Build script can be called from a subdirectory of the project root.
authorKim Nguyễn <kn@lri.fr>
Fri, 8 Feb 2013 17:43:27 +0000 (18:43 +0100)
committerKim Nguyễn <kn@lri.fr>
Fri, 8 Feb 2013 17:43:27 +0000 (18:43 +0100)
build

diff --git a/build b/build
index ed3876a..f73479d 100755 (executable)
--- a/build
+++ b/build
@@ -5,6 +5,10 @@ let debug = ref false
 let profile = ref false
 let verbose = ref false
 
+let dir = Sys.getcwd ()
+let project_root = Filename.dirname Sys.argv.(0)
+let () = Sys.chdir project_root
+
 let () =
   for i = 1 to Array.length Sys.argv - 1 do
     match Sys.argv.(i) with
@@ -20,5 +24,7 @@ let otarget = if !target = "clean" then " -clean " else !target
 let overbose = if !verbose then " -classic-display " else ""
 
 let cmd = "ocamlbuild -use-ocamlfind " ^ overbose ^ oprofile ^ odebug ^ otarget
-let _ = Sys.command cmd
+let i = Sys.command cmd
+let () = Sys.chdir dir
+let _ = exit i