-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdune
53 lines (48 loc) · 1.39 KB
/
dune
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
;; generate static lib from rust code
(rule
(deps
expected_bindings.ml
(source_tree ocamlgen_test_stubs))
(targets libocamlgen_test_stubs.a dllocamlgen_test_stubs.so bindings.ml)
(action
(no-infer
(progn
(run cargo build --release --target-dir %{project_root}/target)
;; Copy .a
(run
cp
%{project_root}/target/release/libocamlgen_test_stubs.a
libocamlgen_test_stubs.a)
;; Copy .so + support macos
(with-accepted-exit-codes
(or 0 1)
(run
cp
%{project_root}/target/release/libocamlgen_test_stubs.so
dllocamlgen_test_stubs.so))
(with-accepted-exit-codes
(or 0 1)
(run
cp
%{project_root}/target/release/libocamlgen_test_stubs.dylib
dllocamlgen_test_stubs.so))
(with-stdout-to
bindings.ml
(run cargo run --bin main --release --target-dir %{project_root}/target))))))
;; Generate an executable for testing
(executable
(name ocamlgen_test)
(public_name ocamlgen_test)
(package ocamlgen-test)
(modules ocamlgen_test bindings)
(libraries alcotest qcheck qcheck-alcotest)
(foreign_archives ocamlgen_test_stubs))
;; rule for running the tests (runs the executable and apply diff on the
;; generated bindings)
(rule
(alias runtest)
(action
(progn
(run ./ocamlgen_test.exe)
;; https://dune.readthedocs.io/en/stable/concepts.html#diffing-and-promotion
(diff expected_bindings.ml bindings.ml))))