script to generate ocaml flags

This commit is contained in:
Simon Cruanes 2018-01-14 20:44:10 -06:00
parent 020b583940
commit e699d636c3
5 changed files with 28 additions and 8 deletions

View file

@ -1,6 +1,6 @@
QTEST_PREAMBLE='' QTEST_PREAMBLE=''
DONTTEST=../src/sequenceLabels.ml DONTTEST=../src/sequenceLabels.ml ../src/mkflags.ml
QTESTABLE=$(filter-out $(DONTTEST), \ QTESTABLE=$(filter-out $(DONTTEST), \
$(wildcard ../src/*.ml) \ $(wildcard ../src/*.ml) \
$(wildcard ../src/*.mli) \ $(wildcard ../src/*.mli) \

View file

@ -1,7 +1,7 @@
(rule (rule
((targets (run_qtest.ml)) ((targets (run_qtest.ml))
(deps ((file Makefile))) (deps ((file Makefile) )) ; (glob_files ../src/**/*.ml{,i})))
(fallback) (fallback)
;(libraries (qtest qcheck)) ;(libraries (qtest qcheck))
(action (action

View file

@ -5,7 +5,6 @@
(libraries (sequence bigarray)) (libraries (sequence bigarray))
(wrapped false) (wrapped false)
(optional) (optional)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -w -33 -safe-string -color always)) (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string))
(ocamlopt_flags (:standard -O3 -color always (ocamlopt_flags (:standard (:include ../flambda.flags)))
-unbox-closures -unbox-closures-factor 20))
)) ))

View file

@ -1,11 +1,18 @@
(rule
((targets (flambda.flags))
(deps ((file mkflags.ml)))
(fallback)
(action
(run ocaml ./mkflags.ml))
))
(library (library
((name sequence) ((name sequence)
(public_name sequence) (public_name sequence)
(wrapped false) (wrapped false)
(flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always -nolabels)) (modules (Sequence SequenceLabels))
(ocamlopt_flags (:standard -O3 -color always (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -nolabels))
-unbox-closures -unbox-closures-factor 20)) (ocamlopt_flags (:standard (:include flambda.flags)))
(libraries (bytes result)) (libraries (bytes result))
)) ))

14
src/mkflags.ml Normal file
View file

@ -0,0 +1,14 @@
let () =
let major, minor =
Scanf.sscanf Sys.ocaml_version "%u.%u"
(fun major minor -> major, minor)
in
let after_4_3 = (major, minor) >= (4, 3) in
let flags_file = open_out "flambda.flags" in
if after_4_3 then (
output_string flags_file "(-O3 -unbox-closures -unbox-closures-factor 20 -color always)\n";
) else (
output_string flags_file "()\n";
);
close_out flags_file