diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-02 20:20:28 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-02 20:20:28 +0000 |
commit | fb523bdee0fb8747261f58511b430095a31cca14 (patch) | |
tree | 892f133ef248328e0f47039ad871f8ccfda79384 | |
parent | 15da03d05eba905398e8e78171dcfb8b66ea109f (diff) | |
parent | a73c4021ecae9a972cfb7d67b2d9639af2fd75c9 (diff) | |
download | soong-build-tools-release.tar.gz |
Snap for 11794311 from a73c4021ecae9a972cfb7d67b2d9639af2fd75c9 to build-tools-releasebuild-tools-release
Change-Id: I485064d3026d0f75cd65f782224066893f13d403
-rw-r--r-- | PREUPLOAD.cfg | 1 | ||||
-rw-r--r-- | android/config.go | 4 | ||||
-rw-r--r-- | android/paths.go | 33 | ||||
-rw-r--r-- | android/selects_test.go | 112 | ||||
-rw-r--r-- | apex/apex_test.go | 23 | ||||
-rw-r--r-- | cc/cc.go | 1 | ||||
-rw-r--r-- | cc/linker.go | 2 | ||||
-rw-r--r-- | cc/llndk_library.go | 137 | ||||
-rw-r--r-- | cc/testing.go | 24 | ||||
-rw-r--r-- | cc/vndk.go | 29 | ||||
-rw-r--r-- | etc/prebuilt_etc.go | 36 | ||||
-rw-r--r-- | etc/prebuilt_etc_test.go | 42 | ||||
-rw-r--r-- | genrule/genrule.go | 7 | ||||
-rw-r--r-- | genrule/genrule_test.go | 149 | ||||
-rw-r--r-- | java/classpath_fragment.go | 10 | ||||
-rw-r--r-- | java/droidstubs.go | 41 | ||||
-rw-r--r-- | java/platform_bootclasspath.go | 1 | ||||
-rw-r--r-- | java/systemserver_classpath_fragment.go | 1 |
18 files changed, 563 insertions, 90 deletions
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg index 317f5c434..e8cad7d7b 100644 --- a/PREUPLOAD.cfg +++ b/PREUPLOAD.cfg @@ -4,3 +4,4 @@ bpfmt = true [Hook Scripts] do_not_use_DO_NOT_MERGE = ${REPO_ROOT}/build/soong/scripts/check_do_not_merge.sh ${PREUPLOAD_COMMIT} +aosp_hook = ${REPO_ROOT}/frameworks/base/tools/aosp/aosp_sha.sh ${PREUPLOAD_COMMIT} "." diff --git a/android/config.go b/android/config.go index 3ea9d4dfa..f6711e61f 100644 --- a/android/config.go +++ b/android/config.go @@ -818,12 +818,12 @@ func (c *config) GetenvWithDefault(key string, defaultValue string) string { } func (c *config) IsEnvTrue(key string) bool { - value := c.Getenv(key) + value := strings.ToLower(c.Getenv(key)) return value == "1" || value == "y" || value == "yes" || value == "on" || value == "true" } func (c *config) IsEnvFalse(key string) bool { - value := c.Getenv(key) + value := strings.ToLower(c.Getenv(key)) return value == "0" || value == "n" || value == "no" || value == "off" || value == "false" } diff --git a/android/paths.go b/android/paths.go index 2b33f67ce..39b660cce 100644 --- a/android/paths.go +++ b/android/paths.go @@ -277,6 +277,7 @@ type WritablePath interface { type genPathProvider interface { genPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleGenPath + genPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir, ext string, trimExt string) ModuleGenPath } type objPathProvider interface { objPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleObjPath @@ -295,6 +296,16 @@ func GenPathWithExt(ctx ModuleOutPathContext, subdir string, p Path, ext string) return PathForModuleGen(ctx) } +// GenPathWithExtAndTrimExt derives a new file path in ctx's generated sources directory +// from the current path, but with the new extension and trim the suffix. +func GenPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir string, p Path, ext string, trimExt string) ModuleGenPath { + if path, ok := p.(genPathProvider); ok { + return path.genPathWithExtAndTrimExt(ctx, subdir, ext, trimExt) + } + ReportPathErrorf(ctx, "Tried to create generated file from unsupported path: %s(%s)", reflect.TypeOf(p).Name(), p) + return PathForModuleGen(ctx) +} + // ObjPathWithExt derives a new file path in ctx's object directory from the // current path, but with the new extension. func ObjPathWithExt(ctx ModuleOutPathContext, subdir string, p Path, ext string) ModuleObjPath { @@ -1507,6 +1518,17 @@ func (p SourcePath) genPathWithExt(ctx ModuleOutPathContext, subdir, ext string) return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } +func (p SourcePath) genPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir, ext string, trimExt string) ModuleGenPath { + // If Trim_extension being set, force append Output_extension without replace original extension. + if trimExt != "" { + if ext != "" { + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)+"."+ext) + } + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)) + } + return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) +} + func (p SourcePath) objPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleObjPath { return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } @@ -1594,6 +1616,17 @@ func (p ModuleGenPath) genPathWithExt(ctx ModuleOutPathContext, subdir, ext stri return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } +func (p ModuleGenPath) genPathWithExtAndTrimExt(ctx ModuleOutPathContext, subdir, ext string, trimExt string) ModuleGenPath { + // If Trim_extension being set, force append Output_extension without replace original extension. + if trimExt != "" { + if ext != "" { + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)+"."+ext) + } + return PathForModuleGen(ctx, subdir, strings.TrimSuffix(p.path, trimExt)) + } + return PathForModuleGen(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) +} + func (p ModuleGenPath) objPathWithExt(ctx ModuleOutPathContext, subdir, ext string) ModuleObjPath { return PathForModuleObj(ctx, subdir, pathtools.ReplaceExtension(p.path, ext)) } diff --git a/android/selects_test.go b/android/selects_test.go index 856328543..d9499a500 100644 --- a/android/selects_test.go +++ b/android/selects_test.go @@ -633,6 +633,61 @@ func TestSelects(t *testing.T) { }, expectedError: "Expected all branches of a select on condition boolean_var_for_testing\\(\\) to have type bool, found string", }, + { + name: "Assigning select to nonconfigurable bool", + bp: ` + my_module_type { + name: "foo", + my_nonconfigurable_bool: select(arch(), { + "x86_64": true, + default: false, + }), + } + `, + expectedError: `can't assign select statement to non-configurable property "my_nonconfigurable_bool"`, + }, + { + name: "Assigning select to nonconfigurable string", + bp: ` + my_module_type { + name: "foo", + my_nonconfigurable_string: select(arch(), { + "x86_64": "x86!", + default: "unknown!", + }), + } + `, + expectedError: `can't assign select statement to non-configurable property "my_nonconfigurable_string"`, + }, + { + name: "Assigning appended selects to nonconfigurable string", + bp: ` + my_module_type { + name: "foo", + my_nonconfigurable_string: select(arch(), { + "x86_64": "x86!", + default: "unknown!", + }) + select(os(), { + "darwin": "_darwin!", + default: "unknown!", + }), + } + `, + expectedError: `can't assign select statement to non-configurable property "my_nonconfigurable_string"`, + }, + { + name: "Assigning select to nonconfigurable string list", + bp: ` + my_module_type { + name: "foo", + my_nonconfigurable_string_list: select(arch(), { + "x86_64": ["foo", "bar"], + default: ["baz", "qux"], + }), + } + `, + expectedError: `can't assign select statement to non-configurable property "my_nonconfigurable_string_list"`, + }, } for _, tc := range testCases { @@ -674,11 +729,14 @@ func TestSelects(t *testing.T) { } type selectsTestProvider struct { - my_bool *bool - my_string *string - my_string_list *[]string - my_paths *[]string - replacing_string_list *[]string + my_bool *bool + my_string *string + my_string_list *[]string + my_paths *[]string + replacing_string_list *[]string + my_nonconfigurable_bool *bool + my_nonconfigurable_string *string + my_nonconfigurable_string_list []string } func (p *selectsTestProvider) String() string { @@ -690,23 +748,42 @@ func (p *selectsTestProvider) String() string { if p.my_string != nil { myStringStr = *p.my_string } + myNonconfigurableStringStr := "nil" + if p.my_string != nil { + myNonconfigurableStringStr = *p.my_nonconfigurable_string + } return fmt.Sprintf(`selectsTestProvider { my_bool: %v, my_string: %s, my_string_list: %s, my_paths: %s, replacing_string_list %s, -}`, myBoolStr, myStringStr, p.my_string_list, p.my_paths, p.replacing_string_list) + my_nonconfigurable_bool: %v, + my_nonconfigurable_string: %s, + my_nonconfigurable_string_list: %s, +}`, + myBoolStr, + myStringStr, + p.my_string_list, + p.my_paths, + p.replacing_string_list, + p.my_nonconfigurable_bool, + myNonconfigurableStringStr, + p.my_nonconfigurable_string_list, + ) } var selectsTestProviderKey = blueprint.NewProvider[selectsTestProvider]() type selectsMockModuleProperties struct { - My_bool proptools.Configurable[bool] - My_string proptools.Configurable[string] - My_string_list proptools.Configurable[[]string] - My_paths proptools.Configurable[[]string] `android:"path"` - Replacing_string_list proptools.Configurable[[]string] `android:"replace_instead_of_append,arch_variant"` + My_bool proptools.Configurable[bool] + My_string proptools.Configurable[string] + My_string_list proptools.Configurable[[]string] + My_paths proptools.Configurable[[]string] `android:"path"` + Replacing_string_list proptools.Configurable[[]string] `android:"replace_instead_of_append,arch_variant"` + My_nonconfigurable_bool *bool + My_nonconfigurable_string *string + My_nonconfigurable_string_list []string } type selectsMockModule struct { @@ -717,11 +794,14 @@ type selectsMockModule struct { func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) { SetProvider(ctx, selectsTestProviderKey, selectsTestProvider{ - my_bool: p.properties.My_bool.Get(ctx), - my_string: p.properties.My_string.Get(ctx), - my_string_list: p.properties.My_string_list.Get(ctx), - my_paths: p.properties.My_paths.Get(ctx), - replacing_string_list: p.properties.Replacing_string_list.Get(ctx), + my_bool: p.properties.My_bool.Get(ctx), + my_string: p.properties.My_string.Get(ctx), + my_string_list: p.properties.My_string_list.Get(ctx), + my_paths: p.properties.My_paths.Get(ctx), + replacing_string_list: p.properties.Replacing_string_list.Get(ctx), + my_nonconfigurable_bool: p.properties.My_nonconfigurable_bool, + my_nonconfigurable_string: p.properties.My_nonconfigurable_string, + my_nonconfigurable_string_list: p.properties.My_nonconfigurable_string_list, }) } diff --git a/apex/apex_test.go b/apex/apex_test.go index 3e284b186..1be10483f 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -3671,34 +3671,13 @@ func ensureExactDeapexedContents(t *testing.T, ctx *android.TestContext, moduleN func vndkLibrariesTxtFiles(vers ...string) (result string) { for _, v := range vers { - if v == "current" { - for _, txt := range []string{"vndkcore", "vndksp", "vndkprivate", "vndkproduct"} { - result += ` - ` + txt + `_libraries_txt { - name: "` + txt + `.libraries.txt", - insert_vndk_version: true, - } - ` - } + for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} { result += ` - llndk_libraries_txt { - name: "llndk.libraries.txt", - } - llndk_libraries_txt_for_apex { - name: "llndk.libraries.txt.apex", - stem: "llndk.libraries.txt", - insert_vndk_version: true, - } - ` - } else { - for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} { - result += ` prebuilt_etc { name: "` + txt + `.libraries.` + v + `.txt", src: "dummy.txt", } ` - } } } return @@ -50,6 +50,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) { ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { ctx.BottomUp("sdk", sdkMutator).Parallel() ctx.BottomUp("vndk", VndkMutator).Parallel() + ctx.BottomUp("llndk", llndkMutator).Parallel() ctx.BottomUp("link", LinkageMutator).Parallel() ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel() ctx.BottomUp("version", versionMutator).Parallel() diff --git a/cc/linker.go b/cc/linker.go index 9686697c8..56a68b2ce 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -330,6 +330,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) deps.HeaderLibs = append(deps.HeaderLibs, linker.Properties.Target.Vendor.Header_libs...) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Vendor.Exclude_header_libs) + deps.ReexportHeaderLibHeaders = removeListFromList(deps.ReexportHeaderLibHeaders, linker.Properties.Target.Vendor.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Vendor.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Vendor.Exclude_static_libs) deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Vendor.Exclude_runtime_libs) @@ -342,6 +343,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Product.Static_libs...) deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Product.Exclude_static_libs) deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Product.Exclude_header_libs) + deps.ReexportHeaderLibHeaders = removeListFromList(deps.ReexportHeaderLibHeaders, linker.Properties.Target.Product.Exclude_header_libs) deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Product.Exclude_static_libs) deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Product.Exclude_static_libs) deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Product.Exclude_runtime_libs) diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 9e727a10b..ae9da9851 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -16,12 +16,12 @@ package cc import ( "android/soong/android" + "android/soong/etc" "strings" ) var ( llndkLibrarySuffix = ".llndk" - llndkHeadersSuffix = ".llndk" ) // Holds properties to describe a stub shared library based on the provided version file. @@ -78,3 +78,138 @@ func makeLlndkVars(ctx android.MakeVarsContext) { ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES", strings.Join(android.SortedKeys(movedToApexLlndkLibraries), " ")) } + +func init() { + RegisterLlndkLibraryTxtType(android.InitRegistrationContext) +} + +func RegisterLlndkLibraryTxtType(ctx android.RegistrationContext) { + ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory) +} + +type llndkLibrariesTxtModule struct { + android.SingletonModuleBase + + outputFile android.OutputPath + moduleNames []string + fileNames []string +} + +var _ etc.PrebuiltEtcModule = &llndkLibrariesTxtModule{} +var _ android.OutputFileProducer = &llndkLibrariesTxtModule{} + +// llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries +// generated by Soong but can be referenced by other modules. +// For example, apex_vndk can depend on these files as prebuilt. +// Make uses LLNDK_LIBRARIES to determine which libraries to install. +// HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN. +// Therefore, by removing the library here, we cause it to only be installed if libc +// depends on it. +func llndkLibrariesTxtFactory() android.SingletonModule { + m := &llndkLibrariesTxtModule{} + android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon) + return m +} + +func (txt *llndkLibrariesTxtModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { + filename := txt.Name() + + txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath + + installPath := android.PathForModuleInstall(ctx, "etc") + ctx.InstallFile(installPath, filename, txt.outputFile) +} + +func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.SingletonContext) { + ctx.VisitAllModules(func(m android.Module) { + if c, ok := m.(*Module); ok && c.VendorProperties.IsLLNDK && !c.Header() && !c.IsVndkPrebuiltLibrary() { + filename, err := getVndkFileName(c) + if err != nil { + ctx.ModuleErrorf(m, "%s", err) + } + + if !strings.HasPrefix(ctx.ModuleName(m), "libclang_rt.hwasan") { + txt.moduleNames = append(txt.moduleNames, ctx.ModuleName(m)) + } + txt.fileNames = append(txt.fileNames, filename) + } + }) + txt.moduleNames = android.SortedUniqueStrings(txt.moduleNames) + txt.fileNames = android.SortedUniqueStrings(txt.fileNames) + + android.WriteFileRule(ctx, txt.outputFile, strings.Join(txt.fileNames, "\n")) +} + +func (txt *llndkLibrariesTxtModule) AndroidMkEntries() []android.AndroidMkEntries { + return []android.AndroidMkEntries{{ + Class: "ETC", + OutputFile: android.OptionalPathForPath(txt.outputFile), + ExtraEntries: []android.AndroidMkExtraEntriesFunc{ + func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { + entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base()) + }, + }, + }} +} + +func (txt *llndkLibrariesTxtModule) MakeVars(ctx android.MakeVarsContext) { + ctx.Strict("LLNDK_LIBRARIES", strings.Join(txt.moduleNames, " ")) +} + +// PrebuiltEtcModule interface +func (txt *llndkLibrariesTxtModule) OutputFile() android.OutputPath { + return txt.outputFile +} + +// PrebuiltEtcModule interface +func (txt *llndkLibrariesTxtModule) BaseDir() string { + return "etc" +} + +// PrebuiltEtcModule interface +func (txt *llndkLibrariesTxtModule) SubDir() string { + return "" +} + +func (txt *llndkLibrariesTxtModule) OutputFiles(tag string) (android.Paths, error) { + return android.Paths{txt.outputFile}, nil +} + +func llndkMutator(mctx android.BottomUpMutatorContext) { + m, ok := mctx.Module().(*Module) + if !ok { + return + } + + if shouldSkipLlndkMutator(m) { + return + } + + lib, isLib := m.linker.(*libraryDecorator) + prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker) + + if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() { + m.VendorProperties.IsLLNDK = true + } + if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() { + m.VendorProperties.IsLLNDK = true + } + + if m.IsVndkPrebuiltLibrary() && !m.IsVndk() { + m.VendorProperties.IsLLNDK = true + } +} + +// Check for modules that mustn't be LLNDK +func shouldSkipLlndkMutator(m *Module) bool { + if !m.Enabled() { + return true + } + if !m.Device() { + return true + } + if m.Target().NativeBridge == android.NativeBridgeEnabled { + return true + } + return false +} diff --git a/cc/testing.go b/cc/testing.go index 20c435aca..4b4e866d4 100644 --- a/cc/testing.go +++ b/cc/testing.go @@ -554,6 +554,7 @@ var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers( ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) RegisterVndkLibraryTxtTypes(ctx) + RegisterLlndkLibraryTxtType(ctx) }), // Additional files needed in tests that disallow non-existent source files. @@ -570,17 +571,17 @@ var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers( // Additional files needed in tests that disallow non-existent source. android.MockFS{ - "defaults/cc/common/libc.map.txt": nil, - "defaults/cc/common/libdl.map.txt": nil, - "defaults/cc/common/libft2.map.txt": nil, - "defaults/cc/common/libm.map.txt": nil, - "defaults/cc/common/ndk_libc++_shared": nil, - "defaults/cc/common/crtbegin_so.c": nil, - "defaults/cc/common/crtbegin.c": nil, - "defaults/cc/common/crtend_so.c": nil, - "defaults/cc/common/crtend.c": nil, - "defaults/cc/common/crtbrand.c": nil, - "external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil, + "defaults/cc/common/libc.map.txt": nil, + "defaults/cc/common/libdl.map.txt": nil, + "defaults/cc/common/libft2.map.txt": nil, + "defaults/cc/common/libm.map.txt": nil, + "defaults/cc/common/ndk_libc++_shared": nil, + "defaults/cc/common/crtbegin_so.c": nil, + "defaults/cc/common/crtbegin.c": nil, + "defaults/cc/common/crtend_so.c": nil, + "defaults/cc/common/crtend.c": nil, + "defaults/cc/common/crtbrand.c": nil, + "external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil, "defaults/cc/common/libclang_rt.ubsan_minimal.android_arm64.a": nil, "defaults/cc/common/libclang_rt.ubsan_minimal.android_arm.a": nil, @@ -702,6 +703,7 @@ func CreateTestContext(config android.Config) *android.TestContext { ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory) RegisterVndkLibraryTxtTypes(ctx) + RegisterLlndkLibraryTxtType(ctx) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) android.RegisterPrebuiltMutators(ctx) diff --git a/cc/vndk.go b/cc/vndk.go index 14b44b643..50e6d4b96 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -219,7 +219,6 @@ func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error { type moduleListerFunc func(ctx android.SingletonContext) (moduleNames, fileNames []string) var ( - llndkLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsLLNDK && !m.Header() }) vndkSPLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKSP }) vndkCoreLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKCore }) vndkPrivateLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKPrivate }) @@ -378,19 +377,12 @@ func VndkMutator(mctx android.BottomUpMutatorContext) { prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker) if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() { - m.VendorProperties.IsLLNDK = true m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private) } if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() { - m.VendorProperties.IsLLNDK = true m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private) } - if m.IsVndkPrebuiltLibrary() && !m.IsVndk() { - m.VendorProperties.IsLLNDK = true - // TODO(b/280697209): copy "llndk.private" flag to vndk_prebuilt_shared - } - if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) { if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() { processVndkLibrary(mctx, m) @@ -404,8 +396,6 @@ func init() { } func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) { - ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory) - ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt_for_apex", llndkLibrariesTxtApexOnlyFactory) ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory) ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory) ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory) @@ -435,25 +425,6 @@ type VndkLibrariesTxtProperties struct { var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{} var _ android.OutputFileProducer = &vndkLibrariesTxt{} -// llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries -// generated by Soong. -// Make uses LLNDK_LIBRARIES to determine which libraries to install. -// HWASAN is only part of the LLNDK in builds in which libc depends on HWASAN. -// Therefore, by removing the library here, we cause it to only be installed if libc -// depends on it. -func llndkLibrariesTxtFactory() android.SingletonModule { - return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan") -} - -// llndk_libraries_txt_for_apex is a singleton module that provide the same LLNDK libraries list -// with the llndk_libraries_txt, but skips setting make variable LLNDK_LIBRARIES. So, it must not -// be used without installing llndk_libraries_txt singleton. -// We include llndk_libraries_txt by default to install the llndk.libraries.txt file to system/etc. -// This singleton module is to install the llndk.libraries.<ver>.txt file to vndk apex. -func llndkLibrariesTxtApexOnlyFactory() android.SingletonModule { - return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "", "libclang_rt.hwasan") -} - // vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries // generated by Soong but can be referenced by other modules. // For example, apex_vndk can depend on these files as prebuilt. diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index d1c1d853e..025ba27aa 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -55,6 +55,9 @@ func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("prebuilt_usr_share", PrebuiltUserShareFactory) ctx.RegisterModuleType("prebuilt_usr_share_host", PrebuiltUserShareHostFactory) ctx.RegisterModuleType("prebuilt_usr_hyphendata", PrebuiltUserHyphenDataFactory) + ctx.RegisterModuleType("prebuilt_usr_keylayout", PrebuiltUserKeyLayoutFactory) + ctx.RegisterModuleType("prebuilt_usr_keychars", PrebuiltUserKeyCharsFactory) + ctx.RegisterModuleType("prebuilt_usr_idc", PrebuiltUserIdcFactory) ctx.RegisterModuleType("prebuilt_font", PrebuiltFontFactory) ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory) ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory) @@ -609,6 +612,39 @@ func PrebuiltUserHyphenDataFactory() android.Module { return module } +// prebuilt_usr_keylayout is for a prebuilt artifact that is installed in +// <partition>/usr/keylayout/<sub_dir> directory. +func PrebuiltUserKeyLayoutFactory() android.Module { + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "usr/keylayout") + // This module is device-only + android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) + android.InitDefaultableModule(module) + return module +} + +// prebuilt_usr_keychars is for a prebuilt artifact that is installed in +// <partition>/usr/keychars/<sub_dir> directory. +func PrebuiltUserKeyCharsFactory() android.Module { + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "usr/keychars") + // This module is device-only + android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) + android.InitDefaultableModule(module) + return module +} + +// prebuilt_usr_idc is for a prebuilt artifact that is installed in +// <partition>/usr/idc/<sub_dir> directory. +func PrebuiltUserIdcFactory() android.Module { + module := &PrebuiltEtc{} + InitPrebuiltEtcModule(module, "usr/idc") + // This module is device-only + android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst) + android.InitDefaultableModule(module) + return module +} + // prebuilt_font installs a font in <partition>/fonts directory. func PrebuiltFontFactory() android.Module { module := &PrebuiltEtc{} diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go index dd9958caf..3ee234069 100644 --- a/etc/prebuilt_etc_test.go +++ b/etc/prebuilt_etc_test.go @@ -287,6 +287,48 @@ func TestPrebuiltPrebuiltUserHyphenDataInstallDirPath(t *testing.T) { android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) } +func TestPrebuiltPrebuiltUserKeyLayoutInstallDirPath(t *testing.T) { + result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` + prebuilt_usr_keylayout { + name: "foo.conf", + src: "foo.conf", + sub_dir: "bar", + } + `) + + p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) + expected := "out/soong/target/product/test_device/system/usr/keylayout/bar" + android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) +} + +func TestPrebuiltPrebuiltUserKeyCharsInstallDirPath(t *testing.T) { + result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` + prebuilt_usr_keychars { + name: "foo.conf", + src: "foo.conf", + sub_dir: "bar", + } + `) + + p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) + expected := "out/soong/target/product/test_device/system/usr/keychars/bar" + android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) +} + +func TestPrebuiltPrebuiltUserIdcInstallDirPath(t *testing.T) { + result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` + prebuilt_usr_idc { + name: "foo.conf", + src: "foo.conf", + sub_dir: "bar", + } + `) + + p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc) + expected := "out/soong/target/product/test_device/system/usr/idc/bar" + android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath) +} + func TestPrebuiltFontInstallDirPath(t *testing.T) { result := prepareForPrebuiltEtcTest.RunTestWithBp(t, ` prebuilt_font { diff --git a/genrule/genrule.go b/genrule/genrule.go index 43f4fe5ee..4ff82e6a6 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -714,13 +714,13 @@ func NewGenSrcs() *Module { rule := getSandboxedRuleBuilder(ctx, android.NewRuleBuilder(pctx, ctx).Sbox(genDir, nil)) for _, in := range shard { - outFile := android.GenPathWithExt(ctx, finalSubDir, in, String(properties.Output_extension)) + outFile := android.GenPathWithExtAndTrimExt(ctx, finalSubDir, in, String(properties.Output_extension), String(properties.Trim_extension)) // If sharding is enabled, then outFile is the path to the output file in // the shard directory, and copyTo is the path to the output file in the // final directory. if len(shards) > 1 { - shardFile := android.GenPathWithExt(ctx, genSubDir, in, String(properties.Output_extension)) + shardFile := android.GenPathWithExtAndTrimExt(ctx, genSubDir, in, String(properties.Output_extension), String(properties.Trim_extension)) copyTo = append(copyTo, outFile) outFile = shardFile } @@ -786,6 +786,9 @@ type genSrcsProperties struct { // Additional files needed for build that are not tooling related. Data []string `android:"path"` + + // Trim the matched extension for each input file, and it should start with ".". + Trim_extension *string } const defaultShardSize = 50 diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go index 2dc6a7954..1df887b3e 100644 --- a/genrule/genrule_test.go +++ b/genrule/genrule_test.go @@ -894,6 +894,155 @@ func TestGenSrcsWithSrcsFromExternalPackage(t *testing.T) { ) } +func TestGenSrcsWithTrimExtAndOutpuExtension(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "external-protos/path/Android.bp": []byte(` + filegroup { + name: "external-protos", + srcs: [ + "baz.a.b.c.proto/baz.a.b.c.proto", + "bar.a.b.c.proto", + "qux.ext.a.b.c.proto", + ], + } + `), + "package-dir/Android.bp": []byte(` + gensrcs { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.a.b.c.proto", + ":external-protos", + ], + + trim_extension: ".a.b.c.proto", + output_extension: "proto.h", + } + `), + }), + ).RunTest(t) + + exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs" + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + []string{exportedIncludeDir}, + gen.exportedIncludeDirs, + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + exportedIncludeDir + "/package-dir/src/foo.proto.h", + exportedIncludeDir + "/external-protos/path/baz.a.b.c.proto/baz.proto.h", + exportedIncludeDir + "/external-protos/path/bar.proto.h", + exportedIncludeDir + "/external-protos/path/qux.ext.proto.h", + }, + gen.outputFiles, + ) +} + +func TestGenSrcsWithTrimExtButNoOutpuExtension(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "external-protos/path/Android.bp": []byte(` + filegroup { + name: "external-protos", + srcs: [ + "baz.a.b.c.proto/baz.a.b.c.proto", + "bar.a.b.c.proto", + "qux.ext.a.b.c.proto", + ], + } + `), + "package-dir/Android.bp": []byte(` + gensrcs { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.a.b.c.proto", + ":external-protos", + ], + + trim_extension: ".a.b.c.proto", + } + `), + }), + ).RunTest(t) + + exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs" + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + []string{exportedIncludeDir}, + gen.exportedIncludeDirs, + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + exportedIncludeDir + "/package-dir/src/foo", + exportedIncludeDir + "/external-protos/path/baz.a.b.c.proto/baz", + exportedIncludeDir + "/external-protos/path/bar", + exportedIncludeDir + "/external-protos/path/qux.ext", + }, + gen.outputFiles, + ) +} + +func TestGenSrcsWithOutpuExtension(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForGenRuleTest, + android.FixtureMergeMockFs(android.MockFS{ + "external-protos/path/Android.bp": []byte(` + filegroup { + name: "external-protos", + srcs: ["baz/baz.a.b.c.proto", "bar.a.b.c.proto"], + } + `), + "package-dir/Android.bp": []byte(` + gensrcs { + name: "module-name", + cmd: "mkdir -p $(genDir) && cat $(in) >> $(genDir)/$(out)", + srcs: [ + "src/foo.a.b.c.proto", + ":external-protos", + ], + + output_extension: "proto.h", + } + `), + }), + ).RunTest(t) + + exportedIncludeDir := "out/soong/.intermediates/package-dir/module-name/gen/gensrcs" + gen := result.Module("module-name", "").(*Module) + + android.AssertPathsRelativeToTopEquals( + t, + "include path", + []string{exportedIncludeDir}, + gen.exportedIncludeDirs, + ) + android.AssertPathsRelativeToTopEquals( + t, + "files", + []string{ + exportedIncludeDir + "/package-dir/src/foo.a.b.c.proto.h", + exportedIncludeDir + "/external-protos/path/baz/baz.a.b.c.proto.h", + exportedIncludeDir + "/external-protos/path/bar.a.b.c.proto.h", + }, + gen.outputFiles, + ) +} + func TestPrebuiltTool(t *testing.T) { testcases := []struct { name string diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 0ebab4d8c..07bc5c163 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -151,10 +151,14 @@ func configuredJarListToClasspathJars(ctx android.ModuleContext, configuredJars return jars } +func (c *ClasspathFragmentBase) outputFilename() string { + return strings.ToLower(c.classpathType.String()) + ".pb" +} + func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.ModuleContext, configuredJars android.ConfiguredJarList, jars []classpathJar) { generateProto := proptools.BoolDefault(c.properties.Generate_classpaths_proto, true) if generateProto { - outputFilename := strings.ToLower(c.classpathType.String()) + ".pb" + outputFilename := c.outputFilename() c.outputFilepath = android.PathForModuleOut(ctx, outputFilename).OutputPath c.installDirPath = android.PathForModuleInstall(ctx, "etc", "classpaths") @@ -181,6 +185,10 @@ func (c *ClasspathFragmentBase) generateClasspathProtoBuildActions(ctx android.M android.SetProvider(ctx, ClasspathFragmentProtoContentInfoProvider, classpathProtoInfo) } +func (c *ClasspathFragmentBase) installClasspathProto(ctx android.ModuleContext) android.InstallPath { + return ctx.InstallFile(c.installDirPath, c.outputFilename(), c.outputFilepath) +} + func writeClasspathsTextproto(ctx android.ModuleContext, output android.WritablePath, jars []classpathJar) { var content strings.Builder diff --git a/java/droidstubs.go b/java/droidstubs.go index 08caf9109..24caf6f37 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -604,6 +604,11 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } } +// AndroidPlusUpdatableJar is the name of some extra jars added into `module-lib` and +// `system-server` directories that contain all the APIs provided by the platform and updatable +// modules because the `android.jar` files do not. See b/337836752. +const AndroidPlusUpdatableJar = "android-plus-updatable.jar" + func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) { if len(d.properties.Api_levels_annotations_dirs) == 0 { ctx.PropertyErrorf("api_levels_annotations_dirs", @@ -648,16 +653,24 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an // Grab the first extensions_dir and we find while scanning ExportedDroiddocDir.deps; // ideally this should be read from prebuiltApis.properties.Extensions_* for _, dep := range t.deps { + // Check to see if it matches an extension first. + depBase := dep.Base() if extRegex.MatchString(dep.String()) && d.properties.Extensions_info_file != nil { if extensions_dir == "" { extensions_dir = t.dir.String() + "/extensions" } cmd.Implicit(dep) - } - if dep.Base() == filename { + } else if depBase == filename { + // Check to see if it matches a dessert release for an SDK, e.g. Android, Car, Wear, etc.. cmd.Implicit(dep) - } - if filename != "android.jar" && dep.Base() == "android.jar" { + } else if depBase == AndroidPlusUpdatableJar && d.properties.Extensions_info_file != nil { + // The output api-versions.xml has been requested to include information on SDK + // extensions. That means it also needs to include + // so + // The module-lib and system-server directories should use `android-plus-updatable.jar` + // instead of `android.jar`. See AndroidPlusUpdatableJar for more information. + cmd.Implicit(dep) + } else if filename != "android.jar" && depBase == "android.jar" { // Metalava implicitly searches these patterns: // prebuilts/tools/common/api-versions/android-%/android.jar // prebuilts/sdk/%/public/android.jar @@ -675,9 +688,25 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an } }) + // Generate the list of --android-jar-pattern options. The order matters so the first one which + // matches will be the one that is used for a specific api level.. for _, sdkDir := range sdkDirs { for _, dir := range dirs { - cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, filename)) + addPattern := func(jarFilename string) { + cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, jarFilename)) + } + + if sdkDir == "module-lib" || sdkDir == "system-server" { + // The module-lib and system-server android.jars do not include the updatable modules (as + // doing so in the source would introduce dependency cycles and the prebuilts have to + // match the sources). So, instead an additional `android-plus-updatable.jar` will be used + // that does include the updatable modules and this pattern will match that. This pattern + // is added in addition to the following pattern to decouple this change from the change + // to add the `android-plus-updatable.jar`. + addPattern(AndroidPlusUpdatableJar) + } + + addPattern(filename) } } @@ -1327,7 +1356,7 @@ func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) { // use a strict naming convention var ( droidstubsModuleNamingToSdkKind = map[string]android.SdkKind{ - //public is commented out since the core libraries use public in their java_sdk_library names + // public is commented out since the core libraries use public in their java_sdk_library names "intracore": android.SdkIntraCore, "intra.core": android.SdkIntraCore, "system_server": android.SdkSystemServer, diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 4db426e0d..b3c9ce50f 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -221,6 +221,7 @@ func (b *platformBootclasspathModule) generateClasspathProtoBuildActions(ctx and // ART and platform boot jars must have a corresponding entry in DEX2OATBOOTCLASSPATH classpathJars := configuredJarListToClasspathJars(ctx, configuredJars, BOOTCLASSPATH, DEX2OATBOOTCLASSPATH) b.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) + b.classpathFragmentBase().installClasspathProto(ctx) } func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index b291e708b..bad2cf1cf 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -69,6 +69,7 @@ func (p *platformSystemServerClasspathModule) GenerateAndroidBuildActions(ctx an configuredJars = configuredJars.AppendList(&standaloneConfiguredJars) classpathJars = append(classpathJars, standaloneClasspathJars...) p.classpathFragmentBase().generateClasspathProtoBuildActions(ctx, configuredJars, classpathJars) + p.classpathFragmentBase().installClasspathProto(ctx) } func (p *platformSystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { |