def __init__(self, proto, protoc=None, plugin=None, toolkit=None): name = proto.name_relative.without_last_extension() dsts = drake.nodes(name.with_extension('pb.go'), ) srcs = [] if plugin is None: if toolkit is not None: if toolkit.os == 'windows': plugin = drake.node('%s/bin/%s/protoc-gen-go.exe' % (toolkit.path, toolkit.platform_str())) else: plugin = drake.node('%s/bin/protoc-gen-go' % toolkit.path) if not plugin.builder: drake.go.FetchPackage( url='github.com/golang/protobuf/protoc-gen-go', toolkit=toolkit, targets=[ plugin, ], ) elif os.environ.get('GOPATH'): plugin = drake.node('%s/bin/protoc-gen-go' % os.environ['GOPATH']) elif os.environ.get('GOROOT'): plugin = drake.node('%s/bin/protoc-gen-go' % os.environ['GOROOT']) self.__toolkit = toolkit super().__init__(proto, protoc=protoc, plugin=plugin, targets=dsts)
def deps_handler(builder, path_obj, t, data): if isinstance(builder, (drake.cxx.Linker, drake.cxx.DynLibLinker)): with logger.log( 'drake.cxx.qt', drake.log.LogLevel.debug, '%s: retrieve linkage to MOC %s', builder, path_obj): if path_obj in drake.Drake.current.nodes: return drake.node(path_obj) path_src = drake.Path(path_obj).with_extension('moc.cc') src = drake.node(path_src) path_header = drake.Path(path_obj).with_extension('hh') header = drake.node(path_header) Moc(builder.toolkit.qt, header, src) obj = drake.cxx.Object(src, builder.toolkit, builder.config) return obj elif isinstance(builder, drake.cxx.Compiler): with logger.log( 'drake.cxx.qt', drake.log.LogLevel.debug, '%s: retrieve reference to MOC %s', builder, path_obj): source = drake.node(drake.Path(path_obj).with_extension('moc.hh')) qt = builder.toolkit.qt res = qt._Qt__moc_cache.get(source) if res is None: res = moc_file(qt, builder, source) if res is not None: qt._Qt__dependencies.setdefault(builder.object, []).append(res) logger.log( 'drake.cxx.qt', drake.log.LogLevel.debug, '%s: reference MOC %s', builder, res) else: raise Exception('unexpected Moc dependency for %s' % builder)
def deps_handler(builder, path_obj, t, data): if isinstance(builder, (drake.cxx.Linker, drake.cxx.DynLibLinker)): with logger.log('drake.cxx.qt', drake.log.LogLevel.debug, '%s: retrieve linkage to MOC %s', builder, path_obj): if path_obj in drake.Drake.current.nodes: return drake.node(path_obj) path_src = drake.Path(path_obj).with_extension('moc.cc') src = drake.node(path_src) path_header = drake.Path(path_obj).with_extension('hh') header = drake.node(path_header) Moc(builder.toolkit.qt, header, src) obj = drake.cxx.Object(src, builder.toolkit, builder.config) return obj elif isinstance(builder, drake.cxx.Compiler): with logger.log('drake.cxx.qt', drake.log.LogLevel.debug, '%s: retrieve reference to MOC %s', builder, path_obj): source = drake.node(drake.Path(path_obj).with_extension('moc.hh')) qt = builder.toolkit.qt res = qt._Qt__moc_cache.get(source) if res is None: res = moc_file(qt, builder, source) if res is not None: qt._Qt__dependencies.setdefault(builder.object, []).append(res) logger.log('drake.cxx.qt', drake.log.LogLevel.debug, '%s: reference MOC %s', builder, res) else: raise Exception('unexpected Moc dependency for %s' % builder)
def __init__(self, proto, protoc = None, plugin = None, toolkit = None): name = proto.name_relative.without_last_extension() dsts = drake.nodes( name.with_extension('pb.go'), ) srcs = [] if plugin is None: if toolkit is not None: if toolkit.os == 'windows': plugin = drake.node('%s/bin/%s/protoc-gen-go.exe' % ( toolkit.path, toolkit.platform_str())) else: plugin = drake.node('%s/bin/protoc-gen-go' % toolkit.path) if not plugin.builder: drake.go.FetchPackage( url = 'github.com/golang/protobuf/protoc-gen-go', toolkit = toolkit, targets = [ plugin, ], ) elif os.environ.get('GOPATH'): plugin = drake.node('%s/bin/protoc-gen-go' % os.environ['GOPATH']) elif os.environ.get('GOROOT'): plugin = drake.node('%s/bin/protoc-gen-go' % os.environ['GOROOT']) self.__toolkit = toolkit super().__init__(proto, protoc = protoc, plugin = plugin, targets = dsts)
def __init__(self, source, toolkit = None, config = None, target = None, sources = [], build_host = False): self.__library = drake.node( target or '%s%s' % (source.name().without_last_extension(), toolkit.staticlib_ext(build_host))) self.__header = drake.node('%s.h' % target.split('.')[0]) super().__init__( node = source, toolkit = toolkit, config = config, target = self.__library, dependencies = sources, lib_type = 'c-archive', header = self.__header, build_host = build_host)
def __init__(self, version, base_url=None, platform="linux", dest=drake.Path("GLFW"), expected_headers=None): super().__init__("GLFW") self.__base_url = base_url or "https://github.com/glfw/glfw/releases/download" self.__version = version self.__platform = "linux" self.__zip = drake.node(dest / "{version}.zip".format(version=self.__version)) self.__path = dest / "glfw-{version}".format(version=self.__version) self.__include_path = self.__path / "include" self.__library_path = self.__path / "src" self.__cmake_lists = drake.Node(self.__path / "CMakeLists.txt") self.__makefile = drake.Node(self.__path / "Makefile") drake.HTTPDownload(url=self.url, dest=self.__zip) drake.Extractor(tarball=self.__zip, targets=[str(self.__cmake_lists.name_absolute())[5:] ]).targets() drake.ShellCommand(sources=[self.__cmake_lists], targets=self.headers + [self.__makefile], command=['cmake', '.'], cwd=self.__path) drake.ShellCommand(sources=[self.__makefile], targets=self.libraries, command=['make', 'glfw'], cwd=self.__path)
def __init__(self, package, destination, targets=[]): self.__package = package self.__destination = destination self.__expected = list( map(lambda t: drake.node(destination / t), targets)) super().__init__([package], self.__expected)
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, basename, version, dist, arch, top_dir, sources, destination = '.'): if '-' in version: raise Exception('RPM cannot have "-" in version') self.__top_dir = drake.Path(os.getcwd()) / top_dir self.__spec = top_dir / 'SPECS' / ('%s.spec' % basename) self.__arch = arch self.__dist = dist self.__rpm_name = '%(base)s-%(ver)s-1.%(dist)s.%(arch)s.rpm' % \ {'base': basename, 'ver': version, 'dist': dist, 'arch': self.__arch} self.__destination = drake.Path(destination) self.__target = drake.node('%s/%s' % (destination, self.__rpm_name)) all_sources = list() for s in sources: all_sources.append(s) if isinstance(s, drake.cxx.Executable): for d in s.dependencies_recursive: all_sources.append(d) super().__init__(all_sources, [self.__target])
def __init__(self, exe, args = None, env = None, valgrind = None, valgrind_args = None): super().__init__(exe, args = args, env = env) self.__valgrind = Valgrind(valgrind) self.__valgrind_status = drake.node( '%s.valgrind' % self.executable.name_relative) self.__valgrind_status.builder = self self.valgrind_reporting = drake.Runner.Reporting.on_failure self.__valgrind_args = valgrind_args or []
def __init__(self, proto, protoc = None, plugin = None): name = proto.name_relative.without_last_extension() dsts = drake.nodes( '{}_pb2.py'.format(name), '{}_pb2_grpc.py'.format(name), ) if plugin is None: plugin = drake.node('/usr/local/bin/grpc_python_plugin') super().__init__(proto, protoc = protoc, plugin = plugin, targets = dsts)
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 __init__(self, proto, protoc=None, plugin=None): name = proto.name_relative.without_last_extension() dsts = drake.nodes( '{}_pb2.py'.format(name), '{}_pb2_grpc.py'.format(name), ) if plugin is None: plugin = drake.node('/usr/local/bin/grpc_python_plugin') super().__init__(proto, protoc=protoc, plugin=plugin, targets=dsts)
def _set_local_libcxx(tgt): if cxx_toolkit.os in [drake.os.macos]: with drake.WritePermissions(drake.node(tgt)): return drake.command([ 'install_name_tool', '-change', '/usr/lib/libc++.1.dylib', '@rpath/libc++.1.dylib', str(drake.path_build(tgt, True)) ]) else: return True
def __init__(self, basename, sources, path, destination = '.', preload = None): self.__destination = drake.Path(destination) basename = drake.Path(basename) self.__target = drake.node(self.__destination / basename) self.__destination = drake.path_build(self.__destination) self.__path = drake.path_build(path) self.__preload = preload if preload is not None: sources += [preload] super().__init__(sources, [self.__target])
def __init__(self, proto, protoc, targets, plugin=None): self.__proto = proto if protoc is None: self.__protoc = drake.node(drake.which.which('protoc')) self.__protoc = protoc self.__plugin = plugin self.__output = proto.name().dirname() srcs = [proto, protoc] if plugin: srcs.append(plugin) super().__init__(srcs, targets)
def __init__(self, proto, protoc=None, plugin=None): name = proto.name_relative dsts = drake.nodes( name.with_extension('pb.h'), name.with_extension('pb.cc'), name.with_extension('grpc.pb.h'), name.with_extension('grpc.pb.cc'), ) if plugin is None: plugin = drake.node('/usr/local/bin/grpc_cpp_plugin') super().__init__(proto, protoc=protoc, plugin=plugin, targets=dsts)
def __init__(self, proto, protoc, targets, plugin = None): self.__proto = proto if protoc is None: self.__protoc = drake.node(drake.which.which('protoc')) self.__protoc = protoc self.__plugin = plugin self.__output = proto.name().dirname() srcs = [proto, protoc] if plugin: srcs.append(plugin) super().__init__(srcs, targets)
def __init__(self, proto, protoc = None, plugin = None): name = proto.name_relative dsts = drake.nodes( name.with_extension('pb.h'), name.with_extension('pb.cc'), name.with_extension('grpc.pb.h'), name.with_extension('grpc.pb.cc'), ) if plugin is None: plugin = drake.node('/usr/local/bin/grpc_cpp_plugin') super().__init__(proto, protoc = protoc, plugin = plugin, targets = dsts)
def __init__(self, script, target = None, resources = []): self.__script = script resources = resources or self.__script.resources target = target or script.name().with_extension('exe') self.__target = drake.node(target) super().__init__(self.__script, self.__target, additional_sources = resources)
def __init__(self, basename, attributes, sources, path, destination='.', preload=None, cleanup_source_directory=True): path = drake.Path(path) self.__destination = drake.Path(destination) basename = drake.Path(basename) self.__target = drake.node(self.__destination / basename) self.__destination = drake.path_build(self.__destination) self.__path = drake.path_build(path) self.__preload = preload self.__attrs = attributes self.__control = drake.node(path / 'DEBIAN/control') if preload is not None: sources += [preload] self.__cleanup_source_directory = cleanup_source_directory super().__init__(sources, [self.__control, self.__target])
def __init__(self, source, target_extension, imagemagick=ImageMagick()): """Create a ConvertBuilder. source -- The source node. target_extension -- File extension to convert to. """ path = drake.Path(source.name()) path.extension = target_extension self.__imagemagick = imagemagick self.__source = source self.__target = drake.node(path) drake.Builder.__init__(self, [self.__source], [self.__target])
def moc_file(qt, linker, source): for i in linker.config.system_include_path: if source.name_relative.dirname() == i: return None path = drake.Path(source.name()).with_extension('moc.cc') src = drake.node(path) if src.builder is None: Moc(linker.toolkit.qt, source, src) res = drake.cxx.Object(src, linker.toolkit, linker.config) qt._Qt__moc_cache[source] = res qt._Qt__moc_files.add(res) return res
def __init__(self, basename, attributes, sources, path, destination = '.', preload = None, cleanup_source_directory = True): path = drake.Path(path) self.__destination = drake.Path(destination) basename = drake.Path(basename) self.__target = drake.node(self.__destination / basename) self.__destination = drake.path_build(self.__destination) self.__path = drake.path_build(path) self.__preload = preload self.__attrs = attributes self.__control = drake.node(path / 'DEBIAN/control') if preload is not None: sources += [preload] self.__cleanup_source_directory = cleanup_source_directory super().__init__( sources, [self.__control, self.__target])
def __init__(self, source, target_extension, imagemagick = ImageMagick()): """Create a ConvertBuilder. source -- The source node. target_extension -- File extension to convert to. """ path = drake.Path(source.name()) path.extension = target_extension self.__imagemagick = imagemagick self.__source = source self.__target = drake.node(path) drake.Builder.__init__(self, [self.__source] , [self.__target])
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, input_libs, output_lib, headers=[], input_headers=None, output_headers=None): drake.Builder.__init__( self, input_libs, itertools.chain([output_lib], (drake.node(output_headers / p) for p in headers))) self.__input_libs = input_libs self.__output_lib = output_lib self.__headers = headers if input_headers: self.__input_headers = drake.path_build(input_headers) else: self.__input_headers = None if output_headers: self.__output_headers = drake.path_build(output_headers) else: self.__output_headers = None
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 package_target(url, toolkit, build_host = False): return drake.node('%s/pkg/%s/%s.a' % (toolkit.package_path, toolkit.platform_str(build_host), url))