def __init__(self, toolkit, srcs, dsts, vars, targets = None, path_to_cmake_source = None): ''' `srcs`: what we depend upon. `dsts`: what will be built. `vars`: dict variables passed to cmake via `-D`. `targets`: list of Makefile targets. `path_to_cmake_source`: path to the directory containing the CMakeFile. ''' self.__toolkit = toolkit self.__vars = vars self.__prefix = drake.Drake.current.prefix self.__path_to_cmake_source = \ drake.Path(path_to_cmake_source) if path_to_cmake_source \ else drake.path_source() / self.__prefix self.__env = dict(os.environ) self.__env.update({ 'CC': ' '.join(toolkit.command_c), 'CXX': ' '.join(toolkit.command_cxx), }) self.__cmake_cache = drake.node('CMakeCache.txt') self.__targets = targets # cmake 3 compat self.__vars.update({'CMAKE_SYSTEM_PROCESSOR': 'x86_64'}) if self.toolkit.os is drake.os.windows: self.__vars.update({ 'CMAKE_ASM_NASM_COMPILER': self.toolkit.cxx[0:-3] + 'as', 'CMAKE_RC_COMPILER': self.toolkit.cxx[0:-3] + 'windres', 'CMAKE_SYSTEM_NAME': 'Windows', }) dsts = list(dsts) dsts.append(self.__cmake_cache) # Call __init__ last, make __cmake_cache is declared a dsts, so # that it has a build-tree path, not a source-tree one. super().__init__(srcs = srcs, dsts = dsts)
def execute(self): print('Generating aggregated license file: %s' % self.__target) with open(str(self.__target), 'w', encoding='utf-8') as out: for license in self.__sorted_sources: l_name = license.replace( '%s/%s/' % (self.__context, self.__license_folder), '') l_file = str(drake.path_source() / license) Packager.print_entry(out, l_name, l_file) return True
def traverse(folder, in_dir): rel_dir = '%s/%s' % (in_dir, folder) if folder else in_dir git = drake.git.Git(rel_dir) for f in git.ls_files(): path = str(drake.path_source() / self.__context / rel_dir / f) if os.path.isdir(path): traverse(f, rel_dir) else: licenses.append(drake.node('%s/%s' % (rel_dir, f)))
def execute(self): print('Generating aggregated license file: %s' % self.__target) with open(str(self.__target), 'w', encoding = 'utf-8') as out: for license in self.__sorted_sources: l_name = license.replace( '%s/%s/' % (self.__context, self.__license_folder), '') l_file = str(drake.path_source() / license) Packager.print_entry(out, l_name, l_file) return True
def __init__(self, path = None, command = GitCommand()): """Create a GitVersion. path -- path to the repository; the source dir by default. """ if path is None: path = '.' self.__path = drake.path_source(path) self.__name = drake.path_build(path) super().__init__(self.__name / 'git')
def __init__(self, name, root, nodes, fullname = None): '''Create a python Package name -- the node name root -- the package root nodes -- the package files ''' super().__init__(name) self.__root = root self.__root_source = drake.path_source(root) self.__root_build = drake.path_build(root) self.__nodes = nodes for node in nodes: self.dependency_add(node) self.__fullname = fullname or name
def __init__(self, name, root, nodes, fullname=None): '''Create a python Package name -- the node name root -- the package root nodes -- the package files ''' super().__init__(name) self.__root = root self.__root_source = drake.path_source(root) self.__root_build = drake.path_build(root) self.__nodes = nodes for node in nodes: self.dependency_add(node) self.__fullname = fullname or name
def __init__(self, path = None): """Create a GitVersion. path -- path to the repository; the source dir by default. """ if path is None: path = '.' self.__path = drake.path_source(path) self.__name = drake.path_build(path) VirtualNode.__init__(self, self.__name / 'git') self.__author_date = None self.__revision = None self.__description = None self.__version = None self.__message = None
def __init__(self, template, content = {}, sources = [], pythonpath = (), hooks = {}): self.__template = template self.__hooks = hooks dst = template.name_relative.without_last_extension() self.__target = drake.node(dst) super().__init__(self.__template, self.__target, additional_sources = sources) self.__content = content self.__pythonpath = [] for path in pythonpath: self.__pythonpath.append(drake.path_source(path)) self.__pythonpath.append(drake.path_build(path))
def __init__(self, toolkit, srcs, dsts, vars, targets=None, path_to_cmake_source=None): ''' `srcs`: what we depend upon. `dsts`: what will be built. `vars`: dict variables passed to cmake via `-D`. `targets`: list of Makefile targets. `path_to_cmake_source`: path to the directory containing the CMakeFile. ''' self.__toolkit = toolkit self.__vars = vars self.__prefix = drake.Drake.current.prefix self.__path_to_cmake_source = \ drake.Path(path_to_cmake_source) if path_to_cmake_source \ else drake.path_source() / self.__prefix self.__env = dict(os.environ) self.__env.update({ 'CC': ' '.join(toolkit.command_c), 'CXX': ' '.join(toolkit.command_cxx), }) self.__cmake_cache = drake.node('CMakeCache.txt') self.__targets = targets # cmake 3 compat self.__vars.update({'CMAKE_SYSTEM_PROCESSOR': 'x86_64'}) if self.toolkit.os is drake.os.windows: self.__vars.update({ 'CMAKE_ASM_NASM_COMPILER': self.toolkit.cxx[0:-3] + 'as', 'CMAKE_RC_COMPILER': self.toolkit.cxx[0:-3] + 'windres', 'CMAKE_SYSTEM_NAME': 'Windows', }) dsts = list(dsts) dsts.append(self.__cmake_cache) # Call __init__ last, make __cmake_cache is declared a dsts, so # that it has a build-tree path, not a source-tree one. super().__init__(srcs=srcs, dsts=dsts)
def __init__(self, template, content={}, sources=[], pythonpath=(), hooks={}, lookup=[], post_process=None): self.__template = template self.__hooks = hooks dst = template.name_relative.without_last_extension() self.__target = drake.node(dst) super().__init__(self.__template, self.__target, additional_sources=sources) self.__content = content self.__lookup = lookup self.__post_process = post_process self.__pythonpath = [] for path in pythonpath: self.__pythonpath.append(drake.path_source(path)) self.__pythonpath.append(drake.path_build(path))
def __init__(self, cxx_toolkit = None, prefix = None, version = drake.Version(), version_effective = None, prefer_shared = True, rcc = None, qmake = None, uic = None, moc = None): """Find and create a configuration for Qt. prefix -- Where to find Qt, should contain include/Qt/qglobal.h among others. /usr and /usr/local are searched by default. If relative, it is rooted in the source tree. version -- Requested version. prefer_shared -- Check dynamic libraries first. """ self.__rcc = rcc self.__qmake = qmake self.__uic = uic self.__moc = moc self.__moc_cache = {} self.__dependencies = {} cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit() self.__cxx_toolkit = cxx_toolkit self.__prefer_shared = prefer_shared include_subdirs = set(drake.Path(p) for p in ['include', 'include/qt4']) if prefix is None: test = [path.dirname() for path in cxx_toolkit.include_path if path.basename() in include_subdirs] else: test = [Path(prefix)] for i in range(len(test)): if not test[i].absolute(): test[i] = drake.path_source() / test[i] token = drake.Path('Qt/qglobal.h') tokens = list(map(lambda p: p / token, include_subdirs)) prefixes = self._search_many_all(tokens, test) miss = [] # Try every search path for path, include_subdir in prefixes: include_subdir = include_subdir.without_suffix(token) # Create basic configuration for version checking. cfg = Config() if not path.absolute(): path = path.without_prefix(drake.path_build()) cfg.add_system_include_path(path / include_subdir) if version_effective is None: try: version_eff = int(cxx_toolkit.preprocess( '#include <Qt/qglobal.h>\nQT_VERSION', config = cfg).split('\n')[-2].strip(), 16) version_eff = drake.Version( version_eff >> 16, (version_eff >> 8) % 256, version_eff % 256, ) # If the token doesn't exists, ignore. except drake.Exception: continue else: version_eff = version_effective if version_eff not in version: miss.append(version_eff) continue # Fill configuration self.__prefix = path self.__cfg = cfg for prop in self.__libraries: setattr(self, '_Qt__config_%s_dynamic' % prop, None) setattr(self, '_Qt__config_%s_static' % prop, None) setattr(self, '_Qt__config_%s_dynamic_header' % prop, None) setattr(self, '_Qt__config_%s_static_header' % prop, None) setattr(self, '_Qt__%s_dynamic' % prop, None) setattr(self, '_Qt__%s_static' % prop, None) self.__version = version_eff self.plug(cxx_toolkit) Qt.__include_dir = path / include_subdir return raise Exception('no matching Qt for the requested version ' '(%s) in %s. Found versions: %s.' % \ (version, self._format_search([path for path, include_subdir in prefixes]), ', '.join(map(str, miss))))
def __init__(self, cxx_toolkit=None, prefix=None, version=drake.Version(), version_effective=None, prefer_shared=True, rcc=None, qmake=None, uic=None, moc=None): """Find and create a configuration for Qt. prefix -- Where to find Qt, should contain include/Qt/qglobal.h among others. /usr and /usr/local are searched by default. If relative, it is rooted in the source tree. version -- Requested version. prefer_shared -- Check dynamic libraries first. """ self.__rcc = rcc self.__qmake = qmake self.__uic = uic self.__moc = moc self.__moc_cache = {} self.__dependencies = {} self.__moc_files = set() cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit() self.__cxx_toolkit = cxx_toolkit self.__prefer_shared = prefer_shared include_subdirs = set( drake.Path(p) for p in ['include', 'include/qt5']) if prefix is None: test = [ path.dirname() for path in cxx_toolkit.include_path if path.basename() in include_subdirs ] else: test = [drake.Path(prefix)] for i in range(len(test)): if not test[i].absolute(): test[i] = drake.path_source() / test[i] token = drake.Path('QtCore/qglobal.h') tokens = list(map(lambda p: p / token, include_subdirs)) prefixes = self._search_many_all(tokens, test) miss = [] # Try every search path for path, include_subdir in prefixes: include_subdir = include_subdir.without_suffix(token) # Create basic configuration for version checking. cfg = drake.cxx.Config() cfg.pic = True if not path.absolute(): path = path.without_prefix(drake.path_build()) cfg.add_system_include_path(path / include_subdir) if version_effective is None: try: version_eff = cxx_toolkit.preprocess( '#include <QtCore/qglobal.h>\nQT_VERSION', config=cfg).split('\n')[-2].strip() version_eff = eval(version_eff, {"__builtins__": None}, {}) version_eff = drake.Version( version_eff >> 16, (version_eff >> 8) % 256, version_eff % 256, ) # If the token doesn't exists, ignore. except Exception as e: continue else: version_eff = version_effective if version_eff not in version: miss.append(version_eff) continue # Fill configuration self.__prefix = path self.__cfg = cfg for prop in self.__libraries: setattr(self, '_Qt__config_%s_dynamic' % prop, None) setattr(self, '_Qt__config_%s_static' % prop, None) setattr(self, '_Qt__config_%s_dynamic_header' % prop, None) setattr(self, '_Qt__config_%s_static_header' % prop, None) setattr(self, '_Qt__%s_dynamic' % prop, None) setattr(self, '_Qt__%s_static' % prop, None) self.__version = version_eff Qt.__include_dir = path / include_subdir return raise Exception( 'no matching Qt ({}) in {}. Found versions: {}.'.format( pretty_listing(version, any=True), pretty_listing([p for p, _ in prefixes], quantifier=True), pretty_listing(miss)))
def __init__(self, cxx_toolkit = None, prefix = None, version = Version(), version_effective = None, prefer_shared = True): """Find and create a configuration for Boost. prefix -- Where to find Boost, should contain include/boost/version.hpp among others. /usr and /usr/local are searched by default. If relative, it is rooted in the source tree. version -- Requested version. prefer_shared -- Check dynamic libraries first. """ # Fix arguments cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit() self.__cxx_toolkit = cxx_toolkit self.__prefer_shared = prefer_shared # Compute the search path. if prefix is None: test = [path.dirname() for path in cxx_toolkit.include_path if path.basename() == 'include'] else: test = [Path(prefix)] for i in range(len(test)): if not test[i].absolute(): test[i] = drake.path_source() / test[i] token = drake.Path('boost/version.hpp') include_subdirs = {drake.Path('include')} for prefix in test: for subdir in include_subdirs: if not (prefix / subdir).exists(): continue include_subdirs = include_subdirs.union( (subdir / p for p in (prefix / subdir).list() if p.startswith('boost-'))) tokens = map(lambda p: p / token, include_subdirs) prefixes = self._search_many_all(list(tokens), test) miss = [] if version_effective is not None: assert prefix is not None # Try every search path for path, include_subdir in prefixes: include_subdir = include_subdir.without_suffix(token) # Create basic configuration for version checking. cfg = Config() cfg.add_system_include_path(path.without_prefix(drake.path_build()) / include_subdir) self.__lib_path = path / 'lib' cfg.lib_path(path.without_prefix(drake.path_build()) / 'lib') # Check the version. if version_effective is None: version_eff = cxx_toolkit.preprocess( '#include <boost/version.hpp>\nBOOST_VERSION', config = cfg) version_eff = int(version_eff.split('\n')[-2].strip()) version_eff = Version(version_eff // 100000, version_eff // 100 % 1000, version_eff % 100) else: version_eff = version_effective if version_eff not in version: miss.append(version_eff) continue # Fill configuration self.__prefix = path self.__cfg = cfg for prop in self.__libraries: setattr(self, '_Boost__config_%s_dynamic' % prop, None) setattr(self, '_Boost__config_%s_static' % prop, None) setattr(self, '_Boost__config_%s_dynamic_header' % prop, None) setattr(self, '_Boost__config_%s_static_header' % prop, None) setattr(self, '_Boost__%s_dynamic' % prop, None) setattr(self, '_Boost__%s_static' % prop, None) self.__version = version_eff return raise Exception('no matching boost for the requested version ' '(%s) in %s. Found versions: %s.' % \ (version, self._format_search([path for path, include_subdir in prefixes]), ', '.join(map(str, miss))))