Merge branch 'pr/238'

This commit is contained in:
Rudi Grinberg 2017-09-05 20:41:19 -04:00
commit 1da474bc4a
3 changed files with 31 additions and 1 deletions

View File

@ -86,6 +86,12 @@ module Gen(P : Params) = struct
else
fun x -> x
in
let objs (cm, _, _, _) =
if mode = Mode.Byte then
[]
else
List.map ~f:(Path.change_extension ~ext:ctx.ext_obj) cm
in
SC.add_rule sctx
(Build.fanout4
(dep_graph >>>
@ -100,6 +106,8 @@ module Gen(P : Params) = struct
(Ocaml_flags.get flags mode)
(SC.expand_and_eval_set sctx ~scope ~dir lib.library_flags ~standard:[])
>>>
Build.dyn_paths (Build.arr objs)
>>>
Build.run ~context:ctx (Dep compiler)
~extra_targets:(
match mode with
@ -376,6 +384,8 @@ module Gen(P : Params) = struct
let src = lib_archive lib ~dir ~ext:(Mode.compiled_lib_ext Native) in
let dst = lib_archive lib ~dir ~ext:".cmxs" in
let build =
Build.dyn_paths (Build.arr (fun () -> [lib_archive lib ~dir ~ext:ctx.ext_lib]))
>>>
Ocaml_flags.get flags Native
>>>
Build.run ~context:ctx
@ -440,8 +450,21 @@ module Gen(P : Params) = struct
~mode
[String.capitalize_ascii name]))
in
let objs (libs, cm) =
if mode = Mode.Byte then
[]
else
let libs =
let f = function
| Lib.Internal (dir, lib) -> Some (Path.relative dir (lib.name ^ ctx.ext_lib))
| External _ -> None
in
List.filter_map ~f libs
in
libs @ List.map ~f:(Path.change_extension ~ext:ctx.ext_obj) cm
in
SC.add_rule sctx
(libs_and_cm
((libs_and_cm >>> Build.dyn_paths (Build.arr objs))
&&&
Build.fanout
(Ocaml_flags.get flags mode)

View File

@ -411,3 +411,7 @@ let rm_rf =
match Unix.lstat fn with
| exception Unix.Unix_error(ENOENT, _, _) -> ()
| _ -> loop fn
let change_extension ~ext t =
let t = try Filename.chop_extension t with Not_found -> t in
t ^ ext

View File

@ -101,3 +101,6 @@ val rmdir : t -> unit
val unlink : t -> unit
val unlink_no_err : t -> unit
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