Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix META generation wrt javascript deps #3445

Merged
merged 1 commit into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
------------------

Expand Down
13 changes: 9 additions & 4 deletions src/dune/gen_meta.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:" ")
] )
]
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox-tests/test-cases/meta-gen/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand Down