Commit b9832611 authored by erwan's avatar erwan
Browse files

Build: fix the version number for opam releases

parent d9b3cdf1
Pipeline #23936 passed with stages
in 3 minutes and 47 seconds
SHA:=$(shell git log -1 --pretty=format:"%h")
# Both work. Which one is the best?
VERSION=$(shell ./node_modules/.bin/git-latest-semver-tag)
VERSION=$(shell git describe --tags)
# if it is not a git version, it has to be an opam version!
SHA:=$(shell git log -1 --pretty=format:"%h" || echo "opam")
BRANCH:=$(shell git branch | grep "*" | cut -d ' ' -f 2 || basename `pwd` | echo "opam")
VERSION=$(shell git describe --tags || basename `pwd` | cut -d '.' -f2-4)
del_version:
rm -f src/lutilsVersion.ml
......
(* Time-stamp: <modified the 13/04/2018 (at 10:19) by Erwan Jahier> *)
(* Time-stamp: <modified the 15/05/2019 (at 10:55) by Erwan Jahier> *)
(* Should rather be named misc or utils *)
......@@ -132,10 +132,11 @@ let entete2 comment_open comment_close version sha =
and hostname = Unix.gethostname ()
in
(comment_open ^ " Automatically generated by "^
Sys.executable_name^" version \""^version^"\" (\"" ^sha^"\")"^comment_close^"\n" ^
comment_open ^ " on " ^ hostname ^
Sys.executable_name^" version \""^version^"\" (\"" ^sha^"\")"^
comment_close^"\n" ^ comment_open ^ " on " ^ hostname ^
" the " ^ date ^ " at " ^ time_str ^comment_close^"\n" ^
comment_open^(String.concat " " (Array.to_list Sys.argv))^ comment_close^"\n\n")
comment_open^(String.concat " " (Array.to_list Sys.argv))^
comment_close^"\n\n")
(* for one-line comments *)
let entete comment version sha = entete2 comment "" version sha
......@@ -147,76 +148,77 @@ type my_create_process_result =
| KO
| PID of int (* if called with ~wait:false *)
let (my_create_process : ?std_in:(Unix.file_descr) -> ?std_out:(Unix.file_descr) ->
let (my_create_process :
?std_in:(Unix.file_descr) -> ?std_out:(Unix.file_descr) ->
?std_err:(Unix.file_descr) ->
?wait:(bool) -> string -> string list -> my_create_process_result) =
fun ?(std_in = Unix.stdin) ?(std_out = Unix.stdout) ?(std_err = Unix.stderr)
?(wait = true) prog args ->
try
let pid =
List.iter (fun x -> output_string stderr (x ^ " ")) (prog::args);
output_string stderr "\n";
flush stderr;
Unix.create_process
prog
(Array.of_list (prog::args))
(std_in)
(std_out)
(std_err)
in
if not wait then PID pid else
let (_,status) = (Unix.waitpid [Unix.WUNTRACED] pid) in
( match status with
Unix.WEXITED i ->
if i = 0 || i = 1 then
(
output_string stderr (" ... " ^ prog ^ " exited normally.\n");
flush stderr;
OK
)
else
(
output_string stderr (
"*** Error: " ^ prog ^ " exited abnormally (return code=" ^
(string_of_int i)^").\n");
flush stderr;
KO
)
| Unix.WSIGNALED i->
output_string stderr (
"*** Error: " ^ prog ^
" process was killed by signal "^(string_of_int i)^"\n");
flush stderr;
KO
| Unix.WSTOPPED i ->
output_string stderr (
"*** Error: " ^ prog ^ " process was stopped by signal " ^
(string_of_int i)^"\n");
flush stderr;
KO
)
with
| Unix.Unix_error(error, name, arg) ->
let msg = ( "*** '" ^
(Unix.error_message error) ^
"'in the system call: '" ^ name ^ " " ^ arg ^ "'\n")
in
output_string stdout msg;
flush stdout;
output_string stderr msg;
flush stderr;
KO
| e ->
output_string stdout (Printexc.to_string e);
flush stdout;
output_string stderr (Printexc.to_string e);
flush stderr;
KO
try
let pid =
List.iter (fun x -> output_string stderr (x ^ " ")) (prog::args);
output_string stderr "\n";
flush stderr;
Unix.create_process
prog
(Array.of_list (prog::args))
(std_in)
(std_out)
(std_err)
in
if not wait then PID pid else
let (_,status) = (Unix.waitpid [Unix.WUNTRACED] pid) in
( match status with
Unix.WEXITED i ->
if i = 0 || i = 1 then
(
output_string stderr (" ... "^prog^" exited normally.\n");
flush stderr;
OK
)
else
(
output_string stderr (
"*** Error: " ^ prog ^ " exited abnormally (return code=" ^
(string_of_int i)^").\n");
flush stderr;
KO
)
| Unix.WSIGNALED i->
output_string stderr (
"*** Error: " ^ prog ^
" process was killed by signal "^(string_of_int i)^"\n");
flush stderr;
KO
| Unix.WSTOPPED i ->
output_string stderr (
"*** Error: " ^ prog ^ " process was stopped by signal " ^
(string_of_int i)^"\n");
flush stderr;
KO
)
with
| Unix.Unix_error(error, name, arg) ->
let msg = ( "*** '" ^
(Unix.error_message error) ^
"'in the system call: '" ^ name ^ " " ^ arg ^ "'\n")
in
output_string stdout msg;
flush stdout;
output_string stderr msg;
flush stderr;
KO
| e ->
output_string stdout (Printexc.to_string e);
flush stdout;
output_string stderr (Printexc.to_string e);
flush stderr;
KO
(* run a cmd and collect the stdout lines into a list (requires sed) *)
let (run : string -> (string -> string option) -> string list) =
fun cmd filter ->
let proc = Unix.open_process_in ("(" ^ cmd ^ " | sed -e 's/^/stdout: /' ) 2>&1") in
let proc = Unix.open_process_in ("("^cmd^" | sed -e 's/^/stdout: /' ) 2>&1") in
let list = ref [] in
try
while true do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment