Skip to content
Snippets Groups Projects
Commit 3fa6378d authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Add a header at top of generated files saying when, by who, how the file was generated.

parent bb580520
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
OCAMLMAKEFILE = ./OCamlMakefile
RESULT=lus2lic
LIBS = str
LIBS = str unix
OCAMLC=ocamlc
ifndef SOURCES
......
(** Time-stamp: <modified the 05/02/2009 (at 14:56) by Erwan Jahier> *)
(** Time-stamp: <modified the 05/02/2009 (at 15:30) by Erwan Jahier> *)
(** Here follows a description of the different modules used by this lus2lic compiler.
......@@ -248,6 +248,41 @@ let (get_source_list : string list -> SyntaxTree.pack_or_model list) =
| Unpacked pack -> [pack]
let dump_entete oc =
let time = Unix.localtime (Unix.time ()) in
let sys_call, _ = Array.fold_left
(fun (acc,i) x ->
if 70 < i + (String.length x) then
acc ^ "\n--\t\t" ^ x, String.length ("\n--\t\t" ^ x)
else
acc ^ " " ^ x , (i+1+(String.length x))
)
("",0)
Sys.argv
and
date = (
(string_of_int time.Unix.tm_mday) ^ "/" ^
(string_of_int (time.Unix.tm_mon+1)) ^ "/" ^
(string_of_int (1900+time.Unix.tm_year))
)
and time_str = (
(string_of_int time.Unix.tm_hour) ^ ":" ^
(if time.Unix.tm_min < 10 then "0" else "") ^
(string_of_int time.Unix.tm_min) ^ ":" ^
(if time.Unix.tm_sec < 10 then "0" else "") ^
(string_of_int time.Unix.tm_sec)
)
(* and user = Unix.getlogin () *)
and hostname = Unix.gethostname ()
in
output_string oc
("-- This file was generated by lus2lic version " ^ Version.str ^
".\n--\t" ^ sys_call ^ "
-- on " ^ hostname ^
(* "by "^ user ^ *)
" the " ^ date ^ " at " ^ time_str ^ "\n\n");
flush oc
let my_exit i =
close_out !Global.oc;
......@@ -272,6 +307,7 @@ let main = (
Some (Ident.idref_of_string !Global.main_node)
in
if !Global.outfile <> "" then Global.oc := open_out !Global.outfile;
dump_entete !Global.oc;
Compile.doit nsl main_node;
LicDump.dump_type_alias !Global.oc;
close_out !Global.oc
......
......@@ -52,9 +52,10 @@ help:
version:
$(LC0) --version
FILTER= grep -v "file was generated by" | grep -v " on "
do_not_exist:
$(LC) do_not_exist.lus >> test_ko.res 2>&1 || true
$(LC) do_not_exist.lus | $(FILTER) >> test_ko.res 2>&1 || true
same_file:
$(LC) should_work/NONREG/ex.lus should_work/NONREG/ex.lus >> test_ok.res 2>&1
......@@ -62,13 +63,13 @@ same_file:
test: begin unit help version do_not_exist same_file
for d in ${OK_LUS}; do \
echo -e "\n$(NL)====> $(LC) $$d" >> test_ok.res; \
$(LC) $$d >> test_ok.res 2>&1 ;\
$(LC) $$d >> test_ok.res 2>&1 ;\
done; \
for d in ${KO_LUS}; do \
echo -e "\n$(NL)====> $(LC) $$d" >> test_ko.res; \
$(LC) $$d >> test_ko.res 2>&1 ;\
$(LC) $$d >> test_ko.res 2>&1 ;\
done; \
rm -f test.res ; cat test_ok.res test_ko.res > test.res ;\
rm -f test.res ; cat test_ok.res test_ko.res | $(FILTER) > test.res ;\
diff -u test.res.exp test.res > test.diff || \
(cat test.diff ; echo "cf test.diff"; exit 1)
utest:
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment