Merge "Handle product vars *flags props in cc* modules"
diff --git a/bazel/properties.go b/bazel/properties.go
index 4cae21e..b2d68da 100644
--- a/bazel/properties.go
+++ b/bazel/properties.go
@@ -307,19 +307,19 @@
}
PlatformTargetMap = map[string]string{
- TARGET_ANDROID_ARM: "//build/bazel/platforms:android_arm",
- TARGET_ANDROID_ARM64: "//build/bazel/platforms:android_arm64",
- TARGET_ANDROID_X86: "//build/bazel/platforms:android_x86",
- TARGET_ANDROID_X86_64: "//build/bazel/platforms:android_x86_64",
- TARGET_DARWIN_X86_64: "//build/bazel/platforms:darwin_x86_64",
- TARGET_FUCHSIA_ARM64: "//build/bazel/platforms:fuchsia_arm64",
- TARGET_FUCHSIA_X86_64: "//build/bazel/platforms:fuchsia_x86_64",
- TARGET_LINUX_X86: "//build/bazel/platforms:linux_glibc_x86",
- TARGET_LINUX_x86_64: "//build/bazel/platforms:linux_glibc_x86_64",
- TARGET_LINUX_BIONIC_ARM64: "//build/bazel/platforms:linux_bionic_arm64",
- TARGET_LINUX_BIONIC_X86_64: "//build/bazel/platforms:linux_bionic_x86_64",
- TARGET_WINDOWS_X86: "//build/bazel/platforms:windows_x86",
- TARGET_WINDOWS_X86_64: "//build/bazel/platforms:windows_x86_64",
+ TARGET_ANDROID_ARM: "//build/bazel/platforms/os_arch:android_arm",
+ TARGET_ANDROID_ARM64: "//build/bazel/platforms/os_arch:android_arm64",
+ TARGET_ANDROID_X86: "//build/bazel/platforms/os_arch:android_x86",
+ TARGET_ANDROID_X86_64: "//build/bazel/platforms/os_arch:android_x86_64",
+ TARGET_DARWIN_X86_64: "//build/bazel/platforms/os_arch:darwin_x86_64",
+ TARGET_FUCHSIA_ARM64: "//build/bazel/platforms/os_arch:fuchsia_arm64",
+ TARGET_FUCHSIA_X86_64: "//build/bazel/platforms/os_arch:fuchsia_x86_64",
+ TARGET_LINUX_X86: "//build/bazel/platforms/os_arch:linux_glibc_x86",
+ TARGET_LINUX_x86_64: "//build/bazel/platforms/os_arch:linux_glibc_x86_64",
+ TARGET_LINUX_BIONIC_ARM64: "//build/bazel/platforms/os_arch:linux_bionic_arm64",
+ TARGET_LINUX_BIONIC_X86_64: "//build/bazel/platforms/os_arch:linux_bionic_x86_64",
+ TARGET_WINDOWS_X86: "//build/bazel/platforms/os_arch:windows_x86",
+ TARGET_WINDOWS_X86_64: "//build/bazel/platforms/os_arch:windows_x86_64",
CONDITIONS_DEFAULT: ConditionsDefaultSelectKey, // The default condition of an os select map.
}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 49f1f42..b87d713 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -497,7 +497,7 @@
"//build/bazel/platforms/os:android": ["-DANDROID_SHARED"],
"//conditions:default": [],
}) + select({
- "//build/bazel/platforms:android_arm": ["-DANDROID_ARM_SHARED"],
+ "//build/bazel/platforms/os_arch:android_arm": ["-DANDROID_ARM_SHARED"],
"//conditions:default": [],
}),
shared_srcs = ["sharedonly.cpp"] + select({
@@ -844,8 +844,8 @@
],
srcs = ["a.cpp"],
version_script = select({
- "//build/bazel/platforms:android_arm": "android_arm.map",
- "//build/bazel/platforms:linux_bionic_arm64": "linux_bionic_arm64.map",
+ "//build/bazel/platforms/os_arch:android_arm": "android_arm.map",
+ "//build/bazel/platforms/os_arch:linux_bionic_arm64": "linux_bionic_arm64.map",
"//conditions:default": None,
}),
)`},
diff --git a/bp2build/cc_library_static_conversion_test.go b/bp2build/cc_library_static_conversion_test.go
index 0257b28..da38adb 100644
--- a/bp2build/cc_library_static_conversion_test.go
+++ b/bp2build/cc_library_static_conversion_test.go
@@ -1282,14 +1282,14 @@
"//build/bazel/platforms/os:android": ["android_src.c"],
"//conditions:default": [],
}) + select({
- "//build/bazel/platforms:android_arm": ["android_arm_src.c"],
- "//build/bazel/platforms:android_arm64": ["android_arm64_src.c"],
- "//build/bazel/platforms:android_x86": ["android_x86_src.c"],
- "//build/bazel/platforms:android_x86_64": ["android_x86_64_src.c"],
+ "//build/bazel/platforms/os_arch:android_arm": ["android_arm_src.c"],
+ "//build/bazel/platforms/os_arch:android_arm64": ["android_arm64_src.c"],
+ "//build/bazel/platforms/os_arch:android_x86": ["android_x86_src.c"],
+ "//build/bazel/platforms/os_arch:android_x86_64": ["android_x86_64_src.c"],
"//conditions:default": [],
}) + select({
- "//build/bazel/platforms:linux_bionic_arm64": ["linux_bionic_arm64_src.c"],
- "//build/bazel/platforms:linux_bionic_x86_64": ["linux_bionic_x86_64_src.c"],
+ "//build/bazel/platforms/os_arch:linux_bionic_arm64": ["linux_bionic_arm64_src.c"],
+ "//build/bazel/platforms/os_arch:linux_bionic_x86_64": ["linux_bionic_x86_64_src.c"],
"//conditions:default": [],
}),
)`},
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 79e72ac..fed9936 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -268,6 +268,66 @@
return attrs
}
+// Convenience struct to hold all attributes parsed from prebuilt properties.
+type prebuiltAttributes struct {
+ Src bazel.LabelAttribute
+}
+
+func Bp2BuildParsePrebuiltLibraryProps(ctx android.TopDownMutatorContext, module *Module) prebuiltAttributes {
+ prebuiltLibraryLinker := module.linker.(*prebuiltLibraryLinker)
+ prebuiltLinker := prebuiltLibraryLinker.prebuiltLinker
+
+ var srcLabelAttribute bazel.LabelAttribute
+
+ if len(prebuiltLinker.properties.Srcs) > 1 {
+ ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most once source file\n")
+ }
+
+ if len(prebuiltLinker.properties.Srcs) == 1 {
+ srcLabelAttribute.Value = android.BazelLabelForModuleSrcSingle(ctx, prebuiltLinker.properties.Srcs[0])
+ for arch, props := range module.GetArchProperties(ctx, &prebuiltLinkerProperties{}) {
+ if prebuiltLinkerProperties, ok := props.(*prebuiltLinkerProperties); ok {
+ if len(prebuiltLinkerProperties.Srcs) > 1 {
+ ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most once source file for arch %s\n", arch.Name)
+ }
+ if len(prebuiltLinkerProperties.Srcs) == 1 {
+ srcLabelAttribute.SetValueForArch(arch.Name, android.BazelLabelForModuleSrcSingle(ctx, prebuiltLinkerProperties.Srcs[0]))
+ }
+ }
+ }
+ }
+
+ for os, targetProperties := range module.GetTargetProperties(ctx, &prebuiltLinkerProperties{}) {
+ if prebuiltLinkerProperties, ok := targetProperties.Properties.(*prebuiltLinkerProperties); ok {
+ if len(prebuiltLinkerProperties.Srcs) > 1 {
+ ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most once source file for os %s\n", os.Name)
+
+ }
+
+ if len(prebuiltLinkerProperties.Srcs) == 1 {
+ srcLabelAttribute.SetOsValueForTarget(os.Name, android.BazelLabelForModuleSrcSingle(ctx, prebuiltLinkerProperties.Srcs[0]))
+ }
+ }
+ for arch, archProperties := range targetProperties.ArchProperties {
+ if prebuiltLinkerProperties, ok := archProperties.(*prebuiltLinkerProperties); ok {
+ if len(prebuiltLinkerProperties.Srcs) > 1 {
+ ctx.ModuleErrorf("Bp2BuildParsePrebuiltLibraryProps: Expected at most once source file for os_arch %s_%s\n", os.Name, arch.Name)
+
+ }
+
+ if len(prebuiltLinkerProperties.Srcs) == 1 {
+ srcLabelAttribute.SetOsArchValueForTarget(os.Name, arch.Name, android.BazelLabelForModuleSrcSingle(ctx, prebuiltLinkerProperties.Srcs[0]))
+ }
+ }
+
+ }
+ }
+
+ return prebuiltAttributes{
+ Src: srcLabelAttribute,
+ }
+}
+
// Convenience struct to hold all attributes parsed from compiler properties.
type compilerAttributes struct {
// Options for all languages
@@ -642,11 +702,20 @@
return relativePaths
}
-// bp2BuildParseExportedIncludes creates a string list attribute contains the
-// exported included directories of a module.
func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) bazel.StringListAttribute {
libraryDecorator := module.linker.(*libraryDecorator)
+ return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator)
+}
+func Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx android.TopDownMutatorContext, module *Module) bazel.StringListAttribute {
+ prebuiltLibraryLinker := module.linker.(*prebuiltLibraryLinker)
+ libraryDecorator := prebuiltLibraryLinker.libraryDecorator
+ return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator)
+}
+
+// bp2BuildParseExportedIncludes creates a string list attribute contains the
+// exported included directories of a module.
+func bp2BuildParseExportedIncludesHelper(ctx android.TopDownMutatorContext, module *Module, libraryDecorator *libraryDecorator) bazel.StringListAttribute {
// Export_system_include_dirs and export_include_dirs are already module dir
// relative, so they don't need to be relativized like include_dirs, which
// are root-relative.
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 9531056..17c7a7b 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -51,7 +51,6 @@
lastReleasedApiXmlFile android.WritablePath
privateApiFile android.WritablePath
removedApiFile android.WritablePath
- removedDexApiFile android.WritablePath
nullabilityWarningsFile android.WritablePath
checkCurrentApiTimestamp android.WritablePath
@@ -79,9 +78,6 @@
// the generated removed API filename by Metalava, defaults to <module>_removed.txt
Removed_api_filename *string
- // the generated removed Dex API filename by Metalava.
- Removed_dex_api_filename *string
-
Check_api struct {
Last_released ApiToCheck
@@ -274,11 +270,6 @@
d.removedApiFilePath = android.PathForModuleSrc(ctx, sourceRemovedApiFile)
}
- if String(d.properties.Removed_dex_api_filename) != "" {
- d.removedDexApiFile = android.PathForModuleOut(ctx, "metalava", String(d.properties.Removed_dex_api_filename))
- cmd.FlagWithOutput("--removed-dex-api ", d.removedDexApiFile)
- }
-
if Bool(d.properties.Write_sdk_values) {
d.metadataDir = android.PathForModuleOut(ctx, "metalava", "metadata")
cmd.FlagWithArg("--sdk-values ", d.metadataDir.String())
diff --git a/python/test.go b/python/test.go
index 6713189..7413782 100644
--- a/python/test.go
+++ b/python/test.go
@@ -15,6 +15,8 @@
package python
import (
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
"android/soong/tradefed"
)
@@ -102,6 +104,9 @@
binary.pythonInstaller = NewPythonInstaller("nativetest", "nativetest64")
test := &testDecorator{binaryDecorator: binary}
+ if hod == android.HostSupportedNoCross && test.testProperties.Test_options.Unit_test == nil {
+ test.testProperties.Test_options.Unit_test = proptools.BoolPtr(true)
+ }
module.bootstrapper = test
module.installer = test
diff --git a/rust/snapshot_utils.go b/rust/snapshot_utils.go
index e0ed1f7..943c790 100644
--- a/rust/snapshot_utils.go
+++ b/rust/snapshot_utils.go
@@ -20,12 +20,12 @@
func (mod *Module) ExcludeFromVendorSnapshot() bool {
// TODO Rust does not yet support snapshotting
- return true
+ return false
}
func (mod *Module) ExcludeFromRecoverySnapshot() bool {
// TODO Rust does not yet support snapshotting
- return true
+ return false
}
func (mod *Module) IsSnapshotLibrary() bool {