def get_default_option_rules(): """Return the default option rules. Args: msg_func (func, optional): function to print status messages Returns: list of OptionRule. Raises: MissingFileError: If default.opts can not be found. """ default_opts_path = os.path.join(sysutil.repo_root_path(), 'etc', 'default.opts') bde_root = os.environ.get('BDE_ROOT') found_default_opts = False found_default_internal_opts = False if not os.path.isfile(default_opts_path): logutil.warn('Cannot find default.opts at %s. ' 'Trying to use $BDE_ROOT/etc/default.opts instead.' % default_opts_path) if bde_root: default_opts_path = os.path.join(bde_root, 'etc', 'default.opts') if os.path.isfile(default_opts_path): found_default_opts = True else: found_default_opts = True if not found_default_opts: raise blderror.MissingFileError('Cannot find default.opts.') option_rules = optionsparser.parse_option_rules_file(default_opts_path) if bde_root: default_internal_opts_path = os.path.join(bde_root, 'etc', 'default_internal.opts') if os.path.isfile(default_internal_opts_path): found_default_internal_opts = True option_rules += optionsparser.parse_option_rules_file( default_internal_opts_path) else: logutil.warn('The BDE_ROOT environment variable is set, ' 'but $BDE_ROOT/etc/default_internal.opts does ' 'not exist.') logutil.msg("Using default option rules from", default_opts_path) if found_default_internal_opts: logutil.msg("Using default option rules from", default_internal_opts_path) return option_rules
def get_default_option_rules(): """Return the default option rules. Returns: list of OptionRule. Raises: MissingFileError: If default.opts can not be found. """ default_opts_path = os.path.join(sysutil.repo_root_path(), "etc", "default.opts") bde_root = os.environ.get("BDE_ROOT") found_default_opts = False found_default_internal_opts = False if not os.path.isfile(default_opts_path): logutil.warn("Cannot find default.opts at %s. " "Trying to use $BDE_ROOT/etc/default.opts instead." % default_opts_path) if bde_root: default_opts_path = os.path.join(bde_root, "etc", "default.opts") if os.path.isfile(default_opts_path): found_default_opts = True else: found_default_opts = True if not found_default_opts: raise blderror.MissingFileError("Cannot find default.opts.") option_rules = optionsparser.parse_option_rules_file(default_opts_path) if bde_root: default_internal_opts_path = os.path.join(bde_root, "etc", "default_internal.opts") if os.path.isfile(default_internal_opts_path): found_default_internal_opts = True option_rules += optionsparser.parse_option_rules_file( default_internal_opts_path) else: logutil.warn('The BDE_ROOT environment variable is set to "%s", ' 'but $BDE_ROOT/etc/default_internal.opts ("%s") does ' "not exist." % (bde_root, default_internal_opts_path)) logutil.msg("Using default option rules from", default_opts_path) if found_default_internal_opts: logutil.msg("Using default option rules from", default_internal_opts_path) return option_rules
def _configure_external_libs(self): if len(self.build_config.external_dep) == 0: return try: self.ctx.find_program('pkg-config', var='PKGCONFIG') except self.ctx.errors.ConfigurationError: Logs.warn('Could not find pkg-config on the PATH. Using the' 'built-in python based pkg-config (pykg-config) ' 'instead.') self.ctx.env['PKGCONFIG'] = [sys.executable, os.path.join( sysutil.repo_root_path(), 'bin', 'tools', 'pykg-config', 'pykg-config.py')] self.ctx.find_program('pkg-config', var='PKGCONFIG') kw = self._get_pkg_config_kwargs() # If the static build is chosen (the default), waf assumes that all # libraries queried from pkg-config are to be built statically, which # is not true for some libraries. We work around this issue by manually # changing the affected libraries to be linked dynamically instead. dl_overrides = ['dl', 'pthread', 'pthreads', 'rt', 'nsl', 'resolv', 'socket'] # If lib_suffix is set, we expect the pkgconfig files being depended on # to have the same suffix as well. Since the .dep files will not have # the suffix, we will remove the suffix from the names of the options # loaded into the waf environment. rename_keys = ['defines', 'includes', 'lib', 'libpath', 'stlib', 'stlibpath'] lib_suffix = self.ctx.options.lib_suffix for lib in sorted(self.build_config.external_dep): actual_lib = lib + str(lib_suffix or '') help_str = """failed to find the library using pkg-config Maybe "%s.pc" is missing from "PKG_CONFIG_PATH"? Inspect config.log in the build output directory for details.""" % \ actual_lib kw['package'] = actual_lib kw['errmsg'] = help_str self.ctx.check_cfg(**kw) if lib_suffix: for k in rename_keys: key_old = (k + '_' + actual_lib).upper() key_new = (k + '_' + lib).upper() self.ctx.env[key_new] = self.ctx.env[key_old] del self.ctx.env[key_old] sl_key = ('stlib_' + lib).upper() dl_key = ('lib_' + lib).upper() # preserve the order of libraries for l in dl_overrides: if l in self.ctx.env[sl_key]: if dl_key not in self.ctx.env: self.ctx.env[dl_key] = [] self.ctx.env[sl_key].remove(l) self.ctx.env[dl_key].append(l) if lib_suffix: defines_old = self.ctx.env['DEFINES'] defines_new = [] for d in defines_old: index = d.find('%s=1' % lib_suffix.upper()) if index >= 0: defines_new.append('%s=1' % d[0:index]) else: defines_new.append(d) self.ctx.env['DEFINES'] = defines_new
def _configure_external_libs(self): if len(self.build_config.external_dep) == 0: return self._configure_distribution_refroot() try: self.ctx.find_program('pkg-config', var='PKGCONFIG') except self.ctx.errors.ConfigurationError: Logs.warn('Could not find pkg-config on the PATH. Using the' 'built-in python based pkg-config (pykg-config) ' 'instead.') self.ctx.env['PKGCONFIG'] = [sys.executable, os.path.join( sysutil.repo_root_path(), 'bin', 'tools', 'pykg-config', 'pykg-config.py')] self.ctx.find_program('pkg-config', var='PKGCONFIG') pkgconfig_args = ['--libs', '--cflags'] if 'shr' not in self.ufid.flags: pkgconfig_args.append('--static') # If the static build is chosen (the default), waf assumes that all # libraries queried from pkg-config are to be built statically, which # is not true for some libraries. We work around this issue by manually # changing the affected libraries to be linked dynamically instead. dl_overrides = ['pthread', 'rt', 'nsl', 'socket'] # If lib_suffix is set, we expect the pkgconfig files being depended on # to have the same suffix as well. Since the .dep files will not have # the suffix, we will remove the suffix from the names of the options # loaded into the waf environment. rename_keys = ['defines', 'includes', 'lib', 'libpath', 'stlib', 'stlibpath'] lib_suffix = self.ctx.options.lib_suffix for lib in sorted(self.build_config.external_dep): actual_lib = lib + str(lib_suffix or '') help_str = """failed to find the library using pkg-config Maybe "%s.pc" is missing from "PKG_CONFIG_PATH"? Inspect config.log in the build output directory for details.""" % \ actual_lib self.ctx.check_cfg( package=actual_lib, args=pkgconfig_args, errmsg=help_str) if lib_suffix: for k in rename_keys: key_old = (k + '_' + actual_lib).upper() key_new = (k + '_' + lib).upper() self.ctx.env[key_new] = self.ctx.env[key_old] del self.ctx.env[key_old] sl_key = ('stlib_' + lib).upper() dl_key = ('lib_' + lib).upper() # preserve the order of libraries for l in dl_overrides: if l in self.ctx.env[sl_key]: if dl_key not in self.ctx.env: self.ctx.env[dl_key] = [] self.ctx.env[sl_key].remove(l) self.ctx.env[dl_key].append(l) if lib_suffix: defines_old = self.ctx.env['DEFINES'] defines_new = [] for d in defines_old: index = d.find('%s=1' % lib_suffix.upper()) if index >= 0: defines_new.append('%s=1' % d[0:index]) else: defines_new.append(d) self.ctx.env['DEFINES'] = defines_new
import fnmatch import os import sys import time from waflib import Utils from waflib import Task from waflib import Logs from waflib import Options from waflib import TaskGen from bdebuild.common import sysutil from bdebuild.waf import lcov testlock = Utils.threading.Lock() test_runner_path = os.path.join(sysutil.repo_root_path(), 'bin', 'bde_runtest.py') @TaskGen.feature('cxx', 'c') @TaskGen.after_method('process_use') def add_coverage(self): if self.bld.env['with_coverage']: if getattr(self, 'uselib', None): if 'GCOV' not in self.uselib: self.uselib += ['GCOV'] else: self.uselib = ['GCOV'] @TaskGen.feature('test')
def test_repo_root_path(self): root_path = sysutil.repo_root_path() self.assertTrue(os.path.isdir(os.path.join(root_path, 'etc')))
import fnmatch import os import sys import time from waflib import Utils from waflib import Task from waflib import Logs from waflib import Options from waflib import TaskGen from bdebuild.common import sysutil from bdebuild.waf import lcov testlock = Utils.threading.Lock() test_runner_path = os.path.join(sysutil.repo_root_path(), "bin", "bde_runtest.py") @TaskGen.feature("cxx", "c") @TaskGen.after_method("process_use") def add_coverage(self): if self.bld.env["with_coverage"]: if getattr(self, "uselib", None): if "GCOV" not in self.uselib: self.uselib += ["GCOV"] else: self.uselib = ["GCOV"] @TaskGen.feature("test") @TaskGen.after_method("apply_link")