diff --git a/CHANGES.md b/CHANGES.md index 442d9d0ca5e..1d4e1a7b676 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -31,7 +31,7 @@ Unreleased - Speed up file copying on macos by using `clonefile` when available (@rgrinberg, #7210) -- Adds support for loading plugins in toplevels (#6082, fixes #6081, +- Adds support for loading plugins in toplevels (#6082, fixes #6081, @ivg, @richardlford) - Support commands that output 8-bit and 24-bit colors in the terminal (#7188, @@ -83,6 +83,9 @@ Unreleased - Fix segfault on MacOS when dune was being shutdown while in watch mode. (#7312, fixes #6151, @gridbugs, @emillon) +- Support `(link_flags ...)` in `(cinaps ...)` stanza. (#7423, fixes #7416, + @nojb) + 3.7.0 (2023-02-17) ------------------ diff --git a/src/dune_rules/cinaps.ml b/src/dune_rules/cinaps.ml index 0aee7b16eda..c35eecca098 100644 --- a/src/dune_rules/cinaps.ml +++ b/src/dune_rules/cinaps.ml @@ -9,6 +9,7 @@ type t = ; runtime_deps : Dep_conf.t list ; cinaps_version : Syntax.Version.t ; alias : Alias.Name.t option + ; link_flags : Link_flags.Spec.t } let name = "cinaps" @@ -38,6 +39,7 @@ let decode = (Dune_lang.Syntax.since syntax (1, 1) >>> repeat Dep_conf.decode) and+ cinaps_version = Dune_lang.Syntax.get_exn syntax and+ alias = field_o "alias" Alias.Name.decode + and+ link_flags = Link_flags.Spec.decode ~since:(Some (3, 8)) (* TODO use this field? *) and+ _flags = Ocaml_flags.Spec.decode in { loc @@ -48,6 +50,7 @@ let decode = ; runtime_deps ; cinaps_version ; alias + ; link_flags }) let () = @@ -139,7 +142,17 @@ let gen_rules sctx t ~dir ~scope = ~js_of_ocaml:None ~package:None in let* (_ : Exe.dep_graphs) = - Exe.build_and_link cctx + let link_args = + let open Action_builder.O in + let* link_flags = + Action_builder.of_memo (Super_context.link_flags sctx ~dir t.link_flags) + in + let+ link_args = + Link_flags.get ~use_standard_cxx_flags:false link_flags + in + Command.Args.As link_args + in + Exe.build_and_link cctx ~link_args ~program:{ name; main_module_name; loc } ~linkages:[ Exe.Linkage.native_or_custom (Super_context.context sctx) ] ~promote:None diff --git a/test/blackbox-tests/test-cases/cinaps/link-flags.t b/test/blackbox-tests/test-cases/cinaps/link-flags.t new file mode 100644 index 00000000000..b6c57f7bfcb --- /dev/null +++ b/test/blackbox-tests/test-cases/cinaps/link-flags.t @@ -0,0 +1,17 @@ +Link-time flags for running cinaps + + $ cat > dune-project < (lang dune 3.8) + > (using cinaps 1.1) + > EOF + + $ cat > dune < (cinaps + > (files *.ml) + > (link_flags -linkall)) + > EOF + + $ touch test.ml + + $ dune build --verbose @cinaps 2>&1 | sed -n 's#.*/cinaps.exe.*\(-linkall\).*#\1#p' + -linkall