Skip to content

Commit

Permalink
Add a way to strip the licence header.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepigre committed Nov 18, 2021
1 parent 2597a1e commit 52959e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ update_license:
ocaml tools/update_license.ml LICENSE ${SRC}
.PHONY: update_license

strip_license:
ocaml tools/update_license.ml --strip ${SRC}
.PHONY: strip_license

builddep-opamfiles: builddep/islaris-builddep.opam
@true
.PHONY: builddep-opamfiles
Expand Down
27 changes: 18 additions & 9 deletions tools/update_license.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,24 @@ let strip_header lines =
let _ =
let (license, files) =
match List.tl (Array.to_list Sys.argv) with
| license :: files -> (license, files)
| _ ->
| "--strip" :: files -> (None , files)
| license :: files -> (Some(license), files)
| _ ->
let prog = Sys.argv.(0) in
Printf.eprintf "Usage: %s LICENSE_FILE FILE1 ... FILEN\n%!" prog;
Printf.eprintf "Usage: %s [LICENSE_FILE | --strip] FILE ...\n%!" prog;
exit 1
in
let header = wrap_in_comment license in
let handle_file file =
let lines = header @ "" :: strip_header (read_file file) in
write_file file lines
in
List.iter handle_file files
match license with
| Some(license) ->
let header = wrap_in_comment license in
let handle_file file =
let lines = header @ "" :: strip_header (read_file file) in
write_file file lines
in
List.iter handle_file files
| None ->
let handle_file file =
let lines = strip_header (read_file file) in
write_file file lines
in
List.iter handle_file files

0 comments on commit 52959e4

Please sign in to comment.