-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.mjs
94 lines (78 loc) · 2.2 KB
/
build.mjs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import child_process from "node:child_process";
import fs from "node:fs";
const pkg = JSON.parse( fs.readFileSync( "./package.json", {encoding:"utf8"} ) );
//await import( "./package.json" , {assert:{ type: 'json' }} );
let config = "Release"
let target = (pkg.name === "@d3x0r/sack-gui")?"gui":"vfs";
let GUI = (pkg.name === "@d3x0r/sack-gui")?1:0;
let skipConfigure = false;
let arg = 2;
const moreopts = [];
for( arg = 2; arg < process.argv.length; arg++ ) {
if( process.argv[arg] === "reldeb")
config = "RelWithDebInfo";
else if( process.argv[arg] === "debug" )
config = "Debug";
else if( process.argv[arg] === "release" )
config = "Release";
else if( process.argv[arg] === "gui") {
target = "gui";
GUI = 1;
} else if( process.argv[arg] === "nwjs")
moreopts.push( "--CDHOST_NWJS=1" );
else if( process.argv[arg] === "build" ) {
skipConfigure = true;
}
}
const platform = process.platform;
if( !skipConfigure )
switch( platform ) {
case "win32":
{
const proc = child_process.spawn( "npx"
, ["cmake-js", "-t", "ClangCL", "--CDMAKE_GUI="+GUI
, moreopts.join(' ')
, "--config", config, "configure"]
, {stdio:"pipe", shell:true}
);
proc.stdout.pipe( process.stdout );
proc.stderr.pipe( process.stderr );
proc.on( "exit", (a,b)=>{
if( a ) process.exit(a);
else runBuild();
} );
//runBuild();
}
break;
case "linux":
//child_process.execSync( "npm run build-"+target+"-"+config+"config" );
{
const proc = child_process.spawn( `npx cmake-js --CDMAKE_GUI=${GUI} ${moreopts.join(' ')} --config ${config} configure`
, {shell:true, stdio:"pipe"}
);
proc.stdout.pipe( process.stdout );
proc.stderr.pipe( process.stderr );
proc.on( "exit", (a,b)=>{
if( a ) process.exit(a);
else runBuild();
console.log( "build exitged?" );
} );
}
break;
default:
console.error( "Platform not handled to build:", platform );
process.exit(1);
break;
}
else
runBuild();
function runBuild() {
const proc = child_process.spawn( `npx cmake-js build`, ["--config", config]
, {shell:true, stdio:"pipe"}
);
proc.stdout.pipe( process.stdout );
proc.stderr.pipe( process.stderr );
proc.on( "exit", (a,b)=>{
if( a ) process.exit(a);
} );
}