Build SRT SDK on install
This commit is contained in:
parent
24e19750bc
commit
5c598a89fa
5 changed files with 55 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
build
|
||||
deps
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@
|
|||
"src/node-srt.cc"
|
||||
],
|
||||
"include_dirs": [
|
||||
"<!@(node -p \"require('node-addon-api').include\")"
|
||||
"<!@(node -p \"require('node-addon-api').include\")",
|
||||
"deps/build/include"
|
||||
],
|
||||
"libraries": [ "/usr/local/lib/libsrt.a" ],
|
||||
"libraries": [ "<(module_root_dir)/deps/build/lib/libsrt.a" ],
|
||||
"dependencies": [
|
||||
"<!(node -p \"require('node-addon-api').gyp\")"
|
||||
],
|
||||
|
|
|
|||
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -265,6 +265,11 @@
|
|||
"assert-plus": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"git-clone": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/git-clone/-/git-clone-0.1.0.tgz",
|
||||
"integrity": "sha1-DXYWN3gJOu9/HDAjjyqe8/B6Lrk="
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
"description": "Nodejs bindings for Secure Reliable Transport SDK",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "node-gyp rebuild",
|
||||
"preinstall": "npm install git-clone && node scripts/build-srt-sdk.js",
|
||||
"install": "node-gyp rebuild -j 8",
|
||||
"clean": "node-gyp clean"
|
||||
},
|
||||
"repository": {
|
||||
|
|
@ -21,6 +22,7 @@
|
|||
"node-gyp": "^7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"git-clone": "^0.1.0",
|
||||
"node-addon-api": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
43
scripts/build-srt-sdk.js
Normal file
43
scripts/build-srt-sdk.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const clone = require('git-clone');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const SRT_REPO = "git@github.com:Haivision/srt.git";
|
||||
const SRT_VERSION = "v1.4.1";
|
||||
|
||||
const depsPath = path.join(__dirname, '../', 'deps');
|
||||
const srtSourcePath = path.join(depsPath, 'srt');
|
||||
const buildDir = path.join(depsPath, 'build');
|
||||
|
||||
if (!fs.existsSync(depsPath)) {
|
||||
fs.mkdirSync(depsPath);
|
||||
}
|
||||
if (!fs.existsSync(buildDir)) {
|
||||
console.log(`Cloning ${SRT_REPO}:${SRT_VERSION}`);
|
||||
clone(SRT_REPO, srtSourcePath, { checkout: SRT_VERSION }, () => {
|
||||
console.log("Running ./configure");
|
||||
const configure = spawnSync('./configure', [ '--prefix', buildDir ], { cwd: srtSourcePath, shell: true } );
|
||||
console.log(configure.stdout.toString());
|
||||
if (configure.status) {
|
||||
console.log(configure.stderr.toString());
|
||||
process.exit(configure.status);
|
||||
}
|
||||
|
||||
console.log("Running make");
|
||||
const make = spawnSync('make', [], { cwd: srtSourcePath, shell: true });
|
||||
console.log(make.stdout.toString());
|
||||
if (make.status) {
|
||||
console.log(make.stderr.toString());
|
||||
process.exit(make.status);
|
||||
}
|
||||
|
||||
console.log("Running make install");
|
||||
const install = spawnSync('make', [ 'install' ], { cwd: srtSourcePath, shell: true });
|
||||
console.log(install.stdout.toString());
|
||||
if (install.status) {
|
||||
console.log(install.stderr.toString());
|
||||
process.exit(install.status);
|
||||
}
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue