Skip to content

Commit

Permalink
Support rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ray committed Nov 22, 2023
1 parent 1758aff commit a4a937a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
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 ./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
23 changes: 19 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,29 @@ 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',
'--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

0 comments on commit a4a937a

Please sign in to comment.