def get_arch_srcs(prebuilt, arch): """Returns build rule for arch specific srcs. e.g., arch: { arm: { srcs: ["..."] }, arm64: { srcs: ["..."] }, } Args: prebuilt: string, name of prebuilt object arch: string, VNDK snapshot arch (e.g. 'arm64') """ arch_srcs = '{ind}arch: {{\n'.format(ind=self.INDENT) src_paths = utils.find(src_root, [prebuilt]) # filter out paths under 'binder32' subdirectory src_paths = filter(lambda src: not src.startswith(utils.BINDER32), src_paths) for src in sorted(src_paths): arch_srcs += ('{ind}{ind}{arch}: {{\n' '{ind}{ind}{ind}srcs: ["{src}"],\n' '{ind}{ind}}},\n'.format( ind=self.INDENT, arch=utils.prebuilt_arch_from_path( os.path.join(arch, src)), src=src)) arch_srcs += '{ind}}},\n'.format(ind=self.INDENT) return arch_srcs
def get_arch_props(prebuilt, arch): """Returns build rule for arch specific srcs. e.g., arch: { arm: { export_include_dirs: ["..."], export_system_include_dirs: ["..."], export_flags: ["..."], relative_install_path: "...", srcs: ["..."] }, arm64: { export_include_dirs: ["..."], export_system_include_dirs: ["..."], export_flags: ["..."], relative_install_path: "...", srcs: ["..."] }, } Args: prebuilt: string, name of prebuilt object arch: string, VNDK snapshot arch (e.g. 'arm64') """ arch_props = '{ind}arch: {{\n'.format(ind=self.INDENT) src_paths = utils.find(src_root, [prebuilt]) # filter out paths under 'binder32' subdirectory src_paths = filter(lambda src: not src.startswith(utils.BINDER32), src_paths) def list_to_prop_value(l, name): if len(l) == 0: return '' dirs = ',\n{ind}{ind}{ind}{ind}'.format(ind=self.INDENT).join( ['"%s"' % d for d in l]) return ('{ind}{ind}{ind}{name}: [\n' '{ind}{ind}{ind}{ind}{dirs},\n' '{ind}{ind}{ind}],\n'.format(ind=self.INDENT, dirs=dirs, name=name)) for src in sorted(src_paths): include_dirs = '' system_include_dirs = '' flags = '' relative_install_path = '' prop_path = os.path.join(src_root, src + '.json') props = dict() try: with open(prop_path, 'r') as f: props = json.loads(f.read()) os.unlink(prop_path) except: # TODO(b/70312118): Parse from soong build system if prebuilt == '*****@*****.**': props['RelativeInstallPath'] = 'hw' if 'ExportedDirs' in props: l = ['include/%s' % d for d in props['ExportedDirs']] include_dirs = list_to_prop_value(l, 'export_include_dirs') if 'ExportedSystemDirs' in props: l = ['include/%s' % d for d in props['ExportedSystemDirs']] system_include_dirs = list_to_prop_value( l, 'export_system_include_dirs') if 'ExportedFlags' in props: flags = list_to_prop_value(props['ExportedFlags'], 'export_flags') if 'RelativeInstallPath' in props: relative_install_path = ( '{ind}{ind}{ind}' 'relative_install_path: "{path}",\n').format( ind=self.INDENT, path=props['RelativeInstallPath']) arch_props += ('{ind}{ind}{arch}: {{\n' '{include_dirs}' '{system_include_dirs}' '{flags}' '{relative_install_path}' '{ind}{ind}{ind}srcs: ["{src}"],\n' '{ind}{ind}}},\n').format( ind=self.INDENT, arch=utils.prebuilt_arch_from_path( os.path.join(arch, src)), include_dirs=include_dirs, system_include_dirs=system_include_dirs, flags=flags, relative_install_path=relative_install_path, src=src) arch_props += '{ind}}},\n'.format(ind=self.INDENT) return arch_props