Permalink
Browse files

_oasis: choose appropriate libs for embedding the toplevel.

  • Loading branch information...
1 parent 473123d commit f95a5556b744b9663cbef1fb912c92af35091529 @Chris00 Chris00 committed Sep 3, 2012
Showing with 31 additions and 4 deletions.
  1. +0 −1 .gitignore
  2. +3 −2 _oasis
  3. +27 −0 myocamlbuild.ml
  4. +1 −1 src/app/build.ml
View
@@ -1,6 +1,5 @@
*~
_build/
-myocamlbuild.ml
setup.ml
setup.data
setup.log
View
5 _oasis
@@ -19,8 +19,9 @@ Executable build
Path: src/app
MainIs: build.ml
BuildDepends: weberizer, ocamlweb, unix, str
- ByteOpt: toplevellib.cma
-# toplevellib does not exist in native code...
+# The following cannot be conditional. The correct compilations tags
+# are set in myocamlbuild.ml. Wait for 4.00.0 to be mainstream to remove.
+# BuildDepends+: compiler-libs.toplevel
CompiledObject: byte
Install: false
View
@@ -0,0 +1,27 @@
+(* OASIS_START *)
+(* OASIS_STOP *)
+
+let env = BaseEnvLight.load() (* setup.data *)
+
+let has_compiler_libs =
+ try
+ Scanf.sscanf (BaseEnvLight.var_get "ocaml_version" env)
+ "%i" (fun maj -> maj >= 4)
+ with _ -> false
+
+let my_dispatch = function
+ | After_rules ->
+ if has_compiler_libs then
+ (* <src/app/*.ml{,i}>: pkg_compiler-libs.toplevel *)
+ let files = ["src/app/code.cmo"; "src/app/code.cmx";
+ "src/app/build.byte"; "src/app/build.native"] in
+ List.iter (fun f -> tag_file f ["pkg_compiler-libs.toplevel"]) files
+ else (
+ ocaml_lib ~extern:true "toplevellib";
+ tag_file "src/app/build.byte" ["use_toplevellib"];
+ )
+ | _ -> ()
+
+let () =
+ Ocamlbuild_plugin.dispatch (MyOCamlbuildBase.dispatch_combine
+ [ dispatch_default; my_dispatch])
View
@@ -154,7 +154,7 @@ let () =
else if l2 = "en" then ".."
else "../" ^ l2 in
let process_html lang p =
- printf "Processing %s\n" (Path.full p);
+ eprintf "Processing %s\n%!" (Path.full p);
let tpl = OCamlWeb_Main.lang tpl lang in
let tpl = OCamlWeb_Main.url_base tpl (Weberizer.Path.to_base p) in
let url_base = if Path.in_base p then "" else Path.to_base p in

0 comments on commit f95a555

Please sign in to comment.