def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2, 6, 0)): # enable tool to build python extensions if conf.env.HAVE_PYTHON_H: conf.check_python_version(version) return interpreters = [] if conf.env['EXTRA_PYTHON']: conf.all_envs['extrapython'] = conf.env.derive() conf.setenv('extrapython') conf.env['PYTHON'] = conf.env['EXTRA_PYTHON'] conf.env['IS_EXTRA_PYTHON'] = 'yes' conf.find_program('python', var='PYTHON', mandatory=True) conf.load('python') try: conf.check_python_version(version) except Exception: Logs.warn('extra-python needs to be Python %s.%s.%s or later' % (version[0], version[1], version[2])) raise interpreters.append(conf.env['PYTHON']) conf.setenv('default') conf.find_program('python3', var='PYTHON', mandatory=mandatory) conf.load('python') path_python = conf.find_program('python3') conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python) conf.check_python_version(version) interpreters.append(conf.env['PYTHON']) conf.env.python_interpreters = interpreters
def set_variant(conf, variant, env): conf.msg('----------------------------------------', '----{ %s' % variant) conf.setenv(variant, env=env) compiler = FLAGS[conf.env.COMPILER_CXX] arch = 'arch_%d' % TARGETS[conf.env.TARGET]['arch'] compiler_target = compiler[arch] if arch in compiler else None # Compiler options conf.env.CXXFLAGS = compiler['common'] + compiler[variant] if compiler_target and 'cxxflags' in compiler_target: conf.env.CXXFLAGS += compiler_target['cxxflags'] # Linker options conf.env.LINKFLAGS = compiler['link_' + variant] if compiler_target and 'linkflags' in compiler_target: conf.env.LINKFLAGS += compiler_target['linkflags'] # Includes and defines if conf.env.TARGET == 'windows_x86': conf.define('WIN32_LEAN_AND_MEAN', 1) if compiler_target and 'env' in compiler_target: for key, value in compiler_target['env'].items(): conf.env[key] = value conf.env.MSVC_MANIFEST = False
def ecpp_setupbuild(conf, id, board = None, device = None, platform = None, arch = None): kw = zip('board device platform arch'.split(),(board,device,platform,arch)) for k,v in kw: module = 'ecpp_%s_%s' % (k,v) if os.path.exists(os.path.join(conf.env['ECPP_DIR'], 'waf' , module + '.py')): conf.load(module) conf.setenv("") envname = id if envname not in conf.all_envs: for k,v in kw: func = getattr(conf,'ecpp_setupbuild_%s_%s' % (k,v),None) if func: func(**dict(kw)) break conf.setenv(envname,conf.env) conf.env['ECPP_ENVNAME'] = envname # override build flag if conf.env['ECPP_BUILDLIB_TARGET']: conf.env['ECPP_BUILDLIB'] = True ecpp_libname = 'ecpp_build_%s' % id.lower() conf.env.append_value('ECPP_LIBNAME', ecpp_libname) conf.env.append_value('ECPP_USE', [ecpp_libname]) else: conf.env['ECPP_BUILDLIB'] = False else: conf.fatal("Doubly defined build id")
def ecpp_setupbuild_arch_avr8(conf,board,device,platform,arch): envname = 'device_%s' % device conf.load('ecpp_toolchain') conf.ecpp_setuptoolchain('avr8') create = envname not in conf.all_envs if create: conf.setenv(envname, conf.env) for x in 'ASFLAGS CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x, ['-mmcu=%s' % device.lower()]) for x in 'CFLAGS CXXFLAGS'.split(): conf.env.append_value(x, ['-Os', '-funsigned-bitfields', '-fshort-enums', '-fomit-frame-pointer']) conf.env.append_value('LINKFLAGS', ['--static', '-Wl,--gc-sections']) n = conf.root.find_dir(os.path.join(conf.env['ECPP_DIR'],'src')) conf.env.append_value('INCLUDES', n.abspath()) conf.env['DEVICE'] = device # Mark this env to build a ecpp library for # each target independently conf.env['ECPP_BUILDLIB_TARGET'] = True conf.env.append_value('ECPP_FEATURES',['avr-firmware']) else: conf.setenv(envname)
def ecpp_setuptoolchain(conf, arch): global tool_prefixes arch = arch.lower() envname = 'toolchain_%s' % arch if envname not in conf.all_envs: conf.setenv(envname, conf.env) for prefix in tool_prefixes[arch]: try: conf.env.stash() conf.env['TOOL_PREFIX'] = prefix conf.load('gcc') conf.load('gxx') conf.load('gas') conf.find_program(['strip'], var='STRIP') conf.find_program(['objcopy'], var='OBJCOPY') conf.find_program(['objdump'], var='OBJDUMP') conf.find_program(['nm'], var='NM') conf.env.append_value('ASFLAGS', ['-g']) conf.env.append_value('CFLAGS', ['-g', '-Wall']) conf.env.append_value('CXXFLAGS', ['-g', '-std=c++11','-Wall', '-ftemplate-depth=10000']) except conf.errors.ConfigurationError: conf.env.revert() else: break else: conf.fatal('Could not find a valid toolchain for "%s".' % arch) else: conf.setenv(envname)
def write_setting_header (conf, **kwargs): conf.setenv ("setting") conf.write_config_header (**kwargs) bak = conf.env.cfg_files conf.setenv("") conf.env.append_unique ("cfg_files", bak) conf.all_envs.pop("setting", None)
def write_setting_header(conf, **kwargs): conf.setenv("setting") conf.write_config_header(**kwargs) bak = conf.env.cfg_files conf.setenv("") conf.env.append_unique("cfg_files", bak) conf.all_envs.pop("setting", None)
def ecpp_setupbuild_platform_netx(conf, device, board, platform, arch): global netx_cpu if not device: device, ldscript = netx_boards[board], 'board_hilscher_%s.ld' % board else: ldscript = 'device_hilscher_%s.ld' % device cpu = netx_cpu[device] envname = 'device_%s' % device conf.load('ecpp_toolchain') conf.ecpp_setuptoolchain('arm') if envname not in conf.all_envs: conf.setenv(envname, conf.env) for x in 'CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x, ['-mthumb-interwork','-mcpu=%s' % cpu]) for x in 'CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x + "_compile_thumb", ['-mthumb']) for x in 'CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x + "_compile_arm", ['-marm']) conf.env.append_value('LINKFLAGS', ['-nodefaultlibs', '--static', '-Wl,--gc-sections']) ldscript = conf.root.find_node(os.path.join(conf.env['ECPP_DIR'],'linkerscripts',ldscript)) if ldscript: conf.env['LINKERSCRIPT'] = ldscript.abspath() conf.env['DEVICE'] = device # Mark this env to build a ecpp library for conf.env['ECPP_BUILDLIB'] = True conf.env.append_value('ECPP_LIBNAME', 'ecpp_%s' % conf.env['DEVICE'].lower()) # new libc needs ecpp library for support code! conf.env['STLIB_c'] = ['c', 'ecpp_%s' % conf.env['DEVICE'].lower()] # lib gcc needs memcpy from libc conf.env['STLIB_gcc'] = ['gcc', 'c'] conf.env.append_value('ECPP_FEATURES',['netx-firmware']) else: conf.setenv(envname)
def add_toolchain(self, conf, compiler, sub_compilers=[], add=True): toolchain = '%s_%s-%s_%s-%s' % (self.NAME.lower(), compiler.arch, compiler.NAMES[0].lower(), compiler.arch_name, compiler.version) if sub_compilers: toolchain = '%s-%s-%s' % (self.NAME.lower(), compiler.NAMES[0].lower(), compiler.version) if add: conf.start_msg(' `- %s' % toolchain) else: conf.start_msg(' `- %s' % compiler.arch) try: conf.setenv(toolchain, conf.env) compiler.load_tools(conf, self) self.load_in_env(conf, compiler) if not sub_compilers: compiler.load_in_env(conf, self) v = conf.env v.ARCH_NAME = compiler.arch v.TOOLCHAIN = toolchain v.append_unique('DEFINES', ['BE_PLATFORM=platform_%s'%v.VALID_PLATFORMS[0]]) if not add: v.ENV_PREFIX = compiler.arch if not sub_compilers: conf.recurse(conf.bugenginenode.abspath()+'/mak/arch/%s'%compiler.arch, once=False) self.add_kernel_toolchains(conf) except Exception as e: conf.end_msg(e, color='RED') conf.variant = '' return None else: conf.end_msg(' ') if not sub_compilers: conf.recurse(conf.bugenginenode.abspath()+'/mak', name='setup', once=False) if v.STATIC: v.append_unique('DEFINES', ['BE_STATIC=1']) conf.variant = '' v.TMPDIR = os.path.join(conf.bldnode.abspath(), toolchain) v.PREFIX = os.path.join('bld', toolchain) conf.variant = '' for c in sub_compilers: t = self.add_toolchain(conf, c, add=False) if t: v.append_unique('SUB_TOOLCHAINS', [t]) if add: for optim in conf.env.ALL_VARIANTS: add_build_command(toolchain, optim) conf.env.append_unique('ALL_TOOLCHAINS', toolchain) return toolchain
def ecpp_setupbuild_platform_stm32(conf, device, board, platform, arch): global stm32_vars ldscript = 'device_%s.ld' % device vars = stm32_vars[device] envname = 'device_%s' % device conf.load('ecpp_toolchain ecpp_platform_arm') conf.ecpp_setuptoolchain('arm') create = envname not in conf.all_envs if create: conf.setenv(envname, conf.env) conf.env['ECPP_ENVNAME'] = envname for k,v in vars.items(): conf.env.append_value(k, Utils.to_list(v)) for x in 'CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x + "_release", ['-Os']) conf.env.append_value(x + "_debug", ['-O0']) conf.env.append_value('LINKFLAGS', ['-nodefaultlibs', '--static', '-Wl,--gc-sections']) ldscript = conf.root.find_node(os.path.join(conf.env['ECPP_DIR'],'linkerscripts',ldscript)) if ldscript: conf.env['LINKERSCRIPT'] = ldscript.abspath() conf.env['DEVICE'] = device # new libc needs ecpp library for support code! conf.env['STLIB_c'] = ['c', 'ecpp_%s' % conf.env['DEVICE'].lower()] conf.env['STLIB_gcc'] = ['gcc', 'c'] # Mark this env to build a ecpp library for conf.env['ECPP_BUILDLIB'] = True conf.env.append_value('ECPP_LIBNAME', 'ecpp_%s' % conf.env['DEVICE'].lower()) conf.env.append_value('ECPP_FEATURES',['stm32-firmware']) else: conf.setenv(envname)
def ecpp_setupbuild_platform_atsam(conf, device, board, platform, arch): global atsam_vars vars = atsam_vars[device] envname = 'device_%s' % device conf.load('ecpp_toolchain ecpp_platform_arm') conf.ecpp_setuptoolchain('arm') create = envname not in conf.all_envs if create: conf.setenv(envname, conf.env) conf.env['ECPP_ENVNAME'] = envname for k,v in vars.items(): conf.env.append_value(k, Utils.to_list(v)) for x in 'CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x + "_release", ['-Os']) conf.env.append_value(x + "_debug", ['-O0']) conf.env.append_value('LINKFLAGS', ['-nodefaultlibs', '--static', '-Wl,--gc-sections']) for x in 'ram flash'.split(): ldscript = 'device_%s_%s.ld' % (device,x) ldscript = conf.root.find_node(os.path.join(conf.env['ECPP_DIR'],'linkerscripts',ldscript )) if ldscript: conf.env['LINKERSCRIPT_%s' % x] = ldscript.abspath() else: conf.env['LINKERSCRIPT_%s' % x] = u'Error: Please define a linkerscript in wscript' conf.env['DEVICE'] = device # new libc needs ecpp library for support code! conf.env['STLIB_c'] = ['c', 'gcc', 'ecpp_%s' % conf.env['DEVICE'].lower()] conf.env['STLIB_gcc'] = [] conf.env.append_value('ECPP_FEATURES',['firmware-hex']) else: conf.setenv(envname)
def ecpp_setupbuild_platform_native(conf, device, board, platform, arch): envname = 'platform_%s' % platform conf.load('ecpp_toolchain') conf.ecpp_setuptoolchain('native') create = envname not in conf.all_envs conf.setenv(envname, conf.env) if create: for x in 'CFLAGS CXXFLAGS'.split(): conf.env.append_value(x, ['-mtune=native']) conf.env.append_value(x + "_debug", ['-O0', '-g']) conf.env.append_value(x + "_release", ['-O2', '-g']) n = conf.root.find_dir(os.path.join(conf.env['ECPP_DIR'],'src')) conf.env.append_value('INCLUDES', n.abspath())
def ecpp_setupbuild(conf, id, board = None, device = None, platform = None, arch = None): kw = zip('board device platform arch'.split(),(board,device,platform,arch)) for k,v in kw: module = 'ecpp_%s_%s' % (k,v) if os.path.exists(os.path.join(conf.env['ECPP_DIR'], 'waf' , module + '.py')): conf.load(module) break else: conf.fatal(u'No build support file found for build id %s' % id) conf.setenv("") envname = id if envname in conf.all_envs: conf.fatal("Doubly defined build id") # setup a new build environment for this particular target for k,v in kw: func = getattr(conf,'ecpp_setupbuild_%s_%s' % (k,v),None) if func: func(**dict(kw)) break else: conf.fatal(u'No builder found for build id %s' % id) # derive a new build environment from target environment for this # build id conf.setenv(envname,conf.env) conf.env['ECPP_ENVNAME'] = envname # build ecpp library for this environment conf.env['ECPP_BUILDLIB'] = True ecpp_libname = 'ecpp_build_%s' % id.lower() conf.env.append_value('ECPP_LIBNAME', ecpp_libname) conf.env.append_value('ECPP_USE', [ecpp_libname]) # new libc needs ecpp library for support code! conf.env['STLIB_c'] = ['c', ecpp_libname]
def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True): if conf.env.disable_python: if mandatory: raise Errors.WafError("Cannot check for python headers when " "--disable-python specified") conf.msg("python headers", "Check disabled due to --disable-python") # we don't want PYTHONDIR in config.h, as otherwise changing # --prefix causes a complete rebuild conf.env.DEFINES = [ x for x in conf.env.DEFINES if not x.startswith('PYTHONDIR=') and not x.startswith('PYTHONARCHDIR=') ] return if conf.env["python_headers_checked"] == []: if conf.env['EXTRA_PYTHON']: conf.setenv('extrapython') _check_python_headers(conf, mandatory=True) conf.setenv('default') _check_python_headers(conf, mandatory) conf.env["python_headers_checked"] = "yes" if conf.env['EXTRA_PYTHON']: extraversion = conf.all_envs['extrapython']['PYTHON_VERSION'] if extraversion == conf.env['PYTHON_VERSION']: raise Errors.WafError( "extrapython %s is same as main python %s" % (extraversion, conf.env['PYTHON_VERSION'])) else: conf.msg("python headers", "using cache") # we don't want PYTHONDIR in config.h, as otherwise changing # --prefix causes a complete rebuild conf.env.DEFINES = [ x for x in conf.env.DEFINES if not x.startswith('PYTHONDIR=') and not x.startswith('PYTHONARCHDIR=') ]
def ecpp_setupbuild_platform_nrf52(conf, device, board, platform, arch): global nrf52_vars ldscript = 'device_%s.ld' % device vars = nrf52_vars[device] envname = 'device_%s' % device conf.load('ecpp_toolchain ecpp_platform_arm') conf.ecpp_setuptoolchain('arm') create = envname not in conf.all_envs if create: conf.setenv(envname, conf.env) conf.env['ECPP_ENVNAME'] = envname for k,v in vars.items(): conf.env.append_value(k, Utils.to_list(v)) for x in 'CFLAGS CXXFLAGS LINKFLAGS'.split(): conf.env.append_value(x + "_release", ['-Os']) conf.env.append_value(x + "_debug", ['-O0']) conf.env.append_value('LINKFLAGS', ['-nodefaultlibs', '--static', '-Wl,--gc-sections']) ldscript = conf.root.find_node(os.path.join(conf.env['ECPP_DIR'],'linkerscripts',ldscript)) if ldscript: conf.env['LINKERSCRIPT_ecpp'] = ldscript.abspath() conf.env['DEVICE'] = device conf.env['STLIB_gcc'] = ['gcc', 'c'] conf.env.append_value('ECPP_FEATURES',['firmware-hex']) else: conf.setenv(envname)
def find_mpi_cc(conf): cc=conf.find_program(['mpiicc','mpicc','cc'],var='MPI_CC') cc=conf.cmd_to_list(cc) # Verify actual MPI implementation conf.env.stash() conf.env.CC = cc conf.env.LINK_CC = cc conf.check_cc(fragment=mpi_test) conf.env.revert() # MPI variables in global ConfigSet conf.env.MPI_CC_NAME='mpicc' conf.env.MPI_CC=cc # An MPI-Specific ConfigSet conf.setenv('mpicc', conf.env) # Compiler Options (use mpicc) conf.env.CC = cc conf.env.LINK_CC = cc #conf.env.CFLAGS = '-Wextra' # Linker Options (Remove '-Wl,-B[static,dynamic]') conf.env.LINKFLAGS_cstlib = [] conf.env.LINKFLAGS_cxxstlib = [] conf.env.SHLIB_MARKER = [] conf.env.STLIB_MARKER = [] # MT sucks on Intel if str(cc).endswith('mpiicc'): conf.env.append_unique('CFLAGS', ['-mt_mpi']) conf.env.append_unique('LDFLAGS', ['-mt_mpi']) # done with MPI-Specific ConfigSet conf.setenv('')
def setting_define (conf, key, val, key_format = "_IBEX_%s_", **kwargs): conf.setenv ("setting") conf.define (key_format % key, val, **kwargs) conf.setenv("")
def configure(conf): seen = set([]) for name, bindir, gcc, gxx, version, target, arch, options in conf.env.GCC_TARGETS: position = target.find('solaris') if position != -1: os = 'sunos' toolchain = '%s-%s-%s-%s'%(os, arch, name, version) if toolchain not in seen: seen.add(toolchain) env = conf.env.derive() conf.setenv(toolchain, env) env.DEST_OS = 'sunos' try: conf.start_msg('Setting up compiler') conf.load_gcc(bindir, gcc, gxx, version, target, arch, options) conf.set_sunos_gcc_options(options, version) except Exception as e: conf.end_msg(e, color='RED') raise else: conf.end_msg('done') conf.set_sunos_options() try: conf.env.KERNEL_TOOLCHAINS = [toolchain] conf.add_toolchain(os, arch, name, version, arch) except Errors.WafError as e: conf.variant = '' Logs.pprint('YELLOW', '%s failed: %s' % (toolchain, e)) except Exception as e: conf.variant = '' Logs.pprint('RED', '%s failed: %s' % (toolchain, e)) raise else: conf.variant = '' Logs.pprint('GREEN', 'configured for toolchain %s' % (toolchain)) for version, directory, target, arch in conf.env.CLANG_TARGETS: if target.find('solaris') != -1: arch_name, options = arch target = 'sunos' toolchain = '%s-%s-%s-%s'%(target, arch_name, 'clang', version) if toolchain not in seen: seen.add(toolchain) env = conf.env.derive() conf.setenv(toolchain, env) env.DEST_OS = 'sunos' try: conf.start_msg('Setting up compiler') conf.load_clang(directory, target, options) conf.set_sunos_clang_options(options, version) except Exception as e: conf.end_msg(e, color='RED') raise else: conf.end_msg('done') try: conf.set_sunos_options() conf.env.KERNEL_TOOLCHAINS = [toolchain] conf.add_toolchain(target, arch_name, 'clang', version, arch_name) except Errors.WafError as e: conf.variant = '' Logs.pprint('YELLOW', '%s failed: %s' % (toolchain, e)) except Exception as e: conf.variant = '' Logs.pprint('RED', '%s failed: %s' % (toolchain, e)) raise else: conf.variant = '' Logs.pprint('GREEN', 'configured for toolchain %s' % (toolchain)) for directory, target, arch, version in conf.env.SUNCC_TARGETS: if target.find('SunOS') != -1: target = 'sunos' toolchain = '%s-%s-%s-%s'%(target, arch, 'suncc', version) if toolchain not in seen: seen.add(toolchain) env = conf.env.derive() conf.setenv(toolchain, env) env.DEST_OS = 'sunos' try: conf.start_msg('Setting up compiler') conf.load_suncc(directory) conf.set_sunos_suncc_options(arch) except Exception as e: conf.end_msg(e, color='RED') raise else: conf.end_msg('done') try: conf.set_sunos_options() conf.env.KERNEL_TOOLCHAINS = [toolchain] conf.add_toolchain(target, arch, 'suncc', version, arch) except Errors.WafError as e: conf.variant = '' Logs.pprint('YELLOW', '%s failed: %s' % (toolchain, e)) except Exception as e: conf.variant = '' Logs.pprint('RED', '%s failed: %s' % (toolchain, e)) raise else: conf.variant = '' Logs.pprint('GREEN', 'configured for toolchain %s' % (toolchain))
def load_compile_rules_for_supported_platforms(conf, platform_configuration_filter): """ Load the compile rules for all the supported target platforms for the current host platform :param conf: Configuration context :param platform_configuration_filter: List of target platforms to filter out """ host_platform = conf.get_waf_host_platform() absolute_lmbr_waf_tool_path = LMBR_WAF_TOOL_DIR if os.path.isabs(LMBR_WAF_TOOL_DIR) else conf.path.make_node(LMBR_WAF_TOOL_DIR).abspath() vanilla_conf = conf.env.derive() # grab a snapshot of conf before you pollute it. host_function_name = load_compile_rules_for_host(conf, host_platform) installed_platforms = [] for platform in conf.get_available_platforms(): platform_spec_vanilla_conf = vanilla_conf.derive() platform_spec_vanilla_conf.detach() # Determine the compile rules module file and remove it and its support if it does not exist compile_rule_script = 'compile_rules_' + host_platform + '_' + platform if not os.path.exists(os.path.join(absolute_lmbr_waf_tool_path, compile_rule_script + '.py')): conf.remove_platform_from_available_platforms(platform) continue Logs.info('[INFO] Configure "%s - [%s]"' % (platform, ', '.join(conf.get_supported_configurations(platform)))) conf.load(compile_rule_script, tooldir=[LMBR_WAF_TOOL_DIR]) # platform installed installed_platforms.append(platform) # Keep track of uselib's that we found in the 3rd party config files third_party_uselib_map = conf.read_and_mark_3rd_party_libs() conf.env['THIRD_PARTY_USELIBS'] = [uselib_name for uselib_name in third_party_uselib_map] # Save off configuration values from the uselib which are necessary during build for modules built with the uselib configuration_settings_map = {} for uselib_name in third_party_uselib_map: configuration_values = conf.get_configuration_settings(uselib_name) if configuration_values: configuration_settings_map[uselib_name] = configuration_values conf.env['THIRD_PARTY_USELIB_SETTINGS'] = configuration_settings_map for supported_configuration in conf.get_supported_configurations(): # if the platform isn't going to generate a build command, don't require that the configuration exists either if platform in platform_configuration_filter: if supported_configuration not in platform_configuration_filter[platform]: continue conf.setenv(platform + '_' + supported_configuration, platform_spec_vanilla_conf.derive()) conf.init_compiler_settings() # add the host settings into the current env getattr(conf, host_function_name)() # make a copy of the config for certain variant loading redirection (e.g. test, dedicated) # this way we can pass the raw configuration to the third pary reader to properly configure # each library config_redirect = supported_configuration # Use the normal configurations as a base for dedicated server is_dedicated = False if config_redirect.endswith('_dedicated'): config_redirect = config_redirect.replace('_dedicated', '') is_dedicated = True # Use the normal configurations as a base for test is_test = False if '_test' in config_redirect: config_redirect = config_redirect.replace('_test', '') is_test = True # Use the specialized function to load platform specifics function_name = 'load_%s_%s_%s_settings' % ( config_redirect, host_platform, platform ) if not hasattr(conf, function_name): conf.fatal('[ERROR] Required Configuration Function \'%s\' not found' % function_name) # Try to load the function getattr(conf, function_name)() # Apply specific dedicated server settings if is_dedicated: getattr(conf, 'load_dedicated_settings')() # Apply specific test settings if is_test: getattr(conf, 'load_test_settings')() if platform in conf.get_supported_platforms(): # If the platform is still supported (it will be removed if the load settings function fails), then # continue to attempt to load the 3rd party uselib defs for the platform for uselib_info in third_party_uselib_map: third_party_config_file = third_party_uselib_map[uselib_info][0] path_alias_map = third_party_uselib_map[uselib_info][1] thirdparty_error_msgs, uselib_names = conf.read_3rd_party_config(third_party_config_file, platform, supported_configuration, path_alias_map) for thirdparty_error_msg in thirdparty_error_msgs: conf.warn_once(thirdparty_error_msg)
def load_compile_rules_for_supported_platforms(conf, platform_configuration_filter): """ Load the compile rules for all the supported target platforms for the current host platform :param conf: Configuration context :param platform_configuration_filter: List of target platforms to filter out """ host_platform = conf.get_waf_host_platform() absolute_lmbr_waf_tool_path = conf.path.make_node( LMBR_WAF_TOOL_DIR).abspath() vanilla_conf = conf.env.derive( ) # grab a snapshot of conf before you pollute it. host_function_name = load_compile_rules_for_host(conf, host_platform) installed_platforms = [] for platform in conf.get_available_platforms(): platform_spec_vanilla_conf = vanilla_conf.derive() platform_spec_vanilla_conf.detach() # Determine the compile rules module file and remove it and its support if it does not exist compile_rule_script = 'compile_rules_' + host_platform + '_' + platform if not os.path.exists( os.path.join(absolute_lmbr_waf_tool_path, compile_rule_script + '.py')): conf.remove_platform_from_available_platforms(platform) continue Logs.info( '[INFO] Configure "%s - [%s]"' % (platform, ', '.join(conf.get_supported_configurations(platform)))) conf.load(compile_rule_script, tooldir=LMBR_WAF_TOOL_DIR) # platform installed installed_platforms.append(platform) # Keep track of uselib's that we found in the 3rd party config files conf.env['THIRD_PARTY_USELIBS'] = [ uselib_name for uselib_name in conf.read_and_mark_3rd_party_libs() ] for configuration in conf.get_supported_configurations(): # if the platform isn't going to generate a build command, don't require that the configuration exists either if platform in platform_configuration_filter: if configuration not in platform_configuration_filter[ platform]: continue conf.setenv(platform + '_' + configuration, platform_spec_vanilla_conf.derive()) conf.init_compiler_settings() # add the host settings into the current env getattr(conf, host_function_name)() # make a copy of the config for certain variant loading redirection (e.g. test, dedicated) # this way we can pass the raw configuration to the third pary reader to properly configure # each library config_redirect = configuration # Use the normal configurations as a base for dedicated server is_dedicated = False if config_redirect.endswith('_dedicated'): config_redirect = config_redirect.replace('_dedicated', '') is_dedicated = True # Use the normal configurations as a base for test is_test = False if '_test' in config_redirect: config_redirect = config_redirect.replace('_test', '') is_test = True # Use the specialized function to load platform specifics function_name = 'load_%s_%s_%s_settings' % ( config_redirect, host_platform, platform) if not hasattr(conf, function_name): conf.fatal( '[ERROR] Required Configuration Function \'%s\' not found' % function_name) # Try to load the function getattr(conf, function_name)() # Apply specific dedicated server settings if is_dedicated: getattr(conf, 'load_dedicated_settings')() # Apply specific test settings if is_test: getattr(conf, 'load_test_settings')() if platform in conf.get_supported_platforms(): # If the platform is still supported (it will be removed if the load settings function fails), then # continue to attempt to load the 3rd party uselib defs for the platform path_alias_map = {'ROOT': conf.srcnode.abspath()} config_3rdparty_folder_legacy = conf.root.make_node( Context.launch_dir).make_node('_WAF_/3rd_party') config_3rdparty_folder_legacy_path = config_3rdparty_folder_legacy.abspath( ) config_3rdparty_folder = conf.root.make_node( Context.launch_dir).make_node('_WAF_/3rdParty') config_3rdparty_folder_path = config_3rdparty_folder.abspath() if os.path.exists( config_3rdparty_folder_legacy_path) and os.path.exists( config_3rdparty_folder_path): has_legacy_configs = len( os.listdir(config_3rdparty_folder_legacy_path)) > 0 # Both legacy and current 3rd party exists. Print a warning and use the current 3rd party if has_legacy_configs: conf.warn_once( 'Legacy 3rd Party configuration path ({0}) will be ignored in favor of ({1}). ' 'Merge & remove the configuration files from the legacy path ({0}) to the current path ({1})' .format(config_3rdparty_folder_legacy_path, config_3rdparty_folder_path)) thirdparty_error_msgs, uselib_names = conf.detect_all_3rd_party_libs( config_3rdparty_folder, platform, configuration, path_alias_map) elif os.path.exists(config_3rdparty_folder_legacy_path): # Only the legacy 3rd party config folder exists. thirdparty_error_msgs, uselib_names = conf.detect_all_3rd_party_libs( config_3rdparty_folder_legacy, platform, configuration, path_alias_map) elif os.path.exists(config_3rdparty_folder_path): # Only the current 3rd party config folder exists. thirdparty_error_msgs, uselib_names = conf.detect_all_3rd_party_libs( config_3rdparty_folder, platform, configuration, path_alias_map) else: # Neither folder exists, report a warning thirdparty_error_msgs = [ 'Unable to find 3rd party configuration path ({}). No 3rd party libraries will ' 'be configured.'.format(config_3rdparty_folder_path) ] for thirdparty_error_msg in thirdparty_error_msgs: conf.warn_once(thirdparty_error_msg)
def setting_define(conf, key, val, key_format="_IBEX_%s_", **kwargs): conf.setenv("setting") conf.define(key_format % key, val, **kwargs) conf.setenv("")