简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM