Skip to content

Commit 47394b3

Browse files
committed
Enable building the whole compiler with dune
1 parent b55d5e7 commit 47394b3

File tree

2,031 files changed

+497
-32463
lines changed

Some content is hidden

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

2,031 files changed

+497
-32463
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,18 @@ jobs:
5353
- name: "Syntax: install OPAM dependencies"
5454
if: env.syntax_status == 'changed'
5555
run: opam install . --deps-only
56-
working-directory: res_syntax
5756

5857
- name: "Syntax: build CLI"
5958
if: env.syntax_status == 'changed'
6059
run: opam exec -- dune build
61-
working-directory: res_syntax
6260

6361
- name: "Syntax: Run roundtrip tests"
6462
if: ${{ env.syntax_status == 'changed' && runner.os != 'Windows' }}
65-
run: opam exec -- make roundtrip-test
66-
working-directory: res_syntax
63+
run: opam exec -- make test-syntax-roundtrip
6764

6865
- name: "Syntax: Run tests (Windows)"
6966
if: ${{ env.syntax_status == 'changed' && runner.os == 'Windows' }}
70-
run: opam exec -- make test
71-
working-directory: res_syntax
67+
run: opam exec -- make test-syntax
7268

7369
# Required for ninja build
7470
- name: "Windows: Use MSVC"
@@ -77,14 +73,14 @@ jobs:
7773
with:
7874
arch: x64
7975

80-
- name: Build ninja
81-
run: node scripts/buildNinjaBinary.js
82-
8376
- name: Use Node.js
8477
uses: actions/setup-node@v3
8578
with:
8679
node-version: 16
8780

81+
- name: Build ninja
82+
run: node scripts/buildNinjaBinary.js
83+
8884
- name: NPM install
8985
run: opam exec -- npm ci
9086
env:

Makefile

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,52 @@
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
95

10-
watch: config
6+
watch:
117
dune build -w
128

9+
bench: build
10+
dune exec -- syntax_benchmarks
11+
1312
dce: build
1413
opam exec reanalyze.exe -- -dce-cmt _build
1514

1615
test: build
1716
npm test
1817

18+
test-syntax: build
19+
dune exec -- syntax_tests
20+
dune exec -- bash ./scripts/test_syntax.sh
21+
# make reanalyze
22+
bash ./scripts/testok.sh
23+
24+
test-syntax-roundtrip: build
25+
dune exec -- syntax_tests
26+
ROUNDTRIP_TEST=1 dune exec -- bash ./scripts/test.sh
27+
# make reanalyze
28+
bash ./scripts/testok.sh
29+
1930
test-gentype: build
2031
make -C jscomp/gentype_tests/typescript-react-example test
2132

2233
test-all: test test-gentype
2334

35+
# reanalyze: build
36+
# reanalyze.exe -set-exit-code -all-cmt _build/default -suppress syntax_tests,syntax_compiler_libs -exclude-paths syntax_compiler_libs
37+
2438
lib: build
2539
node scripts/install -force-lib-rebuild
2640

2741
artifacts: lib
2842
./scripts/makeArtifactList.js
2943

44+
# format:
45+
# dune build @fmt --auto-promote
46+
47+
# checkformat:
48+
# dune build @fmt
49+
3050
clean-gentype:
3151
make -C jscomp/gentype_tests/typescript-react-example clean
3252

@@ -38,4 +58,4 @@ clean-all: clean clean-gentype
3858

3959
.DEFAULT_GOAL := build
4060

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(dirs jscomp res_syntax)
1+
(dirs jscomp)

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))

jscomp/bsb/dune

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(library
2+
(name bsb)
3+
(wrapped false)
4+
(flags
5+
(:standard -w +a-d-4-9-40-41-42-70))
6+
(libraries common ext str unix))

jscomp/bsb_exe/dune

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(executable
2+
(name rescript_main)
3+
(public_name rescript)
4+
(modes exe)
5+
(flags
6+
(:standard -w +a-d-4-9-40-41-42-70))
7+
(libraries bsb common ext str unix))
8+
9+
(copy_files# ../main/rescript_main.{ml,mli})

jscomp/bsb_helper/dune

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(library
2+
(name bsb_helper)
3+
(wrapped false)
4+
(flags
5+
(:standard -w +a-9-40-42))
6+
(libraries ext))

jscomp/bsb_helper_exe/dune

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(executable
2+
(name bsb_helper_main)
3+
(public_name bsb_helper)
4+
(modes exe)
5+
(flags
6+
(:standard -w +a-9-40-42))
7+
(libraries bsb_helper))
8+
9+
(copy_files# ../main/bsb_helper_main.{ml,mli})

0 commit comments

Comments
 (0)