Markus Mottl avatar Markus Mottl committed 449818e

Worked around split function bug in build file and added missing library tags

Comments (0)

Files changed (2)

 <examples/subst/*.ml{,i}>: use_pcre
 # OASIS_STOP
 <**/*.ml{,i}>: warn_A, warn_e, warn_r, annot
+
+<lib/pcre.{cma,cmxa}>: oasis_library_pcre_cclib
+"lib/libpcre_stubs.lib": oasis_library_pcre_cclib
+"lib/dllpcre_stubs.dll": oasis_library_pcre_cclib
+"lib/libpcre_stubs.a": oasis_library_pcre_cclib
+"lib/dllpcre_stubs.so": oasis_library_pcre_cclib
 
 # 503 "myocamlbuild.ml"
 (* OASIS_STOP *)
-Ocamlbuild_plugin.dispatch dispatch_default;;
+
+let () =
+  let additional_rules = function
+    | After_rules ->
+        flag ["compile"; "ocaml"] (S [A "-strict-sequence"]);
+
+        (* Add correct PCRE compilation and link flags *)
+        let pcre_clibs, opcre_cflags, opcre_clibs =
+          let ic = Unix.open_process_in "pcre-config --cflags --libs" in
+          try
+            let pcre_cflags = input_line ic in
+            let pcre_clibs = input_line ic in
+            (* TODO: remove once split-function in generated code is fixed *)
+            let rec split_string s =
+              match try Some (String.index s ' ') with Not_found -> None with
+              | Some pos ->
+                  String.before s pos :: split_string (String.after s (pos + 1))
+              | None -> [s]
+            in
+            let ocamlify ~ocaml_flag flags =
+              let chunks = split_string flags in
+              let cnv flag = [A ocaml_flag; A flag] in
+              List.concat (List.map cnv chunks)
+            in
+            let split_flags flags =
+              let chunks = split_string flags in
+              let cnv flag = A flag in
+              List.map cnv chunks
+            in
+            split_flags pcre_clibs,
+            ocamlify ~ocaml_flag:"-ccopt" pcre_cflags,
+            ocamlify ~ocaml_flag:"-cclib" pcre_clibs
+          with exn ->
+            close_in ic;
+            raise exn
+        in
+        flag ["compile"; "c"] (S opcre_cflags);
+        flag ["link"; "ocaml"; "library"] (S opcre_clibs);
+        flag ["oasis_library_pcre_cclib"; "ocamlmklib"; "c"] (S pcre_clibs);
+        flag ["oasis_library_pcre_cclib"; "link"] (S opcre_clibs)
+      | _ -> ()
+  in
+  dispatch
+    (MyOCamlbuildBase.dispatch_combine [
+         MyOCamlbuildBase.dispatch_default package_default;
+         additional_rules ])
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.