diff options
author | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2015-12-19 16:43:40 +0100 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2015-12-19 16:43:40 +0100 |
commit | cf6be884d6ac2713553ec18339314211716d8af4 (patch) | |
tree | 0201fcc8e0df369f23a2397a1de38f69c8cd3ad7 /driver/Configuration.ml | |
parent | 0c9eaaf7d6cb229437bac8d3b11c88e2b05268a8 (diff) | |
parent | 36fa22560e2a289c9f75f0fe058b72eaad6d53b4 (diff) | |
download | compcert-cf6be884d6ac2713553ec18339314211716d8af4.tar.gz compcert-cf6be884d6ac2713553ec18339314211716d8af4.zip |
Merge pull request #79 from AbsInt/config-option
Add "-conf <filename>" command-line option. Support relative paths for stdlib and tools.
Diffstat (limited to 'driver/Configuration.ml')
-rw-r--r-- | driver/Configuration.ml | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/driver/Configuration.ml b/driver/Configuration.ml index 50e251c4..3025391b 100644 --- a/driver/Configuration.ml +++ b/driver/Configuration.ml @@ -21,16 +21,25 @@ let search_argv key = done; !res +let absolute_path base file = + if Filename.is_relative file then + Filename.concat base file + else + file + (* Locate the .ini file, which is either in the same directory as the executable or in the directory ../share *) let ini_file_name = - match search_argv "--conf" with - | Some s -> s + match search_argv "-conf" with + | Some s -> absolute_path (Sys.getcwd ()) s | None -> try Sys.getenv "COMPCERT_CONFIG" with Not_found -> + let ini_name = match search_argv "-target" with + | Some s -> s^".ini" + | None -> "compcert.ini" in let exe_dir = Filename.dirname Sys.executable_name in let share_dir = Filename.concat (Filename.concat exe_dir Filename.parent_dir_name) @@ -38,7 +47,7 @@ let ini_file_name = let share_compcert_dir = Filename.concat share_dir "compcert" in let search_path = [exe_dir;share_dir;share_compcert_dir] in - let files = List.map (fun s -> Filename.concat s "compcert.ini") search_path in + let files = List.map (fun s -> Filename.concat s ini_name) search_path in try List.find Sys.file_exists files with Not_found -> @@ -47,6 +56,8 @@ let ini_file_name = exit 2 end +let ini_dir = Filename.dirname ini_file_name + (* Read in the .ini file *) let _ = @@ -82,9 +93,19 @@ let get_config_list key = | [] -> bad_config key [] | vl -> vl -let prepro = get_config_list "prepro" -let asm = get_config_list "asm" -let linker = get_config_list "linker" +let tool_absolute_path tools = + match tools with + | [] -> [] + | tool::args -> let tool = + if Filename.is_implicit tool && Filename.dirname tool = Filename.current_dir_name then + tool + else + absolute_path ini_dir tool in + tool::args + +let prepro = tool_absolute_path (get_config_list "prepro") +let asm = tool_absolute_path (get_config_list "asm") +let linker = tool_absolute_path (get_config_list "linker") let arch = match get_config_string "arch" with | "powerpc"|"arm"|"ia32" as a -> a @@ -104,7 +125,8 @@ let has_standard_headers = | v -> bad_config "has_standard_headers" [v] let stdlib_path = if has_runtime_lib then - get_config_string "stdlib_path" + let path = get_config_string "stdlib_path" in + absolute_path ini_dir path else "" let asm_supports_cfi = |