Skip to content

Commit eb832d6

Browse files
committedOct 27, 2016
try to unify build experience
1 parent 94ab5e5 commit eb832d6

File tree

7 files changed

+1509
-998
lines changed

7 files changed

+1509
-998
lines changed
 

‎jscomp/bin/bspack.ml

+1,421-939
Large diffs are not rendered by default.

‎jscomp/bin/bspack.mllib

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
../ocaml/utils/terminfo
22
../ocaml/utils/warnings
33
../ocaml/parsing/location
4-
common/bs_exception
5-
../ocaml/utils/clflags
64
../ocaml/parsing/asttypes
75
../ocaml/utils/misc
86
../ocaml/parsing/longident
97
../ocaml/parsing/parsetree
10-
depends/depend
8+
depends/binary_ast
119
ext/ext_pervasives
1210
ext/ext_bytes
1311
ext/ext_string
1412
ext/literals
1513
ext/ext_filename
14+
ext/string_map
15+
depends/binary_cache
16+
common/bs_exception
17+
../ocaml/utils/clflags
18+
../ocaml/parsing/depend
1619
ext/ext_format
1720
ext/ext_list
1821
common/js_config
19-
ext/string_map
2022
depends/ast_extract
2123
ext/ext_io
2224
../ocaml/parsing/docstrings

‎jscomp/bspack_main.ml

