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

test(melange): interaction between melange_runtime_deps and include_subdirs #7719

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Test `melange.runtime_deps` for installed libraries where the dune file is
nested more than the dune-project file

$ mkdir lib app prefix
$ cat > lib/dune-project <<EOF
> (lang dune 3.8)
> (package (name foo))
> (using melange 0.1)
> EOF

$ mkdir -p lib/packages/foo/src/runtime
$ echo "function foo() { return 42; }" > lib/packages/foo/src/runtime/runtime.js
$ cat > lib/packages/foo/src/dune <<EOF
> (include_subdirs unqualified)
> (library
> (public_name foo)
> (name foo)
> (modes melange)
> (preprocess (pps melange.ppx))
> (melange.runtime_deps ./runtime/runtime.js))
> EOF
$ cat > lib/packages/foo/src/foo.ml <<EOF
> let dirname = [%bs.raw "__dirname"]
> let () = Js.log2 "dirname:" dirname
> let read_asset () = Node.Fs.readFileSync (dirname ^ "/runtime/runtime.js") \`utf8
> EOF

$ dune build --root lib
Entering directory 'lib'
Leaving directory 'lib'

$ cat lib/_build/default/foo.install
lib: [
"_build/install/default/lib/foo/META"
"_build/install/default/lib/foo/dune-package"
"_build/install/default/lib/foo/foo.ml"
"_build/install/default/lib/foo/melange/foo.cmi" {"melange/foo.cmi"}
"_build/install/default/lib/foo/melange/foo.cmj" {"melange/foo.cmj"}
"_build/install/default/lib/foo/melange/foo.cmt" {"melange/foo.cmt"}
"_build/install/default/lib/foo/runtime/runtime.js" {"runtime/runtime.js"}
]

$ grep melange_runtime_deps lib/_build/install/default/lib/foo/dune-package
(melange_runtime_deps runtime/runtime.js))

$ cat > lib/packages/foo/src/dune <<EOF
> (include_subdirs qualified)
> (library
> (public_name foo)
> (name foo)
> (modes melange)
> (preprocess (pps melange.ppx))
> (melange.runtime_deps ./runtime/runtime.js))
> EOF
$ dune build --root lib
Entering directory 'lib'
Leaving directory 'lib'

$ cat lib/_build/default/foo.install
lib: [
"_build/install/default/lib/foo/META"
"_build/install/default/lib/foo/dune-package"
"_build/install/default/lib/foo/foo.ml"
"_build/install/default/lib/foo/melange/foo.cmi" {"melange/foo.cmi"}
"_build/install/default/lib/foo/melange/foo.cmj" {"melange/foo.cmj"}
"_build/install/default/lib/foo/melange/foo.cmt" {"melange/foo.cmt"}
"_build/install/default/lib/foo/runtime/runtime.js" {"runtime/runtime.js"}
]

$ grep melange_runtime_deps lib/_build/install/default/lib/foo/dune-package
(melange_runtime_deps runtime/runtime.js))