Skip to content

Commit 53ac33b

Browse files
committed
Build with dune.
1 parent 0121b7c commit 53ac33b

File tree

9 files changed

+34
-58
lines changed

9 files changed

+34
-58
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
node-version: 14.4.0
5454

5555
- run: npm ci
56+
- run: opam install dune
5657
- run: npm run compile
5758

5859
# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
@@ -69,7 +70,7 @@ jobs:
6970
run: |
7071
cd analysis
7172
mkdir ${{matrix.artifact-folder}}
72-
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
73+
mv _build/install/default/bin/rescript-editor-analysis.exe ${{matrix.artifact-folder}}
7374
tar -cvf binary.tar ${{matrix.artifact-folder}}
7475
7576
- uses: actions/upload-artifact@v2

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@ node_modules
44
examples/*/lib
55
analysis/tests/lib
66
analysis/tests/.bsb.lock
7+
analysis/_build
78
analysis/tests/.merlin
8-
# artifacts from binary compilation
9-
*.exe
10-
*.cmi
11-
*.cmt
12-
*.cmti
13-
*.cmx
14-
*.o
15-
*.install

analysis/.merlin

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

analysis/Makefile

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,11 @@
11
SHELL = /bin/bash
2-
MAKEFLAGS += --jobs 4
3-
INCLUDES = -I src -I src/vendor/res_outcome_printer -I src/vendor -I src/vendor/compiler-libs-406
42

5-
OCAMLOPT = ocamlopt.opt
6-
OCAMLFLAGS = -g -w +26+27+32+33+39 -bin-annot $(INCLUDES)
7-
OCAMLDEP = ocamldep.opt
3+
build-native:
4+
dune build
85

9-
OUTPUT = rescript-editor-analysis.exe
10-
11-
%.cmi : %.mli
12-
@echo Building $@
13-
@$(OCAMLOPT) $(OCAMLFLAGS) -c $<
14-
%.cmx : %.ml
15-
@echo Building $@
16-
@$(OCAMLOPT) $(OCAMLFLAGS) -c $<
17-
18-
include .depend
19-
depend:
20-
@$(OCAMLDEP) -native $(INCLUDES) `find src -name "*.ml" -o -name "*.mli"` > .depend
21-
22-
SOURCE_FILES = $(shell $(OCAMLDEP) -sort `find src -name "*.ml"` | sed -E "s/\.ml/.cmx/g")
23-
24-
$(OUTPUT): $(SOURCE_FILES)
25-
@echo Linking...
26-
@$(OCAMLOPT) $(OCAMLFLAGS) -O2 -o $(OUTPUT) \
27-
unix.cmxa str.cmxa $(INCLUDES) $(SOURCE_FILES)
28-
@echo Done!
29-
30-
build-native: $(OUTPUT) depend
31-
32-
dce: build-native
33-
../../reanalyze/_build/install/default/bin/reanalyze.exe -dce-cmt src -suppress src/vendor
6+
dce:
7+
dune build @check @all
8+
../../reanalyze/_build/install/default/bin/reanalyze.exe -dce-cmt _build -suppress src/vendor
349

3510
tests/node_modules/.bin/rescript:
3611
@cd tests && npm install
@@ -39,9 +14,10 @@ test: build-native tests/node_modules/.bin/rescript
3914
@cd tests && node_modules/.bin/rescript
4015
./test.sh
4116

42-
clean:
43-
git clean -dfx .
17+
clean: tests/node_modules/.bin/rescript
18+
@cd tests && node_modules/.bin/rescript clean
19+
dune clean
4420

4521
.DEFAULT_GOAL := build-native
4622

47-
.PHONY: depend clean build-native dce test
23+
.PHONY: clean build-native dce test

analysis/dummy.opam

Whitespace-only changes.

analysis/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(dirs :standard \ examples tests)

analysis/dune-project

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(lang dune 1.7)
2+
(name rescript-vscode)
3+

analysis/src/dune

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(copy_files# vendor/*.{ml,mli})
2+
(copy_files# vendor/compiler-libs-406/*.{ml,mli})
3+
(copy_files# vendor/res_outcome_printer/*.{ml,mli})
4+
(
5+
executable
6+
(public_name rescript-editor-analysis.exe)
7+
8+
; The main module that will become the binary.
9+
(name Cli)
10+
11+
(flags "-w" "+26+27+32+33+39")
12+
13+
; Depends on:
14+
(libraries unix str)
15+
16+
(modules_without_implementation asttypes outcometree parsetree)
17+
)

analysis/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
for file in tests/src/*.{res,resi}; do
22
output="$(dirname $file)/expected/$(basename $file).txt"
3-
./rescript-editor-analysis.exe test $file &> $output
3+
./_build/install/default/bin/rescript-editor-analysis.exe test $file &> $output
44
# CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
55
if [ "$RUNNER_OS" == "Windows" ]; then
66
perl -pi -e 's/\r\n/\n/g' -- $output

0 commit comments

Comments
 (0)