Merge "Export ndk/aml arches to Bazel"
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 16f144e..b82ea4f 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -347,6 +347,7 @@
".":/*recursive = */ false,
"build/bazel":/* recursive = */ true,
+ "build/make/core":/* recursive = */ false,
"build/bazel_common_rules":/* recursive = */ true,
// build/make/tools/signapk BUILD file is generated, so build/make/tools is not recursive.
"build/make/tools":/* recursive = */ false,
@@ -382,6 +383,8 @@
"prebuilts/sdk":/* recursive = */ false,
"prebuilts/sdk/tools":/* recursive = */ false,
"prebuilts/r8":/* recursive = */ false,
+
+ "tools/asuite/atest/":/* recursive = */ true,
}
Bp2buildModuleAlwaysConvertList = []string{
diff --git a/android/config.go b/android/config.go
index 0c3e2d1..1deb7d4 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1272,10 +1272,6 @@
return coverage
}
-func (c *deviceConfig) AfdoAdditionalProfileDirs() []string {
- return c.config.productVariables.AfdoAdditionalProfileDirs
-}
-
func (c *deviceConfig) PgoAdditionalProfileDirs() []string {
return c.config.productVariables.PgoAdditionalProfileDirs
}
diff --git a/android/fixture.go b/android/fixture.go
index f33e718..3f01f5a 100644
--- a/android/fixture.go
+++ b/android/fixture.go
@@ -658,7 +658,7 @@
func createFixture(t *testing.T, buildDir string, preparers []*simpleFixturePreparer) Fixture {
config := TestConfig(buildDir, nil, "", nil)
- ctx := NewTestContext(config)
+ ctx := newTestContextForFixture(config)
fixture := &fixture{
preparers: preparers,
t: t,
@@ -790,6 +790,16 @@
}
}
+ // Create and set the Context's NameInterface. It needs to be created here as it depends on the
+ // configuration that has been prepared for this fixture.
+ resolver := NewNameResolver(ctx.config)
+
+ // Set the NameInterface in the main Context.
+ ctx.SetNameInterface(resolver)
+
+ // Set the NameResolver in the TestContext.
+ ctx.NameResolver = resolver
+
ctx.Register()
var ninjaDeps []string
extraNinjaDeps, errs := ctx.ParseBlueprintsFiles("ignored")
diff --git a/android/namespace.go b/android/namespace.go
index a3ff761..b43ffdf 100644
--- a/android/namespace.go
+++ b/android/namespace.go
@@ -91,7 +91,27 @@
namespaceExportFilter func(*Namespace) bool
}
-func NewNameResolver(namespaceExportFilter func(*Namespace) bool) *NameResolver {
+// NameResolverConfig provides the subset of the Config interface needed by the
+// NewNameResolver function.
+type NameResolverConfig interface {
+ // ExportedNamespaces is the list of namespaces that Soong must export to
+ // make.
+ ExportedNamespaces() []string
+}
+
+func NewNameResolver(config NameResolverConfig) *NameResolver {
+ namespacePathsToExport := make(map[string]bool)
+
+ for _, namespaceName := range config.ExportedNamespaces() {
+ namespacePathsToExport[namespaceName] = true
+ }
+
+ namespacePathsToExport["."] = true // always export the root namespace
+
+ namespaceExportFilter := func(namespace *Namespace) bool {
+ return namespacePathsToExport[namespace.Path]
+ }
+
r := &NameResolver{
namespacesByDir: sync.Map{},
namespaceExportFilter: namespaceExportFilter,
diff --git a/android/namespace_test.go b/android/namespace_test.go
index 87d1320..7a387a0 100644
--- a/android/namespace_test.go
+++ b/android/namespace_test.go
@@ -602,6 +602,36 @@
// RunTest will report any errors
}
+func TestNamespace_Exports(t *testing.T) {
+ result := GroupFixturePreparers(
+ prepareForTestWithNamespace,
+ FixtureModifyProductVariables(func(variables FixtureProductVariables) {
+ variables.NamespacesToExport = []string{"dir1"}
+ }),
+ dirBpToPreparer(map[string]string{
+ "dir1": `
+ soong_namespace {
+ }
+ test_module {
+ name: "a",
+ }
+ `,
+ "dir2": `
+ soong_namespace {
+ }
+ test_module {
+ name: "b",
+ }
+ `,
+ }),
+ ).RunTest(t)
+
+ aModule := result.Module("a", "")
+ AssertBoolEquals(t, "a exported", true, aModule.ExportedToMake())
+ bModule := result.Module("b", "")
+ AssertBoolEquals(t, "b not exported", false, bModule.ExportedToMake())
+}
+
// some utils to support the tests
var prepareForTestWithNamespace = GroupFixturePreparers(
diff --git a/android/testing.go b/android/testing.go
index 2256c96..8fcf440 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -30,19 +30,11 @@
"github.com/google/blueprint/proptools"
)
-func NewTestContext(config Config) *TestContext {
- namespaceExportFilter := func(namespace *Namespace) bool {
- return true
- }
-
- nameResolver := NewNameResolver(namespaceExportFilter)
+func newTestContextForFixture(config Config) *TestContext {
ctx := &TestContext{
- Context: &Context{blueprint.NewContext(), config},
- NameResolver: nameResolver,
+ Context: &Context{blueprint.NewContext(), config},
}
- ctx.SetNameInterface(nameResolver)
-
ctx.postDeps = append(ctx.postDeps, registerPathDepsMutator)
ctx.SetFs(ctx.config.fs)
@@ -53,6 +45,16 @@
return ctx
}
+func NewTestContext(config Config) *TestContext {
+ ctx := newTestContextForFixture(config)
+
+ nameResolver := NewNameResolver(config)
+ ctx.NameResolver = nameResolver
+ ctx.SetNameInterface(nameResolver)
+
+ return ctx
+}
+
var PrepareForTestWithArchMutator = GroupFixturePreparers(
// Configure architecture targets in the fixture config.
FixtureModifyConfig(modifyTestConfigToSupportArchMutator),
diff --git a/android/variable.go b/android/variable.go
index 37ecab5..28f22c9 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -336,8 +336,7 @@
NamespacesToExport []string `json:",omitempty"`
- AfdoAdditionalProfileDirs []string `json:",omitempty"`
- PgoAdditionalProfileDirs []string `json:",omitempty"`
+ PgoAdditionalProfileDirs []string `json:",omitempty"`
VndkUseCoreVariant *bool `json:",omitempty"`
VndkSnapshotBuildArtifacts *bool `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index 72403f9..09de2d4 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1911,6 +1911,7 @@
a.nativeApisBackedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.BackingLibs))
// TODO(b/239084755): Generate the java api using.xml file from Bazel.
a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.JavaSymbolsUsedByApex))
+ a.installedFilesFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.InstalledFiles))
installSuffix := imageApexSuffix
if a.isCompressed {
installSuffix = imageCapexSuffix
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 985ad59..ea3e734 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -9775,6 +9775,7 @@
SymbolsUsedByApex: "foo_using.txt",
JavaSymbolsUsedByApex: "foo_using.xml",
BundleFile: "apex_bundle.zip",
+ InstalledFiles: "installed-files.txt",
// unused
PackageName: "pkg_name",
@@ -9820,6 +9821,10 @@
t.Errorf("Expected output file %q, got %q", w, g)
}
+ if w, g := "out/bazel/execroot/__main__/installed-files.txt", ab.installedFilesFile.String(); w != g {
+ t.Errorf("Expected installed-files.txt %q, got %q", w, g)
+ }
+
mkData := android.AndroidMkDataForTest(t, result.TestContext, m)
var builder strings.Builder
mkData.Custom(&builder, "foo", "BAZEL_TARGET_", "", mkData)
@@ -9828,4 +9833,7 @@
if w := "ALL_MODULES.$(my_register_name).BUNDLE := out/bazel/execroot/__main__/apex_bundle.zip"; !strings.Contains(data, w) {
t.Errorf("Expected %q in androidmk data, but did not find %q", w, data)
}
+ if w := "$(call dist-for-goals,checkbuild,out/bazel/execroot/__main__/installed-files.txt:foo-installed-files.txt)"; !strings.Contains(data, w) {
+ t.Errorf("Expected %q in androidmk data, but did not find %q", w, data)
+ }
}
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index eb44dd1..b675f17 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -232,6 +232,7 @@
"java_symbols_used_by_apex": info.java_symbols_used_by_apex.path,
"backing_libs": info.backing_libs.path,
"bundle_file": info.base_with_config_zip.path,
+ "installed_files": info.installed_files.path,
})`
}
@@ -247,6 +248,7 @@
JavaSymbolsUsedByApex string `json:"java_symbols_used_by_apex"`
BackingLibs string `json:"backing_libs"`
BundleFile string `json:"bundle_file"`
+ InstalledFiles string `json:"installed_files"`
}
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
diff --git a/bazel/cquery/request_type_test.go b/bazel/cquery/request_type_test.go
index a0a993f..1d30535 100644
--- a/bazel/cquery/request_type_test.go
+++ b/bazel/cquery/request_type_test.go
@@ -176,6 +176,7 @@
"symbols_used_by_apex": "path/to/my.apex_using.txt",
"backing_libs":"path/to/backing.txt",
"bundle_file": "dir/bundlefile.zip",
+ "installed_files":"path/to/installed-files.txt",
"provides_native_libs":[]
}`,
expectedOutput: ApexInfo{
@@ -189,6 +190,7 @@
SymbolsUsedByApex: "path/to/my.apex_using.txt",
BackingLibs: "path/to/backing.txt",
BundleFile: "dir/bundlefile.zip",
+ InstalledFiles: "path/to/installed-files.txt",
},
},
}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 0d6d5b8..4c86374 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -3508,3 +3508,38 @@
},
})
}
+
+func TestCcLibraryWithTidy(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library uses tidy properties",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ srcs: ["foo.cpp"],
+ tidy: true,
+ tidy_checks: ["check1", "check2"],
+ tidy_checks_as_errors: ["check1error", "check2error"],
+ tidy_disabled_srcs: ["bar.cpp"],
+ tidy_timeout_srcs: ["baz.cpp"],
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "local_includes": `["."]`,
+ "srcs": `["foo.cpp"]`,
+ "tidy": `True`,
+ "tidy_checks": `[
+ "check1",
+ "check2",
+ ]`,
+ "tidy_checks_as_errors": `[
+ "check1error",
+ "check2error",
+ ]`,
+ "tidy_disabled_srcs": `["bar.cpp"]`,
+ "tidy_timeout_srcs": `["baz.cpp"]`,
+ }),
+ },
+ })
+}
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 60a410d..a840fa3 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -18,11 +18,13 @@
"fmt"
"io"
"path/filepath"
+ "runtime"
"strings"
"android/soong/android"
"android/soong/bazel"
"android/soong/bazel/cquery"
+ "android/soong/cc"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -31,6 +33,7 @@
func init() {
registerBpfBuildComponents(android.InitRegistrationContext)
pctx.Import("android/soong/cc/config")
+ pctx.StaticVariable("relPwd", cc.PwdPrefix())
}
var (
@@ -40,7 +43,7 @@
blueprint.RuleParams{
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
- Command: "$ccCmd --target=bpf -c $cFlags -MD -MF ${out}.d -o $out $in",
+ Command: "$relPwd $ccCmd --target=bpf -c $cFlags -MD -MF ${out}.d -o $out $in",
CommandDeps: []string{"$ccCmd"},
},
"ccCmd", "cFlags")
@@ -164,6 +167,9 @@
if proptools.Bool(bpf.properties.Btf) {
cflags = append(cflags, "-g")
+ if runtime.GOOS != "darwin" {
+ cflags = append(cflags, "-fdebug-prefix-map=/proc/self/cwd=")
+ }
}
srcs := android.PathsForModuleSrc(ctx, bpf.properties.Srcs)
diff --git a/cc/afdo.go b/cc/afdo.go
index fb66bbe..d36f4af 100644
--- a/cc/afdo.go
+++ b/cc/afdo.go
@@ -36,7 +36,7 @@
func getAfdoProfileProjects(config android.DeviceConfig) []string {
return config.OnceStringSlice(afdoProfileProjectsConfigKey, func() []string {
- return append(globalAfdoProfileProjects, config.AfdoAdditionalProfileDirs()...)
+ return globalAfdoProfileProjects
})
}
diff --git a/cc/binary.go b/cc/binary.go
index d09e744..c2868e7 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -646,7 +646,7 @@
sdkAttributes: bp2BuildParseSdkAttributes(m),
}
- m.convertTidyAttributes(&attrs.tidyAttributes)
+ m.convertTidyAttributes(ctx, &attrs.tidyAttributes)
return attrs
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 2f79cae..6caa854 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -75,9 +75,11 @@
Tidy_flags []string
Tidy_checks []string
Tidy_checks_as_errors []string
+ Tidy_disabled_srcs bazel.LabelListAttribute
+ Tidy_timeout_srcs bazel.LabelListAttribute
}
-func (m *Module) convertTidyAttributes(moduleAttrs *tidyAttributes) {
+func (m *Module) convertTidyAttributes(ctx android.BaseMutatorContext, moduleAttrs *tidyAttributes) {
for _, f := range m.features {
if tidy, ok := f.(*tidyFeature); ok {
moduleAttrs.Tidy = tidy.Properties.Tidy
@@ -85,6 +87,18 @@
moduleAttrs.Tidy_checks = tidy.Properties.Tidy_checks
moduleAttrs.Tidy_checks_as_errors = tidy.Properties.Tidy_checks_as_errors
}
+
+ }
+ archVariantProps := m.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
+ for axis, configToProps := range archVariantProps {
+ for config, _props := range configToProps {
+ if archProps, ok := _props.(*BaseCompilerProperties); ok {
+ archDisabledSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_disabled_srcs)
+ moduleAttrs.Tidy_disabled_srcs.SetSelectValue(axis, config, archDisabledSrcs)
+ archTimeoutSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_timeout_srcs)
+ moduleAttrs.Tidy_timeout_srcs.SetSelectValue(axis, config, archTimeoutSrcs)
+ }
+ }
}
}
diff --git a/cc/builder.go b/cc/builder.go
index 75e4736..46cea0b 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -924,9 +924,9 @@
}
// sourceAbiDiff registers a build statement to compare linked sAbi dump files (.lsdump).
-func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
- baseName, exportedHeaderFlags string, diffFlags []string, prevVersion int,
- checkAllApis, isLlndk, isNdk, isVndkExt, previousVersionDiff bool) android.OptionalPath {
+func sourceAbiDiff(ctx android.ModuleContext, inputDump, referenceDump android.Path,
+ baseName string, diffFlags []string, prevVersion int,
+ checkAllApis, isLlndkOrNdk, isVndkExt, previousVersionDiff bool) android.OptionalPath {
var outputFile android.ModuleOutPath
if previousVersionDiff {
@@ -955,7 +955,7 @@
extraFlags = append(extraFlags, "-target-version", "current")
}
- if isLlndk || isNdk {
+ if isLlndkOrNdk {
extraFlags = append(extraFlags, "-consider-opaque-types-different")
}
if isVndkExt || previousVersionDiff {
diff --git a/cc/config/arm_device.go b/cc/config/arm_device.go
index b53a097..981d1ea 100644
--- a/cc/config/arm_device.go
+++ b/cc/config/arm_device.go
@@ -222,6 +222,7 @@
"": "${config.ArmGenericCflags}",
"cortex-a7": "${config.ArmCortexA7Cflags}",
"cortex-a8": "${config.ArmCortexA8Cflags}",
+ "cortex-a9": "${config.ArmGenericCflags}",
"cortex-a15": "${config.ArmCortexA15Cflags}",
"cortex-a53": "${config.ArmCortexA53Cflags}",
"cortex-a53.a57": "${config.ArmCortexA53Cflags}",
diff --git a/cc/library.go b/cc/library.go
index ef10e7c..897f3c7 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1910,26 +1910,28 @@
addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())
+ isNdk := ctx.isNdk(ctx.Config())
+ isLlndk := ctx.isImplementationForLLNDKPublic()
// If NDK or PLATFORM library, check against previous version ABI.
if !ctx.useVndk() {
prevRefAbiDumpFile := getRefAbiDumpFile(ctx, strconv.Itoa(prevVersion), fileName)
if prevRefAbiDumpFile != nil {
library.prevSAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
- prevRefAbiDumpFile, fileName, exportedHeaderFlags,
+ prevRefAbiDumpFile, fileName,
library.Properties.Header_abi_checker.Diff_flags, prevVersion,
Bool(library.Properties.Header_abi_checker.Check_all_apis),
- ctx.IsLlndk(), ctx.isNdk(ctx.Config()), ctx.IsVndkExt(), true)
+ isLlndk || isNdk, ctx.IsVndkExt(), true)
}
}
refAbiDumpFile := getRefAbiDumpFile(ctx, version, fileName)
if refAbiDumpFile != nil {
library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
- refAbiDumpFile, fileName, exportedHeaderFlags,
+ refAbiDumpFile, fileName,
library.Properties.Header_abi_checker.Diff_flags,
/* unused if not previousVersionDiff */ 0,
Bool(library.Properties.Header_abi_checker.Check_all_apis),
- ctx.IsLlndk(), ctx.isNdk(ctx.Config()), ctx.IsVndkExt(), false)
+ isLlndk || isNdk, ctx.IsVndkExt(), false)
}
}
}
@@ -2792,7 +2794,7 @@
Runtime_deps: linkerAttrs.runtimeDeps,
}
- module.convertTidyAttributes(&commonAttrs.tidyAttributes)
+ module.convertTidyAttributes(ctx, &commonAttrs.tidyAttributes)
var attrs interface{}
if isStatic {
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 2fb21a3..043c03c 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -288,8 +288,8 @@
}
type variantExporterProperties struct {
- // Header directory or library to export
- Export_headers []string
+ // Header directory to export
+ Export_headers []string `android:"arch_variant"`
// Export all headers as system include
Export_headers_as_system *bool
diff --git a/cc/strip.go b/cc/strip.go
index 5c32d8b..c60e135 100644
--- a/cc/strip.go
+++ b/cc/strip.go
@@ -56,9 +56,7 @@
forceEnable := Bool(stripper.StripProperties.Strip.All) ||
Bool(stripper.StripProperties.Strip.Keep_symbols) ||
Bool(stripper.StripProperties.Strip.Keep_symbols_and_debug_frame)
- // create_minidebuginfo doesn't work for riscv64 yet, disable stripping for now
- riscv64 := actx.Arch().ArchType == android.Riscv64
- return !forceDisable && (forceEnable || defaultEnable) && !riscv64
+ return !forceDisable && (forceEnable || defaultEnable)
}
// Keep this consistent with //build/bazel/rules/stripped_shared_library.bzl.
diff --git a/cc/test.go b/cc/test.go
index 92055fa..536210b 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -678,7 +678,7 @@
}
}
- m.convertTidyAttributes(&testBinaryAttrs.tidyAttributes)
+ m.convertTidyAttributes(ctx, &testBinaryAttrs.tidyAttributes)
for _, propIntf := range m.GetProperties() {
if testLinkerProps, ok := propIntf.(*TestLinkerProperties); ok {
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 3fed1a1..028ca44 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -106,19 +106,7 @@
}
func newNameResolver(config android.Config) *android.NameResolver {
- namespacePathsToExport := make(map[string]bool)
-
- for _, namespaceName := range config.ExportedNamespaces() {
- namespacePathsToExport[namespaceName] = true
- }
-
- namespacePathsToExport["."] = true // always export the root namespace
-
- exportFilter := func(namespace *android.Namespace) bool {
- return namespacePathsToExport[namespace.Path]
- }
-
- return android.NewNameResolver(exportFilter)
+ return android.NewNameResolver(config)
}
func newContext(configuration android.Config) *android.Context {