Files: 2e0a6c645c51a858757a8ba0e7568d31afaf72ab / build.js
1798 bytesRaw
1 | var os = require('os') |
2 | var proc = require('child_process') |
3 | var path = require('path') |
4 | var fs = require('fs') |
5 | var mkdirp = require('mkdirp') |
6 | var pkgJson = require('./package') |
7 | |
8 | var platform = process.argv[2] || os.platform() |
9 | var arch = process.argv[3] || os.arch() |
10 | var abi = process.argv[4] || process.versions.modules |
11 | var nodeVersion = process.argv[5] || pkgJson.nodeVersion |
12 | var armv = process.argv[6] || (arch === 'arm' && process.config.variables.arm_version) || '' |
13 | if (armv) armv = 'v' + armv |
14 | console.log('platform:', platform, 'arch:', arch, 'abi:', abi, 'armv:', armv, |
15 | 'node:', nodeVersion) |
16 | process.chdir(__dirname) |
17 | mkdirp.sync('dist') |
18 | |
19 | function cp(src, dest) { |
20 | proc.execFileSync('/bin/cp', ['-v', src, dest], {'stdio': 'inherit'}) |
21 | } |
22 | |
23 | var prebuildsDir = 'node_modules/sodium-native/prebuilds/' + platform + '-' + arch |
24 | console.log('Copying binaries...') |
25 | var libSrc = 'libsodium.' + |
26 | (platform === 'darwin' ? 'dylib' : '.so.' + pkgJson.libsodiumVersion) |
27 | var libDest = 'dist/libsodium.' + (platform === 'darwin' ? 'dylib' : 'so') |
28 | cp(path.join(prebuildsDir, libSrc, libDest) |
29 | // pkg doesn't bundle files with .node extension |
30 | cp(path.join(prebuildsDir, 'node.abi' + abi + '.node'), |
31 | 'dist/sodium.node.bin') |
32 | cp('bin/git-remote-ssb', 'dist/') |
33 | |
34 | console.log('Building pkg executable...') |
35 | var pkg = proc.spawnSync('pkg', [ |
36 | 'bin/git-ssb', |
37 | '-c', 'package.json', |
38 | '--public', |
39 | '-t', 'node' + nodeVersion + '-' + platform + '-' + arch + armv, |
40 | '-o', 'dist/git-ssb' |
41 | ], {stdio: 'inherit'}) |
42 | if (pkg.status) process.exit(1) |
43 | |
44 | process.chdir('dist') |
45 | console.log('Compressing...') |
46 | var tarFile = 'git-ssb-' + pkgJson.version + '-' + platform + '-' + arch + armv + '.tgz' |
47 | proc.spawnSync('tar', [ |
48 | '-czvf', |
49 | tarFile, |
50 | 'git-remote-ssb', |
51 | 'git-ssb' |
52 | ], {stdio: 'inherit'}) |
53 | |
54 | console.log('Built:', tarFile) |
55 |
Built with git-ssb-web