From e13562608a869f5aa57f2d2ba95d512fa58f1bef Mon Sep 17 00:00:00 2001 From: malc Date: Sun, 16 Sep 2007 22:33:31 +0400 Subject: [PATCH] 0.94 --- dep.ml | 18 ++++++++++++------ dep7.ml | 14 ++++++++++---- driver.ml | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- utils.ml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 18 deletions(-) diff --git a/dep.ml b/dep.ml index d6ce282..dd0258b 100644 --- a/dep.ml +++ b/dep.ml @@ -8,14 +8,16 @@ let process_cl_cpp_output_line s set = if Str.string_match line_re s 0 then let win_path = Utils.safe_group 1 s in - if debug && (not (Utils.StringSet.mem win_path set)) - then - prerr_endline s; - Utils.StringSet.add win_path set + if debug && (not (Utils.StringSet.mem win_path set)) + then + prerr_endline s + ; + Utils.StringSet.add win_path set else set let invoke target argv arg_start = + let rejrel = Utils.build_reject_list () in let args = Utils.make_arg_string Path.check_and_modify_absolute argv arg_start in let tool = Utils.tool_name "cl" in let command = Wine.command tool ^ "/E /nologo " ^ args ^ " /w" in @@ -46,8 +48,12 @@ let invoke target argv arg_start = prerr_string (String.escaped win_path); prerr_endline "' to unix" | Some unix_path -> - print_string unix_path; - print_char ' ' + if not (Utils.reject_path unix_path rejrel) + then + begin + print_string unix_path; + print_char ' ' + end end ifiles; print_newline (); end; diff --git a/dep7.ml b/dep7.ml index 51a6bdf..a8acd11 100644 --- a/dep7.ml +++ b/dep7.ml @@ -1,16 +1,21 @@ let note_re = Str.regexp "^Note: including file: *\\(.*\\)$" -let process_cl_dep7_output_line s set = +let process_cl_dep7_output_line rejrel s set = if Str.string_match note_re s 0 then let win_path = Utils.safe_group 1 s in let unix_path = Path.find2 win_path in match unix_path with | Some path -> - Utils.StringSet.add path set + if Utils.reject_path path rejrel + then + set + else + Utils.StringSet.add path set | None -> prerr_string - "Dep7.process_cl_dep7_output_line: Cannot find unix path for "; + "Dep7.process_cl_dep7_output_line: Cannot find unix path for " + ; prerr_endline (String.escaped win_path); set else @@ -35,6 +40,7 @@ let test () = exit 1 let invoke_aux deponly oc target argv arg_start = + let rejrel = Utils.build_reject_list () in let args = Utils.make_arg_string Path.check_and_modify_absolute argv arg_start in let tool = Utils.tool_name "cl" in let command = @@ -49,7 +55,7 @@ let invoke_aux deponly oc target argv arg_start = in let ic = Unix.open_process_in command in let ifiles = - Utils.fold_crlf_chan ic process_cl_dep7_output_line + Utils.fold_crlf_chan ic (process_cl_dep7_output_line rejrel) Utils.StringSet.empty in let code = Utils.close_process_in ic in diff --git a/driver.ml b/driver.ml index 2fa6a0e..8387592 100644 --- a/driver.ml +++ b/driver.ml @@ -1,15 +1,11 @@ -let show_usage () = - print_endline "Incredible Mega Thing Version 0.93"; - print_string "Copryight (C) 2005,2006 extremely cool hacker. "; - print_endline "All rights reserved."; - print_newline (); +let help () = print_string "usage: "; print_string (Filename.basename Sys.executable_name); print_endline " command [ command-argument ] [ arguments ... ]"; print_endline "command is one of: "; List.iter (fun s -> print_string " "; print_endline s) ["cl"; - " run `cl [arguments]' sanitizing output"; + " run `cl [arguments]' sanitizing output (converting pathes etc)"; ""; "dep target"; @@ -36,16 +32,53 @@ let show_usage () = "link"; " run `link [arguments]'"; ""; + + "help"; + " show this help screen"; + "" ]; + let exp_cmd, run_cmd = + if Wine.native + then + "C:\\> set ", "C:\\> " + else + "$ export ", "$ " + in List.iter print_endline ["If environment variable IMT_[CL|LINK] is set it will be used as the "; - "path to respective utility, otherwise cl.exe|link.exe will be used"; + "path to respective utility, otherwise [cl.exe|link.exe] will be used"; + ""; + "Headers produced by [cl]dep[7] commands will be tested against IMT_REJ"; + "environment variable (: separated list of OCaml style regular expressions)"; + "if the path to header matches it will be excluded from the printout"; + "(pathes are tested after windows to unix translation (nop on Win platforms))"; ""; "Example:"; - "$ IMT_CL=/mnt/windows/msc/bin/cl.exe imt cldep7 moo.obj moo.dep -c moo.c"; + exp_cmd ^ "IMT_REJ=/mnt/windows/msc/include:/mnt/psdk/include"; + exp_cmd ^ "IMT_CL=/mnt/windows/msc/bin/cl.exe"; + run_cmd ^ "imt cldep7 moo.obj moo.dep -c moo.c"; "" ]; print_endline "Have a nice day"; + exit 0 + +let show_usage () = + print_endline "Incredible Mega Thing by extremely cool hacker, Version 0.94"; + print_newline (); + print_string "usage: "; + print_string (Filename.basename Sys.executable_name); + print_endline " command [ command-argument ] [ arguments ... ]"; + print_endline "command is one of: "; + List.iter (fun s -> print_string " "; print_endline s) + ["cl: invoke cl"; + "dep target: invoke cl /E, parse output, print dependencies to stdout"; + "dep7 target: invoke cl /showIncludes /Zs, same as dep"; + "dep7-test: test if /showIncludes is available, exit with non-zero if not"; + "cldep7 target depfile: cl+dep7 combined, put dependencies into depfile"; + "link: invoke link"; + "help: show extended help" + ]; + print_endline "Have a nice day"; exit 100 let main argv = @@ -91,6 +124,9 @@ let main argv = and depfile = argv.(3) in Dep7.invoke2 target depfile argv 4 + | "help" -> + help () + | cmd -> prerr_string "invalid command: "; prerr_string (String.escaped cmd); diff --git a/utils.ml b/utils.ml index 1cc27d0..a108708 100644 --- a/utils.ml +++ b/utils.ml @@ -116,3 +116,47 @@ let tool_name s = Unix.getenv ("IMT_" ^ (String.uppercase s)) with Not_found -> s + +let build_reject_list () = + let rejs = + try + Some (Unix.getenv "IMT_REJ") + with Not_found -> + None + in + match rejs with + | None -> + [] + + | Some rejs -> + let l = String.length rejs in + let rec collect accu old_pos = + if old_pos >= l + then + accu + else + let pos = + try + String.index_from rejs old_pos ':' + with Not_found-> + l + in + let s = String.sub rejs old_pos (pos - old_pos) in + let accu = Str.regexp_string_case_fold s :: accu in + collect accu (pos + 1) + in + collect [] 0 + +let reject_path s = function + | [] -> false + | rejrel -> + let rec find = function + | [] -> false + | rejre :: tl -> + if Str.string_partial_match rejre s 0 + then + true + else + find tl + in + find rejrel -- 2.11.4.GIT