search for compiler libraries at configure time
Ignore-this: 69791ad05709149e95a034f2a84be5a3 darcs-hash:20110803170052-c41ad-44393df785313f3e6fb832189d4fc9f0e05f7bc2
This commit is contained in:
parent
ec72c8c913
commit
fa84034e80
|
@ -23,27 +23,14 @@ let () =
|
||||||
flag ["ocaml"; "link"; "toplevel"] & A"-linkpkg";
|
flag ["ocaml"; "link"; "toplevel"] & A"-linkpkg";
|
||||||
|
|
||||||
let env = BaseEnvLight.load () in
|
let env = BaseEnvLight.load () in
|
||||||
let stdlib_path = BaseEnvLight.var_get "standard_library" env in
|
let path = BaseEnvLight.var_get "compiler_libs" env in
|
||||||
|
let stdlib = BaseEnvLight.var_get "standard_library" env in
|
||||||
(* Try to find the path where compiler libraries are: *)
|
|
||||||
let compiler_libs =
|
|
||||||
let stdlib = String.chomp stdlib_path in
|
|
||||||
try
|
|
||||||
let path =
|
|
||||||
List.find Pathname.exists [
|
|
||||||
stdlib / "compiler-libs";
|
|
||||||
stdlib / "compiler-lib";
|
|
||||||
stdlib / ".." / "compiler-libs";
|
|
||||||
stdlib / ".." / "compiler-lib";
|
|
||||||
]
|
|
||||||
in
|
|
||||||
path :: List.filter Pathname.exists [ path / "typing"; path / "utils"; path / "parsing" ]
|
|
||||||
with Not_found ->
|
|
||||||
[]
|
|
||||||
in
|
|
||||||
|
|
||||||
(* Add directories for compiler-libraries: *)
|
(* Add directories for compiler-libraries: *)
|
||||||
let paths = List.map (fun path -> S[A"-I"; A path]) compiler_libs in
|
let paths = [A "-I"; A path;
|
||||||
|
A "-I"; A (path / "typing");
|
||||||
|
A "-I"; A (path / "parsing");
|
||||||
|
A "-I"; A (path / "utils")] in
|
||||||
List.iter
|
List.iter
|
||||||
(fun stage -> flag ["ocaml"; stage; "use_compiler_libs"] & S paths)
|
(fun stage -> flag ["ocaml"; stage; "use_compiler_libs"] & S paths)
|
||||||
["compile"; "ocamldep"; "doc"; "link"];
|
["compile"; "ocamldep"; "doc"; "link"];
|
||||||
|
@ -60,7 +47,7 @@ let () =
|
||||||
(* Build the set of locations of dependencies. *)
|
(* Build the set of locations of dependencies. *)
|
||||||
let locs = List.fold_left (fun set pkg -> StringSet.add pkg.Findlib.location set) StringSet.empty deps in
|
let locs = List.fold_left (fun set pkg -> StringSet.add pkg.Findlib.location set) StringSet.empty deps in
|
||||||
(* Directories to search for .cmi: *)
|
(* Directories to search for .cmi: *)
|
||||||
let directories = StringSet.add stdlib_path (StringSet.add (stdlib_path / "threads") locs) in
|
let directories = StringSet.add stdlib (StringSet.add (stdlib / "threads") locs) in
|
||||||
(* Construct the set of modules to keep by listing
|
(* Construct the set of modules to keep by listing
|
||||||
.cmi files: *)
|
.cmi files: *)
|
||||||
let modules =
|
let modules =
|
||||||
|
@ -76,7 +63,7 @@ let () =
|
||||||
(Array.to_list (Pathname.readdir directory)))
|
(Array.to_list (Pathname.readdir directory)))
|
||||||
directories StringSet.empty
|
directories StringSet.empty
|
||||||
in
|
in
|
||||||
Cmd(S[A(stdlib_path / "expunge");
|
Cmd(S[A(stdlib / "expunge");
|
||||||
A(env "%.top");
|
A(env "%.top");
|
||||||
A(env "%.byte");
|
A(env "%.byte");
|
||||||
A"UTop"; A"Outcometree"; A"Topdirs"; A"Toploop";
|
A"UTop"; A"Outcometree"; A"Topdirs"; A"Toploop";
|
||||||
|
|
24
setup.ml
24
setup.ml
|
@ -17,4 +17,26 @@ let () =
|
||||||
|
|
||||||
(* OASIS_STOP *)
|
(* OASIS_STOP *)
|
||||||
|
|
||||||
let () = setup ();;
|
let search_compiler_libs () =
|
||||||
|
OASISContext.printf `Info "Searching for OCaml compiler libraries";
|
||||||
|
let stdlib = BaseEnv.var_get "standard_library" in
|
||||||
|
let ( / ) = Filename.concat in
|
||||||
|
try
|
||||||
|
List.find (fun path -> Sys.file_exists (path / "types.cmi") || Sys.file_exists (path / "typing" / "types.cmi")) [
|
||||||
|
stdlib;
|
||||||
|
stdlib / "compiler-libs";
|
||||||
|
stdlib / "compiler-lib";
|
||||||
|
stdlib / ".." / "compiler-libs";
|
||||||
|
stdlib / ".." / "compiler-lib";
|
||||||
|
]
|
||||||
|
with Not_found ->
|
||||||
|
OASISContext.printf `Error "Cannot find compiler libraries! See the README for details.";
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
let compiler_libs =
|
||||||
|
BaseEnv.var_define
|
||||||
|
~short_desc:(fun () -> "compiler libraries")
|
||||||
|
"compiler_libs"
|
||||||
|
(Lazy.lazy_from_fun search_compiler_libs)
|
||||||
|
|
||||||
|
let () = setup ()
|
||||||
|
|
Loading…
Reference in New Issue