diff --git a/CHANGES.md b/CHANGES.md index 357f02e7..d743d037 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -65,8 +65,12 @@ next `META.pkg.template`. This feature was unused and was making the code complicated (#370) + - Remove read-only attribute on Windows before unlink (#247) +- Use /Fo instead of -o when invoking the Microsoft C compiler to eliminate + deprecation warning when compiling C++ sources (#354) + 1.0+beta16 (05/11/2017) ----------------------- diff --git a/src/arg_spec.ml b/src/arg_spec.ml index 58fa09ab..8b6799f4 100644 --- a/src/arg_spec.ml +++ b/src/arg_spec.ml @@ -6,6 +6,7 @@ type 'a t = | A of string | As of string list | S of 'a t list + | Concat of string * 'a t list | Dep of Path.t | Deps of Path.t list | Target of Path.t @@ -18,14 +19,16 @@ let rec add_deps ts set = match t with | Dep fn -> Pset.add fn set | Deps fns -> Pset.union set (Pset.of_list fns) - | S ts -> add_deps ts set + | S ts + | Concat (_, ts) -> add_deps ts set | _ -> set) let rec add_targets ts acc = List.fold_left ts ~init:acc ~f:(fun acc t -> match t with | Target fn -> fn :: acc - | S ts -> add_targets ts acc + | S ts + | Concat (_, ts) -> add_targets ts acc | _ -> acc) let expand ~dir ts x = @@ -45,6 +48,7 @@ let expand ~dir ts x = | Paths fns -> List.map fns ~f:(Path.reach ~from:dir) | S ts -> List.concat_map ts ~f:loop_dyn + | Concat (sep, ts) -> [String.concat ~sep (loop_dyn (S ts))] | Target _ -> die "Target not allowed under Dyn" | Dyn _ -> assert false in @@ -54,6 +58,7 @@ let expand ~dir ts x = | (Dep fn | Path fn) -> [Path.reach fn ~from:dir] | (Deps fns | Paths fns) -> List.map fns ~f:(Path.reach ~from:dir) | S ts -> List.concat_map ts ~f:loop + | Concat (sep, ts) -> [String.concat ~sep (loop (S ts))] | Target fn -> [Path.reach fn ~from:dir] | Dyn f -> loop_dyn (f x) in diff --git a/src/arg_spec.mli b/src/arg_spec.mli index 0dfe9ba8..4c6b3fa8 100644 --- a/src/arg_spec.mli +++ b/src/arg_spec.mli @@ -4,6 +4,7 @@ type 'a t = | A of string | As of string list | S of 'a t list + | Concat of string * 'a t list (** Concatenation with a custom separator *) | Dep of Path.t (** A path that is a dependency *) | Deps of Path.t list | Target of Path.t diff --git a/src/gen_rules.ml b/src/gen_rules.ml index 3e8506e9..e91bc6da 100644 --- a/src/gen_rules.ml +++ b/src/gen_rules.ml @@ -413,6 +413,13 @@ Add it to your jbuild file to remove this warning. let build_cxx_file (lib : Library.t) ~scope ~dir ~requires ~h_files c_name = let src = Path.relative dir (c_name ^ ".cpp") in let dst = Path.relative dir (c_name ^ ctx.ext_obj) in + let open Arg_spec in + let output_param = + if ctx.ccomp_type = "msvc" then + [Concat ("", [A "/Fo"; Target dst])] + else + [A "-o"; Target dst] + in SC.add_rule sctx (Build.paths h_files >>> @@ -425,15 +432,15 @@ Add it to your jbuild file to remove this warning. the current directory *) ~dir (SC.resolve_program sctx ctx.c_compiler) - [ S [A "-I"; Path ctx.stdlib_dir] - ; As (SC.cxx_flags sctx) - ; Dyn (fun (cxx_flags, libs) -> - S [ Lib.c_include_flags libs - ; As cxx_flags - ]) - ; A "-o"; Target dst - ; A "-c"; Dep src - ]); + ([ S [A "-I"; Path ctx.stdlib_dir] + ; As (SC.cxx_flags sctx) + ; Dyn (fun (cxx_flags, libs) -> + S [ Lib.c_include_flags libs + ; As cxx_flags + ]) + ] @ output_param @ + [ A "-c"; Dep src + ])); dst (* In 4.02, the compiler reads the cmi for module alias even with [-w -49