diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 1b5f86f..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Build binaries and publish - -on: - push: - branches: [master] - pull_request: - branches: [master] - -env: - CARGO_TERM_COLOR: always - -jobs: - build-linux: - runs-on: node-16 - container: - image: gitea.antonlyap.pp.ua/antonlyap/bliss-rs/node-rust:latest - credentials: - username: antonlyap - password: ${{ secrets.ACCESS_TOKEN }} - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - - x86_64-unknown-linux-musl - - aarch64-unknown-linux-gnu - - aarch64-unknown-linux-musl - - steps: - - name: Set path variable - run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH - - - uses: actions/checkout@v4 - - - uses: actions/cache@v3 - with: - path: target - key: ${{ matrix.target }}-rust-target - - - run: npm install - - run: npm run build -- --release --target ${{ matrix.target }} - - - uses: actions/upload-artifact@v3 - with: - name: binary-${{ matrix.target }} - path: index.node diff --git a/.gitignore b/.gitignore index 1fa996d..fd106ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ target node_modules index.node +index-*.node +bliss-rs-bliss-rs-*.tgz \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 46dd4f7..88420cc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,9 @@ -FROM ghcr.io/catthehacker/ubuntu:js-22.04 +FROM node:20-alpine -RUN apt-get update -RUN apt-get install -yqq wget build-essential yasm libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libavfilter-dev libavdevice-dev libswresample-dev libfftw3-dev libclang-dev ffmpeg +RUN apk add --update wget build-base yasm ffmpeg + +# RUN apt-get update +# RUN apt-get install -yqq wget build-essential yasm libavutil-dev libavcodec-dev libavformat-dev libavfilter-dev libavfilter-dev libavdevice-dev libswresample-dev libfftw3-dev libclang-dev ffmpeg WORKDIR /opt/rust RUN wget https://sh.rustup.rs -O rustup-init.sh diff --git a/index.js b/index.js new file mode 100644 index 0000000..b5a0e16 --- /dev/null +++ b/index.js @@ -0,0 +1,15 @@ +let module; +try { + module = await import('./index.node'); +} catch { + const isLinux = process.platform === 'linux'; + + if (isLinux && process.arch === 'x64') { + module = await import('./index-x86_64-unknown-linux-gnu.node'); + } else if (isLinux && process.arch === 'arm64') { + module = await import('./index-aarch64-unknown-linux-gnu.node'); + } else { + throw new Error('Bliss: unsupported architecture'); + } +} +export const { analyze, analyzeSync } = module; diff --git a/package-lock.json b/package-lock.json index 4acec09..9763328 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,18 @@ "license": "ISC", "dependencies": { "cargo-cp-artifact": "^0.1.8" + }, + "devDependencies": { + "@types/node": "^20.10.5" + } + }, + "node_modules/@types/node": { + "version": "20.10.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.5.tgz", + "integrity": "sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" } }, "node_modules/cargo-cp-artifact": { @@ -19,6 +31,12 @@ "bin": { "cargo-cp-artifact": "bin/cargo-cp-artifact.js" } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true } } } diff --git a/package.json b/package.json index f799585..4555c05 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,24 @@ { - "name": "bliss-rs", + "name": "@bliss-rs/bliss-rs", + "type": "module", "version": "1.0.0", "description": "A fork of the bliss-rs library with Node.js bindings", - "main": "index.node", + "main": "index.js", "types": "index.d.ts", "directories": { "example": "examples" }, + "files": ["index.js", "index.d.ts", "index-*.node"], "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics" }, "author": "antonlyap", - "license": "ISC", + "license": "GPL", "dependencies": { "cargo-cp-artifact": "^0.1.8" + }, + "devDependencies": { + "@types/node": "^20.10.5" } }