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

Add (link_flags ...) to (cinaps) stanza #7423

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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,
Expand Down Expand Up @@ -80,6 +80,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)
------------------

Expand Down
15 changes: 14 additions & 1 deletion src/dune_rules/cinaps.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the cinaps has its own syntax used for versioning. In this case, you should introduce (1, 3) to fix the issue.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, good catch. Fix in #7446. Thanks!

(* TODO use this field? *)
and+ _flags = Ocaml_flags.Spec.decode in
{ loc
Expand All @@ -48,6 +50,7 @@ let decode =
; runtime_deps
; cinaps_version
; alias
; link_flags
})

let () =
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/blackbox-tests/test-cases/cinaps/link-flags.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Link-time flags for running cinaps

$ cat > dune-project <<EOF
> (lang dune 3.8)
> (using cinaps 1.1)
> EOF

$ cat > dune <<EOF
> (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