Skip to content

Commit d63640c

Browse files
authored
Merge pull request #621 from bloomberg/better_ocaml_pack_for_release
provide self contained ppx for merlin (fix #199)
2 parents 45273a8 + 952b2ce commit d63640c

37 files changed

+27156
-19938
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ _build
3636

3737
bsc
3838
bscc
39+
bsppx
3940
jscomp/tools/ocamlpack*
4041

4142
.idea
@@ -56,6 +57,7 @@ bin/*
5657

5758
# for npm publish
5859
!bin/bsc
60+
!bin/bsppx
5961
!bin/ocaml
6062
!bin/ocamldep
6163
!bin/ocamldep.opt

bin/bsppx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
echo "PLEASE RUN NPM POSTINSTALL TO GET BSC BINARY"
3+
exit 2

jscomp/Makefile

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ lam_fold.ml: lambda_fold.mlp lambda.mlp
2020
@echo "Regenrating lambda_map.ml"
2121
$(CAMLP4OF) -filter map -filter trash -impl $< -printer o > $@
2222

23-
./bin/bsc: _build/ext/ext.cmxa _build/common/common.cmxa _build/syntax/syntax.cmxa _build/core.cmxa
23+
./bin/bsc: _build/ext/ext.cmxa _build/common/common.cmxa _build/depends/depends.cmxa _build/syntax/syntax.cmxa _build/core.cmxa
2424
echo "Linking"
2525
$(NATIVE) -g -linkall -o $@ -I +compiler-libs ocamlcommon.cmxa $^ 2>>build.compile
2626
# Note: we can remove main.cmx since we have js_main.cmx which use [js_implementation.implementation],
@@ -40,30 +40,41 @@ release:snapshot
4040
$(NATIVE) -w -a -I bin -I +compiler-libs ocamlcommon.cmxa unix.cmxa $^ -o $@
4141

4242
## order matters
43-
_build/ocamlpack: _build/ext/ext.cmxa _build/common/common.cmxa _build/syntax/pack.cmxa _build/syntax/ocaml_pack_main.cmx
43+
_build/ocamlpack: _build/ext/ext.cmxa _build/common/common.cmxa _build/depends/depends.cmxa _build/ocamlpack_main.cmx
4444
$(NATIVE) -I +compiler-libs ocamlcommon.cmxa unix.cmxa $^ -o $@
4545

4646
snapshot: ./bin/ocamlpack snapshotcmj
4747
$(MAKE) snapshotml
4848

49-
snapshotml:./bin/ocamlpack ./bin/compiler.mllib
49+
snapshotml:./bin/ocamlpack ./bin/compiler.mllib ./bin/bs_ppx.mllib
5050
@echo "Snapshot ml"
5151
$< bin/compiler.mllib > bin/compiler.ml
52+
$< bin/bs_ppx.mllib > bin/bs_ppx.ml
5253
snapshotcmj:
5354
@echo "Collecting cmj files"
5455
ocamlbuild -cflags $(OCAMLBUILD_CFLAGS) -lflags -I,+compiler-libs,ocamlcommon.cmxa js_pack.native --
5556

57+
bootocamlpack: ./bin/ocamlpack
58+
@echo "Bootstrap ocamlpack"
59+
./bin/ocamlpack bin/ocamlpack.mllib > ./bin/ocamlpack.ml
60+
$(NATIVE) -w -40 -I +compiler-libs unix.cmxa ocamlcommon.cmxa -I bin bin/ocamlpack.mli bin/ocamlpack.ml -o bin/ocamlpack
61+
@echo "Using the bootstrapped ocamlpack to genreate new ocamlpack.ml: `date`"
62+
./bin/ocamlpack bin/ocamlpack.mllib > ./bin/ocamlpack.ml
63+
@echo "Bootstrap seems finished, please check diffs in ocamlpack"
64+
git diff bin/ocamlpack.ml
5665

5766
releasebuild:
5867
@echo "Make release compiler"
5968
$(NATIVE) -g -inline 1000 -linkall -w -a -I +compiler-libs -I bin ocamlcommon.cmxa bin/compiler.mli bin/compiler.ml -o bin/bsc
6069

70+
@echo "Make release ppx"
71+
$(NATIVE) -g -inline 1000 -linkall -w -a -I +compiler-libs -I bin ocamlcommon.cmxa bin/bs_ppx.mli bin/bs_ppx.ml -o bin/bsppx
6172
stdlib:
6273
cd stdlib && ./build.sh
6374

6475
world:
6576
@echo "Making compiler"
66-
$(NATIVE) -g -inline 1000 -linkall -w -a -I +compiler-libs -I bin ocamlcommon.cmxa bin/compiler.mli bin/compiler.ml -o bin/bsc
77+
$(MAKE) releasebuild
6778
@echo "Making compiler finished"
6879

6980
@echo "Making stdlib cmis"
@@ -91,23 +102,22 @@ world-test:
91102

92103
travis-world-test:./bin/ocamlpack
93104
@echo "Generating the compiler"
94-
rm -f bin/compiler.ml
95-
./bin/ocamlpack ./bin/compiler.mllib > bin/compiler.ml
105+
rm -f bin/compiler.ml bin/bs_ppx.ml
106+
$(MAKE) snapshotml
96107
@echo "Generating the compiler finished"
97108
$(MAKE) world-test
98109

99110
# no depend on ./bin/ocamlpack ./bin/bsc
100111
# since in npm mode, they are generated from a single file
101112
install:
102-
cp ./bin/bsc ../bin/
103-
cp ./runtime/*.cmt* ../lib/ocaml/
104-
cp ./runtime/*.cmj* ../lib/ocaml/
105-
cp ./runtime/js.cmi ./runtime/js_array.cmi ./runtime/js_string.cmi ./runtime/js_re.cmi ./runtime/js_unsafe.cmi ../lib/ocaml/
106-
cp ./stdlib/*.cm* ../lib/ocaml/
107-
cp ./others/*.cm* ../lib/ocaml/
108-
TMP_OCAMLLIB=$(shell ocamlopt.opt -where)
113+
cp ./bin/bsc ./bin/bsppx ../bin/
114+
cp ./runtime/*.cmt* ./runtime/*.cmj* ./stdlib/*.cm* ./others/*.cm* ../lib/ocaml/
115+
cp ./runtime/js.ml ./runtime/js.cmi ./runtime/js_array.mli ./runtime/js_array.ml ./runtime/js_array.cmi ./runtime/js_string.ml ./runtime/js_string.mli ./runtime/js_string.cmi ./runtime/js_re.ml ./runtime/js_re.mli ./runtime/js_re.cmi ./runtime/js_unsafe.cmi ../lib/ocaml/
116+
117+
109118

110119

120+
# TMP_OCAMLLIB=$(shell ocamlopt.opt -where)
111121
# big-world:bin/big_compiler.ml bin/big_compiler.mli
112122
# @echo "Making compiler"
113123
# ocamlopt.opt -g -inline 1000 -linkall -w -a -I bin bin/big_compiler.mli bin/big_compiler.ml -o bin/bsc
@@ -125,7 +135,7 @@ TMP_OCAMLLIB=$(shell ocamlopt.opt -where)
125135

126136

127137
.PHONY: stdlib
128-
.PHONY: test quicktest release snapshot snapshotcmj
138+
.PHONY: test quicktest release snapshot snapshotcmj releasebuild
129139

130140

131141

jscomp/_tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<ext>:include
44
<syntax>:include
55
<common>:include
6+
<depends>:include
67
true: warn(-40)
78
true: debug
89
true: -traverse

0 commit comments

Comments
 (0)