aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-06-26 21:53:02 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-06-26 21:53:02 +0200
commitdaf9ac64fc9611ecf09d70560a6fa1ba80b9c9c1 (patch)
tree01f2995f0dbce61599c141d10d493407bad95295 /driver
parent6b7b7a73f6d04517ffeb4c6faa59ea403d85925f (diff)
downloadcompcert-daf9ac64fc9611ecf09d70560a6fa1ba80b9c9c1.tar.gz
compcert-daf9ac64fc9611ecf09d70560a6fa1ba80b9c9c1.zip
Added --version option to print version string.
Diffstat (limited to 'driver')
-rw-r--r--driver/Driver.ml28
1 files changed, 19 insertions, 9 deletions
diff --git a/driver/Driver.ml b/driver/Driver.ml
index 480cf665..805d5405 100644
--- a/driver/Driver.ml
+++ b/driver/Driver.ml
@@ -74,7 +74,7 @@ let print_error oc msg =
let output_filename ?(final = false) source_file source_suffix output_suffix =
match !option_o with
| Some file when final -> file
- | _ ->
+ | _ ->
Filename.basename (Filename.chop_suffix source_file source_suffix)
^ output_suffix
@@ -127,7 +127,7 @@ let parse_c_file sourcename ifile =
let oc = open_out ofile in
Cprint.program (Format.formatter_of_out_channel oc) ast;
close_out oc
- end;
+ end;
(* Conversion to Csyntax *)
let csyntax =
match Timing.time "CompCert C generation" C2C.convertProgram ast with
@@ -176,7 +176,7 @@ let compile_c_ast sourcename csyntax ofile debug =
| Errors.Error msg ->
print_error stderr msg;
exit 2 in
- (* Dump Asm in binary format *)
+ (* Dump Asm in binary format *)
if !option_sdump then
dump_asm asm (output_filename sourcename ".c" ".sdump");
(* Print Asm in text form *)
@@ -219,7 +219,7 @@ let compile_cminor_file ifile ofile =
eprintf "File %s, character %d: Syntax error\n"
ifile (Lexing.lexeme_start lb);
exit 2
- | CMlexer.Error msg ->
+ | CMlexer.Error msg ->
eprintf "File %s, character %d: %s\n"
ifile (Lexing.lexeme_start lb) msg;
exit 2
@@ -361,7 +361,7 @@ let process_h_file sourcename =
end else begin
eprintf "Error: input file %s ignored (not in -E mode)\n" sourcename;
exit 2
- end
+ end
(* Record actions to be performed after parsing the command line *)
@@ -386,9 +386,12 @@ let explode_comma_option s =
| [] -> assert false
| hd :: tl -> tl
+let version_string =
+ "The CompCert C verified compiler, version "^ Configuration.version ^ "\n"
+
let usage_string =
-"The CompCert C verified compiler, version " ^ Configuration.version ^ "
-Usage: ccomp [options] <source files>
+ version_string ^
+ "Usage: ccomp [options] <source files>
Recognized source files:
.c C source file
.i or .p C source file that should not be preprocessed
@@ -464,6 +467,7 @@ General options:
-stdlib <dir> Set the path of the Compcert run-time library
-v Print external commands before invoking them
-timings Show the time spent in various compiler passes
+ -version Print the version string and exit
Interpreter mode:
-interp Execute given .c files using the reference interpreter
-quiet Suppress diagnostic messages for the interpreter
@@ -475,6 +479,9 @@ Interpreter mode:
let print_usage_and_exit _ =
printf "%s" usage_string; exit 0
+let print_version_and_exit _ =
+ printf "%s" version_string; exit 0
+
let language_support_options = [
option_fbitfields; option_flongdouble;
option_fstruct_return; option_fvararg_calls; option_funprototyped;
@@ -497,13 +504,16 @@ let cmdline_actions =
(* Getting help *)
Exact "-help", Self print_usage_and_exit;
Exact "--help", Self print_usage_and_exit;
+(* Getting version info *)
+ Exact "-version", Self print_version_and_exit;
+ Exact "--version", Self print_version_and_exit;
(* Processing options *)
Exact "-c", Set option_c;
Exact "-E", Set option_E;
Exact "-S", Set option_S;
Exact "-o", String(fun s -> option_o := Some s);
Prefix "-o", Self (fun s -> let s = String.sub s 2 ((String.length s) - 2) in
- option_o := Some s);
+ option_o := Some s);
(* Preprocessing options *)
Exact "-I", String(fun s -> prepro_options := s :: "-I" :: !prepro_options);
Prefix "-I", Self(fun s -> prepro_options := s :: !prepro_options);
@@ -549,7 +559,7 @@ let cmdline_actions =
Exact "-dmach", Set option_dmach;
Exact "-dasm", Set option_dasm;
Exact "-sdump", Set option_sdump;
-(* General options *)
+(* General options *)
Exact "-v", Set option_v;
Exact "-stdlib", String(fun s -> stdlib_path := s);
Exact "-timings", Set option_timings;