diff options
| author | Alasdair Armstrong | 2018-12-20 22:58:44 +0000 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-12-20 23:07:24 +0000 |
| commit | 367f72900fd24bf51b135f04f6fd301f3e8efb15 (patch) | |
| tree | 782515d2b9dfda003ccab35b938d0cf3cf4028eb /src | |
| parent | 0a9200153430f5e727b3ebe1fa272d4842069530 (diff) | |
Make sure sail -v prints useful version info
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 19 | ||||
| -rw-r--r-- | src/ocaml_backend.ml | 2 | ||||
| -rw-r--r-- | src/process_file.ml | 2 | ||||
| -rw-r--r-- | src/sail.ml | 15 |
4 files changed, 27 insertions, 11 deletions
diff --git a/src/Makefile b/src/Makefile index 3e9d6f63..b658d90d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -62,7 +62,7 @@ endif endif -.PHONY: all sail sail.native sail.byte test clean doc lib power test_power test_idempotence +.PHONY: all sail sail.native sail.byte manifest.ml test clean doc lib power test_power test_idempotence # set to -p on command line to enable gprof profiling OCAML_OPTS?= @@ -90,19 +90,22 @@ bytecode.ml: bytecode.lem lem_interp/interp_ast.lem: ../language/l2.ott ott -sort false -generate_aux_rules true -o lem_interp/interp_ast.lem -picky_multiple_parses true ../language/l2.ott -share_directory.ml: - echo "(* Generated file -- do not edit. *)" > share_directory.ml - echo let d=\"$(SHARE_DIR)\" >> share_directory.ml +manifest.ml: + echo "(* Generated file -- do not edit. *)" > manifest.ml + echo let dir=\"$(SHARE_DIR)\" >> manifest.ml + echo let commit=\"$(shell git rev-parse HEAD)\" >> manifest.ml + echo let branch=\"$(shell git rev-parse --abbrev-ref HEAD)\" >> manifest.ml + echo let version=\"$(shell git describe)\" >> manifest.ml -sail: ast.ml bytecode.ml share_directory.ml +sail: ast.ml bytecode.ml manifest.ml ocamlbuild -use-ocamlfind sail.native sail_lib.cma sail_lib.cmxa -isail: ast.ml bytecode.ml share_directory.ml +isail: ast.ml bytecode.ml manifest.ml ocamlbuild -use-ocamlfind isail.native sail.native: sail -sail.byte: ast.ml bytecode.ml share_directory.ml +sail.byte: ast.ml bytecode.ml manifest.ml ocamlbuild -use-ocamlfind -cflag -g sail.byte interpreter: lem_interp/interp_ast.lem @@ -148,7 +151,7 @@ clean: -rm -f bytecode.ml -rm -f bytecode.lem -rm -f bytecode.ml.bak - -rm -f share_directory.ml + -rm -f manifest.ml doc: ocamlbuild -use-ocamlfind sail.docdir/index.html diff --git a/src/ocaml_backend.ml b/src/ocaml_backend.ml index d075e693..ad2c198e 100644 --- a/src/ocaml_backend.ml +++ b/src/ocaml_backend.ml @@ -963,7 +963,7 @@ let ocaml_compile spec defs generator_types = let sail_dir = try Sys.getenv "SAIL_DIR" with | Not_found -> - let share_dir = Share_directory.d in + let share_dir = Manifest.dir in if Sys.file_exists share_dir then share_dir else diff --git a/src/process_file.ml b/src/process_file.ml index ca013077..0194baa8 100644 --- a/src/process_file.ml +++ b/src/process_file.ml @@ -191,7 +191,7 @@ let rec preprocess opts = function let sail_dir = try Sys.getenv "SAIL_DIR" with | Not_found -> - let share_dir = Share_directory.d in + let share_dir = Manifest.dir in if Sys.file_exists share_dir then share_dir else diff --git a/src/sail.ml b/src/sail.ml index f88fff5a..247cae25 100644 --- a/src/sail.ml +++ b/src/sail.ml @@ -304,9 +304,22 @@ let load_files type_envs files = (out_name, ast, type_envs) +let print_version () = + let open Manifest in + let default = Printf.sprintf "Sail %s @ %s" branch commit in + (* version is the output of git describe *) + match String.split_on_char '-' version with + | [vnum; _; _] -> + (try + let vnum = float_of_string vnum +. 2.0 in + Printf.printf "Sail %.1f (%s @ %s)\n" vnum branch commit + with + | Failure _ -> print_endline default) + | _ -> print_endline default + let main() = if !opt_print_version - then Printf.printf "Sail 2.0\n" + then print_version () else let out_name, ast, type_envs = load_files Type_check.initial_env !opt_file_arguments in Util.opt_warnings := false; (* Don't show warnings during re-writing for now *) |
