forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprebuilt.js
41 lines (37 loc) · 1.18 KB
/
prebuilt.js
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
//@ts-check
var cp = require('child_process')
var path = require('path')
var {sys_extension, is_windows} = require('./config.js')
var root = path.join(__dirname, '..')
var root_config = { cwd: root, stdio: [0, 1, 2] }
process.env.BS_RELEASE_BUILD = 'true'
var version = require('./buildocaml.js').getVersionPrefix()
var fs = require('fs')
var hostPlatform = 'darwin'
function buildCompiler() {
var prebuilt = 'prebuilt.ninja'
var content = `
ocamlopt = ../native/${version}/bin/ocamlopt.opt
ext = ${sys_extension}
INCL = ${version}
include body.ninja
`
fs.writeFileSync(path.join(root,'lib',prebuilt),content,'ascii')
cp.execSync(`ninja -C lib -f ${prebuilt} -t clean && ninja -C lib -f ${prebuilt}`,root_config)
}
if(!is_windows){
require('./ninja.js').updateRelease()
}
var os = require('os')
function createOCamlTar(){
if(os.platform ()=== hostPlatform){
cp.execSync(`git -C ocaml status -uno`, { cwd: root, stdio: [0, 1, 2] })
cp.execSync(`git -C ocaml archive --format=tar.gz HEAD -o ../ocaml.tar.gz`,
{ cwd: root, stdio: [0, 1, 2] }
)
fs.copyFileSync(path.join(root,'ocaml','VERSION'),path.join(root,'OCAML_VERSION'))
}
}
createOCamlTar()
buildCompiler()
//