Skip to content

Commit a0224c1

Browse files
committed
Build the whole compiler with dune
1 parent 083212f commit a0224c1

File tree

163 files changed

+989
-688122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+989
-688122
lines changed

.gitattributes

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525

2626
env:
2727
OCAMLRUNPARAM: b
28+
DUNE_PROFILE: release
2829

2930
steps:
3031
- name: "Windows: Set git to use LF"
@@ -45,6 +46,22 @@ jobs:
4546
opam-pin: false
4647
opam-depext: false
4748

49+
- name: "Install OPAM dependencies"
50+
run: opam install . --deps-only
51+
52+
- name: "Build compiler"
53+
run: |
54+
opam exec -- dune build
55+
./scripts/copyExes.js
56+
57+
- name: Use Node.js
58+
uses: actions/setup-node@v3
59+
with:
60+
node-version: 16
61+
62+
- name: Install npm packages
63+
run: npm ci --ignore-scripts
64+
4865
- name: "Check if syntax subfolder has changed"
4966
id: syntax-diff
5067
shell: bash
@@ -55,25 +72,13 @@ jobs:
5572
echo "syntax_status=changed" >> $GITHUB_ENV
5673
fi
5774
58-
- name: "Syntax: install OPAM dependencies"
59-
if: env.syntax_status == 'changed'
60-
run: opam install . --deps-only
61-
working-directory: res_syntax
62-
63-
- name: "Syntax: build CLI"
64-
if: env.syntax_status == 'changed'
65-
run: opam exec -- dune build
66-
working-directory: res_syntax
67-
6875
- name: "Syntax: Run roundtrip tests"
6976
if: ${{ env.syntax_status == 'changed' && runner.os != 'Windows' }}
70-
run: opam exec -- make roundtrip-test
71-
working-directory: res_syntax
77+
run: opam exec -- make test-syntax-roundtrip
7278

7379
- name: "Syntax: Run tests (Windows)"
7480
if: ${{ env.syntax_status == 'changed' && runner.os == 'Windows' }}
75-
run: opam exec -- make test
76-
working-directory: res_syntax
81+
run: opam exec -- make test-syntax
7782

7883
# Required for ninja build
7984
- name: "Windows: Use MSVC"
@@ -85,23 +90,22 @@ jobs:
8590
- name: Build ninja
8691
run: node scripts/buildNinjaBinary.js
8792

88-
- name: Use Node.js
89-
uses: actions/setup-node@v3
90-
with:
91-
node-version: 16
93+
- name: Build runtime/stdlib
94+
if: runner.os != 'Windows'
95+
run: |
96+
opam exec -- dune exec -- node ./scripts/ninja.js config
97+
opam exec -- dune exec -- node ./scripts/ninja.js build
9298
93-
- name: NPM install
94-
run: opam exec -- npm ci
95-
env:
96-
RESCRIPT_FORCE_REBUILD: 1
99+
- name: Check for changes in lib folder
100+
run: git diff --exit-code lib/js lib/es6
97101

98102
- name: Run tests
99103
if: runner.os != 'Windows'
100-
run: opam exec -- node scripts/ciTest.js -all
104+
run: opam exec -- dune exec -- node scripts/ciTest.js -all
101105

102106
- name: Run tests (Windows)
103107
if: runner.os == 'Windows'
104-
run: opam exec -- node scripts/ciTest.js -mocha -theme -format
108+
run: opam exec -- dune exec -- node scripts/ciTest.js -mocha -theme -format
105109

106110
- name: Get artifact info
107111
run: node .github/workflows/get_artifact_info.js
@@ -119,19 +123,14 @@ jobs:
119123
name: lib-ocaml
120124
path: lib/ocaml
121125

122-
# Important: the ninja build must run after the artifact upload because for some reason
123-
# the bsc.exe created by the ninja build does not find the Pervasives module.
124-
# So this is run here just to test the normal dev workflow, too.
125-
- name: ninja config
126-
if: runner.os != 'Windows'
127-
run: opam exec -- node ./scripts/ninja.js config
128-
129-
- name: ninja build
130-
if: runner.os != 'Windows'
131-
run: opam exec -- node ./scripts/ninja.js build
132-
133-
- name: Check for changes in lib folder
134-
run: git diff --exit-code lib/js lib/es6
126+
- name: "Upload artifacts: cmi cache"
127+
if: runner.os == 'Linux'
128+
uses: actions/upload-artifact@v3
129+
with:
130+
name: cmij-cache
131+
path: |
132+
lib/cmi_cache.bin
133+
lib/cmj_cache.bin
135134
136135
package:
137136
needs: build
@@ -157,9 +156,6 @@ jobs:
157156
- name: Move artifacts
158157
run: ./scripts/moveArtifacts.sh
159158

