From 92b0564856fb3e20a09bead04d5c1b21eed224e1 Mon Sep 17 00:00:00 2001 From: Alasdair Date: Mon, 18 May 2020 16:41:41 +0100 Subject: Add a prefix option for generated coverage files --- sailcov/README.md | 2 +- sailcov/main.ml | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'sailcov') diff --git a/sailcov/README.md b/sailcov/README.md index 069ed7c0..17c6b395 100644 --- a/sailcov/README.md +++ b/sailcov/README.md @@ -52,5 +52,5 @@ and uncovered code can be individually set. Alternatively the default red/green colours for uncovered/covered can be swapped for a yellow/blue theme using `--alt-colors` or `--alt-colours`. See the alternate -[riscv_vmem_sv39.html](https://alasdair.github.io/riscv_vmem_sv39_alt.html) +[riscv_vmem_sv39.html](https://alasdair.github.io/alt_riscv_vmem_sv39.html) for an example. diff --git a/sailcov/main.ml b/sailcov/main.ml index 96c8fdf6..4f1e054c 100644 --- a/sailcov/main.ml +++ b/sailcov/main.ml @@ -2,13 +2,13 @@ let opt_files = ref ([] : string list) let opt_taken = ref "sail_coverage" - let opt_all = ref "all_branches" let opt_tab_width = ref 4 let opt_index = ref None let opt_index_default = ref None +let opt_prefix = ref "" type color = { hue: int; @@ -45,10 +45,13 @@ let options = " set the tab width for html output (default: 4)"); ( "--index", Arg.String (fun str -> opt_index := Some str), - " create an .html page as an index"); + " create a .html page as an index"); ( "--index-default", Arg.String (fun str -> opt_index_default := Some str), " The .sail file that will be displayed by the generated index page by default"); + ( "--prefix", + Arg.String (fun str -> opt_prefix := str), + " Prepend a prefix to all generated html coverage files"); ( "--covered-hue", Arg.Int (fun n -> opt_good_color := { !opt_good_color with hue = clamp_degree n }), " set the hue (between 0 and 360) of the color used for code that is covered (default: 120 (green))"); @@ -232,7 +235,10 @@ iframe { padding: 0; } " - + +let html_file_for file = + !opt_prefix ^ Filename.remove_extension (Filename.basename file) ^ ".html" + let main () = let all = read_coverage !opt_all in let taken = read_coverage !opt_taken in @@ -244,7 +250,7 @@ let main () = SpanSet.iter (mark_good_region source) taken; SpanSet.iter (mark_bad_region source) not_taken; - let output_file = Filename.remove_extension (Filename.basename file) ^ ".html" in + let output_file = html_file_for file in let chan = open_out output_file in let current_goodness = ref 0 in @@ -342,16 +348,16 @@ let main () = output_string chan ""; output_string chan "
"; List.iter (fun file -> let _, _, desc = file_info file all taken in - Printf.ksprintf (output_string chan) "%s
\n" - (Filename.remove_extension (Filename.basename file)) desc + Printf.ksprintf (output_string chan) "%s
\n" + (html_file_for file) desc ) !opt_files; output_string chan "
"; begin match !opt_index_default with | Some default_file -> - Printf.ksprintf (output_string chan) "" - (Filename.remove_extension (Filename.basename default_file)); + Printf.ksprintf (output_string chan) "" + (html_file_for default_file); | None -> output_string chan "" end; -- cgit v1.2.3