Use /Fo instead of -o when invoking CL
The -o option in the Microsoft C Compiler is deprecated (and has been for a very long time). The warning is tedious, so use /Fo instead. The only problem with this is that "-o foo.obj" must become "/Fofoo.obj" with no space, which requires a little support in Arg_spec. Signed-off-by: David Allsopp <david.allsopp@metastack.com>
This commit is contained in:
parent
f9837a278b
commit
61b3e5f189
|
@ -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)
|
||||
-----------------------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue