Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rebuild #35

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 28 additions & 32 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion deps/transmission
Submodule transmission deleted from ec1b5d
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 21 additions & 4 deletions scripts/build-transmission.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down