Ammar Husain
Ammar Husain

Reputation: 1849

Passing extra arguments to Waf script

I am using the Waf build system for my project. There are a few dependencies in my project, that I do not always want to be linked and compiled. I was wondering if there is a way to pass extra arguments to Waf configure and Waf install scripts that I could read in the wscript and figure out if certain executables need to be compiled or not?

Upvotes: 3

Views: 1508

Answers (1)

Ammar Husain
Ammar Husain

Reputation: 1849

I figure out how to do this. In the wscript, create a function for options. In most cases this function should already exist.

def options(opt):
  opt.add_option('-f', '--flag', dest='custom_flag', default=False, action='store_true',
             help='a boolean option')

Now in the configure function, you could simply check for 'custom_flag' to be true if this argument was passed.

def configure(conf)
  if (conf.options.custom_flag):
    #do something
  else:
    #do something else

Now './waf configure --flag' will set the custom_flag to True. It is also possible to pass other non-boolean type arguments

Upvotes: 5

Related Questions