def _extend_proto_sources(self, sources, kwargs_dict): """Return the sources list, extended with proto-cc-sources. @param sources The original list of sources @param kwargs_dict The keyword argument dictionary The protos list, if specified, is at kwargs_dict['protos']. If it is specified, the sources list is extended accordingly, and the 'protos' key is removed (so it's safe to pass-through). """ return listify(sources) + [ self._proto_cc[re.sub(r'\.proto$', '', proto)] for proto in listify(kwargs_dict.pop('protos', None)) ]
def __init__(self, lib_name, libs=None, include_paths=None, lib_paths=None): """Initialize external library instance. @param lib_name Symbolic name of library (or library-group) @param libs Identifiers of libraries to link with (if not specified, `lib_name` is used) @param include_paths Additional include search paths @param lib_paths Additional library search paths """ super(ExtLib, self).__init__() self.name = lib_name self.libs = listify(libs) if libs is not None else [lib_name] self.cpp_paths = listify(include_paths) self.lib_paths = listify(lib_paths)
def build_prog(prog_name, sources=None, with_libs=None, **kwargs): """Customized program builder. @param prog_name Program name @param sources Source file (or list of source files) @param with_libs Library name (or list of library names) to link with. kwargs params: @param install Binary flag to override default value from closure (`default_install`). @param protos Names of proto (or protos) to add to target. """ # Extend sources list with protos from generated code manager sources = self._extend_proto_sources(sources, kwargs) install_flag = kwargs.pop('install', default_install) # Process library dependencies - add libs specified in `with_libs` for lib_name in listify(with_libs): lib_keys = listify(self._get_matching_lib_keys(lib_name)) if len(lib_keys) == 1: # Matched internal library lib_key = lib_keys[0] # Extend prog sources with library nodes sources.extend(self._libs[lib_key]) elif len(lib_keys) > 1: # Matched multiple internal libraries - probably bad! raise StopError( 'Library identifier "%s" matched %d ' 'libraries (%s). Please use a fully ' 'qualified identifier instead!' % (lib_name, len(lib_keys), ', '.join(lib_keys))) else: # empty lib_keys raise StopError('Library identifier "%s" didn\'t match ' 'any library. Is it a typo?' % (lib_name)) # Build the program and add to prog nodes dict if installable prog_nodes = self._env.Program(prog_name, sources, **kwargs) if install_flag: # storing each installable node in a dictionary instead of # defining InstallAs target on the spot, because there's # an "active" variant dir directive messing with paths. self._progs[module].extend(prog_nodes)
def build_prog(prog_name, sources, with_libs=None, *args, **kwargs): """Customized program builder. @param prog_name Program name @param sources Source file (or list of source files) @param with_libs Library name (or list of library names) to link with. @param install Binary flag to override default value from closure (`default_install`). """ # Make sure sources is a list sources = listify(sources) install_flag = kwargs.pop('install', default_install) # Process library dependencies - add libs specified in `with_libs` for lib_name in listify(with_libs): lib_keys = listify(self._get_matching_lib_keys(lib_name)) if len(lib_keys) == 1: # Matched internal library lib_key = lib_keys[0] # Extend prog sources with library nodes sources.extend(self._libs[lib_key]) elif len(lib_keys) > 1: # Matched multiple internal libraries - probably bad! raise StopError('Library identifier "%s" matched %d ' 'libraries (%s). Please use a fully ' 'qualified identifier instead!' % (lib_name, len(lib_keys), ', '.join(lib_keys))) else: # empty lib_keys raise StopError('Library identifier "%s" didn\'t match ' 'any library. Is it a typo?' % (lib_name)) # Build the program and add to prog nodes dict if installable prog_nodes = self._env.Program(prog_name, sources, *args, **kwargs) if install_flag: # storing each installable node in a dictionary instead of # defining InstallAs target on the spot, because there's # an "active" variant dir directive messing with paths. self._progs[module].extend(prog_nodes)
def build_prog(prog_name, sources, with_libs=None, *args, **kwargs): """Customized program builder. @param prog_name Program name @param sources Source file (or list of source files) @param with_libs Library name (or list of library names) to link with. @param install Binary flag to override default value from closure (`default_install`). """ if _ENABLE_DEBUG_PROG and self._env['VERBOSE'] is True: print(self._env.Dump()) # log_warn('LINKFLAGS:', self._env['LINKFLAGS'], '.') dump_info('build_prog:args', *args) dump_info('build_prog:kwargs', **kwargs) # Make sure sources is a list sources = listify(sources) + self._env['COMMON_OBJECTS'] install_flag = kwargs.pop('install', default_install) # Extract optional keywords arguments that we might extend cpp_paths = listify(kwargs.pop('CPPPATH', None)) ext_libs = listify(kwargs.pop('LIBS', None)) lib_paths = listify(kwargs.pop('LIBPATH', None)) # Process library dependencies - add libs specified in `with_libs` for lib_name in listify(with_libs): lib_keys = listify(self._get_matching_lib_keys(lib_name)) if len(lib_keys) == 1: # Matched internal library lib_key = lib_keys[0] # Extend prog sources with library nodes sources.extend(self._libs[lib_key]) elif len(lib_keys) > 1: # Matched multiple internal libraries - probably bad! raise StopError('Library identifier "{}" matched {} ' 'libraries ({}). Please use a fully ' 'qualified identifier instead!'.format( lib_name, len(lib_keys), ', '.join(lib_keys))) else: # empty lib_keys # Maybe it's an external library ext_lib = self._get_external_library(lib_name) if ext_lib: # Matched external library - extend target parameters cpp_paths.extend(ext_lib.cpp_paths) ext_libs.extend(ext_lib.libs) lib_paths.extend(ext_lib.lib_paths) else: raise StopError( 'Library identifier "{}" didn\'t match ' 'any library. Is it a typo?'.format(lib_name)) # Return extended construction environment parameters to kwargs if cpp_paths: kwargs['CPPPATH'] = cpp_paths if ext_libs: kwargs['LIBS'] = ext_libs if lib_paths: kwargs['LIBPATH'] = lib_paths # Build the program and add to prog nodes dict if installable prog_nodes = self._env.Program(prog_name, sources, *args, **kwargs) if install_flag: # storing each installable node in a dictionary instead of # defining InstallAs target on the spot, because there's # an "active" variant dir directive messing with paths. self._progs[module].extend(prog_nodes) return prog_nodes