dune icon indicating copy to clipboard operation
dune copied to clipboard

Add a way to pass the context CFLAGS to foreign build sandboxing

Open samoht opened this issue 5 years ago • 5 comments

Hi there,

I am trying to compile some C code, using the foreign build sandboxing. This is working nicely, but now I would like to be able to tweak the C flags (for instance to use the ones defined in the current workspace context).

Is there a way to do that properly?

I've tried various things, but I only succeeded to make dune explode:

$ echo dune
(rule
  (target foo)
  (action (setenv X %{c_flags} (run echo 1))))
$ dune build ./foo
Error: exception { exn =
    ("Pform.Map.expand_exn",
    { t =
        { vars =
            map
              { "-verbose" : No_info Values []
              ; "<" :
                  Deleted_in
                    "First_dep",(1, 0),[ "Use a named dependency instead:\n\
                                          \n\
                                         \  (deps (:x <dep>) ...)\n\
                                         \   ... %{x}\n\
                                          ..."
                                       ]
[...]

Same for:

(rule
  (target foo)
  (action (run echo %{c_flags})))

Or with (with is what I wanted to use to pass %{c_flags} to the sandboxed ./configure script):

(rule
  (target foo)
  (action (bash "echo %{c_flags}")))

samoht avatar Apr 07 '20 16:04 samoht

Just to clarify, you'd like to print the c_flags so that some script can process them?

rgrinberg avatar Apr 07 '20 19:04 rgrinberg

Just to clarify, you'd like to print the c_flags so that some script can process them?

Yes. I found a way by printing %{cc} and removing the first word, so it's not blocking (just a bit surprising that it failed like that).

samoht avatar Apr 08 '20 06:04 samoht

@samoht Thanks for reporting! I can look into this issue but probably not this/next week.

snowleopard avatar Apr 08 '20 08:04 snowleopard

Any luck with this?

dibrinsofor avatar Oct 02 '24 15:10 dibrinsofor

I'm not aware of anyone working on this at the moment. (Alas, I never found time to look.)

snowleopard avatar Oct 03 '24 23:10 snowleopard