From 6e9f4fb5eb83770576e8ea75c1a6648bc9167a7a Mon Sep 17 00:00:00 2001 From: Geoffrey Bonneville Date: Wed, 22 Nov 2023 21:03:48 +0100 Subject: [PATCH] Support rebuild --- .github/workflows/nodejs.yml | 60 ++++++++++++++++------------------- .gitmodules | 3 -- deps/transmission | 1 - package.json | 6 ++-- scripts/build-transmission.js | 25 ++++++++++++--- 5 files changed, 51 insertions(+), 44 deletions(-) delete mode 100644 .gitmodules delete mode 160000 deps/transmission diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 5b5c353..015836a 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -15,38 +15,36 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - - name: Cache vcpkg - uses: actions/cache@v3 - env: - # https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md#environment-variables - VCPKG_INSTALLATION_ROOT: C:\vcpkg - cache-name: cache-vcpkg - with: - path: ${{ env.VCPKG_INSTALLATION_ROOT }} - key: ${{ runner.os }}-${{ env.cache-name }} - if: ${{ matrix.os == 'windows-latest' }} - - name: Install linux deps - run: sudo apt update && sudo apt install -y libcurl4-openssl-dev - if: ${{ matrix.os == 'ubuntu-latest' }} + - name: Cache vcpkg + uses: actions/cache@v3 + env: + # https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md#environment-variables + VCPKG_INSTALLATION_ROOT: C:\vcpkg + cache-name: cache-vcpkg + with: + path: ${{ env.VCPKG_INSTALLATION_ROOT }} + key: ${{ runner.os }}-${{ env.cache-name }} + if: ${{ matrix.os == 'windows-latest' }} + - name: Install linux deps + run: sudo apt update && sudo apt install -y libcurl4-openssl-dev + if: ${{ matrix.os == 'ubuntu-latest' }} - - name: Install windows deps - run: vcpkg install curl openssl --triplet=x64-windows-static - if: ${{ matrix.os == 'windows-latest' }} - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: 18.x - - run: npm run fetch-deps - - run: npm run build-transmission - - run: npm i - - run: npm test - - run: npm run prebuild - - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.os }} - path: ./prebuilds + - name: Install windows deps + run: vcpkg install curl openssl --triplet=x64-windows-static + if: ${{ matrix.os == 'windows-latest' }} + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.x + - run: npm i + - run: npm test + - run: npm run prebuild + - uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }} + path: ./prebuilds build-aarch64: # The host should always be Linux runs-on: ubuntu-latest @@ -71,8 +69,6 @@ jobs: apt install -y nodejs # Build git config --global --add safe.directory '*' - npm run fetch-deps - npm run build-transmission npm i npm test npm run prebuild-arm64 diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 154266d..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "deps/transmission"] - path = deps/transmission - url = https://github.com/G-Ray/transmission.git \ No newline at end of file diff --git a/deps/transmission b/deps/transmission deleted file mode 160000 index ec1b5dd..0000000 --- a/deps/transmission +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ec1b5dde5ab64c77beea367ede1f3b1418e7ce3e diff --git a/package.json b/package.json index a73b9c1..76145fb 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,10 @@ "license": "GPL-3.0", "main": "index.js", "scripts": { - "install": "node-gyp-build", + "install": "node-gyp-build \"node scripts/build-transmission.js\"", "test": "standard && node --test test.js", "prebuild": "prebuildify --napi --strip", - "prebuild-arm64": "prebuildify --napi --strip --arch=arm64", - "fetch-deps": "git submodule update --recursive --init", - "build-transmission": "node ./scripts/build-transmission.js" + "prebuild-arm64": "prebuildify --napi --strip --arch=arm64" }, "dependencies": { "napi-macros": "^2.2.2", diff --git a/scripts/build-transmission.js b/scripts/build-transmission.js index 1ab6af1..881480c 100755 --- a/scripts/build-transmission.js +++ b/scripts/build-transmission.js @@ -29,7 +29,8 @@ const COMMON_CMAKE_FLAGS = [ ] const { env } = process -const buildPath = path.join(__dirname, '../deps/transmission/build') +const transmissionPath = path.join(__dirname, '../deps/transmission') +const buildPath = path.join(transmissionPath, 'build') const runCommand = async (command, args = [], options = {}) => { return new Promise((resolve, reject) => { @@ -39,15 +40,31 @@ const runCommand = async (command, args = [], options = {}) => { }) } -const cmake = (...args) => runCommand('cmake', ...args) +// Clone transmission repo +const clone = async () => { + if (fs.existsSync(transmissionPath)) return -if (!fs.existsSync(buildPath)) { - fs.mkdirSync(buildPath) + await runCommand('git', [ + 'clone', + '-b', + '4.0.3-transmission-native', + '--recurse-submodules', + 'https://github.com/G-Ray/transmission.git', + transmissionPath + ]) } +const cmake = (...args) => runCommand('cmake', ...args) + const build = async () => { const osType = os.type() + await clone() + + if (!fs.existsSync(buildPath)) { + fs.mkdirSync(buildPath) + } + if (osType === 'Linux') { const flags = [ ...COMMON_CMAKE_FLAGS,