@@ -24,8 +24,6 @@ if (supported_os.indexOf(process.platform) < 0) {
24
24
}
25
25
var is_windows = process . platform === "win32" ;
26
26
27
-
28
-
29
27
var ninja_bin_output = path . join ( root_dir , process . platform , "ninja.exe" ) ;
30
28
31
29
/**
@@ -99,13 +97,70 @@ function ensureExists(dir) {
99
97
}
100
98
}
101
99
100
+ /**
101
+ * @param {string } stdlib
102
+ */
103
+ function install ( stdlib ) {
104
+ installDirBy ( runtime_dir , ocaml_dir , function ( file ) {
105
+ var y = path . parse ( file ) ;
106
+ return y . name === "js" || y . ext . includes ( "cm" ) ;
107
+ } ) ;
108
+ installDirBy ( others_dir , ocaml_dir , function ( file ) {
109
+ var y = path . parse ( file ) ;
110
+ return y . ext === ".ml" || y . ext === ".mli" || y . ext . includes ( "cm" ) ;
111
+ } ) ;
112
+ var stdlib_dir = path . join ( jscomp_dir , stdlib ) ;
113
+ installDirBy ( stdlib_dir , ocaml_dir , function ( file ) {
114
+ var y = path . parse ( file ) ;
115
+ return y . ext === ".ml" || y . ext === ".mli" || y . ext . includes ( "cm" ) ;
116
+ } ) ;
117
+ }
118
+
119
+ /**
120
+ *
121
+ * @param {string } sys_extension
122
+ *
123
+ */
124
+ function copyPrebuiltCompilersForUnix ( sys_extension ) {
125
+ var output = `
126
+ rule cp
127
+ command = cp $in $out
128
+ ` ;
129
+ output += preBuiltCompilerArtifacts
130
+ . map ( function ( x ) {
131
+ return `build ${ x } .exe: cp ${ x } ${ sys_extension } ` ;
132
+ } )
133
+ . join ( "\n" ) ;
134
+ output += "\n" ;
135
+
136
+ var filePath = path . join ( lib_dir , "copy.ninja" ) ;
137
+ fs . writeFileSync ( filePath , output , "ascii" ) ;
138
+ cp . execFileSync ( ninja_bin_output , [ "-f" , "copy.ninja" ] , {
139
+ cwd : lib_dir ,
140
+ stdio : [ 0 , 1 , 2 ]
141
+ } ) ;
142
+ fs . unlinkSync ( filePath ) ;
143
+ }
102
144
145
+ /**
146
+ *
147
+ * @param {string } sys_extension
148
+ *
149
+ */
150
+ function copyPrebuiltCompilersForWindows ( sys_extension ) {
151
+ preBuiltCompilerArtifacts . forEach ( function ( x ) {
152
+ fs . copyFileSync (
153
+ path . join ( lib_dir , `${ x } ${ sys_extension } ` ) ,
154
+ path . join ( lib_dir , `${ x } .exe` )
155
+ ) ;
156
+ } ) ;
157
+ }
103
158
104
159
/**
105
160
* @returns {string|undefined }
106
161
*/
107
162
function checkPrebuiltBscCompiler ( ) {
108
- if ( process . env . BS_TRAVIS_CI ) {
163
+ if ( process . env . BS_CI ) {
109
164
return ;
110
165
}
111
166
try {
@@ -144,7 +199,7 @@ stdlib = ${stdlib}
144
199
subninja runtime/release.ninja
145
200
subninja others/release.ninja
146
201
subninja $stdlib/release.ninja
147
- ${ process . env . BS_TRAVIS_CI ? "subninja test/build.ninja\n" : "\n" }
202
+ ${ process . env . BS_CI ? "subninja test/build.ninja\n" : "\n" }
148
203
build all: phony runtime others $stdlib
149
204
` ;
150
205
var filePath = path . join ( jscomp_dir , "release.ninja" ) ;
@@ -156,7 +211,7 @@ build all: phony runtime others $stdlib
156
211
shell : false
157
212
} ) ;
158
213
var buildArgs = [ "-f" , "release.ninja" ] ;
159
- if ( process . env . BS_TRAVIS_CI ) {
214
+ if ( process . env . BS_CI ) {
160
215
buildArgs . push ( "--verbose" ) ;
161
216
}
162
217
cp . execFileSync ( ninja_bin_output , buildArgs , {
@@ -203,11 +258,11 @@ function provideCompiler() {
203
258
204
259
var filePath = path . join ( lib_dir , "release.ninja" ) ;
205
260
fs . writeFileSync ( filePath , releaseNinja , "ascii" ) ;
206
- cp . execFileSync ( ninja_bin_output , [ "-f" , "release.ninja" , "-t" , "clean" ] , {
261
+ cp . execFileSync ( ninja_bin_output , [ "-f" , "release.ninja" , "-t" , "clean" ] , {
207
262
cwd : lib_dir ,
208
263
stdio : [ 0 , 1 , 2 ]
209
264
} ) ;
210
- cp . execFileSync ( ninja_bin_output , [ "-f" , "release.ninja" , "-v" ] , {
265
+ cp . execFileSync ( ninja_bin_output , [ "-f" , "release.ninja" , "-v" ] , {
211
266
cwd : lib_dir ,
212
267
stdio : [ 0 , 1 , 2 ]
213
268
} ) ;
@@ -224,5 +279,5 @@ var stdlib = ocamlVersion.includes("4.02") ? "stdlib-402" : "stdlib-406";
224
279
225
280
if ( process . env . BS_TRAVIS_CI ) {
226
281
buildLibs ( stdlib ) ;
227
- require ( ' ./installUtils.js' ) . install ( )
282
+ require ( " ./installUtils.js" ) . install ( ) ;
228
283
}
0 commit comments