160-
- name: Create ninja.tar.gz
161-
run: git -C ninja archive --format=tar.gz HEAD -o ../vendor/ninja.tar.gz
162-
163159
- name: Check artifact list
164160
run: node ./scripts/makeArtifactList.js -check
165161

.github/workflows/get_artifact_info.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
const fs = require("fs");
22
const os = require("os");
3+
const { binDirName } = require("../../scripts/bin_path");
34

4-
const artifactPath =
5-
process.platform === "darwin" && process.arch === "arm64"
6-
? process.platform + process.arch
7-
: process.platform;
8-
5+
const artifactPath = binDirName;
96
const artifactName = "binaries-" + artifactPath;
107

118
// Pass artifactPath and artifactName to subsequent GitHub actions

.gitignore

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -45,39 +45,12 @@ _build
4545
.DS_Store
4646

4747
node_modules
48-
oxml
49-
test.json
50-
jscomp/pre_load.js
51-
boot
5248
*.dump
5349
coverage
54-
*.g.js
55-
ppx_tools/
56-
vendor/ocaml/stdlib/target_camlheader
57-
vendor/ocaml/stdlib/target_camlheaderd
58-
man/
59-
lib/ocaml
60-
*.tgz
61-
bin/*
62-
jscomp/bin/*.exe
63-
64-
# for npm publish
6550
*.exe
6651

67-
!bin/bspack
68-
!/bin/bsb
69-
!/bin/bsc
70-
71-
# This is intentional
72-
# so that `npm install && npm intall -g .`
73-
# the second install would use the cached ninja.exe (instead of being ignored)
74-
#
75-
#ninja
7652
.ninja_log
77-
.ninja_deps
7853
.bsdeps
79-
.bs_dir_cache
80-
8154
.bsbuild
8255
lib/prebuilt.ninja
8356
lib/release.ninja
@@ -96,50 +69,20 @@ jscomp/cppoVendor.ninja
9669
jscomp/cppoEnv.ninja
9770
jscomp/bin/bsb
9871
jscomp/bin/bsc
72+
lib/ocaml
9973
lib/bs
10074
lib/js/jscomp/test
10175
jscomp/build_tests/*/lib/
10276
#ignore temporary directory
10377
*.goog.js
10478
*.jsoo.js
10579
*.so
106-
bin/ninja.exe
10780
tmp/
108-
jscomp/ext/hash_set.ml
109-
jscomp/ext/hash_set_poly.ml
110-
jscomp/ext/hash.ml
111-
jscomp/ext/hash_set_ident.ml
112-
jscomp/ext/hash_ident.ml
113-
jscomp/ext/map_ident.ml
114-
jscomp/ext/set_ident.ml
115-
jscomp/ext/hash_set_int.ml
116-
jscomp/ext/hash_int.ml
117-
jscomp/ext/map_int.ml
118-
jscomp/ext/vec_int.ml
119-
jscomp/ext/ordered_hash_map_local_ident.ml
120-
jscomp/ext/ordered_hash_set_string.ml
121-
jscomp/ext/vec.ml
122-
jscomp/ext/set_int.ml
123-
jscomp/ext/hash_set_string.ml
124-
jscomp/ext/hash_string.ml
125-
jscomp/ext/map_string.ml
126-
jscomp/ext/set_string.ml
127-
jscomp/ext/ext_json_parse.ml
128-
jscomp/syntax/reactjs_jsx_ppx_v2.ml
129-
jscomp/syntax/reactjs_jsx_ppx_v3.ml
130-
jscomp/bin/all_ounit_tests.ml
131-
native/
132-
vendor/ocaml
13381
jscomp/.lsp
134-
.vscode/launch.json
13582
tracing*.json
136-
darwin/bsc
13783
.nyc_output
138-
themes
84+
.vscode/launch.json
13985
.vscode/settings.json
140-
*.output # yacc output
141-
jscomp/ml/parser.output
142-
jscomp/ml/lexer.ml
14386

14487
# opam local switch is stored in `_opam` folder
14588
_opam

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ lib/
33
vendor/
44
ninja/
55
res_syntax/
6+
_build/
67
_opam
78
CHANGELOG.md
89
README.md

Makefile

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,58 @@
11
SHELL = /bin/bash
22

3-
config:
4-
./scripts/ninja.js config
5-
6-
build: config
7-
./scripts/ninja.js build
3+
build:
84
dune build
5+
./scripts/copyExes.js
96

10-
watch: config
7+
watch:
118
dune build -w
129

13-
dce: build
10+
bench:
11+
dune exec -- syntax_benchmarks
12+
13+
dce:
1414
opam exec reanalyze.exe -- -dce-cmt _build
1515