+2-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ let specs : (string * Arg.spec * string) list =
239239
"-o", (Arg.String set_output),
240240
" Set output file (default to stdout)" ;
241241
"-with-header", (Arg.Set header_option),
242-
" with header of time stamp(can also be set with env variable BS_RELEASE_BUILD)" ;
242+
" with header of time stamp" ;
243243
"-bs-exclude-I", (Arg.String add_exclude),
244244
" don't read and pack such modules from -I (in the future, we should detect conflicts in mllib or commandline) "
245245
;
@@ -266,8 +266,7 @@ let () =
266266
| Some file -> open_out file) in
267267
let emit_header out_chan =
268268
let local_time = Unix.(localtime (gettimeofday ())) in
269-
(if !header_option (* || *)
270-
(* (try ignore (Sys.getenv "BS_RELEASE_BUILD") ; true with _ -> false) *)
269+
(if !header_option
271270
then
272271
output_string out_chan
273272
(Printf.sprintf "(** Generated by bspack %02d/%02d-%02d:%02d *)\n"

‎jscomp/core.mllib

-11
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ ident_util
66
idents_analysis
77
config_util
88
bs_conditional_initial
9-
109
ocaml_options
1110
ocaml_batch_compile
1211
ocaml_parse
13-
1412
lam
1513
lam_iter
1614
lam_print
17-
1815
lam_compile_env
1916
lam_dispatch_primitive
2017
lam_stats
@@ -34,7 +31,6 @@ lam_compile_global
3431
lam_compile_primitive
3532
lam_beta_reduce
3633
lam_beta_reduce_util
37-
3834
lam_compile_external_call
3935
lam_compile_group
4036
lam_inline_util
@@ -43,12 +39,8 @@ lam_module_ident
4339
lam_dce
4440
lam_analysis
4541
lam_group
46-
47-
48-
4942
j
5043
js_ast_util
51-
5244
js_arr
5345
js_program_loader
5446
js_output
@@ -62,7 +54,6 @@ js_pass_flatten_and_mark_dead
6254
js_pass_scope
6355
js_call_info
6456
js_pass_debug
65-
6657
js_of_lam_option
6758
js_of_lam_float_record
6859
js_of_lam_record
@@ -87,6 +78,4 @@ js_exp_make
8778
js_stmt_make
8879
js_cmj_datasets
8980
js_main
90-
91-
9281
lam_exit_code

‎scripts/buildocaml.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
4+
export BS_RELEASE_BUILD=1
5+
export OCAMLPARAM='_,bin-annot=1'
6+
export OCAMLRUNPARAM=b
7+
8+
if [ $BS_TRAVIS_CI ]
9+
then
10+
git submodule update --init --recursive
11+
OCAML=ocaml
12+
else
13+
OCAML=ocaml_src
14+
if [ -f "ocaml.tar.gz" ]
15+
then
16+
echo "ocaml.tar.gz already exists"
17+
rm -rf $OCAML
18+
mkdir -p $OCAML
19+
tar -zxvf ./ocaml.tar.gz -C $OCAML
20+
else
21+
echo "creating ocaml from github"
22+
git clone -b master --depth 1 https://github.com/bloomberg/ocaml $OCAML
23+
fi
24+
fi
25+
26+
cd $OCAML && ./configure -prefix $(dirname $(pwd)) -no-ocamldoc -no-ocamlbuild -no-shared-libs -no-curses -no-graph -no-pthread -no-debugger && make -j9 world.opt && make install && cd ..

‎scripts/config.js

+54-17
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,73 @@ function getConfigOutput(){
9898
}
9999

100100

101-
var config_map = getConfigOutput()
102-
console.log('config_map',config_map)
103101

104-
if(config_map && config_map.version.indexOf('4.02.3') >= 0 ){
105-
//
106-
if (is_windows){
107-
process.env.WIN32='1'
108-
}
109-
var whole_compiler_config = path.join(jscomp, 'bin', 'config_whole_compiler.ml' )
110-
var content = fs.readFileSync(whole_compiler_config,'utf8')
111-
var generated = content.replace(/%%(\w+)%%/g,
112-
function(_whole,p0){
113-
if(p0 === "LIBDIR"){
114-
//Escape
115-
var origin_path = path.join(working_dir,'lib','ocaml')
116-
return JSON.stringify(origin_path).slice(1,-1)
102+
103+
function patch_config(config_map){
104+
var whole_compiler_config = path.join(jscomp, 'bin', 'config_whole_compiler.ml')
105+
var content = fs.readFileSync(whole_compiler_config, 'utf8')
106+
var generated = content.replace(/%%(\w+)%%/g,
107+
function (_whole, p0) {
108+
if (p0 === "LIBDIR") {
109+
//Escape
110+
var origin_path = path.join(working_dir, 'lib', 'ocaml')
111+
return JSON.stringify(origin_path).slice(1, -1)
117112
}
118-
else{
113+
else {
119114
return config_map[map[p0]]
120115
}
121116
})
122117

123118
fs.writeFileSync(whole_compiler_config, generated, 'utf8')
124-
var working_config = {cwd : jscomp , stdio : [0,1,2]}
119+
}
120+
function install_bsc() {
121+
122+
123+
if (is_windows) {
124+
process.env.WIN32 = '1'
125+
}
126+
var working_config = { cwd: jscomp, stdio: [0, 1, 2] }
125127
console.log("Build the compiler and runtime .. ")
126128
child_process.execSync("make dist-world", working_config)
127129
console.log("Installing")
128130
child_process.execSync('make VERBOSE=true install', working_config)
129131

132+
}
133+
/*
134+
function install_built_in_compiler(){
135+
var env = process.env;
136+
env.BS_RELEASE_BUILD = 1;
137+
// env.OCAMLPARAM='_,bin-annot=1'
138+
var ocaml_build_dir;
139+
if(env.BS_TRAVIS_CI){
140+
ocaml_build_dir = path.join(__dirname,'..','ocaml')
141+
child_process.execSync('git submodule update --init --recursive')
142+
143+
}else{
144+
ocaml_build_dir = path.join(__dirname,'..','ocaml_src')
145+
ocaml_tar = path.join(__dirname,'..','ocaml.tar.gz')
146+
if(fs.existsSync(ocaml_tar)){
147+
console.log('ocaml.tar.gz already exists')
148+
child_process.execSync("rm -rf " + ocaml_build_dir + " && mkdir -p " + ocaml_build_dir + )
149+
}
150+
}
151+
}
152+
*/
153+
154+
155+
var config_map = getConfigOutput()
156+
console.log('config_map',config_map)
157+
158+
if(config_map && config_map.version.indexOf('4.02.3') >= 0 ){
159+
patch_config(config_map);
160+
install_bsc()
130161
}else{
131162
// No compiler existed
163+
child_process.execSync(path.join(__dirname,'buildocaml.sh'))
164+
process.env.PATH = path.join(__dirname,'..','bin') + path.delimiter + process.env.PATH
165+
console.log('configure again with local ocaml installed')
166+
config_map = getConfigOutput()
167+
console.log('config_map', config_map)
168+
patch_config(config_map)
132169
child_process.execSync(path.join(__dirname,'postinstall.sh'))
133170
}

‎scripts/postinstall.sh

-24
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,6 @@
22
set -e
33

44
export BS_RELEASE_BUILD=1
5-
export OCAMLPARAM='_,bin-annot=1'
6-
export OCAMLRUNPARAM=b
7-
8-
if [ $BS_TRAVIS_CI ]
9-
then
10-
git submodule update --init --recursive
11-
OCAML=ocaml
12-
else
13-
OCAML=ocaml_src
14-
if [ -f "ocaml.tar.gz" ]
15-
then
16-
echo "ocaml.tar.gz already exists"
17-
rm -rf $OCAML
18-
mkdir -p $OCAML
19-
tar -zxvf ./ocaml.tar.gz -C $OCAML
20-
else
21-
echo "creating ocaml from github"
22-
git clone -b master --depth 1 https://github.com/bloomberg/ocaml $OCAML
23-
fi
24-
fi
25-
26-
cd $OCAML && ./configure -prefix $(dirname $(pwd)) -no-ocamldoc -no-ocamlbuild -no-shared-libs -no-curses -no-graph -no-pthread -no-debugger && make -j9 world.opt && make install && cd ..
27-
28-
295
export PATH=$(pwd)/bin:$PATH
306

317
if [ $BS_TRAVIS_CI ]

0 commit comments

Comments
 (0)
Please sign in to comment.