forked from buckyos/CYFS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_rust_code_tar.js
More file actions
56 lines (49 loc) · 1.11 KB
/
build_rust_code_tar.js
File metadata and controls
56 lines (49 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const tar = require('tar')
const fs = require('fs');
function getCurrentBuild() {
const execSync = require('child_process').execSync;
const code = execSync('git rev-list --count --first-parent HEAD', {
encoding: 'utf8'
}).trim();
return parseInt(code);
}
const pack_files = [];
const files = fs.readdirSync("../src");
for (const file of files)
{
const path = `../src/${file}`;
if (fs.lstatSync(path).isFile())
{
console.log("file: ", path);
pack_files.push(path);
}
}
const pack_dirs = [
'../src/.cargo',
'../src/3rd',
'../src/component',
'../src/service',
'../src/tools',
];
for (dir of pack_dirs)
{
console.log("dir: ", dir);
}
const all = pack_files.concat(pack_dirs);
const build_dir = `../build`;
if (!fs.existsSync(build_dir)){
fs.mkdirSync(build_dir);
}
const build = getCurrentBuild();
const target = `${build_dir}/cyfs-rust-src.r${build}.tgz`;
tar.c(
{
gzip : 'czf',
file : target,
},
all,
)
.then(_ => {
console.info(`pack complete: ${target}`);
process.exit(0);
});