Merge "Adding fuzz_config in rust_defaults" into main
diff --git a/aconfig/rust_aconfig_library.go b/aconfig/rust_aconfig_library.go
index 8b16372..de41776 100644
--- a/aconfig/rust_aconfig_library.go
+++ b/aconfig/rust_aconfig_library.go
@@ -6,6 +6,7 @@
"fmt"
"github.com/google/blueprint"
+ "github.com/google/blueprint/proptools"
)
type rustDeclarationsTagType struct {
@@ -17,6 +18,7 @@
type RustAconfigLibraryProperties struct {
// name of the aconfig_declarations module to generate a library for
Aconfig_declarations string
+ Test *bool
}
type aconfigDecorator struct {
@@ -58,6 +60,11 @@
}
declarations := ctx.OtherModuleProvider(declarationsModules[0], declarationsProviderKey).(declarationsProviderData)
+ mode := "production"
+ if proptools.Bool(a.Properties.Test) {
+ mode = "test"
+ }
+
ctx.Build(pctx, android.BuildParams{
Rule: rustRule,
Input: declarations.IntermediatePath,
@@ -67,8 +74,7 @@
Description: "rust_aconfig_library",
Args: map[string]string{
"gendir": generatedDir.String(),
- // TODO: Add test mode
- "mode": "production",
+ "mode": mode,
},
})
a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource}
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 8a22886..056c1a8 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -145,6 +145,7 @@
"external/flatbuffers": Bp2BuildDefaultTrueRecursively,
"external/fmtlib": Bp2BuildDefaultTrueRecursively,
"external/fsverity-utils": Bp2BuildDefaultTrueRecursively,
+ "external/gflags": Bp2BuildDefaultTrueRecursively,
"external/google-benchmark": Bp2BuildDefaultTrueRecursively,
"external/googletest": Bp2BuildDefaultTrueRecursively,
"external/guava": Bp2BuildDefaultTrueRecursively,
@@ -1095,6 +1096,7 @@
"ion-unit-tests",
"jemalloc5_integrationtests",
"jemalloc5_unittests",
+ "jemalloc5_stresstests", // run by run_jemalloc_tests.sh and will be deleted after V
"ld_config_test_helper",
"ld_preload_test_helper",
"libBionicCtsGtestMain", // depends on unconverted modules: libgtest_isolated
diff --git a/android/bazel.go b/android/bazel.go
index df30ff2..e4fada0 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -21,6 +21,7 @@
"strings"
"android/soong/ui/metrics/bp2build_metrics_proto"
+
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
@@ -153,8 +154,8 @@
HasHandcraftedLabel() bool
HandcraftedLabel() string
GetBazelLabel(ctx BazelConversionPathContext, module blueprint.Module) string
- ShouldConvertWithBp2build(ctx BazelConversionContext) bool
- shouldConvertWithBp2build(ctx bazelOtherModuleContext, module blueprint.Module) bool
+ ShouldConvertWithBp2build(ctx ShouldConvertWithBazelContext) bool
+ shouldConvertWithBp2build(shouldConvertModuleContext, shouldConvertParams) bool
// ConvertWithBp2build either converts the module to a Bazel build target or
// declares the module as unconvertible (for logging and metrics).
@@ -448,12 +449,32 @@
if !ok {
return false
}
- return b.shouldConvertWithBp2build(ctx, module) || b.HasHandcraftedLabel()
+
+ return b.HasHandcraftedLabel() || b.shouldConvertWithBp2build(ctx, shouldConvertParams{
+ module: module,
+ moduleDir: ctx.OtherModuleDir(module),
+ moduleName: ctx.OtherModuleName(module),
+ moduleType: ctx.OtherModuleType(module),
+ })
+}
+
+type ShouldConvertWithBazelContext interface {
+ ModuleErrorf(format string, args ...interface{})
+ Module() Module
+ Config() Config
+ ModuleType() string
+ ModuleName() string
+ ModuleDir() string
}
// ShouldConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build
-func (b *BazelModuleBase) ShouldConvertWithBp2build(ctx BazelConversionContext) bool {
- return b.shouldConvertWithBp2build(ctx, ctx.Module())
+func (b *BazelModuleBase) ShouldConvertWithBp2build(ctx ShouldConvertWithBazelContext) bool {
+ return b.shouldConvertWithBp2build(ctx, shouldConvertParams{
+ module: ctx.Module(),
+ moduleDir: ctx.ModuleDir(),
+ moduleName: ctx.ModuleName(),
+ moduleType: ctx.ModuleType(),
+ })
}
type bazelOtherModuleContext interface {
@@ -471,11 +492,24 @@
arch == Riscv64 // TODO(b/262192655) Riscv64 toolchains are not currently supported.
}
-func (b *BazelModuleBase) shouldConvertWithBp2build(ctx bazelOtherModuleContext, module blueprint.Module) bool {
+type shouldConvertModuleContext interface {
+ ModuleErrorf(format string, args ...interface{})
+ Config() Config
+}
+
+type shouldConvertParams struct {
+ module blueprint.Module
+ moduleType string
+ moduleDir string
+ moduleName string
+}
+
+func (b *BazelModuleBase) shouldConvertWithBp2build(ctx shouldConvertModuleContext, p shouldConvertParams) bool {
if !b.bazelProps().Bazel_module.CanConvertToBazel {
return false
}
+ module := p.module
// In api_bp2build mode, all soong modules that can provide API contributions should be converted
// This is irrespective of its presence/absence in bp2build allowlists
if ctx.Config().BuildMode == ApiBp2build {
@@ -484,7 +518,7 @@
}
propValue := b.bazelProperties.Bazel_module.Bp2build_available
- packagePath := moduleDirWithPossibleOverride(ctx, module)
+ packagePath := moduleDirWithPossibleOverride(ctx, module, p.moduleDir)
// Modules in unit tests which are enabled in the allowlist by type or name
// trigger this conditional because unit tests run under the "." package path
@@ -493,10 +527,10 @@
return true
}
- moduleName := moduleNameWithPossibleOverride(ctx, module)
+ moduleName := moduleNameWithPossibleOverride(ctx, module, p.moduleName)
allowlist := ctx.Config().Bp2buildPackageConfig
moduleNameAllowed := allowlist.moduleAlwaysConvert[moduleName]
- moduleTypeAllowed := allowlist.moduleTypeAlwaysConvert[ctx.OtherModuleType(module)]
+ moduleTypeAllowed := allowlist.moduleTypeAlwaysConvert[p.moduleType]
allowlistConvert := moduleNameAllowed || moduleTypeAllowed
if moduleNameAllowed && moduleTypeAllowed {
ctx.ModuleErrorf("A module cannot be in moduleAlwaysConvert and also be in moduleTypeAlwaysConvert")
@@ -588,8 +622,21 @@
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "")
return
}
+ // There may be cases where the target is created by a macro rather than in a BUILD file, those
+ // should be captured as well.
+ if bModule.HasHandcraftedLabel() {
+ // Defer to the BUILD target. Generating an additional target would
+ // cause a BUILD file conflict.
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_DEFINED_IN_BUILD_FILE, "")
+ return
+ }
// TODO: b/285631638 - Differentiate between denylisted modules and missing bp2build capabilities.
- if !bModule.shouldConvertWithBp2build(ctx, ctx.Module()) {
+ if !bModule.shouldConvertWithBp2build(ctx, shouldConvertParams{
+ module: ctx.Module(),
+ moduleDir: ctx.ModuleDir(),
+ moduleName: ctx.ModuleName(),
+ moduleType: ctx.ModuleType(),
+ }) {
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_UNSUPPORTED, "")
return
}
diff --git a/android/bazel_paths.go b/android/bazel_paths.go
index b08a4ca..7992564 100644
--- a/android/bazel_paths.go
+++ b/android/bazel_paths.go
@@ -88,6 +88,8 @@
EarlyModulePathContext
BazelConversionContext
+ ModuleName() string
+ ModuleType() string
ModuleErrorf(fmt string, args ...interface{})
PropertyErrorf(property, fmt string, args ...interface{})
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
@@ -459,8 +461,8 @@
}
func bp2buildModuleLabel(ctx BazelConversionContext, module blueprint.Module) string {
- moduleName := moduleNameWithPossibleOverride(ctx, module)
- moduleDir := moduleDirWithPossibleOverride(ctx, module)
+ moduleName := moduleNameWithPossibleOverride(ctx, module, ctx.OtherModuleName(module))
+ moduleDir := moduleDirWithPossibleOverride(ctx, module, ctx.OtherModuleDir(module))
if moduleDir == Bp2BuildTopLevel {
moduleDir = ""
}
diff --git a/android/bazel_paths_test.go b/android/bazel_paths_test.go
index 60c0a14..75b77a3 100644
--- a/android/bazel_paths_test.go
+++ b/android/bazel_paths_test.go
@@ -19,6 +19,7 @@
"testing"
"android/soong/bazel"
+
"github.com/google/blueprint"
"github.com/google/blueprint/pathtools"
)
@@ -157,6 +158,14 @@
return ctx.moduleDir
}
+func (ctx *TestBazelConversionPathContext) ModuleName() string {
+ panic("Unimplemented")
+}
+
+func (ctx *TestBazelConversionPathContext) ModuleType() string {
+ panic("Unimplemented")
+}
+
func TestTransformSubpackagePath(t *testing.T) {
cfg := NullConfig("out", "out/soong")
cfg.fs = pathtools.MockFs(map[string][]byte{
diff --git a/android/bazel_test.go b/android/bazel_test.go
index 13fd408..194a6b3 100644
--- a/android/bazel_test.go
+++ b/android/bazel_test.go
@@ -373,7 +373,14 @@
allowlist: test.allowlist,
}
- shouldConvert := test.module.shouldConvertWithBp2build(bcc, test.module.TestModuleInfo)
+ shouldConvert := test.module.shouldConvertWithBp2build(bcc,
+ shouldConvertParams{
+ module: test.module.TestModuleInfo,
+ moduleDir: test.module.TestModuleInfo.Dir,
+ moduleType: test.module.TestModuleInfo.Typ,
+ moduleName: test.module.TestModuleInfo.ModuleName,
+ },
+ )
if test.shouldConvert != shouldConvert {
t.Errorf("Module shouldConvert expected to be: %v, but was: %v", test.shouldConvert, shouldConvert)
}
diff --git a/android/override_module.go b/android/override_module.go
index a4b7431..9e0de6f 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -353,26 +353,26 @@
// variant of this OverridableModule, or ctx.ModuleName() if this module is not an OverridableModule
// or if this variant is not overridden.
func ModuleNameWithPossibleOverride(ctx BazelConversionContext) string {
- return moduleNameWithPossibleOverride(ctx, ctx.Module())
+ return moduleNameWithPossibleOverride(ctx, ctx.Module(), ctx.OtherModuleName(ctx.Module()))
}
-func moduleNameWithPossibleOverride(ctx bazelOtherModuleContext, module blueprint.Module) string {
+func moduleNameWithPossibleOverride(ctx shouldConvertModuleContext, module blueprint.Module, name string) string {
if overridable, ok := module.(OverridableModule); ok {
if o := overridable.GetOverriddenBy(); o != "" {
return o
}
}
- return ctx.OtherModuleName(module)
+ return name
}
// moduleDirWithPossibleOverride returns the dir of the OverrideModule that overrides the current
// variant of the given OverridableModule, or ctx.OtherModuleName() if the module is not an
// OverridableModule or if the variant is not overridden.
-func moduleDirWithPossibleOverride(ctx bazelOtherModuleContext, module blueprint.Module) string {
+func moduleDirWithPossibleOverride(ctx shouldConvertModuleContext, module blueprint.Module, dir string) string {
if overridable, ok := module.(OverridableModule); ok {
if o := overridable.GetOverriddenByModuleDir(); o != "" {
return o
}
}
- return ctx.OtherModuleDir(module)
+ return dir
}
diff --git a/android/proto.go b/android/proto.go
index 49b3733..b21efd6 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -283,6 +283,15 @@
}
}
+ // TODO - b/246997908: Handle potential orphaned proto_library targets
+ // To create proto_library targets in the same package, we split the .proto files
+ // This means that if a proto_library in a subpackage imports another proto_library from the parent package
+ // (or a different subpackage), it will not find it.
+ // The CcProtoGen action itself runs fine because we construct the correct ProtoInfo,
+ // but the FileDescriptorSet of each proto_library might not be compile-able
+ if pkg != ctx.ModuleDir() {
+ tags.Append(bazel.MakeStringListAttribute([]string{"manual"}))
+ }
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
CommonAttributes{Name: name, Dir: proptools.StringPtr(pkg), Tags: tags},
diff --git a/android/variable.go b/android/variable.go
index bae2adc..ca9a221 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -138,6 +138,7 @@
Srcs []string
Exclude_srcs []string
+ Cmd *string
}
// eng is true for -eng builds, and can be used to turn on additional heavyweight debugging
@@ -677,11 +678,16 @@
if moduleBase.variableProperties != nil {
productVariablesProperty := proptools.FieldNameForProperty("product_variables")
- for /* axis */ _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) {
- for config, props := range configToProps {
- variableValues := reflect.ValueOf(props).Elem().FieldByName(productVariablesProperty)
- productConfigProperties.AddProductConfigProperties(variableValues, config)
+ if moduleBase.ArchSpecific() {
+ for /* axis */ _, configToProps := range moduleBase.GetArchVariantProperties(ctx, moduleBase.variableProperties) {
+ for config, props := range configToProps {
+ variableValues := reflect.ValueOf(props).Elem().FieldByName(productVariablesProperty)
+ productConfigProperties.AddProductConfigProperties(variableValues, config)
+ }
}
+ } else {
+ variableValues := reflect.ValueOf(moduleBase.variableProperties).Elem().FieldByName(productVariablesProperty)
+ productConfigProperties.AddProductConfigProperties(variableValues, "")
}
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index bd19cb5..8368db1 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -390,7 +390,7 @@
name: "foo.rust",
srcs: ["foo.rs"],
rlibs: ["libfoo.rlib.rust"],
- dylibs: ["libfoo.dylib.rust"],
+ rustlibs: ["libfoo.dylib.rust"],
apex_available: ["myapex"],
}
diff --git a/bazel/configurability.go b/bazel/configurability.go
index 671e5c1..aa58fdc 100644
--- a/bazel/configurability.go
+++ b/bazel/configurability.go
@@ -76,6 +76,8 @@
NonApex = "non_apex"
ErrorproneDisabled = "errorprone_disabled"
+ // TODO: b/294868620 - Remove when completing the bug
+ SanitizersEnabled = "sanitizers_enabled"
)
func PowerSetWithoutEmptySet[T any](items []T) [][]T {
@@ -223,6 +225,12 @@
ErrorproneDisabled: "//build/bazel/rules/java/errorprone:errorprone_globally_disabled",
ConditionsDefaultConfigKey: ConditionsDefaultSelectKey,
}
+
+ // TODO: b/294868620 - Remove when completing the bug
+ sanitizersEnabledMap = map[string]string{
+ SanitizersEnabled: "//build/bazel/rules/cc:sanitizers_enabled",
+ ConditionsDefaultConfigKey: ConditionsDefaultSelectKey,
+ }
)
// basic configuration types
@@ -237,6 +245,8 @@
osAndInApex
inApex
errorProneDisabled
+ // TODO: b/294868620 - Remove when completing the bug
+ sanitizersEnabled
)
func osArchString(os string, arch string) string {
@@ -253,6 +263,8 @@
osAndInApex: "os_in_apex",
inApex: "in_apex",
errorProneDisabled: "errorprone_disabled",
+ // TODO: b/294868620 - Remove when completing the bug
+ sanitizersEnabled: "sanitizers_enabled",
}[ct]
}
@@ -287,6 +299,11 @@
if _, ok := errorProneMap[config]; !ok {
panic(fmt.Errorf("Unknown errorprone config: %s", config))
}
+ // TODO: b/294868620 - Remove when completing the bug
+ case sanitizersEnabled:
+ if _, ok := sanitizersEnabledMap[config]; !ok {
+ panic(fmt.Errorf("Unknown sanitizers_enabled config: %s", config))
+ }
default:
panic(fmt.Errorf("Unrecognized ConfigurationType %d", ct))
}
@@ -318,6 +335,9 @@
return inApexMap[config]
case errorProneDisabled:
return errorProneMap[config]
+ // TODO: b/294868620 - Remove when completing the bug
+ case sanitizersEnabled:
+ return sanitizersEnabledMap[config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationType %d", ca.configurationType))
}
@@ -338,6 +358,9 @@
InApexAxis = ConfigurationAxis{configurationType: inApex}
ErrorProneAxis = ConfigurationAxis{configurationType: errorProneDisabled}
+
+ // TODO: b/294868620 - Remove when completing the bug
+ SanitizersEnabledAxis = ConfigurationAxis{configurationType: sanitizersEnabled}
)
// ProductVariableConfigurationAxis returns an axis for the given product variable
diff --git a/bazel/properties.go b/bazel/properties.go
index 702c31c..9c63bc0 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -194,14 +194,7 @@
// UniqueSortedBazelLabels takes a []Label and deduplicates the labels, and returns
// the slice in a sorted order.
func UniqueSortedBazelLabels(originalLabels []Label) []Label {
- uniqueLabelsSet := make(map[Label]bool)
- for _, l := range originalLabels {
- uniqueLabelsSet[l] = true
- }
- var uniqueLabels []Label
- for l, _ := range uniqueLabelsSet {
- uniqueLabels = append(uniqueLabels, l)
- }
+ uniqueLabels := FirstUniqueBazelLabels(originalLabels)
sort.SliceStable(uniqueLabels, func(i, j int) bool {
return uniqueLabels[i].Label < uniqueLabels[j].Label
})
@@ -210,13 +203,13 @@
func FirstUniqueBazelLabels(originalLabels []Label) []Label {
var labels []Label
- found := make(map[Label]bool, len(originalLabels))
+ found := make(map[string]bool, len(originalLabels))
for _, l := range originalLabels {
- if _, ok := found[l]; ok {
+ if _, ok := found[l.Label]; ok {
continue
}
labels = append(labels, l)
- found[l] = true
+ found[l.Label] = true
}
return labels
}
@@ -433,7 +426,7 @@
switch axis.configurationType {
case noConfig:
la.Value = &value
- case arch, os, osArch, productVariables, osAndInApex:
+ case arch, os, osArch, productVariables, osAndInApex, sanitizersEnabled:
if la.ConfigurableValues == nil {
la.ConfigurableValues = make(configurableLabels)
}
@@ -449,7 +442,7 @@
switch axis.configurationType {
case noConfig:
return la.Value
- case arch, os, osArch, productVariables, osAndInApex:
+ case arch, os, osArch, productVariables, osAndInApex, sanitizersEnabled:
return la.ConfigurableValues[axis][config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
@@ -519,7 +512,7 @@
switch axis.configurationType {
case noConfig:
ba.Value = value
- case arch, os, osArch, productVariables, osAndInApex:
+ case arch, os, osArch, productVariables, osAndInApex, sanitizersEnabled:
if ba.ConfigurableValues == nil {
ba.ConfigurableValues = make(configurableBools)
}
@@ -666,7 +659,7 @@
switch axis.configurationType {
case noConfig:
return ba.Value
- case arch, os, osArch, productVariables, osAndInApex:
+ case arch, os, osArch, productVariables, osAndInApex, sanitizersEnabled:
if v, ok := ba.ConfigurableValues[axis][config]; ok {
return &v
} else {
@@ -801,7 +794,7 @@
switch axis.configurationType {
case noConfig:
lla.Value = list
- case arch, os, osArch, productVariables, osAndInApex, inApex, errorProneDisabled:
+ case arch, os, osArch, productVariables, osAndInApex, inApex, errorProneDisabled, sanitizersEnabled:
if lla.ConfigurableValues == nil {
lla.ConfigurableValues = make(configurableLabelLists)
}
@@ -817,7 +810,7 @@
switch axis.configurationType {
case noConfig:
return lla.Value
- case arch, os, osArch, productVariables, osAndInApex, inApex, errorProneDisabled:
+ case arch, os, osArch, productVariables, osAndInApex, inApex, errorProneDisabled, sanitizersEnabled:
return lla.ConfigurableValues[axis][config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
@@ -1175,7 +1168,7 @@
switch axis.configurationType {
case noConfig:
sa.Value = str
- case arch, os, osArch, productVariables:
+ case arch, os, osArch, productVariables, sanitizersEnabled:
if sa.ConfigurableValues == nil {
sa.ConfigurableValues = make(configurableStrings)
}
@@ -1191,7 +1184,7 @@
switch axis.configurationType {
case noConfig:
return sa.Value
- case arch, os, osArch, productVariables:
+ case arch, os, osArch, productVariables, sanitizersEnabled:
if v, ok := sa.ConfigurableValues[axis][config]; ok {
return v
} else {
@@ -1381,7 +1374,7 @@
switch axis.configurationType {
case noConfig:
sla.Value = list
- case arch, os, osArch, productVariables, osAndInApex, errorProneDisabled:
+ case arch, os, osArch, productVariables, osAndInApex, errorProneDisabled, sanitizersEnabled:
if sla.ConfigurableValues == nil {
sla.ConfigurableValues = make(configurableStringLists)
}
@@ -1397,7 +1390,7 @@
switch axis.configurationType {
case noConfig:
return sla.Value
- case arch, os, osArch, productVariables, osAndInApex, errorProneDisabled:
+ case arch, os, osArch, productVariables, osAndInApex, errorProneDisabled, sanitizersEnabled:
return sla.ConfigurableValues[axis][config]
default:
panic(fmt.Errorf("Unrecognized ConfigurationAxis %s", axis))
diff --git a/bazel/properties_test.go b/bazel/properties_test.go
index c98ae0e..751cb8b 100644
--- a/bazel/properties_test.go
+++ b/bazel/properties_test.go
@@ -33,8 +33,12 @@
{Label: "b"},
{Label: "a"},
{Label: "c"},
+ // namespaces
+ {Label: "//foo:bar", OriginalModuleName: "bar"}, // when referenced from foo namespace
+ {Label: "//foo:bar", OriginalModuleName: "//foo:bar"}, // when reference from root namespace
},
expectedUniqueLabels: []Label{
+ {Label: "//foo:bar", OriginalModuleName: "bar"},
{Label: "a"},
{Label: "b"},
{Label: "c"},
@@ -194,6 +198,9 @@
{Label: "b"},
{Label: "a"},
{Label: "c"},
+ // namespaces
+ {Label: "//foo:bar", OriginalModuleName: "bar"}, // when referenced from foo namespace
+ {Label: "//foo:bar", OriginalModuleName: "//foo:bar"}, // when referenced from root namespace
},
Excludes: []Label{
{Label: "x"},
@@ -207,6 +214,7 @@
{Label: "a"},
{Label: "b"},
{Label: "c"},
+ {Label: "//foo:bar", OriginalModuleName: "bar"},
},
Excludes: []Label{
{Label: "x"},
diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go
index d1b4d40..8ed94b4 100644
--- a/bp2build/android_app_conversion_test.go
+++ b/bp2build/android_app_conversion_test.go
@@ -40,6 +40,7 @@
"app.java": "",
"res/res.png": "",
"AndroidManifest.xml": "",
+ "assets/asset.png": "",
},
Blueprint: `
android_app {
@@ -54,6 +55,8 @@
"manifest": `"AndroidManifest.xml"`,
"resource_files": `["res/res.png"]`,
"sdk_version": `"current"`,
+ "assets": `["assets/asset.png"]`,
+ "assets_dir": `"assets"`,
}),
}})
}
@@ -68,6 +71,7 @@
"resa/res.png": "",
"resb/res.png": "",
"manifest/AndroidManifest.xml": "",
+ "assets_/asset.png": "",
},
Blueprint: simpleModuleDoNotConvertBp2build("android_app", "static_lib_dep") + `
android_app {
@@ -81,6 +85,7 @@
java_version: "7",
certificate: "foocert",
required: ["static_lib_dep"],
+ asset_dirs: ["assets_"],
}
`,
ExpectedBazelTargets: []string{
@@ -91,6 +96,8 @@
"resa/res.png",
"resb/res.png",
]`,
+ "assets": `["assets_/asset.png"]`,
+ "assets_dir": `"assets_"`,
"custom_package": `"com.google"`,
"deps": `[":static_lib_dep"]`,
"java_version": `"7"`,
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index 6ca4bb4..cd1bc7f 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -686,6 +686,9 @@
//
// bp2build converters are used for the majority of modules.
if b, ok := m.(android.Bazelable); ok && b.HasHandcraftedLabel() {
+ if aModule, ok := m.(android.Module); ok && aModule.IsConvertedByBp2build() {
+ panic(fmt.Errorf("module %q [%s] [%s] was both converted with bp2build and has a handcrafted label", bpCtx.ModuleName(m), moduleType, dir))
+ }
// Handle modules converted to handcrafted targets.
//
// Since these modules are associated with some handcrafted
diff --git a/bp2build/cc_binary_conversion_test.go b/bp2build/cc_binary_conversion_test.go
index d9a7860..90db365 100644
--- a/bp2build/cc_binary_conversion_test.go
+++ b/bp2build/cc_binary_conversion_test.go
@@ -880,8 +880,15 @@
}`,
targets: []testBazelTarget{
{"cc_binary", "foo", AttrNameToString{
+ "copts": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"],
+ "//conditions:default": [],
+ })`,
+ "additional_compiler_inputs": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"],
+ "//conditions:default": [],
+ })`,
"local_includes": `["."]`,
- "features": `["sanitizer_blocklist_foo_blocklist_txt"]`,
}},
},
})
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index e5ae73e..e70cd10 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -4206,11 +4206,25 @@
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
- "features": `["sanitizer_blocklist_foo_blocklist_txt"]`,
+ "copts": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"],
+ "//conditions:default": [],
+ })`,
+ "additional_compiler_inputs": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"],
+ "//conditions:default": [],
+ })`,
"local_includes": `["."]`,
}),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
- "features": `["sanitizer_blocklist_foo_blocklist_txt"]`,
+ "copts": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"],
+ "//conditions:default": [],
+ })`,
+ "additional_compiler_inputs": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"],
+ "//conditions:default": [],
+ })`,
"local_includes": `["."]`,
}),
},
@@ -4967,6 +4981,7 @@
tc.ExpectedBazelTargets = []string{
MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
"srcs": `["//bar:bar.proto"]`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
@@ -4976,6 +4991,7 @@
tc.ExpectedBazelTargets = []string{
MakeBazelTarget("proto_library", "foo_proto", AttrNameToString{
"srcs": `["//baz/subbaz:baz.proto"]`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
@@ -5035,6 +5051,7 @@
"srcs": `["//bar:bar.proto"]`,
"strip_import_prefix": `""`,
"import_prefix": `"bar"`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
@@ -5046,6 +5063,7 @@
"srcs": `["//baz/subbaz:baz.proto"]`,
"strip_import_prefix": `""`,
"import_prefix": `"baz/subbaz"`,
+ "tags": `["manual"]`,
}),
}
runCcLibraryTestCase(t, tc)
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index ccb426f..90b13b0 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -1225,7 +1225,14 @@
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
- "features": `["sanitizer_blocklist_foo_blocklist_txt"]`,
+ "copts": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"],
+ "//conditions:default": [],
+ })`,
+ "additional_compiler_inputs": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"],
+ "//conditions:default": [],
+ })`,
"local_includes": `["."]`,
}),
},
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 26baf89..89ec8f9 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1950,7 +1950,14 @@
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
- "features": `["sanitizer_blocklist_foo_blocklist_txt"]`,
+ "copts": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": ["-fsanitize-ignorelist=$(location foo_blocklist.txt)"],
+ "//conditions:default": [],
+ })`,
+ "additional_compiler_inputs": `select({
+ "//build/bazel/rules/cc:sanitizers_enabled": [":foo_blocklist.txt"],
+ "//conditions:default": [],
+ })`,
"local_includes": `["."]`,
}),
},
diff --git a/bp2build/genrule_conversion_test.go b/bp2build/genrule_conversion_test.go
index 5a73969..5ca8bd7 100644
--- a/bp2build/genrule_conversion_test.go
+++ b/bp2build/genrule_conversion_test.go
@@ -772,3 +772,144 @@
})
}
}
+
+func TestGenruleWithSoongConfigVariableConfiguredCmd(t *testing.T) {
+ testCases := []struct {
+ moduleType string
+ factory android.ModuleFactory
+ hod android.HostOrDeviceSupported
+ }{
+ {
+ moduleType: "genrule",
+ factory: genrule.GenRuleFactory,
+ },
+ {
+ moduleType: "cc_genrule",
+ factory: cc.GenRuleFactory,
+ hod: android.DeviceSupported,
+ },
+ {
+ moduleType: "java_genrule",
+ factory: java.GenRuleFactory,
+ hod: android.DeviceSupported,
+ },
+ {
+ moduleType: "java_genrule_host",
+ factory: java.GenRuleFactoryHost,
+ hod: android.HostSupported,
+ },
+ }
+
+ bp := `
+soong_config_module_type {
+ name: "my_genrule",
+ module_type: "%s",
+ config_namespace: "my_namespace",
+ bool_variables: ["my_variable"],
+ properties: ["cmd"],
+}
+
+my_genrule {
+ name: "foo",
+ out: ["foo.txt"],
+ cmd: "echo 'no variable' > $(out)",
+ soong_config_variables: {
+ my_variable: {
+ cmd: "echo 'with variable' > $(out)",
+ },
+ },
+ bazel_module: { bp2build_available: true },
+}
+`
+
+ for _, tc := range testCases {
+ moduleAttrs := AttrNameToString{
+ "cmd": `select({
+ "//build/bazel/product_config/config_settings:my_namespace__my_variable": "echo 'with variable' > $(OUTS)",
+ "//conditions:default": "echo 'no variable' > $(OUTS)",
+ })`,
+ "outs": `["foo.txt"]`,
+ }
+
+ expectedBazelTargets := []string{
+ makeBazelTargetHostOrDevice("genrule", "foo", moduleAttrs, tc.hod),
+ }
+
+ t.Run(tc.moduleType, func(t *testing.T) {
+ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { android.RegisterSoongConfigModuleBuildComponents(ctx) },
+ Bp2buildTestCase{
+ Blueprint: fmt.Sprintf(bp, tc.moduleType),
+ ModuleTypeUnderTest: tc.moduleType,
+ ModuleTypeUnderTestFactory: tc.factory,
+ ExpectedBazelTargets: expectedBazelTargets,
+ })
+ })
+ }
+}
+
+func TestGenruleWithProductVariableConfiguredCmd(t *testing.T) {
+ testCases := []struct {
+ moduleType string
+ factory android.ModuleFactory
+ hod android.HostOrDeviceSupported
+ }{
+ {
+ moduleType: "genrule",
+ factory: genrule.GenRuleFactory,
+ },
+ {
+ moduleType: "cc_genrule",
+ factory: cc.GenRuleFactory,
+ hod: android.DeviceSupported,
+ },
+ {
+ moduleType: "java_genrule",
+ factory: java.GenRuleFactory,
+ hod: android.DeviceSupported,
+ },
+ {
+ moduleType: "java_genrule_host",
+ factory: java.GenRuleFactoryHost,
+ hod: android.HostSupported,
+ },
+ }
+
+ bp := `
+
+%s {
+ name: "foo",
+ out: ["foo.txt"],
+ cmd: "echo 'no variable' > $(out)",
+ product_variables: {
+ debuggable: {
+ cmd: "echo 'with variable' > $(out)",
+ },
+ },
+ bazel_module: { bp2build_available: true },
+}
+`
+
+ for _, tc := range testCases {
+ moduleAttrs := AttrNameToString{
+ "cmd": `select({
+ "//build/bazel/product_config/config_settings:debuggable": "echo 'with variable' > $(OUTS)",
+ "//conditions:default": "echo 'no variable' > $(OUTS)",
+ })`,
+ "outs": `["foo.txt"]`,
+ }
+
+ expectedBazelTargets := []string{
+ makeBazelTargetHostOrDevice("genrule", "foo", moduleAttrs, tc.hod),
+ }
+
+ t.Run(tc.moduleType, func(t *testing.T) {
+ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { android.RegisterSoongConfigModuleBuildComponents(ctx) },
+ Bp2buildTestCase{
+ Blueprint: fmt.Sprintf(bp, tc.moduleType),
+ ModuleTypeUnderTest: tc.moduleType,
+ ModuleTypeUnderTestFactory: tc.factory,
+ ExpectedBazelTargets: expectedBazelTargets,
+ })
+ })
+ }
+}
diff --git a/cc/binary.go b/cc/binary.go
index 5ba33a2..4606b62 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -638,7 +638,8 @@
Stl: baseAttrs.stl,
Cpp_std: baseAttrs.cppStd,
- Additional_linker_inputs: baseAttrs.additionalLinkerInputs,
+ Additional_linker_inputs: baseAttrs.additionalLinkerInputs,
+ Additional_compiler_inputs: baseAttrs.additionalCompilerInputs,
Strip: stripAttributes{
Keep_symbols: baseAttrs.stripKeepSymbols,
@@ -680,10 +681,11 @@
Srcs_c bazel.LabelListAttribute
Srcs_as bazel.LabelListAttribute
- Copts bazel.StringListAttribute
- Cppflags bazel.StringListAttribute
- Conlyflags bazel.StringListAttribute
- Asflags bazel.StringListAttribute
+ Copts bazel.StringListAttribute
+ Cppflags bazel.StringListAttribute
+ Conlyflags bazel.StringListAttribute
+ Asflags bazel.StringListAttribute
+ Additional_compiler_inputs bazel.LabelListAttribute
Deps bazel.LabelListAttribute
Dynamic_deps bazel.LabelListAttribute
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 9d90a5b..601c0c5 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -65,6 +65,8 @@
Hdrs bazel.LabelListAttribute
Copts bazel.StringListAttribute
+ Additional_compiler_inputs bazel.LabelListAttribute
+
Deps bazel.LabelListAttribute
Implementation_deps bazel.LabelListAttribute
Dynamic_deps bazel.LabelListAttribute
@@ -508,6 +510,8 @@
suffix bazel.StringAttribute
fdoProfile bazel.LabelAttribute
+
+ additionalCompilerInputs bazel.LabelListAttribute
}
type filterOutFn func(string) bool
@@ -1016,11 +1020,16 @@
(&compilerAttrs).localIncludes.Append(rsLocalIncludes)
(&compilerAttrs).localIncludes.Value = android.FirstUniqueStrings(compilerAttrs.localIncludes.Value)
- features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(bp2buildSanitizerFeatures(ctx, module))
+ sanitizerValues := bp2buildSanitizerFeatures(ctx, module)
+
+ features := compilerAttrs.features.Clone().Append(linkerAttrs.features).Append(sanitizerValues.features)
features = features.Append(bp2buildLtoFeatures(ctx, module))
features = features.Append(convertHiddenVisibilityToFeatureBase(ctx, module))
features.DeduplicateAxesFromBase()
+ compilerAttrs.copts = *compilerAttrs.copts.Append(sanitizerValues.copts)
+ compilerAttrs.additionalCompilerInputs = *compilerAttrs.additionalCompilerInputs.Append(sanitizerValues.additionalCompilerInputs)
+
addMuslSystemDynamicDeps(ctx, linkerAttrs)
return baseAttributes{
@@ -1910,8 +1919,16 @@
return attrs
}
-func bp2buildSanitizerFeatures(ctx android.BazelConversionPathContext, m *Module) bazel.StringListAttribute {
+type sanitizerValues struct {
+ features bazel.StringListAttribute
+ copts bazel.StringListAttribute
+ additionalCompilerInputs bazel.LabelListAttribute
+}
+
+func bp2buildSanitizerFeatures(ctx android.BazelConversionPathContext, m *Module) sanitizerValues {
sanitizerFeatures := bazel.StringListAttribute{}
+ sanitizerCopts := bazel.StringListAttribute{}
+ sanitizerCompilerInputs := bazel.LabelListAttribute{}
bp2BuildPropParseHelper(ctx, m, &SanitizeProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
var features []string
if sanitizerProps, ok := props.(*SanitizeProperties); ok {
@@ -1923,9 +1940,10 @@
}
blocklist := sanitizerProps.Sanitize.Blocklist
if blocklist != nil {
- // Format the blocklist name to be used in a feature name
- blocklistFeatureSuffix := strings.Replace(strings.ToLower(*blocklist), ".", "_", -1)
- features = append(features, "sanitizer_blocklist_"+blocklistFeatureSuffix)
+ // TODO: b/294868620 - Change this not to use the special axis when completing the bug
+ coptValue := fmt.Sprintf("-fsanitize-ignorelist=$(location %s)", *blocklist)
+ sanitizerCopts.SetSelectValue(bazel.SanitizersEnabledAxis, bazel.SanitizersEnabled, []string{coptValue})
+ sanitizerCompilerInputs.SetSelectValue(bazel.SanitizersEnabledAxis, bazel.SanitizersEnabled, bazel.MakeLabelListFromTargetNames([]string{*blocklist}))
}
if sanitizerProps.Sanitize.Cfi != nil && !proptools.Bool(sanitizerProps.Sanitize.Cfi) {
features = append(features, "-android_cfi")
@@ -1938,7 +1956,11 @@
sanitizerFeatures.SetSelectValue(axis, config, features)
}
})
- return sanitizerFeatures
+ return sanitizerValues{
+ features: sanitizerFeatures,
+ copts: sanitizerCopts,
+ additionalCompilerInputs: sanitizerCompilerInputs,
+ }
}
func bp2buildLtoFeatures(ctx android.BazelConversionPathContext, m *Module) bazel.StringListAttribute {
diff --git a/cc/library.go b/cc/library.go
index df1dbc5..2d4d604 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -349,6 +349,7 @@
Runtime_deps: linkerAttrs.runtimeDeps,
sdkAttributes: bp2BuildParseSdkAttributes(m),
Native_coverage: baseAttributes.Native_coverage,
+ Additional_compiler_inputs: compilerAttrs.additionalCompilerInputs,
}
includeAttrs := includesAttributes{
@@ -376,6 +377,7 @@
Runtime_deps: linkerAttrs.runtimeDeps,
sdkAttributes: bp2BuildParseSdkAttributes(m),
Native_coverage: baseAttributes.Native_coverage,
+ Additional_compiler_inputs: compilerAttrs.additionalCompilerInputs,
}
staticTargetAttrs := &bazelCcLibraryStaticAttributes{
@@ -2962,6 +2964,7 @@
sdkAttributes: bp2BuildParseSdkAttributes(module),
Runtime_deps: linkerAttrs.runtimeDeps,
Native_coverage: baseAttributes.Native_coverage,
+ Additional_compiler_inputs: compilerAttrs.additionalCompilerInputs,
}
module.convertTidyAttributes(ctx, &commonAttrs.tidyAttributes)
diff --git a/cc/lto.go b/cc/lto.go
index df9ca0a..820c1f0 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -162,7 +162,7 @@
}
func GlobalThinLTO(ctx android.BaseModuleContext) bool {
- return !ctx.Config().IsEnvFalse("GLOBAL_THINLTO")
+ return ctx.Config().IsEnvTrue("GLOBAL_THINLTO")
}
// Propagate lto requirements down from binaries
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 8a8d605..aa4295d 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -869,7 +869,7 @@
Srcs bazel.LabelListAttribute
Output_extension *string
Tools bazel.LabelListAttribute
- Cmd string
+ Cmd bazel.StringAttribute
Data bazel.LabelListAttribute
}
@@ -917,7 +917,7 @@
Srcs bazel.LabelListAttribute
Outs []string
Tools bazel.LabelListAttribute
- Cmd string
+ Cmd bazel.StringAttribute
}
// ConvertWithBp2build converts a Soong module -> Bazel target.
@@ -967,14 +967,13 @@
}
}
- // Replace in and out variables with $< and $@
- var cmd string
- if m.properties.Cmd != nil {
+ replaceVariables := func(cmd string) string {
+ // Replace in and out variables with $< and $@
if ctx.ModuleType() == "gensrcs" {
- cmd = strings.ReplaceAll(*m.properties.Cmd, "$(in)", "$(SRC)")
+ cmd = strings.ReplaceAll(cmd, "$(in)", "$(SRC)")
cmd = strings.ReplaceAll(cmd, "$(out)", "$(OUT)")
} else {
- cmd = strings.Replace(*m.properties.Cmd, "$(in)", "$(SRCS)", -1)
+ cmd = strings.Replace(cmd, "$(in)", "$(SRCS)", -1)
cmd = strings.Replace(cmd, "$(out)", "$(OUTS)", -1)
}
cmd = strings.Replace(cmd, "$(genDir)", "$(RULEDIR)", -1)
@@ -990,6 +989,21 @@
cmd = strings.Replace(cmd, bpLoc, bazelLoc, -1)
cmd = strings.Replace(cmd, bpLocs, bazelLocs, -1)
}
+ return cmd
+ }
+
+ var cmdProp bazel.StringAttribute
+ cmdProp.SetValue(replaceVariables(proptools.String(m.properties.Cmd)))
+ allProductVariableProps := android.ProductVariableProperties(ctx, m)
+ if productVariableProps, ok := allProductVariableProps["Cmd"]; ok {
+ for productVariable, value := range productVariableProps {
+ var cmd string
+ if strValue, ok := value.(*string); ok && strValue != nil {
+ cmd = *strValue
+ }
+ cmd = replaceVariables(cmd)
+ cmdProp.SetSelectValue(productVariable.ConfigurationAxis(), productVariable.SelectKey(), &cmd)
+ }
}
tags := android.ApexAvailableTagsWithoutTestApexes(ctx, m)
@@ -1003,7 +1017,7 @@
attrs := &bazelGensrcsAttributes{
Srcs: srcs,
Output_extension: outputExtension,
- Cmd: cmd,
+ Cmd: cmdProp,
Tools: tools,
Data: data,
}
@@ -1026,7 +1040,7 @@
attrs := &bazelGenruleAttributes{
Srcs: srcs,
Outs: outs,
- Cmd: cmd,
+ Cmd: cmdProp,
Tools: tools,
}
props := bazel.BazelTargetModuleProperties{
@@ -1056,7 +1070,6 @@
Name: m.Name() + genruleHeaderLibrarySuffix,
Tags: tags,
}, attrs)
-
}
}
diff --git a/java/aar.go b/java/aar.go
index 1e38efc..308a48c 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -23,6 +23,7 @@
"android/soong/android"
"android/soong/bazel"
"android/soong/dexpreopt"
+ "android/soong/ui/metrics/bp2build_metrics_proto"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -1228,6 +1229,8 @@
type bazelAapt struct {
Manifest bazel.Label
Resource_files bazel.LabelListAttribute
+ Assets_dir bazel.StringAttribute
+ Assets bazel.LabelListAttribute
}
type bazelAndroidLibrary struct {
@@ -1242,7 +1245,7 @@
Sdk_version bazel.StringAttribute
}
-func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) *bazelAapt {
+func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) (*bazelAapt, bool) {
manifest := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
resourceFiles := bazel.LabelList{
@@ -1252,10 +1255,30 @@
files := android.RootToModuleRelativePaths(ctx, androidResourceGlob(ctx, dir))
resourceFiles.Includes = append(resourceFiles.Includes, files...)
}
+
+ assetsDir := bazel.StringAttribute{}
+ var assets bazel.LabelList
+ for i, dir := range android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets") {
+ if i > 0 {
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "multiple asset_dirs")
+ return &bazelAapt{}, false
+ }
+ // Assets_dirs are relative to the module dir when specified, but if the default in used in
+ // PathsWithOptionalDefaultForModuleSrc, then dir is relative to the top.
+ assetsRelDir, error := filepath.Rel(ctx.ModuleDir(), dir.Rel())
+ if error != nil {
+ assetsRelDir = dir.Rel()
+ }
+ assetsDir.Value = proptools.StringPtr(assetsRelDir)
+ assets = bazel.MakeLabelList(android.RootToModuleRelativePaths(ctx, androidResourceGlob(ctx, dir)))
+
+ }
return &bazelAapt{
android.BazelLabelForModuleSrcSingle(ctx, manifest),
bazel.MakeLabelListAttribute(resourceFiles),
- }
+ assetsDir,
+ bazel.MakeLabelListAttribute(assets),
+ }, true
}
func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
@@ -1328,6 +1351,10 @@
name := a.Name()
props := AndroidLibraryBazelTargetModuleProperties()
+ aaptAttrs, supported := a.convertAaptAttrsWithBp2Build(ctx)
+ if !supported {
+ return
+ }
ctx.CreateBazelTargetModule(
props,
android.CommonAttributes{Name: name},
@@ -1337,7 +1364,7 @@
Deps: deps,
Exports: depLabels.StaticDeps,
},
- a.convertAaptAttrsWithBp2Build(ctx),
+ aaptAttrs,
},
)
diff --git a/java/app.go b/java/app.go
index e277aed..1d1ea97 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1628,8 +1628,10 @@
deps := depLabels.Deps
deps.Append(depLabels.StaticDeps)
- aapt := a.convertAaptAttrsWithBp2Build(ctx)
-
+ aapt, supported := a.convertAaptAttrsWithBp2Build(ctx)
+ if !supported {
+ return
+ }
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate)
manifestValues := &manifestValueAttribute{}
diff --git a/java/java.go b/java/java.go
index 6667a52..70aba8e 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1683,6 +1683,9 @@
// extracting the compiled class files provided by the
// full_api_surface_stub module.
Full_api_surface_stub *string
+
+ // Version of previously released API file for compatibility check.
+ Previous_api *string `android:"path"`
}
func ApiLibraryFactory() android.Module {
@@ -1890,6 +1893,12 @@
al.stubsFlags(ctx, cmd, stubsDir)
+ migratingNullability := String(al.properties.Previous_api) != ""
+ if migratingNullability {
+ previousApi := android.PathForModuleSrc(ctx, String(al.properties.Previous_api))
+ cmd.FlagWithInput("--migrate-nullness ", previousApi)
+ }
+
al.stubsSrcJar = android.PathForModuleOut(ctx, "metalava", ctx.ModuleName()+"-"+"stubs.srcjar")
al.stubsJarWithoutStaticLibs = android.PathForModuleOut(ctx, "metalava", "stubs.jar")
al.stubsJar = android.PathForModuleOut(ctx, ctx.ModuleName(), fmt.Sprintf("%s.jar", ctx.ModuleName()))
diff --git a/java/sdk_library.go b/java/sdk_library.go
index a38262b..b1ddde0 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1853,7 +1853,7 @@
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.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName() + ".from-text")
+ props.Full_api_surface_stub = proptools.StringPtr(apiScope.kind.DefaultJavaLibraryName())
if alternativeFullApiSurfaceStub != "" {
props.Full_api_surface_stub = proptools.StringPtr(alternativeFullApiSurfaceStub)
}
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index c22b980..118f8b6 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1449,17 +1449,17 @@
{
scope: apiScopePublic,
apiContributions: []string{"foo.stubs.source.api.contribution"},
- fullApiSurfaceStub: "android_stubs_current.from-text",
+ fullApiSurfaceStub: "android_stubs_current",
},
{
scope: apiScopeSystem,
apiContributions: []string{"foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
- fullApiSurfaceStub: "android_system_stubs_current.from-text",
+ fullApiSurfaceStub: "android_system_stubs_current",
},
{
scope: apiScopeTest,
apiContributions: []string{"foo.stubs.source.test.api.contribution", "foo.stubs.source.system.api.contribution", "foo.stubs.source.api.contribution"},
- fullApiSurfaceStub: "android_test_stubs_current.from-text",
+ fullApiSurfaceStub: "android_test_stubs_current",
},
{
scope: apiScopeModuleLib,
diff --git a/python/builder.go b/python/builder.go
index 1066493..2553a77 100644
--- a/python/builder.go
+++ b/python/builder.go
@@ -73,14 +73,14 @@
precompile = pctx.AndroidStaticRule("precompilePython", blueprint.RuleParams{
Command: `LD_LIBRARY_PATH="$ldLibraryPath" ` +
- `PYTHONPATH=$stdlibZip/internal/stdlib ` +
+ `PYTHONPATH=$stdlibZip/internal/$stdlibPkg ` +
`$launcher build/soong/python/scripts/precompile_python.py $in $out`,
CommandDeps: []string{
"$stdlibZip",
"$launcher",
"build/soong/python/scripts/precompile_python.py",
},
- }, "stdlibZip", "launcher", "ldLibraryPath")
+ }, "stdlibZip", "stdlibPkg", "launcher", "ldLibraryPath")
)
func init() {
diff --git a/python/proto.go b/python/proto.go
index 400e72c..ad2b786 100644
--- a/python/proto.go
+++ b/python/proto.go
@@ -19,7 +19,8 @@
)
func genProto(ctx android.ModuleContext, protoFile android.Path, flags android.ProtoFlags) android.Path {
- srcsZipFile := android.PathForModuleGen(ctx, protoFile.Base()+".srcszip")
+ // Using protoFile.Base() would generate duplicate source errors in some cases, so we use Rel() instead
+ srcsZipFile := android.PathForModuleGen(ctx, protoFile.Rel()+".srcszip")
outDir := srcsZipFile.ReplaceExtension(ctx, "tmp")
depFile := srcsZipFile.ReplaceExtension(ctx, "srcszip.d")
diff --git a/python/python.go b/python/python.go
index 8fde638..6c837a8 100644
--- a/python/python.go
+++ b/python/python.go
@@ -169,6 +169,7 @@
getDataPathMappings() []pathMapping
getSrcsZip() android.Path
getPrecompiledSrcsZip() android.Path
+ getPkgPath() string
}
// getSrcsPathMappings gets this module's path mapping of src source path : runfiles destination
@@ -191,6 +192,11 @@
return p.precompiledSrcsZip
}
+// getPkgPath returns the pkg_path value
+func (p *PythonLibraryModule) getPkgPath() string {
+ return String(p.properties.Pkg_path)
+}
+
func (p *PythonLibraryModule) getBaseProperties() *BaseProperties {
return &p.properties
}
@@ -370,7 +376,20 @@
launcherSharedLibDeps = append(launcherSharedLibDeps, "libc++")
case pyVersion3:
- stdLib = "py3-stdlib"
+ var prebuiltStdLib bool
+ if targetForDeps.Os.Bionic() {
+ prebuiltStdLib = false
+ } else if ctx.Config().VendorConfig("cpython3").Bool("force_build_host") {
+ prebuiltStdLib = false
+ } else {
+ prebuiltStdLib = true
+ }
+
+ if prebuiltStdLib {
+ stdLib = "py3-stdlib-prebuilt"
+ } else {
+ stdLib = "py3-stdlib"
+ }
launcherModule = "py3-launcher"
if autorun {
@@ -461,14 +480,19 @@
destToPySrcs := make(map[string]string)
destToPyData := make(map[string]string)
+ // Disable path checks for the stdlib, as it includes a "." in the version string
+ isInternal := proptools.BoolDefault(p.properties.Is_internal, false)
+
for _, s := range expandedSrcs {
if s.Ext() != pyExt && s.Ext() != protoExt {
ctx.PropertyErrorf("srcs", "found non (.py|.proto) file: %q!", s.String())
continue
}
runfilesPath := filepath.Join(pkgPath, s.Rel())
- if err := isValidPythonPath(runfilesPath); err != nil {
- ctx.PropertyErrorf("srcs", err.Error())
+ if !isInternal {
+ if err := isValidPythonPath(runfilesPath); err != nil {
+ ctx.PropertyErrorf("srcs", err.Error())
+ }
}
if !checkForDuplicateOutputPath(ctx, destToPySrcs, runfilesPath, s.String(), p.Name(), p.Name()) {
p.srcsPathMappings = append(p.srcsPathMappings, pathMapping{dest: runfilesPath, src: s})
@@ -591,13 +615,16 @@
// "cross compiling" for device here purely by virtue of host and device python bytecode
// being the same.
var stdLib android.Path
+ var stdLibPkg string
var launcher android.Path
- if ctx.ModuleName() == "py3-stdlib" || ctx.ModuleName() == "py2-stdlib" {
+ if proptools.BoolDefault(p.properties.Is_internal, false) {
stdLib = p.srcsZip
+ stdLibPkg = p.getPkgPath()
} else {
ctx.VisitDirectDepsWithTag(hostStdLibTag, func(module android.Module) {
if dep, ok := module.(pythonDependency); ok {
stdLib = dep.getPrecompiledSrcsZip()
+ stdLibPkg = dep.getPkgPath()
}
})
}
@@ -636,6 +663,7 @@
Description: "Precompile the python sources of " + ctx.ModuleName(),
Args: map[string]string{
"stdlibZip": stdLib.String(),
+ "stdlibPkg": stdLibPkg,
"launcher": launcher.String(),
"ldLibraryPath": strings.Join(ldLibraryPath, ":"),
},
diff --git a/python/tests/par_test.py b/python/tests/par_test.py
index 1e03f16..96b42ae 100644
--- a/python/tests/par_test.py
+++ b/python/tests/par_test.py
@@ -33,6 +33,8 @@
assert_equal("os.path.basename(__file__)", fileName, "par_test.py")
archive = os.path.dirname(__file__)
+major = sys.version_info.major
+minor = sys.version_info.minor
assert_equal("__package__", __package__, "")
assert_equal("sys.argv[0]", sys.argv[0], archive)
@@ -42,10 +44,11 @@
assert_equal("__loader__.archive", __loader__.archive, archive)
assert_equal("site.ENABLE_USER_SITE", site.ENABLE_USER_SITE, None)
-assert_equal("len(sys.path)", len(sys.path), 3)
+assert_equal("len(sys.path)", len(sys.path), 4)
assert_equal("sys.path[0]", sys.path[0], archive)
-assert_equal("sys.path[1]", sys.path[1], os.path.join(archive, "internal"))
-assert_equal("sys.path[2]", sys.path[2], os.path.join(archive, "internal", "stdlib"))
+assert_equal("sys.path[1]", sys.path[1], os.path.join(archive, "internal", f"python{major}{minor}.zip"))
+assert_equal("sys.path[2]", sys.path[2], os.path.join(archive, "internal", f"python{major}.{minor}"))
+assert_equal("sys.path[3]", sys.path[3], os.path.join(archive, "internal", f"python{major}.{minor}", "lib-dynload"))
if os.getenv('ARGTEST', False):
assert_equal("len(sys.argv)", len(sys.argv), 3)
diff --git a/python/tests/py-cmd_test.py b/python/tests/py-cmd_test.py
index c7ba0ab..8aed782 100644
--- a/python/tests/py-cmd_test.py
+++ b/python/tests/py-cmd_test.py
@@ -55,22 +55,22 @@
assert_equal("sys.prefix", sys.prefix, sys.executable)
assert_equal("site.ENABLE_USER_SITE", site.ENABLE_USER_SITE, None)
-if sys.version_info[0] == 2:
+major = sys.version_info.major
+minor = sys.version_info.minor
+
+if major == 2:
assert_equal("len(sys.path)", len(sys.path), 4)
assert_equal("sys.path[0]", sys.path[0], os.path.abspath(os.path.dirname(__file__)))
assert_equal("sys.path[1]", sys.path[1], "/extra")
assert_equal("sys.path[2]", sys.path[2], os.path.join(sys.executable, "internal"))
assert_equal("sys.path[3]", sys.path[3], os.path.join(sys.executable, "internal", "stdlib"))
else:
- assert_equal("len(sys.path)", len(sys.path), 8)
+ assert_equal("len(sys.path)", len(sys.path), 5)
assert_equal("sys.path[0]", sys.path[0], os.path.abspath(os.path.dirname(__file__)))
assert_equal("sys.path[1]", sys.path[1], "/extra")
- assert_equal("sys.path[2]", sys.path[2], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + str(sys.version_info[1]) + '.zip'))
- assert_equal("sys.path[3]", sys.path[3], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1]), '..'))
- assert_equal("sys.path[4]", sys.path[4], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1])))
- assert_equal("sys.path[5]", sys.path[5], os.path.join(sys.executable, 'lib', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1]), 'lib-dynload'))
- assert_equal("sys.path[6]", sys.path[6], os.path.join(sys.executable, "internal"))
- assert_equal("sys.path[7]", sys.path[7], os.path.join(sys.executable, "internal", "stdlib"))
+ assert_equal("sys.path[2]", sys.path[2], os.path.join(sys.executable, 'internal', 'python' + str(sys.version_info[0]) + str(sys.version_info[1]) + '.zip'))
+ assert_equal("sys.path[3]", sys.path[3], os.path.join(sys.executable, 'internal', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1])))
+ assert_equal("sys.path[4]", sys.path[4], os.path.join(sys.executable, 'internal', 'python' + str(sys.version_info[0]) + '.' + str(sys.version_info[1]), 'lib-dynload'))
if failed:
sys.exit(1)
diff --git a/rust/bindgen.go b/rust/bindgen.go
index c2bf6af..407f275 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -294,7 +294,7 @@
// rust_bindgen generates Rust FFI bindings to C libraries using bindgen given a wrapper header as the primary input.
// Bindgen has a number of flags to control the generated source, and additional flags can be passed to clang to ensure
// the header and generated source is appropriately handled. It is recommended to add it as a dependency in the
-// rlibs, dylibs or rustlibs property. It may also be added in the srcs property for external crates, using the ":"
+// rlibs or rustlibs property. It may also be added in the srcs property for external crates, using the ":"
// prefix.
func RustBindgenFactory() android.Module {
module, _ := NewRustBindgen(android.HostAndDeviceSupported)
diff --git a/rust/compiler.go b/rust/compiler.go
index 06ae12f..e6a7a93 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -91,10 +91,8 @@
// list of rust rlib crate dependencies
Rlibs []string `android:"arch_variant"`
- // list of rust dylib crate dependencies
- Dylibs []string `android:"arch_variant"`
-
- // list of rust automatic crate dependencies
+ // list of rust automatic crate dependencies.
+ // Rustlibs linkage is rlib for host targets and dylib for device targets.
Rustlibs []string `android:"arch_variant"`
// list of rust proc_macro crate dependencies
@@ -320,6 +318,15 @@
flags.LinkFlags = append(flags.LinkFlags, cc.RpathFlags(ctx)...)
}
+ if !ctx.toolchain().Bionic() && ctx.Os() != android.LinuxMusl && !ctx.Windows() {
+ // Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device
+ // builds. This is irrelevant for the Windows target as these are Posix specific.
+ flags.LinkFlags = append(flags.LinkFlags,
+ "-ldl",
+ "-lpthread",
+ "-lm",
+ )
+ }
return flags
}
@@ -359,7 +366,6 @@
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.Rlibs = append(deps.Rlibs, compiler.Properties.Rlibs...)
- deps.Dylibs = append(deps.Dylibs, compiler.Properties.Dylibs...)
deps.Rustlibs = append(deps.Rustlibs, compiler.Properties.Rustlibs...)
deps.ProcMacros = append(deps.ProcMacros, compiler.Properties.Proc_macros...)
deps.StaticLibs = append(deps.StaticLibs, compiler.Properties.Static_libs...)
diff --git a/rust/fuzz.go b/rust/fuzz.go
index c2b9405..235f517 100644
--- a/rust/fuzz.go
+++ b/rust/fuzz.go
@@ -25,6 +25,7 @@
func init() {
android.RegisterModuleType("rust_fuzz", RustFuzzFactory)
+ android.RegisterModuleType("rust_fuzz_host", RustFuzzHostFactory)
}
type fuzzDecorator struct {
@@ -43,6 +44,11 @@
return module.Init()
}
+func RustFuzzHostFactory() android.Module {
+ module, _ := NewRustFuzz(android.HostSupported)
+ return module.Init()
+}
+
func NewRustFuzz(hod android.HostOrDeviceSupported) (*Module, *fuzzDecorator) {
module, binary := NewRustBinary(hod)
fuzz := &fuzzDecorator{
diff --git a/rust/fuzz_test.go b/rust/fuzz_test.go
index 0aecf61..ee28c6d 100644
--- a/rust/fuzz_test.go
+++ b/rust/fuzz_test.go
@@ -34,6 +34,10 @@
srcs: ["foo.rs"],
rustlibs: ["libtest_fuzzing"],
}
+ rust_fuzz_host {
+ name: "host_fuzzer",
+ srcs: ["foo.rs"],
+ }
`)
// Check that appropriate dependencies are added and that the rustlib linkage is correct.
@@ -50,7 +54,13 @@
if !strings.Contains(fuzz_libtest.Args["rustcFlags"], "-C passes='sancov-module'") ||
!strings.Contains(fuzz_libtest.Args["rustcFlags"], "--cfg fuzzing") {
t.Errorf("rust_fuzz module does not contain the expected flags (sancov-module, cfg fuzzing).")
+ }
+ // Check that host modules support fuzzing.
+ host_fuzzer := ctx.ModuleForTests("fuzz_libtest", "android_arm64_armv8-a_fuzzer").Rule("rustc")
+ if !strings.Contains(host_fuzzer.Args["rustcFlags"], "-C passes='sancov-module'") ||
+ !strings.Contains(host_fuzzer.Args["rustcFlags"], "--cfg fuzzing") {
+ t.Errorf("rust_fuzz_host module does not contain the expected flags (sancov-module, cfg fuzzing).")
}
// Check that dependencies have 'fuzzer' variants produced for them as well.
diff --git a/rust/library.go b/rust/library.go
index 3f480a2..419fcfc 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -466,7 +466,15 @@
library.includeDirs = append(library.includeDirs, android.PathsForModuleSrc(ctx, library.Properties.Include_dirs)...)
}
if library.shared() {
- flags.LinkFlags = append(flags.LinkFlags, "-Wl,-soname="+library.sharedLibFilename(ctx))
+ if ctx.Darwin() {
+ flags.LinkFlags = append(
+ flags.LinkFlags,
+ "-dynamic_lib",
+ "-install_name @rpath/"+library.sharedLibFilename(ctx),
+ )
+ } else {
+ flags.LinkFlags = append(flags.LinkFlags, "-Wl,-soname="+library.sharedLibFilename(ctx))
+ }
}
return flags
diff --git a/rust/protobuf.go b/rust/protobuf.go
index 0cf6e8c..a14ebea 100644
--- a/rust/protobuf.go
+++ b/rust/protobuf.go
@@ -243,7 +243,7 @@
// rust_protobuf generates protobuf rust code from the provided proto file. This uses the protoc-gen-rust plugin for
// protoc. Additional flags to the protoc command can be passed via the proto_flags property. This module type will
-// create library variants that can be used as a crate dependency by adding it to the rlibs, dylibs, and rustlibs
+// create library variants that can be used as a crate dependency by adding it to the rlibs and rustlibs
// properties of other modules.
func RustProtobufFactory() android.Module {
module, _ := NewRustProtobuf(android.HostAndDeviceSupported)
diff --git a/rust/rust.go b/rust/rust.go
index 08553ac..fc8db86 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1225,6 +1225,11 @@
if _, exists := skipModuleList[depName]; exists {
return
}
+
+ if depTag == android.DarwinUniversalVariantTag {
+ return
+ }
+
if rustDep, ok := dep.(*Module); ok && !rustDep.CcLibraryInterface() {
//Handle Rust Modules
makeLibName := rustMakeLibName(ctx, mod, rustDep, depName+rustDep.Properties.RustSubName)
diff --git a/rust/rust_test.go b/rust/rust_test.go
index 3f4e296..704bfe7 100644
--- a/rust/rust_test.go
+++ b/rust/rust_test.go
@@ -232,11 +232,6 @@
srcs: ["foo.rs"],
crate_name: "shared",
}
- rust_library_host_dylib {
- name: "libdylib",
- srcs: ["foo.rs"],
- crate_name: "dylib",
- }
rust_library_host_rlib {
name: "librlib",
srcs: ["foo.rs"],
@@ -252,7 +247,6 @@
}
rust_binary_host {
name: "fizz-buzz",
- dylibs: ["libdylib"],
rlibs: ["librlib"],
proc_macros: ["libpm"],
static_libs: ["libstatic"],
@@ -265,10 +259,6 @@
rustLink := ctx.ModuleForTests("fizz-buzz", "linux_glibc_x86_64").Rule("rustLink")
// Since dependencies are added to AndroidMk* properties, we can check these to see if they've been picked up.
- if !android.InList("libdylib", module.Properties.AndroidMkDylibs) {
- t.Errorf("Dylib dependency not detected (dependency missing from AndroidMkDylibs)")
- }
-
if !android.InList("librlib.rlib-std", module.Properties.AndroidMkRlibs) {
t.Errorf("Rlib dependency not detected (dependency missing from AndroidMkRlibs)")
}
diff --git a/rust/sanitize.go b/rust/sanitize.go
index 862baf7..cc19e6e 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -209,8 +209,8 @@
}
// TODO:(b/178369775)
- // For now sanitizing is only supported on devices
- if ctx.Os() == android.Android && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) {
+ // For now sanitizing is only supported on non-windows targets
+ if ctx.Os() != android.Windows && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) {
sanitize.Properties.SanitizerEnabled = true
}
}
@@ -234,6 +234,11 @@
if Bool(sanitize.Properties.Sanitize.Address) {
flags.RustFlags = append(flags.RustFlags, asanFlags...)
+ if ctx.Host() {
+ // -nodefaultlibs (provided with libc++) prevents the driver from linking
+ // libraries needed with -fsanitize=address. http://b/18650275 (WAI)
+ flags.LinkFlags = append(flags.LinkFlags, []string{"-Wl,--no-as-needed"}...)
+ }
}
return flags, deps
}
@@ -273,10 +278,17 @@
var deps []string
if mod.IsSanitizerEnabled(cc.Asan) {
- variations = append(variations,
- blueprint.Variation{Mutator: "link", Variation: "shared"})
- depTag = cc.SharedDepTag()
- deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "asan")}
+ if mod.Host() {
+ variations = append(variations,
+ blueprint.Variation{Mutator: "link", Variation: "static"})
+ depTag = cc.StaticDepTag(false)
+ deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "asan.static")}
+ } else {
+ variations = append(variations,
+ blueprint.Variation{Mutator: "link", Variation: "shared"})
+ depTag = cc.SharedDepTag()
+ deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "asan")}
+ }
} else if mod.IsSanitizerEnabled(cc.Hwasan) {
// TODO(b/204776996): HWASan for static Rust binaries isn't supported yet.
if binary, ok := mod.compiler.(binaryInterface); ok {
@@ -391,7 +403,8 @@
}
func (mod *Module) SanitizerSupported(t cc.SanitizerType) bool {
- if mod.Host() {
+ // Sanitizers are not supported on Windows targets.
+ if mod.Os() == android.Windows {
return false
}
switch t {
@@ -417,7 +430,8 @@
}
func (mod *Module) IsSanitizerExplicitlyDisabled(t cc.SanitizerType) bool {
- if mod.Host() {
+ // Sanitizers are not supported on Windows targets.
+ if mod.Os() == android.Windows {
return true
}
diff --git a/rust/testing.go b/rust/testing.go
index 7f30569..3fe751e 100644
--- a/rust/testing.go
+++ b/rust/testing.go
@@ -182,6 +182,7 @@
ctx.RegisterModuleType("rust_library_host_dylib", RustLibraryDylibHostFactory)
ctx.RegisterModuleType("rust_library_host_rlib", RustLibraryRlibHostFactory)
ctx.RegisterModuleType("rust_fuzz", RustFuzzFactory)
+ ctx.RegisterModuleType("rust_fuzz_host", RustFuzzHostFactory)
ctx.RegisterModuleType("rust_ffi", RustFFIFactory)
ctx.RegisterModuleType("rust_ffi_shared", RustFFISharedFactory)
ctx.RegisterModuleType("rust_ffi_static", RustFFIStaticFactory)
diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go
index 0edbb7c..a2c0fb7 100644
--- a/sysprop/sysprop_library.go
+++ b/sysprop/sysprop_library.go
@@ -24,6 +24,7 @@
"sync"
"android/soong/bazel"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -410,7 +411,7 @@
Apex_available []string
Min_sdk_version *string
Bazel_module struct {
- Bp2build_available *bool
+ Label *string
}
}
@@ -428,6 +429,9 @@
SyspropPublicStub string
Apex_available []string
Min_sdk_version *string
+ Bazel_module struct {
+ Bp2build_available *bool
+ }
}
func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
@@ -473,6 +477,14 @@
"Unknown value %s: must be one of Platform, Vendor or Odm", m.Owner())
}
+ var label *string
+ if b, ok := ctx.Module().(android.Bazelable); ok && b.ShouldConvertWithBp2build(ctx) {
+ // TODO: b/295566168 - this will need to change once build files are checked in to account for
+ // checked in modules in mixed builds
+ label = proptools.StringPtr(
+ fmt.Sprintf("//%s:%s", ctx.ModuleDir(), m.CcImplementationModuleName()))
+ }
+
// Generate a C++ implementation library.
// cc_library can receive *.sysprop files as their srcs, generating sources itself.
ccProps := ccLibraryProperties{}
@@ -492,11 +504,7 @@
ccProps.Host_supported = m.properties.Host_supported
ccProps.Apex_available = m.ApexProperties.Apex_available
ccProps.Min_sdk_version = m.properties.Cpp.Min_sdk_version
- // A Bazel macro handles this, so this module does not need to be handled
- // in bp2build
- // TODO(b/237810289) perhaps do something different here so that we aren't
- // also disabling these modules in mixed builds
- ccProps.Bazel_module.Bp2build_available = proptools.BoolPtr(false)
+ ccProps.Bazel_module.Label = label
ctx.CreateModule(cc.LibraryFactory, &ccProps)
scope := "internal"
@@ -541,6 +549,11 @@
SyspropPublicStub: publicStub,
Apex_available: m.ApexProperties.Apex_available,
Min_sdk_version: m.properties.Java.Min_sdk_version,
+ Bazel_module: struct {
+ Bp2build_available *bool
+ }{
+ Bp2build_available: proptools.BoolPtr(false),
+ },
})
if publicStub != "" {
@@ -558,6 +571,11 @@
Sdk_version: proptools.StringPtr("core_current"),
Libs: []string{javaSyspropStub},
Stem: proptools.StringPtr(m.BaseModuleName()),
+ Bazel_module: struct {
+ Bp2build_available *bool
+ }{
+ Bp2build_available: proptools.BoolPtr(false),
+ },
})
}
diff --git a/tests/sbom_test.sh b/tests/sbom_test.sh
index c41f28d..9801a8e 100755
--- a/tests/sbom_test.sh
+++ b/tests/sbom_test.sh
@@ -86,16 +86,17 @@
declare -A diff_excludes
diff_excludes[vendor]="\
- -I /vendor/lib64/libkeystore2_crypto.so"
+ -I /vendor/lib64/libkeystore2_crypto.so \
+ -I /vendor/lib64/libvsock_utils.so"
diff_excludes[system]="\
- -I /system/bin/assemble_cvd
- -I /system/bin/console_forwarder
- -I /system/bin/kernel_log_monitor
- -I /system/bin/logcat_receiver
- -I /system/bin/mkenvimage_slim
- -I /system/bin/run_cvd
- -I /system/bin/simg2img
- -I /system/bin/log_tee
+ -I /system/bin/assemble_cvd \
+ -I /system/bin/console_forwarder \
+ -I /system/bin/kernel_log_monitor \
+ -I /system/bin/logcat_receiver \
+ -I /system/bin/mkenvimage_slim \
+ -I /system/bin/run_cvd \
+ -I /system/bin/simg2img \
+ -I /system/bin/log_tee \
-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 \