X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=tools%2Fwhenjobs.ml;h=a9ae7b7a6ac67a7c8cfa2e2bf4a3f8b1f79c86b7;hb=2c27f26c486961d1b7799d4f4274aa31d04df845;hp=9449abca2f446e593dd9c80715a828f568f97d93;hpb=77707acb12b5424488757569f376e1d9b58e5a22;p=whenjobs.git diff --git a/tools/whenjobs.ml b/tools/whenjobs.ml index 9449abc..a9ae7b7 100644 --- a/tools/whenjobs.ml +++ b/tools/whenjobs.ml @@ -311,8 +311,18 @@ and upload_file () = let files = get_multijobs_filenames () in List.iter ( fun file -> - let cmd = sprintf "ocamlfind ocamlc -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s" - !libdir !libdir file in + let cmd = + if not Config.have_ocamlopt then + (* bytecode *) + sprintf "%s c -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s" + Config.ocamlfind !libdir !libdir file + else ( + (* native code *) + let base = Filename.chop_extension file in (* without .ml suffix *) + sprintf "%s opt -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s &&\n%s opt -shared -linkall %s.cmx -o %s.cmxs" + Config.ocamlfind !libdir !libdir file + Config.ocamlfind base base + ) in if Sys.command cmd <> 0 then ( eprintf "whenjobs: %s: could not compile jobs script, see earlier errors\n" file; @@ -321,25 +331,24 @@ and upload_file () = ) ) files; - let cmo_files = List.map ( + let suffix = if not Dynlink.is_native then "cmo" else "cmxs" in + + let compiled_files = List.map ( fun file -> let n = String.length file in if n < 4 then assert false; - String.sub file 0 (n-3) ^ ".cmo" + sprintf "%s.%s" (String.sub file 0 (n-3)) suffix ) files in (* Test-load the jobs files to ensure they make sense. *) Whenfile.init Whenstate.empty; (try - List.iter Dynlink.loadfile cmo_files + List.iter Dynlink.loadfile compiled_files with Dynlink.Error err -> - eprintf "whenjobs: %s\n" (Dynlink.error_message err); - (* Since it failed, unlink the cmo files. *) - List.iter ( - fun cmo_file -> - (try unlink cmo_file with Unix_error _ -> ()) - ) cmo_files; + eprintf "whenjobs: dynlink: %s\n" (Dynlink.error_message err); + (* Since it failed, unlink the compiled files. *) + List.iter (fun f -> try unlink f with Unix_error _ -> ()) compiled_files; exit 1 ); @@ -571,11 +580,7 @@ and get_jobs_filename () = and get_multijobs_filenames () = (* Get dir/*.ml *) let files = Array.to_list (Sys.readdir jobsdir) in - let files = List.filter ( - fun file -> - let n = String.length file in - n >= 4 && String.sub file (n-3) 3 = ".ml" - ) files in + let files = List.filter (fun file -> string_endswith file ".ml") files in let files = List.map (fun file -> jobsdir // file) files in List.sort compare files