16+
ninja/ninja:
17+
./scripts/buildNinjaBinary.js
18+
1619
test: build
17-
npm test
20+
dune exec -- node scripts/ciTest.js -all
21+
22+
test-syntax: build
23+
dune exec -- syntax_tests
24+
dune exec -- bash ./scripts/test_syntax.sh
25+
# make reanalyze
26+
bash ./scripts/testok.sh
27+
28+
test-syntax-roundtrip: build
29+
dune exec -- syntax_tests
30+
ROUNDTRIP_TEST=1 dune exec -- bash ./scripts/test.sh
31+
# make reanalyze
32+
bash ./scripts/testok.sh
1833

1934
test-gentype: build
2035
make -C jscomp/gentype_tests/typescript-react-example test
2136

2237
test-all: test test-gentype
2338

24-
lib: build
25-
node scripts/install -force-lib-rebuild
39+
# reanalyze:
40+
# reanalyze.exe -set-exit-code -all-cmt _build/default -suppress syntax_tests,syntax_compiler_libs -exclude-paths syntax_compiler_libs
41+
42+
lib: build ninja/ninja
43+
dune exec -- node scripts/ninja.js config
44+
dune exec -- node scripts/ninja.js build
2645

27-
artifacts: lib
46+
package: lib
47+
./scripts/prebuilt.js
2848
./scripts/makeArtifactList.js
2949

50+
# format:
51+
# dune build @fmt --auto-promote
52+
53+
# checkformat:
54+
# dune build @fmt
55+
3056
clean-gentype:
3157
make -C jscomp/gentype_tests/typescript-react-example clean
3258

@@ -38,4 +64,4 @@ clean-all: clean clean-gentype
3864

3965
.DEFAULT_GOAL := build
4066

41-
.PHONY: build clean clean-gentype clean-all config lib test test-all test-gentype
67+
.PHONY: build watch bench dce test test-syntax test-syntax-roundtrip test-gentype test-all lib artifacts clean-gentype clean clean-all

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ ReScript is licensed under LGPL version 3, with relaxed rules about creating and
103103

104104
The ReScript parser (subdirectory `res_syntax`) is licensed under the [MIT License](res_syntax/LICENSE).
105105

106-
`vendor/ocaml.tar.gz` contains the official [OCaml](https://ocaml.org) compiler (version 4.14.0).
107-
Refer to its copyright and license notices for information about its licensing.
108-
109106
The `ninja` subdirectory contains the vendored [ninja](https://github.com/ninja-build/ninja) build system.
110107
Refer to its copyright and license notices for information about its licensing.
111108

docs/Syntax.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ Required:
2222
- OCaml 4.10 or later
2323
- OS: macOS, Linux or Windows
2424

25-
The syntax source code is located in the directory `res_syntax`. All following commands are meant to be executed in that directory.
25+
In the root of the rescript-compiler repo, run
2626

2727
```sh
2828
opam install . --deps-only --with-test
29+
```
30+
31+
To build the syntax sources, run
32+
33+
```sh
2934
make # or "dune build"
3035
```
3136

32-
This will produce the three binaries `rescript`, `tests` and `bench` (with `.exe` extension on Windows).
37+
This will produce the three binaries `res_parser`, `syntax_tests` and `syntax_benchmarks` (with `.exe` extension on Windows).
3338

3439
We only build production binaries, even in dev mode. No need for a separate dev binary when the build is fast enough. Plus, this encourages proper benchmarking of the (production) binary each diff.
3540

dummy.opam

Whitespace-only changes.

dune-project

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1-
(lang dune 2.0)
2-
(name rescript)
3-
1+
(lang dune 2.3)
2+
3+
(name rescript)
4+
5+
(generate_opam_files true)
6+
7+
(license LGPL-3.0-or-later)
8+
9+
(authors "Hongbo Zhang <[email protected]>")
10+
11+
(maintainers "Hongbo Zhang <[email protected]>" "Cristiano Calcagno")
12+
13+
(homepage "https://github.com/rescript-lang/rescript-compiler")
14+
15+
(bug_reports "https://github.com/rescript-lang/rescript-compiler/issues")
16+
17+
(package
18+
(name rescript)
19+
(synopsis "ReScript compiler")
20+
(depends
21+
(ocaml
22+
(>= 4.10))
23+
(ocamlformat
24+
(= 0.22.4))
25+
(cppo
26+
(= 1.6.9))
27+
(js_of_ocaml-compiler
28+
(= 4.0.0))
29+
(reanalyze
30+
(= 2.23.0))
31+
dune))

0 commit comments

Comments
 (0)