11
11
// old compiler.ml
12
12
// This will be run in npm postinstall, don't use too fancy features here
13
13
14
- var child_process = require ( 'child_process' )
14
+ var cp = require ( 'child_process' )
15
15
var fs = require ( 'fs' )
16
16
var path = require ( 'path' )
17
- var os = require ( 'os' )
17
+ // var os = require('os')
18
18
19
- var os_type = os . type ( )
19
+ // var os_type = os.type()
20
20
var root_dir = path . join ( __dirname , '..' )
21
21
var lib_dir = path . join ( root_dir , 'lib' )
22
22
var root_dir_config = { cwd : root_dir , stdio : [ 0 , 1 , 2 ] }
@@ -42,7 +42,7 @@ function provideNinja() {
42
42
function build_ninja ( ) {
43
43
console . log ( 'No prebuilt Ninja, building Ninja now' )
44
44
var build_ninja_command = "./configure.py --bootstrap"
45
- child_process . execSync ( build_ninja_command , { cwd : ninja_source_dir , stdio : [ 0 , 1 , 2 ] } )
45
+ cp . execSync ( build_ninja_command , { cwd : ninja_source_dir , stdio : [ 0 , 1 , 2 ] } )
46
46
fs . renameSync ( path . join ( ninja_source_dir , 'ninja' ) , ninja_bin_output )
47
47
console . log ( 'ninja binary is ready: ' , ninja_bin_output )
48
48
}
@@ -51,7 +51,7 @@ function provideNinja() {
51
51
function test_ninja_compatible ( binary_path ) {
52
52
var version ;
53
53
try {
54
- version = child_process . execSync ( JSON . stringify ( binary_path ) + ' --version' , {
54
+ version = cp . execSync ( JSON . stringify ( binary_path ) + ' --version' , {
55
55
encoding : 'utf8' ,
56
56
stdio : [ 'pipe' , 'pipe' , 'ignore' ] // execSync outputs to stdout even if we catch the error. Silent it here
57
57
} ) . trim ( ) ;
@@ -84,7 +84,7 @@ function provideNinja() {
84
84
* raise an exception if not matched
85
85
*/
86
86
function matchedCompilerExn ( ) {
87
- var output = child_process . execSync ( 'ocamlc.opt -v' , { encoding : 'ascii' } )
87
+ var output = cp . execSync ( 'ocamlc.opt -v' , { encoding : 'ascii' } )
88
88
if ( output . indexOf ( "4.02.3" ) >= 0 ) {
89
89
console . log ( output )
90
90
console . log ( "Use the compiler above" )
@@ -102,7 +102,7 @@ function tryToProvideOCamlCompiler() {
102
102
} catch ( e ) {
103
103
console . log ( 'Build a local version of OCaml compiler, it may take a couple of minutes' )
104
104
try {
105
- child_process . execFileSync ( path . join ( __dirname , 'buildocaml.sh' ) )
105
+ cp . execFileSync ( path . join ( __dirname , 'buildocaml.sh' ) )
106
106
} catch ( e ) {
107
107
console . log ( e . stdout . toString ( ) ) ;
108
108
console . log ( e . stderr . toString ( ) ) ;
@@ -140,7 +140,7 @@ function copyBinToExe() {
140
140
*/
141
141
function checkPrebuilt ( ) {
142
142
try {
143
- var version = child_process . execFileSync ( path . join ( lib_dir , 'bsc' + sys_extension ) , [ '-v' ] )
143
+ var version = cp . execFileSync ( path . join ( lib_dir , 'bsc' + sys_extension ) , [ '-v' ] )
144
144
console . log ( "checkoutput:" , String ( version ) )
145
145
return copyBinToExe ( )
146
146
} catch ( e ) {
@@ -150,17 +150,17 @@ function checkPrebuilt() {
150
150
}
151
151
152
152
function buildLibsAndInstall ( ) {
153
- child_process . execFileSync ( ninja_bin_output , [ "-t" , "clean" ] , { cwd : path . join ( root_dir , 'jscomp' , 'runtime' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
154
- child_process . execFileSync ( ninja_bin_output , { cwd : path . join ( root_dir , 'jscomp' , 'runtime' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
155
- child_process . execFileSync ( ninja_bin_output , [ "-t" , "clean" ] , { cwd : path . join ( root_dir , 'jscomp' , 'others' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
156
- child_process . execFileSync ( ninja_bin_output , { cwd : path . join ( root_dir , 'jscomp' , 'others' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
157
- child_process . execFileSync ( ninja_bin_output , [ "-t" , "clean" ] , { cwd : path . join ( root_dir , 'jscomp' , 'stdlib-402' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
158
- child_process . execFileSync ( ninja_bin_output , { cwd : path . join ( root_dir , 'jscomp' , 'stdlib-402' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
153
+ cp . execFileSync ( ninja_bin_output , [ "-t" , "clean" ] , { cwd : path . join ( root_dir , 'jscomp' , 'runtime' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
154
+ cp . execFileSync ( ninja_bin_output , { cwd : path . join ( root_dir , 'jscomp' , 'runtime' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
155
+ cp . execFileSync ( ninja_bin_output , [ "-t" , "clean" ] , { cwd : path . join ( root_dir , 'jscomp' , 'others' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
156
+ cp . execFileSync ( ninja_bin_output , { cwd : path . join ( root_dir , 'jscomp' , 'others' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
157
+ cp . execFileSync ( ninja_bin_output , [ "-t" , "clean" ] , { cwd : path . join ( root_dir , 'jscomp' , 'stdlib-402' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
158
+ cp . execFileSync ( ninja_bin_output , { cwd : path . join ( root_dir , 'jscomp' , 'stdlib-402' ) , stdio : [ 0 , 1 , 2 ] , shell : false } )
159
159
console . log ( 'Build finsihed' )
160
160
if ( is_windows ) {
161
161
build_util . install ( )
162
162
} else {
163
- child_process . execSync ( make + " install" , root_dir_config )
163
+ cp . execSync ( make + " install" , root_dir_config )
164
164
}
165
165
}
166
166
@@ -175,12 +175,14 @@ function provideCompiler() {
175
175
if ( process . env . BS_TRAVIS_CI === "1" ) {
176
176
console . log ( 'Enforcing snapshot in CI mode' )
177
177
if ( fs . existsSync ( path . join ( root_dir , 'jscomp' , 'Makefile' ) ) ) {
178
- child_process . execSync ( "make -C jscomp force-snapshotml" , root_dir_config )
178
+ cp . execSync ( "make -C jscomp force-snapshotml" , root_dir_config )
179
179
} else {
180
180
console . log ( "jscomp/Makefile is missing" )
181
181
}
182
182
}
183
- child_process . execFileSync ( ninja_bin_output , { cwd : lib_dir , stdio : [ 0 , 1 , 2 ] } )
183
+ // Note this ninja file only works under *nix due to the suffix
184
+ // under windows require '.exe'
185
+ cp . execFileSync ( ninja_bin_output , { cwd : lib_dir , stdio : [ 0 , 1 , 2 ] } )
184
186
185
187
}
186
188
}
0 commit comments