From fc96e9d50ced218e21991a58b86105ae5b6a296f Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Thu, 12 Dec 2024 11:22:04 +0100 Subject: [PATCH 1/5] feat(melange): add manifest information for `melange.emit` Signed-off-by: Antonio Nuno Monteiro --- otherlibs/chrome-trace/src/chrome_trace.mli | 2 +- src/dune_rules/melange/melange_rules.ml | 79 ++++++++++++++++--- src/dune_rules/melange/melange_stanzas.ml | 3 + src/dune_rules/melange/melange_stanzas.mli | 1 + .../test-cases/melange/manifest.t | 56 +++++++++++++ 5 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 test/blackbox-tests/test-cases/melange/manifest.t diff --git a/otherlibs/chrome-trace/src/chrome_trace.mli b/otherlibs/chrome-trace/src/chrome_trace.mli index 64c1947fbe3..c9f93655fb9 100644 --- a/otherlibs/chrome-trace/src/chrome_trace.mli +++ b/otherlibs/chrome-trace/src/chrome_trace.mli @@ -11,7 +11,7 @@ https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview *) module Json : sig - (** Simplifies JSON type *) + (** Simplified JSON type *) type t = [ `Int of int | `Float of float diff --git a/src/dune_rules/melange/melange_rules.ml b/src/dune_rules/melange/melange_rules.ml index 2812ddad4f1..e866192c88a 100644 --- a/src/dune_rules/melange/melange_rules.ml +++ b/src/dune_rules/melange/melange_rules.ml @@ -1,5 +1,17 @@ open Import open Memo.O +module Json = Dune_stats.Json + +(* attach [deps] to the specified [alias] AND the (dune default) [all] alias. + + when [alias] is not supplied, {!Melange_stanzas.Emit.implicit_alias} is + assumed. *) +let add_deps_to_aliases ?(alias = Melange_stanzas.Emit.implicit_alias) ~dir deps = + let alias = Alias.make alias ~dir in + let dune_default_alias = Alias.make Alias0.all ~dir in + let attach alias = Rules.Produce.Alias.add_deps alias deps in + Memo.parallel_iter ~f:attach [ alias; dune_default_alias ] +;; let output_of_lib = let public_lib ~info ~target_dir lib_name = @@ -47,6 +59,52 @@ let make_js_name ~js_ext ~output m = Path.Build.relative dst_dir basename ;; +module Manifest = struct + type mapping = + { source : Path.t + ; targets : Path.Build.t list + } + + type t = { mappings : mapping list } + + let sexp_of_mapping { source; targets } = + let source_str = Path.to_string source in + let target_strs = List.map targets ~f:Path.Build.to_string in + `Assoc [ source_str, `List (List.map target_strs ~f:(fun s -> `String s)) ] + ;; + + let json_of_t t = `List (List.map t.mappings ~f:sexp_of_mapping) + let to_string t = Json.to_string (json_of_t t) + + let create_mapping ~module_systems ~output m = + let source = Module.file m ~ml_kind:Impl |> Option.value_exn in + let targets = + List.map module_systems ~f:(fun (_, js_ext) -> make_js_name ~js_ext ~output m) + in + { source; targets } + ;; + + let setup_manifest_rule ~sctx ~dir ~target_dir ~mode mappings = + let manifest_path = Path.Build.relative target_dir "melange-manifest.sexp" in + Format.eprintf "Creating manifest rule@."; + Format.eprintf " dir: %s@." (Path.Build.to_string dir); + Format.eprintf " target_dir: %s@." (Path.Build.to_string target_dir); + Format.eprintf " mappings count: %d@." (List.length mappings); + Format.eprintf " manifest path: %s@." (Path.Build.to_string manifest_path); + let manifest = { mappings } in + let manifest_str = to_string manifest in + Format.eprintf " manifest content:@.%s@." manifest_str; + let* () = + Action_builder.return manifest_str + |> Action_builder.write_file_dyn manifest_path + |> Super_context.add_rule sctx ~dir:target_dir ~mode + in + let manifest_dep = Action_builder.path (Path.build manifest_path) in + let* () = add_deps_to_aliases ~dir:target_dir manifest_dep in + Memo.return () + ;; +end + let modules_in_obj_dir ~sctx ~scope ~preprocess modules = let* version = let+ ocaml = Context.ocaml (Super_context.context sctx) in @@ -250,17 +308,6 @@ let build_js Super_context.add_rule sctx ~dir ~loc ~mode build) ;; -(* attach [deps] to the specified [alias] AND the (dune default) [all] alias. - - when [alias] is not supplied, {!Melange_stanzas.Emit.implicit_alias} is - assumed. *) -let add_deps_to_aliases ?(alias = Melange_stanzas.Emit.implicit_alias) ~dir deps = - let alias = Alias.make alias ~dir in - let dune_default_alias = Alias.make Alias0.all ~dir in - let attach alias = Rules.Produce.Alias.add_deps alias deps in - Memo.parallel_iter ~f:attach [ alias; dune_default_alias ] -;; - let melange_compile_flags ~sctx ~dir (mel : Melange_stanzas.Emit.t) = let specific = Lib_mode.Map.make_all mel.compile_flags in Ocaml_flags.Spec.make ~common:Ordered_set_lang.Unexpanded.standard ~specific @@ -483,6 +530,16 @@ let setup_entries_js let* () = setup_runtime_assets_rules sctx ~dir ~target_dir ~mode ~output ~for_:`Emit mel in + let* () = + match mel.emit_manifest with + | true -> + let mappings = + List.map modules_for_js ~f:(fun m -> + Manifest.create_mapping ~module_systems ~output m) + in + Manifest.setup_manifest_rule ~sctx ~dir ~target_dir ~mode mappings + | false -> Memo.return () + in let local_modules_and_obj_dir = Some (Modules.With_vlib.modules local_modules, local_obj_dir) in diff --git a/src/dune_rules/melange/melange_stanzas.ml b/src/dune_rules/melange/melange_stanzas.ml index 391daba0b7e..4484b6242d6 100644 --- a/src/dune_rules/melange/melange_stanzas.ml +++ b/src/dune_rules/melange/melange_stanzas.ml @@ -9,6 +9,7 @@ module Emit = struct ; module_systems : (Melange.Module_system.t * Filename.Extension.t) list ; modules : Stanza_common.Modules_settings.t ; emit_stdlib : bool + ; emit_manifest : bool ; libraries : Lib_dep.t list ; package : Package.t option ; preprocess : Preprocess.With_instrumentation.t Preprocess.Per_module.t @@ -114,6 +115,7 @@ module Emit = struct and+ compile_flags = Ordered_set_lang.Unexpanded.field "compile_flags" and+ allow_overlapping_dependencies = field_b "allow_overlapping_dependencies" and+ emit_stdlib = field "emit_stdlib" bool ~default:true + and+ emit_manifest = field "emit_manifest" bool ~default:false and+ modules = Stanza_common.Modules_settings.decode and+ enabled_if = let open Enabled_if in @@ -133,6 +135,7 @@ module Emit = struct ; module_systems ; modules ; emit_stdlib + ; emit_manifest ; libraries ; package ; preprocess diff --git a/src/dune_rules/melange/melange_stanzas.mli b/src/dune_rules/melange/melange_stanzas.mli index 74212be36dd..95cda8453da 100644 --- a/src/dune_rules/melange/melange_stanzas.mli +++ b/src/dune_rules/melange/melange_stanzas.mli @@ -9,6 +9,7 @@ module Emit : sig ; module_systems : (Melange.Module_system.t * string) list ; modules : Stanza_common.Modules_settings.t ; emit_stdlib : bool + ; emit_manifest : bool ; libraries : Lib_dep.t list ; package : Package.t option ; preprocess : Preprocess.With_instrumentation.t Preprocess.Per_module.t diff --git a/test/blackbox-tests/test-cases/melange/manifest.t b/test/blackbox-tests/test-cases/melange/manifest.t new file mode 100644 index 00000000000..904164cb796 --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/manifest.t @@ -0,0 +1,56 @@ +Test melange manifest + + $ cat > dune-project < (lang dune 3.8) + > (using melange 0.1) + > EOF + + $ cat > dune < (melange.emit + > (target output) + > (emit_manifest true) + > (modules main)) + > EOF + + $ cat > main.ml < Js.log "hello" + > EOF + + $ dune build @melange + Creating manifest rule + dir: _build/default + target_dir: _build/default/output + mappings count: 1 + manifest path: _build/default/output/melange-manifest.sexp + manifest content: + [{"_build/default/main.ml":["_build/default/output/main.js"]}] + + $ ls _build/default/output + main.js + melange-manifest.sexp + node_modules + + $ cat _build/default/output/melange-manifest.sexp + [{"_build/default/main.ml":["_build/default/output/main.js"]}] + + $ dune rules @melange | grep -C 3 "manifest" + Creating manifest rule + dir: _build/default + target_dir: _build/default/output + mappings count: 1 + manifest path: _build/default/output/melange-manifest.sexp + manifest content: + [{"_build/default/main.ml":["_build/default/output/main.js"]}] + + ((deps ()) + (targets + ((files (_build/default/output/melange-manifest.sexp)) (directories ()))) + (context default) + (action + (chdir + _build/default + (write-file + output/melange-manifest.sexp + "[{\"_build/default/main.ml\":[\"_build/default/output/main.js\"]}]")))) + + ((deps From 031b4f54733cb631b0a9c9667a96d17aafb545bc Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Fri, 20 Dec 2024 15:45:41 +0100 Subject: [PATCH 2/5] Use original_path to point to .re file on the mapping Signed-off-by: Antonio Nuno Monteiro --- src/dune_rules/melange/melange_rules.ml | 6 +- test/blackbox-tests/test-cases/melange/dune | 2 +- .../test-cases/melange/manifest_with_re.t | 57 +++++++++++++++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 test/blackbox-tests/test-cases/melange/manifest_with_re.t diff --git a/src/dune_rules/melange/melange_rules.ml b/src/dune_rules/melange/melange_rules.ml index e866192c88a..c79d5af4d56 100644 --- a/src/dune_rules/melange/melange_rules.ml +++ b/src/dune_rules/melange/melange_rules.ml @@ -61,14 +61,14 @@ let make_js_name ~js_ext ~output m = module Manifest = struct type mapping = - { source : Path.t + { source : Module.File.t ; targets : Path.Build.t list } type t = { mappings : mapping list } let sexp_of_mapping { source; targets } = - let source_str = Path.to_string source in + let source_str = Module.File.original_path source |> Path.to_string in let target_strs = List.map targets ~f:Path.Build.to_string in `Assoc [ source_str, `List (List.map target_strs ~f:(fun s -> `String s)) ] ;; @@ -77,7 +77,7 @@ module Manifest = struct let to_string t = Json.to_string (json_of_t t) let create_mapping ~module_systems ~output m = - let source = Module.file m ~ml_kind:Impl |> Option.value_exn in + let source = Module.source m ~ml_kind:Impl |> Option.value_exn in let targets = List.map module_systems ~f:(fun (_, js_ext) -> make_js_name ~js_ext ~output m) in diff --git a/test/blackbox-tests/test-cases/melange/dune b/test/blackbox-tests/test-cases/melange/dune index ac05fc1eed1..4ba127ef325 100644 --- a/test/blackbox-tests/test-cases/melange/dune +++ b/test/blackbox-tests/test-cases/melange/dune @@ -4,7 +4,7 @@ (DUNE_SANDBOX symlink)))) (cram - (deps %{bin:node} %{bin:melc}) + (deps %{bin:node} %{bin:melc} %{bin:refmt}) (alias runtest-melange)) (cram diff --git a/test/blackbox-tests/test-cases/melange/manifest_with_re.t b/test/blackbox-tests/test-cases/melange/manifest_with_re.t new file mode 100644 index 00000000000..5727e3f97cb --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/manifest_with_re.t @@ -0,0 +1,57 @@ +Test melange manifest + + $ cat > dune-project < (lang dune 3.8) + > (using melange 0.1) + > EOF + + $ cat > dune < (melange.emit + > (target output) + > (emit_manifest true) + > (modules main)) + > EOF + + + $ cat > main.re < Js.log "hello" + > EOF + + $ dune build @melange + Creating manifest rule + dir: _build/default + target_dir: _build/default/output + mappings count: 1 + manifest path: _build/default/output/melange-manifest.sexp + manifest content: + [{"_build/default/main.re":["_build/default/output/main.js"]}] + + $ ls _build/default/output + main.js + melange-manifest.sexp + node_modules + + $ cat _build/default/output/melange-manifest.sexp + [{"_build/default/main.re":["_build/default/output/main.js"]}] + + $ dune rules @melange | grep -C 3 "manifest" + Creating manifest rule + dir: _build/default + target_dir: _build/default/output + mappings count: 1 + manifest path: _build/default/output/melange-manifest.sexp + manifest content: + [{"_build/default/main.re":["_build/default/output/main.js"]}] + + ((deps ()) + (targets + ((files (_build/default/output/melange-manifest.sexp)) (directories ()))) + (context default) + (action + (chdir + _build/default + (write-file + output/melange-manifest.sexp + "[{\"_build/default/main.re\":[\"_build/default/output/main.js\"]}]")))) + + ((deps From 7a7670e8c65f16a4a637fe50a370344bda500a92 Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Sat, 21 Dec 2024 00:06:26 +0100 Subject: [PATCH 3/5] Push half-backed impl for dependencies Signed-off-by: Antonio Nuno Monteiro --- src/dune_rules/melange/melange_rules.ml | 71 ++++++++++++++++++- .../test-cases/melange/manifest_with_libs.t | 70 ++++++++++++++++++ 2 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 test/blackbox-tests/test-cases/melange/manifest_with_libs.t diff --git a/src/dune_rules/melange/melange_rules.ml b/src/dune_rules/melange/melange_rules.ml index c79d5af4d56..746a2b2a592 100644 --- a/src/dune_rules/melange/melange_rules.ml +++ b/src/dune_rules/melange/melange_rules.ml @@ -76,10 +76,18 @@ module Manifest = struct let json_of_t t = `List (List.map t.mappings ~f:sexp_of_mapping) let to_string t = Json.to_string (json_of_t t) - let create_mapping ~module_systems ~output m = - let source = Module.source m ~ml_kind:Impl |> Option.value_exn in + let create_mapping ~module_systems ~output modules = + let source = Module.source modules ~ml_kind:Impl |> Option.value_exn in let targets = - List.map module_systems ~f:(fun (_, js_ext) -> make_js_name ~js_ext ~output m) + List.map module_systems ~f:(fun (_, js_ext) -> make_js_name ~js_ext ~output modules) + in + { source; targets } + ;; + + let create_mapping_lib ~module_systems ~output lib = + let source = Module.source lib ~ml_kind:Impl |> Option.value_exn in + let targets = + List.map module_systems ~f:(fun (_, js_ext) -> make_js_name ~js_ext ~output lib) in { source; targets } ;; @@ -517,6 +525,51 @@ let setup_entries_js let pkg_name = Option.map mel.package ~f:Package.name in let loc = mel.loc in let module_systems = mel.module_systems in + let* requires_link = Memo.Lazy.force requires_link in + (* Format.eprintf "local modules:@."; + let* () = + Modules.fold_user_written local_modules ~init:(Memo.return ()) ~f:(fun m acc -> + let* () = acc in + let name = Module.name m in + Format.eprintf " Module: %s@." (Module_name.to_string name); + match Module.file m ~ml_kind:Impl with + | None -> + Format.eprintf " No implementation file@."; + Memo.return () + | Some file -> + Format.eprintf " Path: %s@." (Path.to_string file); + Memo.return ()) + in *) + + (* + Format.eprintf "requires_link:@."; + List.iter requires_link_resolved ~f:(fun lib -> + let name = Lib.name lib in + let info = Lib.info lib in + let src_dir = Lib_info.src_dir info in + Format.eprintf " library: %s@." (Lib_name.to_string name); + Format.eprintf " path: %s@." (Path.to_string src_dir); + Format.eprintf " src_dir: %s@." (Path.to_string (Lib_info.src_dir info)); + match Lib_info.modules info with + | External _ -> Format.eprintf " External modules@." + | Local -> Format.eprintf " Local modules in: %s@." (Path.to_string src_dir)); *) + + (* Not sure if read_memo is needed here *) + let* requires_link_resolved = Resolve.Memo.read_memo (Memo.return requires_link) in + let* () = + Memo.parallel_iter requires_link_resolved ~f:(fun lib -> + let name = Lib.name lib in + Format.eprintf " Library: %s@." (Lib_name.to_string name); + let* _modules_with_vlib, impl_modules = + impl_only_modules_defined_in_this_lib ~sctx ~scope lib + in + Format.eprintf " Implementation modules:@."; + List.iter impl_modules ~f:(fun m -> + match Module.file m ~ml_kind:Impl with + | None -> Format.eprintf " No implementation file@." + | Some file -> Format.eprintf " Path: %s@." (Path.to_string file)); + Memo.return ()) + in let* includes = let+ lib_config = let+ ocaml = Super_context.context sctx |> Context.ocaml in @@ -526,6 +579,18 @@ let setup_entries_js cmj_includes ~requires_link ~scope lib_config and* compile_flags = melange_compile_flags ~sctx ~dir mel in let output = `Private_library_or_emit target_dir in + let mappings_for_js = + List.map modules_for_js ~f:(fun modules -> + Manifest.create_mapping ~module_systems ~output modules) + (* and mappings_for_requires_link = + List.map requires_link_resolved ~f:(fun lib -> + let* _modules_with_vlib, impl_modules = + impl_only_modules_defined_in_this_lib ~sctx ~scope lib + in + List.map impl_modules ~f:(fun m -> + Manifest.create_mapping ~module_systems ~output m)) *) + in + let mappings = mappings_for_js in let obj_dir = Obj_dir.of_local local_obj_dir in let* () = setup_runtime_assets_rules sctx ~dir ~target_dir ~mode ~output ~for_:`Emit mel diff --git a/test/blackbox-tests/test-cases/melange/manifest_with_libs.t b/test/blackbox-tests/test-cases/melange/manifest_with_libs.t new file mode 100644 index 00000000000..420e810ac8a --- /dev/null +++ b/test/blackbox-tests/test-cases/melange/manifest_with_libs.t @@ -0,0 +1,70 @@ +Test melange manifest + + $ cat > dune-project < (lang dune 3.8) + > (using melange 0.1) + > EOF + + $ cat > dune < (melange.emit + > (target output) + > (modules main) + > (libraries lib)) + > + > (library + > (name lib) + > (modules lib) + > (modes melange)) + > EOF + + $ cat > lib.ml < let main () = Js.log "hello" + > EOF + + $ cat > main.re < Lib.main(); + > EOF + + $ dune build @melange + Creating manifest rule + dir: _build/default + target_dir: _build/default/output + mappings count: 1 + manifest path: _build/default/output/melange-manifest.sexp + manifest content: + ((_build/default/main.re (_build/default/output/main.js)) + (_build/default/lib.ml (_build/default/output/lib.js))) + + $ ls _build/default/output + lib.js + main.js + melange-manifest.sexp + node_modules + + $ cat _build/default/output/melange-manifest.sexp + ((_build/default/main.re (_build/default/output/main.js)) + (_build/default/lib.ml (_build/default/output/lib.js))) + + $ dune rules @melange | grep -C 3 "manifest" + Creating manifest rule + dir: _build/default + target_dir: _build/default/output + mappings count: 1 + manifest path: _build/default/output/melange-manifest.sexp + manifest content: + ((_build/default/main.re (_build/default/output/main.js)) + (_build/default/lib.ml (_build/default/output/lib.js))) + + ((deps ()) + (targets + ((files (_build/default/output/melange-manifest.sexp)) (directories ()))) + (context default) + (action + (chdir + _build/default + (write-file + output/melange-manifest.sexp + "((_build/default/main.re (_build/default/output/main.js)) + (_build/default/lib.ml (_build/default/output/lib.js))")))) + + ((deps From 2eeb67f920fd3fd553e8b279191a5e5fb26fe6ae Mon Sep 17 00:00:00 2001 From: David Sancho Moreno Date: Mon, 23 Dec 2024 10:58:20 +0100 Subject: [PATCH 4/5] Consider requires_link for the manifest Signed-off-by: Antonio Nuno Monteiro --- src/dune_rules/melange/melange_rules.ml | 275 ++++++++---------- .../test-cases/melange/manifest_with_libs.t | 22 +- 2 files changed, 124 insertions(+), 173 deletions(-) diff --git a/src/dune_rules/melange/melange_rules.ml b/src/dune_rules/melange/melange_rules.ml index 746a2b2a592..05981811213 100644 --- a/src/dune_rules/melange/melange_rules.ml +++ b/src/dune_rules/melange/melange_rules.ml @@ -13,6 +13,79 @@ let add_deps_to_aliases ?(alias = Melange_stanzas.Emit.implicit_alias) ~dir deps Memo.parallel_iter ~f:attach [ alias; dune_default_alias ] ;; +let modules_in_obj_dir ~sctx ~scope ~preprocess modules = + let* version = + let+ ocaml = Context.ocaml (Super_context.context sctx) in + ocaml.version + and* preprocess = + Resolve.Memo.read_memo + (Preprocess.Per_module.with_instrumentation + preprocess + ~instrumentation_backend:(Lib.DB.instrumentation_backend (Scope.libs scope))) + in + let pped_map = Staged.unstage (Pp_spec.pped_modules_map preprocess version) in + Modules.map_user_written modules ~f:(fun m -> Memo.return @@ pped_map m) +;; + +let impl_only_modules_defined_in_this_lib ~sctx ~scope lib = + match Lib_info.modules (Lib.info lib) with + | External None -> + User_error.raise + [ Pp.textf + "The library %s was not compiled with Dune or it was compiled with Dune but \ + published with a META template. Such libraries are not compatible with \ + melange support" + (Lib.name lib |> Lib_name.to_string) + ] + | External (Some modules) -> + Memo.return + ( modules + , (Modules.With_vlib.split_by_lib modules).impl + |> List.filter ~f:(Module.has ~ml_kind:Impl) ) + | Local -> + let lib = Lib.Local.of_lib_exn lib in + let info = Lib.Local.info lib in + let+ modules = + let* modules = Dir_contents.modules_of_local_lib sctx lib in + let preprocess = Lib_info.preprocess info in + modules_in_obj_dir ~sctx ~scope ~preprocess modules >>| Modules.With_vlib.modules + in + let () = + let modes = Lib_info.modes info in + match modes.melange with + | false -> + let lib_name = Lib_name.to_string (Lib_info.name info) in + User_error.raise + ~loc:(Lib_info.loc info) + [ Pp.textf + "The library `%s` was added as a dependency of a `melange.emit` stanza, \ + but this library is not compatible with Melange. To fix this, add \ + `melange` to the `modes` field of the library `%s`." + lib_name + lib_name + ] + | true -> () + in + ( modules + , (Modules.With_vlib.split_by_lib modules).impl + |> List.filter ~f:(Module.has ~ml_kind:Impl) ) +;; + +let modules_for_js_and_obj_dir ~sctx ~dir_contents ~scope (mel : Melange_stanzas.Emit.t) = + let* modules, obj_dir = + Dir_contents.ocaml dir_contents + >>= Ml_sources.modules_and_obj_dir + ~libs:(Scope.libs scope) + ~for_:(Melange { target = mel.target }) + in + let+ modules = modules_in_obj_dir ~sctx ~scope ~preprocess:mel.preprocess modules in + let modules_for_js = + Modules.fold modules ~init:[] ~f:(fun x acc -> + if Module.has x ~ml_kind:Impl then x :: acc else acc) + in + modules, modules_for_js, obj_dir +;; + let output_of_lib = let public_lib ~info ~target_dir lib_name = `Public_library @@ -84,24 +157,45 @@ module Manifest = struct { source; targets } ;; - let create_mapping_lib ~module_systems ~output lib = - let source = Module.source lib ~ml_kind:Impl |> Option.value_exn in - let targets = - List.map module_systems ~f:(fun (_, js_ext) -> make_js_name ~js_ext ~output lib) + let setup_manifest_rule + ~sctx + ~target_dir + ~mode + ~module_systems + ~output + ~dir_contents + ~requires_link + ~scope + mel + = + let* _local_modules, modules_for_js, _local_obj_dir = + modules_for_js_and_obj_dir ~sctx ~dir_contents ~scope mel in - { source; targets } - ;; - - let setup_manifest_rule ~sctx ~dir ~target_dir ~mode mappings = + let mappings_for_js = + List.map modules_for_js ~f:(fun modules -> + create_mapping ~module_systems ~output modules) + in + (* Get mappings for each required library *) + let* mappings_for_libs = + Memo.List.concat_map requires_link ~f:(fun lib -> + let* _modules_with_vlib, impl_modules = + impl_only_modules_defined_in_this_lib ~sctx ~scope lib + in + let lib_output = output_of_lib ~target_dir lib in + Memo.return + (List.map impl_modules ~f:(fun m -> + create_mapping ~module_systems ~output:lib_output m))) + in + let mappings = mappings_for_js @ mappings_for_libs in let manifest_path = Path.Build.relative target_dir "melange-manifest.sexp" in - Format.eprintf "Creating manifest rule@."; - Format.eprintf " dir: %s@." (Path.Build.to_string dir); - Format.eprintf " target_dir: %s@." (Path.Build.to_string target_dir); - Format.eprintf " mappings count: %d@." (List.length mappings); - Format.eprintf " manifest path: %s@." (Path.Build.to_string manifest_path); + (* Format.eprintf "Creating manifest rule@."; *) + (* Format.eprintf " dir: %s@." (Path.Build.to_string dir); *) + (* Format.eprintf " target_dir: %s@." (Path.Build.to_string target_dir); *) + (* Format.eprintf " mappings count: %d@." (List.length mappings); *) + (* Format.eprintf " manifest path: %s@." (Path.Build.to_string manifest_path); *) let manifest = { mappings } in let manifest_str = to_string manifest in - Format.eprintf " manifest content:@.%s@." manifest_str; + (* Format.eprintf " manifest content:@.%s@." manifest_str; *) let* () = Action_builder.return manifest_str |> Action_builder.write_file_dyn manifest_path @@ -113,64 +207,6 @@ module Manifest = struct ;; end -let modules_in_obj_dir ~sctx ~scope ~preprocess modules = - let* version = - let+ ocaml = Context.ocaml (Super_context.context sctx) in - ocaml.version - and* preprocess = - Resolve.Memo.read_memo - (Preprocess.Per_module.with_instrumentation - preprocess - ~instrumentation_backend:(Lib.DB.instrumentation_backend (Scope.libs scope))) - in - let pped_map = Staged.unstage (Pp_spec.pped_modules_map preprocess version) in - Modules.map_user_written modules ~f:(fun m -> Memo.return @@ pped_map m) -;; - -let impl_only_modules_defined_in_this_lib ~sctx ~scope lib = - match Lib_info.modules (Lib.info lib) with - | External None -> - User_error.raise - [ Pp.textf - "The library %s was not compiled with Dune or it was compiled with Dune but \ - published with a META template. Such libraries are not compatible with \ - melange support" - (Lib.name lib |> Lib_name.to_string) - ] - | External (Some modules) -> - Memo.return - ( modules - , (Modules.With_vlib.split_by_lib modules).impl - |> List.filter ~f:(Module.has ~ml_kind:Impl) ) - | Local -> - let lib = Lib.Local.of_lib_exn lib in - let info = Lib.Local.info lib in - let+ modules = - let* modules = Dir_contents.modules_of_local_lib sctx lib in - let preprocess = Lib_info.preprocess info in - modules_in_obj_dir ~sctx ~scope ~preprocess modules >>| Modules.With_vlib.modules - in - let () = - let modes = Lib_info.modes info in - match modes.melange with - | false -> - let lib_name = Lib_name.to_string (Lib_info.name info) in - User_error.raise - ~loc:(Lib_info.loc info) - [ Pp.textf - "The library `%s` was added as a dependency of a `melange.emit` stanza, \ - but this library is not compatible with Melange. To fix this, add \ - `melange` to the `modes` field of the library `%s`." - lib_name - lib_name - ] - | true -> () - in - ( modules - , (Modules.With_vlib.split_by_lib modules).impl - |> List.filter ~f:(Module.has ~ml_kind:Impl) ) -;; - let cmj_glob = Glob.of_string_exn Loc.none "*.cmj" let cmj_includes ~(requires_link : Lib.t list Resolve.t) ~scope lib_config = @@ -494,21 +530,6 @@ let setup_runtime_assets_rules sctx ~dir ~target_dir ~mode ~output ~for_ mel = () ;; -let modules_for_js_and_obj_dir ~sctx ~dir_contents ~scope (mel : Melange_stanzas.Emit.t) = - let* modules, obj_dir = - Dir_contents.ocaml dir_contents - >>= Ml_sources.modules_and_obj_dir - ~libs:(Scope.libs scope) - ~for_:(Melange { target = mel.target }) - in - let+ modules = modules_in_obj_dir ~sctx ~scope ~preprocess:mel.preprocess modules in - let modules_for_js = - Modules.fold modules ~init:[] ~f:(fun x acc -> - if Module.has x ~ml_kind:Impl then x :: acc else acc) - in - modules, modules_for_js, obj_dir -;; - let setup_entries_js ~sctx ~dir @@ -526,50 +547,6 @@ let setup_entries_js let loc = mel.loc in let module_systems = mel.module_systems in let* requires_link = Memo.Lazy.force requires_link in - (* Format.eprintf "local modules:@."; - let* () = - Modules.fold_user_written local_modules ~init:(Memo.return ()) ~f:(fun m acc -> - let* () = acc in - let name = Module.name m in - Format.eprintf " Module: %s@." (Module_name.to_string name); - match Module.file m ~ml_kind:Impl with - | None -> - Format.eprintf " No implementation file@."; - Memo.return () - | Some file -> - Format.eprintf " Path: %s@." (Path.to_string file); - Memo.return ()) - in *) - - (* - Format.eprintf "requires_link:@."; - List.iter requires_link_resolved ~f:(fun lib -> - let name = Lib.name lib in - let info = Lib.info lib in - let src_dir = Lib_info.src_dir info in - Format.eprintf " library: %s@." (Lib_name.to_string name); - Format.eprintf " path: %s@." (Path.to_string src_dir); - Format.eprintf " src_dir: %s@." (Path.to_string (Lib_info.src_dir info)); - match Lib_info.modules info with - | External _ -> Format.eprintf " External modules@." - | Local -> Format.eprintf " Local modules in: %s@." (Path.to_string src_dir)); *) - - (* Not sure if read_memo is needed here *) - let* requires_link_resolved = Resolve.Memo.read_memo (Memo.return requires_link) in - let* () = - Memo.parallel_iter requires_link_resolved ~f:(fun lib -> - let name = Lib.name lib in - Format.eprintf " Library: %s@." (Lib_name.to_string name); - let* _modules_with_vlib, impl_modules = - impl_only_modules_defined_in_this_lib ~sctx ~scope lib - in - Format.eprintf " Implementation modules:@."; - List.iter impl_modules ~f:(fun m -> - match Module.file m ~ml_kind:Impl with - | None -> Format.eprintf " No implementation file@." - | Some file -> Format.eprintf " Path: %s@." (Path.to_string file)); - Memo.return ()) - in let* includes = let+ lib_config = let+ ocaml = Super_context.context sctx |> Context.ocaml in @@ -579,32 +556,10 @@ let setup_entries_js cmj_includes ~requires_link ~scope lib_config and* compile_flags = melange_compile_flags ~sctx ~dir mel in let output = `Private_library_or_emit target_dir in - let mappings_for_js = - List.map modules_for_js ~f:(fun modules -> - Manifest.create_mapping ~module_systems ~output modules) - (* and mappings_for_requires_link = - List.map requires_link_resolved ~f:(fun lib -> - let* _modules_with_vlib, impl_modules = - impl_only_modules_defined_in_this_lib ~sctx ~scope lib - in - List.map impl_modules ~f:(fun m -> - Manifest.create_mapping ~module_systems ~output m)) *) - in - let mappings = mappings_for_js in let obj_dir = Obj_dir.of_local local_obj_dir in let* () = setup_runtime_assets_rules sctx ~dir ~target_dir ~mode ~output ~for_:`Emit mel in - let* () = - match mel.emit_manifest with - | true -> - let mappings = - List.map modules_for_js ~f:(fun m -> - Manifest.create_mapping ~module_systems ~output m) - in - Manifest.setup_manifest_rule ~sctx ~dir ~target_dir ~mode mappings - | false -> Memo.return () - in let local_modules_and_obj_dir = Some (Modules.With_vlib.modules local_modules, local_obj_dir) in @@ -754,6 +709,20 @@ let setup_js_rules_libraries_and_entries setup_js_rules_libraries ~dir ~scope ~target_dir ~sctx ~requires_link ~mode mel and+ () = setup_entries_js ~sctx ~dir ~dir_contents ~scope ~requires_link ~target_dir ~mode mel + and+ () = + match mel.emit_manifest with + | true -> + Manifest.setup_manifest_rule + ~sctx + ~target_dir + ~mode + ~module_systems:mel.module_systems + ~output:(`Private_library_or_emit target_dir) + ~dir_contents + ~scope + ~requires_link + mel + | false -> Memo.return () in () ;; diff --git a/test/blackbox-tests/test-cases/melange/manifest_with_libs.t b/test/blackbox-tests/test-cases/melange/manifest_with_libs.t index 420e810ac8a..932c1cde8ff 100644 --- a/test/blackbox-tests/test-cases/melange/manifest_with_libs.t +++ b/test/blackbox-tests/test-cases/melange/manifest_with_libs.t @@ -26,14 +26,6 @@ Test melange manifest > EOF $ dune build @melange - Creating manifest rule - dir: _build/default - target_dir: _build/default/output - mappings count: 1 - manifest path: _build/default/output/melange-manifest.sexp - manifest content: - ((_build/default/main.re (_build/default/output/main.js)) - (_build/default/lib.ml (_build/default/output/lib.js))) $ ls _build/default/output lib.js @@ -42,18 +34,9 @@ Test melange manifest node_modules $ cat _build/default/output/melange-manifest.sexp - ((_build/default/main.re (_build/default/output/main.js)) - (_build/default/lib.ml (_build/default/output/lib.js))) + ((_build/default/main.re (_build/default/output/main.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/__private__/melange_mini_stdlib/melange_mini_stdlib.ml (_build/default/output/node_modules/melange.__private__.melange_mini_stdlib/melange_mini_stdlib.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_weakset.ml (_build/default/output/node_modules/melange.js/js_weakset.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_weakmap.ml (_build/default/output/node_modules/melange.js/js_weakmap.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_undefined.ml (_build/default/output/node_modules/melange.js/js_undefined.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_types.ml (_build/default/output/node_modules/melange.js/js_types.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_typed_array.ml (_build/default/output/node_modules/melange.js/js_typed_array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_string.ml (_build/default/output/node_modules/melange.js/js_string.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_set.ml (_build/default/output/node_modules/melange.js/js_set.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_re.ml (_build/default/output/node_modules/melange.js/js_re.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_promise.ml (_build/default/output/node_modules/melange.js/js_promise.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_obj.ml (_build/default/output/node_modules/melange.js/js_obj.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_nullable.ml (_build/default/output/node_modules/melange.js/js_nullable.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_null.ml (_build/default/output/node_modules/melange.js/js_null.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_math.ml (_build/default/output/node_modules/melange.js/js_math.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_mapper_runtime.ml (_build/default/output/node_modules/melange.js/js_mapper_runtime.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_map.ml (_build/default/output/node_modules/melange.js/js_map.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_json.ml (_build/default/output/node_modules/melange.js/js_json.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_iterator.ml (_build/default/output/node_modules/melange.js/js_iterator.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_int.ml (_build/default/output/node_modules/melange.js/js_int.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_global.ml (_build/default/output/node_modules/melange.js/js_global.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_float.ml (_build/default/output/node_modules/melange.js/js_float.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_exn.ml (_build/default/output/node_modules/melange.js/js_exn.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_dict.ml (_build/default/output/node_modules/melange.js/js_dict.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_date.ml (_build/default/output/node_modules/melange.js/js_date.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_console.ml (_build/default/output/node_modules/melange.js/js_console.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_bigint.ml (_build/default/output/node_modules/melange.js/js_bigint.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_array.ml (_build/default/output/node_modules/melange.js/js_array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_OO.ml (_build/default/output/node_modules/melange.js/js_OO.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js.ml (_build/default/output/node_modules/melange.js/js.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/curry.ml (_build/default/output/node_modules/melange.js/curry.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_undefined_extern.ml (_build/default/output/node_modules/melange.js/caml_undefined_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_sys.ml (_build/default/output/node_modules/melange.js/caml_sys.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_string_extern.ml (_build/default/output/node_modules/melange.js/caml_string_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_string.ml (_build/default/output/node_modules/melange.js/caml_string.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_splice_call.ml (_build/default/output/node_modules/melange.js/caml_splice_call.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_parser.ml (_build/default/output/node_modules/melange.js/caml_parser.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_option.ml (_build/default/output/node_modules/melange.js/caml_option.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_oo_curry.ml (_build/default/output/node_modules/melange.js/caml_oo_curry.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_oo.ml (_build/default/output/node_modules/melange.js/caml_oo.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_obj.ml (_build/default/output/node_modules/melange.js/caml_obj.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_nativeint_extern.ml (_build/default/output/node_modules/melange.js/caml_nativeint_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_module.ml (_build/default/output/node_modules/melange.js/caml_module.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_md5.ml (_build/default/output/node_modules/melange.js/caml_md5.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_lexer.ml (_build/default/output/node_modules/melange.js/caml_lexer.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_js_exceptions.ml (_build/default/output/node_modules/melange.js/caml_js_exceptions.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_io.ml (_build/default/output/node_modules/melange.js/caml_io.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int64_extern.ml (_build/default/output/node_modules/melange.js/caml_int64_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int64.ml (_build/default/output/node_modules/melange.js/caml_int64.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int32_extern.ml (_build/default/output/node_modules/melange.js/caml_int32_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int32.ml (_build/default/output/node_modules/melange.js/caml_int32.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_hash_primitive.ml (_build/default/output/node_modules/melange.js/caml_hash_primitive.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_hash.ml (_build/default/output/node_modules/melange.js/caml_hash.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_gc.ml (_build/default/output/node_modules/melange.js/caml_gc.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_format.ml (_build/default/output/node_modules/melange.js/caml_format.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_float_extern.ml (_build/default/output/node_modules/melange.js/caml_float_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_float.ml (_build/default/output/node_modules/melange.js/caml_float.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_external_polyfill.ml (_build/default/output/node_modules/melange.js/caml_external_polyfill.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_exceptions.ml (_build/default/output/node_modules/melange.js/caml_exceptions.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_bytes.ml (_build/default/output/node_modules/melange.js/caml_bytes.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_array_extern.ml (_build/default/output/node_modules/melange.js/caml_array_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_array.ml (_build/default/output/node_modules/melange.js/caml_array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml.ml (_build/default/output/node_modules/melange.js/caml.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/weak.ml (_build/default/output/node_modules/melange/weak.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/unit.ml (_build/default/output/node_modules/melange/unit.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/uchar.ml (_build/default/output/node_modules/melange/uchar.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/type.ml (_build/default/output/node_modules/melange/type.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/sys.ml (_build/default/output/node_modules/melange/sys.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stringLabels.ml (_build/default/output/node_modules/melange/stringLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/string.ml (_build/default/output/node_modules/melange/string.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stdlib.ml (_build/default/output/node_modules/melange/stdlib.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/std_exit.ml (_build/default/output/node_modules/melange/std_exit.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stdLabels.ml (_build/default/output/node_modules/melange/stdLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stack.ml (_build/default/output/node_modules/melange/stack.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/set.ml (_build/default/output/node_modules/melange/set.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/seq.ml (_build/default/output/node_modules/melange/seq.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/scanf.ml (_build/default/output/node_modules/melange/scanf.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/result.ml (_build/default/output/node_modules/melange/result.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/random.ml (_build/default/output/node_modules/melange/random.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/queue.ml (_build/default/output/node_modules/melange/queue.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/printf.ml (_build/default/output/node_modules/melange/printf.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/printexc.ml (_build/default/output/node_modules/melange/printexc.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/parsing.ml (_build/default/output/node_modules/melange/parsing.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/out_channel.ml (_build/default/output/node_modules/melange/out_channel.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/option.ml (_build/default/output/node_modules/melange/option.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/oo.ml (_build/default/output/node_modules/melange/oo.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/obj.ml (_build/default/output/node_modules/melange/obj.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/mutex.ml (_build/default/output/node_modules/melange/mutex.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/moreLabels.ml (_build/default/output/node_modules/melange/moreLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/marshal.ml (_build/default/output/node_modules/melange/marshal.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/map.ml (_build/default/output/node_modules/melange/map.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/listLabels.ml (_build/default/output/node_modules/melange/listLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/list.ml (_build/default/output/node_modules/melange/list.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/lexing.ml (_build/default/output/node_modules/melange/lexing.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/lazy.ml (_build/default/output/node_modules/melange/lazy.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/int64.ml (_build/default/output/node_modules/melange/int64.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/int32.ml (_build/default/output/node_modules/melange/int32.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/int.ml (_build/default/output/node_modules/melange/int.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/in_channel.ml (_build/default/output/node_modules/melange/in_channel.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/hashtbl.ml (_build/default/output/node_modules/melange/hashtbl.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/gc.ml (_build/default/output/node_modules/melange/gc.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/fun.ml (_build/default/output/node_modules/melange/fun.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/format.ml (_build/default/output/node_modules/melange/format.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/float.ml (_build/default/output/node_modules/melange/float.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/filename.ml (_build/default/output/node_modules/melange/filename.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/ephemeron.ml (_build/default/output/node_modules/melange/ephemeron.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/either.ml (_build/default/output/node_modules/melange/either.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/dynarray.ml (_build/default/output/node_modules/melange/dynarray.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/domain.ml (_build/default/output/node_modules/melange/domain.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/digest.ml (_build/default/output/node_modules/melange/digest.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/complex.ml (_build/default/output/node_modules/melange/complex.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/char.ml (_build/default/output/node_modules/melange/char.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalOO.ml (_build/default/output/node_modules/melange/camlinternalOO.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalMod.ml (_build/default/output/node_modules/melange/camlinternalMod.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalLazy.ml (_build/default/output/node_modules/melange/camlinternalLazy.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalFormatBasics.ml (_build/default/output/node_modules/melange/camlinternalFormatBasics.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalFormat.ml (_build/default/output/node_modules/melange/camlinternalFormat.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalAtomic.ml (_build/default/output/node_modules/melange/camlinternalAtomic.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/callback.ml (_build/default/output/node_modules/melange/callback.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/bytesLabels.ml (_build/default/output/node_modules/melange/bytesLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/bytes.ml (_build/default/output/node_modules/melange/bytes.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/buffer.ml (_build/default/output/node_modules/melange/buffer.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/bool.ml (_build/default/output/node_modules/melange/bool.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/atomic.ml (_build/default/output/node_modules/melange/atomic.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/arrayLabels.ml (_build/default/output/node_modules/melange/arrayLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/array.ml (_build/default/output/node_modules/melange/array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/arg.ml (_build/default/output/node_modules/melange/arg.js)) (_build/default/lib.ml (_build/default/output/lib.js))) $ dune rules @melange | grep -C 3 "manifest" - Creating manifest rule - dir: _build/default - target_dir: _build/default/output - mappings count: 1 - manifest path: _build/default/output/melange-manifest.sexp - manifest content: - ((_build/default/main.re (_build/default/output/main.js)) - (_build/default/lib.ml (_build/default/output/lib.js))) ((deps ()) (targets @@ -64,7 +47,6 @@ Test melange manifest _build/default (write-file output/melange-manifest.sexp - "((_build/default/main.re (_build/default/output/main.js)) - (_build/default/lib.ml (_build/default/output/lib.js))")))) + "((_build/default/main.re (_build/default/output/main.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/__private__/melange_mini_stdlib/melange_mini_stdlib.ml (_build/default/output/node_modules/melange.__private__.melange_mini_stdlib/melange_mini_stdlib.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_weakset.ml (_build/default/output/node_modules/melange.js/js_weakset.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_weakmap.ml (_build/default/output/node_modules/melange.js/js_weakmap.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_undefined.ml (_build/default/output/node_modules/melange.js/js_undefined.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_types.ml (_build/default/output/node_modules/melange.js/js_types.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_typed_array.ml (_build/default/output/node_modules/melange.js/js_typed_array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_string.ml (_build/default/output/node_modules/melange.js/js_string.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_set.ml (_build/default/output/node_modules/melange.js/js_set.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_re.ml (_build/default/output/node_modules/melange.js/js_re.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_promise.ml (_build/default/output/node_modules/melange.js/js_promise.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_obj.ml (_build/default/output/node_modules/melange.js/js_obj.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_nullable.ml (_build/default/output/node_modules/melange.js/js_nullable.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_null.ml (_build/default/output/node_modules/melange.js/js_null.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_math.ml (_build/default/output/node_modules/melange.js/js_math.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_mapper_runtime.ml (_build/default/output/node_modules/melange.js/js_mapper_runtime.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_map.ml (_build/default/output/node_modules/melange.js/js_map.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_json.ml (_build/default/output/node_modules/melange.js/js_json.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_iterator.ml (_build/default/output/node_modules/melange.js/js_iterator.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_int.ml (_build/default/output/node_modules/melange.js/js_int.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_global.ml (_build/default/output/node_modules/melange.js/js_global.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_float.ml (_build/default/output/node_modules/melange.js/js_float.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_exn.ml (_build/default/output/node_modules/melange.js/js_exn.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_dict.ml (_build/default/output/node_modules/melange.js/js_dict.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_date.ml (_build/default/output/node_modules/melange.js/js_date.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_console.ml (_build/default/output/node_modules/melange.js/js_console.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_bigint.ml (_build/default/output/node_modules/melange.js/js_bigint.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_array.ml (_build/default/output/node_modules/melange.js/js_array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js_OO.ml (_build/default/output/node_modules/melange.js/js_OO.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/js.ml (_build/default/output/node_modules/melange.js/js.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/curry.ml (_build/default/output/node_modules/melange.js/curry.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_undefined_extern.ml (_build/default/output/node_modules/melange.js/caml_undefined_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_sys.ml (_build/default/output/node_modules/melange.js/caml_sys.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_string_extern.ml (_build/default/output/node_modules/melange.js/caml_string_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_string.ml (_build/default/output/node_modules/melange.js/caml_string.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_splice_call.ml (_build/default/output/node_modules/melange.js/caml_splice_call.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_parser.ml (_build/default/output/node_modules/melange.js/caml_parser.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_option.ml (_build/default/output/node_modules/melange.js/caml_option.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_oo_curry.ml (_build/default/output/node_modules/melange.js/caml_oo_curry.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_oo.ml (_build/default/output/node_modules/melange.js/caml_oo.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_obj.ml (_build/default/output/node_modules/melange.js/caml_obj.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_nativeint_extern.ml (_build/default/output/node_modules/melange.js/caml_nativeint_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_module.ml (_build/default/output/node_modules/melange.js/caml_module.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_md5.ml (_build/default/output/node_modules/melange.js/caml_md5.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_lexer.ml (_build/default/output/node_modules/melange.js/caml_lexer.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_js_exceptions.ml (_build/default/output/node_modules/melange.js/caml_js_exceptions.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_io.ml (_build/default/output/node_modules/melange.js/caml_io.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int64_extern.ml (_build/default/output/node_modules/melange.js/caml_int64_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int64.ml (_build/default/output/node_modules/melange.js/caml_int64.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int32_extern.ml (_build/default/output/node_modules/melange.js/caml_int32_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_int32.ml (_build/default/output/node_modules/melange.js/caml_int32.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_hash_primitive.ml (_build/default/output/node_modules/melange.js/caml_hash_primitive.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_hash.ml (_build/default/output/node_modules/melange.js/caml_hash.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_gc.ml (_build/default/output/node_modules/melange.js/caml_gc.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_format.ml (_build/default/output/node_modules/melange.js/caml_format.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_float_extern.ml (_build/default/output/node_modules/melange.js/caml_float_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_float.ml (_build/default/output/node_modules/melange.js/caml_float.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_external_polyfill.ml (_build/default/output/node_modules/melange.js/caml_external_polyfill.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_exceptions.ml (_build/default/output/node_modules/melange.js/caml_exceptions.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_bytes.ml (_build/default/output/node_modules/melange.js/caml_bytes.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_array_extern.ml (_build/default/output/node_modules/melange.js/caml_array_extern.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml_array.ml (_build/default/output/node_modules/melange.js/caml_array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/js/caml.ml (_build/default/output/node_modules/melange.js/caml.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/weak.ml (_build/default/output/node_modules/melange/weak.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/unit.ml (_build/default/output/node_modules/melange/unit.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/uchar.ml (_build/default/output/node_modules/melange/uchar.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/type.ml (_build/default/output/node_modules/melange/type.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/sys.ml (_build/default/output/node_modules/melange/sys.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stringLabels.ml (_build/default/output/node_modules/melange/stringLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/string.ml (_build/default/output/node_modules/melange/string.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stdlib.ml (_build/default/output/node_modules/melange/stdlib.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/std_exit.ml (_build/default/output/node_modules/melange/std_exit.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stdLabels.ml (_build/default/output/node_modules/melange/stdLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/stack.ml (_build/default/output/node_modules/melange/stack.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/set.ml (_build/default/output/node_modules/melange/set.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/seq.ml (_build/default/output/node_modules/melange/seq.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/scanf.ml (_build/default/output/node_modules/melange/scanf.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/result.ml (_build/default/output/node_modules/melange/result.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/random.ml (_build/default/output/node_modules/melange/random.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/queue.ml (_build/default/output/node_modules/melange/queue.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/printf.ml (_build/default/output/node_modules/melange/printf.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/printexc.ml (_build/default/output/node_modules/melange/printexc.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/parsing.ml (_build/default/output/node_modules/melange/parsing.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/out_channel.ml (_build/default/output/node_modules/melange/out_channel.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/option.ml (_build/default/output/node_modules/melange/option.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/oo.ml (_build/default/output/node_modules/melange/oo.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/obj.ml (_build/default/output/node_modules/melange/obj.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/mutex.ml (_build/default/output/node_modules/melange/mutex.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/moreLabels.ml (_build/default/output/node_modules/melange/moreLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/marshal.ml (_build/default/output/node_modules/melange/marshal.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/map.ml (_build/default/output/node_modules/melange/map.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/listLabels.ml (_build/default/output/node_modules/melange/listLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/list.ml (_build/default/output/node_modules/melange/list.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/lexing.ml (_build/default/output/node_modules/melange/lexing.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/lazy.ml (_build/default/output/node_modules/melange/lazy.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/int64.ml (_build/default/output/node_modules/melange/int64.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/int32.ml (_build/default/output/node_modules/melange/int32.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/int.ml (_build/default/output/node_modules/melange/int.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/in_channel.ml (_build/default/output/node_modules/melange/in_channel.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/hashtbl.ml (_build/default/output/node_modules/melange/hashtbl.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/gc.ml (_build/default/output/node_modules/melange/gc.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/fun.ml (_build/default/output/node_modules/melange/fun.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/format.ml (_build/default/output/node_modules/melange/format.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/float.ml (_build/default/output/node_modules/melange/float.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/filename.ml (_build/default/output/node_modules/melange/filename.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/ephemeron.ml (_build/default/output/node_modules/melange/ephemeron.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/either.ml (_build/default/output/node_modules/melange/either.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/dynarray.ml (_build/default/output/node_modules/melange/dynarray.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/domain.ml (_build/default/output/node_modules/melange/domain.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/digest.ml (_build/default/output/node_modules/melange/digest.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/complex.ml (_build/default/output/node_modules/melange/complex.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/char.ml (_build/default/output/node_modules/melange/char.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalOO.ml (_build/default/output/node_modules/melange/camlinternalOO.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalMod.ml (_build/default/output/node_modules/melange/camlinternalMod.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalLazy.ml (_build/default/output/node_modules/melange/camlinternalLazy.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalFormatBasics.ml (_build/default/output/node_modules/melange/camlinternalFormatBasics.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalFormat.ml (_build/default/output/node_modules/melange/camlinternalFormat.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/camlinternalAtomic.ml (_build/default/output/node_modules/melange/camlinternalAtomic.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/callback.ml (_build/default/output/node_modules/melange/callback.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/bytesLabels.ml (_build/default/output/node_modules/melange/bytesLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/bytes.ml (_build/default/output/node_modules/melange/bytes.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/buffer.ml (_build/default/output/node_modules/melange/buffer.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/bool.ml (_build/default/output/node_modules/melange/bool.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/atomic.ml (_build/default/output/node_modules/melange/atomic.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/arrayLabels.ml (_build/default/output/node_modules/melange/arrayLabels.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/array.ml (_build/default/output/node_modules/melange/array.js)) (/Users/davesnx/Code/github/ocaml/dune/_opam/lib/melange/arg.ml (_build/default/output/node_modules/melange/arg.js)) (_build/default/lib.ml (_build/default/output/lib.js)))")))) ((deps From f1163b6591aaf58112730b1dae41bf6992f15e88 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Wed, 1 Jan 2025 23:28:42 -0800 Subject: [PATCH 5/5] wip Signed-off-by: Antonio Nuno Monteiro --- src/dune_rules/melange/melange_rules.ml | 102 ++++++++++++------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/dune_rules/melange/melange_rules.ml b/src/dune_rules/melange/melange_rules.ml index 05981811213..426de3fad4e 100644 --- a/src/dune_rules/melange/melange_rules.ml +++ b/src/dune_rules/melange/melange_rules.ml @@ -2,15 +2,50 @@ open Import open Memo.O module Json = Dune_stats.Json -(* attach [deps] to the specified [alias] AND the (dune default) [all] alias. +let output_of_lib = + let public_lib ~info ~target_dir lib_name = + `Public_library + ( Lib_info.src_dir info + , Path.Build.L.relative target_dir [ "node_modules"; Lib_name.to_string lib_name ] + ) + in + fun ~target_dir lib -> + let info = Lib.info lib in + match Lib_info.status info with + | Private (_, None) -> `Private_library_or_emit target_dir + | Private (_, Some pkg) -> + public_lib + ~info + ~target_dir + (Lib_name.mangled (Package.name pkg) (Lib_name.to_local_exn (Lib.name lib))) + | Installed | Installed_private | Public _ -> + public_lib ~info ~target_dir (Lib_info.name info) +;; - when [alias] is not supplied, {!Melange_stanzas.Emit.implicit_alias} is - assumed. *) -let add_deps_to_aliases ?(alias = Melange_stanzas.Emit.implicit_alias) ~dir deps = - let alias = Alias.make alias ~dir in - let dune_default_alias = Alias.make Alias0.all ~dir in - let attach alias = Rules.Produce.Alias.add_deps alias deps in - Memo.parallel_iter ~f:attach [ alias; dune_default_alias ] +let lib_output_path ~output_dir ~lib_dir src = + match Path.drop_prefix_exn src ~prefix:lib_dir |> Path.Local.to_string with + | "" -> output_dir + | dir -> Path.Build.relative output_dir dir +;; + +let make_js_name ~js_ext ~output m = + let basename = Melange.js_basename m ^ js_ext in + match output with + | `Public_library (lib_dir, output_dir) -> + let src_dir = Module.file m ~ml_kind:Impl |> Option.value_exn |> Path.parent_exn in + let output_dir = lib_output_path ~output_dir ~lib_dir src_dir in + Path.Build.relative output_dir basename + | `Private_library_or_emit target_dir -> + let dst_dir = + Path.Build.append_source + target_dir + (Module.file m ~ml_kind:Impl + |> Option.value_exn + |> Path.as_in_build_dir_exn + |> Path.Build.parent_exn + |> Path.Build.drop_build_context_exn) + in + Path.Build.relative dst_dir basename ;; let modules_in_obj_dir ~sctx ~scope ~preprocess modules = @@ -86,50 +121,15 @@ let modules_for_js_and_obj_dir ~sctx ~dir_contents ~scope (mel : Melange_stanzas modules, modules_for_js, obj_dir ;; -let output_of_lib = - let public_lib ~info ~target_dir lib_name = - `Public_library - ( Lib_info.src_dir info - , Path.Build.L.relative target_dir [ "node_modules"; Lib_name.to_string lib_name ] - ) - in - fun ~target_dir lib -> - let info = Lib.info lib in - match Lib_info.status info with - | Private (_, None) -> `Private_library_or_emit target_dir - | Private (_, Some pkg) -> - public_lib - ~info - ~target_dir - (Lib_name.mangled (Package.name pkg) (Lib_name.to_local_exn (Lib.name lib))) - | Installed | Installed_private | Public _ -> - public_lib ~info ~target_dir (Lib_info.name info) -;; - -let lib_output_path ~output_dir ~lib_dir src = - match Path.drop_prefix_exn src ~prefix:lib_dir |> Path.Local.to_string with - | "" -> output_dir - | dir -> Path.Build.relative output_dir dir -;; +(* attach [deps] to the specified [alias] AND the (dune default) [all] alias. -let make_js_name ~js_ext ~output m = - let basename = Melange.js_basename m ^ js_ext in - match output with - | `Public_library (lib_dir, output_dir) -> - let src_dir = Module.file m ~ml_kind:Impl |> Option.value_exn |> Path.parent_exn in - let output_dir = lib_output_path ~output_dir ~lib_dir src_dir in - Path.Build.relative output_dir basename - | `Private_library_or_emit target_dir -> - let dst_dir = - Path.Build.append_source - target_dir - (Module.file m ~ml_kind:Impl - |> Option.value_exn - |> Path.as_in_build_dir_exn - |> Path.Build.parent_exn - |> Path.Build.drop_build_context_exn) - in - Path.Build.relative dst_dir basename + when [alias] is not supplied, {!Melange_stanzas.Emit.implicit_alias} is + assumed. *) +let add_deps_to_aliases ?(alias = Melange_stanzas.Emit.implicit_alias) ~dir deps = + let alias = Alias.make alias ~dir in + let dune_default_alias = Alias.make Alias0.all ~dir in + let attach alias = Rules.Produce.Alias.add_deps alias deps in + Memo.parallel_iter ~f:attach [ alias; dune_default_alias ] ;; module Manifest = struct