Skip to content

Build with dune. #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
uses: actions/[email protected]
with:
path: ~/.opam
key: ${{matrix.os}}-rescript-vscode-v1
key: ${{matrix.os}}-rescript-vscode-v2

- name: Use OCaml
uses: ocaml/setup-ocaml@v2
Expand All @@ -53,6 +53,7 @@ jobs:
node-version: 14.4.0

- run: npm ci
- run: opam install dune
- run: npm run compile

# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
Expand Down
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ node_modules
examples/*/lib
analysis/tests/lib
analysis/tests/.bsb.lock
analysis/_build
analysis/tests/.merlin
# artifacts from binary compilation
*.exe
*.cmi
*.cmt
*.cmti
*.cmx
*.o
*.install
analysis/rescript-editor-analysis.exe
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Thanks for your interest. Below is an informal spec of how the plugin's server c
## Build & Run

- `npm run compile`. You don't need this if you're developing this repo in VSCode. The compilation happens automatically in the background.
- `cd analysis && make depend && make` (you only need `make depend` for the first run).
- `cd analysis && make`.

## Test

Expand Down
15 changes: 0 additions & 15 deletions analysis/.merlin

This file was deleted.

44 changes: 11 additions & 33 deletions analysis/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
SHELL = /bin/bash
MAKEFLAGS += --jobs 4
INCLUDES = -I src -I src/vendor/res_outcome_printer -I src/vendor -I src/vendor/compiler-libs-406

OCAMLOPT = ocamlopt.opt
OCAMLFLAGS = -g -w +26+27+32+33+39 -bin-annot $(INCLUDES)
OCAMLDEP = ocamldep.opt
build-native:
dune build
cp _build/install/default/bin/rescript-editor-analysis.exe rescript-editor-analysis.exe

OUTPUT = rescript-editor-analysis.exe

%.cmi : %.mli
@echo Building $@
@$(OCAMLOPT) $(OCAMLFLAGS) -c $<
%.cmx : %.ml
@echo Building $@
@$(OCAMLOPT) $(OCAMLFLAGS) -c $<

include .depend
depend:
@$(OCAMLDEP) -native $(INCLUDES) `find src -name "*.ml" -o -name "*.mli"` > .depend

SOURCE_FILES = $(shell $(OCAMLDEP) -sort `find src -name "*.ml"` | sed -E "s/\.ml/.cmx/g")

$(OUTPUT): $(SOURCE_FILES)
@echo Linking...
@$(OCAMLOPT) $(OCAMLFLAGS) -O2 -o $(OUTPUT) \
unix.cmxa str.cmxa $(INCLUDES) $(SOURCE_FILES)
@echo Done!

build-native: $(OUTPUT) depend

dce: build-native
../../reanalyze/_build/install/default/bin/reanalyze.exe -dce-cmt src -suppress src/vendor
dce:
dune build @check @all
../../reanalyze/_build/install/default/bin/reanalyze.exe -dce-cmt _build -suppress src/vendor

tests/node_modules/.bin/rescript:
@cd tests && npm install
Expand All @@ -39,9 +15,11 @@ test: build-native tests/node_modules/.bin/rescript
@cd tests && node_modules/.bin/rescript
./test.sh

clean:
git clean -dfx .
clean: tests/node_modules/.bin/rescript
rm -f rescript-editor-analysis.exe
@cd tests && node_modules/.bin/rescript clean
dune clean

.DEFAULT_GOAL := build-native

.PHONY: depend clean build-native dce test
.PHONY: clean build-native dce test
Empty file added analysis/dummy.opam
Empty file.
1 change: 1 addition & 0 deletions analysis/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(dirs :standard \ examples tests)
3 changes: 3 additions & 0 deletions analysis/dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 1.7)
(name rescript-vscode)

17 changes: 17 additions & 0 deletions analysis/src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(copy_files# vendor/*.{ml,mli})
(copy_files# vendor/compiler-libs-406/*.{ml,mli})
(copy_files# vendor/res_outcome_printer/*.{ml,mli})
(
executable
(public_name rescript-editor-analysis.exe)

; The main module that will become the binary.
(name Cli)

(flags "-w" "+26+27+32+33+39")

; Depends on:
(libraries unix str)

(modules_without_implementation asttypes outcometree parsetree)
)