def get_base_env(*args, **kwargs): """Initialize and return a base construction environment. All args received are passed transparently to SCons Environment init. """ # Initialize new construction environment env = Environment(*args, **kwargs) # pylint: disable=undefined-variable # If a flavor is activated in the external environment - use it if 'BUILD_FLAVOR' in os.environ: active_flavor = os.environ['BUILD_FLAVOR'] if not active_flavor in flavors(): raise StopError('%s (from env) is not a known flavor.' % (active_flavor)) sprint('Using active flavor "%s" from your environment', active_flavor) env.flavors = [active_flavor] else: # If specific flavor target specified, skip processing other flavors # Otherwise, include all known flavors env.flavors = ( set(flavors()).intersection(COMMAND_LINE_TARGETS) # pylint: disable=undefined-variable or flavors()) # Perform base construction environment customizations from site_config if '_common' in ENV_OVERRIDES: env.Replace(**ENV_OVERRIDES['_common']) if '_common' in ENV_EXTENSIONS: env.Append(**ENV_EXTENSIONS['_common']) return env
def get_base_env(*args, **kwargs): """Initialize and return a base construction environment. All args received are passed transparently to SCons Environment init. """ # Initialize new construction environment env = Environment(*args, **kwargs) # pylint: disable=undefined-variable # If a flavor is activated in the external environment - use it if 'BUILD_FLAVOR' in os.environ: active_flavor = os.environ['BUILD_FLAVOR'] if not active_flavor in flavors(): raise StopError('%s (from env) is not a known flavor.' % (active_flavor)) sprint('Using active flavor "%s" from your environment', active_flavor) env.flavors = [active_flavor] else: # If specific flavor target specified, skip processing other flavors # Otherwise, include all known flavors env.flavors = (set(flavors()).intersection(COMMAND_LINE_TARGETS) # pylint: disable=undefined-variable or flavors()) # Perform base construction environment customizations from site_config if '_common' in ENV_OVERRIDES: env.Replace(**ENV_OVERRIDES['_common']) if '_common' in ENV_EXTENSIONS: env.Append(**ENV_EXTENSIONS['_common']) return env
def get_base_env(*args, **kwargs): """Initialize and return a base construction environment. All args received are passed transparently to SCons Environment init. """ # Initialize new construction environment env = Environment(*args, **kwargs) env.flavors = ( set(flavors()).intersection(COMMAND_LINE_TARGETS) # pylint: disable=undefined-variable or flavors()) # Perform base construction environment customizations from site_config if '_common' in ENV_OVERRIDES: env.Replace(**ENV_OVERRIDES['_common']) if '_common' in ENV_EXTENSIONS: env.Append(**ENV_EXTENSIONS['_common']) return env
def get_base_env(*args, **kwargs): """Initialize and return a base construction environment. All args received are passed transparently to SCons Environment init. """ # Initialize new construction environment env = Environment(*args, **kwargs) # pylint: disable=undefined-variable # If a flavor is activated in the external environment - use it if 'BUILD_FLAVOR' in os.environ: active_flavor = os.environ['BUILD_FLAVOR'] if not active_flavor in flavors(): raise StopError( '{} (from env) is not a known flavor.'.format(active_flavor)) log_warn('Using active flavor "{}" from your environment'.format( active_flavor)) env.flavors = [active_flavor] else: # If specific flavor target specified, skip processing other flavors # Otherwise, include all known flavors env.flavors = ( set(flavors()).intersection(COMMAND_LINE_TARGETS) # pylint: disable=undefined-variable or flavors()) # log_warn('flavors') # print(env.flavors) # Perform base construction environment customizations from site_config if '_common' in ENV_OVERRIDES: # https://docs.python.org/3/tutorial/controlflow.html#unpacking-argument-lists # env.Replace(ENV={'PATH': os.environ['PATH']}) env.Replace(**ENV_OVERRIDES['_common']) if '_common' in ENV_EXTENSIONS: env.Append(**ENV_EXTENSIONS['_common']) env.Append( BUILDERS={ 'LST': Builder(generator=lst_generator, suffix='.lst', src_suffix='.elf'), 'SIZ': Builder(generator=siz_generator, suffix='.siz', src_suffix='.elf'), 'BIN': Builder(generator=bin_generator, suffix='.bin', src_suffix='.elf'), 'HEX': Builder(generator=hex_generator, suffix='.hex', src_suffix='.elf') }) env.Append( BUILDERS={ 'ZBIN': Builder(action=zbin_generator, suffix='.bin.gz', src_suffix='.bin'), 'IMG': Builder(generator=img_generator, suffix='.img', src_suffix='.bin'), 'ZIMG': Builder(generator=zimg_generator, suffix='_gz.img', src_suffix=['.bin.gz', '.bin']), 'FLS': Builder(generator=fls_generator, suffix='.fls', src_suffix='.bin') }) # log_warn('base_Environment') # print(env.Dump()) log_warn('COMMAND_LINE_TARGETS: {}'.format(COMMAND_LINE_TARGETS)) log_warn('DEFAULT_TARGETS: {}'.format(DEFAULT_TARGETS)) log_warn('BUILD_TARGETS: {}'.format(BUILD_TARGETS)) return env