-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix opam install, generate META restore version continue WIP more WIP WIP fix after rebase fix ci fix ci fix ci fix ci fix ci fix ci fix ci fix ci linkall toplevel lib empty interface of toplevel lib
- Loading branch information
Hugo Heuzard
committed
Jul 19, 2023
1 parent
64563b6
commit 35910cd
Showing
31 changed files
with
315 additions
and
673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ depend | |
zarith_version.ml | ||
_build | ||
.merlin | ||
c-flags.sexp | ||
library-flags.sexp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- why use -linkall for zarith.cmxs ? | ||
- do we need -failsafe when calling OCAMLMKLIB | ||
- do we need -O3 -Wall -Wextra | ||
- we not longer test bytecode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
module C = Configurator.V1 | ||
|
||
module Version = struct | ||
type t = { major : int; minor : int } | ||
|
||
let num = function '0' .. '9' -> true | _ -> false | ||
|
||
let of_string_exn s : t = | ||
try Scanf.sscanf s "%d.%d" (fun major minor -> { major; minor }) | ||
with _ -> failwith (Printf.sprintf "unable to parse ocaml version %S" s) | ||
|
||
let compare a b = | ||
match compare a.major b.major with 0 -> compare a.minor b.minor | n -> n | ||
end | ||
|
||
type libmode = [ `Auto | `Gmp | `Mpir ] | ||
|
||
let lib : libmode ref = ref `Auto | ||
let perf = ref false | ||
|
||
let lookup_with_pkg_config c ~lib = | ||
match C.Pkg_config.get c with | ||
| None -> None | ||
| Some pc -> ( | ||
match C.Pkg_config.query pc ~package:lib with | ||
| Some deps -> Some deps | ||
| None -> None) | ||
|
||
let lookup_manually c ~lib ~include_h = | ||
let libflag = Printf.sprintf "-l%s" lib in | ||
let c_code = | ||
Printf.sprintf {| | ||
#include <%s>" | ||
int main() { return 1; } | ||
|} include_h | ||
in | ||
if C.c_test c ~link_flags:[ libflag ] c_code then | ||
Some { C.Pkg_config.libs = [ libflag ]; cflags = [] } | ||
else None | ||
let () = | ||
C.main | ||
~args: | ||
[ | ||
( "-gmp", | ||
Unit (fun () -> lib := `Gmp), | ||
"use GMP library (default if found)" ); | ||
( "-mpir", | ||
Unit (fun () -> lib := `Mpir), | ||
"use MPIR library instead of GMP" ); | ||
("-perf", Set perf, "enable performance statistics"); | ||
] | ||
~name:"zarith" | ||
(fun c -> | ||
let version = | ||
Version.of_string_exn (C.ocaml_config_var_exn c "version") | ||
in | ||
let use_legacy = | ||
Version.compare version { Version.major = 4; minor = 8 } < 0 | ||
in | ||
let find_one ~lib ~include_h = | ||
match lookup_with_pkg_config c ~lib with | ||
| Some x -> x | ||
| None -> match lookup_manually c ~lib ~include_h with | ||
| Some x -> x | ||
| None -> failwith (Printf.sprintf "Unable to find the %s c library" lib) | ||
in | ||
let backend, conf = | ||
let rec find = function | ||
| `Auto -> ( | ||
try find `Gmp with e -> ( try find `Mpir with _ -> raise e)) | ||
| `Gmp -> (`Gmp, find_one ~lib:"gmp" ~include_h:"gmp.h") | ||
| `Mpir -> (`Mpir, find_one ~lib:"mpir" ~include_h:"mpir.h") | ||
in | ||
find !lib | ||
in | ||
let defs = | ||
match backend with `Gmp -> [ "-DHAS_GMP" ] | `Mpir -> [ "-DHAS_MPIR" ] | ||
in | ||
let defs = if !perf then "-DZ_PERF_COUNTER" :: defs else defs in | ||
let defs = | ||
if use_legacy then "DZ_OCAML_LEGACY_CUSTOM_OPERATIONS" :: defs else defs | ||
in | ||
C.Flags.write_sexp "c-flags.sexp" | ||
(conf.cflags @ defs (* @ [ "-O3"; "-Wall"; "-Wextra" ] *)); | ||
C.Flags.write_sexp "c-library-flags.sexp" conf.libs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(executable | ||
(name discover) | ||
(libraries dune-configurator)) |
Oops, something went wrong.