Skip to content

Commit fdd0981

Browse files
author
Lucas Pluvinage
committed
Wrap configure script
Update tests according to ocaml-freestanding wip
1 parent 037666d commit fdd0981

File tree

2 files changed

+32
-46
lines changed

2 files changed

+32
-46
lines changed

dune

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,55 @@
88
(foreign_stubs
99
(language c)
1010
(names caml_z)
11-
(flags :standard "-DHAS_GMP" (:include cflags.sxp))
11+
(flags :standard (:include cflags.sxp))
1212
)
1313
(c_library_flags (:include libs.sxp))
1414
)
1515

16-
(rule
17-
(target conf-gmp-cflags-false) ; global gmp
18-
(action (with-stdout-to %{target} (
19-
run echo "()"
20-
)))
16+
(rule
17+
(target Makefile)
18+
(deps configure config.guess env)
19+
(action (bash "env %{read:env} ./configure"))
2120
)
2221

2322
(rule
24-
(target conf-gmp-cflags-true) ; self built gmp
25-
(deps (package gmp))
26-
(action (with-stdout-to %{target} (
27-
bash "echo \"(-I$(dirname %{lib:gmp:META}))\""
28-
)))
23+
(target env)
24+
(deps env-%{lib-available:gmp})
25+
(action (copy env-%{lib-available:gmp} env))
2926
)
3027

3128
(rule
32-
(target cflags.sxp)
33-
(deps (:cflags conf-gmp-cflags-%{lib-available:gmp}))
34-
(action (copy %{cflags} cflags.sxp))
35-
)
36-
37-
38-
(rule
39-
(target conf-gmp-lib-false) ; global gmp
29+
(target env-false)
4030
(action (with-stdout-to %{target} (
41-
run echo "(-lgmp)"
31+
bash "echo -n CC=\\\"%{ocaml-config:c_compiler}\\\" CFLAGS=\\\"%{ocaml-config:ocamlopt_cflags}\\\""
4232
)))
4333
)
44-
34+
; bash "echo \"(\\\"-L$(dirname %{lib:gmp:libgmp.so})\\\" -lgmp)\""
4535
(rule
46-
(target conf-gmp-lib-true) ; self built gmp
47-
(deps (package gmp))
36+
(target env-true)
4837
(action (with-stdout-to %{target} (
49-
bash "echo \"(\\\"-L$(dirname %{lib:gmp:libgmp.so})\\\" -lgmp)\""
38+
bash "echo -n CC=\\\"%{ocaml-config:c_compiler}\\\" LDFLAGS=\\\"-L$(realpath $(dirname %{lib:gmp:libgmp.a}))\\\" CFLAGS=\\\"%{ocaml-config:ocamlopt_cflags}\\\" CPPFLAGS=\\\"-I$(realpath $(dirname %{lib:gmp:libgmp.a}))\\\""
5039
)))
5140
)
5241

42+
(rule
43+
(target cflags.sxp)
44+
(deps Makefile)
45+
(action (with-stdout-to %{target} (progn
46+
(bash "echo -n '('")
47+
(bash "cat Makefile | sed -n -e 's/CFLAGS=//p'")
48+
(bash "echo -n ')'")
49+
))))
50+
5351
(rule
5452
(target libs.sxp)
55-
(deps (:lib conf-gmp-lib-%{lib-available:gmp}))
56-
(action (copy %{lib} libs.sxp))
57-
)
53+
(deps Makefile)
54+
(action (with-stdout-to %{target} (progn
55+
(bash "echo -n '('")
56+
(bash "cat Makefile | sed -n -e 's/LIBS=//p'")
57+
(bash "echo -n ')'")
58+
))))
59+
5860

5961
(rule
6062
(deps META)

tests/dune

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int solo5_app_main(const struct solo5_start_info *si) {
4949
(name zq_freestanding)
5050
(modules zq_freestanding)
5151
(libraries zarith)
52-
(modes (native object))
52+
(link_flags :standard -cclib --solo5-abi=spt)
5353
(foreign_stubs (language c) (names startup manifest))
5454
)
5555

@@ -60,27 +60,11 @@ int solo5_app_main(const struct solo5_start_info *si) {
6060
(action
6161
(run solo5-elftool gen-manifest manifest.json manifest.c)))
6262

63-
(rule
64-
(enabled_if (= %{context_name} freestanding))
65-
(target ldflags)
66-
(action (with-stdout-to %{target} (progn
67-
(bash "solo5-config --target=spt --ldflags")
68-
)))
69-
)
70-
71-
(rule
72-
(enabled_if (= %{context_name} freestanding))
73-
(target zq.out)
74-
(deps zq_freestanding.exe.o)
75-
(action
76-
(bash
77-
"$(solo5-config --target=spt --ld) zq_freestanding.exe.o -o %{target} %{ocaml-config:native_c_libraries} %{read:ldflags}")))
78-
7963
; Run solo5 code
8064
(rule
8165
(enabled_if (= %{context_name} freestanding))
82-
(deps zq.out)
83-
(action (with-accepted-exit-codes 1 (with-stdout-to zq.output.full (run solo5-spt zq.out))))
66+
(deps zq_freestanding.exe)
67+
(action (with-accepted-exit-codes 1 (with-stdout-to zq.output.full (run solo5-spt zq_freestanding.exe))))
8468
)
8569

8670
; Remove solo5 intro

0 commit comments

Comments
 (0)