Ani
Ani

Reputation: 1526

Reading environment/shell variables

I see that waf has reads some shell variables and saves it, in its environment (https://code.google.com/p/waf/wiki/EnvironmentVariables). But from the Waf Book, I am unable to find, as to how I can add some other variable, of my interest to be read at configure time. Do I have to just use Python's os library and read or does waf have any other mechanisms to do so ?

TIA

Upvotes: 1

Views: 661

Answers (1)

mmmmmm
mmmmmm

Reputation: 32616

Yes that is the advantage of waf it is in Python so you can get the data from anywhere so you can read using Python libraries.

However waf has done the work for you form the ApiDocs there is the add_os_flags on a Configure object which reads an OS environment variables into the env dictionary in a Configure object

e.g.

def configure(conf):
    conf.add_os_flags('CFLAGS')

I would note that it might be better to have the data in the build and not in external variables and use command line options to the process. The reason for this is to allow the project to be easily moved to another environment and it will work without having to set extra things that might be forgotten. IN other words keep the configuration together in one place and not spread over several places.

Upvotes: 1

Related Questions