1

I can't figure out how to use two different compilers in the same wscript. Nothing in the Waf book shows this clearly.

I tried something among those lines :

def configure(ctx):
    ctx.setenv('compiler1')
    ctx.env.CC = '/some/compiler'
    ctx.load('compiler_c')
    ctx.setenv('compiler2')
    ctx.env.CC = '/some/other/compiler'
    ctx.load('compiler_c')

This does not appear to work. Waf does not find any compiler when I do it that way. I have only managed to compile using two different compilers by specifying in the command line

 $ CC='/some/compiler' waf configure

This is annoying because I have to manually change the CC variable every time by hand and rerun configure...

Thanks !

XDD
  • 47
  • 6
  • 1
    Did you have a look at **build variants**, see https://waf.io/book/#_changing_the_output_directory this should fix your problem. Also make sure your compilers are in th path. Is your compiler one of these defined in https://waf.io/apidocs/tools/compiler_c.html?module-waflib.Tools.compiler_c ? – user69453 Jun 17 '18 at 14:51
  • Yes I used build variants, I was finally able to make it work. I had sourced something that was overriding the CC variable... – XDD Jun 18 '18 at 14:42
  • It just so happens that the next step for me would be to use a certain gcc compiler. An arm gcc compiler that uses a bunch of flags. Should I write a tool for this, or is there a way for compiler_c to find it ? – XDD Jun 18 '18 at 14:48
  • 1
    just do `ctx.env.CC = 'arm-none-eabi-gcc'` etc. Should I make it an answer? – user69453 Jun 22 '18 at 13:00
  • @XDD: Maybe post an answer to explain how you did it. – neuro Oct 23 '18 at 07:35

1 Answers1

1

Well, you were close :) You just need to load the compiler tool after setting the CC env variable, conf.load("compiler_c") and use variants build. I wrote a complete example in this answer.

neuro
  • 14,948
  • 3
  • 36
  • 59