- let cmo_files = List.map (
- fun file ->
- let n = String.length file in
- if n < 4 then assert false;
- String.sub file 0 (n-3) ^ ".cmo"
- ) files in
+ (* Pack into a single file. *)
+ let filename = sprintf "%s/jobs__%Ld.%s" jobsdir t suffix in
+ let cmd =
+ let objects = List.map (
+ fun file ->
+ let base = Filename.chop_extension file in
+ base ^ if not Config.have_ocamlopt then ".cmo" else ".cmx"
+ ) files in
+ sprintf "%s %s -pack -o %s %s"
+ Config.ocamlfind
+ (if not Config.have_ocamlopt then "c" else "opt")
+ filename (String.concat " " objects) in
+ if Sys.command cmd <> 0 then (
+ eprintf "whenjobs: could not pack jobs script, see earlier errors\n";
+ eprintf "compile command was:\n%s\n" cmd;
+ exit 1
+ );
+
+ (* For native code only, write a *.cmxs file. *)
+ let filename =
+ if Config.have_ocamlopt then (
+ let cmd = sprintf "%s opt -shared -linkall %s -o %ss"
+ Config.ocamlfind filename filename in
+ if Sys.command cmd <> 0 then (
+ eprintf "whenjobs: could not convert to *.cmxs, see earlier errors\n";
+ eprintf "compile command was:\n%s\n" cmd;
+ exit 1
+ );
+ filename ^ "s" (* .cmx -> .cmxs *)
+ )
+ else filename in