X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Fcmdline.ml;h=0549833ad6cedcc265fcfb8b5e3f30a30f286dff;hb=81394242a7d6a47fad6d84ce33d488d38de2647a;hp=cc20d76233aa2aa1e93b26027b7cbc726c83895e;hpb=3a94d620b1c135342c9f88ae943f256b9a9f96c9;p=goals.git diff --git a/src/cmdline.ml b/src/cmdline.ml index cc20d76..0549833 100644 --- a/src/cmdline.ml +++ b/src/cmdline.ml @@ -23,7 +23,7 @@ open Utils (* See also "let id" in [lexer.mll]. *) let var_regexp = - Str.regexp "\\([a-zA-Z_][a-zA-Z0-9_]*\\)[ \t]*=[ \t]*\\(.*\\)" + Str.regexp "\\([a-zA-Z_][-a-zA-Z0-9_]*\\)[ \t]*=[ \t]*\\(.*\\)" let usage = "\ @@ -43,20 +43,22 @@ let print_version () = let datadir = try Sys.getenv "GOALS_DATADIR" with Not_found -> Config.datadir let stdlibdir = datadir // "stdlib" -let prelude_file = stdlibdir // "prelude.gl" +let prelude_gl_file = stdlibdir // "prelude.gl" +let prelude_sh_file = stdlibdir // "prelude.sh" let () = - if not (is_directory stdlibdir) || not (Sys.file_exists prelude_file) then + if not (is_directory stdlibdir) || not (Sys.file_exists prelude_gl_file) then failwithf "%s: cannot find the standard library directory, expected %s. If the standard library directory is in a non-standard location then set GOALS_DATADIR. If you can trying to run goals from the build directory then use ‘./run goals ...’" Sys.executable_name stdlibdir let input_file, - debug_flag, directory, includes, use_prelude, anon_vars, targets = + debug_flag, directory, includes, nr_jobs, use_prelude, anon_vars, targets = let args = ref [] in let debug_flag = ref false in let directory = ref "." in let input_file = ref "Goalfile" in let includes = ref [stdlibdir] in let add_include dir = includes := dir :: !includes in + let nr_jobs = ref 4 (* XXX use nproc *) in let use_prelude = ref true in let argspec = [ @@ -74,6 +76,10 @@ let input_file, "dir Add include directory"; "--include", Arg.String add_include, "dir Add include directory"; + "-j", Arg.Set_int nr_jobs, + "jobs Set number of parallel jobs"; + "--jobs", Arg.Set_int nr_jobs, + "jobs Set number of parallel jobs"; "--no-prelude",Arg.Clear use_prelude, " Do not automatically use prelude.gl from stdlib"; "-v", Arg.Unit print_version, @@ -88,9 +94,12 @@ let input_file, let args = List.rev !args in let debug_flag = !debug_flag in let directory = !directory in - let input_file = absolute_path !input_file in + let input_file = !input_file in (* Don't reverse includes - we want newer -I options to take precedence. *) - let includes = List.map absolute_path !includes in + let includes = !includes in + let nr_jobs = !nr_jobs in + if nr_jobs < 1 then + failwithf "%s: -j must be >= 1" Sys.executable_name; let use_prelude = !use_prelude in (* Get the anon var assignments and targets. *) @@ -108,7 +117,7 @@ let input_file, ) anon_vars in input_file, - debug_flag, directory, includes, use_prelude, anon_vars, targets + debug_flag, directory, includes, nr_jobs, use_prelude, anon_vars, targets (* Create the debug function. *) let debug fs =