aboutsummaryrefslogtreecommitdiffstats
path: root/driver/Configuration.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-11-26 19:04:04 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2015-11-26 19:04:04 +0100
commit730966facd095f87620aa8d0798ccac7e36aa589 (patch)
treec99089d87ac7a8a74c00be231587f7fcb1484f86 /driver/Configuration.ml
parent373b7e7d2ef35d7d07070abc28680b48cbb307d9 (diff)
downloadcompcert-kvx-730966facd095f87620aa8d0798ccac7e36aa589.tar.gz
compcert-kvx-730966facd095f87620aa8d0798ccac7e36aa589.zip
New option --conf.
The option --conf allows it to overwrite the compcert.ini file. Bug 17431.
Diffstat (limited to 'driver/Configuration.ml')
-rw-r--r--driver/Configuration.ml48
1 files changed, 30 insertions, 18 deletions
diff --git a/driver/Configuration.ml b/driver/Configuration.ml
index 1f05afd8..50e251c4 100644
--- a/driver/Configuration.ml
+++ b/driver/Configuration.ml
@@ -12,28 +12,40 @@
open Printf
+let search_argv key =
+ let len = Array.length Sys.argv in
+ let res: string option ref = ref None in
+ for i = 1 to len - 2 do
+ if Sys.argv.(i) = key then
+ res := Some Sys.argv.(i + 1);
+ done;
+ !res
+
(* Locate the .ini file, which is either in the same directory as
the executable or in the directory ../share *)
let ini_file_name =
- try
- Sys.getenv "COMPCERT_CONFIG"
- with Not_found ->
- let exe_dir = Filename.dirname Sys.executable_name in
- let share_dir =
- Filename.concat (Filename.concat exe_dir Filename.parent_dir_name)
- "share" in
- 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
- try
- List.find Sys.file_exists files
- with Not_found ->
- begin
- eprintf "Cannot find compcert.ini configuration file.\n";
- exit 2
- end
+ match search_argv "--conf" with
+ | Some s -> s
+ | None ->
+ try
+ Sys.getenv "COMPCERT_CONFIG"
+ with Not_found ->
+ let exe_dir = Filename.dirname Sys.executable_name in
+ let share_dir =
+ Filename.concat (Filename.concat exe_dir Filename.parent_dir_name)
+ "share" in
+ 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
+ try
+ List.find Sys.file_exists files
+ with Not_found ->
+ begin
+ eprintf "Cannot find compcert.ini configuration file.\n";
+ exit 2
+ end
(* Read in the .ini file *)