Skip to content

Commit

Permalink
reflect reviewer's comments - neat & opt
Browse files Browse the repository at this point in the history
Signed-off-by: Haochen Kotoi-Xie <hx@kxc.inc>
  • Loading branch information
haochenx committed Jun 10, 2023
1 parent 72202ba commit 7c49c1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/dune_rules/melange/melange_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,19 @@ let build_js ~loc ~dir ~pkg_name ~mode ~module_systems ~output ~obj_dir ~sctx
; Dep src
]))

(** attach [deps] to the specified [alias] AND the (dune default) [all] alias.
(* attach [deps] to the specified [alias] AND the (dune default) [all] alias.
when [alias] is not supplied, {!Melange_stanzas.Emit.implicit_alias} is
assumed. *)
when [alias] is not supplied, {!Melange_stanzas.Emit.implicit_alias} is
assumed. *)
let add_deps_to_aliases ?(alias = Melange_stanzas.Emit.implicit_alias) ~dir deps
=
let open Memo.O in
let alias = Alias.make alias ~dir in
let dune_default_alias = Alias.all ~dir in
let attach alias = Rules.Produce.Alias.add_deps alias deps in
attach alias >>> attach dune_default_alias
let+ () = attach alias
and+ () = attach dune_default_alias in
()

let setup_emit_cmj_rules ~sctx ~dir ~scope ~expander ~dir_contents
(mel : Melange_stanzas.Emit.t) =
Expand Down
7 changes: 5 additions & 2 deletions test/blackbox-tests/test-cases/melange/aliases.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ Dune default alias works
$ cat > dune <<EOF
> (melange.emit
> (target output)
> (modules main))
> (modules main)
> (emit_stdlib false))
> (melange.emit
> (target output2)
> (modules main2))
> (modules main2)
> (emit_stdlib false))
> EOF
$ cat > main2.ml <<EOF
Expand Down Expand Up @@ -97,6 +99,7 @@ Even if user defines an alias, dune default alias should still work
> (melange.emit
> (target output)
> (modules main)
> (emit_stdlib false)
> (alias foo))
> EOF
Expand Down

0 comments on commit 7c49c1d

Please sign in to comment.