Merge "Sandbox inputs to aidl rule in cc"
diff --git a/android/Android.bp b/android/Android.bp
index 118087d..94d2c04 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -77,6 +77,7 @@
"path_properties.go",
"paths.go",
"phony.go",
+ "plugin.go",
"prebuilt.go",
"prebuilt_build_tool.go",
"proto.go",
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 9700f8b..751a4cb 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -223,6 +223,7 @@
"frameworks/base/tools/streaming_proto": Bp2BuildDefaultTrueRecursively,
"frameworks/hardware/interfaces/stats/aidl": Bp2BuildDefaultTrue,
"frameworks/libs/modules-utils/build": Bp2BuildDefaultTrueRecursively,
+ "frameworks/libs/net/common/native": Bp2BuildDefaultTrueRecursively,
"frameworks/native/libs/adbd_auth": Bp2BuildDefaultTrueRecursively,
"frameworks/native/libs/arect": Bp2BuildDefaultTrueRecursively,
"frameworks/native/libs/gui": Bp2BuildDefaultTrue,
@@ -1565,10 +1566,10 @@
// also be built - do not add them to this list.
StagingMixedBuildsEnabledList = []string{
// M13: media.swcodec launch
- // TODO(b/282042844): reenable
- // "com.android.media.swcodec",
- // "test_com.android.media.swcodec",
- // "libstagefright_foundation",
+ "com.android.media.swcodec",
+ "test_com.android.media.swcodec",
+ "libstagefright_foundation",
+ "libcodec2_hidl@1.0",
}
// These should be the libs that are included by the apexes in the ProdMixedBuildsEnabledList
diff --git a/android/androidmk.go b/android/androidmk.go
index aa411d1..62f82f2 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -42,7 +42,7 @@
}
func RegisterAndroidMkBuildComponents(ctx RegistrationContext) {
- ctx.RegisterSingletonType("androidmk", AndroidMkSingleton)
+ ctx.RegisterParallelSingletonType("androidmk", AndroidMkSingleton)
}
// Enable androidmk support.
diff --git a/android/api_levels.go b/android/api_levels.go
index fa919fd..2391e6c 100644
--- a/android/api_levels.go
+++ b/android/api_levels.go
@@ -22,7 +22,7 @@
)
func init() {
- RegisterSingletonType("api_levels", ApiLevelsSingleton)
+ RegisterParallelSingletonType("api_levels", ApiLevelsSingleton)
}
const previewAPILevelBase = 9000
diff --git a/android/bazel.go b/android/bazel.go
index 114b1f5..d326634 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -46,6 +46,10 @@
// that is not a platform incompatibility. Example: the module-type is not
// enabled, or is not bp2build-converted.
ModuleIncompatibility
+
+ // Missing dependencies. We can't query Bazel for modules if it has missing dependencies, there
+ // will be failures.
+ ModuleMissingDeps
)
// FileGroupAsLibrary describes a filegroup module that is converted to some library
@@ -367,16 +371,26 @@
// As a side effect, calling this method will also log whether this module is
// mixed build enabled for metrics reporting.
func MixedBuildsEnabled(ctx BaseModuleContext) MixedBuildEnabledStatus {
- module := ctx.Module()
- apexInfo := ctx.Provider(ApexInfoProvider).(ApexInfo)
- withinApex := !apexInfo.IsForPlatform()
-
platformIncompatible := isPlatformIncompatible(ctx.Os(), ctx.Arch().ArchType)
if platformIncompatible {
ctx.Config().LogMixedBuild(ctx, false)
return TechnicalIncompatibility
}
+ if ctx.Config().AllowMissingDependencies() {
+ missingDeps := ctx.getMissingDependencies()
+ // If there are missing dependencies, querying Bazel will fail. Soong instead fails at execution
+ // time, not loading/analysis. disable mixed builds and fall back to Soong to maintain that
+ // behavior.
+ if len(missingDeps) > 0 {
+ ctx.Config().LogMixedBuild(ctx, false)
+ return ModuleMissingDeps
+ }
+ }
+
+ module := ctx.Module()
+ apexInfo := ctx.Provider(ApexInfoProvider).(ApexInfo)
+ withinApex := !apexInfo.IsForPlatform()
mixedBuildEnabled := ctx.Config().IsMixedBuildsEnabled() &&
module.Enabled() &&
convertedToBazel(ctx, module) &&
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 10cf60a..47dd161 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -74,14 +74,12 @@
}
)
-func init() {
- RegisterMixedBuildsMutator(InitRegistrationContext)
+func registerMixedBuildsMutator(ctx RegisterMutatorsContext) {
+ ctx.BottomUp("mixed_builds_prep", mixedBuildsPrepareMutator).Parallel()
}
func RegisterMixedBuildsMutator(ctx RegistrationContext) {
- ctx.FinalDepsMutators(func(ctx RegisterMutatorsContext) {
- ctx.BottomUp("mixed_builds_prep", mixedBuildsPrepareMutator).Parallel()
- })
+ ctx.FinalDepsMutators(registerMixedBuildsMutator)
}
func mixedBuildsPrepareMutator(ctx BottomUpMutatorContext) {
@@ -183,10 +181,6 @@
// Returns the results of GetOutputFiles and GetCcObjectFiles in a single query (in that order).
GetCcInfo(label string, cfgKey configKey) (cquery.CcInfo, error)
- // Returns the executable binary resultant from building together the python sources
- // TODO(b/232976601): Remove.
- GetPythonBinary(label string, cfgKey configKey) (string, error)
-
// Returns the results of the GetApexInfo query (including output files)
GetApexInfo(label string, cfgkey configKey) (cquery.ApexInfo, error)
@@ -315,14 +309,6 @@
return result, nil
}
-func (m MockBazelContext) GetPythonBinary(label string, _ configKey) (string, error) {
- result, ok := m.LabelToPythonBinary[label]
- if !ok {
- return "", fmt.Errorf("no target with label %q in LabelToPythonBinary", label)
- }
- return result, nil
-}
-
func (m MockBazelContext) GetApexInfo(label string, _ configKey) (cquery.ApexInfo, error) {
result, ok := m.LabelToApexInfo[label]
if !ok {
@@ -431,15 +417,6 @@
return cquery.CcInfo{}, fmt.Errorf("no bazel response found for %v", key)
}
-func (bazelCtx *mixedBuildBazelContext) GetPythonBinary(label string, cfgKey configKey) (string, error) {
- key := makeCqueryKey(label, cquery.GetPythonBinary, cfgKey)
- if rawString, ok := bazelCtx.results[key]; ok {
- bazelOutput := strings.TrimSpace(rawString)
- return cquery.GetPythonBinary.ParseResult(bazelOutput), nil
- }
- return "", fmt.Errorf("no bazel response found for %v", key)
-}
-
func (bazelCtx *mixedBuildBazelContext) GetApexInfo(label string, cfgKey configKey) (cquery.ApexInfo, error) {
key := makeCqueryKey(label, cquery.GetApexInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
@@ -468,10 +445,6 @@
panic("unimplemented")
}
-func (n noopBazelContext) GetPythonBinary(_ string, _ configKey) (string, error) {
- panic("unimplemented")
-}
-
func (n noopBazelContext) GetApexInfo(_ string, _ configKey) (cquery.ApexInfo, error) {
panic("unimplemented")
}
@@ -505,7 +478,7 @@
return []bazel.AqueryDepset{}
}
-func addToStringSet(set map[string]bool, items []string) {
+func AddToStringSet(set map[string]bool, items []string) {
for _, item := range items {
set[item] = true
}
@@ -517,19 +490,19 @@
switch buildMode {
case BazelProdMode:
- addToStringSet(enabledModules, allowlists.ProdMixedBuildsEnabledList)
+ AddToStringSet(enabledModules, allowlists.ProdMixedBuildsEnabledList)
for enabledAdHocModule := range forceEnabled {
enabledModules[enabledAdHocModule] = true
}
case BazelStagingMode:
// Staging mode includes all prod modules plus all staging modules.
- addToStringSet(enabledModules, allowlists.ProdMixedBuildsEnabledList)
- addToStringSet(enabledModules, allowlists.StagingMixedBuildsEnabledList)
+ AddToStringSet(enabledModules, allowlists.ProdMixedBuildsEnabledList)
+ AddToStringSet(enabledModules, allowlists.StagingMixedBuildsEnabledList)
for enabledAdHocModule := range forceEnabled {
enabledModules[enabledAdHocModule] = true
}
case BazelDevMode:
- addToStringSet(disabledModules, allowlists.MixedBuildsDisabledList)
+ AddToStringSet(disabledModules, allowlists.MixedBuildsDisabledList)
default:
panic("Expected BazelProdMode, BazelStagingMode, or BazelDevMode")
}
@@ -609,7 +582,7 @@
allowlists.StagingDclaMixedBuildsEnabledList...)
}
dclaEnabledModules := map[string]bool{}
- addToStringSet(dclaEnabledModules, dclaMixedBuildsEnabledList)
+ AddToStringSet(dclaEnabledModules, dclaMixedBuildsEnabledList)
return &mixedBuildBazelContext{
bazelRunner: &builtinBazelRunner{c.UseBazelProxy, absolutePath(c.outDir)},
paths: &paths,
diff --git a/android/bazel_test.go b/android/bazel_test.go
index 77e2515..13fd408 100644
--- a/android/bazel_test.go
+++ b/android/bazel_test.go
@@ -436,3 +436,150 @@
}
}
}
+
+type mixedBuildModule struct {
+ ModuleBase
+ BazelModuleBase
+ props struct {
+ Deps []string
+ Mixed_build_incompatible *bool
+ QueuedBazelCall bool `blueprint:"mutated"`
+ }
+}
+
+type mixedBuildModuleInfo struct {
+ QueuedBazelCall bool
+}
+
+var mixedBuildModuleProvider = blueprint.NewProvider(mixedBuildModuleInfo{})
+
+func mixedBuildModuleFactory() Module {
+ m := &mixedBuildModule{}
+ m.AddProperties(&m.props)
+ InitAndroidArchModule(m, HostAndDeviceDefault, MultilibBoth)
+ InitBazelModule(m)
+
+ return m
+}
+
+func (m *mixedBuildModule) ConvertWithBp2build(ctx TopDownMutatorContext) {
+}
+
+func (m *mixedBuildModule) DepsMutator(ctx BottomUpMutatorContext) {
+ ctx.AddDependency(ctx.Module(), installDepTag{}, m.props.Deps...)
+}
+
+func (m *mixedBuildModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+}
+
+func (m *mixedBuildModule) IsMixedBuildSupported(ctx BaseModuleContext) bool {
+ return !proptools.Bool(m.props.Mixed_build_incompatible)
+}
+
+func (m *mixedBuildModule) QueueBazelCall(ctx BaseModuleContext) {
+ m.props.QueuedBazelCall = true
+}
+
+func (m *mixedBuildModule) ProcessBazelQueryResponse(ctx ModuleContext) {
+ ctx.SetProvider(mixedBuildModuleProvider, mixedBuildModuleInfo{
+ QueuedBazelCall: m.props.QueuedBazelCall,
+ })
+}
+
+var prepareForMixedBuildTests = FixtureRegisterWithContext(func(ctx RegistrationContext) {
+ ctx.RegisterModuleType("deps", mixedBuildModuleFactory)
+ RegisterMixedBuildsMutator(ctx)
+})
+
+func TestMixedBuildsEnabledForType(t *testing.T) {
+ baseBp := `
+ deps {
+ name: "foo",
+ deps: ["bar"],
+ target: { windows: { enabled: true } },
+ %s
+ }
+`
+ depBp := `
+ deps {
+ name: "bar",
+ target: {
+ windows: {
+ enabled: true,
+ },
+ },
+ }
+`
+ testCases := []struct {
+ desc string
+ variant *string
+ missingDeps bool
+ extraBpInfo string
+ mixedBuildsEnabled bool
+ }{
+ {
+ desc: "mixed builds works",
+ mixedBuildsEnabled: true,
+ extraBpInfo: `bazel_module: { bp2build_available: true },`,
+ },
+ {
+ desc: "missing deps",
+ missingDeps: true,
+ mixedBuildsEnabled: false,
+ extraBpInfo: `bazel_module: { bp2build_available: true },`,
+ },
+ {
+ desc: "windows no mixed builds",
+ mixedBuildsEnabled: false,
+ variant: proptools.StringPtr("windows_x86"),
+ extraBpInfo: `bazel_module: { bp2build_available: true },`,
+ },
+ {
+ desc: "mixed builds disabled by type",
+ mixedBuildsEnabled: false,
+ extraBpInfo: `mixed_build_incompatible: true,
+ bazel_module: { bp2build_available: true },`,
+ },
+ {
+ desc: "mixed builds not bp2build available",
+ mixedBuildsEnabled: false,
+ extraBpInfo: `bazel_module: { bp2build_available: false },`,
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.desc, func(t *testing.T) {
+ handlers := GroupFixturePreparers(
+ prepareForMixedBuildTests,
+ PrepareForTestWithArchMutator,
+ FixtureModifyConfig(func(config Config) {
+ config.BazelContext = MockBazelContext{
+ OutputBaseDir: "base",
+ }
+ config.Targets[Windows] = []Target{
+ {Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", true},
+ {Windows, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", true},
+ }
+ }),
+ )
+ bp := fmt.Sprintf(baseBp, tc.extraBpInfo)
+ if tc.missingDeps {
+ handlers = GroupFixturePreparers(
+ handlers,
+ PrepareForTestWithAllowMissingDependencies,
+ )
+ } else {
+ bp += depBp
+ }
+ result := handlers.RunTestWithBp(t, bp)
+
+ variant := proptools.StringDefault(tc.variant, "android_arm64_armv8-a")
+
+ m := result.ModuleForTests("foo", variant)
+ mixedBuildModuleInfo := result.TestContext.ModuleProvider(m.Module(), mixedBuildModuleProvider).(mixedBuildModuleInfo)
+ if w, g := tc.mixedBuildsEnabled, mixedBuildModuleInfo.QueuedBazelCall; w != g {
+ t.Errorf("Expected mixed builds enabled %t, got mixed builds enabled %t", w, g)
+ }
+ })
+ }
+}
diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go
index 46f6488..8e19ad5 100644
--- a/android/buildinfo_prop.go
+++ b/android/buildinfo_prop.go
@@ -23,7 +23,7 @@
func init() {
ctx := InitRegistrationContext
- ctx.RegisterSingletonModuleType("buildinfo_prop", buildinfoPropFactory)
+ ctx.RegisterParallelSingletonModuleType("buildinfo_prop", buildinfoPropFactory)
}
type buildinfoPropProperties struct {
diff --git a/android/config.go b/android/config.go
index 4ed107d..d148012 100644
--- a/android/config.go
+++ b/android/config.go
@@ -302,6 +302,9 @@
// modules that aren't mixed-built for at least one variant will cause a build
// failure
ensureAllowlistIntegrity bool
+
+ // List of Api libraries that contribute to Api surfaces.
+ apiLibraries map[string]struct{}
}
type deviceConfig struct {
@@ -622,6 +625,33 @@
config.BazelContext, err = NewBazelContext(config)
config.Bp2buildPackageConfig = GetBp2BuildAllowList()
+ // TODO(b/276958307): Replace the hardcoded list to a sdk_library local prop.
+ config.apiLibraries = map[string]struct{}{
+ "android.net.ipsec.ike": {},
+ "art.module.public.api": {},
+ "conscrypt.module.public.api": {},
+ "framework-adservices": {},
+ "framework-appsearch": {},
+ "framework-bluetooth": {},
+ "framework-connectivity": {},
+ "framework-connectivity-t": {},
+ "framework-graphics": {},
+ "framework-media": {},
+ "framework-mediaprovider": {},
+ "framework-ondevicepersonalization": {},
+ "framework-permission": {},
+ "framework-permission-s": {},
+ "framework-scheduling": {},
+ "framework-sdkextensions": {},
+ "framework-statsd": {},
+ "framework-sdksandbox": {},
+ "framework-tethering": {},
+ "framework-uwb": {},
+ "framework-virtualization": {},
+ "framework-wifi": {},
+ "i18n.module.public.api": {},
+ }
+
return Config{config}, err
}
@@ -1858,6 +1888,10 @@
return uncheckedFinalApiLevel(apiLevel)
}
+func (c *deviceConfig) BuildBrokenPluginValidation() []string {
+ return c.config.productVariables.BuildBrokenPluginValidation
+}
+
func (c *deviceConfig) BuildBrokenClangAsFlags() bool {
return c.config.productVariables.BuildBrokenClangAsFlags
}
@@ -1894,8 +1928,8 @@
return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
}
-func (c *deviceConfig) BuildBrokenDepfile() bool {
- return Bool(c.config.productVariables.BuildBrokenDepfile)
+func (c *deviceConfig) GenruleSandboxing() bool {
+ return Bool(c.config.productVariables.GenruleSandboxing)
}
func (c *deviceConfig) RequiresInsecureExecmemForSwiftshader() bool {
@@ -1987,8 +2021,20 @@
func (c *config) SetBuildFromTextStub(b bool) {
c.buildFromTextStub = b
}
+
func (c *config) AddForceEnabledModules(forceEnabled []string) {
for _, forceEnabledModule := range forceEnabled {
c.bazelForceEnabledModules[forceEnabledModule] = struct{}{}
}
}
+
+func (c *config) SetApiLibraries(libs []string) {
+ c.apiLibraries = make(map[string]struct{})
+ for _, lib := range libs {
+ c.apiLibraries[lib] = struct{}{}
+ }
+}
+
+func (c *config) GetApiLibraries() map[string]struct{} {
+ return c.apiLibraries
+}
diff --git a/android/gen_notice.go b/android/gen_notice.go
index 091345b..1acc638 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -28,7 +28,7 @@
// Register the gen_notice module type.
func RegisterGenNoticeBuildComponents(ctx RegistrationContext) {
- ctx.RegisterSingletonType("gen_notice_build_rules", GenNoticeBuildRulesFactory)
+ ctx.RegisterParallelSingletonType("gen_notice_build_rules", GenNoticeBuildRulesFactory)
ctx.RegisterModuleType("gen_notice", GenNoticeFactory)
}
diff --git a/android/metrics.go b/android/metrics.go
index 3d41a1d..63c72cd 100644
--- a/android/metrics.go
+++ b/android/metrics.go
@@ -42,7 +42,7 @@
}
func init() {
- RegisterSingletonType("soong_metrics", soongMetricsSingletonFactory)
+ RegisterParallelSingletonType("soong_metrics", soongMetricsSingletonFactory)
}
func soongMetricsSingletonFactory() Singleton { return soongMetricsSingleton{} }
diff --git a/android/module.go b/android/module.go
index db602a0..604ba24 100644
--- a/android/module.go
+++ b/android/module.go
@@ -354,6 +354,10 @@
AddMissingDependencies(missingDeps []string)
+ // getMissingDependencies returns the list of missing dependencies.
+ // Calling this function prevents adding new dependencies.
+ getMissingDependencies() []string
+
// AddUnconvertedBp2buildDep stores module name of a direct dependency that was not converted via bp2build
AddUnconvertedBp2buildDep(dep string)
@@ -939,7 +943,8 @@
NamespaceExportedToMake bool `blueprint:"mutated"`
- MissingDeps []string `blueprint:"mutated"`
+ MissingDeps []string `blueprint:"mutated"`
+ CheckedMissingDeps bool `blueprint:"mutated"`
// Name and variant strings stored by mutators to enable Module.String()
DebugName string `blueprint:"mutated"`
@@ -2862,6 +2867,20 @@
}
}
+func (b *baseModuleContext) checkedMissingDeps() bool {
+ return b.Module().base().commonProperties.CheckedMissingDeps
+}
+
+func (b *baseModuleContext) getMissingDependencies() []string {
+ checked := &b.Module().base().commonProperties.CheckedMissingDeps
+ *checked = true
+ var missingDeps []string
+ missingDeps = append(missingDeps, b.Module().base().commonProperties.MissingDeps...)
+ missingDeps = append(missingDeps, b.bp.EarlyGetMissingDependencies()...)
+ missingDeps = FirstUniqueStrings(missingDeps)
+ return missingDeps
+}
+
type AllowDisabledModuleDependency interface {
blueprint.DependencyTag
AllowDisabledModuleDependency(target Module) bool
@@ -3724,7 +3743,7 @@
}
func init() {
- RegisterSingletonType("buildtarget", BuildTargetSingleton)
+ RegisterParallelSingletonType("buildtarget", BuildTargetSingleton)
}
func BuildTargetSingleton() Singleton {
diff --git a/android/mutator.go b/android/mutator.go
index 0a091eb..4185315 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -67,6 +67,8 @@
// collateGloballyRegisteredMutators constructs the list of mutators that have been registered
// with the InitRegistrationContext and will be used at runtime.
func collateGloballyRegisteredMutators() sortableComponents {
+ // ensure mixed builds mutator is the last mutator
+ finalDeps = append(finalDeps, registerMixedBuildsMutator)
return collateRegisteredMutators(preArch, preDeps, postDeps, finalDeps)
}
@@ -885,10 +887,16 @@
}
func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
return b.bp.AddDependency(module, tag, name...)
}
func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
b.bp.AddReverseDependency(module, tag, name)
}
@@ -938,11 +946,17 @@
func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
names ...string) []blueprint.Module {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
return b.bp.AddVariationDependencies(variations, tag, names...)
}
func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
tag blueprint.DependencyTag, names ...string) []blueprint.Module {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
return b.bp.AddFarVariationDependencies(variations, tag, names...)
}
@@ -952,10 +966,16 @@
}
func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
b.bp.ReplaceDependencies(name)
}
func (b *bottomUpMutatorContext) ReplaceDependenciesIf(name string, predicate blueprint.ReplaceDependencyPredicate) {
+ if b.baseModuleContext.checkedMissingDeps() {
+ panic("Adding deps not allowed after checking for missing deps")
+ }
b.bp.ReplaceDependenciesIf(name, predicate)
}
diff --git a/android/plugin.go b/android/plugin.go
new file mode 100644
index 0000000..4672453
--- /dev/null
+++ b/android/plugin.go
@@ -0,0 +1,140 @@
+// Copyright 2022 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package android
+
+import (
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "strings"
+
+ "github.com/google/blueprint"
+)
+
+func init() {
+ RegisterPluginSingletonBuildComponents(InitRegistrationContext)
+}
+
+func RegisterPluginSingletonBuildComponents(ctx RegistrationContext) {
+ ctx.RegisterParallelSingletonType("plugins", pluginSingletonFactory)
+}
+
+// pluginSingleton is a singleton to handle allowlisting of the final Android-<product_name>.mk file
+// output.
+func pluginSingletonFactory() Singleton {
+ return &pluginSingleton{}
+}
+
+type pluginSingleton struct{}
+
+var allowedPluginsByName = map[string]bool{
+ "aidl-soong-rules": true,
+ "arm_compute_library_nn_driver": true,
+ "cuttlefish-soong-rules": true,
+ "gki-soong-rules": true,
+ "hidl-soong-rules": true,
+ "kernel-config-soong-rules": true,
+ "soong-angle-codegen": true,
+ "soong-api": true,
+ "soong-art": true,
+ "soong-ca-certificates": true,
+ "soong-ca-certificates-apex": true,
+ "soong-clang": true,
+ "soong-clang-prebuilts": true,
+ "soong-csuite": true,
+ "soong-fluoride": true,
+ "soong-fs_config": true,
+ "soong-icu": true,
+ "soong-java-config-error_prone": true,
+ "soong-libchrome": true,
+ "soong-llvm": true,
+ "soong-robolectric": true,
+ "soong-rust-prebuilts": true,
+ "soong-selinux": true,
+ "soong-wayland-protocol-codegen": true,
+ "treble_report_app": true,
+ "treble_report_local": true,
+ "treble_report_module": true,
+ "vintf-compatibility-matrix-soong-rules": true,
+ "xsdc-soong-rules": true,
+}
+
+const (
+ internalPluginsPath = "vendor/google/build/soong/internal_plugins.json"
+)
+
+type pluginProvider interface {
+ IsPluginFor(string) bool
+}
+
+func maybeAddInternalPluginsToAllowlist(ctx SingletonContext) {
+ if path := ExistentPathForSource(ctx, internalPluginsPath); path.Valid() {
+ ctx.AddNinjaFileDeps(path.String())
+ absPath := absolutePath(path.String())
+ var moreAllowed map[string]bool
+ data, err := ioutil.ReadFile(absPath)
+ if err != nil {
+ ctx.Errorf("Failed to open internal plugins path %q %q", internalPluginsPath, err)
+ }
+ if err := json.Unmarshal(data, &moreAllowed); err != nil {
+ fmt.Fprintf(os.Stderr, "Internal plugins file %q did not parse correctly: %q", data, err)
+ }
+ for k, v := range moreAllowed {
+ allowedPluginsByName[k] = v
+ }
+ }
+}
+
+func (p *pluginSingleton) GenerateBuildActions(ctx SingletonContext) {
+ for _, p := range ctx.DeviceConfig().BuildBrokenPluginValidation() {
+ allowedPluginsByName[p] = true
+ }
+ maybeAddInternalPluginsToAllowlist(ctx)
+
+ disallowedPlugins := map[string]bool{}
+ ctx.VisitAllModulesBlueprint(func(module blueprint.Module) {
+ if ctx.ModuleType(module) != "bootstrap_go_package" {
+ return
+ }
+
+ p, ok := module.(pluginProvider)
+ if !ok || !p.IsPluginFor("soong_build") {
+ return
+ }
+
+ name := ctx.ModuleName(module)
+ if _, ok := allowedPluginsByName[name]; ok {
+ return
+ }
+
+ dir := ctx.ModuleDir(module)
+
+ // allow use of plugins within Soong to not allowlist everything
+ if strings.HasPrefix(dir, "build/soong") {
+ return
+ }
+
+ // allow third party users outside of external to create new plugins, i.e. non-google paths
+ // under vendor or hardware
+ if !strings.HasPrefix(dir, "external/") && IsThirdPartyPath(dir) {
+ return
+ }
+ disallowedPlugins[name] = true
+ })
+ if len(disallowedPlugins) > 0 {
+ ctx.Errorf("New plugins are not supported; however %q were found. Please reach out to the build team or use BUILD_BROKEN_PLUGIN_VALIDATION (see Changes.md for more info).", SortedStringKeys(disallowedPlugins))
+ }
+}
diff --git a/android/register.go b/android/register.go
index 1a3db9d..64b0207 100644
--- a/android/register.go
+++ b/android/register.go
@@ -65,16 +65,19 @@
// True if this should be registered as a pre-singleton, false otherwise.
pre bool
+ // True if this should be registered as a parallel singleton.
+ parallel bool
+
name string
factory SingletonFactory
}
-func newSingleton(name string, factory SingletonFactory) singleton {
- return singleton{false, name, factory}
+func newSingleton(name string, factory SingletonFactory, parallel bool) singleton {
+ return singleton{pre: false, parallel: parallel, name: name, factory: factory}
}
func newPreSingleton(name string, factory SingletonFactory) singleton {
- return singleton{true, name, factory}
+ return singleton{pre: true, parallel: false, name: name, factory: factory}
}
func (s singleton) componentName() string {
@@ -86,7 +89,7 @@
if s.pre {
ctx.RegisterPreSingletonType(s.name, adaptor)
} else {
- ctx.RegisterSingletonType(s.name, adaptor)
+ ctx.RegisterSingletonType(s.name, adaptor, s.parallel)
}
}
@@ -145,8 +148,16 @@
moduleTypeByFactory[factory] = name
}
+func registerSingletonType(name string, factory SingletonFactory, parallel bool) {
+ singletons = append(singletons, newSingleton(name, factory, parallel))
+}
+
func RegisterSingletonType(name string, factory SingletonFactory) {
- singletons = append(singletons, newSingleton(name, factory))
+ registerSingletonType(name, factory, false)
+}
+
+func RegisterParallelSingletonType(name string, factory SingletonFactory) {
+ registerSingletonType(name, factory, true)
}
func RegisterPreSingletonType(name string, factory SingletonFactory) {
@@ -220,17 +231,17 @@
func collateGloballyRegisteredSingletons() sortableComponents {
allSingletons := append(sortableComponents(nil), singletons...)
allSingletons = append(allSingletons,
- singleton{false, "bazeldeps", BazelSingleton},
+ singleton{pre: false, parallel: true, name: "bazeldeps", factory: BazelSingleton},
// Register phony just before makevars so it can write out its phony rules as Make rules
- singleton{false, "phony", phonySingletonFactory},
+ singleton{pre: false, parallel: false, name: "phony", factory: phonySingletonFactory},
// Register makevars after other singletons so they can export values through makevars
- singleton{false, "makevars", makeVarsSingletonFunc},
+ singleton{pre: false, parallel: false, name: "makevars", factory: makeVarsSingletonFunc},
// Register env and ninjadeps last so that they can track all used environment variables and
// Ninja file dependencies stored in the config.
- singleton{false, "ninjadeps", ninjaDepsSingletonFactory},
+ singleton{pre: false, parallel: false, name: "ninjadeps", factory: ninjaDepsSingletonFactory},
)
return allSingletons
@@ -259,7 +270,9 @@
type RegistrationContext interface {
RegisterModuleType(name string, factory ModuleFactory)
RegisterSingletonModuleType(name string, factory SingletonModuleFactory)
+ RegisterParallelSingletonModuleType(name string, factory SingletonModuleFactory)
RegisterPreSingletonType(name string, factory SingletonFactory)
+ RegisterParallelSingletonType(name string, factory SingletonFactory)
RegisterSingletonType(name string, factory SingletonFactory)
PreArchMutators(f RegisterMutatorFunc)
@@ -315,8 +328,15 @@
}
func (ctx *initRegistrationContext) RegisterSingletonModuleType(name string, factory SingletonModuleFactory) {
+ ctx.registerSingletonModuleType(name, factory, false)
+}
+func (ctx *initRegistrationContext) RegisterParallelSingletonModuleType(name string, factory SingletonModuleFactory) {
+ ctx.registerSingletonModuleType(name, factory, true)
+}
+
+func (ctx *initRegistrationContext) registerSingletonModuleType(name string, factory SingletonModuleFactory, parallel bool) {
s, m := SingletonModuleFactoryAdaptor(name, factory)
- ctx.RegisterSingletonType(name, s)
+ ctx.registerSingletonType(name, s, parallel)
ctx.RegisterModuleType(name, m)
// Overwrite moduleTypesForDocs with the original factory instead of the lambda returned by
// SingletonModuleFactoryAdaptor so that docs can find the module type documentation on the
@@ -324,12 +344,20 @@
RegisterModuleTypeForDocs(name, reflect.ValueOf(factory))
}
-func (ctx *initRegistrationContext) RegisterSingletonType(name string, factory SingletonFactory) {
+func (ctx *initRegistrationContext) registerSingletonType(name string, factory SingletonFactory, parallel bool) {
if _, present := ctx.singletonTypes[name]; present {
panic(fmt.Sprintf("singleton type %q is already registered", name))
}
ctx.singletonTypes[name] = factory
- RegisterSingletonType(name, factory)
+ registerSingletonType(name, factory, parallel)
+}
+
+func (ctx *initRegistrationContext) RegisterSingletonType(name string, factory SingletonFactory) {
+ ctx.registerSingletonType(name, factory, false)
+}
+
+func (ctx *initRegistrationContext) RegisterParallelSingletonType(name string, factory SingletonFactory) {
+ ctx.registerSingletonType(name, factory, true)
}
func (ctx *initRegistrationContext) RegisterPreSingletonType(name string, factory SingletonFactory) {
diff --git a/android/test_suites.go b/android/test_suites.go
index b570b23..b48d71a 100644
--- a/android/test_suites.go
+++ b/android/test_suites.go
@@ -15,7 +15,7 @@
package android
func init() {
- RegisterSingletonType("testsuites", testSuiteFilesFactory)
+ RegisterParallelSingletonType("testsuites", testSuiteFilesFactory)
}
func testSuiteFilesFactory() Singleton {
diff --git a/android/testing.go b/android/testing.go
index 2a9c658..5ad7ad0 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -495,8 +495,18 @@
ctx.RegisterModuleType(name, m)
}
+func (ctx *TestContext) RegisterParallelSingletonModuleType(name string, factory SingletonModuleFactory) {
+ s, m := SingletonModuleFactoryAdaptor(name, factory)
+ ctx.RegisterParallelSingletonType(name, s)
+ ctx.RegisterModuleType(name, m)
+}
+
func (ctx *TestContext) RegisterSingletonType(name string, factory SingletonFactory) {
- ctx.singletons = append(ctx.singletons, newSingleton(name, factory))
+ ctx.singletons = append(ctx.singletons, newSingleton(name, factory, false))
+}
+
+func (ctx *TestContext) RegisterParallelSingletonType(name string, factory SingletonFactory) {
+ ctx.singletons = append(ctx.singletons, newSingleton(name, factory, true))
}
func (ctx *TestContext) RegisterPreSingletonType(name string, factory SingletonFactory) {
diff --git a/android/variable.go b/android/variable.go
index 97171e7..3832fcf 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -440,10 +440,11 @@
ShippingApiLevel *string `json:",omitempty"`
+ BuildBrokenPluginValidation []string `json:",omitempty"`
BuildBrokenClangAsFlags bool `json:",omitempty"`
BuildBrokenClangCFlags bool `json:",omitempty"`
BuildBrokenClangProperty bool `json:",omitempty"`
- BuildBrokenDepfile *bool `json:",omitempty"`
+ GenruleSandboxing *bool `json:",omitempty"`
BuildBrokenEnforceSyspropOwner bool `json:",omitempty"`
BuildBrokenTrebleSyspropNeverallow bool `json:",omitempty"`
BuildBrokenUsesSoongPython2Modules bool `json:",omitempty"`
diff --git a/android_sdk/sdk_repo_host.go b/android_sdk/sdk_repo_host.go
index 61058df..9623a8b 100644
--- a/android_sdk/sdk_repo_host.go
+++ b/android_sdk/sdk_repo_host.go
@@ -242,7 +242,7 @@
fmt.Fprintln(w, ".PHONY:", name, "sdk_repo", "sdk-repo-"+name)
fmt.Fprintln(w, "sdk_repo", "sdk-repo-"+name+":", strings.Join(s.FilesToInstall().Strings(), " "))
- fmt.Fprintf(w, "$(call dist-for-goals,sdk_repo sdk-repo-%s,%s:%s-$(FILE_NAME_TAG).zip)\n\n", s.BaseModuleName(), s.outputFile.String(), s.outputBaseName)
+ fmt.Fprintf(w, "$(call dist-for-goals,sdk_repo sdk-repo-%s,%s:%s-FILE_NAME_TAG_PLACEHOLDER.zip)\n\n", s.BaseModuleName(), s.outputFile.String(), s.outputBaseName)
},
}
}
diff --git a/apex/Android.bp b/apex/Android.bp
index 61d7fb2..0791497 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -29,7 +29,6 @@
"bp2build.go",
"deapexer.go",
"key.go",
- "metadata.go",
"prebuilt.go",
"testing.go",
"vndk.go",
@@ -39,7 +38,6 @@
"bootclasspath_fragment_test.go",
"classpath_element_test.go",
"dexpreopt_bootjars_test.go",
- "metadata_test.go",
"platform_bootclasspath_test.go",
"systemserver_classpath_fragment_test.go",
"vndk_test.go",
diff --git a/apex/apex.go b/apex/apex.go
index ff7ee35..1c79463 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -3273,7 +3273,7 @@
//
// Module separator
//
- m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
+ m["com.android.cellbroadcast"] = []string{}
//
// Module separator
//
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index ebc35cf..a63344f 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -27,7 +27,7 @@
}
func registerApexDepsInfoComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory)
+ ctx.RegisterParallelSingletonType("apex_depsinfo_singleton", apexDepsInfoSingletonFactory)
}
type apexDepsInfoSingleton struct {
diff --git a/apex/key.go b/apex/key.go
index 0a7e80f..3010d76 100644
--- a/apex/key.go
+++ b/apex/key.go
@@ -33,7 +33,7 @@
func registerApexKeyBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("apex_key", ApexKeyFactory)
- ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
+ ctx.RegisterParallelSingletonType("apex_keys_text", apexKeysTextFactory)
}
type apexKey struct {
diff --git a/apex/metadata.go b/apex/metadata.go
deleted file mode 100644
index b1dff3e..0000000
--- a/apex/metadata.go
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package apex
-
-import (
- "encoding/json"
-
- "github.com/google/blueprint"
-
- "android/soong/android"
-)
-
-var (
- mtctx = android.NewPackageContext("android/soong/multitree_apex")
-)
-
-func init() {
- RegisterModulesSingleton(android.InitRegistrationContext)
-}
-
-func RegisterModulesSingleton(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("apex_multitree_singleton", multitreeAnalysisSingletonFactory)
-}
-
-var PrepareForTestWithApexMultitreeSingleton = android.FixtureRegisterWithContext(RegisterModulesSingleton)
-
-func multitreeAnalysisSingletonFactory() android.Singleton {
- return &multitreeAnalysisSingleton{}
-}
-
-type multitreeAnalysisSingleton struct {
- multitreeApexMetadataPath android.OutputPath
-}
-
-type ApexMultitreeMetadataEntry struct {
- // The name of the apex.
- Name string
-
- // TODO: Add other properties as needed.
-}
-
-type ApexMultitreeMetadata struct {
- // Information about the installable apexes.
- Apexes map[string]ApexMultitreeMetadataEntry
-}
-
-func (p *multitreeAnalysisSingleton) GenerateBuildActions(context android.SingletonContext) {
- data := ApexMultitreeMetadata{
- Apexes: make(map[string]ApexMultitreeMetadataEntry, 0),
- }
- context.VisitAllModules(func(module android.Module) {
- // If this module is not being installed, ignore it.
- if !module.Enabled() || module.IsSkipInstall() {
- return
- }
- // Actual apexes provide ApexBundleInfoProvider.
- if _, ok := context.ModuleProvider(module, ApexBundleInfoProvider).(ApexBundleInfo); !ok {
- return
- }
- bundle, ok := module.(*apexBundle)
- if ok && !bundle.testApex && !bundle.vndkApex && bundle.primaryApexType {
- name := module.Name()
- entry := ApexMultitreeMetadataEntry{
- Name: name,
- }
- data.Apexes[name] = entry
- }
- })
- p.multitreeApexMetadataPath = android.PathForOutput(context, "multitree_apex_metadata.json")
-
- jsonStr, err := json.Marshal(data)
- if err != nil {
- context.Errorf(err.Error())
- }
- android.WriteFileRule(context, p.multitreeApexMetadataPath, string(jsonStr))
- // This seems cleaner, but doesn't emit the phony rule in testing.
- // context.Phony("multitree_apex_metadata", p.multitreeApexMetadataPath)
-
- context.Build(mtctx, android.BuildParams{
- Rule: blueprint.Phony,
- Description: "phony rule for multitree_apex_metadata",
- Inputs: []android.Path{p.multitreeApexMetadataPath},
- Output: android.PathForPhony(context, "multitree_apex_metadata"),
- })
-}
diff --git a/apex/metadata_test.go b/apex/metadata_test.go
deleted file mode 100644
index fed5bea..0000000
--- a/apex/metadata_test.go
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package apex
-
-import (
- "strings"
- "testing"
-
- "android/soong/android"
- "android/soong/java"
-)
-
-func TestModulesSingleton(t *testing.T) {
- result := android.GroupFixturePreparers(
- PrepareForTestWithApexMultitreeSingleton,
- java.PrepareForTestWithJavaDefaultModules,
- PrepareForTestWithApexBuildComponents,
- java.FixtureConfigureApexBootJars("myapex:foo"),
- java.PrepareForTestWithJavaSdkLibraryFiles,
- ).RunTestWithBp(t, `
- prebuilt_apex {
- name: "myapex",
- src: "myapex.apex",
- exported_bootclasspath_fragments: ["mybootclasspath-fragment"],
- }
-
- // A prebuilt java_sdk_library_import that is not preferred by default but will be preferred
- // because AlwaysUsePrebuiltSdks() is true.
- java_sdk_library_import {
- name: "foo",
- prefer: false,
- shared_library: false,
- permitted_packages: ["foo"],
- public: {
- jars: ["sdk_library/public/foo-stubs.jar"],
- stub_srcs: ["sdk_library/public/foo_stub_sources"],
- current_api: "sdk_library/public/foo.txt",
- removed_api: "sdk_library/public/foo-removed.txt",
- sdk_version: "current",
- },
- apex_available: ["myapex"],
- }
-
- prebuilt_bootclasspath_fragment {
- name: "mybootclasspath-fragment",
- apex_available: [
- "myapex",
- ],
- contents: [
- "foo",
- ],
- hidden_api: {
- stub_flags: "prebuilt-stub-flags.csv",
- annotation_flags: "prebuilt-annotation-flags.csv",
- metadata: "prebuilt-metadata.csv",
- index: "prebuilt-index.csv",
- all_flags: "prebuilt-all-flags.csv",
- },
- }
-
- platform_bootclasspath {
- name: "myplatform-bootclasspath",
- fragments: [
- {
- apex: "myapex",
- module:"mybootclasspath-fragment",
- },
- ],
- }
-`,
- )
-
- outputs := result.SingletonForTests("apex_multitree_singleton").AllOutputs()
- for _, output := range outputs {
- testingBuildParam := result.SingletonForTests("apex_multitree_singleton").Output(output)
- switch {
- case strings.Contains(output, "soong/multitree_apex_metadata.json"):
- android.AssertStringEquals(t, "Invalid build rule", "android/soong/android.writeFile", testingBuildParam.Rule.String())
- android.AssertIntEquals(t, "Invalid input", len(testingBuildParam.Inputs), 0)
- android.AssertStringDoesContain(t, "Invalid output path", output, "soong/multitree_apex_metadata.json")
-
- case strings.HasSuffix(output, "multitree_apex_metadata"):
- android.AssertStringEquals(t, "Invalid build rule", "<builtin>:phony", testingBuildParam.Rule.String())
- android.AssertStringEquals(t, "Invalid input", testingBuildParam.Inputs[0].String(), "out/soong/multitree_apex_metadata.json")
- android.AssertStringEquals(t, "Invalid output path", output, "multitree_apex_metadata")
- android.AssertIntEquals(t, "Invalid args", len(testingBuildParam.Args), 0)
- }
- }
-}
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index 6a3b3c8..ca96f23 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -8,7 +8,6 @@
var (
GetOutputFiles = &getOutputFilesRequestType{}
- GetPythonBinary = &getPythonBinaryRequestType{}
GetCcInfo = &getCcInfoType{}
GetApexInfo = &getApexInfoType{}
GetCcUnstrippedInfo = &getCcUnstrippedInfoType{}
@@ -45,8 +44,6 @@
type getOutputFilesRequestType struct{}
-type getPythonBinaryRequestType struct{}
-
// Name returns a string name for this request type. Such request type names must be unique,
// and must only consist of alphanumeric characters.
func (g getOutputFilesRequestType) Name() string {
@@ -72,31 +69,6 @@
return splitOrEmpty(rawString, ", ")
}
-// Name returns a string name for this request type. Such request type names must be unique,
-// and must only consist of alphanumeric characters.
-func (g getPythonBinaryRequestType) Name() string {
- return "getPythonBinary"
-}
-
-// StarlarkFunctionBody returns a starlark function body to process this request type.
-// The returned string is the body of a Starlark function which obtains
-// all request-relevant information about a target and returns a string containing
-// this information.
-// The function should have the following properties:
-// - The arguments are `target` (a configured target) and `id_string` (the label + configuration).
-// - The return value must be a string.
-// - The function body should not be indented outside of its own scope.
-func (g getPythonBinaryRequestType) StarlarkFunctionBody() string {
- return "return providers(target)['FilesToRunProvider'].executable.path"
-}
-
-// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
-// The given rawString must correspond to the string output which was created by evaluating the
-// Starlark given in StarlarkFunctionBody.
-func (g getPythonBinaryRequestType) ParseResult(rawString string) string {
- return rawString
-}
-
type getCcInfoType struct{}
// Name returns a string name for this request type. Such request type names must be unique,
diff --git a/bazel/cquery/request_type_test.go b/bazel/cquery/request_type_test.go
index 7003ce1..e772bb7 100644
--- a/bazel/cquery/request_type_test.go
+++ b/bazel/cquery/request_type_test.go
@@ -40,34 +40,6 @@
}
}
-func TestGetPythonBinaryParseResults(t *testing.T) {
- t.Parallel()
- testCases := []struct {
- description string
- input string
- expectedOutput string
- }{
- {
- description: "no result",
- input: "",
- expectedOutput: "",
- },
- {
- description: "one result",
- input: "test",
- expectedOutput: "test",
- },
- }
- for _, tc := range testCases {
- t.Run(tc.description, func(t *testing.T) {
- actualOutput := GetPythonBinary.ParseResult(tc.input)
- if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
- t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput)
- }
- })
- }
-}
-
func TestGetCcInfoParseResults(t *testing.T) {
t.Parallel()
testCases := []struct {
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index 50f241f..3cff60f 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -51,7 +51,7 @@
pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
pctx.SourcePathVariable("bloaty", "prebuilts/build-tools/${hostPrebuiltTag}/bin/bloaty")
pctx.HostBinToolVariable("bloatyMerger", "bloaty_merger")
- android.RegisterSingletonType("file_metrics", fileSizesSingleton)
+ android.RegisterParallelSingletonType("file_metrics", fileSizesSingleton)
fileSizeMeasurerKey = blueprint.NewProvider(measuredFiles{})
}
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index 6ec3703..8a83cc0 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -222,6 +222,7 @@
"-Wl,--version-script,$(location vs)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
+ "features": `["android_cfi_exports_map"]`,
},
},
},
@@ -249,6 +250,7 @@
"version_script",
"dynamic.list",
]`,
+ "features": `["android_cfi_exports_map"]`,
"linkopts": `[
"--nospace_flag",
"-z",
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 0e8705b..3dd9373 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -900,7 +900,8 @@
"-Wl,--version-script,$(location v.map)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
- "srcs": `["a.cpp"]`,
+ "srcs": `["a.cpp"]`,
+ "features": `["android_cfi_exports_map"]`,
}),
},
)
@@ -958,6 +959,11 @@
"//conditions:default": [],
})`,
"srcs": `["a.cpp"]`,
+ "features": `select({
+ "//build/bazel/platforms/arch:arm": ["android_cfi_exports_map"],
+ "//build/bazel/platforms/arch:arm64": ["android_cfi_exports_map"],
+ "//conditions:default": [],
+ })`,
}),
},
)
@@ -985,12 +991,15 @@
}
`,
ExpectedBazelTargets: []string{
- MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{}),
+ MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
+ "features": `["android_cfi_exports_map"]`,
+ }),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
"additional_linker_inputs": `[
"version_script",
"dynamic.list",
]`,
+ "features": `["android_cfi_exports_map"]`,
"linkopts": `[
"--nospace_flag",
"-z",
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 2ee9c99..6c9f9a1 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -362,6 +362,7 @@
"-Wl,--version-script,$(location version_script)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
+ "features": `["android_cfi_exports_map"]`,
}),
},
})
@@ -398,6 +399,7 @@
"-Wl,--version-script,$(location version_script)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
+ "features": `["android_cfi_exports_map"]`,
}),
},
})
@@ -913,6 +915,7 @@
"header.h",
]`,
"linkopts": `["-Wl,--version-script,$(location version_script)"]`,
+ "features": `["android_cfi_exports_map"]`,
}),
},
})
diff --git a/cc/bp2build.go b/cc/bp2build.go
index fa98df4..259ba39 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -1257,6 +1257,7 @@
label := android.BazelLabelForModuleSrcSingle(ctx, *props.Version_script)
additionalLinkerInputs.Add(&label)
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--version-script,$(location %s)", label.Label))
+ axisFeatures = append(axisFeatures, "android_cfi_exports_map")
}
if props.Dynamic_list != nil {
diff --git a/cc/cc.go b/cc/cc.go
index f4b5655..0e7f6c8 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -83,7 +83,7 @@
ctx.TopDown("sabi_deps", sabiDepsMutator)
})
- ctx.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
+ ctx.RegisterParallelSingletonType("kythe_extract_all", kytheExtractAllFactory)
}
// Deps is a struct containing module names of dependencies, separated by the kind of dependency.
diff --git a/cc/ccdeps.go b/cc/ccdeps.go
index 75e1faf..d30abba 100644
--- a/cc/ccdeps.go
+++ b/cc/ccdeps.go
@@ -30,7 +30,7 @@
// The info file is generated in $OUT/module_bp_cc_depend.json.
func init() {
- android.RegisterSingletonType("ccdeps_generator", ccDepsGeneratorSingleton)
+ android.RegisterParallelSingletonType("ccdeps_generator", ccDepsGeneratorSingleton)
}
func ccDepsGeneratorSingleton() android.Singleton {
diff --git a/cc/cmakelists.go b/cc/cmakelists.go
index ad130ba..0f3f02d 100644
--- a/cc/cmakelists.go
+++ b/cc/cmakelists.go
@@ -29,7 +29,7 @@
// structure (see variable CLionOutputProjectsDirectory for root).
func init() {
- android.RegisterSingletonType("cmakelists_generator", cMakeListsGeneratorSingleton)
+ android.RegisterParallelSingletonType("cmakelists_generator", cMakeListsGeneratorSingleton)
}
func cMakeListsGeneratorSingleton() android.Singleton {
diff --git a/cc/compdb.go b/cc/compdb.go
index ea12443..617be1a 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -32,7 +32,7 @@
// make SOONG_GEN_COMPDB=1 nothing to get all targets.
func init() {
- android.RegisterSingletonType("compdb_generator", compDBGeneratorSingleton)
+ android.RegisterParallelSingletonType("compdb_generator", compDBGeneratorSingleton)
}
func compDBGeneratorSingleton() android.Singleton {
diff --git a/cc/config/global.go b/cc/config/global.go
index d4106eb..d63e324 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -438,6 +438,8 @@
pctx.StaticVariableWithEnvOverride("ClangShortVersion", "LLVM_RELEASE_VERSION", ClangDefaultShortVersion)
pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib/clang/${ClangShortVersion}/lib/linux")
+ exportedVars.ExportStringListStaticVariable("WarningAllowedProjects", WarningAllowedProjects)
+
// These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts
// being used for the rest of the build process.
pctx.SourcePathVariable("RSClangBase", "prebuilts/clang/host")
diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go
index 6a10e14..a0ef575 100644
--- a/cc/config/toolchain.go
+++ b/cc/config/toolchain.go
@@ -20,6 +20,12 @@
"android/soong/android"
)
+func init() {
+ exportedVars.ExportStringListStaticVariable("DarwinAvailableLibraries", darwinAvailableLibraries)
+ exportedVars.ExportStringListStaticVariable("LinuxAvailableLibraries", linuxAvailableLibraries)
+ exportedVars.ExportStringListStaticVariable("WindowsAvailableLibraries", windowsAvailableLibraries)
+}
+
type toolchainFactory func(arch android.Arch) Toolchain
var toolchainFactories = make(map[android.OsType]map[android.ArchType]toolchainFactory)
diff --git a/cc/fuzz.go b/cc/fuzz.go
index dfefc11..c897501 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -28,7 +28,7 @@
func init() {
android.RegisterModuleType("cc_fuzz", LibFuzzFactory)
- android.RegisterSingletonType("cc_fuzz_packaging", fuzzPackagingFactory)
+ android.RegisterParallelSingletonType("cc_fuzz_packaging", fuzzPackagingFactory)
}
type FuzzProperties struct {
@@ -398,7 +398,9 @@
}
hostOrTargetString := "target"
- if ccModule.Host() {
+ if ccModule.Target().HostCross {
+ hostOrTargetString = "host_cross"
+ } else if ccModule.Host() {
hostOrTargetString = "host"
}
diff --git a/cc/lto.go b/cc/lto.go
index 1afa1dd..581856b 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -91,11 +91,6 @@
return flags
}
- // TODO(b/254713216): LTO doesn't work on riscv64 yet.
- if ctx.Arch().ArchType == android.Riscv64 {
- return flags
- }
-
if lto.LTO(ctx) {
var ltoCFlag string
var ltoLdFlag string
diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go
index 3456c32..86166dc 100644
--- a/cc/ndk_abi.go
+++ b/cc/ndk_abi.go
@@ -19,8 +19,8 @@
)
func init() {
- android.RegisterSingletonType("ndk_abi_dump", NdkAbiDumpSingleton)
- android.RegisterSingletonType("ndk_abi_diff", NdkAbiDiffSingleton)
+ android.RegisterParallelSingletonType("ndk_abi_dump", NdkAbiDumpSingleton)
+ android.RegisterParallelSingletonType("ndk_abi_diff", NdkAbiDiffSingleton)
}
func getNdkAbiDumpInstallBase(ctx android.PathContext) android.OutputPath {
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index dffc6c6..0cf21b6 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -66,7 +66,7 @@
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
ctx.RegisterModuleType("versioned_ndk_headers", versionedNdkHeadersFactory)
ctx.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
- ctx.RegisterSingletonType("ndk", NdkSingleton)
+ ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
}
func getNdkInstallBase(ctx android.PathContext) android.InstallPath {
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 7fddc1b..6e732b6 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -665,6 +665,21 @@
s.Diag.Cfi = nil
}
+ // TODO(b/280478629): runtimes don't exist for musl arm64 yet.
+ if ctx.toolchain().Musl() && ctx.Arch().ArchType == android.Arm64 {
+ s.Address = nil
+ s.Hwaddress = nil
+ s.Thread = nil
+ s.Scudo = nil
+ s.Fuzzer = nil
+ s.Cfi = nil
+ s.Diag.Cfi = nil
+ s.Misc_undefined = nil
+ s.Undefined = nil
+ s.All_undefined = nil
+ s.Integer_overflow = nil
+ }
+
// Also disable CFI for VNDK variants of components
if ctx.isVndk() && ctx.useVndk() {
s.Cfi = nil
diff --git a/cc/stub_library.go b/cc/stub_library.go
index f324dcc..3a6d0ae 100644
--- a/cc/stub_library.go
+++ b/cc/stub_library.go
@@ -23,7 +23,7 @@
func init() {
// Use singleton type to gather all generated soong modules.
- android.RegisterSingletonType("stublibraries", stubLibrariesSingleton)
+ android.RegisterParallelSingletonType("stublibraries", stubLibrariesSingleton)
}
type stubLibraries struct {
diff --git a/cc/tidy.go b/cc/tidy.go
index bbcaece..7b123cb 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -201,7 +201,7 @@
}
func init() {
- android.RegisterSingletonType("tidy_phony_targets", TidyPhonySingleton)
+ android.RegisterParallelSingletonType("tidy_phony_targets", TidyPhonySingleton)
}
// This TidyPhonySingleton generates both tidy-* and obj-* phony targets for C/C++ files.
diff --git a/cc/vndk.go b/cc/vndk.go
index 9b70004..7a2286e 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -417,16 +417,16 @@
func init() {
RegisterVndkLibraryTxtTypes(android.InitRegistrationContext)
- android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
+ android.RegisterParallelSingletonType("vndk-snapshot", VndkSnapshotSingleton)
}
func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
- ctx.RegisterSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory)
- ctx.RegisterSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory)
- ctx.RegisterSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory)
- ctx.RegisterSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory)
- ctx.RegisterSingletonModuleType("vndkproduct_libraries_txt", vndkProductLibrariesTxtFactory)
- ctx.RegisterSingletonModuleType("vndkcorevariant_libraries_txt", vndkUsingCoreVariantLibrariesTxtFactory)
+ ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory)
+ ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory)
+ ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory)
+ ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory)
+ ctx.RegisterParallelSingletonModuleType("vndkproduct_libraries_txt", vndkProductLibrariesTxtFactory)
+ ctx.RegisterParallelSingletonModuleType("vndkcorevariant_libraries_txt", vndkUsingCoreVariantLibrariesTxtFactory)
}
type vndkLibrariesTxt struct {
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 0cc3bd6..e61ebe6 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -197,7 +197,7 @@
func init() {
pctx.Import("android/soong/android")
- android.RegisterSingletonType("dexpreopt-soong-config", func() android.Singleton {
+ android.RegisterParallelSingletonType("dexpreopt-soong-config", func() android.Singleton {
return &globalSoongConfigSingleton{}
})
}
diff --git a/genrule/Android.bp b/genrule/Android.bp
index 8fb5c40..b201cae 100644
--- a/genrule/Android.bp
+++ b/genrule/Android.bp
@@ -15,6 +15,7 @@
"soong-shared",
],
srcs: [
+ "allowlists.go",
"genrule.go",
"locations.go",
],
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
new file mode 100644
index 0000000..875dbab
--- /dev/null
+++ b/genrule/allowlists.go
@@ -0,0 +1,147 @@
+// Copyright 2023 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package genrule
+
+import (
+ "android/soong/android"
+)
+
+var (
+ DepfileAllowList = []string{
+ "depfile_allowed_for_test",
+ "tflite_support_spm_config",
+ "tflite_support_spm_encoder_config",
+ "gen_uwb_core_proto",
+ "libtextclassifier_fbgen_utils_flatbuffers_flatbuffers_test",
+ "libtextclassifier_fbgen_utils_lua_utils_tests",
+ "libtextclassifier_fbgen_lang_id_common_flatbuffers_model",
+ "libtextclassifier_fbgen_lang_id_common_flatbuffers_embedding-network",
+ "libtextclassifier_fbgen_annotator_datetime_datetime",
+ "libtextclassifier_fbgen_annotator_model",
+ "libtextclassifier_fbgen_annotator_experimental_experimental",
+ "libtextclassifier_fbgen_annotator_entity-data",
+ "libtextclassifier_fbgen_annotator_person_name_person_name_model",
+ "libtextclassifier_fbgen_utils_tflite_text_encoder_config",
+ "libtextclassifier_fbgen_utils_codepoint-range",
+ "libtextclassifier_fbgen_utils_intents_intent-config",
+ "libtextclassifier_fbgen_utils_flatbuffers_flatbuffers",
+ "libtextclassifier_fbgen_utils_zlib_buffer",
+ "libtextclassifier_fbgen_utils_tokenizer",
+ "libtextclassifier_fbgen_utils_grammar_rules",
+ "libtextclassifier_fbgen_utils_grammar_semantics_expression",
+ "libtextclassifier_fbgen_utils_resources",
+ "libtextclassifier_fbgen_utils_i18n_language-tag",
+ "libtextclassifier_fbgen_utils_normalization",
+ "libtextclassifier_fbgen_utils_container_bit-vector",
+ "libtextclassifier_fbgen_actions_actions-entity-data",
+ "libtextclassifier_fbgen_actions_actions_model",
+ "libtextclassifier_fbgen_utils_grammar_testing_value",
+ }
+
+ SandboxingDenyModuleList = []string{
+ "framework-javastream-protos",
+ "RsBalls-rscript",
+ "CtsRsBlasTestCases-rscript",
+ "pvmfw_fdt_template_rs",
+ "RSTest_v14-rscript",
+ "com.android.apex.test.bar_stripped",
+ "com.android.apex.test.sharedlibs_secondary_generated",
+ "ImageProcessingJB-rscript",
+ "RSTest-rscript",
+ "BluetoothGeneratedDumpsysBinarySchema_bfbs",
+ "WmediumdServerProto_h",
+ "TracingVMProtoStub_h",
+ "FrontendStub_h",
+ "VehicleServerProtoStub_cc",
+ "AudioFocusControlProtoStub_cc",
+ "AudioFocusControlProtoStub_h",
+ "TracingVMProtoStub_cc",
+ "VehicleServerProtoStub_h",
+ "hidl2aidl_translate_cpp_test_gen_headers",
+ "hidl2aidl_translate_cpp_test_gen_src",
+ "hidl2aidl_translate_java_test_gen_src",
+ "hidl2aidl_translate_ndk_test_gen_headers",
+ "hidl2aidl_translate_ndk_test_gen_src",
+ "hidl_hash_test_gen",
+ "nos_app_avb_service_genc++",
+ "nos_app_avb_service_genc++_headers",
+ "nos_app_avb_service_genc++_mock",
+ "nos_app_identity_service_genc++",
+ "nos_app_keymaster_service_genc++",
+ "nos_generator_test_service_genc++_headers",
+ "nos_generator_test_service_genc++_mock",
+ "r8retrace-run-retrace",
+ "ltp_config_arm",
+ "ltp_config_arm_64_hwasan",
+ "ltp_config_arm_lowmem",
+ "ltp_config_arm_64",
+ "ltp_config_riscv_64",
+ "ltp_config_x86_64",
+ "vm-tests-tf-lib",
+ "hidl_cpp_impl_test_gen-headers",
+ "pandora_experimental-python-gen-src",
+ "framework-cppstream-protos",
+ "Refocus-rscript",
+ "RSTest_v11-rscript",
+ "RSTest_v16-rscript",
+ "ScriptGroupTest-rscript",
+ "ImageProcessing2-rscript",
+ "ImageProcessing-rscript",
+ "com.android.apex.test.pony_stripped",
+ "com.android.apex.test.baz_stripped",
+ "com.android.apex.test.foo_stripped",
+ "com.android.apex.test.sharedlibs_generated",
+ "CtsRenderscriptTestCases-rscript",
+ "BlueberryFacadeAndCertGeneratedStub_py",
+ "BlueberryFacadeGeneratedStub_cc",
+ "BlueberryFacadeGeneratedStub_h",
+ "BluetoothGeneratedDumpsysDataSchema_h",
+ "FrontendStub_cc",
+ "OpenwrtControlServerProto_cc",
+ "OpenwrtControlServerProto_h",
+ "WmediumdServerProto_cc",
+ "c2hal_test_genc++",
+ "c2hal_test_genc++_headers",
+ "hidl2aidl_test_gen_aidl",
+ "hidl_error_test_gen",
+ "hidl_export_test_gen-headers",
+ "hidl_format_test_diff",
+ "hidl_hash_version_gen",
+ "libbt_topshim_facade_py_proto",
+ "nos_app_identity_service_genc++_headers",
+ "nos_app_identity_service_genc++_mock",
+ "nos_app_keymaster_service_genc++_headers",
+ "nos_app_keymaster_service_genc++_mock",
+ "nos_app_weaver_service_genc++",
+ "nos_app_weaver_service_genc++_headers",
+ "nos_app_weaver_service_genc++_mock",
+ "nos_generator_test_service_genc++",
+ "pandora-python-gen-src",
+ }
+
+ SandboxingDenyPathList = []string{
+ "art/test",
+ "external/perfetto",
+ }
+)
+var DepfileAllowSet = map[string]bool{}
+var SandboxingDenyModuleSet = map[string]bool{}
+var SandboxingDenyPathSet = map[string]bool{}
+
+func init() {
+ android.AddToStringSet(DepfileAllowSet, DepfileAllowList)
+ android.AddToStringSet(SandboxingDenyModuleSet, append(DepfileAllowList, SandboxingDenyModuleList...))
+ android.AddToStringSet(SandboxingDenyPathSet, SandboxingDenyPathList)
+}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 00adb70..c830fcc 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -452,7 +452,7 @@
manifestPath := android.PathForModuleOut(ctx, manifestName)
// Use a RuleBuilder to create a rule that runs the command inside an sbox sandbox.
- rule := android.NewRuleBuilder(pctx, ctx).Sbox(task.genDir, manifestPath).SandboxTools()
+ rule := getSandboxedRuleBuilder(ctx, android.NewRuleBuilder(pctx, ctx).Sbox(task.genDir, manifestPath))
cmd := rule.Command()
for _, out := range task.out {
@@ -594,14 +594,16 @@
func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Allowlist genrule to use depfile until we have a solution to remove it.
// TODO(b/235582219): Remove allowlist for genrule
- if ctx.ModuleType() == "gensrcs" &&
- !ctx.DeviceConfig().BuildBrokenDepfile() &&
- Bool(g.properties.Depfile) {
- ctx.PropertyErrorf(
- "depfile",
- "Deprecated to ensure the module type is convertible to Bazel. "+
- "Try specifying the dependencies explicitly so that there is no need to use depfile. "+
- "If not possible, the escape hatch is to use BUILD_BROKEN_DEPFILE to bypass the error.")
+ if Bool(g.properties.Depfile) {
+ // TODO(b/283852474): Checking the GenruleSandboxing flag is temporary in
+ // order to pass the presubmit before internal master is updated.
+ if ctx.DeviceConfig().GenruleSandboxing() && !DepfileAllowSet[g.Name()] {
+ ctx.PropertyErrorf(
+ "depfile",
+ "Deprecated to ensure the module type is convertible to Bazel. "+
+ "Try specifying the dependencies explicitly so that there is no need to use depfile. "+
+ "If not possible, the escape hatch is to add the module to allowlists.go to bypass the error.")
+ }
}
g.generateCommonBuildActions(ctx)
@@ -737,7 +739,7 @@
// TODO(ccross): this RuleBuilder is a hack to be able to call
// rule.Command().PathForOutput. Replace this with passing the rule into the
// generator.
- rule := android.NewRuleBuilder(pctx, ctx).Sbox(genDir, nil).SandboxTools()
+ rule := getSandboxedRuleBuilder(ctx, android.NewRuleBuilder(pctx, ctx).Sbox(genDir, nil))
for _, in := range shard {
outFile := android.GenPathWithExt(ctx, finalSubDir, in, String(properties.Output_extension))
@@ -1020,3 +1022,11 @@
return module
}
+
+func getSandboxedRuleBuilder(ctx android.ModuleContext, r *android.RuleBuilder) *android.RuleBuilder {
+ if !ctx.DeviceConfig().GenruleSandboxing() || SandboxingDenyPathSet[ctx.ModuleDir()] ||
+ SandboxingDenyModuleSet[ctx.ModuleName()] {
+ return r.SandboxTools()
+ }
+ return r.SandboxInputs()
+}
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index 63f8fa9..370fe3d 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -97,8 +97,9 @@
func TestGenruleCmd(t *testing.T) {
testcases := []struct {
- name string
- prop string
+ name string
+ moduleName string
+ prop string
allowMissingDependencies bool
@@ -285,7 +286,8 @@
expect: "echo foo > __SBOX_SANDBOX_DIR__/out/out2",
},
{
- name: "depfile",
+ name: "depfile",
+ moduleName: "depfile_allowed_for_test",
prop: `
out: ["out"],
depfile: true,
@@ -397,7 +399,8 @@
err: "$(depfile) used without depfile property",
},
{
- name: "error no depfile",
+ name: "error no depfile",
+ moduleName: "depfile_allowed_for_test",
prop: `
out: ["out"],
depfile: true,
@@ -440,11 +443,15 @@
for _, test := range testcases {
t.Run(test.name, func(t *testing.T) {
- bp := "genrule {\n"
- bp += "name: \"gen\",\n"
- bp += test.prop
- bp += "}\n"
-
+ moduleName := "gen"
+ if test.moduleName != "" {
+ moduleName = test.moduleName
+ }
+ bp := fmt.Sprintf(`
+ genrule {
+ name: "%s",
+ %s
+ }`, moduleName, test.prop)
var expectedErrors []string
if test.err != "" {
expectedErrors = append(expectedErrors, regexp.QuoteMeta(test.err))
@@ -455,6 +462,9 @@
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Allow_missing_dependencies = proptools.BoolPtr(test.allowMissingDependencies)
}),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.GenruleSandboxing = proptools.BoolPtr(true)
+ }),
android.FixtureModifyContext(func(ctx *android.TestContext) {
ctx.SetAllowMissingDependencies(test.allowMissingDependencies)
}),
@@ -466,7 +476,7 @@
return
}
- gen := result.Module("gen", "").(*Module)
+ gen := result.Module(moduleName, "").(*Module)
android.AssertStringEquals(t, "raw commands", test.expect, gen.rawCommands[0])
})
}
@@ -627,53 +637,42 @@
}
}
-func TestGensrcsBuildBrokenDepfile(t *testing.T) {
+func TestGenruleAllowlistingDepfile(t *testing.T) {
tests := []struct {
- name string
- prop string
- BuildBrokenDepfile *bool
- err string
+ name string
+ prop string
+ err string
+ moduleName string
}{
{
- name: `error when BuildBrokenDepfile is set to false`,
+ name: `error when module is not allowlisted`,
prop: `
depfile: true,
cmd: "cat $(in) > $(out) && cat $(depfile)",
`,
- BuildBrokenDepfile: proptools.BoolPtr(false),
- err: "depfile: Deprecated to ensure the module type is convertible to Bazel",
+ err: "depfile: Deprecated to ensure the module type is convertible to Bazel",
},
{
- name: `error when BuildBrokenDepfile is not set`,
+ name: `no error when module is allowlisted`,
prop: `
depfile: true,
cmd: "cat $(in) > $(out) && cat $(depfile)",
`,
- err: "depfile: Deprecated to ensure the module type is convertible to Bazel.",
- },
- {
- name: `no error when BuildBrokenDepfile is explicitly set to true`,
- prop: `
- depfile: true,
- cmd: "cat $(in) > $(out) && cat $(depfile)",
- `,
- BuildBrokenDepfile: proptools.BoolPtr(true),
- },
- {
- name: `no error if depfile is not set`,
- prop: `
- cmd: "cat $(in) > $(out)",
- `,
+ moduleName: `depfile_allowed_for_test`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
+ moduleName := "foo"
+ if test.moduleName != "" {
+ moduleName = test.moduleName
+ }
bp := fmt.Sprintf(`
gensrcs {
- name: "foo",
+ name: "%s",
srcs: ["data.txt"],
%s
- }`, test.prop)
+ }`, moduleName, test.prop)
var expectedErrors []string
if test.err != "" {
@@ -682,9 +681,7 @@
android.GroupFixturePreparers(
prepareForGenRuleTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- if test.BuildBrokenDepfile != nil {
- variables.BuildBrokenDepfile = test.BuildBrokenDepfile
- }
+ variables.GenruleSandboxing = proptools.BoolPtr(true)
}),
).
ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern(expectedErrors)).
diff --git a/java/androidmk.go b/java/androidmk.go
index 148d7c2..9c21633 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -133,13 +133,19 @@
return entriesList
}
-func (j *JavaFuzzLibrary) AndroidMkEntries() []android.AndroidMkEntries {
+func (j *JavaFuzzTest) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := j.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", "null-suite")
- androidMkWriteTestData(j.jniFilePaths, entries)
androidMkWriteTestData(android.Paths{j.implementationJarFile}, entries)
+ androidMkWriteTestData(j.jniFilePaths, entries)
+ if j.fuzzPackagedModule.Corpus != nil {
+ androidMkWriteTestData(j.fuzzPackagedModule.Corpus, entries)
+ }
+ if j.fuzzPackagedModule.Dictionary != nil {
+ androidMkWriteTestData(android.Paths{j.fuzzPackagedModule.Dictionary}, entries)
+ }
})
return entriesList
}
diff --git a/java/app.go b/java/app.go
index 3344647..366005c 100755
--- a/java/app.go
+++ b/java/app.go
@@ -585,19 +585,6 @@
certificates = append([]Certificate{mainCert}, certificates...)
}
- if !m.Platform() {
- certPath := certificates[0].Pem.String()
- systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
- if strings.HasPrefix(certPath, systemCertPath) {
- enforceSystemCert := ctx.Config().EnforceSystemCertificate()
- allowed := ctx.Config().EnforceSystemCertificateAllowList()
-
- if enforceSystemCert && !inList(m.Name(), allowed) {
- ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
- }
- }
- }
-
if len(certificates) > 0 {
mainCertificate = certificates[0]
} else {
@@ -613,6 +600,20 @@
}
}
+ if !m.Platform() {
+ certPath := mainCertificate.Pem.String()
+ systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
+ if strings.HasPrefix(certPath, systemCertPath) {
+ enforceSystemCert := ctx.Config().EnforceSystemCertificate()
+ allowed := ctx.Config().EnforceSystemCertificateAllowList()
+
+ if enforceSystemCert && !inList(m.Name(), allowed) {
+ ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
+ }
+ }
+ }
+
+
return mainCertificate, certificates
}
@@ -976,6 +977,10 @@
// For OutputFileProducer interface
func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) {
switch tag {
+ // In some instances, it can be useful to reference the aapt-generated flags from another
+ // target, e.g., system server implements services declared in the framework-res manifest.
+ case ".aapt.proguardOptionsFile":
+ return []android.Path{a.proguardOptionsFile}, nil
case ".aapt.srcjar":
return []android.Path{a.aaptSrcJar}, nil
case ".export-package.apk":
diff --git a/java/app_test.go b/java/app_test.go
index 8a69a03..c485478 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -3382,6 +3382,14 @@
srcs: ["a.java"],
certificate: ":missing_certificate",
sdk_version: "current",
+ }
+
+ android_app {
+ name: "bar",
+ srcs: ["a.java"],
+ certificate: ":missing_certificate",
+ product_specific: true,
+ sdk_version: "current",
}`)
foo := result.ModuleForTests("foo", "android_common")
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 2541f14..9bdef74 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -432,3 +432,39 @@
fragment = result.Module("a_test_fragment", "android_common").(*BootclasspathFragmentModule)
android.AssertBoolEquals(t, "is a test fragment by type", true, fragment.isTestFragment())
}
+
+func TestBootclassFragment_LinkTextStub(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ prepareForTestWithBootclasspathFragment,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("mysdklibrary"),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetBuildFromTextStub(true)
+ }),
+ ).RunTestWithBp(t, `
+ bootclasspath_fragment {
+ name: "myfragment",
+ contents: ["mysdklibrary"],
+ hidden_api: {split_packages: ["*"]},
+ additional_stubs: [
+ "android-non-updatable",
+ ],
+ }
+ java_sdk_library {
+ name: "mysdklibrary",
+ srcs: ["a.java"],
+ shared_library: false,
+ public: {enabled: true},
+ system: {enabled: true},
+ }
+ `)
+
+ fragment := result.ModuleForTests("myfragment", "android_common")
+ ruleCommand := fragment.Rule("modularHiddenAPIStubFlagsFile").RuleParams.Command
+ android.AssertStringDoesContain(t, "Command expected to contain library as dependency stub dex",
+ ruleCommand, "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.module_lib.from-text/android_common/dex/android-non-updatable.stubs.module_lib.from-text.jar")
+ android.AssertStringDoesNotContain(t,
+ "Command not expected to contain multiple api_library as dependency stub dex", ruleCommand,
+ "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.from-text/android_common/dex/android-non-updatable.stubs.from-text.jar")
+}
diff --git a/java/config/config.go b/java/config/config.go
index b82a137..195dae1 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -98,7 +98,7 @@
"-JDcom.android.tools.r8.emitRecordAnnotationsExInDex",
}, dexerJavaVmFlagsList...))
exportedVars.ExportStringListStaticVariable("R8Flags", append([]string{
- "-JXmx2048M",
+ "-JXmx4096M",
"-JDcom.android.tools.r8.emitRecordAnnotationsInDex",
"-JDcom.android.tools.r8.emitPermittedSubclassesAnnotationsInDex",
"-JDcom.android.tools.r8.emitRecordAnnotationsExInDex",
diff --git a/java/core-libraries/TxtStubLibraries.bp b/java/core-libraries/TxtStubLibraries.bp
index 813187e..0cf0f36 100644
--- a/java/core-libraries/TxtStubLibraries.bp
+++ b/java/core-libraries/TxtStubLibraries.bp
@@ -22,8 +22,6 @@
libs: [
"core-current-stubs-for-system-modules-no-annotations.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
java_library {
@@ -36,8 +34,6 @@
"core.current.stubs.from-text",
"core-lambda-stubs.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
// Same as core-module-lib-stubs-system-modules, but the stubs are generated from .txt files
@@ -47,8 +43,6 @@
libs: [
"core-module-lib-stubs-for-system-modules-no-annotations.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
java_library {
@@ -61,8 +55,6 @@
"core.module_lib.stubs.from-text",
"core-lambda-stubs.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
java_library {
@@ -79,8 +71,6 @@
sdk_version: "none",
system_modules: "none",
visibility: ["//visibility:private"],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
// Same as legacy-core-platform-api-stubs-system-modules, but the stubs are generated from .txt files
@@ -91,8 +81,6 @@
"legacy.core.platform.api.no.annotations.stubs.from-text",
"core-lambda-stubs.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
java_library {
@@ -108,8 +96,6 @@
"legacy.core.platform.api.stubs.from-text",
],
patch_module: "java.base",
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
// Same as stable-core-platform-api-stubs-system-modules, but the stubs are generated from .txt files
@@ -120,8 +106,6 @@
"stable.core.platform.api.no.annotations.stubs.from-text",
"core-lambda-stubs.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
java_library {
@@ -137,8 +121,6 @@
"stable.core.platform.api.stubs.from-text",
],
patch_module: "java.base",
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
java_api_library {
@@ -151,6 +133,4 @@
// LambdaMetaFactory depends on CallSite etc. which is part of the Core API surface
"core.current.stubs.from-text",
],
- // TODO: Enable after stub generation from .txt file is available
- enabled: false,
}
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index f477f40..116c833 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -465,7 +465,7 @@
}
func RegisterDexpreoptBootJarsComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonModuleType("dex_bootjars", dexpreoptBootJarsFactory)
+ ctx.RegisterParallelSingletonModuleType("dex_bootjars", dexpreoptBootJarsFactory)
}
func SkipDexpreoptBootJars(ctx android.PathContext) bool {
diff --git a/java/dexpreopt_check.go b/java/dexpreopt_check.go
index 83c088c..7499481 100644
--- a/java/dexpreopt_check.go
+++ b/java/dexpreopt_check.go
@@ -28,7 +28,7 @@
}
func RegisterDexpreoptCheckBuildComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonModuleType("dexpreopt_systemserver_check", dexpreoptSystemserverCheckFactory)
+ ctx.RegisterParallelSingletonModuleType("dexpreopt_systemserver_check", dexpreoptSystemserverCheckFactory)
}
// A build-time check to verify if all compilation artifacts of system server jars are installed
diff --git a/java/fuzz.go b/java/fuzz.go
index 9a0c908..5c5f769 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -19,12 +19,12 @@
"sort"
"strings"
- "github.com/google/blueprint"
- "github.com/google/blueprint/proptools"
-
"android/soong/android"
"android/soong/cc"
"android/soong/fuzz"
+
+ "github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
)
const (
@@ -32,63 +32,63 @@
targetString = "target"
)
-type jniProperties struct {
- // list of jni libs
- Jni_libs []string
-
- // sanitization
- Sanitizers []string
-}
-
func init() {
RegisterJavaFuzzBuildComponents(android.InitRegistrationContext)
}
func RegisterJavaFuzzBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("java_fuzz", JavaFuzzFactory)
- ctx.RegisterModuleType("java_fuzz_host", JavaFuzzHostFactory)
- ctx.RegisterSingletonType("java_fuzz_host_packaging", javaFuzzHostPackagingFactory)
- ctx.RegisterSingletonType("java_fuzz_device_packaging", javaFuzzDevicePackagingFactory)
+ ctx.RegisterParallelSingletonType("java_fuzz_packaging", javaFuzzPackagingFactory)
}
-type JavaFuzzLibrary struct {
- Library
+type JavaFuzzTest struct {
+ Test
fuzzPackagedModule fuzz.FuzzPackagedModule
- jniProperties jniProperties
jniFilePaths android.Paths
}
-// IsSanitizerEnabledForJni implemented to make JavaFuzzLibrary implement
-// cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
-// sanitized for the given sanitizer or not.
-func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
- // TODO: once b/231370928 is resolved, please uncomment the loop
- // for _, s := range j.jniProperties.Sanitizers {
- // if sanitizerName == s {
- // return true
- // }
- // }
- return false
+// java_fuzz builds and links sources into a `.jar` file for the device.
+// This generates .class files in a jar which can then be instrumented before
+// fuzzing in Android Runtime (ART: Android OS on emulator or device)
+func JavaFuzzFactory() android.Module {
+ module := &JavaFuzzTest{}
+
+ module.addHostAndDeviceProperties()
+ module.AddProperties(&module.testProperties)
+ module.AddProperties(&module.fuzzPackagedModule.FuzzProperties)
+
+ module.Module.properties.Installable = proptools.BoolPtr(true)
+ module.Module.dexpreopter.isTest = true
+ module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+
+ android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+ disableLinuxBionic := struct {
+ Target struct {
+ Linux_bionic struct {
+ Enabled *bool
+ }
+ }
+ }{}
+ disableLinuxBionic.Target.Linux_bionic.Enabled = proptools.BoolPtr(false)
+ ctx.AppendProperties(&disableLinuxBionic)
+ })
+
+ InitJavaModuleMultiTargets(module, android.HostAndDeviceSupported)
+ return module
}
-func (j *JavaFuzzLibrary) DepsMutator(mctx android.BottomUpMutatorContext) {
- if len(j.jniProperties.Jni_libs) > 0 {
- if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil {
- config := &fuzz.FuzzConfig{}
- j.fuzzPackagedModule.FuzzProperties.Fuzz_config = config
- }
- // this will be used by the ingestion pipeline to determine the version
- // of jazzer to add to the fuzzer package
- j.fuzzPackagedModule.FuzzProperties.Fuzz_config.IsJni = proptools.BoolPtr(true)
- for _, target := range mctx.MultiTargets() {
+func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+ if len(j.testProperties.Jni_libs) > 0 {
+ for _, target := range ctx.MultiTargets() {
sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"})
- mctx.AddFarVariationDependencies(sharedLibVariations, cc.JniFuzzLibTag, j.jniProperties.Jni_libs...)
+ ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...)
}
}
- j.Library.DepsMutator(mctx)
+
+ j.deps(ctx)
}
-func (j *JavaFuzzLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+func (j *JavaFuzzTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if j.fuzzPackagedModule.FuzzProperties.Corpus != nil {
j.fuzzPackagedModule.Corpus = android.PathsForModuleSrc(ctx, j.fuzzPackagedModule.FuzzProperties.Corpus)
}
@@ -105,21 +105,15 @@
}
_, sharedDeps := cc.CollectAllSharedDependencies(ctx)
-
for _, dep := range sharedDeps {
sharedLibInfo := ctx.OtherModuleProvider(dep, cc.SharedLibraryInfoProvider).(cc.SharedLibraryInfo)
if sharedLibInfo.SharedLibrary != nil {
- // The .class jars are output in slightly different locations
- // relative to the jni libs. Therefore, for consistency across
- // host and device fuzzers of jni lib location, we save it in a
- // native_libs directory.
- var relPath string
+ arch := "lib"
if sharedLibInfo.Target.Arch.ArchType.Multilib == "lib64" {
- relPath = filepath.Join("lib64", sharedLibInfo.SharedLibrary.Base())
- } else {
- relPath = filepath.Join("lib", sharedLibInfo.SharedLibrary.Base())
+ arch = "lib64"
}
- libPath := android.PathForModuleOut(ctx, relPath)
+
+ libPath := android.PathForModuleOut(ctx, filepath.Join(arch, sharedLibInfo.SharedLibrary.Base()))
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: sharedLibInfo.SharedLibrary,
@@ -129,104 +123,37 @@
} else {
ctx.PropertyErrorf("jni_libs", "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
}
+
}
- j.Library.GenerateAndroidBuildActions(ctx)
+ j.Test.GenerateAndroidBuildActions(ctx)
}
-// java_fuzz_host builds and links sources into a `.jar` file for the host.
-//
-// By default, a java_fuzz produces a `.jar` file containing `.class` files.
-// This jar is not suitable for installing on a device.
-func JavaFuzzHostFactory() android.Module {
- module := &JavaFuzzLibrary{}
- module.addHostProperties()
- module.AddProperties(&module.jniProperties)
- module.Module.properties.Installable = proptools.BoolPtr(true)
- module.AddProperties(&module.fuzzPackagedModule.FuzzProperties)
-
- // java_fuzz packaging rules collide when both linux_glibc and linux_bionic are enabled, disable the linux_bionic variants.
- android.AddLoadHook(module, func(ctx android.LoadHookContext) {
- disableLinuxBionic := struct {
- Target struct {
- Linux_bionic struct {
- Enabled *bool
- }
- }
- }{}
- disableLinuxBionic.Target.Linux_bionic.Enabled = proptools.BoolPtr(false)
- ctx.AppendProperties(&disableLinuxBionic)
- })
-
- InitJavaModuleMultiTargets(module, android.HostSupportedNoCross)
- return module
-}
-
-// java_fuzz builds and links sources into a `.jar` file for the device.
-// This generates .class files in a jar which can then be instrumented before
-// fuzzing in Android Runtime (ART: Android OS on emulator or device)
-func JavaFuzzFactory() android.Module {
- module := &JavaFuzzLibrary{}
- module.addHostAndDeviceProperties()
- module.AddProperties(&module.jniProperties)
- module.Module.properties.Installable = proptools.BoolPtr(true)
- module.AddProperties(&module.fuzzPackagedModule.FuzzProperties)
- module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
- InitJavaModuleMultiTargets(module, android.DeviceSupported)
- return module
-}
-
-// Responsible for generating rules that package host fuzz targets into
-// a zip file.
-type javaFuzzHostPackager struct {
+type javaFuzzPackager struct {
fuzz.FuzzPackager
}
-// Responsible for generating rules that package device fuzz targets into
-// a zip file.
-type javaFuzzDevicePackager struct {
- fuzz.FuzzPackager
+func javaFuzzPackagingFactory() android.Singleton {
+ return &javaFuzzPackager{}
}
-func javaFuzzHostPackagingFactory() android.Singleton {
- return &javaFuzzHostPackager{}
-}
-
-func javaFuzzDevicePackagingFactory() android.Singleton {
- return &javaFuzzDevicePackager{}
-}
-
-func (s *javaFuzzHostPackager) GenerateBuildActions(ctx android.SingletonContext) {
- generateBuildActions(&s.FuzzPackager, hostString, ctx)
-}
-
-func (s *javaFuzzDevicePackager) GenerateBuildActions(ctx android.SingletonContext) {
- generateBuildActions(&s.FuzzPackager, targetString, ctx)
-}
-
-func generateBuildActions(s *fuzz.FuzzPackager, hostOrTargetString string, ctx android.SingletonContext) {
+func (s *javaFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
// Map between each architecture + host/device combination.
archDirs := make(map[fuzz.ArchOs][]fuzz.FileToZip)
- // List of individual fuzz targets.
s.FuzzTargets = make(map[string]bool)
-
ctx.VisitAllModules(func(module android.Module) {
// Discard non-fuzz targets.
- javaFuzzModule, ok := module.(*JavaFuzzLibrary)
+ javaFuzzModule, ok := module.(*JavaFuzzTest)
if !ok {
return
}
- if hostOrTargetString == hostString {
- if !javaFuzzModule.Host() {
- return
- }
- } else if hostOrTargetString == targetString {
- if javaFuzzModule.Host() || javaFuzzModule.Target().HostCross {
- return
- }
+ hostOrTargetString := "target"
+ if javaFuzzModule.Target().HostCross {
+ hostOrTargetString = "host_cross"
+ } else if javaFuzzModule.Host() {
+ hostOrTargetString = "host"
}
fuzzModuleValidator := fuzz.FuzzModule{
@@ -246,7 +173,7 @@
var files []fuzz.FileToZip
builder := android.NewRuleBuilder(pctx, ctx)
- // Package the artifacts (data, corpus, config and dictionary into a zipfile.
+ // Package the artifacts (data, corpus, config and dictionary) into a zipfile.
files = s.PackageArtifacts(ctx, module, javaFuzzModule.fuzzPackagedModule, archDir, builder)
// Add .jar
@@ -261,27 +188,14 @@
if !ok {
return
}
-
})
s.CreateFuzzPackage(ctx, archDirs, fuzz.Java, pctx)
}
-func (s *javaFuzzHostPackager) MakeVars(ctx android.MakeVarsContext) {
+func (s *javaFuzzPackager) MakeVars(ctx android.MakeVarsContext) {
packages := s.Packages.Strings()
sort.Strings(packages)
-
- ctx.Strict("SOONG_JAVA_FUZZ_HOST_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
-
+ ctx.Strict("SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
// Preallocate the slice of fuzz targets to minimize memory allocations.
- s.PreallocateSlice(ctx, "ALL_JAVA_FUZZ_HOST_TARGETS")
-}
-
-func (s *javaFuzzDevicePackager) MakeVars(ctx android.MakeVarsContext) {
- packages := s.Packages.Strings()
- sort.Strings(packages)
-
- ctx.Strict("SOONG_JAVA_FUZZ_DEVICE_PACKAGING_ARCH_MODULES", strings.Join(packages, " "))
-
- // Preallocate the slice of fuzz targets to minimize memory allocations.
- s.PreallocateSlice(ctx, "ALL_JAVA_FUZZ_DEVICE_TARGETS")
+ s.PreallocateSlice(ctx, "ALL_JAVA_FUZZ_TARGETS")
}
diff --git a/java/fuzz_test.go b/java/fuzz_test.go
index 186c3aa..dd1e96b 100644
--- a/java/fuzz_test.go
+++ b/java/fuzz_test.go
@@ -31,18 +31,16 @@
func TestJavaFuzz(t *testing.T) {
result := prepForJavaFuzzTest.RunTestWithBp(t, `
- java_fuzz_host {
+ java_fuzz {
name: "foo",
srcs: ["a.java"],
+ host_supported: true,
+ device_supported: false,
libs: ["bar"],
static_libs: ["baz"],
jni_libs: [
"libjni",
],
- sanitizers: [
- "address",
- "fuzzer",
- ],
}
java_library_host {
@@ -84,7 +82,7 @@
}
ctx := result.TestContext
- foo := ctx.ModuleForTests("foo", osCommonTarget).Module().(*JavaFuzzLibrary)
+ foo := ctx.ModuleForTests("foo", osCommonTarget).Module().(*JavaFuzzTest)
expected := "lib64/libjni.so"
if runtime.GOOS == "darwin" {
diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go
index 96e084a..e54275b 100644
--- a/java/hiddenapi_modular.go
+++ b/java/hiddenapi_modular.go
@@ -647,7 +647,7 @@
// public version is provided by the art.module.public.api module. In those cases it is necessary
// to treat all those modules as they were the same name, otherwise it will result in multiple
// definitions of a single class being passed to hidden API processing which will cause an error.
- if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule {
+ if name == scope.nonUpdatablePrebuiltModule || name == android.JavaApiLibraryName(ctx.Config(), scope.nonUpdatableSourceModule) {
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
// java_sdk_library.
// TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent.
diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go
index 52934a3..d4ee4fc 100644
--- a/java/hiddenapi_singleton.go
+++ b/java/hiddenapi_singleton.go
@@ -25,7 +25,7 @@
}
func RegisterHiddenApiSingletonComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory)
+ ctx.RegisterParallelSingletonType("hiddenapi", hiddenAPISingletonFactory)
}
var PrepareForTestWithHiddenApiBuildComponents = android.FixtureRegisterWithContext(RegisterHiddenApiSingletonComponents)
diff --git a/java/java.go b/java/java.go
index a98762c..a23526a 100644
--- a/java/java.go
+++ b/java/java.go
@@ -73,8 +73,8 @@
ctx.BottomUp("jacoco_deps", jacocoDepsMutator).Parallel()
})
- ctx.RegisterSingletonType("logtags", LogtagsSingleton)
- ctx.RegisterSingletonType("kythe_java_extract", kytheExtractJavaFactory)
+ ctx.RegisterParallelSingletonType("logtags", LogtagsSingleton)
+ ctx.RegisterParallelSingletonType("kythe_java_extract", kytheExtractJavaFactory)
}
func RegisterJavaSdkMemberTypes() {
@@ -1156,7 +1156,6 @@
}
j.addDataDeviceBinsDeps(ctx)
-
j.deps(ctx)
}
@@ -1651,7 +1650,7 @@
// list of api.txt files relative to this directory that contribute to the
// API surface.
// This is a list of relative paths
- Api_files []string
+ Api_files []string `android:"path"`
// List of flags to be passed to the javac compiler to generate jar file
Javacflags []string
@@ -1833,9 +1832,7 @@
// Add the api_files inputs
for _, api := range al.properties.Api_files {
- // Use MaybeExistentPathForSource since the api file might not exist during analysis.
- // This will be provided by the orchestrator in the combined execution.
- srcFiles = append(srcFiles, android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), api))
+ srcFiles = append(srcFiles, android.PathForModuleSrc(ctx, api))
}
if srcFiles == nil {
@@ -2609,6 +2606,7 @@
&appProperties{},
&appTestProperties{},
&overridableAppProperties{},
+ &hostTestProperties{},
&testProperties{},
&ImportProperties{},
&AARImportProperties{},
diff --git a/java/java_test.go b/java/java_test.go
index 2a4913e..ea89e6e 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2252,6 +2252,29 @@
android.AssertStringDoesContain(t, "Command expected to contain output files list text file flag", manifestCommand, "--out __SBOX_SANDBOX_DIR__/out/sources.txt")
}
+func TestJavaApiLibraryFilegroupInput(t *testing.T) {
+ ctx, _ := testJavaWithFS(t, `
+ filegroup {
+ name: "default_current.txt",
+ srcs: ["current.txt"],
+ }
+
+ java_api_library {
+ name: "foo",
+ api_files: [":default_current.txt"],
+ }
+ `,
+ map[string][]byte{
+ "current.txt": nil,
+ })
+
+ m := ctx.ModuleForTests("foo", "android_common")
+ outputs := fmt.Sprint(m.AllOutputs())
+ if !strings.Contains(outputs, "foo/foo.jar") {
+ t.Errorf("Module output does not contain expected jar %s", "foo/foo.jar")
+ }
+}
+
func TestTradefedOptions(t *testing.T) {
result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, `
java_test_host {
diff --git a/java/jdeps.go b/java/jdeps.go
index a52b867..4c8c11c 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -26,7 +26,7 @@
// called. Dependency info file is generated in $OUT/module_bp_java_depend.json.
func init() {
- android.RegisterSingletonType("jdeps_generator", jDepsGeneratorSingleton)
+ android.RegisterParallelSingletonType("jdeps_generator", jDepsGeneratorSingleton)
}
func jDepsGeneratorSingleton() android.Singleton {
diff --git a/java/lint.go b/java/lint.go
index 40ef484..a0f9970 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -705,7 +705,7 @@
var _ android.SingletonMakeVarsProvider = (*lintSingleton)(nil)
func init() {
- android.RegisterSingletonType("lint",
+ android.RegisterParallelSingletonType("lint",
func() android.Singleton { return &lintSingleton{} })
registerLintBuildComponents(android.InitRegistrationContext)
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index 07fb92c..0d4db7c 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -26,7 +26,7 @@
}
func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonModuleType("platform_bootclasspath", platformBootclasspathFactory)
+ ctx.RegisterParallelSingletonModuleType("platform_bootclasspath", platformBootclasspathFactory)
}
// The tags used for the dependencies between the platform bootclasspath and any configured boot
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index d417291..2197304 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -36,7 +36,7 @@
}
func registerPlatformCompatConfigBuildComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
+ ctx.RegisterParallelSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory)
ctx.RegisterModuleType("platform_compat_config", PlatformCompatConfigFactory)
ctx.RegisterModuleType("prebuilt_platform_compat_config", prebuiltCompatConfigFactory)
ctx.RegisterModuleType("global_compat_config", globalCompatConfigFactory)
diff --git a/java/robolectric.go b/java/robolectric.go
index 008b8b1..6bbe872 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -144,29 +144,37 @@
roboTestConfig := android.PathForModuleGen(ctx, "robolectric").
Join(ctx, "com/android/tools/test_config.properties")
+ var ok bool
+ var instrumentedApp *AndroidApp
+
// TODO: this inserts paths to built files into the test, it should really be inserting the contents.
instrumented := ctx.GetDirectDepsWithTag(instrumentationForTag)
- if len(instrumented) != 1 {
+ if len(instrumented) == 1 {
+ instrumentedApp, ok = instrumented[0].(*AndroidApp)
+ if !ok {
+ ctx.PropertyErrorf("instrumentation_for", "dependency must be an android_app")
+ }
+ } else if !ctx.Config().AllowMissingDependencies() {
panic(fmt.Errorf("expected exactly 1 instrumented dependency, got %d", len(instrumented)))
}
- instrumentedApp, ok := instrumented[0].(*AndroidApp)
- if !ok {
- ctx.PropertyErrorf("instrumentation_for", "dependency must be an android_app")
+ if instrumentedApp != nil {
+ r.manifest = instrumentedApp.mergedManifestFile
+ r.resourceApk = instrumentedApp.outputFile
+
+ generateRoboTestConfig(ctx, roboTestConfig, instrumentedApp)
+ r.extraResources = android.Paths{roboTestConfig}
}
- r.manifest = instrumentedApp.mergedManifestFile
- r.resourceApk = instrumentedApp.outputFile
-
- generateRoboTestConfig(ctx, roboTestConfig, instrumentedApp)
- r.extraResources = android.Paths{roboTestConfig}
-
r.Library.GenerateAndroidBuildActions(ctx)
roboSrcJar := android.PathForModuleGen(ctx, "robolectric", ctx.ModuleName()+".srcjar")
- r.generateRoboSrcJar(ctx, roboSrcJar, instrumentedApp)
- r.roboSrcJar = roboSrcJar
+
+ if instrumentedApp != nil {
+ r.generateRoboSrcJar(ctx, roboSrcJar, instrumentedApp)
+ r.roboSrcJar = roboSrcJar
+ }
roboTestConfigJar := android.PathForModuleOut(ctx, "robolectric_samedir", "samedir_config.jar")
generateSameDirRoboTestConfigJar(ctx, roboTestConfigJar)
@@ -177,7 +185,10 @@
// once the Make test runner is removed.
roboTestConfigJar,
r.outputFile,
- instrumentedApp.implementationAndResourcesJar,
+ }
+
+ if instrumentedApp != nil {
+ combinedJarJars = append(combinedJarJars, instrumentedApp.implementationAndResourcesJar)
}
handleLibDeps := func(dep android.Module) {
@@ -213,21 +224,28 @@
r.tests = append(r.tests, s)
}
- r.data = append(r.data, r.manifest, r.resourceApk)
+ installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
+ var installDeps android.Paths
+
+ if r.manifest != nil {
+ r.data = append(r.data, r.manifest)
+ installedManifest := ctx.InstallFile(installPath, ctx.ModuleName()+"-AndroidManifest.xml", r.manifest)
+ installDeps = append(installDeps, installedManifest)
+ }
+
+ if r.resourceApk != nil {
+ r.data = append(r.data, r.resourceApk)
+ installedResourceApk := ctx.InstallFile(installPath, ctx.ModuleName()+".apk", r.resourceApk)
+ installDeps = append(installDeps, installedResourceApk)
+ }
runtimes := ctx.GetDirectDepWithTag("robolectric-android-all-prebuilts", roboRuntimesTag)
-
- installPath := android.PathForModuleInstall(ctx, r.BaseModuleName())
-
- installedResourceApk := ctx.InstallFile(installPath, ctx.ModuleName()+".apk", r.resourceApk)
- installedManifest := ctx.InstallFile(installPath, ctx.ModuleName()+"-AndroidManifest.xml", r.manifest)
- installedConfig := ctx.InstallFile(installPath, ctx.ModuleName()+".config", r.testConfig)
-
- var installDeps android.Paths
for _, runtime := range runtimes.(*robolectricRuntimes).runtimes {
installDeps = append(installDeps, runtime)
}
- installDeps = append(installDeps, installedResourceApk, installedManifest, installedConfig)
+
+ installedConfig := ctx.InstallFile(installPath, ctx.ModuleName()+".config", r.testConfig)
+ installDeps = append(installDeps, installedConfig)
for _, data := range android.PathsForModuleSrc(ctx, r.testProperties.Data) {
installedData := ctx.InstallFile(installPath, data.Rel(), data)
@@ -340,7 +358,9 @@
fmt.Fprintln(w, "LOCAL_MODULE :=", name)
android.AndroidMkEmitAssignList(w, "LOCAL_JAVA_LIBRARIES", []string{module}, r.libs)
fmt.Fprintln(w, "LOCAL_TEST_PACKAGE :=", String(r.robolectricProperties.Instrumentation_for))
- fmt.Fprintln(w, "LOCAL_INSTRUMENT_SRCJARS :=", r.roboSrcJar.String())
+ if r.roboSrcJar != nil {
+ fmt.Fprintln(w, "LOCAL_INSTRUMENT_SRCJARS :=", r.roboSrcJar.String())
+ }
android.AndroidMkEmitAssignList(w, "LOCAL_ROBOTEST_FILES", tests)
if t := r.robolectricProperties.Test_options.Timeout; t != nil {
fmt.Fprintln(w, "LOCAL_ROBOTEST_TIMEOUT :=", *t)
diff --git a/java/sdk.go b/java/sdk.go
index 8b4918a..7fa604f 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -28,7 +28,7 @@
func init() {
android.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
- android.RegisterSingletonType("sdk", sdkSingletonFactory)
+ android.RegisterParallelSingletonType("sdk", sdkSingletonFactory)
android.RegisterMakeVarsProvider(pctx, sdkMakeVars)
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 103f1ac..89da19a 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -156,6 +156,9 @@
// Whether the api scope can be treated as unstable, and should skip compat checks.
unstable bool
+
+ // Represents the SDK kind of this scope.
+ kind android.SdkKind
}
// Initialize a scope, creating and adding appropriate dependency tags
@@ -229,6 +232,10 @@
return ".stubs" + scope.moduleSuffix
}
+func (scope *apiScope) apiLibraryModuleName(baseName string) string {
+ return scope.stubsLibraryModuleName(baseName) + ".from-text"
+}
+
func (scope *apiScope) stubsLibraryModuleName(baseName string) string {
return baseName + scope.stubsLibraryModuleNameSuffix()
}
@@ -289,6 +296,7 @@
return &module.sdkLibraryProperties.Public
},
sdkVersion: "current",
+ kind: android.SdkPublic,
})
apiScopeSystem = initApiScope(&apiScope{
name: "system",
@@ -301,6 +309,7 @@
moduleSuffix: ".system",
sdkVersion: "system_current",
annotation: "android.annotation.SystemApi(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS)",
+ kind: android.SdkSystem,
})
apiScopeTest = initApiScope(&apiScope{
name: "test",
@@ -314,6 +323,7 @@
sdkVersion: "test_current",
annotation: "android.annotation.TestApi",
unstable: true,
+ kind: android.SdkTest,
})
apiScopeModuleLib = initApiScope(&apiScope{
name: "module-lib",
@@ -331,6 +341,7 @@
moduleSuffix: ".module_lib",
sdkVersion: "module_current",
annotation: "android.annotation.SystemApi(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES)",
+ kind: android.SdkModule,
})
apiScopeSystemServer = initApiScope(&apiScope{
name: "system-server",
@@ -361,6 +372,7 @@
// com.android.* classes are okay in this interface"
"--hide", "InternalClasses",
},
+ kind: android.SdkSystemServer,
})
allApiScopes = apiScopes{
apiScopePublic,
@@ -842,6 +854,13 @@
return c.namingScheme.stubsSourceModuleName(apiScope, baseName)
}
+// Name of the java_api_library module that generates the from-text stubs source
+// and compiles to a jar file.
+func (c *commonToSdkLibraryAndImport) apiLibraryModuleName(apiScope *apiScope) string {
+ baseName := c.module.BaseModuleName()
+ return c.namingScheme.apiLibraryModuleName(apiScope, baseName)
+}
+
// The component names for different outputs of the java_sdk_library.
//
// They are similar to the names used for the child modules it creates
@@ -1269,7 +1288,9 @@
// Add dependencies to the stubs library
stubModuleName := module.stubsLibraryModuleName(apiScope)
// Use JavaApiLibraryName function to be redirected to stubs generated from .txt if applicable
- stubModuleName = android.JavaApiLibraryName(ctx.Config(), stubModuleName)
+ if module.contributesToApiSurface(ctx.Config()) {
+ stubModuleName = android.JavaApiLibraryName(ctx.Config(), stubModuleName)
+ }
ctx.AddVariationDependencies(nil, apiScope.stubsTag, stubModuleName)
// Add a dependency on the stubs source in order to access both stubs source and api information.
@@ -1477,6 +1498,11 @@
return latestPrebuiltApiModuleName(module.distStem()+"-incompatibilities", apiScope)
}
+func (module *SdkLibrary) contributesToApiSurface(c android.Config) bool {
+ _, exists := c.GetApiLibraries()[module.Name()]
+ return exists
+}
+
func childModuleVisibility(childVisibility []string) []string {
if childVisibility == nil {
// No child visibility set. The child will use the visibility of the sdk_library.
@@ -1758,6 +1784,46 @@
mctx.CreateModule(DroidstubsFactory, &props).(*Droidstubs).CallHookIfAvailable(mctx)
}
+func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
+ props := struct {
+ Name *string
+ Visibility []string
+ Api_contributions []string
+ Libs []string
+ Static_libs []string
+ Dep_api_srcs *string
+ }{}
+
+ props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
+ props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
+
+ apiContributions := []string{}
+
+ // Api surfaces are not independent of each other, but have subset relationships,
+ // and so does the api files. To generate from-text stubs for api surfaces other than public,
+ // all subset api domains' api_contriubtions must be added as well.
+ scope := apiScope
+ for scope != nil {
+ apiContributions = append(apiContributions, module.stubsSourceModuleName(scope)+".api.contribution")
+ scope = scope.extends
+ }
+
+ props.Api_contributions = apiContributions
+ props.Libs = module.properties.Libs
+ props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
+ props.Libs = append(props.Libs, "stub-annotations")
+ props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
+ props.Dep_api_srcs = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + ".from-text")
+
+ // android_module_lib_stubs_current.from-text only comprises api contributions from art, conscrypt and i18n.
+ // Thus, replace with android_module_lib_stubs_current_full.from-text, which comprises every api domains.
+ if apiScope.kind == android.SdkModule {
+ props.Dep_api_srcs = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + "_full.from-text")
+ }
+
+ mctx.CreateModule(ApiLibraryFactory, &props)
+}
+
func (module *SdkLibrary) compareAgainstLatestApi(apiScope *apiScope) bool {
return !(apiScope.unstable || module.sdkLibraryProperties.Unsafe_ignore_missing_latest_api)
}
@@ -1954,6 +2020,10 @@
module.createStubsSourcesAndApi(mctx, scope, module.stubsSourceModuleName(scope), scope.droidstubsArgs)
module.createStubsLibrary(mctx, scope)
+
+ if module.contributesToApiSurface(mctx.Config()) {
+ module.createApiLibrary(mctx, scope)
+ }
}
if module.requiresRuntimeImplementationLibrary() {
@@ -2006,6 +2076,8 @@
stubsLibraryModuleName(scope *apiScope, baseName string) string
stubsSourceModuleName(scope *apiScope, baseName string) string
+
+ apiLibraryModuleName(scope *apiScope, baseName string) string
}
type defaultNamingScheme struct {
@@ -2019,6 +2091,10 @@
return scope.stubsSourceModuleName(baseName)
}
+func (s *defaultNamingScheme) apiLibraryModuleName(scope *apiScope, baseName string) string {
+ return scope.apiLibraryModuleName(baseName)
+}
+
var _ sdkLibraryComponentNamingScheme = (*defaultNamingScheme)(nil)
func moduleStubLinkType(name string) (stub bool, ret sdkLinkType) {
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 1d0c13d..141e16b 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -35,6 +35,9 @@
"29": {"foo"},
"30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"},
}),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
+ }),
).RunTestWithBp(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -121,6 +124,7 @@
result.ModuleForTests(apiScopeSystem.stubsSourceModuleName("foo"), "android_common")
result.ModuleForTests(apiScopeTest.stubsSourceModuleName("foo"), "android_common")
result.ModuleForTests(apiScopePublic.stubsSourceModuleName("foo")+".api.contribution", "")
+ result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common")
result.ModuleForTests("foo"+sdkXmlFileSuffix, "android_common")
result.ModuleForTests("foo.api.public.28", "")
result.ModuleForTests("foo.api.system.28", "")
@@ -1412,3 +1416,62 @@
fooStubsSources := result.ModuleForTests("foo.stubs.source", "android_common").Module().(*Droidstubs)
android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
}
+
+func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.SetApiLibraries([]string{"foo"})
+ }),
+ ).RunTestWithBp(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["a.java", "b.java"],
+ api_packages: ["foo"],
+ system: {
+ enabled: true,
+ },
+ module_lib: {
+ enabled: true,
+ },
+ test: {
+ enabled: true,
+ },
+ }
+ `)
+
+ testCases := []struct {
+ scope *apiScope
+ apiContributions []string
+ depApiSrcs string
+ }{
+ {
+ scope: apiScopePublic,
+ apiContributions: []string{"foo.stubs.source.api.contribution"},
+ depApiSrcs: "android_stubs_current.from-text",
+ },
+ {
+ scope: apiScopeSystem,
+ apiContributions: []string{"foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
+ depApiSrcs: "android_system_stubs_current.from-text",
+ },
+ {
+ scope: apiScopeTest,
+ apiContributions: []string{"foo.stubs.source.test.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
+ depApiSrcs: "android_test_stubs_current.from-text",
+ },
+ {
+ scope: apiScopeModuleLib,
+ apiContributions: []string{"foo.stubs.source.module_lib.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
+ depApiSrcs: "android_module_lib_stubs_current_full.from-text",
+ },
+ }
+
+ for _, c := range testCases {
+ m := result.ModuleForTests(c.scope.apiLibraryModuleName("foo"), "android_common").Module().(*ApiLibrary)
+ android.AssertArrayString(t, "Module expected to contain api contributions", c.apiContributions, m.properties.Api_contributions)
+ android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.depApiSrcs, *m.properties.Dep_api_srcs)
+ }
+}
diff --git a/java/testing.go b/java/testing.go
index 6671bf0..3a238d7 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -71,7 +71,12 @@
// Needed for framework
defaultJavaDir + "/framework/aidl": nil,
// Needed for various deps defined in GatherRequiredDepsForTest()
- defaultJavaDir + "/a.java": nil,
+ defaultJavaDir + "/a.java": nil,
+ defaultJavaDir + "/api/current.txt": nil,
+ defaultJavaDir + "/api/system-current.txt": nil,
+ defaultJavaDir + "/api/test-current.txt": nil,
+ defaultJavaDir + "/api/module-lib-current.txt": nil,
+ defaultJavaDir + "/api/system-server-current.txt": nil,
// Needed for R8 rules on apps
"build/make/core/proguard.flags": nil,
@@ -395,16 +400,20 @@
}
extraApiLibraryModules := map[string]string{
- "android_stubs_current.from-text": "api/current.txt",
- "android_system_stubs_current.from-text": "api/system-current.txt",
- "android_test_stubs_current.from-text": "api/test-current.txt",
- "android_module_lib_stubs_current.from-text": "api/module-lib-current.txt",
- "android_module_lib_stubs_current_full.from-text": "api/module-lib-current.txt",
- "android_system_server_stubs_current.from-text": "api/system-server-current.txt",
- "core.current.stubs.from-text": "api/current.txt",
- "legacy.core.platform.api.stubs.from-text": "api/current.txt",
- "stable.core.platform.api.stubs.from-text": "api/current.txt",
- "core-lambda-stubs.from-text": "api/current.txt",
+ "android_stubs_current.from-text": "api/current.txt",
+ "android_system_stubs_current.from-text": "api/system-current.txt",
+ "android_test_stubs_current.from-text": "api/test-current.txt",
+ "android_module_lib_stubs_current.from-text": "api/module-lib-current.txt",
+ "android_module_lib_stubs_current_full.from-text": "api/module-lib-current.txt",
+ "android_system_server_stubs_current.from-text": "api/system-server-current.txt",
+ "core.current.stubs.from-text": "api/current.txt",
+ "legacy.core.platform.api.stubs.from-text": "api/current.txt",
+ "stable.core.platform.api.stubs.from-text": "api/current.txt",
+ "core-lambda-stubs.from-text": "api/current.txt",
+ "android-non-updatable.stubs.from-text": "api/current.txt",
+ "android-non-updatable.stubs.system.from-text": "api/system-current.txt",
+ "android-non-updatable.stubs.test.from-text": "api/test-current.txt",
+ "android-non-updatable.stubs.module_lib.from-text": "api/module-lib-current.txt",
}
for libName, apiFile := range extraApiLibraryModules {
diff --git a/multitree/metadata.go b/multitree/metadata.go
index 3fd7215..0eb0efc 100644
--- a/multitree/metadata.go
+++ b/multitree/metadata.go
@@ -20,7 +20,7 @@
)
func init() {
- android.RegisterSingletonType("update-meta", UpdateMetaSingleton)
+ android.RegisterParallelSingletonType("update-meta", UpdateMetaSingleton)
}
func UpdateMetaSingleton() android.Singleton {
diff --git a/provenance/provenance_singleton.go b/provenance/provenance_singleton.go
index fbb6212..5d27c0c 100644
--- a/provenance/provenance_singleton.go
+++ b/provenance/provenance_singleton.go
@@ -51,7 +51,7 @@
}
func RegisterProvenanceSingleton(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("provenance_metadata_singleton", provenanceInfoSingletonFactory)
+ ctx.RegisterParallelSingletonType("provenance_metadata_singleton", provenanceInfoSingletonFactory)
}
var PrepareForTestWithProvenanceSingleton = android.FixtureRegisterWithContext(RegisterProvenanceSingleton)
diff --git a/python/test.go b/python/test.go
index 31da17e..6e23a44 100644
--- a/python/test.go
+++ b/python/test.go
@@ -39,7 +39,7 @@
}
func PythonTestHostFactory() android.Module {
- return NewTest(android.HostSupportedNoCross).init()
+ return NewTest(android.HostSupported).init()
}
func PythonTestFactory() android.Module {
@@ -66,6 +66,10 @@
// Test options.
Test_options TestOptions
+
+ // list of device binary modules that should be installed alongside the test
+ // This property adds 64bit AND 32bit variants of the dependency
+ Data_device_bins_both []string `android:"arch_variant"`
}
type TestOptions struct {
@@ -98,12 +102,48 @@
android.InitAndroidArchModule(p, p.hod, p.multilib)
android.InitDefaultableModule(p)
android.InitBazelModule(p)
- if p.hod == android.HostSupportedNoCross && p.testProperties.Test_options.Unit_test == nil {
+ if p.isTestHost() && p.testProperties.Test_options.Unit_test == nil {
p.testProperties.Test_options.Unit_test = proptools.BoolPtr(true)
}
return p
}
+func (p *PythonTestModule) isTestHost() bool {
+ return p.hod == android.HostSupported
+}
+
+var dataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
+
+// python_test_host DepsMutator uses this method to add multilib dependencies of
+// data_device_bin_both
+func (p *PythonTestModule) addDataDeviceBinsDeps(ctx android.BottomUpMutatorContext, filter string) {
+ if len(p.testProperties.Data_device_bins_both) < 1 {
+ return
+ }
+
+ var maybeAndroidTarget *android.Target
+ androidTargetList := android.FirstTarget(ctx.Config().Targets[android.Android], filter)
+ if len(androidTargetList) > 0 {
+ maybeAndroidTarget = &androidTargetList[0]
+ }
+
+ if maybeAndroidTarget != nil {
+ ctx.AddFarVariationDependencies(
+ maybeAndroidTarget.Variations(),
+ dataDeviceBinsTag,
+ p.testProperties.Data_device_bins_both...,
+ )
+ }
+}
+
+func (p *PythonTestModule) DepsMutator(ctx android.BottomUpMutatorContext) {
+ p.PythonBinaryModule.DepsMutator(ctx)
+ if p.isTestHost() {
+ p.addDataDeviceBinsDeps(ctx, "lib32")
+ p.addDataDeviceBinsDeps(ctx, "lib64")
+ }
+}
+
func (p *PythonTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// We inherit from only the library's GenerateAndroidBuildActions, and then
// just use buildBinary() so that the binary is not installed into the location
@@ -153,6 +193,12 @@
p.data = append(p.data, android.DataPath{SrcPath: dataSrcPath})
}
+ if p.isTestHost() && len(p.testProperties.Data_device_bins_both) > 0 {
+ ctx.VisitDirectDepsWithTag(dataDeviceBinsTag, func(dep android.Module) {
+ p.data = append(p.data, android.DataPath{SrcPath: android.OutputFileForModule(ctx, dep, "")})
+ })
+ }
+
// Emulate the data property for java_data dependencies.
for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) {
for _, javaDataSrcPath := range android.OutputFilesForModule(ctx, javaData, "") {
diff --git a/rust/doc.go b/rust/doc.go
index fe3581b..6970d79 100644
--- a/rust/doc.go
+++ b/rust/doc.go
@@ -19,7 +19,7 @@
)
func init() {
- android.RegisterSingletonType("rustdoc", RustdocSingleton)
+ android.RegisterParallelSingletonType("rustdoc", RustdocSingleton)
}
func RustdocSingleton() android.Singleton {
diff --git a/rust/project_json.go b/rust/project_json.go
index fe259d6..40aa7c7 100644
--- a/rust/project_json.go
+++ b/rust/project_json.go
@@ -74,7 +74,7 @@
}
func init() {
- android.RegisterSingletonType("rust_project_generator", rustProjectGeneratorSingleton)
+ android.RegisterParallelSingletonType("rust_project_generator", rustProjectGeneratorSingleton)
}
// sourceProviderVariantSource returns the path to the source file if this
diff --git a/rust/rust.go b/rust/rust.go
index dc53cc0..4324ecb 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -45,7 +45,7 @@
})
pctx.Import("android/soong/rust/config")
pctx.ImportAs("cc_config", "android/soong/cc/config")
- android.InitRegistrationContext.RegisterSingletonType("kythe_rust_extract", kytheExtractRustFactory)
+ android.InitRegistrationContext.RegisterParallelSingletonType("kythe_rust_extract", kytheExtractRustFactory)
}
type Flags struct {
diff --git a/rust/testing.go b/rust/testing.go
index 0a6a870..7f30569 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -200,8 +200,8 @@
ctx.BottomUp("rust_stdlinkage", LibstdMutator).Parallel()
ctx.BottomUp("rust_begin", BeginMutator).Parallel()
})
- ctx.RegisterSingletonType("rust_project_generator", rustProjectGeneratorSingleton)
- ctx.RegisterSingletonType("kythe_rust_extract", kytheExtractRustFactory)
+ ctx.RegisterParallelSingletonType("rust_project_generator", rustProjectGeneratorSingleton)
+ ctx.RegisterParallelSingletonType("kythe_rust_extract", kytheExtractRustFactory)
ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("rust_sanitizers", rustSanitizerRuntimeMutator).Parallel()
})
diff --git a/snapshot/host_fake_snapshot.go b/snapshot/host_fake_snapshot.go
index b04657d..c4cfbb5 100644
--- a/snapshot/host_fake_snapshot.go
+++ b/snapshot/host_fake_snapshot.go
@@ -75,7 +75,7 @@
}
func registerHostSnapshotComponents(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("host-fake-snapshot", HostToolsFakeAndroidSingleton)
+ ctx.RegisterParallelSingletonType("host-fake-snapshot", HostToolsFakeAndroidSingleton)
}
type hostFakeSingleton struct {
diff --git a/snapshot/recovery_snapshot.go b/snapshot/recovery_snapshot.go
index ac002be..8ff59cb 100644
--- a/snapshot/recovery_snapshot.go
+++ b/snapshot/recovery_snapshot.go
@@ -68,7 +68,7 @@
type RecoverySnapshotImage struct{}
func (RecoverySnapshotImage) Init(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
+ ctx.RegisterParallelSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
}
func (RecoverySnapshotImage) RegisterAdditionalModule(ctx android.RegistrationContext, name string, factory android.ModuleFactory) {
diff --git a/snapshot/vendor_snapshot.go b/snapshot/vendor_snapshot.go
index 8f7b8c2..4484c85 100644
--- a/snapshot/vendor_snapshot.go
+++ b/snapshot/vendor_snapshot.go
@@ -78,8 +78,8 @@
type VendorSnapshotImage struct{}
func (VendorSnapshotImage) Init(ctx android.RegistrationContext) {
- ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
- ctx.RegisterSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton)
+ ctx.RegisterParallelSingletonType("vendor-snapshot", VendorSnapshotSingleton)
+ ctx.RegisterParallelSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton)
}
func (VendorSnapshotImage) RegisterAdditionalModule(ctx android.RegistrationContext, name string, factory android.ModuleFactory) {
diff --git a/tests/bootstrap_test.sh b/tests/bootstrap_test.sh
index 5935247..5fc05f8 100755
--- a/tests/bootstrap_test.sh
+++ b/tests/bootstrap_test.sh
@@ -207,8 +207,8 @@
function test_soong_build_rerun_iff_environment_changes() {
setup
- mkdir -p cherry
- cat > cherry/Android.bp <<'EOF'
+ mkdir -p build/soong/cherry
+ cat > build/soong/cherry/Android.bp <<'EOF'
bootstrap_go_package {
name: "cherry",
pkgPath: "android/soong/cherry",
@@ -224,7 +224,7 @@
}
EOF
- cat > cherry/cherry.go <<'EOF'
+ cat > build/soong/cherry/cherry.go <<'EOF'
package cherry
import (
@@ -317,8 +317,8 @@
run_soong
local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
- mkdir -p a
- cat > a/Android.bp <<'EOF'
+ mkdir -p vendor/foo/picard
+ cat > vendor/foo/picard/Android.bp <<'EOF'
bootstrap_go_package {
name: "picard-soong-rules",
pkgPath: "android/soong/picard",
@@ -334,7 +334,7 @@
}
EOF
- cat > a/picard.go <<'EOF'
+ cat > vendor/foo/picard/picard.go <<'EOF'
package picard
import (
@@ -390,11 +390,11 @@
function test_glob_during_bootstrapping() {
setup
- mkdir -p a
- cat > a/Android.bp <<'EOF'
+ mkdir -p build/soong/picard
+ cat > build/soong/picard/Android.bp <<'EOF'
build=["foo*.bp"]
EOF
- cat > a/fooa.bp <<'EOF'
+ cat > build/soong/picard/fooa.bp <<'EOF'
bootstrap_go_package {
name: "picard-soong-rules",
pkgPath: "android/soong/picard",
@@ -410,7 +410,7 @@
}
EOF
- cat > a/picard.go <<'EOF'
+ cat > build/soong/picard/picard.go <<'EOF'
package picard
import (
@@ -459,7 +459,7 @@
grep -q "Make it so" out/soong/build.ninja || fail "Original action not present"
- cat > a/foob.bp <<'EOF'
+ cat > build/soong/picard/foob.bp <<'EOF'
bootstrap_go_package {
name: "worf-soong-rules",
pkgPath: "android/soong/worf",
@@ -476,7 +476,7 @@
}
EOF
- cat > a/worf.go <<'EOF'
+ cat > build/soong/picard/worf.go <<'EOF'
package worf
import "android/soong/picard"
diff --git a/tests/dcla_apex_comparison_test.sh b/tests/dcla_apex_comparison_test.sh
index 97ae97e..667dde0 100755
--- a/tests/dcla_apex_comparison_test.sh
+++ b/tests/dcla_apex_comparison_test.sh
@@ -45,6 +45,11 @@
com.android.tethering
)
+BAZEL_TARGETS=(
+ //packages/modules/adb/apex:com.android.adbd
+ //frameworks/av/apex:com.android.media.swcodec
+)
+
DCLA_LIBS=(
libbase.so
libc++.so
@@ -76,6 +81,10 @@
############
OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
+function call_bazel() {
+ build/bazel/bin/bazel $@
+}
+
function cleanup {
rm -rf "${OUTPUT_DIR}"
}
@@ -87,7 +96,9 @@
function extract_dcla_libs() {
local product=$1; shift
- for module in "${MODULES[@]}"; do
+ local modules=("$@"); shift
+
+ for module in "${modules[@]}"; do
local apex="${OUTPUT_DIR}/${product}/${module}.apex"
local extract_dir="${OUTPUT_DIR}/${product}/${module}/extract"
@@ -97,11 +108,12 @@
function compare_dcla_libs() {
local product=$1; shift
+ local modules=("$@"); shift
for lib in "${DCLA_LIBS[@]}"; do
for arch in lib lib64; do
local prev_sha=""
- for module in "${MODULES[@]}"; do
+ for module in "${modules[@]}"; do
local file="${OUTPUT_DIR}/${product}/${module}/extract/${arch}/${lib}"
if [[ ! -f "${file}" ]]; then
# not all libs are present in a module
@@ -112,7 +124,7 @@
sha="${sha% *}"
if [ "${prev_sha}" == "" ]; then
prev_sha="${sha}"
- elif [ "${sha}" != "${prev_sha}" ] && { [ "${lib}" != "libcrypto.so" ] || [ "${module}" != "com.android.tethering" ]; }; then
+ elif [ "${sha}" != "${prev_sha}" ] && { [ "${lib}" != "libcrypto.so" ] || [[ "${module}" != *"com.android.tethering" ]]; }; then
echo "Test failed, ${lib} has different hash value"
exit 1
fi
@@ -131,8 +143,22 @@
--product "${product}" \
--dist_dir "${OUTPUT_DIR}/${product}"
- extract_dcla_libs "${product}"
- compare_dcla_libs "${product}"
+ bazel_apexes=()
+ if [[ -n ${TEST_BAZEL+x} ]] && [ "${TEST_BAZEL}" = true ]; then
+ export TARGET_PRODUCT="${product/module/aosp}"
+ call_bazel build --config=bp2build --config=ci --config=android "${BAZEL_TARGETS[@]}"
+ for target in "${BAZEL_TARGETS[@]}"; do
+ apex_path="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files $target))"
+ mkdir -p ${OUTPUT_DIR}/${product}
+ bazel_apex="bazel_$(basename $apex_path)"
+ mv $apex_path ${OUTPUT_DIR}/${product}/${bazel_apex}
+ bazel_apexes+=(${bazel_apex%".apex"})
+ done
+ fi
+
+ all_modeuls=(${MODULES[@]} ${bazel_apexes[@]})
+ extract_dcla_libs "${product}" "${all_modeuls[@]}"
+ compare_dcla_libs "${product}" "${all_modeuls[@]}"
done
echo "Test passed"
diff --git a/tests/lib.sh b/tests/lib.sh
index 715eac1..7f3970e 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -99,6 +99,7 @@
symlink_directory external/python
symlink_directory external/sqlite
symlink_directory external/spdx-tools
+ symlink_directory libcore
touch "$MOCK_TOP/Android.bp"
}
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index e1aa70c..db14bd4 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -15,8 +15,8 @@
# mock client.
"$TOP/build/soong/tests/apex_comparison_tests.sh"
"$TOP/build/soong/tests/apex_comparison_tests.sh" "module_arm64only"
-extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
-BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
+TEST_BAZEL=true extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
+#BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh"
"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_arm" "armv7-a"
"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_cf_arm64_phone" "armv8-a" "cortex-a53"
diff --git a/ui/build/config.go b/ui/build/config.go
index 6b6ce71..8ec9680 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -316,9 +316,8 @@
func NewConfig(ctx Context, args ...string) Config {
ret := &configImpl{
- environ: OsEnvironment(),
- sandboxConfig: &SandboxConfig{},
- ninjaWeightListSource: HINT_FROM_SOONG,
+ environ: OsEnvironment(),
+ sandboxConfig: &SandboxConfig{},
}
// Default matching ninja
diff --git a/ui/build/kati.go b/ui/build/kati.go
index dad68fa..aea56d3 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -22,6 +22,7 @@
"os/user"
"path/filepath"
"strings"
+ "time"
"android/soong/ui/metrics"
"android/soong/ui/status"
@@ -66,6 +67,21 @@
}
}
+func writeValueIfChanged(ctx Context, config Config, dir string, filename string, value string) {
+ filePath := filepath.Join(dir, filename)
+ previousValue := ""
+ rawPreviousValue, err := ioutil.ReadFile(filePath)
+ if err == nil {
+ previousValue = string(rawPreviousValue)
+ }
+
+ if previousValue != value {
+ if err = ioutil.WriteFile(filePath, []byte(value), 0666); err != nil {
+ ctx.Fatalf("Failed to write: %v", err)
+ }
+ }
+}
+
// Base function to construct and run the Kati command line with additional
// arguments, and a custom function closure to mutate the environment Kati runs
// in.
@@ -157,28 +173,60 @@
}
cmd.Stderr = cmd.Stdout
- // Apply the caller's function closure to mutate the environment variables.
- envFunc(cmd.Environment)
-
+ var username string
// Pass on various build environment metadata to Kati.
- if _, ok := cmd.Environment.Get("BUILD_USERNAME"); !ok {
- username := "unknown"
+ if usernameFromEnv, ok := cmd.Environment.Get("BUILD_USERNAME"); !ok {
+ username = "unknown"
if u, err := user.Current(); err == nil {
username = u.Username
} else {
ctx.Println("Failed to get current user:", err)
}
cmd.Environment.Set("BUILD_USERNAME", username)
+ } else {
+ username = usernameFromEnv
}
- if _, ok := cmd.Environment.Get("BUILD_HOSTNAME"); !ok {
- hostname, err := os.Hostname()
+ hostname, ok := cmd.Environment.Get("BUILD_HOSTNAME")
+ // Unset BUILD_HOSTNAME during kati run to avoid kati rerun, kati will use BUILD_HOSTNAME from a file.
+ cmd.Environment.Unset("BUILD_HOSTNAME")
+ if !ok {
+ hostname, err = os.Hostname()
if err != nil {
ctx.Println("Failed to read hostname:", err)
hostname = "unknown"
}
- cmd.Environment.Set("BUILD_HOSTNAME", hostname)
}
+ writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_hostname.txt", hostname)
+
+ // BUILD_NUMBER should be set to the source control value that
+ // represents the current state of the source code. E.g., a
+ // perforce changelist number or a git hash. Can be an arbitrary string
+ // (to allow for source control that uses something other than numbers),
+ // but must be a single word and a valid file name.
+ //
+ // If no BUILD_NUMBER is set, create a useful "I am an engineering build
+ // from this date/time" value. Make it start with a non-digit so that
+ // anyone trying to parse it as an integer will probably get "0".
+ cmd.Environment.Unset("HAS_BUILD_NUMBER")
+ buildNumber, ok := cmd.Environment.Get("BUILD_NUMBER")
+ // Unset BUILD_NUMBER during kati run to avoid kati rerun, kati will use BUILD_NUMBER from a file.
+ cmd.Environment.Unset("BUILD_NUMBER")
+ if ok {
+ cmd.Environment.Set("HAS_BUILD_NUMBER", "true")
+ writeValueIfChanged(ctx, config, config.OutDir(), "file_name_tag.txt", buildNumber)
+ } else {
+ buildNumber = fmt.Sprintf("eng.%.6s.%s", username, time.Now().Format("20060102.150405" /* YYYYMMDD.HHMMSS */))
+ cmd.Environment.Set("HAS_BUILD_NUMBER", "false")
+ writeValueIfChanged(ctx, config, config.OutDir(), "file_name_tag.txt", username)
+ }
+ // Write the build number to a file so it can be read back in
+ // without changing the command line every time. Avoids rebuilds
+ // when using ninja.
+ writeValueIfChanged(ctx, config, config.SoongOutDir(), "build_number.txt", buildNumber)
+
+ // Apply the caller's function closure to mutate the environment variables.
+ envFunc(cmd.Environment)
cmd.StartOrFatal()
// Set up the ToolStatus command line reader for Kati for a consistent UI
@@ -336,6 +384,7 @@
"ANDROID_BUILD_SHELL",
"DIST_DIR",
"OUT_DIR",
+ "FILE_NAME_TAG",
}...)
if config.Dist() {