X-Git-Url: http://git.annexia.org/?p=whenjobs.git;a=blobdiff_plain;f=tools%2Fwhenjobs.ml;h=49a398de7a47051be5f44b0e6d919961ecfbc529;hp=1334aec8b4686d3b78d768195c005a589588c18a;hb=cb8bbd5621366d5adc82e59bff62bd8cc50d8e85;hpb=550bd0df9a6c9067dd0e2f9e77ae650efdf62454 diff --git a/tools/whenjobs.ml b/tools/whenjobs.ml index 1334aec..49a398d 100644 --- a/tools/whenjobs.ml +++ b/tools/whenjobs.ml @@ -307,26 +307,39 @@ and list_file () = close_in chan and upload_file () = - (* Recompile the jobs file. *) - let file = get_jobs_filename () in - let cmo_file = sprintf "%s/jobs.cmo" jobsdir in - let cmd = sprintf "ocamlfind ocamlc -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s -o %s" - !libdir !libdir file cmo_file in - if Sys.command cmd <> 0 then ( - eprintf "whenjobs: could not compile jobs script, see earlier error messages\n"; - eprintf "compile command was:\n%s\n" cmd; - exit 1 - ); + (* Recompile the jobs file(s). *) + let files = get_multijobs_filenames () in + List.iter ( + fun file -> + let cmd = sprintf "%s c -I +camlp4 -I %s -package unix,camlp4.lib -pp 'camlp4o %s/pa_when.cmo' -c %s" + Config.ocamlfind !libdir !libdir file in + if Sys.command cmd <> 0 then ( + eprintf "whenjobs: %s: could not compile jobs script, see earlier errors\n" + file; + eprintf "compile command was:\n%s\n" cmd; + exit 1 + ) + ) files; + + 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 - (* Test-load the jobs file to ensure it makes sense. *) + (* Test-load the jobs files to ensure they make sense. *) Whenfile.init Whenstate.empty; (try - Dynlink.loadfile cmo_file + List.iter Dynlink.loadfile cmo_files with Dynlink.Error err -> eprintf "whenjobs: %s\n" (Dynlink.error_message err); - (* Since it failed, unlink it. *) - (try unlink cmo_file with Unix_error _ -> ()); + (* Since it failed, unlink the cmo files. *) + List.iter ( + fun cmo_file -> + (try unlink cmo_file with Unix_error _ -> ()) + ) cmo_files; exit 1 ); @@ -555,6 +568,17 @@ and suggest_check_server_logs () = and get_jobs_filename () = sprintf "%s/jobs.ml" jobsdir +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.map (fun file -> jobsdir // file) files in + List.sort compare files + and create_tutorial file = let chan = open_out file in output_string chan Tutorial.tutorial;