git ssb

39+

cel / git-ssb



Tree: 2e0a6c645c51a858757a8ba0e7568d31afaf72ab

Files: 2e0a6c645c51a858757a8ba0e7568d31afaf72ab / build.js

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

Built with git-ssb-web