Merge "Handle already existing targets of different name" into main
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index a00ac98..5c8e5e3 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -196,6 +196,7 @@
"external/openscreen": Bp2BuildDefaultTrueRecursively,
"external/ow2-asm": Bp2BuildDefaultTrueRecursively,
"external/pcre": Bp2BuildDefaultTrueRecursively,
+ "external/perfmark/api": Bp2BuildDefaultTrueRecursively,
"external/protobuf": Bp2BuildDefaultTrueRecursively,
"external/python/pyyaml/lib/yaml": Bp2BuildDefaultTrueRecursively,
"external/python/six": Bp2BuildDefaultTrueRecursively,
@@ -244,7 +245,6 @@
"frameworks/hardware/interfaces/stats/aidl": Bp2BuildDefaultTrue,
"frameworks/libs/modules-utils/build": Bp2BuildDefaultTrueRecursively,
"frameworks/libs/modules-utils/java": Bp2BuildDefaultTrue,
- "frameworks/libs/net/common/native": Bp2BuildDefaultTrueRecursively, // TODO(b/296014682): Remove this path
"frameworks/native": Bp2BuildDefaultTrue,
"frameworks/native/libs/adbd_auth": Bp2BuildDefaultTrueRecursively,
"frameworks/native/libs/arect": Bp2BuildDefaultTrueRecursively,
@@ -925,6 +925,28 @@
"libdexmakerjvmtiagent",
"libopenjdkjvmti_headers",
"libstaticjvmtiagent",
+
+ // tradefed deps
+ "tradefed-protos",
+ "grpc-java",
+ "grpc-java-api",
+ "grpc-java-auth",
+ "grpc-java-context",
+ "grpc-java-core",
+ "grpc-java-core-inprocess",
+ "grpc-java-core-internal",
+ "grpc-java-core-util",
+ "grpc-java-protobuf",
+ "grpc-java-protobuf-lite",
+ "grpc-java-stub",
+ "grpc-java-annotation-stubs",
+ "grpc-java-annotation-stubs-srcjar",
+ "gen_annotations",
+ "opencensus-java-contrib-grpc-metrics",
+ "opencensus-java-api",
+ "gson",
+ "GsonBuildConfig.java",
+ "gson_version_generator",
}
Bp2buildModuleTypeAlwaysConvertList = []string{
@@ -948,6 +970,7 @@
"license",
"linker_config",
"ndk_library",
+ "ndk_headers",
"sysprop_library",
"xsd_config",
// go/keep-sorted end
@@ -1026,7 +1049,6 @@
"conscrypt-for-host", // TODO(b/210751803), we don't handle path property for filegroups
"host-libprotobuf-java-full", // TODO(b/210751803), we don't handle path property for filegroups
"libprotobuf-internal-python-srcs", // TODO(b/210751803), we don't handle path property for filegroups
- "libprotobuf-java-util-full", // TODO(b/210751803), we don't handle path property for filegroups
// go deps:
"analyze_bcpf", // depends on bpmodify a blueprint_go_binary.
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 4b98345..56ec17d 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -665,7 +665,8 @@
command.expression,
"--profile=" + shared.BazelMetricsFilename(context.paths, runName),
- "--host_platform=@soong_injection//product_config_platforms:mixed_builds_product-" + context.targetBuildVariant + "_" + runtime.GOOS + "_x86_64",
+ "--host_platform=@soong_injection//product_config_platforms:mixed_builds_product_" + runtime.GOOS + "_x86_64",
+ "--//build/bazel/product_config:target_build_variant=" + context.targetBuildVariant,
// Don't specify --platforms, because on some products/branches (like kernel-build-tools)
// the main platform for mixed_builds_product-variant doesn't exist because an arch isn't
// specified in product config. The derivative platforms that config_node transitions into
@@ -720,9 +721,9 @@
#####################################################
def _config_node_transition_impl(settings, attr):
if attr.os == "android" and attr.arch == "target":
- target = "mixed_builds_product-{VARIANT}"
+ target = "mixed_builds_product"
else:
- target = "mixed_builds_product-{VARIANT}_%s_%s" % (attr.os, attr.arch)
+ target = "mixed_builds_product_%s_%s" % (attr.os, attr.arch)
apex_name = ""
if attr.within_apex:
# //build/bazel/rules/apex:apex_name has to be set to a non_empty value,
@@ -794,11 +795,7 @@
)
`
- productReplacer := strings.NewReplacer(
- "{PRODUCT}", context.targetProduct,
- "{VARIANT}", context.targetBuildVariant)
-
- return []byte(productReplacer.Replace(contents))
+ return []byte(contents)
}
func (context *mixedBuildBazelContext) mainBuildFileContents() []byte {
@@ -972,9 +969,9 @@
platform_name = platforms[0].name
if platform_name == "host":
return "HOST"
- if not platform_name.startswith("mixed_builds_product-{TARGET_BUILD_VARIANT}"):
- fail("expected platform name of the form 'mixed_builds_product-{TARGET_BUILD_VARIANT}_android_<arch>' or 'mixed_builds_product-{TARGET_BUILD_VARIANT}_linux_<arch>', but was " + str(platforms))
- platform_name = platform_name.removeprefix("mixed_builds_product-{TARGET_BUILD_VARIANT}").removeprefix("_")
+ if not platform_name.startswith("mixed_builds_product"):
+ fail("expected platform name of the form 'mixed_builds_product_android_<arch>' or 'mixed_builds_product_linux_<arch>', but was " + str(platforms))
+ platform_name = platform_name.removeprefix("mixed_builds_product").removeprefix("_")
config_key = ""
if not platform_name:
config_key = "target|android"
@@ -983,7 +980,7 @@
elif platform_name.startswith("linux_"):
config_key = platform_name.removeprefix("linux_") + "|linux"
else:
- fail("expected platform name of the form 'mixed_builds_product-{TARGET_BUILD_VARIANT}_android_<arch>' or 'mixed_builds_product-{TARGET_BUILD_VARIANT}_linux_<arch>', but was " + str(platforms))
+ fail("expected platform name of the form 'mixed_builds_product_android_<arch>' or 'mixed_builds_product_linux_<arch>', but was " + str(platforms))
within_apex = buildoptions.get("//build/bazel/rules/apex:within_apex")
apex_sdk_version = buildoptions.get("//build/bazel/rules/apex:min_sdk_version")
@@ -1012,8 +1009,6 @@
return id_string + ">>NONE"
`
replacer := strings.NewReplacer(
- "{TARGET_PRODUCT}", context.targetProduct,
- "{TARGET_BUILD_VARIANT}", context.targetBuildVariant,
"{LABEL_REGISTRATION_MAP_SECTION}", labelRegistrationMapSection,
"{FUNCTION_DEF_SECTION}", functionDefSection,
"{MAIN_SWITCH_SECTION}", mainSwitchSection)
diff --git a/apex/builder.go b/apex/builder.go
index 1204dbb..729917f 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -17,6 +17,7 @@
import (
"encoding/json"
"fmt"
+ "path"
"path/filepath"
"runtime"
"sort"
@@ -231,11 +232,11 @@
Description: "run apex_linkerconfig_validation",
}, "image_dir")
- apexVintfFragmentsValidationRule = pctx.StaticRule("apexVintfFragmentsValidationRule", blueprint.RuleParams{
- Command: `/bin/bash -c '(shopt -s nullglob; for f in ${image_dir}/etc/vintf/*.xml; do VINTF_IGNORE_TARGET_FCM_VERSION=true ${assemble_vintf} -i "$$f" > /dev/null; done)' && touch ${out}`,
+ assembleVintfRule = pctx.StaticRule("assembleVintfRule", blueprint.RuleParams{
+ Command: `rm -f $out && VINTF_IGNORE_TARGET_FCM_VERSION=true ${assemble_vintf} -i $in -o $out`,
CommandDeps: []string{"${assemble_vintf}"},
- Description: "run apex_vintf_validation",
- }, "image_dir")
+ Description: "run assemble_vintf",
+ })
)
// buildManifest creates buile rules to modify the input apex_manifest.json to add information
@@ -458,6 +459,22 @@
})
}
+func isVintfFragment(fi apexFile) bool {
+ isVintfFragment, _ := path.Match("etc/vintf/*.xml", fi.path())
+ return isVintfFragment
+}
+
+func runAssembleVintf(ctx android.ModuleContext, vintfFragment android.Path) android.Path {
+ processed := android.PathForModuleOut(ctx, "vintf", vintfFragment.Base())
+ ctx.Build(pctx, android.BuildParams{
+ Rule: assembleVintfRule,
+ Input: vintfFragment,
+ Output: processed,
+ Description: "run assemble_vintf for VINTF in APEX",
+ })
+ return processed
+}
+
// buildApex creates build rules to build an APEX using apexer.
func (a *apexBundle) buildApex(ctx android.ModuleContext) {
suffix := imageApexSuffix
@@ -495,7 +512,15 @@
copyCommands = append(copyCommands, "ln -sfn "+pathOnDevice+" "+destPath)
} else {
// Copy the file into APEX
- copyCommands = append(copyCommands, "cp -f "+fi.builtFile.String()+" "+destPath)
+ if !a.testApex && isVintfFragment(fi) {
+ // copy the output of assemble_vintf instead of the original
+ vintfFragment := runAssembleVintf(ctx, fi.builtFile)
+ copyCommands = append(copyCommands, "cp -f "+vintfFragment.String()+" "+destPath)
+ implicitInputs = append(implicitInputs, vintfFragment)
+ } else {
+ copyCommands = append(copyCommands, "cp -f "+fi.builtFile.String()+" "+destPath)
+ implicitInputs = append(implicitInputs, fi.builtFile)
+ }
var installedPath android.InstallPath
if fi.class == appSet {
@@ -513,7 +538,6 @@
installedPath = ctx.InstallFile(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile)
}
}
- implicitInputs = append(implicitInputs, fi.builtFile)
// Create additional symlinks pointing the file inside the APEX (if any). Note that
// this is independent from the symlink optimization.
@@ -858,9 +882,6 @@
}
var validations android.Paths
validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
- if !a.testApex && a.SocSpecific() {
- validations = append(validations, runApexVintfFragmentsValidation(ctx, unsignedOutputFile.OutputPath, imageDir.OutputPath))
- }
// TODO(b/279688635) deapexer supports [ext4]
if suffix == imageApexSuffix && ext4 == a.payloadFsType {
validations = append(validations, runApexSepolicyTests(ctx, unsignedOutputFile.OutputPath))
@@ -1128,19 +1149,6 @@
return timestamp
}
-func runApexVintfFragmentsValidation(ctx android.ModuleContext, apexFile android.OutputPath, imageDir android.OutputPath) android.Path {
- timestamp := android.PathForModuleOut(ctx, "apex_vintf_fragments_validation.timestamp")
- ctx.Build(pctx, android.BuildParams{
- Rule: apexVintfFragmentsValidationRule,
- Input: apexFile,
- Output: timestamp,
- Args: map[string]string{
- "image_dir": imageDir.String(),
- },
- })
- return timestamp
-}
-
// Runs apex_sepolicy_tests
//
// $ deapexer list -Z {apex_file} > {file_contexts}
diff --git a/bp2build/android_app_conversion_test.go b/bp2build/android_app_conversion_test.go
index 7f04e2a..8ec4b35 100644
--- a/bp2build/android_app_conversion_test.go
+++ b/bp2build/android_app_conversion_test.go
@@ -434,7 +434,6 @@
name: "foo",
sdk_version: "current",
min_sdk_version: "24",
- max_sdk_version: "30",
target_sdk_version: "29",
optimize: {
enabled: false,
@@ -446,7 +445,6 @@
"manifest": `"AndroidManifest.xml"`,
"resource_files": `[]`,
"manifest_values": `{
- "maxSdkVersion": "30",
"minSdkVersion": "24",
"targetSdkVersion": "29",
}`,
@@ -475,12 +473,8 @@
MakeBazelTarget("android_binary", "foo", AttrNameToString{
"manifest": `"AndroidManifest.xml"`,
"resource_files": `[]`,
- "manifest_values": `{
- "minSdkVersion": "30",
- "targetSdkVersion": "30",
- }`,
- "sdk_version": `"30"`,
- "optimize": `False`,
+ "sdk_version": `"30"`,
+ "optimize": `False`,
}),
}})
}
diff --git a/bp2build/bp2build_product_config.go b/bp2build/bp2build_product_config.go
index 3d9cae0..7c26262 100644
--- a/bp2build/bp2build_product_config.go
+++ b/bp2build/bp2build_product_config.go
@@ -53,9 +53,9 @@
return res, err
}
- currentProductFolder := fmt.Sprintf("build/bazel/products/%s-%s", targetProduct, targetBuildVariant)
+ currentProductFolder := fmt.Sprintf("build/bazel/products/%s", targetProduct)
if len(productVariables.PartitionVars.ProductDirectory) > 0 {
- currentProductFolder = fmt.Sprintf("%s%s-%s", productVariables.PartitionVars.ProductDirectory, targetProduct, targetBuildVariant)
+ currentProductFolder = fmt.Sprintf("%s%s", productVariables.PartitionVars.ProductDirectory, targetProduct)
}
productReplacer := strings.NewReplacer(
@@ -73,7 +73,7 @@
}
productLabelsToVariables := make(map[string]*android.ProductVariables)
- productLabelsToVariables[productReplacer.Replace("@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}")] = &productVariables
+ productLabelsToVariables[productReplacer.Replace("@//{PRODUCT_FOLDER}:{PRODUCT}")] = &productVariables
for product, productVariablesStarlark := range productsForTestingMap {
productVariables, err := starlarkMapToProductVariables(productVariablesStarlark)
if err != nil {
@@ -84,10 +84,10 @@
res.bp2buildTargets = make(map[string]BazelTargets)
res.bp2buildTargets[currentProductFolder] = append(res.bp2buildTargets[currentProductFolder], BazelTarget{
- name: productReplacer.Replace("{PRODUCT}-{VARIANT}"),
+ name: productReplacer.Replace("{PRODUCT}"),
packageName: currentProductFolder,
content: productReplacer.Replace(`android_product(
- name = "{PRODUCT}-{VARIANT}",
+ name = "{PRODUCT}",
soong_variables = _soong_variables,
)`),
ruleClass: "android_product",
@@ -134,7 +134,7 @@
# extra rebuilding, make mixed builds always use a single platform so that the bazel artifacts
# are always under the same path.
android_product(
- name = "mixed_builds_product-{VARIANT}",
+ name = "mixed_builds_product",
soong_variables = _soong_variables,
extra_constraints = ["@//build/bazel/platforms:mixed_builds"],
)
@@ -148,34 +148,35 @@
# TODO: When we start generating the platforms for more than just the
# currently lunched product, they should all be listed here
product_labels = [
- "@soong_injection//product_config_platforms:mixed_builds_product-{VARIANT}",
- "@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}",
+ "@soong_injection//product_config_platforms:mixed_builds_product",
+ "@//{PRODUCT_FOLDER}:{PRODUCT}",
`)+strings.Join(productsForTesting, "\n")+"\n]\n"),
newFile(
"product_config_platforms",
"common.bazelrc",
productReplacer.Replace(`
build --platform_mappings=platform_mappings
-build --platforms @//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_x86_64
+build --platforms @//{PRODUCT_FOLDER}:{PRODUCT}_linux_x86_64
+build --//build/bazel/product_config:target_build_variant={VARIANT}
-build:android --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}
-build:linux_x86 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_x86
-build:linux_x86_64 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_x86_64
-build:linux_bionic_x86_64 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_bionic_x86_64
-build:linux_musl_x86 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_musl_x86
-build:linux_musl_x86_64 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_musl_x86_64
+build:android --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}
+build:linux_x86 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}_linux_x86
+build:linux_x86_64 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}_linux_x86_64
+build:linux_bionic_x86_64 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}_linux_bionic_x86_64
+build:linux_musl_x86 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}_linux_musl_x86
+build:linux_musl_x86_64 --platforms=@//{PRODUCT_FOLDER}:{PRODUCT}_linux_musl_x86_64
`)),
newFile(
"product_config_platforms",
"linux.bazelrc",
productReplacer.Replace(`
-build --host_platform @//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_linux_x86_64
+build --host_platform @//{PRODUCT_FOLDER}:{PRODUCT}_linux_x86_64
`)),
newFile(
"product_config_platforms",
"darwin.bazelrc",
productReplacer.Replace(`
-build --host_platform @//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_darwin_x86_64
+build --host_platform @//{PRODUCT_FOLDER}:{PRODUCT}_darwin_x86_64
`)),
}
res.bp2buildFiles = []BazelFile{
@@ -237,12 +238,6 @@
soongConfigDefinitions soongconfig.Bp2BuildSoongConfigDefinitions,
convertedModulePathMap map[string]string,
result *strings.Builder) {
- targetBuildVariant := "user"
- if proptools.Bool(productVariables.Eng) {
- targetBuildVariant = "eng"
- } else if proptools.Bool(productVariables.Debuggable) {
- targetBuildVariant = "userdebug"
- }
platform_sdk_version := -1
if productVariables.Platform_sdk_version != nil {
@@ -270,7 +265,6 @@
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:cfi_exclude_paths=%s\n", strings.Join(productVariables.CFIExcludePaths, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:cfi_include_paths=%s\n", strings.Join(productVariables.CFIIncludePaths, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:compressed_apex=%t\n", proptools.Bool(productVariables.CompressedApex)))
- result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:debuggable=%t\n", proptools.Bool(productVariables.Debuggable)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:default_app_certificate=%s\n", proptools.String(productVariables.DefaultAppCertificate)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:default_app_certificate_filegroup=%s\n", defaultAppCertificateFilegroup))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:device_abi=%s\n", strings.Join(productVariables.DeviceAbi, ",")))
@@ -281,7 +275,6 @@
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:device_platform=%s\n", label))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:enable_cfi=%t\n", proptools.BoolDefault(productVariables.EnableCFI, true)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:enforce_vintf_manifest=%t\n", proptools.Bool(productVariables.Enforce_vintf_manifest)))
- result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:eng=%t\n", proptools.Bool(productVariables.Eng)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:malloc_not_svelte=%t\n", proptools.Bool(productVariables.Malloc_not_svelte)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:malloc_pattern_fill_contents=%t\n", proptools.Bool(productVariables.Malloc_pattern_fill_contents)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:malloc_zero_contents=%t\n", proptools.Bool(productVariables.Malloc_zero_contents)))
@@ -290,6 +283,7 @@
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:memtag_heap_sync_include_paths=%s\n", strings.Join(productVariables.MemtagHeapSyncIncludePaths, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:manifest_package_name_overrides=%s\n", strings.Join(productVariables.ManifestPackageNameOverrides, ",")))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:native_coverage=%t\n", proptools.Bool(productVariables.Native_coverage)))
+ result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:platform_sdk_final=%t\n", proptools.Bool(productVariables.Platform_sdk_final)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:platform_version_name=%s\n", proptools.String(productVariables.Platform_version_name)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:product_brand=%s\n", productVariables.ProductBrand))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:product_manufacturer=%s\n", productVariables.ProductManufacturer))
@@ -301,7 +295,6 @@
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:release_version=%s\n", productVariables.ReleaseVersion))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:platform_sdk_version=%d\n", platform_sdk_version))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:safestack=%t\n", proptools.Bool(productVariables.Safestack)))
- result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:target_build_variant=%s\n", targetBuildVariant))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:treble_linker_namespaces=%t\n", proptools.Bool(productVariables.Treble_linker_namespaces)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:tidy_checks=%s\n", proptools.String(productVariables.TidyChecks)))
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:uml=%t\n", proptools.Bool(productVariables.Uml)))
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 2cbcfc1..560123e 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -5183,3 +5183,30 @@
}
runCcLibraryTestCase(t, tc)
}
+
+func TestNdkHeadersConversion(t *testing.T) {
+ tc := Bp2buildTestCase{
+ Description: "ndk_headers conversion",
+ ModuleTypeUnderTest: "ndk_headers",
+ ModuleTypeUnderTestFactory: cc.NdkHeadersFactory,
+ Blueprint: `
+ndk_headers {
+ name: "libfoo_headers",
+ from: "from",
+ to: "to",
+ srcs: ["foo.h", "foo_other.h"]
+}
+`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTargetNoRestrictions("ndk_headers", "libfoo_headers", AttrNameToString{
+ "strip_import_prefix": `"from"`,
+ "import_prefix": `"to"`,
+ "hdrs": `[
+ "foo.h",
+ "foo_other.h",
+ ]`,
+ }),
+ },
+ }
+ runCcLibraryTestCase(t, tc)
+}
diff --git a/bp2build/cc_test_conversion_test.go b/bp2build/cc_test_conversion_test.go
index 679a364..392a962 100644
--- a/bp2build/cc_test_conversion_test.go
+++ b/bp2build/cc_test_conversion_test.go
@@ -631,3 +631,23 @@
},
})
}
+
+func TestCcTest_UnitTestFalse(t *testing.T) {
+ runCcTestTestCase(t, ccTestBp2buildTestCase{
+ description: "cc test with test_options.tags converted to tags",
+ blueprint: `
+cc_test {
+ name: "mytest",
+ host_supported: true,
+ srcs: ["test.cpp"],
+ test_options: { unit_test: false },
+}
+` + simpleModule("cc_library_static", "libgtest_main") +
+ simpleModule("cc_library_static", "libgtest"),
+ stubbedBuildDefinitions: []string{
+ "libgtest_main",
+ "libgtest",
+ },
+ targets: []testBazelTarget{},
+ })
+}
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 38777ff..ba825cf 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -153,8 +153,6 @@
// The architecture doesn't matter here, but asm/types.h is included by linux/types.h.
"-isystem bionic/libc/kernel/uapi/asm-arm64",
"-isystem bionic/libc/kernel/android/uapi",
- // TODO(b/296014682): Remove after the bpf_headers is moved to Connectivity
- "-I frameworks/libs/net/common/native/bpf_headers/include/bpf",
"-I packages/modules/Connectivity/staticlibs/native/bpf_headers/include/bpf",
// TODO(b/149785767): only give access to specific file with AID_* constants
"-I system/core/libcutils/include",
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 1a8e90f..da5db1c 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -21,6 +21,7 @@
"github.com/google/blueprint"
"android/soong/android"
+ "android/soong/bazel"
)
var (
@@ -79,6 +80,7 @@
type headerModule struct {
android.ModuleBase
+ android.BazelModuleBase
properties headerProperties
@@ -145,6 +147,29 @@
}
}
+type bazelNdkHeadersAttributes struct {
+ Strip_import_prefix *string
+ Import_prefix *string
+ Hdrs bazel.LabelListAttribute
+}
+
+func (h *headerModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
+ props := bazel.BazelTargetModuleProperties{
+ Rule_class: "ndk_headers",
+ Bzl_load_location: "//build/bazel/rules/cc:ndk_headers.bzl",
+ }
+ attrs := &bazelNdkHeadersAttributes{
+ Strip_import_prefix: h.properties.From,
+ Import_prefix: h.properties.To,
+ Hdrs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, h.properties.Srcs, h.properties.Exclude_srcs)),
+ }
+ ctx.CreateBazelTargetModule(
+ props,
+ android.CommonAttributes{Name: h.Name()},
+ attrs,
+ )
+}
+
// ndk_headers installs the sets of ndk headers defined in the srcs property
// to the sysroot base + "usr/include" + to directory + directory component.
// ndk_headers requires the license file to be specified. Example:
@@ -155,10 +180,11 @@
// to = "bar"
// header = "include/foo/woodly/doodly.h"
// output path = "ndk/sysroot/usr/include/bar/woodly/doodly.h"
-func ndkHeadersFactory() android.Module {
+func NdkHeadersFactory() android.Module {
module := &headerModule{}
module.AddProperties(&module.properties)
android.InitAndroidModule(module)
+ android.InitBazelModule(module)
return module
}
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 9ec2ae4..54a2ee2 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -62,7 +62,7 @@
}
func RegisterNdkModuleTypes(ctx android.RegistrationContext) {
- ctx.RegisterModuleType("ndk_headers", ndkHeadersFactory)
+ ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory)
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
ctx.RegisterModuleType("versioned_ndk_headers", versionedNdkHeadersFactory)
ctx.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
diff --git a/cc/test.go b/cc/test.go
index 7a6cf1b..8c63dc6 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -25,6 +25,7 @@
"android/soong/bazel"
"android/soong/bazel/cquery"
"android/soong/tradefed"
+ "android/soong/ui/metrics/bp2build_metrics_proto"
)
// TestLinkerProperties properties to be registered via the linker
@@ -718,6 +719,13 @@
combinedData.Append(android.BazelLabelForModuleDeps(ctx, p.Data_libs))
data.SetSelectValue(axis, config, combinedData)
tags.SetSelectValue(axis, config, p.Test_options.Tags)
+
+ // TODO: b/300117121 - handle bp2build conversion of non-unit tests
+ // default to true to only handle non-nil falses
+ if !BoolDefault(p.Test_options.Unit_test, true) {
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "Host unit_test = false")
+ return
+ }
}
}
}
diff --git a/cc/testing.go b/cc/testing.go
index 21745c3..36bc261 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -42,7 +42,7 @@
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
ctx.RegisterModuleType("ndk_prebuilt_static_stl", NdkPrebuiltStaticStlFactory)
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
- ctx.RegisterModuleType("ndk_headers", ndkHeadersFactory)
+ ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory)
}
func GatherRequiredDepsForTest(oses ...android.OsType) string {
diff --git a/java/aar.go b/java/aar.go
index f28d971..8f5deab 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -1352,6 +1352,9 @@
if !supported {
return
}
+ if hasJavaResources := aaptAttrs.ConvertJavaResources(ctx, commonAttrs); hasJavaResources {
+ return
+ }
ctx.CreateBazelTargetModule(
props,
android.CommonAttributes{Name: name},
diff --git a/java/app.go b/java/app.go
index 3ab814a..6030500 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1622,7 +1622,6 @@
type manifestValueAttribute struct {
MinSdkVersion *string
- MaxSdkVersion *string
TargetSdkVersion *string
}
@@ -1636,6 +1635,16 @@
Manifest_values *manifestValueAttribute
Optimize *bool
Proguard_specs bazel.LabelListAttribute
+ Updatable *bool
+}
+
+func (b bazelAapt) ConvertJavaResources(ctx android.Bp2buildMutatorContext, javaAttrs *javaCommonAttributes) bool {
+ // TODO (b/300470246) bp2build support for java_resources & java_resource_dirs in android rules
+ hasJavaResources := !javaAttrs.javaResourcesAttributes.Resources.IsEmpty()
+ if hasJavaResources {
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_UNSUPPORTED, "(b/300470246) java resources in android_* module")
+ }
+ return hasJavaResources
}
func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (bool, android.CommonAttributes, *bazelAndroidAppAttributes) {
@@ -1660,28 +1669,9 @@
certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate)
- manifestValues := &manifestValueAttribute{}
- // TODO(b/274474008 ): Directly convert deviceProperties.Min_sdk_version in bp2build
- // MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set
- minSdkVersion := a.MinSdkVersion(ctx)
- if !minSdkVersion.IsPreview() && !minSdkVersion.IsInvalid() {
- if minSdkStr, err := minSdkVersion.EffectiveVersionString(ctx); err == nil {
- manifestValues.MinSdkVersion = &minSdkStr
- }
- }
-
- maxSdkVersion := a.MaxSdkVersion(ctx)
- if !maxSdkVersion.IsPreview() && !maxSdkVersion.IsInvalid() {
- if maxSdkStr, err := maxSdkVersion.EffectiveVersionString(ctx); err == nil {
- manifestValues.MaxSdkVersion = &maxSdkStr
- }
- }
-
- targetSdkVersion := a.TargetSdkVersion(ctx)
- if !targetSdkVersion.IsPreview() && !targetSdkVersion.IsInvalid() {
- if targetSdkStr, err := targetSdkVersion.EffectiveVersionString(ctx); err == nil {
- manifestValues.TargetSdkVersion = &targetSdkStr
- }
+ manifestValues := &manifestValueAttribute{
+ MinSdkVersion: a.deviceProperties.Min_sdk_version,
+ TargetSdkVersion: a.deviceProperties.Target_sdk_version,
}
appAttrs := &bazelAndroidAppAttributes{
@@ -1690,6 +1680,7 @@
Certificate: certificate,
Certificate_name: certificateName,
Manifest_values: manifestValues,
+ Updatable: a.appProperties.Updatable,
}
if !BoolDefault(a.dexProperties.Optimize.Enabled, true) {
@@ -1730,6 +1721,10 @@
if !supported {
return false, android.CommonAttributes{}, &bazelAndroidAppAttributes{}
}
+ if hasJavaResources := aapt.ConvertJavaResources(ctx, commonAttrs); hasJavaResources {
+ return false, android.CommonAttributes{}, &bazelAndroidAppAttributes{}
+ }
+
depLabels := bp2BuildInfo.DepLabels
deps := depLabels.Deps
diff --git a/rust/builder.go b/rust/builder.go
index 0740518..09933d3 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -22,6 +22,7 @@
"github.com/google/blueprint"
"android/soong/android"
+ cc_config "android/soong/cc/config"
"android/soong/rust/config"
)
@@ -204,7 +205,9 @@
}
}
- envVars = append(envVars, "AR="+cmd.PathForTool(deps.Llvm_ar))
+ envVars = append(envVars, "AR="+cmd.PathForInput(
+ cc_config.ClangPath(ctx, "bin/llvm-ar")),
+ )
if ctx.Darwin() {
envVars = append(envVars, "ANDROID_RUST_DARWIN=true")
@@ -292,11 +295,6 @@
}
if flags.Clippy {
- // TODO(b/298461712) remove this hack to let slim manifest branches build
- if deps.Clippy_driver == nil {
- deps.Clippy_driver = config.RustPath(ctx, "bin/clippy-driver")
- }
-
clippyRule := getRuleBuilder(ctx, pctx, false, "clippy")
clippyCmd := clippyRule.Command()
clippyFile := android.PathForModuleOut(ctx, outputFile.Base()+".clippy")
@@ -305,7 +303,7 @@
clippyCmd.
Flags(rustEnvVars(ctx, deps, clippyCmd)).
- Tool(deps.Clippy_driver).
+ Tool(config.RustPath(ctx, "bin/clippy-driver")).
Flag("--emit metadata").
FlagWithOutput("-o ", clippyFile).
FlagWithOutput("--emit dep-info=", clippyDepInfoFile).
@@ -365,14 +363,18 @@
}
}
- // TODO(b/298461712) remove this hack to let slim manifest branches build
- if deps.Rustc == nil {
- deps.Rustc = config.RustPath(ctx, "bin/rustc")
+ clangTools := android.Paths{
+ cc_config.ClangPath(ctx, "bin/llvm-ar"),
+ }
+ if ctx.Config().BuildOS != android.Darwin {
+ clangTools = append(clangTools,
+ cc_config.ClangPath(ctx, "lib/libc++.so"),
+ )
}
rustcCmd.
Flags(rustEnvVars(ctx, deps, rustcCmd)).
- Tool(deps.Rustc).
+ Tool(config.RustPath(ctx, "bin/rustc")).
FlagWithInput("-C linker=", android.PathForSource(ctx, "build", "soong", "scripts", "mkcratersp.py")).
Flag("--emit link").
Flag("-o").
@@ -380,6 +382,7 @@
FlagWithOutput("--emit dep-info=", depInfoFile).
Inputs(inputs).
Flags(libFlags).
+ Implicits(clangTools).
ImplicitTools(toolImplicits).
Implicits(implicits).
Flags(rustcFlags).
@@ -406,9 +409,20 @@
// those need to be renamed/symlinked to something in the rustLink sandbox
// if we want to separate the rules
linkerSboxOutputFile := android.PathForModuleOut(ctx, sboxDirectory, outputFile.Base())
+ clangTools := android.Paths{
+ cc_config.ClangPath(ctx, "bin/clang++"),
+ cc_config.ClangPath(ctx, "bin/lld"),
+ cc_config.ClangPath(ctx, "bin/ld.lld"),
+ }
+ if ctx.Config().BuildOS != android.Darwin {
+ clangTools = append(clangTools,
+ cc_config.ClangPath(ctx, "bin/clang++.real"),
+ cc_config.ClangPath(ctx, "lib/libc++.so"),
+ )
+ }
rustLinkCmd := rustcRule.Command()
rustLinkCmd.
- Tool(deps.Clang).
+ Tool(cc_config.ClangPath(ctx, "bin/clang++")).
Flag("-o").
Output(linkerSboxOutputFile).
Inputs(deps.CrtBegin).
@@ -416,6 +430,7 @@
FlagWithInput("@", rustSboxOutputFile).
Flags(linkFlags).
Inputs(deps.CrtEnd).
+ ImplicitTools(clangTools).
ImplicitTools(toolImplicits).
Implicits(rustcImplicitOutputs.Paths()).
Implicits(implicits).
@@ -441,7 +456,7 @@
Flag("KYTHE_CANONICALIZE_VNAME_PATHS=prefer-relative").
Tool(ctx.Config().PrebuiltBuildTool(ctx, "rust_extractor")).
Flags(rustEnvVars(ctx, deps, kytheCmd)).
- Tool(deps.Rustc).
+ Tool(config.RustPath(ctx, "bin/rustc")).
Flag("-C linker=true").
Inputs(inputs).
Flags(makeLibFlags(deps, kytheCmd)).
@@ -455,11 +470,6 @@
}
func Rustdoc(ctx ModuleContext, main android.Path, deps PathDeps, flags Flags) android.ModuleOutPath {
- // TODO(b/298461712) remove this hack to let slim manifest branches build
- if deps.Rustdoc == nil {
- deps.Rustdoc = config.RustPath(ctx, "bin/rustdoc")
- }
-
rustdocRule := getRuleBuilder(ctx, pctx, false, "rustdoc")
rustdocCmd := rustdocRule.Command()
@@ -498,7 +508,7 @@
rustdocCmd.
Flags(rustEnvVars(ctx, deps, rustdocCmd)).
- Tool(deps.Rustdoc).
+ Tool(config.RustPath(ctx, "bin/rustdoc")).
Flags(rustdocFlags).
Input(main).
Flag("-o "+docDir.String()).
diff --git a/rust/config/global.go b/rust/config/global.go
index 0ddc116..9daafba 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -147,6 +147,6 @@
if override := ctx.Config().Getenv("RUST_DEFAULT_VERSION"); override != "" {
rustVersion = override
}
- return android.PathForSource(ctx, rustBase, ctx.Config().PrebuiltOS(), rustVersion)
+ return android.PathForSource(ctx, rustBase, HostPrebuiltTag(ctx.Config()), rustVersion)
})
}
diff --git a/rust/rust.go b/rust/rust.go
index 6d6b55e..26e3ffc 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -472,13 +472,6 @@
// Paths to generated source files
SrcDeps android.Paths
srcProviderFiles android.Paths
-
- // Paths to specific build tools
- Rustc android.Path
- Clang android.Path
- Llvm_ar android.Path
- Clippy_driver android.Path
- Rustdoc android.Path
}
type RustLibraries []RustLibrary
@@ -1480,18 +1473,9 @@
depPaths.BuildToolDeps = append(depPaths.BuildToolDeps, buildTool.Deps...)
switch android.RemoveOptionalPrebuiltPrefix(dep.Name()) {
case "rustc":
- depPaths.Rustc = buildTool.Src
// rustc expects the standard cc toolchain libraries (libdl, libm, libc, etc.)
// not to be under the __SBOX_SANDBOX_DIR__/ directory
depPaths.BuildToolSrcDeps = append(depPaths.BuildToolSrcDeps, buildTool.Deps...)
- case "clang++":
- depPaths.Clang = buildTool.Src
- case "llvm-ar":
- depPaths.Llvm_ar = buildTool.Src
- case "clippy-driver":
- depPaths.Clippy_driver = buildTool.Src
- case "rustdoc":
- depPaths.Rustdoc = buildTool.Src
}
case depTag == cc.CrtBeginDepTag:
depPaths.CrtBegin = append(depPaths.CrtBegin, android.OutputFileForModule(ctx, dep, ""))
@@ -1612,13 +1596,6 @@
}
ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "rustc")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "clippy-driver")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "rustdoc")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "clang++")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "clang++.real")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "lld")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "ld.lld")
- ctx.AddFarVariationDependencies([]blueprint.Variation{}, buildToolDepTag, "llvm-ar")
// rlibs
rlibDepVariations = append(rlibDepVariations, blueprint.Variation{Mutator: "rust_libraries", Variation: rlibVariation})
diff --git a/rust/toolchain_library.go b/rust/toolchain_library.go
index cb345a4..054104c 100644
--- a/rust/toolchain_library.go
+++ b/rust/toolchain_library.go
@@ -89,7 +89,7 @@
func rustSetToolchainSource(ctx android.LoadHookContext) {
if toolchainLib, ok := ctx.Module().(*Module).compiler.(*toolchainLibraryDecorator); ok {
- prefix := filepath.Join(config.HostPrebuiltTag(ctx.Config()), GetRustPrebuiltVersion(ctx))
+ prefix := filepath.Join("linux-x86", GetRustPrebuiltVersion(ctx))
versionedCrateRoot := path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_crate_root))
versionedSrcs := make([]string, len(toolchainLib.Properties.Toolchain_srcs))
for i, src := range toolchainLib.Properties.Toolchain_srcs {