Merge "Fix ravenizer when transitive classpath is enabled" into main
diff --git a/android/androidmk.go b/android/androidmk.go
index fb51531..6426835 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -920,6 +920,7 @@
case "*phony.PhonyRule": // writes phony deps and acts like `.PHONY`
case "*selinux.selinuxContextsModule": // license properties written
case "*sysprop.syspropLibrary": // license properties written
+ case "*vintf.vintfCompatibilityMatrixRule": // use case like phony
default:
if !ctx.Config().IsEnvFalse("ANDROID_REQUIRE_LICENSES") {
return fmt.Errorf("custom make rules not allowed for %q (%q) module %q", ctx.ModuleType(mod), reflect.TypeOf(mod), ctx.ModuleName(mod))
diff --git a/android/apex.go b/android/apex.go
index 29b2a9f..114fe29 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -88,6 +88,9 @@
// Returns the name of the overridden apex (com.android.foo)
BaseApexName string
+
+ // Returns the value of `apex_available_name`
+ ApexAvailableName string
}
// AllApexInfo holds the ApexInfo of all apexes that include this module.
diff --git a/android/arch_list.go b/android/arch_list.go
index f1289a3..2937092 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -159,6 +159,9 @@
"armv9-a": {
"dotprod",
},
+ "armv9-2a": {
+ "dotprod",
+ },
},
X86: {
"amberlake": {
diff --git a/android/config.go b/android/config.go
index b95d4e7..8f6d740 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1490,11 +1490,6 @@
}
}
if coverage && len(c.config.productVariables.NativeCoverageExcludePaths) > 0 {
- // Workaround coverage boot failure.
- // http://b/269981180
- if strings.HasPrefix(path, "external/protobuf") {
- coverage = false
- }
if HasAnyPrefix(path, c.config.productVariables.NativeCoverageExcludePaths) {
coverage = false
}
@@ -2068,3 +2063,19 @@
func (c *config) EnableUffdGc() string {
return String(c.productVariables.EnableUffdGc)
}
+
+func (c *config) DeviceFrameworkCompatibilityMatrixFile() []string {
+ return c.productVariables.DeviceFrameworkCompatibilityMatrixFile
+}
+
+func (c *config) DeviceProductCompatibilityMatrixFile() []string {
+ return c.productVariables.DeviceProductCompatibilityMatrixFile
+}
+
+func (c *config) BoardAvbEnable() bool {
+ return Bool(c.productVariables.BoardAvbEnable)
+}
+
+func (c *config) BoardAvbSystemAddHashtreeFooterArgs() []string {
+ return c.productVariables.BoardAvbSystemAddHashtreeFooterArgs
+}
diff --git a/android/defs.go b/android/defs.go
index 78cdea2..9f3fb1e 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -16,7 +16,6 @@
import (
"github.com/google/blueprint"
- "github.com/google/blueprint/bootstrap"
)
var (
@@ -120,8 +119,3 @@
return ctx.Config().RBEWrapper()
})
}
-
-// GlobToListFileRule creates a rule that writes a list of files matching a pattern to a file.
-func GlobToListFileRule(ctx ModuleContext, pattern string, excludes []string, file WritablePath) {
- bootstrap.GlobFile(ctx.blueprintModuleContext(), pattern, excludes, file.String())
-}
diff --git a/android/module.go b/android/module.go
index c50d1a3..009b0df 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1997,7 +1997,7 @@
TargetDependencies: targetRequired,
HostDependencies: hostRequired,
Data: data,
- Required: m.RequiredModuleNames(ctx),
+ Required: append(m.RequiredModuleNames(ctx), m.VintfFragmentModuleNames(ctx)...),
}
SetProvider(ctx, ModuleInfoJSONProvider, ctx.moduleInfoJSON)
}
diff --git a/android/variable.go b/android/variable.go
index 14f1756..9026f93 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -515,6 +515,11 @@
OdmPropFiles []string `json:",omitempty"`
EnableUffdGc *string `json:",omitempty"`
+
+ BoardAvbEnable *bool `json:",omitempty"`
+ BoardAvbSystemAddHashtreeFooterArgs []string `json:",omitempty"`
+ DeviceFrameworkCompatibilityMatrixFile []string `json:",omitempty"`
+ DeviceProductCompatibilityMatrixFile []string `json:",omitempty"`
}
type PartitionQualifiedVariablesType struct {
diff --git a/apex/apex.go b/apex/apex.go
index 6421c8e..1f4a99b 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1078,6 +1078,7 @@
ApexContents: []*android.ApexContents{apexContents},
TestApexes: testApexes,
BaseApexName: mctx.ModuleName(),
+ ApexAvailableName: proptools.String(a.properties.Apex_available_name),
}
mctx.WalkDeps(func(child, parent android.Module) bool {
if !continueApexDepsWalk(child, parent) {
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 7cad337..df7857f 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -835,6 +835,7 @@
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ "all_apex_contributions",
"art-bootclasspath-fragment",
"bar",
"dex2oatd",
@@ -1006,6 +1007,7 @@
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ "all_apex_contributions",
"android-non-updatable.stubs",
"android-non-updatable.stubs.module_lib",
"android-non-updatable.stubs.system",
@@ -1178,6 +1180,7 @@
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ "all_apex_contributions",
"android-non-updatable.stubs",
"android-non-updatable.stubs.system",
"android-non-updatable.stubs.test",
@@ -1331,6 +1334,7 @@
`)
java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ "all_apex_contributions",
"art-bootclasspath-fragment",
"bar",
"dex2oatd",
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index beb68e1..761afcf 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -41,11 +41,18 @@
"armv8-2a-dotprod": []string{
"-march=armv8.2-a+dotprod",
},
+ // On ARMv9 and later, Pointer Authentication Codes (PAC) are mandatory,
+ // so -fstack-protector is unnecessary.
"armv9-a": []string{
"-march=armv8.2-a+dotprod",
"-mbranch-protection=standard",
"-fno-stack-protector",
},
+ "armv9-2a": []string{
+ "-march=armv9.2-a",
+ "-mbranch-protection=standard",
+ "-fno-stack-protector",
+ },
}
arm64Ldflags = []string{
diff --git a/cc/library.go b/cc/library.go
index 65a923a..03f7174 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1264,14 +1264,6 @@
func (library *libraryDecorator) llndkIncludeDirsForAbiCheck(ctx ModuleContext, deps PathDeps) []string {
var includeDirs, systemIncludeDirs []string
- // The ABI checker does not need the preprocess which adds macro guards to function declarations.
- preprocessedDirs := android.PathsForModuleSrc(ctx, library.Properties.Llndk.Export_preprocessed_headers).Strings()
- if Bool(library.Properties.Llndk.Export_headers_as_system) {
- systemIncludeDirs = append(systemIncludeDirs, preprocessedDirs...)
- } else {
- includeDirs = append(includeDirs, preprocessedDirs...)
- }
-
if library.Properties.Llndk.Override_export_include_dirs != nil {
includeDirs = append(includeDirs, android.PathsForModuleSrc(
ctx, library.Properties.Llndk.Override_export_include_dirs).Strings()...)
@@ -1579,25 +1571,6 @@
}
}
-func processLLNDKHeaders(ctx ModuleContext, srcHeaderDir string, outDir android.ModuleGenPath) (timestamp android.Path, installPaths android.WritablePaths) {
- srcDir := android.PathForModuleSrc(ctx, srcHeaderDir)
- srcFiles := ctx.GlobFiles(filepath.Join(srcDir.String(), "**/*.h"), nil)
-
- for _, header := range srcFiles {
- headerDir := filepath.Dir(header.String())
- relHeaderDir, err := filepath.Rel(srcDir.String(), headerDir)
- if err != nil {
- ctx.ModuleErrorf("filepath.Rel(%q, %q) failed: %s",
- srcDir.String(), headerDir, err)
- continue
- }
-
- installPaths = append(installPaths, outDir.Join(ctx, relHeaderDir, header.Base()))
- }
-
- return processHeadersWithVersioner(ctx, srcDir, outDir, srcFiles, installPaths), installPaths
-}
-
// link registers actions to link this library, and sets various fields
// on this library to reflect information that should be exported up the build
// tree (for example, exported flags and include paths).
@@ -1605,26 +1578,6 @@
flags Flags, deps PathDeps, objs Objects) android.Path {
if ctx.IsLlndk() {
- if len(library.Properties.Llndk.Export_preprocessed_headers) > 0 {
- // This is the vendor variant of an LLNDK library with preprocessed headers.
- genHeaderOutDir := android.PathForModuleGen(ctx, "include")
-
- var timestampFiles android.Paths
- for _, dir := range library.Properties.Llndk.Export_preprocessed_headers {
- timestampFile, installPaths := processLLNDKHeaders(ctx, dir, genHeaderOutDir)
- timestampFiles = append(timestampFiles, timestampFile)
- library.addExportedGeneratedHeaders(installPaths.Paths()...)
- }
-
- if Bool(library.Properties.Llndk.Export_headers_as_system) {
- library.reexportSystemDirs(genHeaderOutDir)
- } else {
- library.reexportDirs(genHeaderOutDir)
- }
-
- library.reexportDeps(timestampFiles...)
- }
-
// override the module's export_include_dirs with llndk.override_export_include_dirs
// if it is set.
if override := library.Properties.Llndk.Override_export_include_dirs; override != nil {
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 5ece78a..c7950f9 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -36,10 +36,6 @@
// bionic/libc.
Export_headers_as_system *bool
- // Which headers to process with versioner. This really only handles
- // bionic/libc/include right now.
- Export_preprocessed_headers []string
-
// Whether the system library uses symbol versions.
Unversioned *bool
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index e002931..7481954 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -23,15 +23,6 @@
)
var (
- versionBionicHeaders = pctx.AndroidStaticRule("versionBionicHeaders",
- blueprint.RuleParams{
- // The `&& touch $out` isn't really necessary, but Blueprint won't
- // let us have only implicit outputs.
- Command: "$versionerCmd -o $outDir $srcDir $depsPath && touch $out",
- CommandDeps: []string{"$versionerCmd"},
- },
- "depsPath", "srcDir", "outDir")
-
preprocessNdkHeader = pctx.AndroidStaticRule("preprocessNdkHeader",
blueprint.RuleParams{
Command: "$preprocessor -o $out $in",
@@ -40,10 +31,6 @@
"preprocessor")
)
-func init() {
- pctx.SourcePathVariable("versionerCmd", "prebuilts/clang-tools/${config.HostPrebuiltTag}/bin/versioner")
-}
-
// Returns the NDK base include path for use with sdk_version current. Usable with -I.
func getCurrentIncludePath(ctx android.PathContext) android.OutputPath {
return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
@@ -167,126 +154,6 @@
return module
}
-type versionedHeaderProperties struct {
- // Base directory of the headers being installed. As an example:
- //
- // versioned_ndk_headers {
- // name: "foo",
- // from: "include",
- // to: "",
- // }
- //
- // Will install $SYSROOT/usr/include/foo/bar/baz.h. If `from` were instead
- // "include/foo", it would have installed $SYSROOT/usr/include/bar/baz.h.
- From *string
-
- // Install path within the sysroot. This is relative to usr/include.
- To *string
-
- // Path to the NOTICE file associated with the headers.
- License *string
-}
-
-// Like ndk_headers, but preprocesses the headers with the bionic versioner:
-// https://android.googlesource.com/platform/bionic/+/main/tools/versioner/README.md.
-//
-// Unlike ndk_headers, we don't operate on a list of sources but rather a whole directory, the
-// module does not have the srcs property, and operates on a full directory (the `from` property).
-//
-// Note that this is really only built to handle bionic/libc/include.
-type versionedHeaderModule struct {
- android.ModuleBase
-
- properties versionedHeaderProperties
-
- srcPaths android.Paths
- installPaths android.Paths
- licensePath android.Path
-}
-
-// Return the glob pattern to find all .h files beneath `dir`
-func headerGlobPattern(dir string) string {
- return filepath.Join(dir, "**", "*.h")
-}
-
-func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- if String(m.properties.License) == "" {
- ctx.PropertyErrorf("license", "field is required")
- }
-
- m.licensePath = android.PathForModuleSrc(ctx, String(m.properties.License))
-
- fromSrcPath := android.PathForModuleSrc(ctx, String(m.properties.From))
- toOutputPath := getCurrentIncludePath(ctx).Join(ctx, String(m.properties.To))
- m.srcPaths = ctx.GlobFiles(headerGlobPattern(fromSrcPath.String()), nil)
- var installPaths []android.WritablePath
- for _, header := range m.srcPaths {
- installDir := getHeaderInstallDir(ctx, header, String(m.properties.From), String(m.properties.To))
- installPath := installDir.Join(ctx, header.Base())
- installPaths = append(installPaths, installPath)
- m.installPaths = append(m.installPaths, installPath)
- }
-
- if len(m.installPaths) == 0 {
- ctx.ModuleErrorf("glob %q matched zero files", String(m.properties.From))
- }
-
- processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, m.srcPaths, installPaths)
-}
-
-func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path,
- srcPaths android.Paths, installPaths []android.WritablePath) android.Path {
- // The versioner depends on a dependencies directory to simplify determining include paths
- // when parsing headers. This directory contains architecture specific directories as well
- // as a common directory, each of which contains symlinks to the actually directories to
- // be included.
- //
- // ctx.Glob doesn't follow symlinks, so we need to do this ourselves so we correctly
- // depend on these headers.
- // TODO(http://b/35673191): Update the versioner to use a --sysroot.
- depsPath := android.PathForSource(ctx, "bionic/libc/versioner-dependencies")
- depsGlob := ctx.Glob(filepath.Join(depsPath.String(), "**/*"), nil)
- for i, path := range depsGlob {
- if ctx.IsSymlink(path) {
- dest := ctx.Readlink(path)
- // Additional .. to account for the symlink itself.
- depsGlob[i] = android.PathForSource(
- ctx, filepath.Clean(filepath.Join(path.String(), "..", dest)))
- }
- }
-
- timestampFile := android.PathForModuleOut(ctx, "versioner.timestamp")
- ctx.Build(pctx, android.BuildParams{
- Rule: versionBionicHeaders,
- Description: "versioner preprocess " + srcDir.Rel(),
- Output: timestampFile,
- Implicits: append(srcPaths, depsGlob...),
- ImplicitOutputs: installPaths,
- Args: map[string]string{
- "depsPath": depsPath.String(),
- "srcDir": srcDir.String(),
- "outDir": outDir.String(),
- },
- })
-
- return timestampFile
-}
-
-// versioned_ndk_headers preprocesses the headers with the bionic versioner:
-// https://android.googlesource.com/platform/bionic/+/main/tools/versioner/README.md.
-// Unlike the ndk_headers soong module, versioned_ndk_headers operates on a
-// directory level specified in `from` property. This is only used to process
-// the bionic/libc/include directory.
-func VersionedNdkHeadersFactory() android.Module {
- module := &versionedHeaderModule{}
-
- module.AddProperties(&module.properties)
-
- android.InitAndroidModule(module)
-
- return module
-}
-
// preprocessed_ndk_header {
//
// name: "foo",
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index f571523..92da172 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -79,7 +79,6 @@
func RegisterNdkModuleTypes(ctx android.RegistrationContext) {
ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory)
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
- ctx.RegisterModuleType("versioned_ndk_headers", VersionedNdkHeadersFactory)
ctx.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
}
@@ -230,17 +229,6 @@
licensePaths = append(licensePaths, m.licensePath)
}
- if m, ok := module.(*versionedHeaderModule); ok {
- headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
- headerInstallPaths = append(headerInstallPaths, m.installPaths...)
- // Verification intentionally not done for headers that go through
- // versioner. It'd be nice to have, but the only user is bionic, and
- // that one module would also need to use skip_verification, so it
- // wouldn't help at all.
- installPaths = append(installPaths, m.installPaths...)
- licensePaths = append(licensePaths, m.licensePath)
- }
-
if m, ok := module.(*preprocessedHeadersModule); ok {
headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
headerInstallPaths = append(headerInstallPaths, m.installPaths...)
diff --git a/java/aar.go b/java/aar.go
index bffe88b..b5e24c4 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -15,10 +15,10 @@
package java
import (
+ "crypto/sha256"
"fmt"
"path/filepath"
"slices"
- "strconv"
"strings"
"android/soong/android"
@@ -236,18 +236,20 @@
rroDirs = append(rroDirs, resRRODirs...)
}
+ assetDirsHasher := sha256.New()
var assetDeps android.Paths
- for i, dir := range assetDirs {
+ for _, dir := range assetDirs {
// Add a dependency on every file in the asset directory. This ensures the aapt2
// rule will be rerun if one of the files in the asset directory is modified.
- assetDeps = append(assetDeps, androidResourceGlob(ctx, dir)...)
+ dirContents := androidResourceGlob(ctx, dir)
+ assetDeps = append(assetDeps, dirContents...)
- // Add a dependency on a file that contains a list of all the files in the asset directory.
+ // Add a hash of all the files in the asset directory to the command line.
// This ensures the aapt2 rule will be run if a file is removed from the asset directory,
// or a file is added whose timestamp is older than the output of aapt2.
- assetFileListFile := android.PathForModuleOut(ctx, "asset_dir_globs", strconv.Itoa(i)+".glob")
- androidResourceGlobList(ctx, dir, assetFileListFile)
- assetDeps = append(assetDeps, assetFileListFile)
+ for _, path := range dirContents.Strings() {
+ assetDirsHasher.Write([]byte(path))
+ }
}
assetDirStrings := assetDirs.Strings()
@@ -282,6 +284,7 @@
linkDeps = append(linkDeps, manifestPath)
linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A "))
+ linkFlags = append(linkFlags, fmt.Sprintf("$$(: %x)", assetDirsHasher.Sum(nil)))
linkDeps = append(linkDeps, assetDeps...)
// Returns the effective version for {min|target}_sdk_version
@@ -970,7 +973,7 @@
// Defaults to sdk_version if not set. See sdk_version for possible values.
Min_sdk_version *string
// List of java static libraries that the included ARR (android library prebuilts) has dependencies to.
- Static_libs []string
+ Static_libs proptools.Configurable[[]string]
// List of java libraries that the included ARR (android library prebuilts) has dependencies to.
Libs []string
// If set to true, run Jetifier against .aar file. Defaults to false.
@@ -1100,7 +1103,7 @@
}
ctx.AddVariationDependencies(nil, libTag, a.properties.Libs...)
- ctx.AddVariationDependencies(nil, staticLibTag, a.properties.Static_libs...)
+ ctx.AddVariationDependencies(nil, staticLibTag, a.properties.Static_libs.GetOrDefault(ctx, nil)...)
a.usesLibrary.deps(ctx, false)
}
diff --git a/java/android_resources.go b/java/android_resources.go
index 038a260..3bb3eb5 100644
--- a/java/android_resources.go
+++ b/java/android_resources.go
@@ -39,15 +39,6 @@
return ctx.GlobFiles(filepath.Join(dir.String(), "**/*"), androidResourceIgnoreFilenames)
}
-// androidResourceGlobList creates a rule to write the list of files in the given directory, using
-// the standard exclusion patterns for Android resources, to the given output file.
-func androidResourceGlobList(ctx android.ModuleContext, dir android.Path,
- fileListFile android.WritablePath) {
-
- android.GlobToListFileRule(ctx, filepath.Join(dir.String(), "**/*"),
- androidResourceIgnoreFilenames, fileListFile)
-}
-
type overlayType int
const (
diff --git a/java/base.go b/java/base.go
index 71be239..6cc0066 100644
--- a/java/base.go
+++ b/java/base.go
@@ -81,7 +81,7 @@
Libs []string `android:"arch_variant"`
// list of java libraries that will be compiled into the resulting jar
- Static_libs []string `android:"arch_variant"`
+ Static_libs proptools.Configurable[[]string] `android:"arch_variant"`
// list of java libraries that should not be used to build this module
Exclude_static_libs []string `android:"arch_variant"`
@@ -831,6 +831,10 @@
return j.ApexModuleBase.AvailableFor(what)
}
+func (j *Module) staticLibs(ctx android.BaseModuleContext) []string {
+ return android.RemoveListFromList(j.properties.Static_libs.GetOrDefault(ctx, nil), j.properties.Exclude_static_libs)
+}
+
func (j *Module) deps(ctx android.BottomUpMutatorContext) {
if ctx.Device() {
j.linter.deps(ctx)
@@ -847,8 +851,7 @@
libDeps := ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
- j.properties.Static_libs = android.RemoveListFromList(j.properties.Static_libs, j.properties.Exclude_static_libs)
- ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
+ ctx.AddVariationDependencies(nil, staticLibTag, j.staticLibs(ctx)...)
// Add dependency on libraries that provide additional hidden api annotations.
ctx.AddVariationDependencies(nil, hiddenApiAnnotationsTag, j.properties.Hiddenapi_additional_annotations...)
@@ -930,7 +933,7 @@
ctx.AddVariationDependencies(nil, staticLibTag, "jacocoagent")
}
- if j.useCompose() {
+ if j.useCompose(ctx) {
ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), kotlinPluginTag,
"androidx.compose.compiler_compiler-hosted")
}
@@ -1941,8 +1944,8 @@
j.outputFile = outputFile.WithoutRel()
}
-func (j *Module) useCompose() bool {
- return android.InList("androidx.compose.runtime_runtime", j.properties.Static_libs)
+func (j *Module) useCompose(ctx android.BaseModuleContext) bool {
+ return android.InList("androidx.compose.runtime_runtime", j.staticLibs(ctx))
}
func collectDepProguardSpecInfo(ctx android.ModuleContext) (transitiveProguardFlags, transitiveUnconditionalExportedFlags []*android.DepSet[android.Path]) {
@@ -2202,7 +2205,7 @@
}
dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...)
dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...)
- dpInfo.Static_libs = append(dpInfo.Static_libs, j.properties.Static_libs...)
+ dpInfo.Static_libs = append(dpInfo.Static_libs, j.staticLibs(ctx)...)
dpInfo.Libs = append(dpInfo.Libs, j.properties.Libs...)
}
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index bef3b58..fe4cc76 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -463,6 +463,12 @@
// Add a dependency onto the dex2oat tool which is needed for creating the boot image. The
// path is retrieved from the dependency by GetGlobalSoongConfig(ctx).
dexpreopt.RegisterToolDeps(ctx)
+
+ // Add a dependency to `all_apex_contributions` to determine if prebuilts are active.
+ // If prebuilts are active, `contents` validation on the source bootclasspath fragment should be disabled.
+ if _, isPrebuiltModule := ctx.Module().(*PrebuiltBootclasspathFragmentModule); !isPrebuiltModule {
+ ctx.AddDependency(b, android.AcDepTag, "all_apex_contributions")
+ }
}
func (b *BootclasspathFragmentModule) BootclasspathDepsMutator(ctx android.BottomUpMutatorContext) {
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 1c63e3f..4734357 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -209,13 +209,18 @@
psi = prebuiltSelectionInfo
}
})
+
// Find the apex variant for this module
- var apexVariantsWithoutTestApexes []string
+ apexVariantsWithoutTestApexes := []string{}
if apexInfo.BaseApexName != "" {
// This is a transitive dependency of an override_apex
- apexVariantsWithoutTestApexes = []string{apexInfo.BaseApexName}
+ apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.BaseApexName)
} else {
- _, apexVariantsWithoutTestApexes, _ = android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes)
+ _, variants, _ := android.ListSetDifference(apexInfo.InApexVariants, apexInfo.TestApexes)
+ apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, variants...)
+ }
+ if apexInfo.ApexAvailableName != "" {
+ apexVariantsWithoutTestApexes = append(apexVariantsWithoutTestApexes, apexInfo.ApexAvailableName)
}
disableSource := false
// find the selected apexes
diff --git a/java/droiddoc.go b/java/droiddoc.go
index f81c5ba..2929bb8 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -54,7 +54,7 @@
Filter_packages []string
// list of java libraries that will be in the classpath.
- Libs []string `android:"arch_variant"`
+ Libs proptools.Configurable[[]string] `android:"arch_variant"`
// If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true.
Installable *bool
@@ -274,7 +274,7 @@
}
}
- ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
+ ctx.AddVariationDependencies(nil, libTag, j.properties.Libs.GetOrDefault(ctx, nil)...)
}
func (j *Javadoc) collectAidlFlags(ctx android.ModuleContext, deps deps) droiddocBuilderFlags {
diff --git a/java/generated_java_library.go b/java/generated_java_library.go
index d5e6d8f..79f1b6f 100644
--- a/java/generated_java_library.go
+++ b/java/generated_java_library.go
@@ -70,14 +70,6 @@
module.Library.properties.Libs = append(module.Library.properties.Libs, name)
}
-// Add a java shared library as a dependency, as if they had said `libs: [ "name" ]`
-func (module *GeneratedJavaLibraryModule) AddStaticLibrary(name string) {
- if module.depsMutatorDone {
- panic("GeneratedJavaLibraryModule.AddStaticLibrary called after DepsMutator")
- }
- module.Library.properties.Static_libs = append(module.Library.properties.Static_libs, name)
-}
-
func (module *GeneratedJavaLibraryModule) DepsMutator(ctx android.BottomUpMutatorContext) {
module.callbacks.DepsMutator(module, ctx)
module.depsMutatorDone = true
diff --git a/java/java.go b/java/java.go
index 797a90d..95f4fd8 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2011,11 +2011,11 @@
// List of shared java libs that this module has dependencies to and
// should be passed as classpath in javac invocation
- Libs []string
+ Libs proptools.Configurable[[]string]
// List of java libs that this module has static dependencies to and will be
// merge zipped after metalava invocation
- Static_libs []string
+ Static_libs proptools.Configurable[[]string]
// Version of previously released API file for compatibility check.
Previous_api *string `android:"path"`
@@ -2191,8 +2191,8 @@
}
}
- ctx.AddVariationDependencies(nil, libTag, al.properties.Libs...)
- ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs...)
+ ctx.AddVariationDependencies(nil, libTag, al.properties.Libs.GetOrDefault(ctx, nil)...)
+ ctx.AddVariationDependencies(nil, staticLibTag, al.properties.Static_libs.GetOrDefault(ctx, nil)...)
for _, aconfigDeclarationsName := range al.properties.Aconfig_declarations {
ctx.AddDependency(ctx.Module(), aconfigDeclarationTag, aconfigDeclarationsName)
@@ -2426,16 +2426,16 @@
func (al *ApiLibrary) IDEInfo(ctx android.BaseModuleContext, i *android.IdeInfo) {
i.Deps = append(i.Deps, al.ideDeps(ctx)...)
- i.Libs = append(i.Libs, al.properties.Libs...)
- i.Static_libs = append(i.Static_libs, al.properties.Static_libs...)
+ i.Libs = append(i.Libs, al.properties.Libs.GetOrDefault(ctx, nil)...)
+ i.Static_libs = append(i.Static_libs, al.properties.Static_libs.GetOrDefault(ctx, nil)...)
i.SrcJars = append(i.SrcJars, al.stubsSrcJar.String())
}
// deps of java_api_library for module_bp_java_deps.json
func (al *ApiLibrary) ideDeps(ctx android.BaseModuleContext) []string {
ret := []string{}
- ret = append(ret, al.properties.Libs...)
- ret = append(ret, al.properties.Static_libs...)
+ ret = append(ret, al.properties.Libs.GetOrDefault(ctx, nil)...)
+ ret = append(ret, al.properties.Static_libs.GetOrDefault(ctx, nil)...)
if al.properties.System_modules != nil {
ret = append(ret, proptools.String(al.properties.System_modules))
}
@@ -2479,7 +2479,7 @@
Libs []string
// List of static java libs that this module has dependencies to
- Static_libs []string
+ Static_libs proptools.Configurable[[]string]
// List of files to remove from the jar file(s)
Exclude_files []string
@@ -2620,7 +2620,7 @@
func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...)
- ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...)
+ ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs.GetOrDefault(ctx, nil)...)
if ctx.Device() && Bool(j.dexProperties.Compile_dex) {
sdkDeps(ctx, android.SdkContext(j), j.dexer)
diff --git a/java/rro.go b/java/rro.go
index 0fc6e1c..8bb9be2 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -17,7 +17,11 @@
// This file contains the module implementations for runtime_resource_overlay and
// override_runtime_resource_overlay.
-import "android/soong/android"
+import (
+ "android/soong/android"
+
+ "github.com/google/blueprint/proptools"
+)
func init() {
RegisterRuntimeResourceOverlayBuildComponents(android.InitRegistrationContext)
@@ -71,7 +75,7 @@
Min_sdk_version *string
// list of android_library modules whose resources are extracted and linked against statically
- Static_libs []string
+ Static_libs proptools.Configurable[[]string]
// list of android_app modules whose resources are extracted and linked against
Resource_libs []string
@@ -120,7 +124,7 @@
ctx.AddDependency(ctx.Module(), certificateTag, cert)
}
- ctx.AddVariationDependencies(nil, staticLibTag, r.properties.Static_libs...)
+ ctx.AddVariationDependencies(nil, staticLibTag, r.properties.Static_libs.GetOrDefault(ctx, nil)...)
ctx.AddVariationDependencies(nil, libTag, r.properties.Resource_libs...)
for _, aconfig_declaration := range r.aaptProperties.Flags_packages {
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 98b65dd..b7aa4e5 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1744,11 +1744,13 @@
func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) {
visibility := childModuleVisibility(module.sdkLibraryProperties.Impl_library_visibility)
+ staticLibs := module.properties.Static_libs.Clone()
+ staticLibs.AppendSimpleValue(module.sdkLibraryProperties.Impl_only_static_libs)
props := struct {
Name *string
Visibility []string
Libs []string
- Static_libs []string
+ Static_libs proptools.Configurable[[]string]
Apex_available []string
Stem *string
}{
@@ -1757,7 +1759,7 @@
Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...),
- Static_libs: append(module.properties.Static_libs, module.sdkLibraryProperties.Impl_only_static_libs...),
+ Static_libs: staticLibs,
// Pass the apex_available settings down so that the impl library can be statically
// embedded within a library that is added to an APEX. Needed for updatable-media.
Apex_available: module.ApexAvailable(),
@@ -1863,7 +1865,7 @@
Sdk_version *string
Api_surface *string
System_modules *string
- Libs []string
+ Libs proptools.Configurable[[]string]
Output_javadoc_comments *bool
Arg_files []string
Args *string
@@ -1907,10 +1909,11 @@
props.Installable = proptools.BoolPtr(false)
// A droiddoc module has only one Libs property and doesn't distinguish between
// shared libs and static libs. So we need to add both of these libs to Libs property.
- props.Libs = module.properties.Libs
- props.Libs = append(props.Libs, module.properties.Static_libs...)
- props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
- props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
+ props.Libs = proptools.NewConfigurable[[]string](nil, nil)
+ props.Libs.AppendSimpleValue(module.properties.Libs)
+ props.Libs.Append(module.properties.Static_libs)
+ props.Libs.AppendSimpleValue(module.sdkLibraryProperties.Stub_only_libs)
+ props.Libs.AppendSimpleValue(module.scopeToProperties[apiScope].Libs)
props.Aidl.Include_dirs = module.deviceProperties.Aidl.Include_dirs
props.Aidl.Local_include_dirs = module.deviceProperties.Aidl.Local_include_dirs
props.Java_version = module.properties.Java_version
@@ -2024,7 +2027,7 @@
Name *string
Visibility []string
Api_contributions []string
- Libs []string
+ Libs proptools.Configurable[[]string]
Static_libs []string
System_modules *string
Enable_validation *bool
@@ -2056,11 +2059,12 @@
props.Api_contributions = apiContributions
// Ensure that stub-annotations is added to the classpath before any other libs
- props.Libs = []string{"stub-annotations"}
- props.Libs = append(props.Libs, module.properties.Libs...)
- props.Libs = append(props.Libs, module.properties.Static_libs...)
- props.Libs = append(props.Libs, module.sdkLibraryProperties.Stub_only_libs...)
- props.Libs = append(props.Libs, module.scopeToProperties[apiScope].Libs...)
+ props.Libs = proptools.NewConfigurable[[]string](nil, nil)
+ props.Libs.AppendSimpleValue([]string{"stub-annotations"})
+ props.Libs.AppendSimpleValue(module.properties.Libs)
+ props.Libs.Append(module.properties.Static_libs)
+ props.Libs.AppendSimpleValue(module.sdkLibraryProperties.Stub_only_libs)
+ props.Libs.AppendSimpleValue(module.scopeToProperties[apiScope].Libs)
props.Static_libs = module.sdkLibraryProperties.Stub_only_static_libs
props.System_modules = module.deviceProperties.System_modules
@@ -2370,7 +2374,7 @@
// Add the impl_only_libs and impl_only_static_libs *after* we're done using them in submodules.
module.properties.Libs = append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...)
- module.properties.Static_libs = append(module.properties.Static_libs, module.sdkLibraryProperties.Impl_only_static_libs...)
+ module.properties.Static_libs.AppendSimpleValue(module.sdkLibraryProperties.Impl_only_static_libs)
}
func (module *SdkLibrary) InitSdkLibraryProperties() {
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 12d5877..bb63315 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -1528,7 +1528,8 @@
// The foo.stubs.source should depend on bar-lib
fooStubsSources := result.ModuleForTests("foo.stubs.source", "android_common").Module().(*Droidstubs)
- android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
+ eval := fooStubsSources.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs.GetOrDefault(eval, nil), "bar-lib")
}
func TestJavaSdkLibrary_Scope_Libs_PassedToDroidstubs(t *testing.T) {
@@ -1554,7 +1555,8 @@
// The foo.stubs.source should depend on bar-lib
fooStubsSources := result.ModuleForTests("foo.stubs.source", "android_common").Module().(*Droidstubs)
- android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs, "bar-lib")
+ eval := fooStubsSources.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringListContains(t, "foo stubs should depend on bar-lib", fooStubsSources.Javadoc.properties.Libs.GetOrDefault(eval, nil), "bar-lib")
}
func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
@@ -1705,18 +1707,15 @@
exportableSourceStubsLibraryModuleName := apiScopePublic.exportableSourceStubsLibraryModuleName("foo")
// Check modules generation
- topLevelModule := result.ModuleForTests(exportableStubsLibraryModuleName, "android_common")
+ result.ModuleForTests(exportableStubsLibraryModuleName, "android_common")
result.ModuleForTests(exportableSourceStubsLibraryModuleName, "android_common")
// Check static lib dependency
android.AssertBoolEquals(t, "exportable top level stubs library module depends on the"+
"exportable source stubs library module", true,
- CheckModuleHasDependency(t, result.TestContext, exportableStubsLibraryModuleName,
- "android_common", exportableSourceStubsLibraryModuleName),
+ CheckModuleHasDependencyWithTag(t, result.TestContext, exportableStubsLibraryModuleName,
+ "android_common", staticLibTag, exportableSourceStubsLibraryModuleName),
)
- android.AssertArrayString(t, "exportable source stub library is a static lib of the"+
- "top level exportable stubs library", []string{exportableSourceStubsLibraryModuleName},
- topLevelModule.Module().(*Library).properties.Static_libs)
}
// For java libraries depending on java_sdk_library(_import) via libs, assert that
diff --git a/java/testing.go b/java/testing.go
index e31e0d2..0c79e9f 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -633,6 +633,18 @@
return false
}
+// CheckModuleHasDependency returns true if the module depends on the expected dependency.
+func CheckModuleHasDependencyWithTag(t *testing.T, ctx *android.TestContext, name, variant string, desiredTag blueprint.DependencyTag, expected string) bool {
+ module := ctx.ModuleForTests(name, variant).Module()
+ found := false
+ ctx.VisitDirectDepsWithTags(module, func(m blueprint.Module, tag blueprint.DependencyTag) {
+ if tag == desiredTag && m.Name() == expected {
+ found = true
+ }
+ })
+ return found
+}
+
// CheckPlatformBootclasspathModules returns the apex:module pair for the modules depended upon by
// the platform-bootclasspath module.
func CheckPlatformBootclasspathModules(t *testing.T, result *android.TestResult, name string, expected []string) {
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 057b370..416dce6 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -131,11 +131,7 @@
java_import {
name: "myjavalib",
prefer: false,
- visibility: [
- "//other/foo",
- "//package",
- "//prebuilts/mysdk",
- ],
+ visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myjavalib.jar"],
}
@@ -151,11 +147,7 @@
java_import {
name: "mydefaultedjavalib",
prefer: false,
- visibility: [
- "//other/bar",
- "//package",
- "//prebuilts/mysdk",
- ],
+ visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/mydefaultedjavalib.jar"],
}
@@ -163,10 +155,7 @@
java_import {
name: "myprivatejavalib",
prefer: false,
- visibility: [
- "//package",
- "//prebuilts/mysdk",
- ],
+ visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
jars: ["java/myprivatejavalib.jar"],
}
@@ -185,28 +174,6 @@
`)
}
-func TestPrebuiltVisibilityProperty_AddPrivate(t *testing.T) {
- testSdkError(t, `prebuilt_visibility: "//visibility:private" does not widen the visibility`, `
- sdk {
- name: "mysdk",
- prebuilt_visibility: [
- "//visibility:private",
- ],
- java_header_libs: [
- "myjavalib",
- ],
- }
-
- java_library {
- name: "myjavalib",
- // Uses package default visibility
- srcs: ["Test.java"],
- system_modules: "none",
- sdk_version: "none",
- }
-`)
-}
-
func TestSdkInstall(t *testing.T) {
sdk := `
sdk {
diff --git a/sdk/update.go b/sdk/update.go
index e1b363a..9379f36 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -1109,20 +1109,22 @@
// same package so can be marked as private.
m.AddProperty("visibility", []string{"//visibility:private"})
} else {
- // Extract visibility information from a member variant. All variants have the same
- // visibility so it doesn't matter which one is used.
- visibilityRules := android.EffectiveVisibilityRules(s.ctx, variant)
-
- // Add any additional visibility rules needed for the prebuilts to reference each other.
- err := visibilityRules.Widen(s.sdk.properties.Prebuilt_visibility)
- if err != nil {
- s.ctx.PropertyErrorf("prebuilt_visibility", "%s", err)
- }
-
- visibility := visibilityRules.Strings()
- if len(visibility) != 0 {
- m.AddProperty("visibility", visibility)
- }
+ // Change the visibility of the module SDK prebuilts to public.
+ // This includes
+ // 1. Stub libraries of `sdk` modules
+ // 2. Binaries and libraries of `module_exports` modules
+ //
+ // This is a workaround to improve maintainlibility of the module SDK.
+ // Since module sdks are generated from release branches and dropped to development
+ // branches, there might be a visibility skew between the sources and prebuilts
+ // of a specific module.
+ // To reconcile this potential skew, change the visibility to public
+ //
+ // This is safe for (1) since these are stub libraries.
+ // This is ok for (2) since these are host and test exports and are intended for
+ // ART development.
+ // TODO (b/361303067): This can be removed if ART uses full manifests.
+ m.AddProperty("visibility", []string{"//visibility:public"})
}
// Where available copy apex_available properties from the member.
diff --git a/ui/build/config.go b/ui/build/config.go
index 6432348..08e1957 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -41,6 +41,7 @@
const (
envConfigDir = "vendor/google/tools/soong_config"
jsonSuffix = "json"
+ abfsSrcDir = "/src"
)
var (
@@ -214,6 +215,10 @@
sandboxConfig: &SandboxConfig{},
ninjaWeightListSource: DEFAULT,
}
+ wd, err := os.Getwd()
+ if err != nil {
+ ctx.Fatalln("Failed to get working directory:", err)
+ }
// Skip soong tests by default on Linux
if runtime.GOOS == "linux" {
@@ -245,17 +250,13 @@
// Make sure OUT_DIR is set appropriately
if outDir, ok := ret.environ.Get("OUT_DIR"); ok {
- ret.environ.Set("OUT_DIR", filepath.Clean(outDir))
+ ret.environ.Set("OUT_DIR", ret.sandboxPath(wd, filepath.Clean(outDir)))
} else {
outDir := "out"
if baseDir, ok := ret.environ.Get("OUT_DIR_COMMON_BASE"); ok {
- if wd, err := os.Getwd(); err != nil {
- ctx.Fatalln("Failed to get working directory:", err)
- } else {
- outDir = filepath.Join(baseDir, filepath.Base(wd))
- }
+ outDir = filepath.Join(baseDir, filepath.Base(wd))
}
- ret.environ.Set("OUT_DIR", outDir)
+ ret.environ.Set("OUT_DIR", ret.sandboxPath(wd, outDir))
}
// loadEnvConfig needs to know what the OUT_DIR is, so it should
@@ -361,12 +362,12 @@
ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1")
tmpDir := absPath(ctx, ret.TempDir())
- ret.environ.Set("TMPDIR", tmpDir)
+ ret.environ.Set("TMPDIR", ret.sandboxPath(wd, tmpDir))
// Always set ASAN_SYMBOLIZER_PATH so that ASAN-based tools can symbolize any crashes
symbolizerPath := filepath.Join("prebuilts/clang/host", ret.HostPrebuiltTag(),
"llvm-binutils-stable/llvm-symbolizer")
- ret.environ.Set("ASAN_SYMBOLIZER_PATH", absPath(ctx, symbolizerPath))
+ ret.environ.Set("ASAN_SYMBOLIZER_PATH", ret.sandboxPath(wd, absPath(ctx, symbolizerPath)))
// Precondition: the current directory is the top of the source tree
checkTopDir(ctx)
@@ -426,9 +427,9 @@
}
ret.environ.Unset("OVERRIDE_ANDROID_JAVA_HOME")
- ret.environ.Set("JAVA_HOME", absJavaHome)
- ret.environ.Set("ANDROID_JAVA_HOME", javaHome)
- ret.environ.Set("ANDROID_JAVA8_HOME", java8Home)
+ ret.environ.Set("JAVA_HOME", ret.sandboxPath(wd, absJavaHome))
+ ret.environ.Set("ANDROID_JAVA_HOME", ret.sandboxPath(wd, javaHome))
+ ret.environ.Set("ANDROID_JAVA8_HOME", ret.sandboxPath(wd, java8Home))
ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
// b/286885495, https://bugzilla.redhat.com/show_bug.cgi?id=2227130: some versions of Fedora include patches
@@ -444,7 +445,7 @@
ret.buildDateTime = strconv.FormatInt(time.Now().Unix(), 10)
}
- ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
+ ret.environ.Set("BUILD_DATETIME_FILE", ret.sandboxPath(wd, buildDateTimeFile))
if _, ok := ret.environ.Get("BUILD_USERNAME"); !ok {
username := "unknown"
@@ -455,6 +456,7 @@
}
ret.environ.Set("BUILD_USERNAME", username)
}
+ ret.environ.Set("PWD", ret.sandboxPath(wd, wd))
if ret.UseRBE() {
for k, v := range getRBEVars(ctx, Config{ret}) {
@@ -1296,6 +1298,19 @@
return err == nil
}
+func (c *configImpl) sandboxPath(base, in string) string {
+ if !c.UseABFS() {
+ return in
+ }
+
+ rel, err := filepath.Rel(base, in)
+ if err != nil {
+ return in
+ }
+
+ return filepath.Join(abfsSrcDir, rel)
+}
+
func (c *configImpl) UseRBE() bool {
// These alternate modes of running Soong do not use RBE / reclient.
if c.Queryview() || c.JsonModuleGraph() {
@@ -1722,6 +1737,11 @@
}
func (c *configImpl) SkipMetricsUpload() bool {
+ // b/362625275 - Metrics upload sometimes prevents abfs unmount
+ if c.UseABFS() {
+ return true
+ }
+
return c.skipMetricsUpload
}
diff --git a/ui/build/path.go b/ui/build/path.go
index 51ebff1..075bf2e 100644
--- a/ui/build/path.go
+++ b/ui/build/path.go
@@ -57,6 +57,22 @@
return ret
}
+func updatePathForSandbox(config Config) {
+ wd, err := os.Getwd()
+ if err != nil {
+ return
+ }
+
+ var newPath []string
+ if path, ok := config.Environment().Get("PATH"); ok && path != "" {
+ entries := strings.Split(path, string(filepath.ListSeparator))
+ for _, ent := range entries {
+ newPath = append(newPath, config.sandboxPath(wd, ent))
+ }
+ }
+ config.Environment().Set("PATH", strings.Join(newPath, string(filepath.ListSeparator)))
+}
+
// SetupLitePath is the "lite" version of SetupPath used for dumpvars, or other
// places that does not need the full logging capabilities of path_interposer,
// wants the minimal performance overhead, and still get the benefits of $PATH
@@ -121,6 +137,7 @@
// Set $PATH to be the directories containing the host tool symlinks, and
// the prebuilts directory for the current host OS.
config.Environment().Set("PATH", myPath)
+ updatePathForSandbox(config)
config.pathReplaced = true
}
@@ -265,5 +282,6 @@
// Replace the $PATH variable with the path_interposer symlinks, and
// checked-in prebuilts.
config.Environment().Set("PATH", myPath)
+ updatePathForSandbox(config)
config.pathReplaced = true
}
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index d9ca854..95b71a7 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -50,7 +50,6 @@
const (
nsjailPath = "prebuilts/build-tools/linux-x86/bin/nsjail"
- abfsSrcDir = "/src"
)
var sandboxConfig struct {
@@ -148,20 +147,42 @@
return sandboxConfig.working
}
-func (c *Cmd) srcDirArg() string {
- if !c.config.UseABFS() {
- return sandboxConfig.srcDir
+// Assumes input path is absolute, clean, and if applicable, an evaluated
+// symlink. If path is not a subdirectory of src dir or relative path
+// cannot be determined, return the input untouched.
+func (c *Cmd) relFromSrcDir(path string) string {
+ if !strings.HasPrefix(path, sandboxConfig.srcDir) {
+ return path
}
- return sandboxConfig.srcDir + ":" + abfsSrcDir
+ rel, err := filepath.Rel(sandboxConfig.srcDir, path)
+ if err != nil {
+ return path
+ }
+
+ return rel
+}
+
+func (c *Cmd) dirArg(path string) string {
+ if !c.config.UseABFS() {
+ return path
+ }
+
+ rel := c.relFromSrcDir(path)
+
+ return path + ":" + filepath.Join(abfsSrcDir, rel)
+}
+
+func (c *Cmd) srcDirArg() string {
+ return c.dirArg(sandboxConfig.srcDir)
}
func (c *Cmd) outDirArg() string {
- if !c.config.UseABFS() {
- return sandboxConfig.outDir
- }
+ return c.dirArg(sandboxConfig.outDir)
+}
- return sandboxConfig.outDir + ":" + filepath.Join(abfsSrcDir, sandboxConfig.outDir)
+func (c *Cmd) distDirArg() string {
+ return c.dirArg(sandboxConfig.distDir)
}
// When configured to use ABFS, we need to allow the creation of the /src
@@ -187,8 +208,17 @@
return args
}
+func (c *Cmd) workDir() string {
+ if !c.config.UseABFS() {
+ wd, _ := os.Getwd()
+ return wd
+ }
+
+ return abfsSrcDir
+}
+
func (c *Cmd) wrapSandbox() {
- wd, _ := os.Getwd()
+ wd := c.workDir()
var sandboxArgs []string
sandboxArgs = append(sandboxArgs,
@@ -226,7 +256,7 @@
)
sandboxArgs = append(sandboxArgs,
- c.readMountArgs()...
+ c.readMountArgs()...,
)
sandboxArgs = append(sandboxArgs,
@@ -264,7 +294,7 @@
if _, err := os.Stat(sandboxConfig.distDir); !os.IsNotExist(err) {
//Mount dist dir as read-write if it already exists
- sandboxArgs = append(sandboxArgs, "-B", sandboxConfig.distDir)
+ sandboxArgs = append(sandboxArgs, "-B", c.distDirArg())
}
if c.Sandbox.AllowBuildBrokenUsesNetwork && c.config.BuildBrokenUsesNetwork() {
diff --git a/ui/build/soong.go b/ui/build/soong.go
index a9c2cc7..b94ffa5 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -244,7 +244,6 @@
globfiles := bootstrap.GlobFileListFiles(bootstrap.GlobDirectory(config.SoongOutDir(), globPathName))
return bootstrap.PrimaryBuilderInvocation{
- Inputs: []string{"Android.bp"},
Implicits: globfiles,
Outputs: []string{pb.output},
Args: allArgs,