Merge "Write the list of ndk libraries to cc_toolchain/ndk_libs.bzl" into main
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index fb2e0d7..849c823 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -178,6 +178,7 @@
"external/libjpeg-turbo": Bp2BuildDefaultTrueRecursively,
"external/libmpeg2": Bp2BuildDefaultTrueRecursively,
"external/libpng": Bp2BuildDefaultTrueRecursively,
+ "external/libphonenumber": Bp2BuildDefaultTrueRecursively,
"external/libvpx": Bp2BuildDefaultTrueRecursively,
"external/libyuv": Bp2BuildDefaultTrueRecursively,
"external/lz4/lib": Bp2BuildDefaultTrue,
@@ -285,13 +286,9 @@
"hardware/interfaces/health/2.1": Bp2BuildDefaultTrue,
"hardware/interfaces/health/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/health/utils": Bp2BuildDefaultTrueRecursively,
- "hardware/interfaces/media/1.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/media/bufferpool": Bp2BuildDefaultTrueRecursively,
+ "hardware/interfaces/media": Bp2BuildDefaultTrueRecursively,
"hardware/interfaces/media/bufferpool/aidl/default/tests": Bp2BuildDefaultFalseRecursively,
- "hardware/interfaces/media/c2/1.0": Bp2BuildDefaultTrue,
- "hardware/interfaces/media/c2/1.1": Bp2BuildDefaultTrue,
- "hardware/interfaces/media/c2/1.2": Bp2BuildDefaultTrue,
- "hardware/interfaces/media/omx/1.0": Bp2BuildDefaultTrue,
+ "hardware/interfaces/media/omx/1.0/vts": Bp2BuildDefaultFalseRecursively,
"hardware/interfaces/neuralnetworks": Bp2BuildDefaultTrueRecursively,
"hardware/interfaces/neuralnetworks/aidl/vts": Bp2BuildDefaultFalseRecursively,
"hardware/interfaces/neuralnetworks/1.0/vts": Bp2BuildDefaultFalseRecursively,
@@ -414,6 +411,7 @@
"system/tools/aidl/build/tests_bp2build": Bp2BuildDefaultTrue,
"system/tools/aidl/metadata": Bp2BuildDefaultTrue,
"system/tools/hidl/metadata": Bp2BuildDefaultTrue,
+ "system/tools/hidl/utils": Bp2BuildDefaultTrue,
"system/tools/mkbootimg": Bp2BuildDefaultTrueRecursively,
"system/tools/sysprop": Bp2BuildDefaultTrue,
"system/tools/xsdc/utils": Bp2BuildDefaultTrueRecursively,
@@ -422,7 +420,7 @@
"tools/apifinder": Bp2BuildDefaultTrue,
"tools/apksig": Bp2BuildDefaultTrue,
"tools/external_updater": Bp2BuildDefaultTrueRecursively,
- "tools/metalava": Bp2BuildDefaultTrue,
+ "tools/metalava": Bp2BuildDefaultTrueRecursively,
"tools/platform-compat/java/android/compat": Bp2BuildDefaultTrueRecursively,
"tools/tradefederation/prebuilts/filegroups": Bp2BuildDefaultTrueRecursively,
}
@@ -1051,6 +1049,7 @@
"libgmock_ndk", // depends on unconverted modules: libgtest_ndk_c++
"libnativehelper_lazy_mts_jni", "libnativehelper_mts_jni", // depends on unconverted modules: libnativetesthelper_jni, libgmock_ndk
"libnativetesthelper_jni", // depends on unconverted modules: libgtest_ndk_c++
+ "libphonenumber_test", // depends on android.test.mock
"libstatslog", // depends on unconverted modules: libstatspull, statsd-aidl-ndk
"libstatslog_art", // depends on unconverted modules: statslog_art.cpp, statslog_art.h
"linker_reloc_bench_main", // depends on unconverted modules: liblinker_reloc_bench_*
@@ -1636,10 +1635,6 @@
// depends on libart-unstripped and new module type llvm_prebuilt_build_tool
"check_cfi",
- // TODO(b/297070571): cannot convert prebuilts_etc module which possess identical name and src properties
- "boringssl_self_test.zygote64.rc",
- "boringssl_self_test.zygote64_32.rc",
-
// depends on unconverted module tradefed
"HelloWorldPerformanceTest",
@@ -1721,9 +1716,10 @@
Label: "//build/bazel/examples/partitions:system_image",
Host: false,
},
- {
- Label: "//build/bazel/examples/partitions:run_test",
- Host: false,
- },
+ // TODO(b/297269187) re-enable this
+ //{
+ // Label: "//build/bazel/examples/partitions:run_test",
+ // Host: false,
+ //},
}
)
diff --git a/android/apex.go b/android/apex.go
index 6119b08..d84499b 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -934,6 +934,19 @@
})
}
+// Construct ApiLevel object from min_sdk_version string value
+func MinSdkVersionFromValue(ctx EarlyModuleContext, value string) ApiLevel {
+ if value == "" {
+ return NoneApiLevel
+ }
+ apiLevel, err := ApiLevelFromUser(ctx, value)
+ if err != nil {
+ ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
+ return NoneApiLevel
+ }
+ return apiLevel
+}
+
// Implemented by apexBundle.
type ApexTestInterface interface {
// Return true if the apex bundle is an apex_test
diff --git a/android/prebuilt_build_tool.go b/android/prebuilt_build_tool.go
index aeae20f..17b3230 100644
--- a/android/prebuilt_build_tool.go
+++ b/android/prebuilt_build_tool.go
@@ -17,7 +17,7 @@
import "path/filepath"
func init() {
- RegisterModuleType("prebuilt_build_tool", prebuiltBuildToolFactory)
+ RegisterModuleType("prebuilt_build_tool", NewPrebuiltBuildTool)
}
type prebuiltBuildToolProperties struct {
@@ -101,10 +101,6 @@
// prebuilt_build_tool is to declare prebuilts to be used during the build, particularly for use
// in genrules with the "tools" property.
-func prebuiltBuildToolFactory() Module {
- return NewPrebuiltBuildTool()
-}
-
func NewPrebuiltBuildTool() Module {
module := &prebuiltBuildTool{}
module.AddProperties(&module.properties)
diff --git a/android/rule_builder.go b/android/rule_builder.go
index 777c1cf..97582db 100644
--- a/android/rule_builder.go
+++ b/android/rule_builder.go
@@ -474,13 +474,23 @@
Inputs(depFiles.Paths())
}
+// BuildWithNinjaVars adds the built command line to the build graph, with dependencies on Inputs and Tools, and output files for
+// Outputs. This function will not escape Ninja variables, so it may be used to write sandbox manifests using Ninja variables.
+func (r *RuleBuilder) BuildWithUnescapedNinjaVars(name string, desc string) {
+ r.build(name, desc, false)
+}
+
// Build adds the built command line to the build graph, with dependencies on Inputs and Tools, and output files for
// Outputs.
func (r *RuleBuilder) Build(name string, desc string) {
+ r.build(name, desc, true)
+}
+
+func (r *RuleBuilder) build(name string, desc string, ninjaEscapeCommandString bool) {
name = ninjaNameEscape(name)
if len(r.missingDeps) > 0 {
- r.ctx.Build(pctx, BuildParams{
+ r.ctx.Build(r.pctx, BuildParams{
Rule: ErrorRule,
Outputs: r.Outputs(),
Description: desc,
@@ -619,12 +629,35 @@
name, r.sboxManifestPath.String(), r.outDir.String())
}
- // Create a rule to write the manifest as a the textproto.
+ // Create a rule to write the manifest as textproto.
pbText, err := prototext.Marshal(&manifest)
if err != nil {
ReportPathErrorf(r.ctx, "sbox manifest failed to marshal: %q", err)
}
- WriteFileRule(r.ctx, r.sboxManifestPath, string(pbText))
+ if ninjaEscapeCommandString {
+ WriteFileRule(r.ctx, r.sboxManifestPath, string(pbText))
+ } else {
+ // We need to have a rule to write files that is
+ // defined on the RuleBuilder's pctx in order to
+ // write Ninja variables in the string.
+ // The WriteFileRule function above rule can only write
+ // raw strings because it is defined on the android
+ // package's pctx, and it can't access variables defined
+ // in another context.
+ r.ctx.Build(r.pctx, BuildParams{
+ Rule: r.ctx.Rule(r.pctx, "unescapedWriteFile", blueprint.RuleParams{
+ Command: `rm -rf ${out} && cat ${out}.rsp > ${out}`,
+ Rspfile: "${out}.rsp",
+ RspfileContent: "${content}",
+ Description: "write file",
+ }, "content"),
+ Output: r.sboxManifestPath,
+ Description: "write sbox manifest " + r.sboxManifestPath.Base(),
+ Args: map[string]string{
+ "content": string(pbText),
+ },
+ })
+ }
// Generate a new string to use as the command line of the sbox rule. This uses
// a RuleBuilderCommand as a convenience method of building the command line, then
@@ -724,7 +757,7 @@
}
r.ctx.Build(r.pctx, BuildParams{
- Rule: r.ctx.Rule(pctx, name, blueprint.RuleParams{
+ Rule: r.ctx.Rule(r.pctx, name, blueprint.RuleParams{
Command: proptools.NinjaEscape(commandString),
CommandDeps: proptools.NinjaEscapeList(tools.Strings()),
Restat: r.restat,
diff --git a/android/rule_builder_test.go b/android/rule_builder_test.go
index 86647eb..a6b3a27 100644
--- a/android/rule_builder_test.go
+++ b/android/rule_builder_test.go
@@ -28,6 +28,17 @@
"android/soong/shared"
)
+var (
+ pctx_ruleBuilderTest = NewPackageContext("android/soong/rule_builder")
+ pctx_ruleBuilderTestSubContext = NewPackageContext("android/soong/rule_builder/config")
+)
+
+func init() {
+ pctx_ruleBuilderTest.Import("android/soong/rule_builder/config")
+ pctx_ruleBuilderTest.StaticVariable("cmdFlags", "${config.ConfigFlags}")
+ pctx_ruleBuilderTestSubContext.StaticVariable("ConfigFlags", "--some-clang-flag")
+}
+
func builderContext() BuilderContext {
return BuilderContextForTesting(TestConfig("out", nil, "", map[string][]byte{
"ld": nil,
@@ -496,11 +507,13 @@
type testRuleBuilderModule struct {
ModuleBase
properties struct {
- Srcs []string
+ Srcs []string
+ Flags []string
- Restat bool
- Sbox bool
- Sbox_inputs bool
+ Restat bool
+ Sbox bool
+ Sbox_inputs bool
+ Unescape_ninja_vars bool
}
}
@@ -518,8 +531,9 @@
rspFileContents2 := PathsForSource(ctx, []string{"rsp_in2"})
manifestPath := PathForModuleOut(ctx, "sbox.textproto")
- testRuleBuilder_Build(ctx, in, implicit, orderOnly, validation, out, outDep, outDir,
- manifestPath, t.properties.Restat, t.properties.Sbox, t.properties.Sbox_inputs,
+ testRuleBuilder_Build(ctx, in, implicit, orderOnly, validation, t.properties.Flags,
+ out, outDep, outDir,
+ manifestPath, t.properties.Restat, t.properties.Sbox, t.properties.Sbox_inputs, t.properties.Unescape_ninja_vars,
rspFile, rspFileContents, rspFile2, rspFileContents2)
}
@@ -543,17 +557,18 @@
rspFileContents2 := PathsForSource(ctx, []string{"rsp_in2"})
manifestPath := PathForOutput(ctx, "singleton/sbox.textproto")
- testRuleBuilder_Build(ctx, in, implicit, orderOnly, validation, out, outDep, outDir,
- manifestPath, true, false, false,
+ testRuleBuilder_Build(ctx, in, implicit, orderOnly, validation, nil, out, outDep, outDir,
+ manifestPath, true, false, false, false,
rspFile, rspFileContents, rspFile2, rspFileContents2)
}
func testRuleBuilder_Build(ctx BuilderContext, in Paths, implicit, orderOnly, validation Path,
+ flags []string,
out, outDep, outDir, manifestPath WritablePath,
- restat, sbox, sboxInputs bool,
+ restat, sbox, sboxInputs, unescapeNinjaVars bool,
rspFile WritablePath, rspFileContents Paths, rspFile2 WritablePath, rspFileContents2 Paths) {
- rule := NewRuleBuilder(pctx, ctx)
+ rule := NewRuleBuilder(pctx_ruleBuilderTest, ctx)
if sbox {
rule.Sbox(outDir, manifestPath)
@@ -564,6 +579,7 @@
rule.Command().
Tool(PathForSource(ctx, "cp")).
+ Flags(flags).
Inputs(in).
Implicit(implicit).
OrderOnly(orderOnly).
@@ -577,7 +593,11 @@
rule.Restat()
}
- rule.Build("rule", "desc")
+ if unescapeNinjaVars {
+ rule.BuildWithUnescapedNinjaVars("rule", "desc")
+ } else {
+ rule.Build("rule", "desc")
+ }
}
var prepareForRuleBuilderTest = FixtureRegisterWithContext(func(ctx RegistrationContext) {
@@ -792,3 +812,47 @@
})
}
}
+
+func TestRuleBuilderWithNinjaVarEscaping(t *testing.T) {
+ bp := `
+ rule_builder_test {
+ name: "foo_sbox_escaped_ninja",
+ flags: ["${cmdFlags}"],
+ sbox: true,
+ sbox_inputs: true,
+ }
+ rule_builder_test {
+ name: "foo_sbox",
+ flags: ["${cmdFlags}"],
+ sbox: true,
+ sbox_inputs: true,
+ unescape_ninja_vars: true,
+ }
+ `
+ result := GroupFixturePreparers(
+ prepareForRuleBuilderTest,
+ FixtureWithRootAndroidBp(bp),
+ ).RunTest(t)
+
+ escapedNinjaMod := result.ModuleForTests("foo_sbox_escaped_ninja", "").Rule("writeFile")
+ AssertStringDoesContain(
+ t,
+ "",
+ escapedNinjaMod.BuildParams.Args["content"],
+ "$${cmdFlags}",
+ )
+
+ unescapedNinjaMod := result.ModuleForTests("foo_sbox", "").Rule("unescapedWriteFile")
+ AssertStringDoesContain(
+ t,
+ "",
+ unescapedNinjaMod.BuildParams.Args["content"],
+ "${cmdFlags}",
+ )
+ AssertStringDoesNotContain(
+ t,
+ "",
+ unescapedNinjaMod.BuildParams.Args["content"],
+ "$${cmdFlags}",
+ )
+}
diff --git a/apex/apex.go b/apex/apex.go
index 1e65b0f..a116b85 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -18,6 +18,7 @@
import (
"fmt"
+ "log"
"path/filepath"
"regexp"
"sort"
@@ -991,6 +992,13 @@
return false
}
}
+
+ //TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
+ if useVndk && mctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
+ log.Print("Libbinder is linked from Vendor APEX ", a.Name(), " with module ", parent.Name())
+ return false
+ }
+
// By default, all the transitive dependencies are collected, unless filtered out
// above.
return true
@@ -2225,6 +2233,11 @@
vctx.requireNativeLibs = append(vctx.requireNativeLibs, ":vndk")
return false
}
+
+ //TODO: b/296491928 Vendor APEX should use libbinder.ndk instead of libbinder once VNDK is fully deprecated.
+ if ch.UseVndk() && ctx.Config().IsVndkDeprecated() && child.Name() == "libbinder" {
+ return false
+ }
af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
af.transitiveDep = true
@@ -2730,13 +2743,13 @@
// Only override the minSdkVersion value on Apexes which already specify
// a min_sdk_version (it's optional for non-updatable apexes), and that its
// min_sdk_version value is lower than the one to override with.
- minApiLevel := minSdkVersionFromValue(ctx, proptools.String(a.properties.Min_sdk_version))
+ minApiLevel := android.MinSdkVersionFromValue(ctx, proptools.String(a.properties.Min_sdk_version))
if minApiLevel.IsNone() {
return ""
}
overrideMinSdkValue := ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride()
- overrideApiLevel := minSdkVersionFromValue(ctx, overrideMinSdkValue)
+ overrideApiLevel := android.MinSdkVersionFromValue(ctx, overrideMinSdkValue)
if !overrideApiLevel.IsNone() && overrideApiLevel.CompareTo(minApiLevel) > 0 {
minApiLevel = overrideApiLevel
}
@@ -2751,20 +2764,7 @@
// Returns apex's min_sdk_version ApiLevel, honoring overrides
func (a *apexBundle) minSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
- return minSdkVersionFromValue(ctx, a.minSdkVersionValue(ctx))
-}
-
-// Construct ApiLevel object from min_sdk_version string value
-func minSdkVersionFromValue(ctx android.EarlyModuleContext, value string) android.ApiLevel {
- if value == "" {
- return android.NoneApiLevel
- }
- apiLevel, err := android.ApiLevelFromUser(ctx, value)
- if err != nil {
- ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
- return android.NoneApiLevel
- }
- return apiLevel
+ return android.MinSdkVersionFromValue(ctx, a.minSdkVersionValue(ctx))
}
// Ensures that a lib providing stub isn't statically linked
diff --git a/bp2build/api_domain_conversion_test.go b/bp2build/api_domain_conversion_test.go
deleted file mode 100644
index 224008f..0000000
--- a/bp2build/api_domain_conversion_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2022 Google Inc. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package bp2build
-
-import (
- "testing"
-
- "android/soong/android"
- "android/soong/cc"
-)
-
-func registerApiDomainModuleTypes(ctx android.RegistrationContext) {
- android.RegisterApiDomainBuildComponents(ctx)
- cc.RegisterNdkModuleTypes(ctx)
- cc.RegisterLibraryBuildComponents(ctx)
-}
-
-func TestApiDomainContributionsTest(t *testing.T) {
- bp := `
- api_domain {
- name: "system",
- cc_api_contributions: [
- "libfoo.ndk",
- "libbar",
- ],
- }
- `
- fs := map[string]string{
- "libfoo/Android.bp": `
- ndk_library {
- name: "libfoo",
- }
- `,
- "libbar/Android.bp": `
- cc_library {
- name: "libbar",
- }
- `,
- }
- expectedBazelTarget := MakeBazelTargetNoRestrictions(
- "api_domain",
- "system",
- AttrNameToString{
- "cc_api_contributions": `[
- "//libfoo:libfoo.ndk.contribution",
- "//libbar:libbar.contribution",
- ]`,
- "target_compatible_with": `["//build/bazel/platforms/os:android"]`,
- },
- )
- RunApiBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{
- Blueprint: bp,
- ExpectedBazelTargets: []string{expectedBazelTarget},
- Filesystem: fs,
- })
-}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 246f169..9bb1713 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2867,7 +2867,6 @@
ExpectedBazelTargets: makeCcLibraryTargets("foolib", AttrNameToString{
"implementation_dynamic_deps": `select({
"//build/bazel/rules/apex:foo": ["@api_surfaces//module-libapi/current:barlib"],
- "//build/bazel/rules/apex:system": ["@api_surfaces//module-libapi/current:barlib"],
"//conditions:default": [":barlib"],
})`,
"local_includes": `["."]`,
@@ -2925,10 +2924,6 @@
"@api_surfaces//module-libapi/current:barlib",
"@api_surfaces//module-libapi/current:quxlib",
],
- "//build/bazel/rules/apex:system": [
- "@api_surfaces//module-libapi/current:barlib",
- "@api_surfaces//module-libapi/current:quxlib",
- ],
"//conditions:default": [
":barlib",
":quxlib",
diff --git a/bp2build/cc_library_shared_conversion_test.go b/bp2build/cc_library_shared_conversion_test.go
index 90b13b0..44b9722 100644
--- a/bp2build/cc_library_shared_conversion_test.go
+++ b/bp2build/cc_library_shared_conversion_test.go
@@ -661,7 +661,7 @@
":libapexfoo_stable",
],
"//build/bazel/rules/apex:system": [
- "@api_surfaces//module-libapi/current:libplatform_stable",
+ ":libplatform_stable",
"@api_surfaces//module-libapi/current:libapexfoo_stable",
],
"//conditions:default": [
diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go
index 7429ae6..512c1e1 100644
--- a/bp2build/java_library_conversion_test.go
+++ b/bp2build/java_library_conversion_test.go
@@ -441,12 +441,13 @@
func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) {
runJavaLibraryTestCase(t, Bp2buildTestCase{
Filesystem: map[string]string{
- "res/a.res": "",
- "res1/b.res": "",
+ "res/a.res": "",
+ "res1/b.res": "",
+ "res2/b.java": "",
},
Blueprint: `java_library {
name: "java-lib-1",
- java_resource_dirs: ["res", "res1"],
+ java_resource_dirs: ["res", "res1", "res2"],
sdk_version: "current",
}`,
ExpectedBazelTargets: []string{
@@ -1046,3 +1047,14 @@
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
})
}
+
+func TestJavaSdkVersionCorePlatformDoesNotConvert(t *testing.T) {
+ runJavaLibraryTestCase(t, Bp2buildTestCase{
+ Blueprint: `java_library {
+ name: "java-lib-1",
+ sdk_version: "core_platform",
+ bazel_module: { bp2build_available: true },
+}`,
+ ExpectedBazelTargets: []string{},
+ })
+}
diff --git a/bp2build/prebuilt_etc_conversion_test.go b/bp2build/prebuilt_etc_conversion_test.go
index 5b2d609..e237303 100644
--- a/bp2build/prebuilt_etc_conversion_test.go
+++ b/bp2build/prebuilt_etc_conversion_test.go
@@ -346,3 +346,17 @@
ExpectedErr: fmt.Errorf("label attribute could not be collapsed"),
})
}
+
+func TestPrebuiltEtcNoConversionIfSrcEqualsName(t *testing.T) {
+ runPrebuiltEtcTestCase(t, Bp2buildTestCase{
+ Description: "",
+ Filesystem: map[string]string{},
+ Blueprint: `
+prebuilt_etc {
+ name: "foo",
+ filename: "fooFilename",
+ src: "foo",
+}`,
+ ExpectedBazelTargets: []string{},
+ })
+}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 83553c8..62416f7 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -1624,6 +1624,11 @@
if linkable, ok := ctx.Module().(LinkableInterface); ok && linkable.Bootstrap() {
sameApiDomain = true
}
+ // If dependency has `apex_available: ["//apex_available:platform]`, then the platform variant of rdep should link against its impl.
+ // https://cs.android.com/android/_/android/platform/build/soong/+/main:cc/cc.go;l=3617;bpv=1;bpt=0;drc=c6a93d853b37ec90786e745b8d282145e6d3b589
+ if depApexAvailable := dep.(*Module).ApexAvailable(); len(depApexAvailable) == 1 && depApexAvailable[0] == android.AvailableToPlatform {
+ sameApiDomain = true
+ }
} else {
sameApiDomain = android.InList(apiDomain, dep.(*Module).ApexAvailable())
}
diff --git a/cc/testing.go b/cc/testing.go
index d1632aa..dbdee9e 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -35,6 +35,7 @@
multitree.RegisterApiImportsModule(ctx)
+ ctx.RegisterModuleType("prebuilt_build_tool", android.NewPrebuiltBuildTool)
ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)
ctx.RegisterModuleType("cc_object", ObjectFactory)
ctx.RegisterModuleType("cc_genrule", GenRuleFactory)
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index fc56dd5..3364f50 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -119,6 +119,9 @@
}
manifest, err := readManifest(manifestFile)
+ if err != nil {
+ return err
+ }
if len(manifest.Commands) == 0 {
return fmt.Errorf("at least one commands entry is required in %q", manifestFile)
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 370a423..c48bafa 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -40,6 +40,7 @@
"android/soong/bazel"
"android/soong/bazel/cquery"
"android/soong/snapshot"
+ "android/soong/ui/metrics/bp2build_metrics_proto"
)
var pctx = android.NewPackageContext("android/soong/etc")
@@ -711,7 +712,7 @@
// Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion
// of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes
// used by both prebuilt_etc_xml and other prebuilt_* moodules
-func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) *bazelPrebuiltFileAttributes {
+func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) (*bazelPrebuiltFileAttributes, bool) {
var src bazel.LabelAttribute
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
for config, p := range configToProps {
@@ -720,7 +721,12 @@
continue
}
if props.Src != nil {
- label := android.BazelLabelForModuleSrcSingle(ctx, *props.Src)
+ srcStr := proptools.String(props.Src)
+ if srcStr == ctx.ModuleName() {
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "src == name")
+ return &bazelPrebuiltFileAttributes{}, false
+ }
+ label := android.BazelLabelForModuleSrcSingle(ctx, srcStr)
src.SetSelectValue(axis, config, label)
}
}
@@ -779,8 +785,7 @@
attrs.Filename_from_src = bazel.BoolAttribute{Value: moduleProps.Filename_from_src}
}
- return attrs
-
+ return attrs, true
}
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
@@ -793,7 +798,10 @@
return
}
- attrs := module.Bp2buildHelper(ctx)
+ attrs, convertible := module.Bp2buildHelper(ctx)
+ if !convertible {
+ return
+ }
props := bazel.BazelTargetModuleProperties{
Rule_class: "prebuilt_file",
diff --git a/java/app.go b/java/app.go
index d71cd77..d533b71 100755
--- a/java/app.go
+++ b/java/app.go
@@ -316,6 +316,17 @@
a.generateJavaUsedByApex(ctx)
}
+func (a *AndroidApp) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ defaultMinSdkVersion := a.Module.MinSdkVersion(ctx)
+ if proptools.Bool(a.appProperties.Updatable) {
+ overrideApiLevel := android.MinSdkVersionFromValue(ctx, ctx.DeviceConfig().ApexGlobalMinSdkVersionOverride())
+ if !overrideApiLevel.IsNone() && overrideApiLevel.CompareTo(defaultMinSdkVersion) > 0 {
+ return overrideApiLevel
+ }
+ }
+ return defaultMinSdkVersion
+}
+
func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) {
if a.Updatable() {
if !a.SdkVersion(ctx).Stable() {
diff --git a/java/app_test.go b/java/app_test.go
index 8474ea7..fc57f44 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -4137,3 +4137,49 @@
"\\S+soong/.intermediates/foo/android_common_bar/privapp_allowlist_com.google.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/bar.xml",
)
}
+
+func TestApexGlobalMinSdkVersionOverride(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.ApexGlobalMinSdkVersionOverride = proptools.StringPtr("Tiramisu")
+ }),
+ ).RunTestWithBp(t, `
+ android_app {
+ name: "com.android.bar",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ }
+ android_app {
+ name: "com.android.foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ min_sdk_version: "S",
+ updatable: true,
+ }
+ override_android_app {
+ name: "com.android.go.foo",
+ base: "com.android.foo",
+ }
+ `)
+ foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
+ fooOverride := result.ModuleForTests("com.android.foo", "android_common_com.android.go.foo").Rule("manifestFixer")
+ bar := result.ModuleForTests("com.android.bar", "android_common").Rule("manifestFixer")
+
+ android.AssertStringDoesContain(t,
+ "expected manifest fixer to set com.android.bar minSdkVersion to S",
+ bar.BuildParams.Args["args"],
+ "--minSdkVersion S",
+ )
+ android.AssertStringDoesContain(t,
+ "com.android.foo: expected manifest fixer to set minSdkVersion to T",
+ foo.BuildParams.Args["args"],
+ "--minSdkVersion T",
+ )
+ android.AssertStringDoesContain(t,
+ "com.android.go.foo: expected manifest fixer to set minSdkVersion to T",
+ fooOverride.BuildParams.Args["args"],
+ "--minSdkVersion T",
+ )
+
+}
diff --git a/java/java.go b/java/java.go
index 521aef3..99bb1b3 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2826,7 +2826,7 @@
if resourceStripPrefix == nil && i == 0 {
resourceStripPrefix = resAttr.Resource_strip_prefix
resources = resAttr.Resources.Value
- } else {
+ } else if !resAttr.Resources.IsEmpty() {
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{
Rule_class: "java_resources",
@@ -2904,8 +2904,13 @@
var staticDeps bazel.LabelListAttribute
if proptools.String(m.deviceProperties.Sdk_version) == "" && m.DeviceSupported() {
+ // TODO(b/297356704): handle platform apis in bp2build
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version unset")
return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
+ } else if proptools.String(m.deviceProperties.Sdk_version) == "core_platform" {
+ // TODO(b/297356582): handle core_platform in bp2build
+ ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "sdk_version core_platform")
+ return &javaCommonAttributes{}, &bp2BuildJavaInfo{}, false
}
archVariantProps := m.GetArchVariantProperties(ctx, &CommonProperties{})
diff --git a/java/sdk_library.go b/java/sdk_library.go
index b1ddde0..d1620af 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1633,7 +1633,7 @@
}{}
props.Name = proptools.StringPtr(module.sourceStubLibraryModuleName(apiScope))
- props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
+ props.Visibility = []string{"//visibility:override", "//visibility:private"}
// sources are generated from the droiddoc
props.Srcs = []string{":" + module.stubsSourceModuleName(apiScope)}
sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
@@ -1829,7 +1829,7 @@
}{}
props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope))
- props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility)
+ props.Visibility = []string{"//visibility:override", "//visibility:private"}
apiContributions := []string{}
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 118f8b6..868d697 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1474,3 +1474,32 @@
android.AssertStringEquals(t, "Module expected to contain full api surface api library", c.fullApiSurfaceStub, *m.properties.Full_api_surface_stub)
}
}
+
+func TestStaticDepStubLibrariesVisibility(t *testing.T) {
+ android.GroupFixturePreparers(
+ prepareForJavaTest,
+ PrepareForTestWithJavaSdkLibraryFiles,
+ FixtureWithLastReleaseApis("foo"),
+ android.FixtureMergeMockFs(
+ map[string][]byte{
+ "A.java": nil,
+ "dir/Android.bp": []byte(
+ `
+ java_library {
+ name: "bar",
+ srcs: ["A.java"],
+ libs: ["foo.stubs.from-source"],
+ }
+ `),
+ "dir/A.java": nil,
+ },
+ ).ExtendWithErrorHandler(
+ android.FixtureExpectsAtLeastOneErrorMatchingPattern(
+ `module "bar" variant "android_common": depends on //.:foo.stubs.from-source which is not visible to this module`)),
+ ).RunTestWithBp(t, `
+ java_sdk_library {
+ name: "foo",
+ srcs: ["A.java"],
+ }
+ `)
+}
diff --git a/rust/binary.go b/rust/binary.go
index 1e24beb..2c9f64d 100644
--- a/rust/binary.go
+++ b/rust/binary.go
@@ -137,9 +137,14 @@
func (binary *binaryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) buildOutput {
fileName := binary.getStem(ctx) + ctx.toolchain().ExecutableSuffix()
- srcPath, _ := srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs)
outputFile := android.PathForModuleOut(ctx, fileName)
ret := buildOutput{outputFile: outputFile}
+ var crateRootPath android.Path
+ if binary.baseCompiler.Properties.Crate_root == nil {
+ crateRootPath, _ = srcPathFromModuleSrcs(ctx, binary.baseCompiler.Properties.Srcs)
+ } else {
+ crateRootPath = android.PathForModuleSrc(ctx, *binary.baseCompiler.Properties.Crate_root)
+ }
flags.RustFlags = append(flags.RustFlags, deps.depFlags...)
flags.LinkFlags = append(flags.LinkFlags, deps.depLinkFlags...)
@@ -154,7 +159,7 @@
}
binary.baseCompiler.unstrippedOutputFile = outputFile
- ret.kytheFile = TransformSrcToBinary(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrcToBinary(ctx, crateRootPath, deps, flags, outputFile).kytheFile
return ret
}
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 407f275..a80a587 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -29,7 +29,7 @@
defaultBindgenFlags = []string{""}
// bindgen should specify its own Clang revision so updating Clang isn't potentially blocked on bindgen failures.
- bindgenClangVersion = "clang-r498229"
+ bindgenClangVersion = "clang-r498229b"
_ = pctx.VariableFunc("bindgenClangVersion", func(ctx android.PackageVarContext) string {
if override := ctx.Config().Getenv("LLVM_BINDGEN_PREBUILTS_VERSION"); override != "" {
diff --git a/rust/compiler.go b/rust/compiler.go
index e6a7a93..d6c52e8 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -73,6 +73,15 @@
// If no source file is defined, a single generated source module can be defined to be used as the main source.
Srcs []string `android:"path,arch_variant"`
+ // Entry point that is passed to rustc to begin the compilation. E.g. main.rs or lib.rs.
+ // When this property is set,
+ // * sandboxing is enabled for this module, and
+ // * the srcs attribute is interpreted as a list of all source files potentially
+ // used in compilation, including the entrypoint, and
+ // * compile_data can be used to add additional files used in compilation that
+ // not directly used as source files.
+ Crate_root *string `android:"path,arch_variant"`
+
// name of the lint set that should be used to validate this module.
//
// Possible values are "default" (for using a sensible set of lints
@@ -511,6 +520,8 @@
ctx.PropertyErrorf("srcs", "only a single generated source module can be defined without a main source file.")
}
+ // TODO: b/297264540 - once all modules are sandboxed, we need to select the proper
+ // entry point file from Srcs rather than taking the first one
paths := android.PathsForModuleSrc(ctx, srcs)
return paths[srcIndex], paths[1:]
}
diff --git a/rust/library.go b/rust/library.go
index 3f031c1..7432a12 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -489,7 +489,7 @@
var outputFile android.ModuleOutPath
var ret buildOutput
var fileName string
- srcPath := library.srcPath(ctx, deps)
+ crateRootPath := library.crateRootPath(ctx, deps)
if library.sourceProvider != nil {
deps.srcProviderFiles = append(deps.srcProviderFiles, library.sourceProvider.Srcs()...)
@@ -536,13 +536,13 @@
// Call the appropriate builder for this library type
if library.rlib() {
- ret.kytheFile = TransformSrctoRlib(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrctoRlib(ctx, crateRootPath, deps, flags, outputFile).kytheFile
} else if library.dylib() {
- ret.kytheFile = TransformSrctoDylib(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrctoDylib(ctx, crateRootPath, deps, flags, outputFile).kytheFile
} else if library.static() {
- ret.kytheFile = TransformSrctoStatic(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrctoStatic(ctx, crateRootPath, deps, flags, outputFile).kytheFile
} else if library.shared() {
- ret.kytheFile = TransformSrctoShared(ctx, srcPath, deps, flags, outputFile).kytheFile
+ ret.kytheFile = TransformSrctoShared(ctx, crateRootPath, deps, flags, outputFile).kytheFile
}
if library.rlib() || library.dylib() {
@@ -585,13 +585,15 @@
return ret
}
-func (library *libraryDecorator) srcPath(ctx ModuleContext, _ PathDeps) android.Path {
+func (library *libraryDecorator) crateRootPath(ctx ModuleContext, _ PathDeps) android.Path {
if library.sourceProvider != nil {
// Assume the first source from the source provider is the library entry point.
return library.sourceProvider.Srcs()[0]
- } else {
+ } else if library.baseCompiler.Properties.Crate_root == nil {
path, _ := srcPathFromModuleSrcs(ctx, library.baseCompiler.Properties.Srcs)
return path
+ } else {
+ return android.PathForModuleSrc(ctx, *library.baseCompiler.Properties.Crate_root)
}
}
@@ -606,7 +608,7 @@
return android.OptionalPath{}
}
- return android.OptionalPathForPath(Rustdoc(ctx, library.srcPath(ctx, deps),
+ return android.OptionalPathForPath(Rustdoc(ctx, library.crateRootPath(ctx, deps),
deps, flags))
}
diff --git a/rust/toolchain_library.go b/rust/toolchain_library.go
index 326d529..e118f92 100644
--- a/rust/toolchain_library.go
+++ b/rust/toolchain_library.go
@@ -21,6 +21,8 @@
"android/soong/android"
"android/soong/rust/config"
+
+ "github.com/google/blueprint/proptools"
)
// This module is used to compile the rust toolchain libraries
@@ -33,11 +35,15 @@
rustToolchainLibraryRlibFactory)
android.RegisterModuleType("rust_toolchain_library_dylib",
rustToolchainLibraryDylibFactory)
+ android.RegisterModuleType("rust_toolchain_rustc_prebuilt",
+ rustToolchainRustcPrebuiltFactory)
}
type toolchainLibraryProperties struct {
- // path to the toolchain source, relative to the top of the toolchain source
- Toolchain_src *string `android:"arch_variant"`
+ // path to the toolchain crate root, relative to the top of the toolchain source
+ Toolchain_crate_root *string `android:"arch_variant"`
+ // path to the rest of the toolchain srcs, relative to the top of the toolchain source
+ Toolchain_srcs []string `android:"arch_variant"`
}
type toolchainLibraryDecorator struct {
@@ -83,15 +89,20 @@
func rustSetToolchainSource(ctx android.LoadHookContext) {
if toolchainLib, ok := ctx.Module().(*Module).compiler.(*toolchainLibraryDecorator); ok {
prefix := "linux-x86/" + GetRustPrebuiltVersion(ctx)
- newSrcs := []string{path.Join(prefix, android.String(toolchainLib.Properties.Toolchain_src))}
+ 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 {
+ versionedSrcs[i] = path.Join(prefix, src)
+ }
type props struct {
- Srcs []string
+ Crate_root *string
+ Srcs []string
}
p := &props{}
- p.Srcs = newSrcs
+ p.Crate_root = &versionedCrateRoot
+ p.Srcs = versionedSrcs
ctx.AppendProperties(p)
-
} else {
ctx.ModuleErrorf("Called rustSetToolchainSource on a non-Rust Module.")
}
@@ -101,3 +112,47 @@
func GetRustPrebuiltVersion(ctx android.LoadHookContext) string {
return ctx.AConfig().GetenvWithDefault("RUST_PREBUILTS_VERSION", config.RustDefaultVersion)
}
+
+type toolchainRustcPrebuiltProperties struct {
+ // path to rustc prebuilt, relative to the top of the toolchain source
+ Toolchain_prebuilt_src *string
+ // path to deps, relative to the top of the toolchain source
+ Toolchain_deps []string
+ // path to deps, relative to module directory
+ Deps []string
+}
+
+func rustToolchainRustcPrebuiltFactory() android.Module {
+ module := android.NewPrebuiltBuildTool()
+ module.AddProperties(&toolchainRustcPrebuiltProperties{})
+ android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+ var toolchainProps *toolchainRustcPrebuiltProperties
+ for _, p := range ctx.Module().GetProperties() {
+ toolchainProperties, ok := p.(*toolchainRustcPrebuiltProperties)
+ if ok {
+ toolchainProps = toolchainProperties
+ }
+ }
+
+ if toolchainProps.Toolchain_prebuilt_src == nil {
+ ctx.PropertyErrorf("toolchain_prebuilt_src", "must set path to rustc prebuilt")
+ }
+
+ prefix := "linux-x86/" + GetRustPrebuiltVersion(ctx)
+ deps := make([]string, 0, len(toolchainProps.Toolchain_deps)+len(toolchainProps.Deps))
+ for _, d := range toolchainProps.Toolchain_deps {
+ deps = append(deps, path.Join(prefix, d))
+ }
+ deps = append(deps, toolchainProps.Deps...)
+
+ props := struct {
+ Src *string
+ Deps []string
+ }{
+ Src: proptools.StringPtr(path.Join(prefix, *toolchainProps.Toolchain_prebuilt_src)),
+ Deps: deps,
+ }
+ ctx.AppendProperties(&props)
+ })
+ return module
+}
diff --git a/tests/sbom_test.sh b/tests/sbom_test.sh
index 9de9b97..73fbeab 100755
--- a/tests/sbom_test.sh
+++ b/tests/sbom_test.sh
@@ -47,13 +47,10 @@
}
function diff_files {
- file_list_file="$1"; shift
- files_in_spdx_file="$1"; shift
- partition_name="$1"; shift
- exclude=
- if [ -v 'diff_excludes[$partition_name]' ]; then
- exclude=${diff_excludes[$partition_name]}
- fi
+ local file_list_file="$1"; shift
+ local files_in_spdx_file="$1"; shift
+ local partition_name="$1"; shift
+ local exclude="$1"; shift
diff "$file_list_file" "$files_in_spdx_file" $exclude
if [ $? != "0" ]; then
@@ -84,9 +81,6 @@
dump_erofs=$out_dir/host/linux-x86/bin/dump.erofs
lz4=$out_dir/host/linux-x86/bin/lz4
- declare -A diff_excludes
- diff_excludes[system]="-I /system/bin/hwservicemanager"
-
# Example output of dump.erofs is as below, and the data used in the test start
# at line 11. Column 1 is inode id, column 2 is inode type and column 3 is name.
# Each line is captured in variable "entry", awk is used to get type and name.
@@ -158,7 +152,7 @@
sort -n -o "$files_in_spdx_file" "$files_in_spdx_file"
echo ============ Diffing files in $f and SBOM
- diff_files "$file_list_file" "$files_in_spdx_file" "$partition_name"
+ diff_files "$file_list_file" "$files_in_spdx_file" "$partition_name" ""
done
RAMDISK_IMAGES="$product_out/ramdisk.img"
@@ -176,7 +170,7 @@
grep "FileName: /${partition_name}/" $product_out/sbom.spdx | sed 's/^FileName: //' | sort -n > "$files_in_spdx_file"
echo ============ Diffing files in $f and SBOM
- diff_files "$file_list_file" "$files_in_spdx_file" "$partition_name"
+ diff_files "$file_list_file" "$files_in_spdx_file" "$partition_name" ""
done
verify_package_verification_code "$product_out/sbom.spdx"
diff --git a/xml/xml.go b/xml/xml.go
index 8c0c072..20a26f5 100644
--- a/xml/xml.go
+++ b/xml/xml.go
@@ -146,7 +146,11 @@
}
func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
- baseAttrs := p.PrebuiltEtc.Bp2buildHelper(ctx)
+ baseAttrs, convertible := p.PrebuiltEtc.Bp2buildHelper(ctx)
+
+ if !convertible {
+ return
+ }
var schema *string
if p.properties.Schema != nil {