Skip to content

Commit

Permalink
chore: update melange (#7617)
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Nuno Monteiro <[email protected]>
  • Loading branch information
anmonteiro authored Apr 24, 2023
1 parent 7bb6de7 commit b70666f
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 64 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ ppx_inline_test \
ppxlib \
ctypes \
"utop>=2.6.0" \
"melange>=0.3.1" \
"mel>=0.3.1"

"melange" \
"rescript-syntax"
# Dependencies recommended for developing dune locally,
# but not wanted in CI
DEV_DEPS := \
Expand Down Expand Up @@ -74,8 +73,9 @@ dev-depext:

.PHONY: melange
melange:
opam pin add -n melange-compiler-libs https://github.com/melange-re/melange-compiler-libs.git#7263bea2285499f5da857f2bb374345a5178791e
opam pin add -n melange https://github.com/melange-re/melange.git#68c6eff82ed056feed809d6cc82558e8697b965b
opam pin add -n melange-compiler-libs.dev https://github.com/melange-re/melange-compiler-libs.git#575ac4c24b296ea897821f9aaee1146ff258c704
opam pin add -n melange.dev https://github.com/melange-re/melange.git#60eabf03d60b1e71f8d5aae72d24d7a1dfcf5bf6
opam pin add -n rescript-syntax.dev https://github.com/melange-re/melange.git#60eabf03d60b1e71f8d5aae72d24d7a1dfcf5bf6

.PHONY: dev-deps
dev-deps: melange
Expand Down
68 changes: 43 additions & 25 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
slim-melange = mkSlim {
extraBuildInputs = [
pkgs.ocamlPackages.melange
pkgs.ocamlPackages.mel
pkgs.ocamlPackages.rescript-syntax
];
meta.description = ''
Provides a minimal shell environment built purely from nixpkgs
Expand Down Expand Up @@ -214,7 +214,7 @@
++ [
ocamllsp.outputs.packages.${system}.ocaml-lsp-server
pkgs.ocamlPackages.melange
pkgs.ocamlPackages.mel
pkgs.ocamlPackages.rescript-syntax
] ++ nixpkgs.lib.attrsets.attrVals (builtins.attrNames devPackages) scope;
inputsFrom = [ self.packages.${system}.dune ];
meta.description = ''
Expand Down
2 changes: 1 addition & 1 deletion src/dune_engine/action.ml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module Prog = struct
match program with
| "refmt" -> Some (Option.value ~default:"opam install reason" hint)
| "rescript_syntax" ->
Some (Option.value ~default:"opam install mel" hint)
Some (Option.value ~default:"opam install rescript-syntax" hint)
| _ -> hint
in
Utils.program_not_found_message ?hint ~loc ~context program
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Example using melange.emit, copy_files and include_subdirs
$ cat > src/dune <<EOF
> (melange.emit
> (target app)
> (preprocess (pps melange.ppx))
> (emit_stdlib false)
> (alias mel))
>
> (subdir
Expand All @@ -41,7 +43,6 @@ Example using melange.emit, copy_files and include_subdirs
$ node $src
hello from file


Now add include_subdirs unqualified to show issue

$ echo "(include_subdirs unqualified)" >> src/dune
Expand All @@ -51,4 +52,3 @@ Now add include_subdirs unqualified to show issue
$ node $src
hello from file


6 changes: 5 additions & 1 deletion test/blackbox-tests/test-cases/melange/copy-files-simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Test simple interactions between melange.emit and copy_files
$ cat > dune <<EOF
> (melange.emit
> (target output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (alias mel))
>
> (copy_files
Expand All @@ -32,11 +34,14 @@ Test simple interactions between melange.emit and copy_files
hello from file



Copy the file into the output folder, so we can use same path as in-source

$ cat > dune <<EOF
> (melange.emit
> (target output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (alias mel))
>
> (subdir output
Expand All @@ -55,4 +60,3 @@ Copy the file into the output folder, so we can use same path as in-source
$ node _build/default/output/main.js
hello from file


Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Test simple interactions between melange.emit and copy_files
> (alias mel)
> (target output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (runtime_deps ./some_dir))
> EOF

Expand All @@ -25,11 +26,7 @@ Test simple interactions between melange.emit and copy_files
> let () = Js.log file_content
> EOF

$ dune build @mel --display=short
melc .output.mobjs/melange/melange__Main.{cmi,cmj,cmt}
melc output/main.js
sh some_dir
sh some_dir
$ dune build @mel
Error: Is a directory
-> required by _build/default/output/some_dir
-> required by alias output/mel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Test simple interactions between melange.emit and copy_files
> (alias mel)
> (target output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (runtime_deps assets/file.txt assets/file.txt))
> EOF

Expand All @@ -34,9 +35,7 @@ Rules created for the assets in the output directory
(targets ((files (default/a/output/a/assets/file.txt)) (directories ())))
(chdir _build/default (copy a/assets/file.txt a/output/a/assets/file.txt))))

$ dune build @mel --display=short
melc a/.output.mobjs/melange/melange__Main.{cmi,cmj,cmt}
melc a/output/a/main.js
$ dune build @mel

The runtime_dep index.txt was copied to the build folder

Expand All @@ -52,6 +51,7 @@ The runtime_dep index.txt was copied to the build folder
hello from file



Test depending on non-existing paths

$ mkdir another
Expand All @@ -61,16 +61,18 @@ Test depending on non-existing paths
> (alias non-existing-mel)
> (target another-output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (runtime_deps doesnt-exist.txt))
> EOF

$ dune build @non-existing-mel
File "another/dune", line 1, characters 0-119:
File "another/dune", line 1, characters 0-151:
1 | (melange.emit
2 | (alias non-existing-mel)
3 | (target another-output)
4 | (emit_stdlib false)
5 | (runtime_deps doesnt-exist.txt))
5 | (preprocess (pps melange.ppx))
6 | (runtime_deps doesnt-exist.txt))
Error: No rule found for another/doesnt-exist.txt
[1]

Expand All @@ -81,11 +83,12 @@ Test depend on non-file dependencies
> (alias non-existing-mel)
> (target another-output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (runtime_deps (sandbox none)))
> EOF
$ dune build @non-existing-mel
File "another/dune", line 5, characters 15-29:
5 | (runtime_deps (sandbox none)))
File "another/dune", line 6, characters 15-29:
6 | (runtime_deps (sandbox none)))
^^^^^^^^^^^^^^
Error: only files are allowed in this position
[1]
Expand All @@ -98,6 +101,7 @@ Test depending on paths that "escape" the melange.emit directory
> (alias mel)
> (target another-output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (runtime_deps ../a/assets/file.txt))
> EOF
$ cat > another/main.ml <<EOF
Expand All @@ -117,11 +121,7 @@ Need to create the source dir first for the alias to be picked up
((files (default/another/another-output/a/assets/file.txt))
(copy a/assets/file.txt another/another-output/a/assets/file.txt))))

$ dune build @mel --display=short
melc a/.output.mobjs/melange/melange__Main.{cmi,cmj,cmt}
melc another/.another-output.mobjs/melange/melange__Main.{cmi,cmj,cmt}
melc a/output/a/main.js
melc another/another-output/another/main.js
$ dune build @mel

Path ends ups being emitted "correctly", but outside the target dir.
$ ls _build/default/another/another-output/another
Expand All @@ -137,6 +137,7 @@ Test depending on external paths
> (alias mel)
> (target external-output)
> (emit_stdlib false)
> (preprocess (pps melange.ppx))
> (runtime_deps /etc/hosts))
> EOF
$ cat > external/main.ml <<EOF
Expand All @@ -147,6 +148,7 @@ Test depending on external paths
> EOF

$ dune build @mel --display=short
ppx external/main.pp.ml
melc external/.external-output.mobjs/melange/melange__Main.{cmi,cmj,cmt}
melc external/external-output/external/main.js

Expand Down
Loading

0 comments on commit b70666f

Please sign in to comment.