forked from pgj/mirage-kfreebsd
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add the ocamlbuild plugin lost in the reorganization.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
open Ocamlbuild_plugin;; | ||
open Command;; | ||
|
||
module Util = struct | ||
let split s ch = | ||
let x = ref [] in | ||
let rec go s = | ||
let pos = String.index s ch in | ||
x := (String.before s pos)::!x; | ||
go (String.after s (pos + 1)) | ||
in | ||
try | ||
go s | ||
with Not_found -> !x | ||
|
||
let split_nl s = split s '\n' | ||
let run_and_read x = List.hd (split_nl (Ocamlbuild_pack.My_unix.run_and_read x)) | ||
end | ||
|
||
let query dir = Util.run_and_read ("ocamlfind query " ^ dir);; | ||
|
||
dispatch begin function | ||
| After_rules -> | ||
flag ["camlp4of"; "build_syntax"] | ||
(S[A "-I"; A "+camlp4"]); | ||
flag ["compile"; "use_custom_stdlib"] | ||
(S[A "-nostdlib"; A "-I"; A (query "mirage-stdlib")]); | ||
| _ -> () | ||
end;; |