Merge "Switch to toybox dd." into main
diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go
index 4e199dd..5cdf5b6 100644
--- a/aconfig/aconfig_declarations.go
+++ b/aconfig/aconfig_declarations.go
@@ -116,32 +116,38 @@
func (module *DeclarationsModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag
+ valuesFiles := make([]android.Path, 0)
ctx.VisitDirectDeps(func(dep android.Module) {
if !ctx.OtherModuleHasProvider(dep, valueSetProviderKey) {
// Other modules get injected as dependencies too, for example the license modules
return
}
depData := ctx.OtherModuleProvider(dep, valueSetProviderKey).(valueSetProviderData)
- valuesFiles, ok := depData.AvailablePackages[module.properties.Package]
+ paths, ok := depData.AvailablePackages[module.properties.Package]
if ok {
- for _, path := range valuesFiles {
+ valuesFiles = append(valuesFiles, paths...)
+ for _, path := range paths {
module.properties.Values = append(module.properties.Values, path.String())
}
}
})
// Intermediate format
- inputFiles := android.PathsForModuleSrc(ctx, module.properties.Srcs)
+ declarationFiles := android.PathsForModuleSrc(ctx, module.properties.Srcs)
intermediatePath := android.PathForModuleOut(ctx, "intermediate.pb")
defaultPermission := ctx.Config().ReleaseAconfigFlagDefaultPermission()
+ inputFiles := make([]android.Path, len(declarationFiles))
+ copy(inputFiles, declarationFiles)
+ inputFiles = append(inputFiles, valuesFiles...)
ctx.Build(pctx, android.BuildParams{
Rule: aconfigRule,
Output: intermediatePath,
+ Inputs: inputFiles,
Description: "aconfig_declarations",
Args: map[string]string{
"release_version": ctx.Config().ReleaseVersion(),
"package": module.properties.Package,
- "declarations": android.JoinPathsWithPrefix(inputFiles, "--declarations "),
+ "declarations": android.JoinPathsWithPrefix(declarationFiles, "--declarations "),
"values": joinAndPrefix(" --values ", module.properties.Values),
"default-permission": optionalVariable(" --default-permission ", defaultPermission),
},
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 056c1a8..f411026 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -255,6 +255,7 @@
"hardware/interfaces/audio/aidl/common": Bp2BuildDefaultTrue,
"hardware/interfaces/audio/aidl/default": Bp2BuildDefaultTrue,
"hardware/interfaces/audio/aidl/sounddose": Bp2BuildDefaultTrue,
+ "hardware/interfaces/camera/metadata/aidl": Bp2BuildDefaultTrueRecursively,
"hardware/interfaces/common/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/common/fmq/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/common/support": Bp2BuildDefaultTrue,
@@ -396,6 +397,7 @@
"system/media/audio": Bp2BuildDefaultTrueRecursively,
"system/media/alsa_utils": Bp2BuildDefaultTrueRecursively,
"system/media/audio_utils": Bp2BuildDefaultTrueRecursively,
+ "system/media/camera": Bp2BuildDefaultTrueRecursively,
"system/memory/libion": Bp2BuildDefaultTrueRecursively,
"system/memory/libmemunreachable": Bp2BuildDefaultTrueRecursively,
"system/sepolicy/apex": Bp2BuildDefaultTrueRecursively,
@@ -437,6 +439,7 @@
// external/bazelbuild-rules_android/... is needed by mixed builds, otherwise mixed builds analysis fails
// e.g. ERROR: Analysis of target '@soong_injection//mixed_builds:buildroot' failed
"external/bazelbuild-rules_android":/* recursive = */ true,
+ "external/bazelbuild-rules_cc":/* recursive = */ true,
"external/bazelbuild-rules_java":/* recursive = */ true,
"external/bazelbuild-rules_license":/* recursive = */ true,
"external/bazelbuild-rules_go":/* recursive = */ true,
@@ -668,6 +671,9 @@
//frameworks/native/cmds/cmd
"libcmd",
+ //system/chre
+ "chre_api",
+
//system/core/fs_mgr/libdm
"libdm",
diff --git a/android/bazel.go b/android/bazel.go
index e4fada0..94b36e3 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -689,3 +689,21 @@
})
return validatedOutputFilePath
}
+
+func RunsOn(hostSupported bool, deviceSupported bool, unitTest bool) []string {
+ var runsOn []string
+
+ if hostSupported && deviceSupported {
+ runsOn = []string{"host_without_device", "device"}
+ } else if hostSupported {
+ if unitTest {
+ runsOn = []string{"host_without_device"}
+ } else {
+ runsOn = []string{"host_with_device"}
+ }
+ } else if deviceSupported {
+ runsOn = []string{"device"}
+ }
+
+ return runsOn
+}
diff --git a/android/bazel_paths.go b/android/bazel_paths.go
index 7992564..86829ce 100644
--- a/android/bazel_paths.go
+++ b/android/bazel_paths.go
@@ -205,6 +205,21 @@
return labels
}
+func BazelLabelForSrcPatternExcludes(ctx BazelConversionPathContext, dir, pattern string, excludes []string) bazel.LabelList {
+ topRelPaths, err := ctx.GlobWithDeps(filepath.Join(dir, pattern), excludes)
+ if err != nil {
+ ctx.ModuleErrorf("Could not search dir: %s for pattern %s due to %v\n", dir, pattern, err)
+ }
+ // An intermediate list of labels relative to `dir` that assumes that there no subpacakges beneath `dir`
+ dirRelLabels := []bazel.Label{}
+ for _, topRelPath := range topRelPaths {
+ dirRelPath := Rel(ctx, dir, topRelPath)
+ dirRelLabels = append(dirRelLabels, bazel.Label{Label: "./" + dirRelPath})
+ }
+ // Return the package boudary resolved labels
+ return TransformSubpackagePaths(ctx.Config(), dir, bazel.MakeLabelList(dirRelLabels))
+}
+
// Returns true if a prefix + components[:i] is a package boundary.
//
// A package boundary is determined by a BUILD file in the directory. This can happen in 2 cases:
@@ -378,7 +393,13 @@
if m, tag := SrcIsModuleWithTag(p); m != "" {
l := getOtherModuleLabel(ctx, m, tag, BazelModuleLabel)
if l != nil && !InList(l.Label, expandedExcludes) {
- l.OriginalModuleName = fmt.Sprintf(":%s", m)
+ if strings.HasPrefix(m, "//") {
+ // this is a module in a soong namespace
+ // It appears as //<namespace>:<module_name> in srcs, and not ://<namespace>:<module_name>
+ l.OriginalModuleName = m
+ } else {
+ l.OriginalModuleName = fmt.Sprintf(":%s", m)
+ }
labels.Includes = append(labels.Includes, *l)
}
} else {
diff --git a/android/bazel_paths_test.go b/android/bazel_paths_test.go
index 75b77a3..bed719c 100644
--- a/android/bazel_paths_test.go
+++ b/android/bazel_paths_test.go
@@ -15,6 +15,7 @@
package android
import (
+ "fmt"
"path/filepath"
"testing"
@@ -114,8 +115,9 @@
type TestBazelConversionPathContext struct {
TestBazelConversionContext
- moduleDir string
- cfg Config
+ moduleDir string
+ cfg Config
+ mockGlobResults *[]string
}
func (ctx *TestBazelConversionPathContext) AddNinjaFileDeps(...string) {
@@ -123,7 +125,10 @@
}
func (ctx *TestBazelConversionPathContext) GlobWithDeps(string, []string) ([]string, error) {
- panic("Unimplemented")
+ if ctx.mockGlobResults == nil {
+ return []string{}, fmt.Errorf("Set mock glob results first")
+ }
+ return *ctx.mockGlobResults, nil
}
func (ctx *TestBazelConversionPathContext) PropertyErrorf(string, string, ...interface{}) {
@@ -190,3 +195,46 @@
}
}
}
+
+// Check that the files in a specific directory are returned with labels that respect package boundaries
+// Since the test uses a mock for GlobWithDeps, the params passed to BazelLabelForSrcPatternExcludes are no-ops
+func TestBazelLabelForSrcPatternExcludes(t *testing.T) {
+ cfg := NullConfig("out", "out/soong")
+ cfg.fs = pathtools.MockFs(map[string][]byte{
+ "x/Android.bp": nil,
+ "x/y/Android.bp": nil,
+ // .proto files
+ "foo.proto": nil,
+ "x/bar.proto": nil,
+ "x/baz.proto": nil,
+ "x/y/qux.proto": nil,
+ })
+
+ var ctx BazelConversionPathContext = &TestBazelConversionPathContext{
+ cfg: cfg,
+ }
+
+ // Root dir
+ ctx.(*TestBazelConversionPathContext).mockGlobResults = &[]string{"foo.proto", "x/bar.proto", "x/baz.proto", "x/y/qux.proto"}
+ actualLabelsFromRoot := BazelLabelForSrcPatternExcludes(ctx, ".", "**/*.proto", []string{})
+ expectedLabelsAsString := []string{"foo.proto", "//x:bar.proto", "//x:baz.proto", "//x/y:qux.proto"}
+ for i, actual := range actualLabelsFromRoot.Includes {
+ AssertStringEquals(t, "Error in finding src labels relative to root directory", expectedLabelsAsString[i], actual.Label)
+ }
+
+ // x dir
+ ctx.(*TestBazelConversionPathContext).mockGlobResults = &[]string{"x/bar.proto", "x/baz.proto", "x/y/qux.proto"}
+ actualLabelsFromRoot = BazelLabelForSrcPatternExcludes(ctx, "x", "**/*.proto", []string{})
+ expectedLabelsAsString = []string{"bar.proto", "baz.proto", "//x/y:qux.proto"}
+ for i, actual := range actualLabelsFromRoot.Includes {
+ AssertStringEquals(t, "Error in finding src labels relative to x directory", expectedLabelsAsString[i], actual.Label)
+ }
+
+ // y dir
+ ctx.(*TestBazelConversionPathContext).mockGlobResults = &[]string{"x/y/qux.proto"}
+ actualLabelsFromRoot = BazelLabelForSrcPatternExcludes(ctx, "x/y", "**/*.proto", []string{})
+ expectedLabelsAsString = []string{"qux.proto"}
+ for i, actual := range actualLabelsFromRoot.Includes {
+ AssertStringEquals(t, "Error in finding src labels relative to x/y directory", expectedLabelsAsString[i], actual.Label)
+ }
+}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 8368db1..da059eb 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -3870,6 +3870,7 @@
}
`+vndkLibrariesTxtFiles("current"), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.DeviceVndkVersion = proptools.StringPtr(tc.vndkVersion)
+ variables.KeepVndk = proptools.BoolPtr(true)
}))
ensureExactContents(t, ctx, "com.android.vndk.current", "android_common_image", tc.expectedFiles)
})
diff --git a/apex/vndk.go b/apex/vndk.go
index 095e89d..68b3a40 100644
--- a/apex/vndk.go
+++ b/apex/vndk.go
@@ -80,6 +80,10 @@
// config targets the 'current' VNDK (see `vndkVersion`).
ab.Disable()
}
+ if proptools.String(ab.vndkProperties.Vndk_version) != "" &&
+ apiLevel.GreaterThanOrEqualTo(android.ApiLevelOrPanic(mctx, mctx.DeviceConfig().PlatformVndkVersion())) {
+ ab.Disable()
+ }
}
}
@@ -103,7 +107,7 @@
}
} else if a, ok := mctx.Module().(*apexBundle); ok && a.vndkApex {
vndkVersion := proptools.StringDefault(a.vndkProperties.Vndk_version, "current")
- mctx.AddDependency(mctx.Module(), prebuiltTag, cc.VndkLibrariesTxtModules(vndkVersion)...)
+ mctx.AddDependency(mctx.Module(), prebuiltTag, cc.VndkLibrariesTxtModules(vndkVersion, mctx)...)
}
}
diff --git a/apex/vndk_test.go b/apex/vndk_test.go
index 21526c3..4327a61 100644
--- a/apex/vndk_test.go
+++ b/apex/vndk_test.go
@@ -51,6 +51,7 @@
`+vndkLibrariesTxtFiles("current"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.DeviceVndkVersion = proptools.StringPtr("")
+ variables.KeepVndk = proptools.BoolPtr(true)
}),
)
// VNDK-Lite contains only core variants of VNDK-Sp libraries
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 bb0eafc..9c63bc0 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -426,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)
}
@@ -442,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))
@@ -512,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)
}
@@ -659,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 {
@@ -794,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)
}
@@ -810,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))
@@ -1168,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)
}
@@ -1184,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 {
@@ -1374,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)
}
@@ -1390,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/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/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 622ec4a..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": `["."]`,
}),
},
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/cc_test_conversion_test.go b/bp2build/cc_test_conversion_test.go
index 3c037b4..abceac8 100644
--- a/bp2build/cc_test_conversion_test.go
+++ b/bp2build/cc_test_conversion_test.go
@@ -135,6 +135,10 @@
"//build/bazel/platforms/os:linux_musl": ["linux.cpp"],
"//conditions:default": [],
})`,
+ "runs_on": `[
+ "host_without_device",
+ "device",
+ ]`,
},
},
},
@@ -158,6 +162,10 @@
"gtest": "False",
"local_includes": `["."]`,
"srcs": `["test.cpp"]`,
+ "runs_on": `[
+ "host_without_device",
+ "device",
+ ]`,
},
},
},
@@ -185,6 +193,10 @@
":libgtest_main",
":libgtest",
]`,
+ "runs_on": `[
+ "host_without_device",
+ "device",
+ ]`,
},
},
},
@@ -215,6 +227,7 @@
":libgtest_main",
":libgtest",
]`,
+ "runs_on": `["device"]`,
},
},
},
@@ -244,6 +257,7 @@
":libgtest_main",
":libgtest",
]`,
+ "runs_on": `["device"]`,
},
},
},
@@ -280,6 +294,7 @@
"template_test_config": `"test_config_template.xml"`,
"deps": `[":libgtest_isolated_main"]`,
"dynamic_deps": `[":liblog"]`,
+ "runs_on": `["device"]`,
},
},
},
@@ -306,6 +321,7 @@
":libgtest",
":libgtest_main",
]`,
+ "runs_on": `["device"]`,
},
},
},
@@ -331,6 +347,7 @@
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
"deps": `[":libgtest_isolated_main"]`,
"dynamic_deps": `[":liblog"]`,
+ "runs_on": `["device"]`,
},
},
},
@@ -361,12 +378,14 @@
]`,
"gtest": "True",
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
+ "runs_on": `["device"]`,
},
},
{"cc_test", "mytest_with_no_gtest", AttrNameToString{
"local_includes": `["."]`,
"gtest": "False",
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
+ "runs_on": `["device"]`,
},
},
},
diff --git a/bp2build/genrule_conversion_test.go b/bp2build/genrule_conversion_test.go
index 5ca8bd7..2a10a14 100644
--- a/bp2build/genrule_conversion_test.go
+++ b/bp2build/genrule_conversion_test.go
@@ -27,6 +27,8 @@
func registerGenruleModuleTypes(ctx android.RegistrationContext) {
ctx.RegisterModuleType("genrule_defaults", func() android.Module { return genrule.DefaultsFactory() })
+ ctx.RegisterModuleType("cc_binary", func() android.Module { return cc.BinaryFactory() })
+ ctx.RegisterModuleType("soong_namespace", func() android.Module { return android.NamespaceFactory() })
}
func runGenruleTestCase(t *testing.T, tc Bp2buildTestCase) {
@@ -913,3 +915,40 @@
})
}
}
+
+func TestGenruleWithModulesInNamespaces(t *testing.T) {
+ bp := `
+genrule {
+ name: "mygenrule",
+ cmd: "echo $(location //mynamespace:mymodule) > $(out)",
+ srcs: ["//mynamespace:mymodule"],
+ out: ["myout"],
+}
+`
+ fs := map[string]string{
+ "mynamespace/Android.bp": `soong_namespace {}`,
+ "mynamespace/dir/Android.bp": `cc_binary {name: "mymodule"}`,
+ }
+ expectedBazelTargets := []string{
+ MakeBazelTargetNoRestrictions("genrule", "mygenrule", AttrNameToString{
+ // The fully qualified soong label is <namespace>:<module_name>
+ // - here the prefix is mynamespace
+ // The fully qualifed bazel label is <package>:<module_name>
+ // - here the prefix is mynamespace/dir, since there is a BUILD file at each level of this FS path
+ "cmd": `"echo $(location //mynamespace/dir:mymodule) > $(OUTS)"`,
+ "outs": `["myout"]`,
+ "srcs": `["//mynamespace/dir:mymodule"]`,
+ }),
+ }
+
+ t.Run("genrule that uses module from a different namespace", func(t *testing.T) {
+ runGenruleTestCase(t, Bp2buildTestCase{
+ Blueprint: bp,
+ Filesystem: fs,
+ ModuleTypeUnderTest: "genrule",
+ ModuleTypeUnderTestFactory: genrule.GenRuleFactory,
+ 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..0157632 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,13 +1020,25 @@
(&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)
+ // Dedupe all deps.
+ (&linkerAttrs).deps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).deps.Value)
+ (&linkerAttrs).implementationDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).implementationDeps.Value)
+ (&linkerAttrs).implementationDynamicDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).implementationDynamicDeps.Value)
+ (&linkerAttrs).wholeArchiveDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).wholeArchiveDeps.Value)
+ (&linkerAttrs).implementationWholeArchiveDeps.Value = bazel.FirstUniqueBazelLabelList((&linkerAttrs).implementationWholeArchiveDeps.Value)
+
return baseAttributes{
compilerAttrs,
linkerAttrs,
@@ -1910,8 +1926,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 +1947,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 +1963,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/cc_test.go b/cc/cc_test.go
index d95ed3f..7ce0f37 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -654,6 +654,7 @@
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
config.TestProductVariables.Platform_vndk_version = StringPtr("29")
+ config.TestProductVariables.KeepVndk = BoolPtr(true)
ctx := testCcWithConfig(t, config)
module := ctx.ModuleForTests("llndk.libraries.txt", "android_common")
diff --git a/cc/config/global.go b/cc/config/global.go
index ff5ab05..498b3ce 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -75,11 +75,6 @@
// Help catch common 32/64-bit errors.
"-Werror=int-conversion",
- // Disable overly aggressive warning for macros defined with a leading underscore
- // This happens in AndroidConfig.h, which is included nearly everywhere.
- // TODO: can we remove this now?
- "-Wno-reserved-id-macro",
-
// Force clang to always output color diagnostics. Ninja will strip the ANSI
// color codes if it is not running in a terminal.
"-fcolor-diagnostics",
@@ -101,6 +96,9 @@
// Warnings from clang-12
"-Wno-gnu-folding-constant",
+ // http://b/145210666
+ "-Wno-error=reorder-init-list",
+
// Calls to the APIs that are newer than the min sdk version of the caller should be
// guarded with __builtin_available.
"-Wunguarded-availability",
@@ -218,8 +216,6 @@
// new warnings are fixed.
"-Wno-tautological-constant-compare",
"-Wno-tautological-type-limit-compare",
- // http://b/145210666
- "-Wno-reorder-init-list",
// http://b/145211066
"-Wno-implicit-int-float-conversion",
// New warnings to be fixed after clang-r377782.
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/test.go b/cc/test.go
index 0be2301..adc80c2 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -686,6 +686,8 @@
tidyAttributes
tradefed.TestConfigAttributes
+
+ Runs_on bazel.StringListAttribute
}
// testBinaryBp2build is the bp2build converter for cc_test modules. A cc_test's
@@ -730,6 +732,8 @@
addImplicitGtestDeps(ctx, &testBinaryAttrs, gtest, gtestIsolated)
+ var unitTest *bool
+
for _, testProps := range m.GetProperties() {
if p, ok := testProps.(*TestBinaryProperties); ok {
useVendor := false // TODO Bug: 262914724
@@ -745,9 +749,15 @@
&testInstallBase,
)
testBinaryAttrs.TestConfigAttributes = testConfigAttributes
+ unitTest = p.Test_options.Unit_test
}
}
+ testBinaryAttrs.Runs_on = bazel.MakeStringListAttribute(android.RunsOn(
+ m.ModuleBase.HostSupported(),
+ m.ModuleBase.DeviceSupported(),
+ gtest || (unitTest != nil && *unitTest)))
+
// TODO (b/262914724): convert to tradefed_cc_test and tradefed_cc_test_host
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{
diff --git a/cc/vndk.go b/cc/vndk.go
index 7a2286e..82a2a4b 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -39,25 +39,34 @@
vndkUsingCoreVariantLibrariesTxt = "vndkcorevariant.libraries.txt"
)
-func VndkLibrariesTxtModules(vndkVersion string) []string {
+func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext) []string {
if vndkVersion == "current" {
- return []string{
- llndkLibrariesTxt,
+ result := []string{
vndkCoreLibrariesTxt,
vndkSpLibrariesTxt,
vndkPrivateLibrariesTxt,
vndkProductLibrariesTxt,
}
+
+ // TODO(b/290159430) This part will not be required once deprecation of VNDK
+ // is handled with 'ro.vndk.version' property
+ if !ctx.Config().IsVndkDeprecated() {
+ result = append(result, llndkLibrariesTxt)
+ }
+
+ return result
}
// Snapshot vndks have their own *.libraries.VER.txt files.
// Note that snapshots don't have "vndkcorevariant.libraries.VER.txt"
- return []string{
- insertVndkVersion(llndkLibrariesTxt, vndkVersion),
+ result := []string{
insertVndkVersion(vndkCoreLibrariesTxt, vndkVersion),
insertVndkVersion(vndkSpLibrariesTxt, vndkVersion),
insertVndkVersion(vndkPrivateLibrariesTxt, vndkVersion),
insertVndkVersion(vndkProductLibrariesTxt, vndkVersion),
+ insertVndkVersion(llndkLibrariesTxt, vndkVersion),
}
+
+ return result
}
type VndkProperties struct {
@@ -352,11 +361,19 @@
return false
}
- // prebuilt vndk modules should match with device
// TODO(b/142675459): Use enabled: to select target device in vndk_prebuilt_shared
// When b/142675459 is landed, remove following check
- if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok && !p.MatchesWithDevice(mctx.DeviceConfig()) {
- return false
+ if p, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
+ // prebuilt vndk modules should match with device
+ if !p.MatchesWithDevice(mctx.DeviceConfig()) {
+ return false
+ }
+
+ // ignore prebuilt vndk modules that are newer than or equal to the platform vndk version
+ platformVndkApiLevel := android.ApiLevelOrPanic(mctx, mctx.DeviceConfig().PlatformVndkVersion())
+ if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(mctx, p.Version())) {
+ return false
+ }
}
if lib, ok := m.linker.(libraryInterface); ok {
@@ -519,11 +536,15 @@
}
func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- var filename string
- if BoolDefault(txt.properties.Insert_vndk_version, true) {
+ filename := txt.Name()
+
+ shouldInsertVndkVersion := BoolDefault(txt.properties.Insert_vndk_version, true)
+ // llndk.libraries.txt file installed in the system image should not contain version info.
+ if ctx.Config().IsVndkDeprecated() && txt.Name() == llndkLibrariesTxt {
+ shouldInsertVndkVersion = false
+ }
+ if shouldInsertVndkVersion {
filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
- } else {
- filename = txt.Name()
}
txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go
index 37819a4..5e526db 100644
--- a/cc/vndk_prebuilt.go
+++ b/cc/vndk_prebuilt.go
@@ -131,6 +131,12 @@
func (p *vndkPrebuiltLibraryDecorator) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
+ platformVndkApiLevel := android.ApiLevelOrPanic(ctx, ctx.DeviceConfig().PlatformVndkVersion())
+ if platformVndkApiLevel.LessThanOrEqualTo(android.ApiLevelOrPanic(ctx, p.Version())) {
+ // This prebuilt VNDK module is not required for the current build
+ ctx.Module().HideFromMake()
+ return nil
+ }
if !p.MatchesWithDevice(ctx.DeviceConfig()) {
ctx.Module().HideFromMake()
diff --git a/genrule/genrule.go b/genrule/genrule.go
index aa4295d..8e3f278 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -140,7 +140,7 @@
// prebuilts or scripts that do not need a module to build them.
Tools []string
- // Local file that is used as the tool
+ // Local files that are used by the tool
Tool_files []string `android:"path"`
// List of directories to export generated headers from
@@ -403,7 +403,6 @@
}
addLabelsForInputs := func(propName string, include, exclude []string) android.Paths {
-
includeDirInPaths := ctx.DeviceConfig().BuildBrokenInputDir(g.Name())
var srcFiles android.Paths
for _, in := range include {
diff --git a/java/aar.go b/java/aar.go
index 1e38efc..0216196 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -23,13 +23,13 @@
"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"
)
type AndroidLibraryDependency interface {
- LibraryDependency
ExportPackage() android.Path
ResourcesNodeDepSet() *android.DepSet[*resourcesNode]
RRODirsDepSet() *android.DepSet[rroDir]
@@ -777,17 +777,9 @@
ctx.CheckbuildFile(a.aarFile)
}
- a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles,
- android.PathsForModuleSrc(ctx, a.dexProperties.Optimize.Proguard_flags_files)...)
-
- ctx.VisitDirectDeps(func(m android.Module) {
- if ctx.OtherModuleDependencyTag(m) == staticLibTag {
- if lib, ok := m.(LibraryDependency); ok {
- a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
- }
- }
- })
- a.exportedProguardFlagFiles = android.FirstUniquePaths(a.exportedProguardFlagFiles)
+ proguardSpecInfo := a.collectProguardSpecInfo(ctx)
+ ctx.SetProvider(ProguardSpecInfoProvider, proguardSpecInfo)
+ a.exportedProguardFlagFiles = proguardSpecInfo.ProguardFlagsFiles.ToList()
prebuiltJniPackages := android.Paths{}
ctx.VisitDirectDeps(func(module android.Module) {
@@ -938,10 +930,6 @@
func (a *AARImport) ExportPackage() android.Path {
return a.exportPackage
}
-func (a *AARImport) ExportedProguardFlagFiles() android.Paths {
- return android.Paths{a.proguardFlags}
-}
-
func (a *AARImport) ResourcesNodeDepSet() *android.DepSet[*resourcesNode] {
return a.resourcesNodesDepSet
}
@@ -1045,10 +1033,17 @@
extractedAARDir := android.PathForModuleOut(ctx, "aar")
a.classpathFile = extractedAARDir.Join(ctx, "classes-combined.jar")
- a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml")
aarRTxt := extractedAARDir.Join(ctx, "R.txt")
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
+ a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
+ ctx.SetProvider(ProguardSpecInfoProvider, ProguardSpecInfo{
+ ProguardFlagsFiles: android.NewDepSet[android.Path](
+ android.POSTORDER,
+ android.Paths{a.proguardFlags},
+ nil,
+ ),
+ })
ctx.Build(pctx, android.BuildParams{
Rule: unzipAAR,
@@ -1228,6 +1223,8 @@
type bazelAapt struct {
Manifest bazel.Label
Resource_files bazel.LabelListAttribute
+ Assets_dir bazel.StringAttribute
+ Assets bazel.LabelListAttribute
}
type bazelAndroidLibrary struct {
@@ -1242,7 +1239,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 +1249,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 +1345,10 @@
name := a.Name()
props := AndroidLibraryBazelTargetModuleProperties()
+ aaptAttrs, supported := a.convertAaptAttrsWithBp2Build(ctx)
+ if !supported {
+ return
+ }
ctx.CreateBazelTargetModule(
props,
android.CommonAttributes{Name: name},
@@ -1337,7 +1358,7 @@
Deps: deps,
Exports: depLabels.StaticDeps,
},
- a.convertAaptAttrsWithBp2Build(ctx),
+ aaptAttrs,
},
)
diff --git a/java/app.go b/java/app.go
index e277aed..7cf86c0 100755
--- a/java/app.go
+++ b/java/app.go
@@ -200,10 +200,6 @@
return Bool(a.properties.Installable)
}
-func (a *AndroidApp) ExportedProguardFlagFiles() android.Paths {
- return nil
-}
-
func (a *AndroidApp) ResourcesNodeDepSet() *android.DepSet[*resourcesNode] {
return a.aapt.resourcesNodesDepSet
}
@@ -482,8 +478,10 @@
func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
var staticLibProguardFlagFiles android.Paths
ctx.VisitDirectDeps(func(m android.Module) {
- if lib, ok := m.(LibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
- staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
+ depProguardInfo := ctx.OtherModuleProvider(m, ProguardSpecInfoProvider).(ProguardSpecInfo)
+ staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, depProguardInfo.UnconditionallyExportedProguardFlags.ToList()...)
+ if ctx.OtherModuleDependencyTag(m) == staticLibTag {
+ staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, depProguardInfo.ProguardFlagsFiles.ToList()...)
}
})
@@ -1628,8 +1626,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/base.go b/java/base.go
index f5eb01c..4fe093a 100644
--- a/java/base.go
+++ b/java/base.go
@@ -622,6 +622,8 @@
return android.Paths{j.dexer.proguardDictionary.Path()}, nil
}
return nil, fmt.Errorf("%q was requested, but no output file was found.", tag)
+ case ".generated_srcjars":
+ return j.properties.Generated_srcjars, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
@@ -1670,6 +1672,49 @@
return android.InList("androidx.compose.runtime_runtime", j.properties.Static_libs)
}
+func (j *Module) collectProguardSpecInfo(ctx android.ModuleContext) ProguardSpecInfo {
+ transitiveUnconditionalExportedFlags := []*android.DepSet[android.Path]{}
+ transitiveProguardFlags := []*android.DepSet[android.Path]{}
+
+ ctx.VisitDirectDeps(func(m android.Module) {
+ depProguardInfo := ctx.OtherModuleProvider(m, ProguardSpecInfoProvider).(ProguardSpecInfo)
+ depTag := ctx.OtherModuleDependencyTag(m)
+
+ if depProguardInfo.UnconditionallyExportedProguardFlags != nil {
+ transitiveUnconditionalExportedFlags = append(transitiveUnconditionalExportedFlags, depProguardInfo.UnconditionallyExportedProguardFlags)
+ transitiveProguardFlags = append(transitiveProguardFlags, depProguardInfo.UnconditionallyExportedProguardFlags)
+ }
+
+ if depTag == staticLibTag && depProguardInfo.ProguardFlagsFiles != nil {
+ transitiveProguardFlags = append(transitiveProguardFlags, depProguardInfo.ProguardFlagsFiles)
+ }
+ })
+
+ directUnconditionalExportedFlags := android.Paths{}
+ proguardFlagsForThisModule := android.PathsForModuleSrc(ctx, j.dexProperties.Optimize.Proguard_flags_files)
+ exportUnconditionally := proptools.Bool(j.dexProperties.Optimize.Export_proguard_flags_files)
+ if exportUnconditionally {
+ // if we explicitly export, then our unconditional exports are the same as our transitive flags
+ transitiveUnconditionalExportedFlags = transitiveProguardFlags
+ directUnconditionalExportedFlags = proguardFlagsForThisModule
+ }
+
+ return ProguardSpecInfo{
+ Export_proguard_flags_files: exportUnconditionally,
+ ProguardFlagsFiles: android.NewDepSet[android.Path](
+ android.POSTORDER,
+ proguardFlagsForThisModule,
+ transitiveProguardFlags,
+ ),
+ UnconditionallyExportedProguardFlags: android.NewDepSet[android.Path](
+ android.POSTORDER,
+ directUnconditionalExportedFlags,
+ transitiveUnconditionalExportedFlags,
+ ),
+ }
+
+}
+
// Returns a copy of the supplied flags, but with all the errorprone-related
// fields copied to the regular build's fields.
func enableErrorproneFlags(flags javaBuilderFlags) javaBuilderFlags {
diff --git a/java/core-libraries/Android.bp b/java/core-libraries/Android.bp
index de9a82d..4380f4f 100644
--- a/java/core-libraries/Android.bp
+++ b/java/core-libraries/Android.bp
@@ -55,6 +55,19 @@
],
}
+java_api_library {
+ name: "core.current.stubs.from-text",
+ api_surface: "core",
+ api_contributions: [
+ "art.module.public.api.stubs.source.api.contribution",
+ "conscrypt.module.public.api.stubs.source.api.contribution",
+ "i18n.module.public.api.stubs.source.api.contribution",
+ ],
+ libs: [
+ "stub-annotations",
+ ],
+}
+
java_library {
name: "core.current.stubs",
defaults: [
@@ -153,7 +166,6 @@
system_modules: "none",
}
-
// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
// provided by the core libraries.
//
@@ -265,6 +277,32 @@
],
}
+java_defaults {
+ name: "android_core_platform_stubs_current_contributions",
+ api_surface: "core_platform",
+ api_contributions: [
+ "art.module.public.api.stubs.source.api.contribution",
+ "art.module.public.api.stubs.source.system.api.contribution",
+ "art.module.public.api.stubs.source.module_lib.api.contribution",
+ "conscrypt.module.platform.api.stubs.source.api.contribution",
+ "i18n.module.public.api.stubs.source.api.contribution",
+ ],
+}
+
+java_api_library {
+ name: "legacy.core.platform.api.stubs.from-text",
+ api_surface: "core_platform",
+ defaults: [
+ "android_core_platform_stubs_current_contributions",
+ ],
+ api_contributions: [
+ "legacy.i18n.module.platform.api.stubs.source.api.contribution",
+ ],
+ libs: [
+ "stub-annotations",
+ ],
+}
+
java_library {
name: "legacy.core.platform.api.stubs",
visibility: core_platform_visibility,
@@ -328,6 +366,20 @@
],
}
+java_api_library {
+ name: "stable.core.platform.api.stubs.from-text",
+ api_surface: "core_platform",
+ defaults: [
+ "android_core_platform_stubs_current_contributions",
+ ],
+ api_contributions: [
+ "stable.i18n.module.platform.api.stubs.source.api.contribution",
+ ],
+ libs: [
+ "stub-annotations",
+ ],
+}
+
java_library {
name: "stable.core.platform.api.stubs",
visibility: core_platform_visibility,
diff --git a/java/dex.go b/java/dex.go
index 7e7da00..df501bf 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -71,6 +71,10 @@
// Specifies the locations of files containing proguard flags.
Proguard_flags_files []string `android:"path"`
+
+ // If true, transitive reverse dependencies of this module will have this
+ // module's proguard spec appended to their optimization action
+ Export_proguard_flags_files *bool
}
// Keep the data uncompressed. We always need uncompressed dex for execution,
diff --git a/java/dex_test.go b/java/dex_test.go
index 2ba3831..ec1ef15 100644
--- a/java/dex_test.go
+++ b/java/dex_test.go
@@ -15,6 +15,7 @@
package java
import (
+ "fmt"
"testing"
"android/soong/android"
@@ -327,7 +328,7 @@
fooD8.Args["d8Flags"], staticLibHeader.String())
}
-func TestProguardFlagsInheritance(t *testing.T) {
+func TestProguardFlagsInheritanceStatic(t *testing.T) {
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app {
name: "app",
@@ -380,3 +381,246 @@
android.AssertStringDoesContain(t, "expected tertiary_lib's proguard flags from inherited dep",
appR8.Args["r8Flags"], "tertiary.flags")
}
+
+func TestProguardFlagsInheritance(t *testing.T) {
+ directDepFlagsFileName := "direct_dep.flags"
+ transitiveDepFlagsFileName := "transitive_dep.flags"
+ bp := `
+ android_app {
+ name: "app",
+ static_libs: ["androidlib"], // this must be static_libs to initate dexing
+ platform_apis: true,
+ }
+
+ android_library {
+ name: "androidlib",
+ static_libs: ["app_dep"],
+ }
+
+ java_library {
+ name: "app_dep",
+ %s: ["dep"],
+ }
+
+ java_library {
+ name: "dep",
+ %s: ["transitive_dep"],
+ optimize: {
+ proguard_flags_files: ["direct_dep.flags"],
+ export_proguard_flags_files: %v,
+ },
+ }
+
+ java_library {
+ name: "transitive_dep",
+ optimize: {
+ proguard_flags_files: ["transitive_dep.flags"],
+ export_proguard_flags_files: %v,
+ },
+ }
+ `
+
+ testcases := []struct {
+ name string
+ depType string
+ depExportsFlagsFiles bool
+ transitiveDepType string
+ transitiveDepExportsFlagsFiles bool
+ expectedFlagsFiles []string
+ }{
+ {
+ name: "libs_export_libs_export",
+ depType: "libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "static_export_libs_export",
+ depType: "static_libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "libs_no-export_static_export",
+ depType: "libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{transitiveDepFlagsFileName},
+ },
+ {
+ name: "static_no-export_static_export",
+ depType: "static_libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "libs_export_libs_no-export",
+ depType: "libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{directDepFlagsFileName},
+ },
+ {
+ name: "static_export_libs_no-export",
+ depType: "static_libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{directDepFlagsFileName},
+ },
+ {
+ name: "libs_no-export_static_no-export",
+ depType: "libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{},
+ },
+ {
+ name: "static_no-export_static_no-export",
+ depType: "static_libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "libs_no-export_libs_export",
+ depType: "libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{transitiveDepFlagsFileName},
+ },
+ {
+ name: "static_no-export_libs_export",
+ depType: "static_libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "libs_export_static_export",
+ depType: "libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "static_export_static_export",
+ depType: "static_libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: true,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "libs_no-export_libs_no-export",
+ depType: "libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{},
+ },
+ {
+ name: "static_no-export_libs_no-export",
+ depType: "static_libs",
+ depExportsFlagsFiles: false,
+ transitiveDepType: "libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{directDepFlagsFileName},
+ },
+ {
+ name: "libs_export_static_no-export",
+ depType: "libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ {
+ name: "static_export_static_no-export",
+ depType: "static_libs",
+ depExportsFlagsFiles: true,
+ transitiveDepType: "static_libs",
+ transitiveDepExportsFlagsFiles: false,
+ expectedFlagsFiles: []string{directDepFlagsFileName, transitiveDepFlagsFileName},
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(tc.name, func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureMergeMockFs(android.MockFS{
+ directDepFlagsFileName: nil,
+ transitiveDepFlagsFileName: nil,
+ }),
+ ).RunTestWithBp(t,
+ fmt.Sprintf(
+ bp,
+ tc.depType,
+ tc.transitiveDepType,
+ tc.depExportsFlagsFiles,
+ tc.transitiveDepExportsFlagsFiles,
+ ),
+ )
+ appR8 := result.ModuleForTests("app", "android_common").Rule("r8")
+
+ shouldHaveDepFlags := android.InList(directDepFlagsFileName, tc.expectedFlagsFiles)
+ if shouldHaveDepFlags {
+ android.AssertStringDoesContain(t, "expected deps's proguard flags",
+ appR8.Args["r8Flags"], directDepFlagsFileName)
+ } else {
+ android.AssertStringDoesNotContain(t, "app did not expect deps's proguard flags",
+ appR8.Args["r8Flags"], directDepFlagsFileName)
+ }
+
+ shouldHaveTransitiveDepFlags := android.InList(transitiveDepFlagsFileName, tc.expectedFlagsFiles)
+ if shouldHaveTransitiveDepFlags {
+ android.AssertStringDoesContain(t, "expected transitive deps's proguard flags",
+ appR8.Args["r8Flags"], transitiveDepFlagsFileName)
+ } else {
+ android.AssertStringDoesNotContain(t, "app did not expect transitive deps's proguard flags",
+ appR8.Args["r8Flags"], transitiveDepFlagsFileName)
+ }
+ })
+ }
+}
+
+func TestProguardFlagsInheritanceAppImport(t *testing.T) {
+ bp := `
+ android_app {
+ name: "app",
+ static_libs: ["aarimport"], // this must be static_libs to initate dexing
+ platform_apis: true,
+ }
+
+ android_library {
+ name: "androidlib",
+ static_libs: ["aarimport"],
+ }
+
+ android_library_import {
+ name: "aarimport",
+ aars: ["import.aar"],
+ }
+ `
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ ).RunTestWithBp(t, bp)
+
+ appR8 := result.ModuleForTests("app", "android_common").Rule("r8")
+ android.AssertStringDoesContain(t, "expected aarimports's proguard flags",
+ appR8.Args["r8Flags"], "proguard.txt")
+}
diff --git a/java/generated_java_library.go b/java/generated_java_library.go
index f9baa85..1cab6ac 100644
--- a/java/generated_java_library.go
+++ b/java/generated_java_library.go
@@ -78,11 +78,6 @@
checkPropertyEmpty(ctx, module, "exclude_srcs", module.Library.properties.Exclude_srcs)
checkPropertyEmpty(ctx, module, "java_resource_dirs", module.Library.properties.Java_resource_dirs)
checkPropertyEmpty(ctx, module, "exclude_java_resource_dirs", module.Library.properties.Exclude_java_resource_dirs)
- // No additional libraries. The generator should add anything necessary automatically
- // by returning something from ____ (TODO: Additional libraries aren't needed now, so
- // these are just blocked).
- checkPropertyEmpty(ctx, module, "libs", module.Library.properties.Libs)
- checkPropertyEmpty(ctx, module, "static_libs", module.Library.properties.Static_libs)
// Restrict these for no good reason other than to limit the surface area. If there's a
// good use case put them back.
checkPropertyEmpty(ctx, module, "plugins", module.Library.properties.Plugins)
diff --git a/java/java.go b/java/java.go
index 70aba8e..5f59fe4 100644
--- a/java/java.go
+++ b/java/java.go
@@ -225,6 +225,23 @@
}, "jar_name", "partition", "main_class")
)
+type ProguardSpecInfo struct {
+ // If true, proguard flags files will be exported to reverse dependencies across libs edges
+ // If false, proguard flags files will only be exported to reverse dependencies across
+ // static_libs edges.
+ Export_proguard_flags_files bool
+
+ // TransitiveDepsProguardSpecFiles is a depset of paths to proguard flags files that are exported from
+ // all transitive deps. This list includes all proguard flags files from transitive static dependencies,
+ // and all proguard flags files from transitive libs dependencies which set `export_proguard_spec: true`.
+ ProguardFlagsFiles *android.DepSet[android.Path]
+
+ // implementation detail to store transitive proguard flags files from exporting shared deps
+ UnconditionallyExportedProguardFlags *android.DepSet[android.Path]
+}
+
+var ProguardSpecInfoProvider = blueprint.NewProvider(ProguardSpecInfo{})
+
// JavaInfo contains information about a java module for use by modules that depend on it.
type JavaInfo struct {
// HeaderJars is a list of jars that can be passed as the javac classpath in order to link
@@ -310,11 +327,6 @@
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
}
-// Provides transitive Proguard flag files to downstream DEX jars.
-type LibraryDependency interface {
- ExportedProguardFlagFiles() android.Paths
-}
-
// TODO(jungjw): Move this to kythe.go once it's created.
type xref interface {
XrefJavaFiles() android.Paths
@@ -626,12 +638,6 @@
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths)
}
-var _ LibraryDependency = (*Library)(nil)
-
-func (j *Library) ExportedProguardFlagFiles() android.Paths {
- return j.exportedProguardFlagFiles
-}
-
var _ android.ApexModule = (*Library)(nil)
// Provides access to the list of permitted packages from apex boot jars.
@@ -730,15 +736,9 @@
j.installFile = ctx.InstallFile(installDir, j.Stem()+".jar", j.outputFile, extraInstallDeps...)
}
- j.exportedProguardFlagFiles = append(j.exportedProguardFlagFiles,
- android.PathsForModuleSrc(ctx, j.dexProperties.Optimize.Proguard_flags_files)...)
- ctx.VisitDirectDeps(func(m android.Module) {
- if lib, ok := m.(LibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
- j.exportedProguardFlagFiles = append(j.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
- }
- })
- j.exportedProguardFlagFiles = android.FirstUniquePaths(j.exportedProguardFlagFiles)
-
+ proguardSpecInfo := j.collectProguardSpecInfo(ctx)
+ ctx.SetProvider(ProguardSpecInfoProvider, proguardSpecInfo)
+ j.exportedProguardFlagFiles = proguardSpecInfo.ProguardFlagsFiles.ToList()
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
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/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/config/lints.go b/rust/config/lints.go
index ef6b315..9322981 100644
--- a/rust/config/lints.go
+++ b/rust/config/lints.go
@@ -46,6 +46,7 @@
"-A deprecated",
"-D missing-docs",
"-D warnings",
+ "-D unsafe_op_in_unsafe_fn",
}
// Default Clippy lints. These are applied on top of defaultRustcLints.
// It should be assumed that any warning lint will be promoted to a
@@ -55,6 +56,7 @@
"-A clippy::unnecessary-wraps",
"-A clippy::unusual-byte-groupings",
"-A clippy::upper-case-acronyms",
+ "-D clippy::undocumented_unsafe_blocks",
}
// Rust lints for vendor code.
diff --git a/rust/library_test.go b/rust/library_test.go
index add7173..30ef333 100644
--- a/rust/library_test.go
+++ b/rust/library_test.go
@@ -196,6 +196,65 @@
}
}
+func TestNativeDependencyOfRlib(t *testing.T) {
+ ctx := testRust(t, `
+ rust_ffi_static {
+ name: "libffi_static",
+ crate_name: "ffi_static",
+ rlibs: ["librust_rlib"],
+ srcs: ["foo.rs"],
+ }
+ rust_library_rlib {
+ name: "librust_rlib",
+ crate_name: "rust_rlib",
+ srcs: ["foo.rs"],
+ shared_libs: ["shared_cc_dep"],
+ static_libs: ["static_cc_dep"],
+ }
+ cc_library_shared {
+ name: "shared_cc_dep",
+ srcs: ["foo.cpp"],
+ }
+ cc_library_static {
+ name: "static_cc_dep",
+ srcs: ["foo.cpp"],
+ }
+ `)
+
+ rustRlibRlibStd := ctx.ModuleForTests("librust_rlib", "android_arm64_armv8-a_rlib_rlib-std")
+ rustRlibDylibStd := ctx.ModuleForTests("librust_rlib", "android_arm64_armv8-a_rlib_dylib-std")
+ ffiStatic := ctx.ModuleForTests("libffi_static", "android_arm64_armv8-a_static")
+
+ modules := []android.TestingModule{
+ rustRlibRlibStd,
+ rustRlibDylibStd,
+ ffiStatic,
+ }
+
+ // librust_rlib specifies -L flag to cc deps output directory on rustc command
+ // and re-export the cc deps to rdep libffi_static
+ // When building rlib crate, rustc doesn't link the native libraries
+ // The build system assumes the cc deps will be at the final linkage (either a shared library or binary)
+ // Hence, these flags are no-op
+ // TODO: We could consider removing these flags
+ for _, module := range modules {
+ if !strings.Contains(module.Rule("rustc").Args["libFlags"],
+ "-L out/soong/.intermediates/shared_cc_dep/android_arm64_armv8-a_shared/") {
+ t.Errorf(
+ "missing -L flag for shared_cc_dep, rustcFlags: %#v",
+ rustRlibRlibStd.Rule("rustc").Args["libFlags"],
+ )
+ }
+ if !strings.Contains(module.Rule("rustc").Args["libFlags"],
+ "-L out/soong/.intermediates/static_cc_dep/android_arm64_armv8-a_static/") {
+ t.Errorf(
+ "missing -L flag for static_cc_dep, rustcFlags: %#v",
+ rustRlibRlibStd.Rule("rustc").Args["libFlags"],
+ )
+ }
+ }
+}
+
// Test that variants pull in the right type of rustlib autodep
func TestAutoDeps(t *testing.T) {
diff --git a/rust/rust.go b/rust/rust.go
index e2154f0..fc8db86 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -613,6 +613,7 @@
&cc.RustBindgenClangProperties{},
&ClippyProperties{},
&SanitizeProperties{},
+ &fuzz.FuzzProperties{},
)
android.InitDefaultsModule(module)
diff --git a/tradefed/autogen_bazel.go b/tradefed/autogen_bazel.go
index d3109d9..9575f7a 100644
--- a/tradefed/autogen_bazel.go
+++ b/tradefed/autogen_bazel.go
@@ -99,7 +99,7 @@
}
// check for default AndroidTest.xml
- defaultTestConfigPath := ctx.ModuleDir() + "/AndroidTest.xml"
+ defaultTestConfigPath := "AndroidTest.xml"
c, _ := android.BazelStringOrLabelFromProp(ctx, &defaultTestConfigPath)
return c.Value
}