def compile(self, src:fbuild.db.SRC, dst=None, *, flags=[], **kwargs) -> fbuild.db.DST: """Compile a c file and cache the results.""" # Generate the dependencies while we compile the file. with tempfile() as dep: obj = self.uncached_compile(src, dst, flags=list(chain(('-MMD', '-MF', dep), flags)), **kwargs) with open(dep, 'rb') as f: # Parse the output and return the module dependencies. stdout = f.read().replace(b'\\\n', b'') # Parse the output and return the module dependencies. m = re.match(b'\s*\S+:(?: (.*))?$', stdout) if not m: raise fbuild.ExecutionError('unable to understand %r' % stdout) s = m.group(1) if s is not None: deps = s.decode().split() self.ctx.db.add_external_dependencies_to_call(srcs=deps) return obj
def compile(self, src: fbuild.db.SRC, dst=None, *, flags=[], **kwargs) -> fbuild.db.DST: """Compile a c file and cache the results.""" # Generate the dependencies while we compile the file. with tempfile() as dep: obj = self.uncached_compile(src, dst, flags=list( chain(('-MMD', '-MF', dep), flags)), **kwargs) with open(dep, 'rb') as f: # Parse the output and return the module dependencies. stdout = f.read().replace(b'\\\n', b'') # Parse the output and return the module dependencies. m = re.match(b'\s*\S+:(?: (.*))?$', stdout) if not m: raise fbuild.ExecutionError('unable to understand %r' % stdout) s = m.group(1) if s is not None: deps = s.decode().split() self.ctx.db.add_external_dependencies_to_call(srcs=deps) return obj
def check_flags(self, flags): if flags: self.ctx.logger.check('checking %s with %s' % (self, ' '.join(flags))) else: self.ctx.logger.check('checking %s' % self) code = 'int main(int argc, char** argv){return 0;}' with tempfile(code, suffix=self.src_suffix) as src: try: self([src], flags=flags, quieter=1, cwd=src.parent) except fbuild.ExecutionError: self.ctx.logger.failed() return False self.ctx.logger.passed() return True
def check_flags(self, flags): if flags: self.ctx.logger.check('checking %s with %s' % (self, ' '.join(flags))) else: self.ctx.logger.check('checking %s' % self) code = 'int main(int argc, char** argv){return 0;}' with tempfile(code, suffix='.c') as src: try: self([src], flags=flags, quieter=1, cwd=src.parent) except fbuild.ExecutionError: self.ctx.logger.failed() return False self.ctx.logger.passed() return True
def check_flags(self, flags=[]): if flags: self.ctx.logger.check("checking %s with %s" % (self, " ".join(flags))) else: self.ctx.logger.check("checking %s" % self) with tempfile("", suffix=".flx") as src: try: self(src, flags=flags, quieter=1) except fbuild.ExecutionError as e: self.ctx.logger.failed() if e.stdout: self.ctx.logger.log(e.stdout.decode()) if e.stderr: self.ctx.logger.log(e.stderr.decode()) return False self.ctx.logger.passed() return True
def check_flags(self, flags=[]): if flags: self.ctx.logger.check('checking %s with %s' % (self, ' '.join(flags))) else: self.ctx.logger.check('checking %s' % self) with tempfile('', suffix='.flx') as src: try: self(src, flags=flags, quieter=1) except fbuild.ExecutionError as e: self.ctx.logger.failed() if e.stdout: self.ctx.logger.log(e.stdout.decode()) if e.stderr: self.ctx.logger.log(e.stderr.decode()) return False self.ctx.logger.passed() return True
def check_flags(self, flags=[]): if flags: self.ctx.logger.check('checking %s with %s' % (self, ' '.join(flags))) else: self.ctx.logger.check('checking %s' % self) with tempfile('', suffix='.flx') as src: try: self(src, flags=flags, quieter=1, timeout=120) except fbuild.ExecutionError as e: self.ctx.logger.failed() if e.stdout: self.ctx.logger.log(e.stdout.decode()) if e.stderr: self.ctx.logger.log(e.stderr.decode()) return False self.ctx.logger.passed() return True
def check_flags(self, flags=[]): """Verify that we can run with these flags.""" if flags: self.ctx.logger.check('checking %s with %s' % (self, ' '.join(flags))) else: self.ctx.logger.check('checking %s' % self) with tempfile('', suffix=self.src_suffix) as src: try: self._run([src], flags=flags, quieter=1) except fbuild.ExecutionError as e: self.ctx.logger.failed() if e.stdout: self.ctx.logger.log(e.stdout.decode()) if e.stderr: self.ctx.logger.log(e.stderr.decode()) return False self.ctx.logger.passed() return True