diff --git a/cc/library.go b/cc/library.go index 65a923a5e..03f7174c6 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1264,14 +1264,6 @@ func (library *libraryDecorator) exportedIncludeDirsForAbiCheck(ctx ModuleContex func (library *libraryDecorator) llndkIncludeDirsForAbiCheck(ctx ModuleContext, deps PathDeps) []string { var includeDirs, systemIncludeDirs []string - // The ABI checker does not need the preprocess which adds macro guards to function declarations. - preprocessedDirs := android.PathsForModuleSrc(ctx, library.Properties.Llndk.Export_preprocessed_headers).Strings() - if Bool(library.Properties.Llndk.Export_headers_as_system) { - systemIncludeDirs = append(systemIncludeDirs, preprocessedDirs...) - } else { - includeDirs = append(includeDirs, preprocessedDirs...) - } - if library.Properties.Llndk.Override_export_include_dirs != nil { includeDirs = append(includeDirs, android.PathsForModuleSrc( ctx, library.Properties.Llndk.Override_export_include_dirs).Strings()...) @@ -1579,25 +1571,6 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, deps PathD } } -func processLLNDKHeaders(ctx ModuleContext, srcHeaderDir string, outDir android.ModuleGenPath) (timestamp android.Path, installPaths android.WritablePaths) { - srcDir := android.PathForModuleSrc(ctx, srcHeaderDir) - srcFiles := ctx.GlobFiles(filepath.Join(srcDir.String(), "**/*.h"), nil) - - for _, header := range srcFiles { - headerDir := filepath.Dir(header.String()) - relHeaderDir, err := filepath.Rel(srcDir.String(), headerDir) - if err != nil { - ctx.ModuleErrorf("filepath.Rel(%q, %q) failed: %s", - srcDir.String(), headerDir, err) - continue - } - - installPaths = append(installPaths, outDir.Join(ctx, relHeaderDir, header.Base())) - } - - return processHeadersWithVersioner(ctx, srcDir, outDir, srcFiles, installPaths), installPaths -} - // link registers actions to link this library, and sets various fields // on this library to reflect information that should be exported up the build // tree (for example, exported flags and include paths). @@ -1605,26 +1578,6 @@ func (library *libraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { if ctx.IsLlndk() { - if len(library.Properties.Llndk.Export_preprocessed_headers) > 0 { - // This is the vendor variant of an LLNDK library with preprocessed headers. - genHeaderOutDir := android.PathForModuleGen(ctx, "include") - - var timestampFiles android.Paths - for _, dir := range library.Properties.Llndk.Export_preprocessed_headers { - timestampFile, installPaths := processLLNDKHeaders(ctx, dir, genHeaderOutDir) - timestampFiles = append(timestampFiles, timestampFile) - library.addExportedGeneratedHeaders(installPaths.Paths()...) - } - - if Bool(library.Properties.Llndk.Export_headers_as_system) { - library.reexportSystemDirs(genHeaderOutDir) - } else { - library.reexportDirs(genHeaderOutDir) - } - - library.reexportDeps(timestampFiles...) - } - // override the module's export_include_dirs with llndk.override_export_include_dirs // if it is set. if override := library.Properties.Llndk.Override_export_include_dirs; override != nil { diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 5ece78a83..c7950f9ff 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -36,10 +36,6 @@ type llndkLibraryProperties struct { // bionic/libc. Export_headers_as_system *bool - // Which headers to process with versioner. This really only handles - // bionic/libc/include right now. - Export_preprocessed_headers []string - // Whether the system library uses symbol versions. Unversioned *bool diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go index e00293143..74819540b 100644 --- a/cc/ndk_headers.go +++ b/cc/ndk_headers.go @@ -23,15 +23,6 @@ import ( ) var ( - versionBionicHeaders = pctx.AndroidStaticRule("versionBionicHeaders", - blueprint.RuleParams{ - // The `&& touch $out` isn't really necessary, but Blueprint won't - // let us have only implicit outputs. - Command: "$versionerCmd -o $outDir $srcDir $depsPath && touch $out", - CommandDeps: []string{"$versionerCmd"}, - }, - "depsPath", "srcDir", "outDir") - preprocessNdkHeader = pctx.AndroidStaticRule("preprocessNdkHeader", blueprint.RuleParams{ Command: "$preprocessor -o $out $in", @@ -40,10 +31,6 @@ var ( "preprocessor") ) -func init() { - pctx.SourcePathVariable("versionerCmd", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/versioner") -} - // Returns the NDK base include path for use with sdk_version current. Usable with -I. func getCurrentIncludePath(ctx android.PathContext) android.OutputPath { return getNdkSysrootBase(ctx).Join(ctx, "usr/include") @@ -167,126 +154,6 @@ func NdkHeadersFactory() android.Module { return module } -type versionedHeaderProperties struct { - // Base directory of the headers being installed. As an example: - // - // versioned_ndk_headers { - // name: "foo", - // from: "include", - // to: "", - // } - // - // Will install $SYSROOT/usr/include/foo/bar/baz.h. If `from` were instead - // "include/foo", it would have installed $SYSROOT/usr/include/bar/baz.h. - From *string - - // Install path within the sysroot. This is relative to usr/include. - To *string - - // Path to the NOTICE file associated with the headers. - License *string -} - -// Like ndk_headers, but preprocesses the headers with the bionic versioner: -// https://android.googlesource.com/platform/bionic/+/main/tools/versioner/README.md. -// -// Unlike ndk_headers, we don't operate on a list of sources but rather a whole directory, the -// module does not have the srcs property, and operates on a full directory (the `from` property). -// -// Note that this is really only built to handle bionic/libc/include. -type versionedHeaderModule struct { - android.ModuleBase - - properties versionedHeaderProperties - - srcPaths android.Paths - installPaths android.Paths - licensePath android.Path -} - -// Return the glob pattern to find all .h files beneath `dir` -func headerGlobPattern(dir string) string { - return filepath.Join(dir, "**", "*.h") -} - -func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - if String(m.properties.License) == "" { - ctx.PropertyErrorf("license", "field is required") - } - - m.licensePath = android.PathForModuleSrc(ctx, String(m.properties.License)) - - fromSrcPath := android.PathForModuleSrc(ctx, String(m.properties.From)) - toOutputPath := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To)) - m.srcPaths = ctx.GlobFiles(headerGlobPattern(fromSrcPath.String()), nil) - var installPaths []android.WritablePath - for _, header := range m.srcPaths { - installDir := getHeaderInstallDir(ctx, header, String(m.properties.From), String(m.properties.To)) - installPath := installDir.Join(ctx, header.Base()) - installPaths = append(installPaths, installPath) - m.installPaths = append(m.installPaths, installPath) - } - - if len(m.installPaths) == 0 { - ctx.ModuleErrorf("glob %q matched zero files", String(m.properties.From)) - } - - processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, m.srcPaths, installPaths) -} - -func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path, - srcPaths android.Paths, installPaths []android.WritablePath) android.Path { - // The versioner depends on a dependencies directory to simplify determining include paths - // when parsing headers. This directory contains architecture specific directories as well - // as a common directory, each of which contains symlinks to the actually directories to - // be included. - // - // ctx.Glob doesn't follow symlinks, so we need to do this ourselves so we correctly - // depend on these headers. - // TODO(http://b/35673191): Update the versioner to use a --sysroot. - depsPath := android.PathForSource(ctx, "bionic/libc/versioner-dependencies") - depsGlob := ctx.Glob(filepath.Join(depsPath.String(), "**/*"), nil) - for i, path := range depsGlob { - if ctx.IsSymlink(path) { - dest := ctx.Readlink(path) - // Additional .. to account for the symlink itself. - depsGlob[i] = android.PathForSource( - ctx, filepath.Clean(filepath.Join(path.String(), "..", dest))) - } - } - - timestampFile := android.PathForModuleOut(ctx, "versioner.timestamp") - ctx.Build(pctx, android.BuildParams{ - Rule: versionBionicHeaders, - Description: "versioner preprocess " + srcDir.Rel(), - Output: timestampFile, - Implicits: append(srcPaths, depsGlob...), - ImplicitOutputs: installPaths, - Args: map[string]string{ - "depsPath": depsPath.String(), - "srcDir": srcDir.String(), - "outDir": outDir.String(), - }, - }) - - return timestampFile -} - -// versioned_ndk_headers preprocesses the headers with the bionic versioner: -// https://android.googlesource.com/platform/bionic/+/main/tools/versioner/README.md. -// Unlike the ndk_headers soong module, versioned_ndk_headers operates on a -// directory level specified in `from` property. This is only used to process -// the bionic/libc/include directory. -func VersionedNdkHeadersFactory() android.Module { - module := &versionedHeaderModule{} - - module.AddProperties(&module.properties) - - android.InitAndroidModule(module) - - return module -} - // preprocessed_ndk_header { // // name: "foo", diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go index f571523a0..92da17241 100644 --- a/cc/ndk_sysroot.go +++ b/cc/ndk_sysroot.go @@ -79,7 +79,6 @@ func init() { func RegisterNdkModuleTypes(ctx android.RegistrationContext) { ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory) ctx.RegisterModuleType("ndk_library", NdkLibraryFactory) - ctx.RegisterModuleType("versioned_ndk_headers", VersionedNdkHeadersFactory) ctx.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory) ctx.RegisterParallelSingletonType("ndk", NdkSingleton) } @@ -230,17 +229,6 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) { licensePaths = append(licensePaths, m.licensePath) } - if m, ok := module.(*versionedHeaderModule); ok { - headerSrcPaths = append(headerSrcPaths, m.srcPaths...) - headerInstallPaths = append(headerInstallPaths, m.installPaths...) - // Verification intentionally not done for headers that go through - // versioner. It'd be nice to have, but the only user is bionic, and - // that one module would also need to use skip_verification, so it - // wouldn't help at all. - installPaths = append(installPaths, m.installPaths...) - licensePaths = append(licensePaths, m.licensePath) - } - if m, ok := module.(*preprocessedHeadersModule); ok { headerSrcPaths = append(headerSrcPaths, m.srcPaths...) headerInstallPaths = append(headerInstallPaths, m.installPaths...)