def CompileCC(self, source_ppath): """Compiles a C++ source file into an object file. Args: source_ppath: .cc file project path. """ source_apath = self.GetSourceAbsolutePath(source_ppath) object_ppath = misc.SwitchSuffix(source_ppath, '.cc', '.o') object_apath = os.path.join(self._output_dir, object_ppath) source_ppaths = set([source_ppath]) source_ppaths.update(self.GetCCIncludesClosure(source_ppath)) target_ppaths = [object_ppath] if self.IsUpToDate(source_ppaths, target_ppaths): logging.info('%s -> %s is up to date', source_ppath, object_ppath) return misc.MakeDirectoriesFor(object_apath) command = (self.vars.CXX_COMPILER_COMMAND + self.vars.CXX_FLAGS + [ '-I' + self._source_dir, '-I' + self._output_dir, '-c', source_apath, '-o', object_apath, ]) logging.info('Compiling C++: %s', source_ppath) self.Exec(command) self.RecordMetadata(source_ppaths, target_ppaths)
def DeclareProtoLibrary(self, name, sources=tuple(), dependencies=tuple()): """Declares a protocol-buffer definition node.""" proto_compile_nodes = map(self.DeclareProtoCompile, sources) dependencies = set(dependencies) dependencies.update([n.name for n in proto_compile_nodes]) cc_sources = [ misc.SwitchSuffix(source, 'proto', 'pb.cc') for source in sources ] self.DeclareLibrary(name=name, sources=cc_sources, dependencies=dependencies)
def DeclareProtoCompile(self, source): name = misc.SwitchSuffix(source, 'proto', 'pb.cc') proto_node = ProtoNode(graph=self, name=name, source=source) self._DeclareNode(proto_node) return proto_node
def _DeclareObjects(self, sources, dependencies): for source in sources: object_name = misc.SwitchSuffix(source, 'cc', 'o') yield self.DeclareObject(name=object_name, source=source, dependencies=dependencies)