Fix opaque calculation for includes

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-08-02 09:15:01 +02:00
parent b394896c1f
commit e09bbfcd6e
5 changed files with 29 additions and 9 deletions

View File

@ -5,7 +5,7 @@ module SC = Super_context
module Includes = struct module Includes = struct
type t = string list Arg_spec.t Cm_kind.Dict.t type t = string list Arg_spec.t Cm_kind.Dict.t
let make sctx ~opaque ~requires : _ Cm_kind.Dict.t = let make sctx ~requires : _ Cm_kind.Dict.t =
match requires with match requires with
| Error exn -> Cm_kind.Dict.make_all (Arg_spec.Dyn (fun _ -> raise exn)) | Error exn -> Cm_kind.Dict.make_all (Arg_spec.Dyn (fun _ -> raise exn))
| Ok libs -> | Ok libs ->
@ -19,13 +19,18 @@ module Includes = struct
] ]
in in
let cmx_includes = let cmx_includes =
if opaque then Arg_spec.S
cmi_includes [ iflags
else ; Hidden_deps
Arg_spec.S [ iflags ( libs
; Hidden_deps |> List.map ~f:(fun lib ->
(SC.Libs.file_deps sctx libs ~ext:".cmi-and-.cmx") (lib, if Lib.opaque lib then
] ".cmi"
else
".cmi-and-.cmx"))
|> SC.Libs.file_deps_with_exts sctx
)
]
in in
{ cmi = cmi_includes { cmi = cmi_includes
; cmo = cmi_includes ; cmo = cmi_includes
@ -84,7 +89,7 @@ let create ~super_context ~scope ~dir ?(dir_kind=File_tree.Dune_file.Kind.Dune)
; lib_interface_module ; lib_interface_module
; flags ; flags
; requires ; requires
; includes = Includes.make super_context ~requires ~opaque ; includes = Includes.make super_context ~requires
; preprocessing ; preprocessing
; no_keep_locs ; no_keep_locs
; opaque ; opaque

View File

@ -338,6 +338,8 @@ let plugins t = t.info.plugins
let jsoo_runtime t = t.info.jsoo_runtime let jsoo_runtime t = t.info.jsoo_runtime
let unique_id t = t.unique_id let unique_id t = t.unique_id
let opaque t = t.info.opaque
let dune_version t = t.info.dune_version let dune_version t = t.info.dune_version
let src_dir t = t.info.src_dir let src_dir t = t.info.src_dir

View File

@ -26,6 +26,8 @@ val archives : t -> Path.t list Mode.Dict.t
val plugins : t -> Path.t list Mode.Dict.t val plugins : t -> Path.t list Mode.Dict.t
val jsoo_runtime : t -> Path.t list val jsoo_runtime : t -> Path.t list
val opaque : t -> bool
val dune_version : t -> Syntax.Version.t option val dune_version : t -> Syntax.Version.t option
(** A unique integer identifier. It is only unique for the duration of (** A unique integer identifier. It is only unique for the duration of

View File

@ -708,6 +708,15 @@ module Libs = struct
(lib_files_alias ~dir ~name:(Library.best_name lib) ~ext)) (lib_files_alias ~dir ~name:(Library.best_name lib) ~ext))
|> Path.Set.of_list) |> Path.Set.of_list)
let file_deps_with_exts t lib_exts =
List.rev_map lib_exts ~f:(fun ((lib : Lib.t), ext) ->
if Lib.is_local lib then
Alias.stamp_file
(lib_files_alias ~dir:(Lib.src_dir lib) ~name:(Lib.name lib) ~ext)
else
Build_system.stamp_file_for_files_of t.build_system
~dir:(Lib.obj_dir lib) ~ext)
let file_deps t libs ~ext = let file_deps t libs ~ext =
List.rev_map libs ~f:(fun (lib : Lib.t) -> List.rev_map libs ~f:(fun (lib : Lib.t) ->
if Lib.is_local lib then if Lib.is_local lib then

View File

@ -197,6 +197,8 @@ module Libs : sig
all the files with extension [ext] of libraries [libs]. *) all the files with extension [ext] of libraries [libs]. *)
val file_deps : t -> Lib.L.t -> ext:string -> Path.t list val file_deps : t -> Lib.L.t -> ext:string -> Path.t list
val file_deps_with_exts : t -> (Lib.t * string) list -> Path.t list
(** Setup the alias that depends on all files with a given extension (** Setup the alias that depends on all files with a given extension
for a library *) for a library *)
val setup_file_deps_alias val setup_file_deps_alias