From f8873c38a261e24b4d2293b62adbc7b7051aa3f8 Mon Sep 17 00:00:00 2001 From: ygrek Date: Mon, 27 Jul 2009 12:50:05 +0300 Subject: [PATCH] determine version with myocamlbuild --- src/build | 2 -- src/build.bat | 1 - src/make_version.ml | 1 - src/myocamlbuild.ml | 16 ++++++++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) delete mode 100644 src/make_version.ml diff --git a/src/build b/src/build index 1435f1e..a7011a4 100755 --- a/src/build +++ b/src/build @@ -1,3 +1 @@ - -git describe | ocaml make_version.ml > git.ml ocamlbuild sqlgg.byte diff --git a/src/build.bat b/src/build.bat index 4b2f192..d7737df 100644 --- a/src/build.bat +++ b/src/build.bat @@ -1,4 +1,3 @@ del sqlgg.exe -git describe | ocaml make_version.ml > git.ml ocamlbuild -classic-display -no-links sqlgg.byte copy _build\sqlgg.byte sqlgg.exe diff --git a/src/make_version.ml b/src/make_version.ml deleted file mode 100644 index 148de66..0000000 --- a/src/make_version.ml +++ /dev/null @@ -1 +0,0 @@ -print_endline ("let revision=\"" ^ input_line stdin ^ "\"") diff --git a/src/myocamlbuild.ml b/src/myocamlbuild.ml index 6dff773..656867b 100644 --- a/src/myocamlbuild.ml +++ b/src/myocamlbuild.ml @@ -5,6 +5,22 @@ module C = Myocamlbuild_config ;; +let () = + let with_res res destroy k = let x = (try k res with e -> destroy res; raise e) in destroy res; x in + let get_line r d = with_res r d input_line in + + with_res (open_out "git.ml") close_out (fun out -> + let revision = + try + get_line (Unix.open_process_in "git describe --always") (Unix.close_process_in) + with + _ -> (try get_line (open_in "git.describe") close_in with _ -> "") + in + Printf.fprintf out "let revision=\"%s\"\n" (String.escaped revision) + ) + +;; + dispatch begin function | After_rules -> -- 2.11.4.GIT