Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing extra arguments to Waf script

Tags:

waf

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?

like image 613
Ammar Husain Avatar asked Jun 30 '26 16:06

Ammar Husain


1 Answers

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

like image 147
Ammar Husain Avatar answered Jul 03 '26 14:07

Ammar Husain