def install_cc_source_library_atom(self, atom): name = sanitize(atom['name']) include_paths = [ os.path.relpath(h, atom['include_dir']) for h in atom['headers'] ] self.workspace_info.headers['//pkg/' + name] = include_paths if not self.install: return library = model.CppSourceLibrary(name) base = self.dest('pkg', name) self.copy_files(atom['headers'], atom['root'], base, library.hdrs) self.copy_files(atom['sources'], atom['root'], base, library.srcs) for dep in atom['deps']: library.deps.append('//pkg/' + sanitize(dep)) for dep in atom['fidl_deps']: dep_name = sanitize(dep) library.deps.append('//fidl/%s:%s_cc' % (dep_name, dep_name)) library.includes = os.path.relpath(atom['include_dir'], atom['root']) self.write_file(os.path.join(base, 'BUILD'), 'cc_library', library)
def install_cc_source_library_atom(self, atom): name = atom['name'] # Add atom to test targets self.cc_source_targets.append(name) base = self.dest('pkg', name) library = model.CppSourceLibrary(name) library.relative_path_to_root = os.path.relpath(self.output, start=base) self.copy_files(atom['headers'], atom['root'], base, library.hdrs) self.copy_files(atom['sources'], atom['root'], base, library.srcs) for dep in atom['deps']: library.deps.append('../' + dep) for dep in atom['fidl_deps']: dep_name = dep library.deps.append('../../fidl/' + dep_name) library.includes = os.path.relpath(atom['include_dir'], atom['root']) self.write_file(os.path.join(base, 'BUILD.gn'), 'cc_library', library) self.write_atom_metadata(os.path.join(base, 'meta.json'), atom) self.build_files.append( os.path.relpath(os.path.join(base, 'BUILD.gn'), self.output))
def install_cpp_source_atom(self, atom): '''Installs a source atom from the "cpp" domain.''' if self.is_overlay: return name = sanitize(atom.id.name) library = model.CppSourceLibrary(name) base = self.dest('pkg', name) for file in atom.files: dest = self.make_dir(os.path.join(base, file.destination)) shutil.copy2(file.source, dest) extension = os.path.splitext(file.destination)[1][1:] if extension == 'h': library.hdrs.append(file.destination) elif extension == 'c' or extension == 'cc' or extension == 'cpp': library.srcs.append(file.destination) else: raise Exception('Error: unknow file extension "%s" for %s.' % (extension, atom.id)) for dep_id in atom.deps: library.deps.append('//pkg/' + sanitize(dep_id.name)) library.includes.append('include') self.write_file(os.path.join(base, 'BUILD'), 'cc_library', library)