Merge "Revert "Auto generate prebuilt_* modules from PRODUCT_COPY_FILES"" into main
diff --git a/android/module_context.go b/android/module_context.go
index 9fa3fa3..1f5e706 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -19,6 +19,7 @@
"github.com/google/blueprint/depset"
"path"
"path/filepath"
+ "slices"
"strings"
"github.com/google/blueprint"
@@ -562,9 +563,22 @@
m.aconfigFilePaths = paths
}
+func (m *moduleContext) getOwnerAndOverrides() (string, []string) {
+ owner := m.ModuleName()
+ overrides := slices.Clone(m.Module().base().commonProperties.Overrides)
+ if b, ok := m.Module().(OverridableModule); ok {
+ if b.GetOverriddenBy() != "" {
+ // overriding variant of base module
+ overrides = append(overrides, m.ModuleName()) // com.android.foo
+ owner = m.Module().Name() // com.company.android.foo
+ }
+ }
+ return owner, overrides
+}
+
func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec {
licenseFiles := m.Module().EffectiveLicenseFiles()
- overrides := CopyOf(m.Module().base().commonProperties.Overrides)
+ owner, overrides := m.getOwnerAndOverrides()
spec := PackagingSpec{
relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
srcPath: srcPath,
@@ -576,7 +590,7 @@
aconfigPaths: m.getAconfigPaths(),
archType: m.target.Arch.ArchType,
overrides: &overrides,
- owner: m.ModuleName(),
+ owner: owner,
}
m.packagingSpecs = append(m.packagingSpecs, spec)
return spec
@@ -695,7 +709,7 @@
m.installFiles = append(m.installFiles, fullInstallPath)
}
- overrides := CopyOf(m.Module().base().commonProperties.Overrides)
+ owner, overrides := m.getOwnerAndOverrides()
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
srcPath: nil,
@@ -706,7 +720,7 @@
aconfigPaths: m.getAconfigPaths(),
archType: m.target.Arch.ArchType,
overrides: &overrides,
- owner: m.ModuleName(),
+ owner: owner,
})
return fullInstallPath
@@ -742,7 +756,7 @@
m.installFiles = append(m.installFiles, fullInstallPath)
}
- overrides := CopyOf(m.Module().base().commonProperties.Overrides)
+ owner, overrides := m.getOwnerAndOverrides()
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
srcPath: nil,
@@ -753,7 +767,7 @@
aconfigPaths: m.getAconfigPaths(),
archType: m.target.Arch.ArchType,
overrides: &overrides,
- owner: m.ModuleName(),
+ owner: owner,
})
return fullInstallPath
diff --git a/android/packaging.go b/android/packaging.go
index b5c4503..98c85fa 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -17,7 +17,6 @@
import (
"fmt"
"path/filepath"
- "slices"
"sort"
"strings"
@@ -257,79 +256,76 @@
return p
}
-func (p *PackagingBase) highPriorityDeps() []string {
- return slices.Concat(
- p.properties.High_priority_deps,
- p.properties.Multilib.Both.High_priority_deps,
- p.properties.Multilib.Common.High_priority_deps,
- p.properties.Multilib.First.High_priority_deps,
- p.properties.Multilib.Lib32.High_priority_deps,
- p.properties.Multilib.Lib64.High_priority_deps,
- p.properties.Multilib.Prefer32.High_priority_deps,
- p.properties.Arch.Arm.High_priority_deps,
- p.properties.Arch.Arm64.High_priority_deps,
- p.properties.Arch.X86.High_priority_deps,
- p.properties.Arch.X86_64.High_priority_deps,
- )
-}
-
// From deps and multilib.*.deps, select the dependencies that are for the given arch deps is for
// the current archicture when this module is not configured for multi target. When configured for
// multi target, deps is selected for each of the targets and is NOT selected for the current
// architecture which would be Common.
-func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) []string {
- if len(p.highPriorityDeps()) > 0 && !p.AllowHighPriorityDeps {
- ctx.ModuleErrorf("Usage of high_priority_deps is not allowed for %s module type", ctx.ModuleType())
+// It returns two lists, the normal and high priority deps, respectively.
+func (p *PackagingBase) getDepsForArch(ctx BaseModuleContext, arch ArchType) ([]string, []string) {
+ var normalDeps []string
+ var highPriorityDeps []string
+
+ get := func(prop DepsProperty) {
+ normalDeps = append(normalDeps, prop.Deps.GetOrDefault(ctx, nil)...)
+ highPriorityDeps = append(highPriorityDeps, prop.High_priority_deps...)
+ }
+ has := func(prop DepsProperty) bool {
+ return len(prop.Deps.GetOrDefault(ctx, nil)) > 0 || len(prop.High_priority_deps) > 0
}
- get := func(prop DepsProperty) []string {
- return Concat(prop.Deps.GetOrDefault(ctx, nil), prop.High_priority_deps)
- }
-
- var ret []string
if arch == ctx.Target().Arch.ArchType && len(ctx.MultiTargets()) == 0 {
- ret = append(ret, get(p.properties.DepsProperty)...)
+ get(p.properties.DepsProperty)
} else if arch.Multilib == "lib32" {
- ret = append(ret, get(p.properties.Multilib.Lib32)...)
+ get(p.properties.Multilib.Lib32)
// multilib.prefer32.deps are added for lib32 only when they support 32-bit arch
- for _, dep := range get(p.properties.Multilib.Prefer32) {
+ for _, dep := range p.properties.Multilib.Prefer32.Deps.GetOrDefault(ctx, nil) {
if checkIfOtherModuleSupportsLib32(ctx, dep) {
- ret = append(ret, dep)
+ normalDeps = append(normalDeps, dep)
+ }
+ }
+ for _, dep := range p.properties.Multilib.Prefer32.High_priority_deps {
+ if checkIfOtherModuleSupportsLib32(ctx, dep) {
+ highPriorityDeps = append(highPriorityDeps, dep)
}
}
} else if arch.Multilib == "lib64" {
- ret = append(ret, get(p.properties.Multilib.Lib64)...)
+ get(p.properties.Multilib.Lib64)
// multilib.prefer32.deps are added for lib64 only when they don't support 32-bit arch
- for _, dep := range get(p.properties.Multilib.Prefer32) {
+ for _, dep := range p.properties.Multilib.Prefer32.Deps.GetOrDefault(ctx, nil) {
if !checkIfOtherModuleSupportsLib32(ctx, dep) {
- ret = append(ret, dep)
+ normalDeps = append(normalDeps, dep)
+ }
+ }
+ for _, dep := range p.properties.Multilib.Prefer32.High_priority_deps {
+ if !checkIfOtherModuleSupportsLib32(ctx, dep) {
+ highPriorityDeps = append(highPriorityDeps, dep)
}
}
} else if arch == Common {
- ret = append(ret, get(p.properties.Multilib.Common)...)
+ get(p.properties.Multilib.Common)
}
if p.DepsCollectFirstTargetOnly {
- if len(get(p.properties.Multilib.First)) > 0 {
+ if has(p.properties.Multilib.First) {
ctx.PropertyErrorf("multilib.first.deps", "not supported. use \"deps\" instead")
}
for i, t := range ctx.MultiTargets() {
if t.Arch.ArchType == arch {
- ret = append(ret, get(p.properties.Multilib.Both)...)
+ get(p.properties.Multilib.Both)
if i == 0 {
- ret = append(ret, get(p.properties.DepsProperty)...)
+ get(p.properties.DepsProperty)
}
}
}
} else {
- if len(get(p.properties.Multilib.Both)) > 0 {
+ if has(p.properties.Multilib.Both) {
ctx.PropertyErrorf("multilib.both.deps", "not supported. use \"deps\" instead")
}
for i, t := range ctx.MultiTargets() {
if t.Arch.ArchType == arch {
- ret = append(ret, get(p.properties.DepsProperty)...)
+ get(p.properties.DepsProperty)
if i == 0 {
- ret = append(ret, get(p.properties.Multilib.First)...)
+ get(p.properties.Multilib.First)
}
}
}
@@ -338,17 +334,21 @@
if ctx.Arch().ArchType == Common {
switch arch {
case Arm64:
- ret = append(ret, get(p.properties.Arch.Arm64)...)
+ get(p.properties.Arch.Arm64)
case Arm:
- ret = append(ret, get(p.properties.Arch.Arm)...)
+ get(p.properties.Arch.Arm)
case X86_64:
- ret = append(ret, get(p.properties.Arch.X86_64)...)
+ get(p.properties.Arch.X86_64)
case X86:
- ret = append(ret, get(p.properties.Arch.X86)...)
+ get(p.properties.Arch.X86)
}
}
- return FirstUniqueStrings(ret)
+ if len(highPriorityDeps) > 0 && !p.AllowHighPriorityDeps {
+ ctx.ModuleErrorf("Usage of high_priority_deps is not allowed for %s module type", ctx.ModuleType())
+ }
+
+ return FirstUniqueStrings(normalDeps), FirstUniqueStrings(highPriorityDeps)
}
func getSupportedTargets(ctx BaseModuleContext) []Target {
@@ -412,27 +412,34 @@
// See PackageModule.AddDeps
func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.DependencyTag) {
- highPriorityDeps := p.highPriorityDeps()
- for _, t := range getSupportedTargets(ctx) {
- for _, dep := range p.getDepsForArch(ctx, t.Arch.ArchType) {
- if p.IgnoreMissingDependencies && !ctx.OtherModuleExists(dep) {
- continue
- }
- targetVariation := t.Variations()
- sharedVariation := blueprint.Variation{
- Mutator: "link",
- Variation: "shared",
- }
- // If a shared variation exists, use that. Static variants do not provide any standalone files
- // for packaging.
- if ctx.OtherModuleFarDependencyVariantExists([]blueprint.Variation{sharedVariation}, dep) {
- targetVariation = append(targetVariation, sharedVariation)
- }
- if InList(dep, highPriorityDeps) {
- depTag = highPriorityDepTag{depTag}
- }
+ addDep := func(t Target, dep string, highPriority bool) {
+ if p.IgnoreMissingDependencies && !ctx.OtherModuleExists(dep) {
+ return
+ }
+ targetVariation := t.Variations()
+ sharedVariation := blueprint.Variation{
+ Mutator: "link",
+ Variation: "shared",
+ }
+ // If a shared variation exists, use that. Static variants do not provide any standalone files
+ // for packaging.
+ if ctx.OtherModuleFarDependencyVariantExists([]blueprint.Variation{sharedVariation}, dep) {
+ targetVariation = append(targetVariation, sharedVariation)
+ }
+ depTagToUse := depTag
+ if highPriority {
+ depTagToUse = highPriorityDepTag{depTag}
+ }
- ctx.AddFarVariationDependencies(targetVariation, depTag, dep)
+ ctx.AddFarVariationDependencies(targetVariation, depTagToUse, dep)
+ }
+ for _, t := range getSupportedTargets(ctx) {
+ normalDeps, highPriorityDeps := p.getDepsForArch(ctx, t.Arch.ArchType)
+ for _, dep := range normalDeps {
+ addDep(t, dep, false)
+ }
+ for _, dep := range highPriorityDeps {
+ addDep(t, dep, true)
}
}
}
diff --git a/android/util.go b/android/util.go
index 2d269b7..3fc4608 100644
--- a/android/util.go
+++ b/android/util.go
@@ -660,3 +660,13 @@
v, loaded := m.Map.LoadOrStore(key, value)
return v.(V), loaded
}
+
+// AppendIfNotZero append the given value to the slice if it is not the zero value
+// for its type.
+func AppendIfNotZero[T comparable](slice []T, value T) []T {
+ var zeroValue T // Get the zero value of the type T
+ if value != zeroValue {
+ return append(slice, value)
+ }
+ return slice
+}
diff --git a/cc/cc.go b/cc/cc.go
index 551f2cd..5dee32e 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -35,6 +35,14 @@
"android/soong/genrule"
)
+type CcMakeVarsInfo struct {
+ WarningsAllowed string
+ UsingWnoError string
+ MissingProfile string
+}
+
+var CcMakeVarsInfoProvider = blueprint.NewProvider[*CcMakeVarsInfo]()
+
func init() {
RegisterCCBuildComponents(android.InitRegistrationContext)
@@ -531,6 +539,7 @@
getSharedFlags() *SharedFlags
notInPlatform() bool
optimizeForSize() bool
+ getOrCreateMakeVarsInfo() *CcMakeVarsInfo
}
type SharedFlags struct {
@@ -845,9 +854,10 @@
sourceProperties android.SourceProperties
// initialize before calling Init
- hod android.HostOrDeviceSupported
- multilib android.Multilib
- testModule bool
+ hod android.HostOrDeviceSupported
+ multilib android.Multilib
+ testModule bool
+ incremental bool
// Allowable SdkMemberTypes of this module type.
sdkMemberTypes []android.SdkMemberType
@@ -913,8 +923,16 @@
hasSysprop bool
hasWinMsg bool
hasYacc bool
+
+ makeVarsInfo *CcMakeVarsInfo
}
+func (c *Module) IncrementalSupported() bool {
+ return c.incremental
+}
+
+var _ blueprint.Incremental = (*Module)(nil)
+
func (c *Module) AddJSONData(d *map[string]interface{}) {
c.AndroidModuleBase().AddJSONData(d)
(*d)["Cc"] = map[string]interface{}{
@@ -1700,6 +1718,13 @@
return ctx.mod.NotInPlatform()
}
+func (ctx *moduleContextImpl) getOrCreateMakeVarsInfo() *CcMakeVarsInfo {
+ if ctx.mod.makeVarsInfo == nil {
+ ctx.mod.makeVarsInfo = &CcMakeVarsInfo{}
+ }
+ return ctx.mod.makeVarsInfo
+}
+
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
return &Module{
hod: hod,
@@ -2091,6 +2116,10 @@
}
c.setOutputFiles(ctx)
+
+ if c.makeVarsInfo != nil {
+ android.SetProvider(ctx, CcMakeVarsInfoProvider, c.makeVarsInfo)
+ }
}
func (c *Module) setOutputFiles(ctx ModuleContext) {
diff --git a/cc/compiler.go b/cc/compiler.go
index f06287c..0fa058a 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -685,10 +685,10 @@
if len(srcs) > 0 {
module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName()
if inList("-Wno-error", flags.Local.CFlags) || inList("-Wno-error", flags.Local.CppFlags) {
- addToModuleList(ctx, modulesUsingWnoErrorKey, module)
+ ctx.getOrCreateMakeVarsInfo().UsingWnoError = module
} else if !inList("-Werror", flags.Local.CFlags) && !inList("-Werror", flags.Local.CppFlags) {
if warningsAreAllowed(ctx.ModuleDir()) {
- addToModuleList(ctx, modulesWarningsAllowedKey, module)
+ ctx.getOrCreateMakeVarsInfo().WarningsAllowed = module
} else {
flags.Local.CFlags = append([]string{"-Werror"}, flags.Local.CFlags...)
}
diff --git a/cc/makevars.go b/cc/makevars.go
index f82e0e9..4cb98e7 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -25,10 +25,7 @@
)
var (
- modulesWarningsAllowedKey = android.NewOnceKey("ModulesWarningsAllowed")
- modulesUsingWnoErrorKey = android.NewOnceKey("ModulesUsingWnoError")
- modulesMissingProfileFileKey = android.NewOnceKey("ModulesMissingProfileFile")
- sanitizerVariables = map[string]string{
+ sanitizerVariables = map[string]string{
"ADDRESS_SANITIZER_RUNTIME_LIBRARY": config.AddressSanitizerRuntimeLibrary(),
"HWADDRESS_SANITIZER_RUNTIME_LIBRARY": config.HWAddressSanitizerRuntimeLibrary(),
"HWADDRESS_SANITIZER_STATIC_LIBRARY": config.HWAddressSanitizerStaticLibrary(),
@@ -50,15 +47,9 @@
}).(*sync.Map)
}
-func makeStringOfKeys(ctx android.MakeVarsContext, key android.OnceKey) string {
- set := getNamedMapForConfig(ctx.Config(), key)
- keys := []string{}
- set.Range(func(key interface{}, value interface{}) bool {
- keys = append(keys, key.(string))
- return true
- })
- sort.Strings(keys)
- return strings.Join(keys, " ")
+func makeVarsString(items []string) string {
+ items = android.SortedUniqueStrings(items)
+ return strings.Join(items, " ")
}
func makeStringOfWarningAllowedProjects() string {
@@ -108,28 +99,33 @@
ctx.Strict("GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideExternalGlobalCflags}")
// Filter vendor_public_library that are exported to make
- exportedVendorPublicLibraries := []string{}
+ var exportedVendorPublicLibraries []string
+ var warningsAllowed []string
+ var usingWnoErrors []string
+ var missingProfiles []string
ctx.VisitAllModules(func(module android.Module) {
+ if v, ok := android.OtherModuleProvider(ctx, module, CcMakeVarsInfoProvider); ok {
+ warningsAllowed = android.AppendIfNotZero(warningsAllowed, v.WarningsAllowed)
+ usingWnoErrors = android.AppendIfNotZero(usingWnoErrors, v.UsingWnoError)
+ missingProfiles = android.AppendIfNotZero(missingProfiles, v.MissingProfile)
+ }
if ccModule, ok := module.(*Module); ok {
baseName := ccModule.BaseModuleName()
if ccModule.IsVendorPublicLibrary() && module.ExportedToMake() {
- if !inList(baseName, exportedVendorPublicLibraries) {
- exportedVendorPublicLibraries = append(exportedVendorPublicLibraries, baseName)
- }
+ exportedVendorPublicLibraries = append(exportedVendorPublicLibraries, baseName)
}
}
})
- sort.Strings(exportedVendorPublicLibraries)
- ctx.Strict("VENDOR_PUBLIC_LIBRARIES", strings.Join(exportedVendorPublicLibraries, " "))
+ ctx.Strict("VENDOR_PUBLIC_LIBRARIES", makeVarsString(exportedVendorPublicLibraries))
lsdumpPaths := *lsdumpPaths(ctx.Config())
sort.Strings(lsdumpPaths)
ctx.Strict("LSDUMP_PATHS", strings.Join(lsdumpPaths, " "))
ctx.Strict("ANDROID_WARNING_ALLOWED_PROJECTS", makeStringOfWarningAllowedProjects())
- ctx.Strict("SOONG_MODULES_WARNINGS_ALLOWED", makeStringOfKeys(ctx, modulesWarningsAllowedKey))
- ctx.Strict("SOONG_MODULES_USING_WNO_ERROR", makeStringOfKeys(ctx, modulesUsingWnoErrorKey))
- ctx.Strict("SOONG_MODULES_MISSING_PGO_PROFILE_FILE", makeStringOfKeys(ctx, modulesMissingProfileFileKey))
+ ctx.Strict("SOONG_MODULES_WARNINGS_ALLOWED", makeVarsString(warningsAllowed))
+ ctx.Strict("SOONG_MODULES_USING_WNO_ERROR", makeVarsString(usingWnoErrors))
+ ctx.Strict("SOONG_MODULES_MISSING_PGO_PROFILE_FILE", makeVarsString(missingProfiles))
ctx.Strict("CLANG_COVERAGE_CONFIG_CFLAGS", strings.Join(clangCoverageCFlags, " "))
ctx.Strict("CLANG_COVERAGE_CONFIG_COMMFLAGS", strings.Join(clangCoverageCommonFlags, " "))
diff --git a/cc/orderfile.go b/cc/orderfile.go
index 38b8905..6e08da7 100644
--- a/cc/orderfile.go
+++ b/cc/orderfile.go
@@ -54,10 +54,6 @@
})
}
-func recordMissingOrderfile(ctx BaseModuleContext, missing string) {
- getNamedMapForConfig(ctx.Config(), modulesMissingProfileFileKey).Store(missing, true)
-}
-
type OrderfileProperties struct {
Orderfile struct {
Instrumentation *bool
@@ -117,7 +113,7 @@
// Record that this module's order file is absent
missing := *props.Orderfile.Order_file_path + ":" + ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName()
- recordMissingOrderfile(ctx, missing)
+ ctx.getOrCreateMakeVarsInfo().MissingProfile = missing
return android.OptionalPath{}
}
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index f767eae..29f9373 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -691,3 +691,27 @@
android.AssertStringDoesContain(t, "Could not find linker.config.json file in cmd", linkerConfigCmd, "conv_linker_config proto --force -s linker.config.json")
android.AssertStringDoesContain(t, "Could not find stub in `provideLibs`", linkerConfigCmd, "--key provideLibs --value libfoo_has_stubs.so")
}
+
+// override_android_* modules implicitly override their base module.
+// If both of these are listed in `deps`, the base module should not be installed.
+func TestOverrideModulesInDeps(t *testing.T) {
+ result := fixture.RunTestWithBp(t, `
+ android_filesystem {
+ name: "myfilesystem",
+ deps: ["myapp", "myoverrideapp"],
+ }
+
+ android_app {
+ name: "myapp",
+ platform_apis: true,
+ }
+ override_android_app {
+ name: "myoverrideapp",
+ base: "myapp",
+ }
+ `)
+
+ partition := result.ModuleForTests("myfilesystem", "android_common")
+ fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
+ android.AssertStringEquals(t, "filesystem with override app", "app/myoverrideapp/myoverrideapp.apk\n", fileList)
+}
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 001cac8..06e154a 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -68,7 +68,7 @@
}
// Map of module name to depCandidateProps
-type multilibDeps *map[string]*depCandidateProps
+type multilibDeps map[string]*depCandidateProps
// Information necessary to generate the filesystem modules, including details about their
// dependencies
@@ -76,7 +76,7 @@
// List of modules in `PRODUCT_PACKAGES` and `PRODUCT_PACKAGES_DEBUG`
depCandidates []string
// Map of names of partition to the information of modules to be added as deps
- fsDeps map[string]multilibDeps
+ fsDeps map[string]*multilibDeps
// List of name of partitions to be generated by the filesystem_creator module
soongGeneratedPartitions []string
// Mutex to protect the fsDeps
@@ -90,10 +90,6 @@
Overrides []string
}
-func newMultilibDeps() multilibDeps {
- return &map[string]*depCandidateProps{}
-}
-
func defaultDepCandidateProps(config android.Config) *depCandidateProps {
return &depCandidateProps{
Namespace: ".",
@@ -122,9 +118,9 @@
return &FsGenState{
depCandidates: candidates,
- fsDeps: map[string]multilibDeps{
+ fsDeps: map[string]*multilibDeps{
// These additional deps are added according to the cuttlefish system image bp.
- "system": &map[string]*depCandidateProps{
+ "system": {
"com.android.apex.cts.shim.v1_prebuilt": defaultDepCandidateProps(ctx.Config()),
"dex_bootjars": defaultDepCandidateProps(ctx.Config()),
"framework_compatibility_matrix.device.xml": defaultDepCandidateProps(ctx.Config()),
@@ -142,19 +138,19 @@
"public.libraries.android.txt": defaultDepCandidateProps(ctx.Config()),
"update_engine_sideload": defaultDepCandidateProps(ctx.Config()),
},
- "vendor": &map[string]*depCandidateProps{
+ "vendor": {
"fs_config_files_vendor": defaultDepCandidateProps(ctx.Config()),
"fs_config_dirs_vendor": defaultDepCandidateProps(ctx.Config()),
generatedModuleName(ctx.Config(), "vendor-build.prop"): defaultDepCandidateProps(ctx.Config()),
},
- "odm": &map[string]*depCandidateProps{
+ "odm": {
// fs_config_* files are automatically installed for all products with odm partitions.
// https://cs.android.com/android/_/android/platform/build/+/e4849e87ab660b59a6501b3928693db065ee873b:tools/fs_config/Android.mk;l=34;drc=8d6481b92c4b4e9b9f31a61545b6862090fcc14b;bpv=1;bpt=0
"fs_config_files_odm": defaultDepCandidateProps(ctx.Config()),
"fs_config_dirs_odm": defaultDepCandidateProps(ctx.Config()),
},
- "product": newMultilibDeps(),
- "system_ext": &map[string]*depCandidateProps{
+ "product": {},
+ "system_ext": {
// VNDK apexes are automatically included.
// This hardcoded list will need to be updated if `PRODUCT_EXTRA_VNDK_VERSIONS` is updated.
// https://cs.android.com/android/_/android/platform/build/+/adba533072b00c53ac0f198c550a3cbd7a00e4cd:core/main.mk;l=984;bpv=1;bpt=0;drc=174db7b179592cf07cbfd2adb0119486fda911e7
@@ -172,14 +168,14 @@
}).(*FsGenState)
}
-func checkDepModuleInMultipleNamespaces(mctx android.BottomUpMutatorContext, foundDeps map[string]*depCandidateProps, module string, partitionName string) {
+func checkDepModuleInMultipleNamespaces(mctx android.BottomUpMutatorContext, foundDeps multilibDeps, module string, partitionName string) {
otherNamespace := mctx.Namespace().Path
if val, found := foundDeps[module]; found && otherNamespace != "." && !android.InList(val.Namespace, []string{".", otherNamespace}) {
mctx.ModuleErrorf("found in multiple namespaces(%s and %s) when including in %s partition", val.Namespace, otherNamespace, partitionName)
}
}
-func appendDepIfAppropriate(mctx android.BottomUpMutatorContext, deps *map[string]*depCandidateProps, installPartition string) {
+func appendDepIfAppropriate(mctx android.BottomUpMutatorContext, deps *multilibDeps, installPartition string) {
checkDepModuleInMultipleNamespaces(mctx, *deps, mctx.Module().Name(), installPartition)
if _, ok := (*deps)[mctx.Module().Name()]; ok {
// Prefer the namespace-specific module over the platform module
diff --git a/rust/config/global.go b/rust/config/global.go
index 68a74c2..7b79fca 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -15,6 +15,7 @@
package config
import (
+ "fmt"
"strings"
"android/soong/android"
@@ -93,6 +94,16 @@
}
)
+func RustPath(ctx android.PathContext) string {
+ // I can't see any way to flatten the static variable inside Soong, so this
+ // reproduces the init logic.
+ var RustBase string = RustDefaultBase
+ if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" {
+ RustBase = override
+ }
+ return fmt.Sprintf("%s/%s/%s", RustBase, HostPrebuiltTag(ctx.Config()), GetRustVersion(ctx))
+}
+
func init() {
pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase)
pctx.VariableConfigMethod("HostPrebuiltTag", HostPrebuiltTag)
diff --git a/rust/project_json.go b/rust/project_json.go
index 6c1e320..6e8cebe 100644
--- a/rust/project_json.go
+++ b/rust/project_json.go
@@ -19,6 +19,7 @@
"fmt"
"android/soong/android"
+ "android/soong/rust/config"
)
// This singleton collects Rust crate definitions and generates a JSON file
@@ -44,17 +45,19 @@
}
type rustProjectCrate struct {
- DisplayName string `json:"display_name"`
- RootModule string `json:"root_module"`
- Edition string `json:"edition,omitempty"`
- Deps []rustProjectDep `json:"deps"`
- Cfg []string `json:"cfg"`
- Env map[string]string `json:"env"`
- ProcMacro bool `json:"is_proc_macro"`
+ DisplayName string `json:"display_name"`
+ RootModule string `json:"root_module"`
+ Edition string `json:"edition,omitempty"`
+ Deps []rustProjectDep `json:"deps"`
+ Cfg []string `json:"cfg"`
+ Env map[string]string `json:"env"`
+ ProcMacro bool `json:"is_proc_macro"`
+ ProcMacroDylib *string `json:"proc_macro_dylib_path"`
}
type rustProjectJson struct {
- Crates []rustProjectCrate `json:"crates"`
+ Sysroot string `json:"sysroot"`
+ Crates []rustProjectCrate `json:"crates"`
}
// crateInfo is used during the processing to keep track of the known crates.
@@ -135,16 +138,21 @@
return 0, false
}
- _, procMacro := rModule.compiler.(*procMacroDecorator)
+ var procMacroDylib *string = nil
+ if procDec, procMacro := rModule.compiler.(*procMacroDecorator); procMacro {
+ procMacroDylib = new(string)
+ *procMacroDylib = procDec.baseCompiler.unstrippedOutputFilePath().String()
+ }
crate := rustProjectCrate{
- DisplayName: rModule.Name(),
- RootModule: rootModule.String(),
- Edition: rModule.compiler.edition(),
- Deps: make([]rustProjectDep, 0),
- Cfg: make([]string, 0),
- Env: make(map[string]string),
- ProcMacro: procMacro,
+ DisplayName: rModule.Name(),
+ RootModule: rootModule.String(),
+ Edition: rModule.compiler.edition(),
+ Deps: make([]rustProjectDep, 0),
+ Cfg: make([]string, 0),
+ Env: make(map[string]string),
+ ProcMacro: procMacroDylib != nil,
+ ProcMacroDylib: procMacroDylib,
}
if rModule.compiler.cargoOutDir().Valid() {
@@ -197,6 +205,8 @@
return
}
+ singleton.project.Sysroot = config.RustPath(ctx)
+
singleton.knownCrates = make(map[string]crateInfo)
ctx.VisitAllModules(func(module android.Module) {
singleton.appendCrateAndDependencies(ctx, module)