Merge "Add critical path infomation into metrics"
diff --git a/android/Android.bp b/android/Android.bp
index 29a88f2..641c438 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -111,6 +111,7 @@
"depset_test.go",
"deptag_test.go",
"expand_test.go",
+ "filegroup_test.go",
"fixture_test.go",
"gen_notice_test.go",
"license_kind_test.go",
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 63495bc..45b8043 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -218,6 +218,7 @@
"hardware/interfaces": Bp2BuildDefaultTrue,
"hardware/interfaces/audio/aidl": Bp2BuildDefaultTrue,
+ "hardware/interfaces/audio/aidl/common": Bp2BuildDefaultTrue,
"hardware/interfaces/common/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/common/fmq/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/1.0": Bp2BuildDefaultTrue,
@@ -698,6 +699,11 @@
// for api_fingerprint.txt generation
"api_fingerprint",
+
+ // allowlisting for kotlinx_coroutines
+ "kotlinx_coroutines",
+ "annotations",
+ "kotlinx-coroutines-android-annotation-stubs",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
diff --git a/android/bazel.go b/android/bazel.go
index b600758..782632b 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -356,6 +356,7 @@
withinApex := !apexInfo.IsForPlatform()
mixedBuildEnabled := ctx.Config().IsMixedBuildsEnabled() &&
ctx.Os() != Windows && // Windows toolchains are not currently supported.
+ ctx.Os() != LinuxBionic && // Linux Bionic toolchains are not currently supported.
module.Enabled() &&
convertedToBazel(ctx, module) &&
ctx.Config().BazelContext.IsModuleNameAllowed(module.Name(), withinApex)
diff --git a/android/config.go b/android/config.go
index 07151f9..979f1ca 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1759,6 +1759,10 @@
return c.config.productVariables.BuildBrokenTrebleSyspropNeverallow
}
+func (c *deviceConfig) BuildBrokenUsesSoongPython2Modules() bool {
+ return c.config.productVariables.BuildBrokenUsesSoongPython2Modules
+}
+
func (c *deviceConfig) BuildDebugfsRestrictionsEnabled() bool {
return c.config.productVariables.BuildDebugfsRestrictionsEnabled
}
diff --git a/android/config_bp2build.go b/android/config_bp2build.go
index 2beeb51..830890d 100644
--- a/android/config_bp2build.go
+++ b/android/config_bp2build.go
@@ -95,6 +95,15 @@
return ev.pctx.VariableConfigMethod(name, method)
}
+func (ev ExportedVariables) ExportStringStaticVariableWithEnvOverride(name, envVar, defaultVal string) {
+ ev.ExportVariableConfigMethod(name, func(config Config) string {
+ if override := config.Getenv(envVar); override != "" {
+ return override
+ }
+ return defaultVal
+ })
+}
+
// ExportSourcePathVariable declares a static "source path" variable and exports
// it to Bazel's toolchain.
func (ev ExportedVariables) ExportSourcePathVariable(name string, value string) {
diff --git a/android/defaults.go b/android/defaults.go
index a821b28..31d6014 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -15,8 +15,6 @@
package android
import (
- "bytes"
- "fmt"
"reflect"
"github.com/google/blueprint"
@@ -69,11 +67,9 @@
// Set the property structures into which defaults will be added.
setProperties(props []interface{}, variableProperties interface{})
- // Apply defaults from the supplied DefaultsModule to the property structures supplied to
+ // Apply defaults from the supplied Defaults to the property structures supplied to
// setProperties(...).
- applyDefaults(TopDownMutatorContext, []DefaultsModule)
-
- applySingleDefaultsWithTracker(EarlyModuleContext, DefaultsModule, defaultsTrackerFunc)
+ applyDefaults(TopDownMutatorContext, []Defaults)
// Set the hook to be called after any defaults have been applied.
//
@@ -119,23 +115,9 @@
Defaults_visibility []string
}
-// AdditionalDefaultsProperties contains properties of defaults modules which
-// can have other defaults applied.
-type AdditionalDefaultsProperties struct {
-
- // The list of properties set by the default whose values must not be changed by any module that
- // applies these defaults. It is an error if a property is not supported by the defaults module or
- // has not been set to a non-zero value. If this contains "*" then that must be the only entry in
- // which case all properties that are set on this defaults will be protected (except the
- // protected_properties and visibility.
- Protected_properties []string
-}
-
type DefaultsModuleBase struct {
DefaultableModuleBase
- defaultsProperties AdditionalDefaultsProperties
-
// Included to support setting bazel_module.label for multiple Soong modules to the same Bazel
// target. This is primarily useful for modules that were architecture specific and instead are
// handled in Bazel as a select().
@@ -169,18 +151,6 @@
// DefaultsModuleBase will type-assert to the Defaults interface.
isDefaults() bool
- // additionalDefaultableProperties returns additional properties provided by the defaults which
- // can themselves have defaults applied.
- additionalDefaultableProperties() []interface{}
-
- // protectedProperties returns the names of the properties whose values cannot be changed by a
- // module that applies these defaults.
- protectedProperties() []string
-
- // setProtectedProperties sets the names of the properties whose values cannot be changed by a
- // module that applies these defaults.
- setProtectedProperties(protectedProperties []string)
-
// Get the structures containing the properties for which defaults can be provided.
properties() []interface{}
@@ -197,18 +167,6 @@
Bazelable
}
-func (d *DefaultsModuleBase) additionalDefaultableProperties() []interface{} {
- return []interface{}{&d.defaultsProperties}
-}
-
-func (d *DefaultsModuleBase) protectedProperties() []string {
- return d.defaultsProperties.Protected_properties
-}
-
-func (d *DefaultsModuleBase) setProtectedProperties(protectedProperties []string) {
- d.defaultsProperties.Protected_properties = protectedProperties
-}
-
func (d *DefaultsModuleBase) properties() []interface{} {
return d.defaultableProperties
}
@@ -232,10 +190,6 @@
&ApexProperties{},
&distProperties{})
- // Additional properties of defaults modules that can themselves have
- // defaults applied.
- module.AddProperties(module.additionalDefaultableProperties()...)
-
// Bazel module must be initialized _before_ Defaults to be included in cc_defaults module.
InitBazelModule(module)
initAndroidModuleBase(module)
@@ -263,58 +217,6 @@
// The applicable licenses property for defaults is 'licenses'.
setPrimaryLicensesProperty(module, "licenses", &commonProperties.Licenses)
-
- AddLoadHook(module, func(ctx LoadHookContext) {
-
- protectedProperties := module.protectedProperties()
- if len(protectedProperties) == 0 {
- return
- }
-
- propertiesAvailable := map[string]struct{}{}
- propertiesSet := map[string]struct{}{}
-
- // A defaults tracker which will keep track of which properties have been set on this module.
- collector := func(defaults DefaultsModule, property string, dstValue interface{}, srcValue interface{}) bool {
- value := reflect.ValueOf(dstValue)
- propertiesAvailable[property] = struct{}{}
- if !value.IsZero() {
- propertiesSet[property] = struct{}{}
- }
- // Skip all the properties so that there are no changes to the defaults.
- return false
- }
-
- // Try and apply this module's defaults to itself, so that the properties can be collected but
- // skip all the properties so it doesn't actually do anything.
- module.applySingleDefaultsWithTracker(ctx, module, collector)
-
- if InList("*", protectedProperties) {
- if len(protectedProperties) != 1 {
- ctx.PropertyErrorf("protected_properties", `if specified then "*" must be the only property listed`)
- return
- }
-
- // Do not automatically protect the protected_properties property.
- delete(propertiesSet, "protected_properties")
-
- // Or the visibility property.
- delete(propertiesSet, "visibility")
-
- // Replace the "*" with the names of all the properties that have been set.
- protectedProperties = SortedKeys(propertiesSet)
- module.setProtectedProperties(protectedProperties)
- } else {
- for _, property := range protectedProperties {
- if _, ok := propertiesAvailable[property]; !ok {
- ctx.PropertyErrorf(property, "property is not supported by this module type %q",
- ctx.ModuleType())
- } else if _, ok := propertiesSet[property]; !ok {
- ctx.PropertyErrorf(property, "is not set; protected properties must be explicitly set")
- }
- }
- }
- })
}
var _ Defaults = (*DefaultsModuleBase)(nil)
@@ -366,204 +268,35 @@
b.setNamespacedVariableProps(dst)
}
-// defaultValueInfo contains information about each default value that applies to a protected
-// property.
-type defaultValueInfo struct {
- // The DefaultsModule providing the value, which may be defined on that module or applied as a
- // default from other modules.
- module Module
-
- // The default value, as returned by getComparableValue
- defaultValue reflect.Value
-}
-
-// protectedPropertyInfo contains information about each property that has to be protected when
-// applying defaults.
-type protectedPropertyInfo struct {
- // True if the property was set on the module to which defaults are applied, this is an error.
- propertySet bool
-
- // The original value of the property on the module, as returned by getComparableValue.
- originalValue reflect.Value
-
- // A list of defaults for the property that are being applied.
- defaultValues []defaultValueInfo
-}
-
-// getComparableValue takes a reflect.Value that may be a pointer to another value and returns a
-// reflect.Value to the underlying data or the original if was not a pointer or was nil. The
-// returned values can then be compared for equality.
-func getComparableValue(value reflect.Value) reflect.Value {
- if value.IsZero() {
- return value
- }
- for value.Kind() == reflect.Ptr {
- value = value.Elem()
- }
- return value
-}
-
func (defaultable *DefaultableModuleBase) applyDefaults(ctx TopDownMutatorContext,
- defaultsList []DefaultsModule) {
-
- // Collate information on all the properties protected by each of the default modules applied
- // to this module.
- allProtectedProperties := map[string]*protectedPropertyInfo{}
- for _, defaults := range defaultsList {
- for _, property := range defaults.protectedProperties() {
- info := allProtectedProperties[property]
- if info == nil {
- info = &protectedPropertyInfo{}
- allProtectedProperties[property] = info
- }
- }
- }
-
- // If there are any protected properties then collate information about attempts to change them.
- var protectedPropertyInfoCollector defaultsTrackerFunc
- if len(allProtectedProperties) > 0 {
- protectedPropertyInfoCollector = func(defaults DefaultsModule, property string,
- dstValue interface{}, srcValue interface{}) bool {
-
- // If the property is not protected then return immediately.
- info := allProtectedProperties[property]
- if info == nil {
- return true
- }
-
- currentValue := reflect.ValueOf(dstValue)
- if info.defaultValues == nil {
- info.propertySet = !currentValue.IsZero()
- info.originalValue = getComparableValue(currentValue)
- }
-
- defaultValue := reflect.ValueOf(srcValue)
- if !defaultValue.IsZero() {
- info.defaultValues = append(info.defaultValues,
- defaultValueInfo{defaults, getComparableValue(defaultValue)})
- }
-
- return true
- }
- }
+ defaultsList []Defaults) {
for _, defaults := range defaultsList {
if ctx.Config().BuildMode == Bp2build {
applyNamespacedVariableDefaults(defaults, ctx)
}
-
- defaultable.applySingleDefaultsWithTracker(ctx, defaults, protectedPropertyInfoCollector)
- }
-
- // Check the status of any protected properties.
- for property, info := range allProtectedProperties {
- if len(info.defaultValues) == 0 {
- // No defaults were applied to the protected properties. Possibly because this module type
- // does not support any of them.
- continue
- }
-
- // Check to make sure that there are no conflicts between the defaults.
- conflictingDefaults := false
- previousDefaultValue := reflect.ValueOf(false)
- for _, defaultInfo := range info.defaultValues {
- defaultValue := defaultInfo.defaultValue
- if previousDefaultValue.IsZero() {
- previousDefaultValue = defaultValue
- } else if !reflect.DeepEqual(previousDefaultValue.Interface(), defaultValue.Interface()) {
- conflictingDefaults = true
- break
- }
- }
-
- if conflictingDefaults {
- var buf bytes.Buffer
- for _, defaultInfo := range info.defaultValues {
- buf.WriteString(fmt.Sprintf("\n defaults module %q provides value %#v",
- ctx.OtherModuleName(defaultInfo.module), defaultInfo.defaultValue))
- }
- result := buf.String()
- ctx.ModuleErrorf("has conflicting default values for protected property %q:%s", property, result)
- continue
- }
-
- // Now check to see whether there the current module tried to override/append to the defaults.
- if info.propertySet {
- originalValue := info.originalValue
- // Just compare against the first defaults.
- defaultValue := info.defaultValues[0].defaultValue
- defaults := info.defaultValues[0].module
-
- if originalValue.Kind() == reflect.Slice {
- ctx.ModuleErrorf("attempts to append %q to protected property %q's value of %q defined in module %q",
- originalValue,
- property,
- defaultValue,
- ctx.OtherModuleName(defaults))
+ for _, prop := range defaultable.defaultableProperties {
+ if prop == defaultable.defaultableVariableProperties {
+ defaultable.applyDefaultVariableProperties(ctx, defaults, prop)
} else {
- same := reflect.DeepEqual(originalValue.Interface(), defaultValue.Interface())
- message := ""
- if same {
- message = fmt.Sprintf(" with a matching value (%#v) so this property can simply be removed.", originalValue)
- } else {
- message = fmt.Sprintf(" with a different value (override %#v with %#v) so removing the property may necessitate other changes.", defaultValue, originalValue)
- }
- ctx.ModuleErrorf("attempts to override protected property %q defined in module %q%s",
- property,
- ctx.OtherModuleName(defaults), message)
+ defaultable.applyDefaultProperties(ctx, defaults, prop)
}
}
}
}
-func (defaultable *DefaultableModuleBase) applySingleDefaultsWithTracker(ctx EarlyModuleContext, defaults DefaultsModule, tracker defaultsTrackerFunc) {
- for _, prop := range defaultable.defaultableProperties {
- var err error
- if prop == defaultable.defaultableVariableProperties {
- err = defaultable.applyDefaultVariableProperties(defaults, prop, tracker)
- } else {
- err = defaultable.applyDefaultProperties(defaults, prop, tracker)
- }
- if err != nil {
- if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
- ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
- } else {
- panic(err)
- }
- }
- }
-}
-
-// defaultsTrackerFunc is the type of a function that can be used to track how defaults are applied.
-type defaultsTrackerFunc func(defaults DefaultsModule, property string,
- dstValue interface{}, srcValue interface{}) bool
-
-// filterForTracker wraps a defaultsTrackerFunc in a proptools.ExtendPropertyFilterFunc
-func filterForTracker(defaults DefaultsModule, tracker defaultsTrackerFunc) proptools.ExtendPropertyFilterFunc {
- if tracker == nil {
- return nil
- }
- return func(property string,
- dstField, srcField reflect.StructField,
- dstValue, srcValue interface{}) (bool, error) {
-
- apply := tracker(defaults, property, dstValue, srcValue)
- return apply, nil
- }
-}
-
// Product variable properties need special handling, the type of the filtered product variable
// property struct may not be identical between the defaults module and the defaultable module.
// Use PrependMatchingProperties to apply whichever properties match.
-func (defaultable *DefaultableModuleBase) applyDefaultVariableProperties(defaults DefaultsModule,
- defaultableProp interface{}, tracker defaultsTrackerFunc) error {
+func (defaultable *DefaultableModuleBase) applyDefaultVariableProperties(ctx TopDownMutatorContext,
+ defaults Defaults, defaultableProp interface{}) {
if defaultableProp == nil {
- return nil
+ return
}
defaultsProp := defaults.productVariableProperties()
if defaultsProp == nil {
- return nil
+ return
}
dst := []interface{}{
@@ -573,26 +306,31 @@
proptools.CloneEmptyProperties(reflect.ValueOf(defaultsProp)).Interface(),
}
- filter := filterForTracker(defaults, tracker)
-
- return proptools.PrependMatchingProperties(dst, defaultsProp, filter)
+ err := proptools.PrependMatchingProperties(dst, defaultsProp, nil)
+ if err != nil {
+ if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
+ ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
+ } else {
+ panic(err)
+ }
+ }
}
-func (defaultable *DefaultableModuleBase) applyDefaultProperties(defaults DefaultsModule,
- defaultableProp interface{}, checker defaultsTrackerFunc) error {
-
- filter := filterForTracker(defaults, checker)
+func (defaultable *DefaultableModuleBase) applyDefaultProperties(ctx TopDownMutatorContext,
+ defaults Defaults, defaultableProp interface{}) {
for _, def := range defaults.properties() {
if proptools.TypeEqual(defaultableProp, def) {
- err := proptools.PrependProperties(defaultableProp, def, filter)
+ err := proptools.PrependProperties(defaultableProp, def, nil)
if err != nil {
- return err
+ if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
+ ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
+ } else {
+ panic(err)
+ }
}
}
}
-
- return nil
}
func RegisterDefaultsPreArchMutators(ctx RegisterMutatorsContext) {
@@ -609,12 +347,12 @@
func defaultsMutator(ctx TopDownMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok {
if len(defaultable.defaults().Defaults) > 0 {
- var defaultsList []DefaultsModule
+ var defaultsList []Defaults
seen := make(map[Defaults]bool)
ctx.WalkDeps(func(module, parent Module) bool {
if ctx.OtherModuleDependencyTag(module) == DefaultsDepTag {
- if defaults, ok := module.(DefaultsModule); ok {
+ if defaults, ok := module.(Defaults); ok {
if !seen[defaults] {
seen[defaults] = true
defaultsList = append(defaultsList, defaults)
diff --git a/android/defaults_test.go b/android/defaults_test.go
index d80f40c..a7542ab 100644
--- a/android/defaults_test.go
+++ b/android/defaults_test.go
@@ -19,14 +19,7 @@
)
type defaultsTestProperties struct {
- Foo []string
- Bar []string
- Nested struct {
- Fizz *bool
- }
- Other struct {
- Buzz *string
- }
+ Foo []string
}
type defaultsTestModule struct {
@@ -137,167 +130,3 @@
// TODO: missing transitive defaults is currently not handled
_ = missingTransitiveDefaults
}
-
-func TestProtectedProperties_ProtectedPropertyNotSet(t *testing.T) {
- bp := `
- defaults {
- name: "transitive",
- protected_properties: ["foo"],
- }
- `
-
- GroupFixturePreparers(
- prepareForDefaultsTest,
- FixtureWithRootAndroidBp(bp),
- ).ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(
- "module \"transitive\": foo: is not set; protected properties must be explicitly set")).
- RunTest(t)
-}
-
-func TestProtectedProperties_ProtectedPropertyNotLeaf(t *testing.T) {
- bp := `
- defaults {
- name: "transitive",
- protected_properties: ["nested"],
- nested: {
- fizz: true,
- },
- }
- `
-
- GroupFixturePreparers(
- prepareForDefaultsTest,
- FixtureWithRootAndroidBp(bp),
- ).ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qmodule "transitive": nested: property is not supported by this module type "defaults"\E`)).
- RunTest(t)
-}
-
-// TestProtectedProperties_ApplyDefaults makes sure that the protected_properties property has
-// defaults applied.
-func TestProtectedProperties_HasDefaultsApplied(t *testing.T) {
-
- bp := `
- defaults {
- name: "transitive",
- protected_properties: ["foo"],
- foo: ["transitive"],
- }
-
- defaults {
- name: "defaults",
- defaults: ["transitive"],
- protected_properties: ["bar"],
- bar: ["defaults"],
- }
- `
-
- result := GroupFixturePreparers(
- prepareForDefaultsTest,
- FixtureWithRootAndroidBp(bp),
- ).RunTest(t)
-
- defaults := result.Module("defaults", "").(DefaultsModule)
- AssertDeepEquals(t, "defaults protected properties", []string{"foo", "bar"}, defaults.protectedProperties())
-}
-
-// TestProtectedProperties_ProtectAllProperties makes sure that protected_properties: ["*"] protects
-// all properties.
-func TestProtectedProperties_ProtectAllProperties(t *testing.T) {
-
- bp := `
- defaults {
- name: "transitive",
- protected_properties: ["other.buzz"],
- other: {
- buzz: "transitive",
- },
- }
-
- defaults {
- name: "defaults",
- defaults: ["transitive"],
- visibility: ["//visibility:private"],
- protected_properties: ["*"],
- foo: ["other"],
- bar: ["defaults"],
- nested: {
- fizz: true,
- }
- }
- `
-
- result := GroupFixturePreparers(
- prepareForDefaultsTest,
- FixtureWithRootAndroidBp(bp),
- ).RunTest(t)
-
- defaults := result.Module("defaults", "").(DefaultsModule)
- AssertDeepEquals(t, "defaults protected properties", []string{"other.buzz", "bar", "foo", "nested.fizz"},
- defaults.protectedProperties())
-}
-
-func TestProtectedProperties_DetectedOverride(t *testing.T) {
- bp := `
- defaults {
- name: "defaults",
- protected_properties: ["foo", "nested.fizz"],
- foo: ["defaults"],
- nested: {
- fizz: true,
- },
- }
-
- test {
- name: "foo",
- defaults: ["defaults"],
- foo: ["module"],
- nested: {
- fizz: false,
- },
- }
- `
-
- GroupFixturePreparers(
- prepareForDefaultsTest,
- FixtureWithRootAndroidBp(bp),
- ).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(
- []string{
- `\Qmodule "foo": attempts to append ["module"] to protected property "foo"'s value of ["defaults"] defined in module "defaults"\E`,
- `\Qmodule "foo": attempts to override protected property "nested.fizz" defined in module "defaults" with a different value (override true with false) so removing the property may necessitate other changes.\E`,
- })).RunTest(t)
-}
-
-func TestProtectedProperties_DefaultsConflict(t *testing.T) {
- bp := `
- defaults {
- name: "defaults1",
- protected_properties: ["other.buzz"],
- other: {
- buzz: "value",
- },
- }
-
- defaults {
- name: "defaults2",
- protected_properties: ["other.buzz"],
- other: {
- buzz: "another",
- },
- }
-
- test {
- name: "foo",
- defaults: ["defaults1", "defaults2"],
- }
- `
-
- GroupFixturePreparers(
- prepareForDefaultsTest,
- FixtureWithRootAndroidBp(bp),
- ).ExtendWithErrorHandler(FixtureExpectsAtLeastOneErrorMatchingPattern(
- `\Qmodule "foo": has conflicting default values for protected property "other.buzz":
- defaults module "defaults1" provides value "value"
- defaults module "defaults2" provides value "another"\E`,
- )).RunTest(t)
-}
diff --git a/android/filegroup.go b/android/filegroup.go
index 0f6e00e..278d46d 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -26,13 +26,18 @@
)
func init() {
- RegisterModuleType("filegroup", FileGroupFactory)
+ RegisterFilegroupBuildComponents(InitRegistrationContext)
}
var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx RegistrationContext) {
- ctx.RegisterModuleType("filegroup", FileGroupFactory)
+ RegisterFilegroupBuildComponents(ctx)
})
+func RegisterFilegroupBuildComponents(ctx RegistrationContext) {
+ ctx.RegisterModuleType("filegroup", FileGroupFactory)
+ ctx.RegisterModuleType("filegroup_defaults", FileGroupDefaultsFactory)
+}
+
var convertedProtoLibrarySuffix = "_bp2build_converted"
// IsFilegroup checks that a module is a filegroup type
@@ -178,6 +183,7 @@
type fileGroup struct {
ModuleBase
BazelModuleBase
+ DefaultableModuleBase
FileGroupAsLibrary
properties fileGroupProperties
srcs Paths
@@ -195,6 +201,7 @@
module.AddProperties(&module.properties)
InitAndroidModule(module)
InitBazelModule(module)
+ InitDefaultableModule(module)
return module
}
@@ -326,3 +333,17 @@
}
return nil, false
}
+
+// Defaults
+type FileGroupDefaults struct {
+ ModuleBase
+ DefaultsModuleBase
+}
+
+func FileGroupDefaultsFactory() Module {
+ module := &FileGroupDefaults{}
+ module.AddProperties(&fileGroupProperties{})
+ InitDefaultsModule(module)
+
+ return module
+}
diff --git a/android/filegroup_test.go b/android/filegroup_test.go
index 8292d5e..893da57 100644
--- a/android/filegroup_test.go
+++ b/android/filegroup_test.go
@@ -58,3 +58,24 @@
AssertStringEquals(t, "src full path", expectedOutputfile, fg.srcs[0].String())
}
}
+
+func TestFilegroupDefaults(t *testing.T) {
+ bp := FixtureAddTextFile("p/Android.bp", `
+ filegroup_defaults {
+ name: "defaults",
+ visibility: ["//x"],
+ }
+ filegroup {
+ name: "foo",
+ defaults: ["defaults"],
+ visibility: ["//y"],
+ }
+ `)
+ result := GroupFixturePreparers(
+ PrepareForTestWithFilegroup,
+ PrepareForTestWithDefaults,
+ PrepareForTestWithVisibility,
+ bp).RunTest(t)
+ rules := effectiveVisibilityRules(result.Config, qualifiedModuleName{pkg: "p", name: "foo"})
+ AssertDeepEquals(t, "visibility", []string{"//x", "//y"}, rules.Strings())
+}
diff --git a/android/neverallow.go b/android/neverallow.go
index ba5385c..2139c3c 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -165,6 +165,7 @@
javaDeviceForHostProjectsAllowedList := []string{
"development/build",
"external/guava",
+ "external/kotlinx.coroutines",
"external/robolectric-shadows",
"external/robolectric",
"frameworks/layoutlib",
diff --git a/android/variable.go b/android/variable.go
index 1b5d558..8c5c0bc 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -442,6 +442,7 @@
BuildBrokenDepfile *bool `json:",omitempty"`
BuildBrokenEnforceSyspropOwner bool `json:",omitempty"`
BuildBrokenTrebleSyspropNeverallow bool `json:",omitempty"`
+ BuildBrokenUsesSoongPython2Modules bool `json:",omitempty"`
BuildBrokenVendorPropertyNamespace bool `json:",omitempty"`
BuildBrokenInputDirModules []string `json:",omitempty"`
diff --git a/bp2build/aar_conversion_test.go b/bp2build/aar_conversion_test.go
index 0cda5dd..6020ee5 100644
--- a/bp2build/aar_conversion_test.go
+++ b/bp2build/aar_conversion_test.go
@@ -171,3 +171,39 @@
MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
}})
}
+
+func TestConvertAndroidLibraryKotlinCflags(t *testing.T) {
+ t.Helper()
+ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{
+ Description: "Android Library with .kt srcs and kotlincflags ",
+ ModuleTypeUnderTest: "android_library",
+ ModuleTypeUnderTestFactory: java.AndroidLibraryFactory,
+ Filesystem: map[string]string{
+ "AndroidManifest.xml": "",
+ },
+ Blueprint: `
+android_library {
+ name: "TestLib",
+ srcs: ["a.java", "b.kt"],
+ kotlincflags: ["-flag1", "-flag2"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget(
+ "android_library",
+ "TestLib",
+ AttrNameToString{
+ "srcs": `[
+ "a.java",
+ "b.kt",
+ ]`,
+ "kotlincflags": `[
+ "-flag1",
+ "-flag2",
+ ]`,
+ "manifest": `"AndroidManifest.xml"`,
+ "resource_files": `[]`,
+ }),
+ MakeNeverlinkDuplicateTarget("android_library", "TestLib"),
+ }})
+}
diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go
index 4d18f83..03b3d2b 100644
--- a/bp2build/android_app_conversion_test.go
+++ b/bp2build/android_app_conversion_test.go
@@ -306,3 +306,41 @@
}),
}})
}
+
+func TestAndroidAppKotlinCflags(t *testing.T) {
+ runAndroidAppTestCase(t, Bp2buildTestCase{
+ Description: "Android app with kotlincflags",
+ ModuleTypeUnderTest: "android_app",
+ ModuleTypeUnderTestFactory: java.AndroidAppFactory,
+ Filesystem: map[string]string{
+ "res/res.png": "",
+ },
+ Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + `
+android_app {
+ name: "foo",
+ srcs: ["a.java", "b.kt"],
+ certificate: ":foocert",
+ manifest: "fooManifest.xml",
+ kotlincflags: ["-flag1", "-flag2"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("android_library", "foo_kt", AttrNameToString{
+ "srcs": `[
+ "a.java",
+ "b.kt",
+ ]`,
+ "manifest": `"fooManifest.xml"`,
+ "resource_files": `["res/res.png"]`,
+ "kotlincflags": `[
+ "-flag1",
+ "-flag2",
+ ]`,
+ }),
+ MakeBazelTarget("android_binary", "foo", AttrNameToString{
+ "deps": `[":foo_kt"]`,
+ "certificate": `":foocert"`,
+ "manifest": `"fooManifest.xml"`,
+ }),
+ }})
+}
diff --git a/bp2build/cc_prebuilt_library_conversion_test.go b/bp2build/cc_prebuilt_library_conversion_test.go
index 2fe158e..c5a6dfd 100644
--- a/bp2build/cc_prebuilt_library_conversion_test.go
+++ b/bp2build/cc_prebuilt_library_conversion_test.go
@@ -39,6 +39,10 @@
MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
"static_library": `"libf.so"`,
}),
+ MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_alwayslink", AttrNameToString{
+ "static_library": `"libf.so"`,
+ "alwayslink": "True",
+ }),
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
"shared_library": `"libf.so"`,
}),
@@ -71,8 +75,14 @@
"//build/bazel/platforms/arch:arm": "libg.so",
"//build/bazel/platforms/arch:arm64": "libf.so",
"//conditions:default": None,
- })`,
- }),
+ })`}),
+ MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_alwayslink", AttrNameToString{
+ "alwayslink": "True",
+ "static_library": `select({
+ "//build/bazel/platforms/arch:arm": "libg.so",
+ "//build/bazel/platforms/arch:arm64": "libf.so",
+ "//conditions:default": None,
+ })`}),
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
"shared_library": `select({
"//build/bazel/platforms/arch:arm": "libg.so",
@@ -109,6 +119,12 @@
"export_includes": `["testdir/1/"]`,
"export_system_includes": `["testdir/2/"]`,
}),
+ MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_alwayslink", AttrNameToString{
+ "static_library": `"libf.so"`,
+ "export_includes": `["testdir/1/"]`,
+ "export_system_includes": `["testdir/2/"]`,
+ "alwayslink": "True",
+ }),
// TODO(b/229374533): When fixed, update this test
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
"shared_library": `"libf.so"`,
@@ -188,6 +204,10 @@
MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static", AttrNameToString{
"static_library": `"libf.so"`,
}),
+ MakeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_alwayslink", AttrNameToString{
+ "static_library": `"libf.so"`,
+ "alwayslink": "True",
+ }),
MakeBazelTarget("cc_prebuilt_library_shared", "libtest", AttrNameToString{
"shared_library": `"libg.so"`,
}),
@@ -245,6 +265,10 @@
// makeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static", attrNameToString{
// "static_library": `"libf.so"`,
// }),
+// makeBazelTarget("cc_prebuilt_library_static", "libtest_bp2build_cc_library_static_always", attrNameToString{
+// "static_library": `"libf.so"`,
+// "alwayslink": "True",
+// }),
// },
// })
//}
diff --git a/bp2build/cc_prebuilt_library_static_test.go b/bp2build/cc_prebuilt_library_static_test.go
index 6116b00..17da813 100644
--- a/bp2build/cc_prebuilt_library_static_test.go
+++ b/bp2build/cc_prebuilt_library_static_test.go
@@ -39,6 +39,10 @@
MakeBazelTarget("cc_prebuilt_library_static", "libtest", AttrNameToString{
"static_library": `"libf.so"`,
}),
+ MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
+ "static_library": `"libf.so"`,
+ "alwayslink": "True",
+ }),
},
})
}
@@ -68,8 +72,14 @@
"//build/bazel/platforms/arch:arm": "libg.so",
"//build/bazel/platforms/arch:arm64": "libf.so",
"//conditions:default": None,
- })`,
- }),
+ })`}),
+ MakeBazelTarget("cc_prebuilt_library_static", "libtest_alwayslink", AttrNameToString{
+ "alwayslink": "True",
+ "static_library": `select({
+ "//build/bazel/platforms/arch:arm": "libg.so",
+ "//build/bazel/platforms/arch:arm64": "libf.so",
+ "//conditions:default": None,
+ })`}),
},
})
}
diff --git a/bp2build/java_binary_host_conversion_test.go b/bp2build/java_binary_host_conversion_test.go
index 6f17e34..278a9bf 100644
--- a/bp2build/java_binary_host_conversion_test.go
+++ b/bp2build/java_binary_host_conversion_test.go
@@ -284,3 +284,38 @@
},
})
}
+
+func TestJavaBinaryHostKotlinCflags(t *testing.T) {
+ runJavaBinaryHostTestCase(t, Bp2buildTestCase{
+ Description: "java_binary_host with kotlincflags",
+ Filesystem: testFs,
+ Blueprint: `java_binary_host {
+ name: "java-binary-host",
+ manifest: "test.mf",
+ srcs: ["a.kt"],
+ kotlincflags: ["-flag1", "-flag2"],
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("kt_jvm_library", "java-binary-host_kt", AttrNameToString{
+ "srcs": `["a.kt"]`,
+ "kotlincflags": `[
+ "-flag1",
+ "-flag2",
+ ]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ MakeBazelTarget("java_binary", "java-binary-host", AttrNameToString{
+ "main_class": `"com.android.test.MainClass"`,
+ "runtime_deps": `[":java-binary-host_kt"]`,
+ "target_compatible_with": `select({
+ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go
index f1d6398..e3c4857 100644
--- a/bp2build/java_library_conversion_test.go
+++ b/bp2build/java_library_conversion_test.go
@@ -673,7 +673,7 @@
func TestJavaLibraryKotlinSrcs(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
- Description: "java_library with kotlin srcs",
+ Description: "java_library with kotlin srcs",
Blueprint: `java_library {
name: "java-lib-1",
srcs: ["a.java", "b.java", "c.kt"],
@@ -693,9 +693,32 @@
})
}
+func TestJavaLibraryKotlincflags(t *testing.T) {
+ runJavaLibraryTestCase(t, Bp2buildTestCase{
+ Description: "java_library with kotlincfalgs",
+ Blueprint: `java_library {
+ name: "java-lib-1",
+ srcs: [ "a.kt"],
+ kotlincflags: ["-flag1", "-flag2"],
+ bazel_module: { bp2build_available: true },
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("kt_jvm_library", "java-lib-1", AttrNameToString{
+ "srcs": `["a.kt"]`,
+ "kotlincflags": `[
+ "-flag1",
+ "-flag2",
+ ]`,
+ }),
+ MakeNeverlinkDuplicateTarget("kt_jvm_library", "java-lib-1"),
+ },
+ })
+}
+
func TestJavaLibraryKotlinCommonSrcs(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
- Description: "java_library with kotlin common_srcs",
+ Description: "java_library with kotlin common_srcs",
Blueprint: `java_library {
name: "java-lib-1",
srcs: ["a.java", "b.java"],
diff --git a/cc/check.go b/cc/check.go
index 3d290a9..58ff5b2 100644
--- a/cc/check.go
+++ b/cc/check.go
@@ -57,6 +57,10 @@
} else if strings.HasPrefix("../", path) {
ctx.PropertyErrorf(prop, "Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory", flag)
}
+ } else if args[0] == "-mllvm" {
+ if len(args) > 2 {
+ ctx.PropertyErrorf(prop, "`-mllvm` only takes one argument: `%s`", flag)
+ }
} else if strings.HasPrefix(flag, "-D") && strings.Contains(flag, "=") {
// Do nothing in this case.
// For now, we allow space characters in -DNAME=def form to allow use cases
diff --git a/cc/config/global.go b/cc/config/global.go
index 488af45..6b45b12 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -234,8 +234,6 @@
// New warnings to be fixed after clang-r433403
"-Wno-error=unused-but-set-variable", // http://b/197240255
"-Wno-error=unused-but-set-parameter", // http://b/197240255
- // New warnings to be fixed after clang-r458507
- "-Wno-error=unqualified-std-cast-call", // http://b/239662094
// New warnings to be fixed after clang-r468909
"-Wno-error=deprecated-builtins", // http://b/241601211
"-Wno-error=deprecated", // in external/googletest/googletest
@@ -253,6 +251,7 @@
"-Wno-sizeof-array-div",
"-Wno-unused-but-set-variable",
"-Wno-unused-but-set-parameter",
+ "-Wno-unqualified-std-cast-call",
"-Wno-bitwise-instead-of-logical",
"-Wno-misleading-indentation",
"-Wno-array-parameter",
@@ -417,15 +416,12 @@
exportedVars.ExportStringList("CommonGlobalIncludes", commonGlobalIncludes)
pctx.PrefixedExistentPathsForSourcesVariable("CommonGlobalIncludes", "-I", commonGlobalIncludes)
- exportedVars.ExportStringStaticVariable("CLANG_DEFAULT_VERSION", ClangDefaultVersion)
- exportedVars.ExportStringStaticVariable("CLANG_DEFAULT_SHORT_VERSION", ClangDefaultShortVersion)
-
pctx.StaticVariableWithEnvOverride("ClangBase", "LLVM_PREBUILTS_BASE", ClangDefaultBase)
- pctx.StaticVariableWithEnvOverride("ClangVersion", "LLVM_PREBUILTS_VERSION", ClangDefaultVersion)
+ exportedVars.ExportStringStaticVariableWithEnvOverride("ClangVersion", "LLVM_PREBUILTS_VERSION", ClangDefaultVersion)
pctx.StaticVariable("ClangPath", "${ClangBase}/${HostPrebuiltTag}/${ClangVersion}")
pctx.StaticVariable("ClangBin", "${ClangPath}/bin")
- pctx.StaticVariableWithEnvOverride("ClangShortVersion", "LLVM_RELEASE_VERSION", ClangDefaultShortVersion)
+ exportedVars.ExportStringStaticVariableWithEnvOverride("ClangShortVersion", "LLVM_RELEASE_VERSION", ClangDefaultShortVersion)
pctx.StaticVariable("ClangAsanLibDir", "${ClangBase}/linux-x86/${ClangVersion}/lib/clang/${ClangShortVersion}/lib/linux")
// These are tied to the version of LLVM directly in external/llvm, so they might trail the host prebuilts
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index bb517ea..5b7ba43 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -352,6 +352,7 @@
Static_library bazel.LabelAttribute
Export_includes bazel.StringListAttribute
Export_system_includes bazel.StringListAttribute
+ Alwayslink bazel.BoolAttribute
}
// TODO(b/228623543): The below is not entirely true until the bug is fixed. For now, both targets are always generated
@@ -389,6 +390,11 @@
tags := android.ApexAvailableTags(module)
ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name, Tags: tags}, attrs, prebuiltAttrs.Enabled)
+
+ _true := true
+ alwayslinkAttrs := *attrs
+ alwayslinkAttrs.Alwayslink.SetValue(&_true)
+ ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name + "_alwayslink", Tags: tags}, &alwayslinkAttrs, prebuiltAttrs.Enabled)
}
type bazelPrebuiltLibrarySharedAttributes struct {
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 5c187f6..9b51160 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -136,7 +136,7 @@
ctx.EventHandler.Begin("queryview")
defer ctx.EventHandler.End("queryview")
codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.QueryView, topDir)
- err := createBazelWorkspace(codegenContext, shared.JoinPath(topDir, queryviewDir))
+ err := createBazelWorkspace(codegenContext, shared.JoinPath(topDir, queryviewDir), false)
maybeQuit(err, "")
touch(shared.JoinPath(topDir, queryviewMarker))
}
@@ -174,7 +174,28 @@
// Run codegen to generate BUILD files
codegenContext := bp2build.NewCodegenContext(ctx.Config(), ctx, bp2build.ApiBp2build, topDir)
absoluteApiBp2buildDir := shared.JoinPath(topDir, cmdlineArgs.BazelApiBp2buildDir)
- err := createBazelWorkspace(codegenContext, absoluteApiBp2buildDir)
+ // Always generate bp2build_all_srcs filegroups in api_bp2build.
+ // This is necessary to force each Android.bp file to create an equivalent BUILD file
+ // and prevent package boundray issues.
+ // e.g.
+ // Source
+ // f/b/Android.bp
+ // java_library{
+ // name: "foo",
+ // api: "api/current.txt",
+ // }
+ //
+ // f/b/api/Android.bp <- will cause package boundary issues
+ //
+ // Gen
+ // f/b/BUILD
+ // java_contribution{
+ // name: "foo.contribution",
+ // api: "//f/b/api:current.txt",
+ // }
+ //
+ // If we don't generate f/b/api/BUILD, foo.contribution will be unbuildable.
+ err := createBazelWorkspace(codegenContext, absoluteApiBp2buildDir, true)
maybeQuit(err, "")
ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
diff --git a/cmd/soong_build/queryview.go b/cmd/soong_build/queryview.go
index 35ae009..ce32184 100644
--- a/cmd/soong_build/queryview.go
+++ b/cmd/soong_build/queryview.go
@@ -25,11 +25,11 @@
)
// A helper function to generate a Read-only Bazel workspace in outDir
-func createBazelWorkspace(ctx *bp2build.CodegenContext, outDir string) error {
+func createBazelWorkspace(ctx *bp2build.CodegenContext, outDir string, generateFilegroups bool) error {
os.RemoveAll(outDir)
ruleShims := bp2build.CreateRuleShims(android.ModuleTypeFactories())
- res, err := bp2build.GenerateBazelTargets(ctx, false)
+ res, err := bp2build.GenerateBazelTargets(ctx, generateFilegroups)
if err != nil {
panic(err)
}
diff --git a/java/java.go b/java/java.go
index 61f5949..15ee4a9 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2787,11 +2787,12 @@
depLabels.StaticDeps = bazel.MakeLabelListAttribute(staticDeps)
hasKotlin := !kotlinSrcs.IsEmpty()
+ commonAttrs.kotlinAttributes = &kotlinAttributes{
+ Kotlincflags: &m.properties.Kotlincflags,
+ }
if len(m.properties.Common_srcs) != 0 {
hasKotlin = true
- commonAttrs.kotlinAttributes = &kotlinAttributes{
- bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs)),
- }
+ commonAttrs.kotlinAttributes.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs))
}
bp2BuildInfo := &bp2BuildJavaInfo{
@@ -2810,7 +2811,8 @@
}
type kotlinAttributes struct {
- Common_srcs bazel.LabelListAttribute
+ Common_srcs bazel.LabelListAttribute
+ Kotlincflags *[]string
}
func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) {
@@ -2844,12 +2846,12 @@
if !bp2BuildInfo.hasKotlin {
props = bazel.BazelTargetModuleProperties{
Rule_class: "java_library",
- Bzl_load_location: "//build/bazel/rules/java:library.bzl",
+ Bzl_load_location: "//build/bazel/rules/java:rules.bzl",
}
} else {
props = bazel.BazelTargetModuleProperties{
Rule_class: "kt_jvm_library",
- Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl",
+ Bzl_load_location: "//build/bazel/rules/kotlin:rules.bzl",
}
}
@@ -2929,7 +2931,8 @@
}
props := bazel.BazelTargetModuleProperties{
- Rule_class: "java_binary",
+ Rule_class: "java_binary",
+ Bzl_load_location: "//build/bazel/rules/java:rules.bzl",
}
attrs := &javaBinaryHostAttributes{
Runtime_deps: runtimeDeps,
@@ -2944,7 +2947,7 @@
ktName := m.Name() + "_kt"
ktProps := bazel.BazelTargetModuleProperties{
Rule_class: "kt_jvm_library",
- Bzl_load_location: "//build/bazel/rules/kotlin:kt_jvm_library.bzl",
+ Bzl_load_location: "//build/bazel/rules/kotlin:rules.bzl",
}
ktAttrs := &javaLibraryAttributes{
@@ -2981,7 +2984,10 @@
attrs := &bazelJavaImportAttributes{
Jars: jars,
}
- props := bazel.BazelTargetModuleProperties{Rule_class: "java_import"}
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "java_import",
+ Bzl_load_location: "//build/bazel/rules/java:rules.bzl",
+ }
name := android.RemoveOptionalPrebuiltPrefix(i.Name())
@@ -2992,7 +2998,13 @@
Neverlink: bazel.BoolAttribute{Value: &neverlink},
Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}),
}
- ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{Rule_class: "java_library"}, android.CommonAttributes{Name: name + "-neverlink"}, neverlinkAttrs)
+ ctx.CreateBazelTargetModule(
+ bazel.BazelTargetModuleProperties{
+ Rule_class: "java_library",
+ Bzl_load_location: "//build/bazel/rules/java:rules.bzl",
+ },
+ android.CommonAttributes{Name: name + "-neverlink"},
+ neverlinkAttrs)
}
diff --git a/java/lint_defaults.txt b/java/lint_defaults.txt
index 061f4d0..1bb4996 100644
--- a/java/lint_defaults.txt
+++ b/java/lint_defaults.txt
@@ -40,6 +40,13 @@
# NewApi checks will continue to be enforced for apex deps since
# lint.strict_updatability_linting will be true for those Soong modules
--disable_check NewApi
+# Disable ChromeOS specific checks
+--disable_check PermissionImpliesUnsupportedChromeOsHardware
+# Disable UnsafeImplicitIntentLaunch until it can avoid false positives/crash
+# TODO(265425607)
+--disable_check UnsafeImplicitIntentLaunch
+# InvalidId will give errors on ids defined like android:id="@androidprv:id/contentPanel"
+--disable_check InvalidId
# Downgrade existing errors to warnings
--warning_check AppCompatResource # 55 occurences in 10 modules
diff --git a/python/python.go b/python/python.go
index 0ae7b36..c7c523d 100644
--- a/python/python.go
+++ b/python/python.go
@@ -263,6 +263,12 @@
versionProps = append(versionProps, props.Version.Py3)
}
if proptools.BoolDefault(props.Version.Py2.Enabled, false) {
+ if !mctx.DeviceConfig().BuildBrokenUsesSoongPython2Modules() &&
+ mctx.ModuleName() != "par_test" &&
+ mctx.ModuleName() != "py2-cmd" &&
+ mctx.ModuleName() != "py2-stdlib" {
+ mctx.PropertyErrorf("version.py2.enabled", "Python 2 is no longer supported, please convert to python 3. This error can be temporarily overridden by setting BUILD_BROKEN_USES_SOONG_PYTHON2_MODULES := true in the product configuration")
+ }
versionNames = append(versionNames, pyVersion2)
versionProps = append(versionProps, props.Version.Py2)
}
diff --git a/tests/bp2build_bazel_test.sh b/tests/bp2build_bazel_test.sh
index 1ff1b5b..68d7f8d 100755
--- a/tests/bp2build_bazel_test.sh
+++ b/tests/bp2build_bazel_test.sh
@@ -343,4 +343,29 @@
run_bazel build --config=android --config=api_bp2build //:empty
}
+# Verify that an *_api_contribution target can refer to an api file from
+# another Bazel package.
+function test_api_export_from_another_bazel_package() {
+ setup
+ # Parent dir Android.bp
+ mkdir -p foo
+ cat > foo/Android.bp << 'EOF'
+cc_library {
+ name: "libfoo",
+ stubs: {
+ symbol_file: "api/libfoo.map.txt",
+ },
+}
+EOF
+ # Child dir Android.bp
+ mkdir -p foo/api
+ cat > foo/api/Android.bp << 'EOF'
+package{}
+EOF
+ touch foo/api/libfoo.map.txt
+ # Run test
+ run_soong api_bp2build
+ run_bazel build --config=android --config=api_bp2build //foo:libfoo.contribution
+}
+
scan_and_run_tests
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index e1aa70c..a762952 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -20,5 +20,3 @@
"$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"
-
-"$TOP/build/soong/tests/sbom_test.sh"
diff --git a/tests/sbom_test.sh b/tests/sbom_test.sh
deleted file mode 100755
index 28ce9d8..0000000
--- a/tests/sbom_test.sh
+++ /dev/null
@@ -1,202 +0,0 @@
-#!/bin/bash
-
-# 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.
-
-set -uo pipefail
-
-# Integration test for verifying generated SBOM for cuttlefish device.
-
-if [ ! -e "build/make/core/Makefile" ]; then
- echo "$0 must be run from the top of the Android source tree."
- exit 1
-fi
-
-tmp_dir="$(mktemp -d tmp.XXXXXX)"
-function cleanup {
- rm -rf "${tmp_dir}"
-}
-trap cleanup EXIT
-
-out_dir=$tmp_dir
-droid_target=droid
-
-debug=false
-if [ $debug = "true" ]; then
- out_dir=out
- droid_target=
-fi
-# m droid
-TARGET_PRODUCT="aosp_cf_x86_64_phone" TARGET_BUILD_VARIANT=userdebug OUT_DIR=$out_dir \
- build/soong/soong_ui.bash --make-mode $droid_target dump.erofs sbom
-
-# Generate installed file list from .img files in PRODUCT_OUT
-dump_erofs=$out_dir/host/linux-x86/bin/dump.erofs
-product_out=$out_dir/target/product/vsoc_x86_64
-
-declare -A diff_excludes
-diff_excludes[odm]="-I /odm/lib/modules"
-diff_excludes[vendor]=\
-"-I /vendor/lib64/libkeystore2_crypto.so \
- -I /vendor/lib/modules \
- -I /vendor/odm"
-diff_excludes[system]=\
-"-I /acct/ \
- -I /adb_keys \
- -I /apex/ \
- -I /bin \
- -I /bugreports \
- -I /cache \
- -I /config/ \
- -I /d \
- -I /data/ \
- -I /data_mirror/ \
- -I /debug_ramdisk/ \
- -I /dev/ \
- -I /etc \
- -I /init \
- -I /init.environ.rc \
- -I /linkerconfig/ \
- -I /metadata/ \
- -I /mnt/ \
- -I /odm/app \
- -I /odm/bin \
- -I /odm_dlkm/etc \
- -I /odm/etc \
- -I /odm/firmware \
- -I /odm/framework \
- -I /odm/lib \
- -I /odm/lib64 \
- -I /odm/overlay \
- -I /odm/priv-app \
- -I /odm/usr \
- -I /oem/ \
- -I /postinstall/ \
- -I /proc/ \
- -I /product/ \
- -I /sdcard \
- -I /second_stage_resources/ \
- -I /storage/ \
- -I /sys/ \
- -I /system_dlkm/ \
- -I /system_ext/ \
- -I /system/lib64/android.hardware.confirmationui@1.0.so \
- -I /system/lib64/android.hardware.confirmationui-V1-ndk.so \
- -I /system/lib64/android.hardware.keymaster@4.1.so \
- -I /system/lib64/android.hardware.security.rkp-V3-ndk.so \
- -I /system/lib64/android.hardware.security.sharedsecret-V1-ndk.so \
- -I /system/lib64/android.security.compat-ndk.so \
- -I /system/lib64/libkeymaster4_1support.so \
- -I /system/lib64/libkeymint.so \
- -I /system/lib64/libkeystore2_aaid.so \
- -I /system/lib64/libkeystore2_apc_compat.so \
- -I /system/lib64/libkeystore2_crypto.so \
- -I /system/lib64/libkm_compat_service.so \
- -I /system/lib64/libkm_compat.so \
- -I /system/lib64/vndk-29 \
- -I /system/lib64/vndk-sp-29 \
- -I /system/lib/modules \
- -I /system/lib/vndk-29 \
- -I /system/lib/vndk-sp-29 \
- -I /system/product \
- -I /system/system_ext \
- -I /system/usr/icu \
- -I /system/vendor \
- -I /vendor/ \
- -I /vendor_dlkm/etc"
-
-# Example output of dump.erofs is as below, and the data used in the test start
-# at line 11. Column 1 is inode id, column 2 is inode type and column 3 is name.
-# Each line is captured in variable "entry", sed is used to trim the leading
-# spaces and cut is used to get field 1 every time. Once a field is extracted,
-# "cut --complement" is used to remove the extracted field so next field can be
-# processed in the same way and to be processed field is always field 1.
-# Output of dump.erofs:
-# File : /
-# Size: 160 On-disk size: 160 directory
-# NID: 39 Links: 10 Layout: 2 Compression ratio: 100.00%
-# Inode size: 64 Extent size: 0 Xattr size: 16
-# Uid: 0 Gid: 0 Access: 0755/rwxr-xr-x
-# Timestamp: 2023-02-14 01:15:54.000000000
-#
-# NID TYPE FILENAME
-# 39 2 .
-# 39 2 ..
-# 47 2 app
-# 1286748 2 bin
-# 1286754 2 etc
-# 5304814 2 lib
-# 5309056 2 lib64
-# 5309130 2 media
-# 5388910 2 overlay
-# 5479537 2 priv-app
-EROFS_IMAGES="\
- $product_out/product.img \
- $product_out/system.img \
- $product_out/system_ext.img \
- $product_out/system_dlkm.img \
- $product_out/system_other.img \
- $product_out/odm.img \
- $product_out/odm_dlkm.img \
- $product_out/vendor.img \
- $product_out/vendor_dlkm.img"
-for f in $EROFS_IMAGES; do
- partition_name=$(basename $f | cut -d. -f1)
- file_list_file="${product_out}/sbom-${partition_name}-files.txt"
- files_in_spdx_file="${product_out}/sbom-${partition_name}-files-in-spdx.txt"
- rm "$file_list_file" > /dev/null 2>&1
- all_dirs="/"
- while [ ! -z "$all_dirs" ]; do
- dir=$(echo "$all_dirs" | cut -d ' ' -f1)
- all_dirs=$(echo "$all_dirs" | cut -d ' ' -f1 --complement -s)
- entries=$($dump_erofs --ls --path "$dir" $f | tail -n +11)
- while read -r entry; do
- nid=$(echo $entry | sed 's/^\s*//' | cut -d ' ' -f1)
- entry=$(echo $entry | sed 's/^\s*//' | cut -d ' ' -f1 --complement)
- type=$(echo $entry | sed 's/^\s*//' | cut -d ' ' -f1)
- entry=$(echo $entry | sed 's/^\s*//' | cut -d ' ' -f1 --complement)
- name=$(echo $entry | sed 's/^\s*//' | cut -d ' ' -f1)
- case $type in
- "2") # directory
- all_dirs=$(echo "$all_dirs $dir/$name" | sed 's/^\s*//')
- ;;
- *)
- (
- if [ "$partition_name" != "system" ]; then
- # system partition is mounted to /, not to prepend partition name.
- printf %s "/$partition_name"
- fi
- echo "$dir/$name" | sed 's#^//#/#'
- ) >> "$file_list_file"
- ;;
- esac
- done <<< "$entries"
- done
- sort -n -o "$file_list_file" "$file_list_file"
-
- # Diff
- echo ============ Diffing files in $f and SBOM
- grep "FileName: /${partition_name}/" $product_out/sbom.spdx | sed 's/^FileName: //' | sort -n > "$files_in_spdx_file"
- exclude=
- if [ -v 'diff_excludes[$partition_name]' ]; then
- exclude=${diff_excludes[$partition_name]}
- fi
- diff "$file_list_file" "$files_in_spdx_file" $exclude
- if [ $? != "0" ]; then
- echo Found diffs in $f and SBOM.
- exit 1
- else
- echo No diffs.
- fi
-done
\ No newline at end of file
diff --git a/third_party/zip/writer.go b/third_party/zip/writer.go
index f526838..8a957e1 100644
--- a/third_party/zip/writer.go
+++ b/third_party/zip/writer.go
@@ -162,9 +162,17 @@
if records > uint16max {
records = uint16max
}
+ // Only store uint32max for the size and the offset if they don't fit.
+ // Robolectric currently doesn't support zip64 and fails to find the
+ // offset to the central directory when the number of files in the zip
+ // is larger than 2^16.
+ if size > uint32max {
+ size = uint32max
+ }
+ if offset > uint32max {
+ offset = uint32max
+ }
// END ANDROID CHANGE
- size = uint32max
- offset = uint32max
}
// write end record
diff --git a/ui/metrics/event.go b/ui/metrics/event.go
index b3a027e..cbdeb27 100644
--- a/ui/metrics/event.go
+++ b/ui/metrics/event.go
@@ -135,8 +135,8 @@
e := t.peek()
e.procResInfo = append(e.procResInfo, &soong_metrics_proto.ProcessResourceInfo{
Name: proto.String(name),
- UserTimeMicros: proto.Uint64(uint64(rusage.Utime.Usec)),
- SystemTimeMicros: proto.Uint64(uint64(rusage.Stime.Usec)),
+ UserTimeMicros: proto.Uint64(uint64(state.UserTime().Microseconds())),
+ SystemTimeMicros: proto.Uint64(uint64(state.SystemTime().Microseconds())),
MinorPageFaults: proto.Uint64(uint64(rusage.Minflt)),
MajorPageFaults: proto.Uint64(uint64(rusage.Majflt)),
// ru_inblock and ru_oublock are measured in blocks of 512 bytes.