Use Bytes instead of String for mutable byte array.
[goaljobs.git] / examples / compile-c / compile.ml
1 open Goaljobs
2
3 let rec goal all () =
4   require (built "program" ["main.c"; "utils.c"])
5
6 (* Goal: build the final program from source files. *)
7 and built program sources =
8   target (more_recent [program] sources);
9   List.iter (fun s -> require (compiled s)) sources;
10
11   let objects = List.map (change_file_extension "o") sources in
12   sh "cd $builddir && cc %s -o %s" (String.concat " " objects) program
13
14 (* Goal: Make sure a C file is compiled (to an object file). *)
15 and compiled c_file =
16   let o_file = change_file_extension "o" c_file in
17   target (more_recent [o_file] [c_file]);
18   require (file_exists c_file);
19   sh "cd $builddir && cc -c %s -o %s" c_file o_file