Skip to content

Commit

Permalink
Fix Jsoo rules bug: artifacts of libraries with public names are not …
Browse files Browse the repository at this point in the history
…found (#6828)

Signed-off-by: Nicolás Ojeda Bär <n.oje.bar@gmail.com>
Signed-off-by: Hugo Heuzard <hugo.heuzard@gmail.com>
Co-authored-by: Hugo Heuzard <hugo.heuzard@gmail.com>
  • Loading branch information
nojb and hhugo committed Jan 5, 2023
1 parent cde7139 commit 620b98b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Unreleased
enabled (#6645, @hhugo)

- Fix *js_of_ocaml* separate compilation rules when `--enable=effects`
or `--enable=use-js-string` is used. (#6714, @hhugo)
or `--enable=use-js-string` is used. (#6714, #6828, @hhugo)

- Remove spurious build dir created when running `dune init proj ...` (#6707,
fixes #5429, @gridbugs)
Expand Down
8 changes: 4 additions & 4 deletions src/dune_rules/jsoo_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ let with_js_ext s =

let jsoo_archives ~sctx config lib =
let info = Lib.info lib in
let archives = Lib_info.archives info in
match Lib.is_local lib with
| true ->
let obj_dir = Lib_info.obj_dir info in
[ in_obj_dir' ~obj_dir ~config:(Some config)
[ Lib_name.to_string (Lib.name lib) ^ Js_of_ocaml.Ext.cma ]
]
List.map archives.byte ~f:(fun archive ->
in_obj_dir' ~obj_dir ~config:(Some config)
[ with_js_ext (Path.basename archive) ])
| false ->
let archives = Lib_info.archives info in
List.map archives.byte ~f:(fun archive ->
Path.build
(in_build_dir ~sctx ~config
Expand Down
1 change: 1 addition & 0 deletions test/blackbox-tests/test-cases/jsoo/public-libs.t/a/a.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let x = 12
3 changes: 3 additions & 0 deletions test/blackbox-tests/test-cases/jsoo/public-libs.t/a/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(library
(public_name foo.a)
(name a))
4 changes: 4 additions & 0 deletions test/blackbox-tests/test-cases/jsoo/public-libs.t/b/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(name main)
(libraries a)
(modes js))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let _ = A.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(lang dune 3.7)

(package (name foo))
17 changes: 17 additions & 0 deletions test/blackbox-tests/test-cases/jsoo/public-libs.t/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Compilation of libraries with pulic-names

$ dune build --display short
ocamlc a/.a.objs/byte/a.{cmi,cmo,cmt}
js_of_ocaml b/.main.eobjs/jsoo/main.bc.runtime.js
js_of_ocaml .js/default/stdlib/std_exit.cmo.js
js_of_ocaml .js/default/stdlib/stdlib.cma.js
ocamlopt a/.a.objs/native/a.{cmx,o}
ocamlc b/.main.eobjs/byte/dune__exe__Main.{cmi,cmti}
ocamlc a/a.cma
ocamlopt a/a.{a,cmxa}
ocamlc b/.main.eobjs/byte/dune__exe__Main.{cmo,cmt}
js_of_ocaml a/.a.objs/jsoo/default/a.cma.js
ocamlopt a/a.cmxs
ocamlc b/main.bc-for-jsoo
js_of_ocaml b/.main.eobjs/jsoo/dune__exe__Main.cmo.js
js_of_ocaml b/main.bc.js

0 comments on commit 620b98b

Please sign in to comment.