Merge "Collect paths to transitive SDK Java library dependencies."
diff --git a/android/apex.go b/android/apex.go
index 8c06b63..100beb0 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -29,8 +29,8 @@
)
type ApexInfo struct {
- // Name of the apex variant that this module is mutated into
- ApexName string
+ // Name of the apex variation that this module is mutated into
+ ApexVariationName string
MinSdkVersion int
Updatable bool
@@ -72,16 +72,16 @@
// Returns the APEXes that this module will be built for
ApexVariations() []ApexInfo
- // Returns the name of APEX that this module will be built for. Empty string
- // is returned when 'IsForPlatform() == true'. Note that a module can be
- // included in multiple APEXes, in which case, the module is mutated into
- // multiple modules each of which for an APEX. This method returns the
- // name of the APEX that a variant module is for.
+ // Returns the name of APEX variation that this module will be built for.
+ //Empty string is returned when 'IsForPlatform() == true'. Note that a
+ // module can be included in multiple APEXes, in which case, the module
+ // is mutated into multiple modules each of which for an APEX. This method
+ // returns the name of the APEX that a variant module is for.
// Call this after apex.apexMutator is run.
- ApexName() string
+ ApexVariationName() string
// Tests whether this module will be built for the platform or not.
- // This is a shortcut for ApexName() == ""
+ // This is a shortcut for ApexVariationName() == ""
IsForPlatform() bool
// Tests if this module could have APEX variants. APEX variants are
@@ -183,7 +183,7 @@
m.apexVariationsLock.Lock()
defer m.apexVariationsLock.Unlock()
for _, v := range m.apexVariations {
- if v.ApexName == apex.ApexName {
+ if v.ApexVariationName == apex.ApexVariationName {
return
}
}
@@ -194,12 +194,12 @@
return m.apexVariations
}
-func (m *ApexModuleBase) ApexName() string {
- return m.ApexProperties.Info.ApexName
+func (m *ApexModuleBase) ApexVariationName() string {
+ return m.ApexProperties.Info.ApexVariationName
}
func (m *ApexModuleBase) IsForPlatform() bool {
- return m.ApexProperties.Info.ApexName == ""
+ return m.ApexProperties.Info.ApexVariationName == ""
}
func (m *ApexModuleBase) CanHaveApexVariants() bool {
@@ -276,7 +276,7 @@
func (a byApexName) Len() int { return len(a) }
func (a byApexName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
-func (a byApexName) Less(i, j int) bool { return a[i].ApexName < a[j].ApexName }
+func (a byApexName) Less(i, j int) bool { return a[i].ApexVariationName < a[j].ApexVariationName }
func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Module {
if len(m.apexVariations) > 0 {
@@ -286,7 +286,7 @@
variations := []string{}
variations = append(variations, "") // Original variation for platform
for _, apex := range m.apexVariations {
- variations = append(variations, apex.ApexName)
+ variations = append(variations, apex.ApexVariationName)
}
defaultVariation := ""
@@ -338,7 +338,7 @@
apexesForModule = make(map[string]bool)
apexNamesMap()[moduleName] = apexesForModule
}
- apexesForModule[apex.ApexName] = apexesForModule[apex.ApexName] || directDep
+ apexesForModule[apex.ApexVariationName] = apexesForModule[apex.ApexVariationName] || directDep
}
// TODO(b/146393795): remove this when b/146393795 is fixed
diff --git a/android/module.go b/android/module.go
index 6956167..b689a87 100644
--- a/android/module.go
+++ b/android/module.go
@@ -97,6 +97,8 @@
GlobFiles(globPattern string, excludes []string) Paths
IsSymlink(path Path) bool
Readlink(path Path) string
+
+ Namespace() *Namespace
}
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
@@ -219,7 +221,6 @@
VisitAllModuleVariants(visit func(Module))
GetMissingDependencies() []string
- Namespace() blueprint.Namespace
}
type Module interface {
@@ -1187,7 +1188,7 @@
var deps Paths
- namespacePrefix := ctx.Namespace().(*Namespace).id
+ namespacePrefix := ctx.Namespace().id
if namespacePrefix != "" {
namespacePrefix = namespacePrefix + "-"
}
@@ -1331,7 +1332,7 @@
suffix = append(suffix, ctx.Arch().ArchType.String())
}
if apex, ok := m.module.(ApexModule); ok && !apex.IsForPlatform() {
- suffix = append(suffix, apex.ApexName())
+ suffix = append(suffix, apex.ApexVariationName())
}
ctx.Variable(pctx, "moduleDesc", desc)
@@ -1498,6 +1499,10 @@
return e.kind == systemExtSpecificModule
}
+func (e *earlyModuleContext) Namespace() *Namespace {
+ return e.EarlyModuleContext.Namespace().(*Namespace)
+}
+
type baseModuleContext struct {
bp blueprint.BaseModuleContext
earlyModuleContext
diff --git a/android/mutator.go b/android/mutator.go
index b70c4ff..40e61de 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -216,6 +216,7 @@
ReplaceDependencies(string)
ReplaceDependenciesIf(string, blueprint.ReplaceDependencyPredicate)
AliasVariation(variationName string)
+ CreateAliasVariation(fromVariationName, toVariationName string)
}
type bottomUpMutatorContext struct {
@@ -436,3 +437,7 @@
func (b *bottomUpMutatorContext) AliasVariation(variationName string) {
b.bp.AliasVariation(variationName)
}
+
+func (b *bottomUpMutatorContext) CreateAliasVariation(fromVariationName, toVariationName string) {
+ b.bp.CreateAliasVariation(fromVariationName, toVariationName)
+}
diff --git a/android/testing.go b/android/testing.go
index 696efb6..f32d745 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -119,14 +119,24 @@
if module == nil {
// find all the modules that do exist
- allModuleNames := []string{}
+ var allModuleNames []string
+ var allVariants []string
ctx.VisitAllModules(func(m blueprint.Module) {
- allModuleNames = append(allModuleNames, m.(Module).Name()+"("+ctx.ModuleSubDir(m)+")")
+ allModuleNames = append(allModuleNames, ctx.ModuleName(m))
+ if ctx.ModuleName(m) == name {
+ allVariants = append(allVariants, ctx.ModuleSubDir(m))
+ }
})
sort.Strings(allModuleNames)
+ sort.Strings(allVariants)
- panic(fmt.Errorf("failed to find module %q variant %q. All modules:\n %s",
- name, variant, strings.Join(allModuleNames, "\n ")))
+ if len(allVariants) == 0 {
+ panic(fmt.Errorf("failed to find module %q. All modules:\n %s",
+ name, strings.Join(allModuleNames, "\n ")))
+ } else {
+ panic(fmt.Errorf("failed to find module %q variant %q. All variants:\n %s",
+ name, variant, strings.Join(allVariants, "\n ")))
+ }
}
return TestingModule{module}
diff --git a/apex/apex.go b/apex/apex.go
index 8d9aa51..1267ec7 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -686,9 +686,9 @@
return
}
apexInfo := android.ApexInfo{
- ApexName: mctx.ModuleName(),
- MinSdkVersion: a.minSdkVersion(mctx),
- Updatable: a.Updatable(),
+ ApexVariationName: mctx.ModuleName(),
+ MinSdkVersion: a.minSdkVersion(mctx),
+ Updatable: a.Updatable(),
}
useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
@@ -1797,7 +1797,7 @@
}
// Check for the indirect dependencies if it is considered as part of the APEX
- if am.ApexName() != "" {
+ if am.ApexVariationName() != "" {
return do(ctx, parent, am, false /* externalDep */)
}
diff --git a/cc/binary.go b/cc/binary.go
index 63bbd83..6769fa7 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -445,7 +445,7 @@
// The original path becomes a symlink to the corresponding file in the
// runtime APEX.
translatedArch := ctx.Target().NativeBridge == android.NativeBridgeEnabled
- if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() {
+ if InstallToBootstrap(ctx.baseModuleName(), ctx.Config()) && !translatedArch && ctx.apexVariationName() == "" && !ctx.inRamdisk() && !ctx.inRecovery() {
if ctx.Device() && isBionic(ctx.baseModuleName()) {
binary.installSymlinkToRuntimeApex(ctx, file)
}
diff --git a/cc/cc.go b/cc/cc.go
index abe003e..4d61fa2 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -344,7 +344,7 @@
isNDKStubLibrary() bool
useClangLld(actx ModuleContext) bool
isForPlatform() bool
- apexName() string
+ apexVariationName() string
apexSdkVersion() int
hasStubsVariants() bool
isStubs() bool
@@ -1290,8 +1290,8 @@
return ctx.mod.IsForPlatform()
}
-func (ctx *moduleContextImpl) apexName() string {
- return ctx.mod.ApexName()
+func (ctx *moduleContextImpl) apexVariationName() string {
+ return ctx.mod.ApexVariationName()
}
func (ctx *moduleContextImpl) apexSdkVersion() int {
@@ -2390,7 +2390,7 @@
if ccDep.CcLibrary() && !libDepTag.static() {
depIsStubs := ccDep.BuildStubs()
depHasStubs := VersionVariantAvailable(c) && ccDep.HasStubsVariants()
- depInSameApex := android.DirectlyInApex(c.ApexName(), depName)
+ depInSameApex := android.DirectlyInApex(c.ApexVariationName(), depName)
depInPlatform := !android.DirectlyInAnyApex(ctx, depName)
var useThisDep bool
@@ -2446,7 +2446,7 @@
// by default, use current version of LLNDK
versionToUse := ""
versions := stubsVersionsFor(ctx.Config())[depName]
- if c.ApexName() != "" && len(versions) > 0 {
+ if c.ApexVariationName() != "" && len(versions) > 0 {
// if this is for use_vendor apex && dep has stubsVersions
// apply the same rule of apex sdk enforcement to choose right version
var err error
diff --git a/cc/compiler.go b/cc/compiler.go
index d0b5b46..4a42d07 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -335,10 +335,10 @@
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_RECOVERY__")
}
- if ctx.apexName() != "" {
+ if ctx.apexVariationName() != "" {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX__")
if Bool(compiler.Properties.Use_apex_name_macro) {
- flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX_"+makeDefineString(ctx.apexName())+"__")
+ flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX_"+makeDefineString(ctx.apexVariationName())+"__")
}
if ctx.Device() {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_SDK_VERSION__="+strconv.Itoa(ctx.apexSdkVersion()))
diff --git a/java/app.go b/java/app.go
index 2010d53..bfec83f 100755
--- a/java/app.go
+++ b/java/app.go
@@ -964,6 +964,8 @@
switch tag {
case ".aapt.srcjar":
return []android.Path{a.aaptSrcJar}, nil
+ case ".export-package.apk":
+ return []android.Path{a.exportPackage}, nil
}
return a.Library.OutputFiles(tag)
}
diff --git a/java/config/config.go b/java/config/config.go
index 2f39c99..05da3b5 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -148,9 +148,9 @@
pctx.HostBinToolVariable("DexpreoptGen", "dexpreopt_gen")
pctx.VariableFunc("REJavaPool", remoteexec.EnvOverrideFunc("RBE_JAVA_POOL", "java16"))
- pctx.VariableFunc("REJavacExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAVAC_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
- pctx.VariableFunc("RED8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_D8_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
- pctx.VariableFunc("RER8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_R8_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
+ pctx.VariableFunc("REJavacExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAVAC_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy))
+ pctx.VariableFunc("RED8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_D8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy))
+ pctx.VariableFunc("RER8ExecStrategy", remoteexec.EnvOverrideFunc("RBE_R8_EXEC_STRATEGY", remoteexec.RemoteLocalFallbackExecStrategy))
pctx.VariableFunc("RETurbineExecStrategy", remoteexec.EnvOverrideFunc("RBE_TURBINE_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
pctx.VariableFunc("RESignApkExecStrategy", remoteexec.EnvOverrideFunc("RBE_SIGNAPK_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
pctx.VariableFunc("REJarExecStrategy", remoteexec.EnvOverrideFunc("RBE_JAR_EXEC_STRATEGY", remoteexec.LocalExecStrategy))
@@ -163,7 +163,7 @@
pctx.HostBinToolVariable("ManifestMergerCmd", "manifest-merger")
- pctx.HostBinToolVariable("Class2Greylist", "class2greylist")
+ pctx.HostBinToolVariable("Class2NonSdkList", "class2nonsdklist")
pctx.HostBinToolVariable("HiddenAPI", "hiddenapi")
hostBinToolVariableWithSdkToolsPrebuilt("Aapt2Cmd", "aapt2")
diff --git a/java/config/makevars.go b/java/config/makevars.go
index 708a72a..df447a1 100644
--- a/java/config/makevars.go
+++ b/java/config/makevars.go
@@ -75,7 +75,7 @@
ctx.Strict("ANDROID_MANIFEST_MERGER", "${ManifestMergerCmd}")
- ctx.Strict("CLASS2GREYLIST", "${Class2Greylist}")
+ ctx.Strict("CLASS2NONSDKLIST", "${Class2NonSdkList}")
ctx.Strict("HIDDENAPI", "${HiddenAPI}")
ctx.Strict("DEX_FLAGS", "${DexFlags}")
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index b445456..2a84f14 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -262,7 +262,7 @@
apex, isApexModule := module.(android.ApexModule)
fromUpdatableApex := isApexModule && apex.Updatable()
if image.name == artBootImageName {
- if isApexModule && strings.HasPrefix(apex.ApexName(), "com.android.art.") {
+ if isApexModule && strings.HasPrefix(apex.ApexVariationName(), "com.android.art.") {
// ok: found the jar in the ART apex
} else if isApexModule && apex.IsForPlatform() && Bool(module.(*Library).deviceProperties.Hostdex) {
// exception (skip and continue): special "hostdex" platform variant
@@ -272,7 +272,7 @@
return -1, nil
} else if fromUpdatableApex {
// error: this jar is part of an updatable apex other than ART
- ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexName())
+ ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the ART boot image", name, apex.ApexVariationName())
} else {
// error: this jar is part of the platform or a non-updatable apex
ctx.Errorf("module '%s' is not allowed in the ART boot image", name)
@@ -282,7 +282,7 @@
// ok: this jar is part of the platform or a non-updatable apex
} else {
// error: this jar is part of an updatable apex
- ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the framework boot image", name, apex.ApexName())
+ ctx.Errorf("module '%s' from updatable apex '%s' is not allowed in the framework boot image", name, apex.ApexVariationName())
}
} else {
panic("unknown boot image: " + image.name)
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index b5a0217..63b801a 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -23,8 +23,8 @@
)
var hiddenAPIGenerateCSVRule = pctx.AndroidStaticRule("hiddenAPIGenerateCSV", blueprint.RuleParams{
- Command: "${config.Class2Greylist} --stub-api-flags ${stubAPIFlags} $in $outFlag $out",
- CommandDeps: []string{"${config.Class2Greylist}"},
+ Command: "${config.Class2NonSdkList} --stub-api-flags ${stubAPIFlags} $in $outFlag $out",
+ CommandDeps: []string{"${config.Class2NonSdkList}"},
}, "outFlag", "stubAPIFlags")
type hiddenAPI struct {
diff --git a/java/java.go b/java/java.go
index f66e7fb..25fba13 100644
--- a/java/java.go
+++ b/java/java.go
@@ -558,7 +558,6 @@
bootClasspathTag = dependencyTag{name: "bootclasspath"}
systemModulesTag = dependencyTag{name: "system modules"}
frameworkResTag = dependencyTag{name: "framework-res"}
- frameworkApkTag = dependencyTag{name: "framework-apk"}
kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib"}
kotlinAnnotationsTag = dependencyTag{name: "kotlin-annotations"}
proguardRaiseTag = dependencyTag{name: "proguard-raise"}
@@ -699,12 +698,6 @@
if sdkDep.systemModules != "" {
ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules)
}
-
- if ctx.ModuleName() == "android_stubs_current" ||
- ctx.ModuleName() == "android_system_stubs_current" ||
- ctx.ModuleName() == "android_test_stubs_current" {
- ctx.AddVariationDependencies(nil, frameworkApkTag, "framework-res")
- }
}
syspropPublicStubs := syspropPublicStubs(ctx.Config())
@@ -1048,18 +1041,6 @@
} else {
ctx.PropertyErrorf("exported_plugins", "%q is not a java_plugin module", otherName)
}
- case frameworkApkTag:
- if ctx.ModuleName() == "android_stubs_current" ||
- ctx.ModuleName() == "android_system_stubs_current" ||
- ctx.ModuleName() == "android_test_stubs_current" {
- // framework stubs.jar need to depend on framework-res.apk, in order to pull the
- // resource files out of there for aapt.
- //
- // Normally the package rule runs aapt, which includes the resource,
- // but we're not running that in our package rule so just copy in the
- // resource files here.
- deps.staticResourceJars = append(deps.staticResourceJars, dep.(*AndroidApp).exportPackage)
- }
case kotlinStdlibTag:
deps.kotlinStdlib = append(deps.kotlinStdlib, dep.HeaderJars()...)
case kotlinAnnotationsTag:
@@ -1678,7 +1659,7 @@
j.linter.compileSdkVersion = lintSDKVersionString(j.sdkVersion())
j.linter.javaLanguageLevel = flags.javaVersion.String()
j.linter.kotlinLanguageLevel = "1.3"
- if j.ApexName() != "" && ctx.Config().UnbundledBuildApps() {
+ if j.ApexVariationName() != "" && ctx.Config().UnbundledBuildApps() {
j.linter.buildModuleReportZip = true
}
j.linter.lint(ctx)
diff --git a/java/sdk_library.go b/java/sdk_library.go
index ff26575..6f939a9 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1378,7 +1378,7 @@
// Get the apex name for module, "" if it is for platform.
func getApexNameForModule(module android.Module) string {
if apex, ok := module.(android.ApexModule); ok {
- return apex.ApexName()
+ return apex.ApexVariationName()
}
return ""
@@ -1389,7 +1389,7 @@
// If either this or the other module are on the platform then this will return
// false.
func withinSameApexAs(module android.ApexModule, other android.Module) bool {
- name := module.ApexName()
+ name := module.ApexVariationName()
return name != "" && getApexNameForModule(other) == name
}
@@ -2091,8 +2091,8 @@
// File path to the runtime implementation library
func (module *sdkLibraryXml) implPath() string {
implName := proptools.String(module.properties.Lib_name)
- if apexName := module.ApexName(); apexName != "" {
- // TODO(b/146468504): ApexName() is only a soong module name, not apex name.
+ if apexName := module.ApexVariationName(); apexName != "" {
+ // TODO(b/146468504): ApexVariationName() is only a soong module name, not apex name.
// In most cases, this works fine. But when apex_name is set or override_apex is used
// this can be wrong.
return fmt.Sprintf("/apex/%s/javalib/%s.jar", apexName, implName)
diff --git a/rust/clippy.go b/rust/clippy.go
index e1f567d..6f0ed7f 100644
--- a/rust/clippy.go
+++ b/rust/clippy.go
@@ -19,8 +19,14 @@
)
type ClippyProperties struct {
- // whether to run clippy.
- Clippy *bool
+ // name of the lint set that should be used to validate this module.
+ //
+ // Possible values are "default" (for using a sensible set of lints
+ // depending on the module's location), "android" (for the strictest
+ // lint set that applies to all Android platform code), "vendor" (for a
+ // relaxed set) and "none" (to disable the execution of clippy). The
+ // default value is "default". See also the `lints` property.
+ Clippy_lints *string
}
type clippy struct {
@@ -32,10 +38,10 @@
}
func (c *clippy) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
- if c.Properties.Clippy != nil && !*c.Properties.Clippy {
- return flags, deps
+ enabled, lints, err := config.ClippyLintsForDir(ctx.ModuleDir(), c.Properties.Clippy_lints)
+ if err != nil {
+ ctx.PropertyErrorf("clippy_lints", err.Error())
}
- enabled, lints := config.ClippyLintsForDir(ctx.ModuleDir())
flags.Clippy = enabled
flags.ClippyFlags = append(flags.ClippyFlags, lints)
return flags, deps
diff --git a/rust/clippy_test.go b/rust/clippy_test.go
index 3144173..7815aab 100644
--- a/rust/clippy_test.go
+++ b/rust/clippy_test.go
@@ -16,31 +16,77 @@
import (
"testing"
+
+ "android/soong/android"
)
func TestClippy(t *testing.T) {
- ctx := testRust(t, `
+
+ bp := `
+ // foo uses the default value of clippy_lints
rust_library {
name: "libfoo",
srcs: ["foo.rs"],
crate_name: "foo",
}
+ // bar forces the use of the "android" lint set
+ rust_library {
+ name: "libbar",
+ srcs: ["foo.rs"],
+ crate_name: "bar",
+ clippy_lints: "android",
+ }
+ // foobar explicitly disable clippy
rust_library {
name: "libfoobar",
srcs: ["foo.rs"],
crate_name: "foobar",
- clippy: false,
- }`)
+ clippy_lints: "none",
+ }`
- ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").Output("libfoo.dylib.so")
- fooClippy := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
- if fooClippy.Rule.String() != "android/soong/rust.clippy" {
- t.Errorf("Clippy output (default) for libfoo was not generated: %+v", fooClippy)
+ bp = bp + GatherRequiredDepsForTest()
+
+ fs := map[string][]byte{
+ // Reuse the same blueprint file for subdirectories.
+ "external/Android.bp": []byte(bp),
+ "hardware/Android.bp": []byte(bp),
}
- ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").Output("libfoobar.dylib.so")
- foobarClippy := ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
- if foobarClippy.Rule != nil {
- t.Errorf("Clippy output for libfoobar is not empty")
+ var clippyLintTests = []struct {
+ modulePath string
+ fooFlags string
+ }{
+ {"", "${config.ClippyDefaultLints}"},
+ {"external/", ""},
+ {"hardware/", "${config.ClippyVendorLints}"},
+ }
+
+ for _, tc := range clippyLintTests {
+ t.Run("path="+tc.modulePath, func(t *testing.T) {
+
+ config := android.TestArchConfig(buildDir, nil, bp, fs)
+ ctx := CreateTestContext()
+ ctx.Register(config)
+ _, errs := ctx.ParseFileList(".", []string{tc.modulePath + "Android.bp"})
+ android.FailIfErrored(t, errs)
+ _, errs = ctx.PrepareBuildActions(config)
+ android.FailIfErrored(t, errs)
+
+ r := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
+ if r.Args["clippyFlags"] != tc.fooFlags {
+ t.Errorf("Incorrect flags for libfoo: %q, want %q", r.Args["clippyFlags"], tc.fooFlags)
+ }
+
+ r = ctx.ModuleForTests("libbar", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
+ if r.Args["clippyFlags"] != "${config.ClippyDefaultLints}" {
+ t.Errorf("Incorrect flags for libbar: %q, want %q", r.Args["clippyFlags"], "${config.ClippyDefaultLints}")
+ }
+
+ r = ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("clippy")
+ if r.Rule != nil {
+ t.Errorf("libfoobar is setup to use clippy when explicitly disabled: clippyFlags=%q", r.Args["clippyFlags"])
+ }
+
+ })
}
}
diff --git a/rust/compiler.go b/rust/compiler.go
index c39a4a1..ef7fb8c 100644
--- a/rust/compiler.go
+++ b/rust/compiler.go
@@ -32,8 +32,8 @@
compiler.Properties.No_stdlibs = proptools.BoolPtr(true)
}
-func (compiler *baseCompiler) setNoLint() {
- compiler.Properties.No_lint = proptools.BoolPtr(true)
+func (compiler *baseCompiler) disableLints() {
+ compiler.Properties.Lints = proptools.StringPtr("none")
}
func NewBaseCompiler(dir, dir64 string, location installLocation) *baseCompiler {
@@ -58,8 +58,14 @@
// path to the source file that is the main entry point of the program (e.g. main.rs or lib.rs)
Srcs []string `android:"path,arch_variant"`
- // whether to suppress the standard lint flags - default to false
- No_lint *bool
+ // name of the lint set that should be used to validate this module.
+ //
+ // Possible values are "default" (for using a sensible set of lints
+ // depending on the module's location), "android" (for the strictest
+ // lint set that applies to all Android platform code), "vendor" (for
+ // a relaxed set) and "none" (for ignoring all lint warnings and
+ // errors). The default value is "default".
+ Lints *string
// flags to pass to rustc
Flags []string `android:"path,arch_variant"`
@@ -159,11 +165,11 @@
func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flags {
- if Bool(compiler.Properties.No_lint) {
- flags.RustFlags = append(flags.RustFlags, config.AllowAllLints)
- } else {
- flags.RustFlags = append(flags.RustFlags, config.RustcLintsForDir(ctx.ModuleDir()))
+ lintFlags, err := config.RustcLintsForDir(ctx.ModuleDir(), compiler.Properties.Lints)
+ if err != nil {
+ ctx.PropertyErrorf("lints", err.Error())
}
+ flags.RustFlags = append(flags.RustFlags, lintFlags)
flags.RustFlags = append(flags.RustFlags, compiler.Properties.Flags...)
flags.RustFlags = append(flags.RustFlags, compiler.featuresToFlags(compiler.Properties.Features)...)
flags.RustFlags = append(flags.RustFlags, "--edition="+compiler.edition())
diff --git a/rust/compiler_test.go b/rust/compiler_test.go
index b853196..8b9fccc 100644
--- a/rust/compiler_test.go
+++ b/rust/compiler_test.go
@@ -17,6 +17,8 @@
import (
"strings"
"testing"
+
+ "android/soong/android"
)
// Test that feature flags are being correctly generated.
@@ -104,3 +106,74 @@
t.Fatalf("unexpected install path for binary: %#v", install_path_bin)
}
}
+
+func TestLints(t *testing.T) {
+
+ bp := `
+ // foo uses the default value of lints
+ rust_library {
+ name: "libfoo",
+ srcs: ["foo.rs"],
+ crate_name: "foo",
+ }
+ // bar forces the use of the "android" lint set
+ rust_library {
+ name: "libbar",
+ srcs: ["foo.rs"],
+ crate_name: "bar",
+ lints: "android",
+ }
+ // foobar explicitly disable all lints
+ rust_library {
+ name: "libfoobar",
+ srcs: ["foo.rs"],
+ crate_name: "foobar",
+ lints: "none",
+ }`
+
+ bp = bp + GatherRequiredDepsForTest()
+
+ fs := map[string][]byte{
+ // Reuse the same blueprint file for subdirectories.
+ "external/Android.bp": []byte(bp),
+ "hardware/Android.bp": []byte(bp),
+ }
+
+ var lintTests = []struct {
+ modulePath string
+ fooFlags string
+ }{
+ {"", "${config.RustDefaultLints}"},
+ {"external/", "${config.RustAllowAllLints}"},
+ {"hardware/", "${config.RustVendorLints}"},
+ }
+
+ for _, tc := range lintTests {
+ t.Run("path="+tc.modulePath, func(t *testing.T) {
+
+ config := android.TestArchConfig(buildDir, nil, bp, fs)
+ ctx := CreateTestContext()
+ ctx.Register(config)
+ _, errs := ctx.ParseFileList(".", []string{tc.modulePath + "Android.bp"})
+ android.FailIfErrored(t, errs)
+ _, errs = ctx.PrepareBuildActions(config)
+ android.FailIfErrored(t, errs)
+
+ r := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("rustc")
+ if !strings.Contains(r.Args["rustcFlags"], tc.fooFlags) {
+ t.Errorf("Incorrect flags for libfoo: %q, want %q", r.Args["rustcFlags"], tc.fooFlags)
+ }
+
+ r = ctx.ModuleForTests("libbar", "android_arm64_armv8-a_dylib").MaybeRule("rustc")
+ if !strings.Contains(r.Args["rustcFlags"], "${config.RustDefaultLints}") {
+ t.Errorf("Incorrect flags for libbar: %q, want %q", r.Args["rustcFlags"], "${config.RustDefaultLints}")
+ }
+
+ r = ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("rustc")
+ if !strings.Contains(r.Args["rustcFlags"], "${config.RustAllowAllLints}") {
+ t.Errorf("Incorrect flags for libfoobar: %q, want %q", r.Args["rustcFlags"], "${config.RustAllowAllLints}")
+ }
+
+ })
+ }
+}
diff --git a/rust/config/allowed_list.go b/rust/config/allowed_list.go
index ed9f90b..62d469e 100644
--- a/rust/config/allowed_list.go
+++ b/rust/config/allowed_list.go
@@ -10,6 +10,7 @@
"prebuilts/rust",
"system/extras/profcollectd",
"system/security",
+ "system/tools/aidl",
}
RustModuleTypes = []string{
diff --git a/rust/config/lints.go b/rust/config/lints.go
index e24ffac..06bb668 100644
--- a/rust/config/lints.go
+++ b/rust/config/lints.go
@@ -15,6 +15,7 @@
package config
import (
+ "fmt"
"strings"
"android/soong/android"
@@ -24,18 +25,21 @@
// The Android build system tries to avoid reporting warnings during the build.
// Therefore, by default, we upgrade warnings to denials. For some of these
// lints, an allow exception is setup, using the variables below.
-// There are different default lints depending on the repository location (see
-// DefaultLocalClippyChecks).
+//
// The lints are split into two categories. The first one contains the built-in
// lints (https://doc.rust-lang.org/rustc/lints/index.html). The second is
// specific to Clippy lints (https://rust-lang.github.io/rust-clippy/master/).
//
-// When developing a module, it is possible to use the `no_lint` property to
-// disable the built-in lints configuration. It is also possible to set
-// `clippy` to false to disable the clippy verification. Expect some
-// questioning during review if you enable one of these options. For external/
-// code, if you need to use them, it is likely a bug. Otherwise, it may be
-// useful to add an exception (that is, move a lint from deny to allow).
+// For both categories, there are 3 levels of linting possible:
+// - "android", for the strictest lints that applies to all Android platform code.
+// - "vendor", for relaxed rules.
+// - "none", to disable the linting.
+// There is a fourth option ("default") which automatically selects the linting level
+// based on the module's location. See defaultLintSetForPath.
+//
+// When developing a module, you may set `lints = "none"` and `clippy_lints =
+// "none"` to disable all the linting. Expect some questioning during code review
+// if you enable one of these options.
var (
// Default Rust lints that applies to Google-authored modules.
defaultRustcLints = []string{
@@ -102,13 +106,6 @@
pctx.StaticVariable("RustAllowAllLints", strings.Join(allowAllLints, " "))
}
-type PathBasedClippyConfig struct {
- PathPrefix string
- RustcConfig string
- ClippyEnabled bool
- ClippyConfig string
-}
-
const noLint = ""
const rustcDefault = "${config.RustDefaultLints}"
const rustcVendor = "${config.RustVendorLints}"
@@ -116,36 +113,78 @@
const clippyDefault = "${config.ClippyDefaultLints}"
const clippyVendor = "${config.ClippyVendorLints}"
-// This is a map of local path prefixes to a set of parameters for the linting:
-// - a string for the lints to apply to rustc.
-// - a boolean to indicate if clippy should be executed.
-// - a string for the lints to apply to clippy.
-// The first entry matching will be used.
-var DefaultLocalClippyChecks = []PathBasedClippyConfig{
- {"external/", rustcAllowAll, false, noLint},
- {"hardware/", rustcVendor, true, clippyVendor},
- {"prebuilts/", rustcAllowAll, false, noLint},
- {"vendor/google", rustcDefault, true, clippyDefault},
- {"vendor/", rustcVendor, true, clippyVendor},
+// lintConfig defines a set of lints and clippy configuration.
+type lintConfig struct {
+ rustcConfig string // for the lints to apply to rustc.
+ clippyEnabled bool // to indicate if clippy should be executed.
+ clippyConfig string // for the lints to apply to clippy.
}
-var AllowAllLints = rustcAllowAll
+
+const (
+ androidLints = "android"
+ vendorLints = "vendor"
+ noneLints = "none"
+)
+
+// lintSets defines the categories of linting for Android and their mapping to lintConfigs.
+var lintSets = map[string]lintConfig{
+ androidLints: {rustcDefault, true, clippyDefault},
+ vendorLints: {rustcVendor, true, clippyVendor},
+ noneLints: {rustcAllowAll, false, noLint},
+}
+
+type pathLintSet struct {
+ prefix string
+ set string
+}
+
+// This is a map of local path prefixes to a lint set. The first entry
+// matching will be used. If no entry matches, androidLints ("android") will be
+// used.
+var defaultLintSetForPath = []pathLintSet{
+ {"external", noneLints},
+ {"hardware", vendorLints},
+ {"prebuilts", noneLints},
+ {"vendor/google", androidLints},
+ {"vendor", vendorLints},
+}
// ClippyLintsForDir returns a boolean if Clippy should be executed and if so, the lints to be used.
-func ClippyLintsForDir(dir string) (bool, string) {
- for _, pathCheck := range DefaultLocalClippyChecks {
- if strings.HasPrefix(dir, pathCheck.PathPrefix) {
- return pathCheck.ClippyEnabled, pathCheck.ClippyConfig
+func ClippyLintsForDir(dir string, clippyLintsProperty *string) (bool, string, error) {
+ if clippyLintsProperty != nil {
+ set, ok := lintSets[*clippyLintsProperty]
+ if ok {
+ return set.clippyEnabled, set.clippyConfig, nil
+ }
+ if *clippyLintsProperty != "default" {
+ return false, "", fmt.Errorf("unknown value for `clippy_lints`: %v, valid options are: default, android, vendor or none", *clippyLintsProperty)
}
}
- return true, clippyDefault
+ for _, p := range defaultLintSetForPath {
+ if strings.HasPrefix(dir, p.prefix) {
+ setConfig := lintSets[p.set]
+ return setConfig.clippyEnabled, setConfig.clippyConfig, nil
+ }
+ }
+ return true, clippyDefault, nil
}
// RustcLintsForDir returns the standard lints to be used for a repository.
-func RustcLintsForDir(dir string) string {
- for _, pathCheck := range DefaultLocalClippyChecks {
- if strings.HasPrefix(dir, pathCheck.PathPrefix) {
- return pathCheck.RustcConfig
+func RustcLintsForDir(dir string, lintProperty *string) (string, error) {
+ if lintProperty != nil {
+ set, ok := lintSets[*lintProperty]
+ if ok {
+ return set.rustcConfig, nil
+ }
+ if *lintProperty != "default" {
+ return "", fmt.Errorf("unknown value for `lints`: %v, valid options are: default, android, vendor or none", *lintProperty)
+ }
+
+ }
+ for _, p := range defaultLintSetForPath {
+ if strings.HasPrefix(dir, p.prefix) {
+ return lintSets[p.set].rustcConfig, nil
}
}
- return rustcDefault
+ return rustcDefault, nil
}
diff --git a/rust/rust.go b/rust/rust.go
index 54b2285..b697869 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1046,9 +1046,9 @@
return name
}
-func (mod *Module) setClippy(clippy bool) {
+func (mod *Module) disableClippy() {
if mod.clippy != nil {
- mod.clippy.Properties.Clippy = proptools.BoolPtr(clippy)
+ mod.clippy.Properties.Clippy_lints = proptools.StringPtr("none")
}
}
diff --git a/rust/source_provider.go b/rust/source_provider.go
index 76679c2..e168718 100644
--- a/rust/source_provider.go
+++ b/rust/source_provider.go
@@ -73,8 +73,8 @@
module.compiler = library
if !enableLints {
- library.setNoLint()
- module.setClippy(false)
+ library.disableLints()
+ module.disableClippy()
}
return module
diff --git a/scripts/build-aml-prebuilts.sh b/scripts/build-aml-prebuilts.sh
index c60eaa1..ef5565d 100755
--- a/scripts/build-aml-prebuilts.sh
+++ b/scripts/build-aml-prebuilts.sh
@@ -84,6 +84,8 @@
"CrossHostArch": "x86_64",
"Aml_abis": true,
+ "Allow_missing_dependencies": ${SOONG_ALLOW_MISSING_DEPENDENCIES:-false},
+ "Unbundled_build": ${TARGET_BUILD_UNBUNDLED:-false},
"UseGoma": ${USE_GOMA}
}
EOF
diff --git a/sh/Android.bp b/sh/Android.bp
index 0f40c5f..e5ffeef 100644
--- a/sh/Android.bp
+++ b/sh/Android.bp
@@ -5,6 +5,7 @@
"blueprint",
"soong",
"soong-android",
+ "soong-cc",
"soong-tradefed",
],
srcs: [
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index f28b2b6..217a4e1 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -17,11 +17,14 @@
import (
"fmt"
"path/filepath"
+ "sort"
"strings"
+ "github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/cc"
"android/soong/tradefed"
)
@@ -88,6 +91,20 @@
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
Auto_gen_config *bool
+
+ // list of binary modules that should be installed alongside the test
+ Data_bins []string `android:"path,arch_variant"`
+
+ // list of library modules that should be installed alongside the test
+ Data_libs []string `android:"path,arch_variant"`
+
+ // list of device binary modules that should be installed alongside the test.
+ // Only available for host sh_test modules.
+ Data_device_bins []string `android:"path,arch_variant"`
+
+ // list of device library modules that should be installed alongside the test.
+ // Only available for host sh_test modules.
+ Data_device_libs []string `android:"path,arch_variant"`
}
type ShBinary struct {
@@ -111,6 +128,8 @@
data android.Paths
testConfig android.Path
+
+ dataModules map[string]android.Path
}
func (s *ShBinary) HostToolPath() android.OptionalPath {
@@ -192,6 +211,50 @@
}
}
+type dependencyTag struct {
+ blueprint.BaseDependencyTag
+ name string
+}
+
+var (
+ shTestDataBinsTag = dependencyTag{name: "dataBins"}
+ shTestDataLibsTag = dependencyTag{name: "dataLibs"}
+ shTestDataDeviceBinsTag = dependencyTag{name: "dataDeviceBins"}
+ shTestDataDeviceLibsTag = dependencyTag{name: "dataDeviceLibs"}
+)
+
+var sharedLibVariations = []blueprint.Variation{{Mutator: "link", Variation: "shared"}}
+
+func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
+ s.ShBinary.DepsMutator(ctx)
+
+ ctx.AddFarVariationDependencies(ctx.Target().Variations(), shTestDataBinsTag, s.testProperties.Data_bins...)
+ ctx.AddFarVariationDependencies(append(ctx.Target().Variations(), sharedLibVariations...),
+ shTestDataLibsTag, s.testProperties.Data_libs...)
+ if ctx.Target().Os.Class == android.Host && len(ctx.Config().Targets[android.Android]) > 0 {
+ deviceVariations := ctx.Config().Targets[android.Android][0].Variations()
+ ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
+ ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
+ shTestDataDeviceLibsTag, s.testProperties.Data_device_libs...)
+ } else if ctx.Target().Os.Class != android.Host {
+ if len(s.testProperties.Data_device_bins) > 0 {
+ ctx.PropertyErrorf("data_device_bins", "only available for host modules")
+ }
+ if len(s.testProperties.Data_device_libs) > 0 {
+ ctx.PropertyErrorf("data_device_libs", "only available for host modules")
+ }
+ }
+}
+
+func (s *ShTest) addToDataModules(ctx android.ModuleContext, relPath string, path android.Path) {
+ if _, exists := s.dataModules[relPath]; exists {
+ ctx.ModuleErrorf("data modules have a conflicting installation path, %v - %s, %s",
+ relPath, s.dataModules[relPath].String(), path.String())
+ return
+ }
+ s.dataModules[relPath] = path
+}
+
func (s *ShTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.ShBinary.generateAndroidBuildActions(ctx)
testDir := "nativetest"
@@ -223,6 +286,50 @@
}
s.testConfig = tradefed.AutoGenShellTestConfig(ctx, s.testProperties.Test_config,
s.testProperties.Test_config_template, s.testProperties.Test_suites, configs, s.testProperties.Auto_gen_config, s.outputFilePath.Base())
+
+ s.dataModules = make(map[string]android.Path)
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ depTag := ctx.OtherModuleDependencyTag(dep)
+ switch depTag {
+ case shTestDataBinsTag, shTestDataDeviceBinsTag:
+ if cc, isCc := dep.(*cc.Module); isCc {
+ s.addToDataModules(ctx, cc.OutputFile().Path().Base(), cc.OutputFile().Path())
+ return
+ }
+ property := "data_bins"
+ if depTag == shTestDataDeviceBinsTag {
+ property = "data_device_bins"
+ }
+ ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
+ case shTestDataLibsTag, shTestDataDeviceLibsTag:
+ if cc, isCc := dep.(*cc.Module); isCc {
+ // Copy to an intermediate output directory to append "lib[64]" to the path,
+ // so that it's compatible with the default rpath values.
+ var relPath string
+ if cc.Arch().ArchType.Multilib == "lib64" {
+ relPath = filepath.Join("lib64", cc.OutputFile().Path().Base())
+ } else {
+ relPath = filepath.Join("lib", cc.OutputFile().Path().Base())
+ }
+ if _, exist := s.dataModules[relPath]; exist {
+ return
+ }
+ relocatedLib := android.PathForModuleOut(ctx, "relocated", relPath)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Input: cc.OutputFile().Path(),
+ Output: relocatedLib,
+ })
+ s.addToDataModules(ctx, relPath, relocatedLib)
+ return
+ }
+ property := "data_libs"
+ if depTag == shTestDataDeviceBinsTag {
+ property = "data_device_libs"
+ }
+ ctx.PropertyErrorf(property, "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep))
+ }
+ })
}
func (s *ShTest) InstallInData() bool {
@@ -251,6 +358,15 @@
path = strings.TrimSuffix(path, rel)
entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel)
}
+ relPaths := make([]string, 0)
+ for relPath, _ := range s.dataModules {
+ relPaths = append(relPaths, relPath)
+ }
+ sort.Strings(relPaths)
+ for _, relPath := range relPaths {
+ dir := strings.TrimSuffix(s.dataModules[relPath].String(), relPath)
+ entries.AddStrings("LOCAL_TEST_DATA", dir+":"+relPath)
+ }
},
},
}}
diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go
index 3bfe611..0aa607b 100644
--- a/sh/sh_binary_test.go
+++ b/sh/sh_binary_test.go
@@ -3,10 +3,12 @@
import (
"io/ioutil"
"os"
+ "path/filepath"
"reflect"
"testing"
"android/soong/android"
+ "android/soong/cc"
)
var buildDir string
@@ -46,6 +48,9 @@
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("sh_test", ShTestFactory)
ctx.RegisterModuleType("sh_test_host", ShTestHostFactory)
+
+ cc.RegisterRequiredBuildComponentsForTest(ctx)
+
ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
android.FailIfErrored(t, errs)
@@ -105,6 +110,65 @@
}
}
+func TestShTest_dataModules(t *testing.T) {
+ ctx, config := testShBinary(t, `
+ sh_test {
+ name: "foo",
+ src: "test.sh",
+ host_supported: true,
+ data_bins: ["bar"],
+ data_libs: ["libbar"],
+ }
+
+ cc_binary {
+ name: "bar",
+ host_supported: true,
+ shared_libs: ["libbar"],
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "libbar",
+ host_supported: true,
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ buildOS := android.BuildOs.String()
+ arches := []string{"android_arm64_armv8-a", buildOS + "_x86_64"}
+ for _, arch := range arches {
+ variant := ctx.ModuleForTests("foo", arch)
+
+ libExt := ".so"
+ if arch == "darwin_x86_64" {
+ libExt = ".dylib"
+ }
+ relocated := variant.Output("relocated/lib64/libbar" + libExt)
+ expectedInput := filepath.Join(buildDir, ".intermediates/libbar/"+arch+"_shared/libbar"+libExt)
+ if relocated.Input.String() != expectedInput {
+ t.Errorf("Unexpected relocation input, expected: %q, actual: %q",
+ expectedInput, relocated.Input.String())
+ }
+
+ mod := variant.Module().(*ShTest)
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
+ expectedData := []string{
+ filepath.Join(buildDir, ".intermediates/bar", arch, ":bar"),
+ filepath.Join(buildDir, ".intermediates/foo", arch, "relocated/:lib64/libbar"+libExt),
+ }
+ actualData := entries.EntryMap["LOCAL_TEST_DATA"]
+ if !reflect.DeepEqual(expectedData, actualData) {
+ t.Errorf("Unexpected test data, expected: %q, actual: %q", expectedData, actualData)
+ }
+ }
+}
+
func TestShTestHost(t *testing.T) {
ctx, _ := testShBinary(t, `
sh_test_host {
@@ -124,3 +188,53 @@
t.Errorf("host bit is not set for a sh_test_host module.")
}
}
+
+func TestShTestHost_dataDeviceModules(t *testing.T) {
+ ctx, config := testShBinary(t, `
+ sh_test_host {
+ name: "foo",
+ src: "test.sh",
+ data_device_bins: ["bar"],
+ data_device_libs: ["libbar"],
+ }
+
+ cc_binary {
+ name: "bar",
+ shared_libs: ["libbar"],
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+
+ cc_library {
+ name: "libbar",
+ no_libcrt: true,
+ nocrt: true,
+ system_shared_libs: [],
+ stl: "none",
+ }
+ `)
+
+ buildOS := android.BuildOs.String()
+ variant := ctx.ModuleForTests("foo", buildOS+"_x86_64")
+
+ relocated := variant.Output("relocated/lib64/libbar.so")
+ expectedInput := filepath.Join(buildDir, ".intermediates/libbar/android_arm64_armv8-a_shared/libbar.so")
+ if relocated.Input.String() != expectedInput {
+ t.Errorf("Unexpected relocation input, expected: %q, actual: %q",
+ expectedInput, relocated.Input.String())
+ }
+
+ mod := variant.Module().(*ShTest)
+ entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
+ expectedData := []string{
+ filepath.Join(buildDir, ".intermediates/bar/android_arm64_armv8-a/:bar"),
+ // libbar has been relocated, and so has a variant that matches the host arch.
+ filepath.Join(buildDir, ".intermediates/foo/"+buildOS+"_x86_64/relocated/:lib64/libbar.so"),
+ }
+ actualData := entries.EntryMap["LOCAL_TEST_DATA"]
+ if !reflect.DeepEqual(expectedData, actualData) {
+ t.Errorf("Unexpected test data, expected: %q, actual: %q", expectedData, actualData)
+ }
+}
diff --git a/ui/build/rbe.go b/ui/build/rbe.go
index 99107e3..6a26063 100644
--- a/ui/build/rbe.go
+++ b/ui/build/rbe.go
@@ -53,11 +53,14 @@
func getRBEVars(ctx Context, config Config) map[string]string {
rand.Seed(time.Now().UnixNano())
vars := map[string]string{
- "RBE_server_address": fmt.Sprintf("unix://%v/reproxy_%v.sock", absPath(ctx, config.TempDir()), rand.Intn(1000)),
- "RBE_log_path": config.rbeLogPath(),
- "RBE_re_proxy": config.rbeReproxy(),
- "RBE_exec_root": config.rbeExecRoot(),
- "RBE_output_dir": config.rbeStatsOutputDir(),
+ "RBE_log_path": config.rbeLogPath(),
+ "RBE_log_dir": config.logDir(),
+ "RBE_re_proxy": config.rbeReproxy(),
+ "RBE_exec_root": config.rbeExecRoot(),
+ "RBE_output_dir": config.rbeStatsOutputDir(),
+ }
+ if config.StartRBE() {
+ vars["RBE_server_address"] = fmt.Sprintf("unix://%v/reproxy_%v.sock", absPath(ctx, config.TempDir()), rand.Intn(1000))
}
k, v := config.rbeAuth()
vars[k] = v