From 5bf43e5ae7f6e5ab7f7e00f3d64d6fbe690b6539 Mon Sep 17 00:00:00 2001 From: Hugo Heuzard Date: Sun, 3 May 2020 14:51:43 +0200 Subject: [PATCH] Fix META generation wrt javascript deps Signed-off-by: Hugo Heuzard --- CHANGES.md | 6 ++++++ src/dune/gen_meta.ml | 13 +++++++++---- test/blackbox-tests/test-cases/meta-gen/run.t | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 74c000c304c..7482a654389 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +Unreleased +---------- + +- Generate correct META files for sub-libraries (of the form `lib.foo`) that + contain .js runtime files. (#3445, @hhugo) + 2.5.1 (17/04/2020) ------------------ diff --git a/src/dune/gen_meta.ml b/src/dune/gen_meta.ml index daafa015f00..34ba9b4328f 100644 --- a/src/dune/gen_meta.ml +++ b/src/dune/gen_meta.ml @@ -63,7 +63,7 @@ let archives ?(preds = []) lib = ; plugin (preds @ [ Pos "native" ]) (make plugins.native) ] -let gen_lib pub_name lib ~version = +let gen_lib pub_name lib ~path ~version = let info = Lib.info lib in let synopsis = Lib_info.synopsis info in let kind = Lib_info.kind info in @@ -139,7 +139,9 @@ let gen_lib pub_name lib ~version = let root = Pub_name.root pub_name in let l = List.map l ~f:Path.basename in [ rule "linkopts" [ Pos "javascript" ] Set - (List.map l ~f:(sprintf "+%s/%s" root) |> String.concat ~sep:" ") + ( List.map l + ~f:(sprintf "+%s/%s" (String.concat ~sep:"/" (root :: path))) + |> String.concat ~sep:" " ) ; rule "jsoo_runtime" [] Set (String.concat l ~sep:" ") ] ) ] @@ -153,10 +155,13 @@ let gen ~package ~version ?(add_directory_entry = true) entries = let pkgs = List.map entries ~f:(fun (e : Super_context.Lib_entry.t) -> match e with - | Library lib -> + | Library lib -> ( let name = Lib.Local.info lib |> Lib_info.name in let pub_name = Pub_name.parse name in - (pub_name, gen_lib pub_name (Lib.Local.to_lib lib) ~version) + match Pub_name.to_list pub_name with + | [] -> assert false + | _package :: path -> + (pub_name, gen_lib pub_name ~path (Lib.Local.to_lib lib) ~version) ) | Deprecated_library_name { old_public_name = { public = old_public_name; _ } ; new_public_name = _, new_public_name diff --git a/test/blackbox-tests/test-cases/meta-gen/run.t b/test/blackbox-tests/test-cases/meta-gen/run.t index 0e4c4ae4a2e..22bdb46929c 100644 --- a/test/blackbox-tests/test-cases/meta-gen/run.t +++ b/test/blackbox-tests/test-cases/meta-gen/run.t @@ -60,8 +60,8 @@ archive(native) = "foobar_runtime_lib2.cmxa" plugin(byte) = "foobar_runtime_lib2.cma" plugin(native) = "foobar_runtime_lib2.cmxs" - linkopts(javascript) = "+foobar/foobar_runtime.js - +foobar/foobar_runtime2.js" + linkopts(javascript) = "+foobar/runtime-lib2/foobar_runtime.js + +foobar/runtime-lib2/foobar_runtime2.js" jsoo_runtime = "foobar_runtime.js foobar_runtime2.js" ) package "sub" (