Add new properties to aid in removing the 1-variant fallback
These new properties are essentially methods to specify "outgoing
transitions" in blueprint files. There are lots of host tests
that want to include apps built for device in their data, so they
need a property that adds dependencies based on the device variants
instead of copying the same host variants.
After this cl is submitted, I'll do an LSC to update all the usages
that are relying on the 1-variant fallback to use these properties
instead.
Bug: 372091092
Test: m nothing --no-skip-soong-tests
Change-Id: I45b8fb024da120ad61606e3a21de86e4392be2a4
diff --git a/cc/cc.go b/cc/cc.go
index 9c514ee..52bf669 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -119,9 +119,10 @@
ObjFiles []string
- GeneratedSources []string
- GeneratedHeaders []string
- GeneratedDeps []string
+ GeneratedSources []string
+ GeneratedHeaders []string
+ DeviceFirstGeneratedHeaders []string
+ GeneratedDeps []string
ReexportGeneratedHeaders []string
@@ -2609,6 +2610,11 @@
actx.AddDependency(c, depTag, gen)
}
+ for _, gen := range deps.DeviceFirstGeneratedHeaders {
+ depTag := genHeaderDepTag
+ actx.AddVariationDependencies(ctx.Config().AndroidFirstDeviceTarget.Variations(), depTag, gen)
+ }
+
crtVariations := GetCrtVariations(ctx, c)
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
for _, crt := range deps.CrtBegin {
diff --git a/cc/compiler.go b/cc/compiler.go
index 7bba962..88d97aa 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -100,6 +100,11 @@
// of genrule modules.
Generated_headers proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
+ // Same as generated_headers, but the dependencies will be added based on the first supported
+ // arch variant and the device os variant. This can be useful for creating a host tool that
+ // embeds a copy of a device tool, that it then extracts and pushes to a device at runtime.
+ Device_first_generated_headers proptools.Configurable[[]string] `android:"arch_variant,variant_prepend"`
+
// pass -frtti instead of -fno-rtti
Rtti *bool `android:"arch_variant"`
@@ -294,6 +299,7 @@
deps.GeneratedSources = append(deps.GeneratedSources, compiler.Properties.Generated_sources...)
deps.GeneratedSources = removeListFromList(deps.GeneratedSources, compiler.Properties.Exclude_generated_sources)
deps.GeneratedHeaders = append(deps.GeneratedHeaders, compiler.Properties.Generated_headers.GetOrDefault(ctx, nil)...)
+ deps.DeviceFirstGeneratedHeaders = append(deps.DeviceFirstGeneratedHeaders, compiler.Properties.Device_first_generated_headers.GetOrDefault(ctx, nil)...)
deps.AidlLibs = append(deps.AidlLibs, compiler.Properties.Aidl.Libs...)
android.ProtoDeps(ctx, &compiler.Proto)
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 0aa9d4b..8a974c0 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -347,6 +347,7 @@
func PackageFuzzModule(ctx android.ModuleContext, fuzzPackagedModule fuzz.FuzzPackagedModule, pctx android.PackageContext) fuzz.FuzzPackagedModule {
fuzzPackagedModule.Corpus = android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Corpus)
+ fuzzPackagedModule.Corpus = append(fuzzPackagedModule.Corpus, android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Device_common_corpus)...)
fuzzPackagedModule.Data = android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Data)
diff --git a/cc/test.go b/cc/test.go
index f5bb761..ae73886 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -15,10 +15,11 @@
package cc
import (
- "github.com/google/blueprint/proptools"
"path/filepath"
"strconv"
+ "github.com/google/blueprint/proptools"
+
"android/soong/android"
"android/soong/tradefed"
)
@@ -82,6 +83,16 @@
// the test
Data []string `android:"path,arch_variant"`
+ // Same as data, but adds depedencies on modules using the device's os variant, and common
+ // architecture's variant. Can be useful to add device-built apps to the data of a host
+ // test.
+ Device_common_data []string `android:"path_device_common"`
+
+ // Same as data, but adds depedencies on modules using the device's os variant, and the device's
+ // first architecture's variant. Can be useful to add device-built apps to the data of a host
+ // test.
+ Device_first_data []string `android:"path_device_first"`
+
// list of shared library modules that should be installed alongside the test
Data_libs []string `android:"arch_variant"`
@@ -324,6 +335,8 @@
func (test *testBinary) install(ctx ModuleContext, file android.Path) {
dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
+ dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_common_data)...)
+ dataSrcPaths = append(dataSrcPaths, android.PathsForModuleSrc(ctx, test.Properties.Device_first_data)...)
for _, dataSrcPath := range dataSrcPaths {
test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})