Fix copy# for Microsoft C compiler

Microsoft CL doesn't support #n and requires the more strictly correct
directive #line

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
This commit is contained in:
David Allsopp 2017-12-07 21:12:16 +00:00
parent 7b6db8a3c2
commit 9d3c0b649c
4 changed files with 13 additions and 1 deletions

View File

@ -26,6 +26,8 @@ next
- Fix doc generation when several private libraries have the same name (#369)
- Fix copy# for C/C++ with Microsoft C compiler (#353)
1.0+beta16 (05/11/2017)
-----------------------

View File

@ -596,7 +596,13 @@ let rec exec t ~ectx ~dir ~env_extra ~stdout_to ~stderr_to =
Io.with_file_in (Path.to_string src) ~f:(fun ic ->
Io.with_file_out (Path.to_string dst) ~f:(fun oc ->
let fn = Path.drop_build_context src in
Printf.fprintf oc "# 1 %S\n" (Path.to_string fn);
let directive =
if List.mem (Path.extension fn) ~set:[".c"; ".cpp"; ".h"] then
"line"
else
""
in
Printf.fprintf oc "#%s 1 %S\n" directive (Path.to_string fn);
Io.copy_channels ic oc));
return ()
| System cmd ->

View File

@ -426,4 +426,6 @@ let change_extension ~ext t =
let t = try Filename.chop_extension t with Not_found -> t in
t ^ ext
let extension = Filename.extension
let pp = Format.pp_print_string

View File

@ -112,4 +112,6 @@ val rm_rf : t -> unit
(** Changes the extension of the filename (or adds an extension if there was none) *)
val change_extension : ext:string -> t -> t
val extension : t -> string
val pp : t Fmt.t