Instead of duplicating the configuration detection in all dependent projects, configuration files may be written when libraries are installed. To ease the interaction with build systems based on Make (cannot query databases or apis), small applications have been created for reading the cache files and to interpret the parameters (with names traditionally ending in -config): pkg-config, wx-config, sdl-config, etc.
Waf provides the method check_cfg for querying config parameters:
def configure(conf): conf.check_cfg(atleast_pkgconfig_version='0.0.0')conf.check_cfg(package='pango', atleast_version='0.0.0')
conf.check_cfg(package='pango', exact_version='0.21') conf.check_cfg(package='pango', max_version='9.0.0') conf.check_cfg(package='pango', args='--cflags --libs')
pango_version = conf.check_cfg(modversion='pango')
conf.check_cfg(path='sdl-config', args='--cflags --libs', package='', uselib_store='SDL')
![]()
Check for the pkg-config version | |
Check for a module version | |
Obtain the flags for a package and assign them to the uselib PANGO (calculated automatically from the package name, can be overridden with the attribute "uselib_store='MYPANGO'") | |
Retrieve the module version for a package. The returned object is a string containing the version number or an empty string in case of any errors. If there were no errors, 'PANGO_VERSION' is defined, can be overridden with the attribute "uselib_store='MYPANGO'". | |
Obtain the flags for a different configuration program (sdl-config). The example is applicable for other configuration programs such as wx-config, pcre-config, etc |
Due to the amount of flags, the lack of standards between config applications, and to the output changing for different operating systems (-I for gcc, /I for msvc), the output of pkg-config is parsed, and the variables for the corresponding uselib are set in a go. The function parse_flags(line, uselib, env) in the Waf module config_c.py performs the output analysis.