aboutsummaryrefslogtreecommitdiff
path: root/android/module_context.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/module_context.go')
-rw-r--r--android/module_context.go101
1 files changed, 59 insertions, 42 deletions
diff --git a/android/module_context.go b/android/module_context.go
index 0a23a745f..986ecf4f5 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -85,8 +85,6 @@ type BuildParams struct {
PhonyOutput bool
}
-type ModuleBuildParams BuildParams
-
type ModuleContext interface {
BaseModuleContext
@@ -94,21 +92,6 @@ type ModuleContext interface {
// used by the golang module types that need to call into the bootstrap module types.
BlueprintModuleContext() blueprint.ModuleContext
- // Deprecated: use ModuleContext.Build instead.
- ModuleBuild(pctx PackageContext, params ModuleBuildParams)
-
- // Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
- // be tagged with `android:"path" to support automatic source module dependency resolution.
- //
- // Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
- ExpandSources(srcFiles, excludes []string) Paths
-
- // Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
- // be tagged with `android:"path" to support automatic source module dependency resolution.
- //
- // Deprecated: use PathForModuleSrc instead.
- ExpandSource(srcFile, prop string) Path
-
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
// InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
@@ -185,6 +168,11 @@ type ModuleContext interface {
// dependency tags for which IsInstallDepNeeded returns true.
PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec
+ // PackageFileWithFakeFullInstall creates a PackagingSpec, but does not require a full
+ // install by android_device.
+ // This is experimental, and is only meant to be used by Soong only builds.
+ PackageFileWithFakeFullInstall(installPath InstallPath, name string, srcPath Path) PackagingSpec
+
CheckbuildFile(srcPaths ...Path)
UncheckedModule()
@@ -267,6 +255,11 @@ type ModuleContext interface {
// goal is built.
DistForGoalWithFilename(goal string, path Path, filename string)
+ // DistForGoalWithFilenameTag creates a rule to copy a Path to the artifacts
+ // directory on the build server with the given filename appended with the
+ // `-FILE_NAME_TAG_PLACEHOLDER` suffix when the specified goal is built.
+ DistForGoalWithFilenameTag(goal string, path Path, filename string)
+
// DistForGoals creates a rule to copy one or more Paths to the artifacts
// directory on the build server when any of the specified goals are built.
DistForGoals(goals []string, paths ...Path)
@@ -275,6 +268,15 @@ type ModuleContext interface {
// directory on the build server with the given filename when any of the
// specified goals are built.
DistForGoalsWithFilename(goals []string, path Path, filename string)
+
+ // Defines this module as a compatibility suite test and gives all the information needed
+ // to build the suite.
+ SetTestSuiteInfo(info TestSuiteInfo)
+
+ // FreeModuleAfterGenerateBuildActions marks this module as no longer necessary after the completion of
+ // GenerateBuildActions, i.e. all later accesses to the module will be via ModuleProxy and not direct access
+ // to the Module.
+ FreeModuleAfterGenerateBuildActions()
}
type moduleContext struct {
@@ -334,6 +336,9 @@ type moduleContext struct {
complianceMetadataInfo *ComplianceMetadataInfo
dists []dist
+
+ testSuiteInfo TestSuiteInfo
+ testSuiteInfoSet bool
}
var _ ModuleContext = &moduleContext{}
@@ -352,10 +357,6 @@ func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContex
}
}
-func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
- m.Build(pctx, BuildParams(params))
-}
-
// Convert build parameters from their concrete Android types into their string representations,
// and combine the singular and plural fields of the same type (e.g. Output and Outputs).
func convertBuildParams(params BuildParams) blueprint.BuildParams {
@@ -417,7 +418,7 @@ func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.
if m.config.UseRemoteBuild() {
if params.Pool == nil {
- // When USE_GOMA=true or USE_RBE=true are set and the rule is not supported by goma/RBE, restrict
+ // When USE_RBE=true is set and the rule is not supported by RBE, restrict
// jobs to the local parallelism value
params.Pool = localPool
} else if params.Pool == remotePool {
@@ -461,6 +462,9 @@ func (m *moduleContext) Phony(name string, deps ...Path) {
panic("Phony dep cannot be nil")
}
}
+ if name == "" {
+ panic("Phony name cannot be the empty string")
+ }
m.phonies[name] = append(m.phonies[name], deps...)
}
@@ -484,15 +488,15 @@ func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.Dependenc
}
}
-func (m *moduleContext) GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) *ModuleProxy {
+func (m *moduleContext) GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) ModuleProxy {
deps := m.getDirectDepsProxyInternal(name, tag)
if len(deps) == 1 {
- return &deps[0]
+ return deps[0]
} else if len(deps) >= 2 {
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
name, m.ModuleName()))
} else {
- return nil
+ return ModuleProxy{}
}
}
@@ -622,6 +626,11 @@ func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPat
return m.packageFile(fullInstallPath, srcPath, false, false)
}
+func (m *moduleContext) PackageFileWithFakeFullInstall(installPath InstallPath, name string, srcPath Path) PackagingSpec {
+ fullInstallPath := installPath.Join(m, name)
+ return m.packageFile(fullInstallPath, srcPath, false, true)
+}
+
func (m *moduleContext) getAconfigPaths() Paths {
return m.aconfigFilePaths
}
@@ -632,7 +641,7 @@ func (m *moduleContext) setAconfigPaths(paths Paths) {
func (m *moduleContext) getOwnerAndOverrides() (string, []string) {
owner := m.ModuleName()
- overrides := slices.Clone(m.Module().base().commonProperties.Overrides)
+ overrides := slices.Clone(m.Module().base().baseProperties.Overrides)
if b, ok := m.Module().(OverridableModule); ok {
if b.GetOverriddenBy() != "" {
// overriding variant of base module
@@ -661,6 +670,7 @@ func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, e
requiresFullInstall: requiresFullInstall,
fullInstallPath: fullInstallPath,
variation: m.ModuleSubDir(),
+ prebuilt: IsModulePrebuilt(m, m.Module()),
}
m.packagingSpecs = append(m.packagingSpecs, spec)
return spec
@@ -816,6 +826,7 @@ func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, src
requiresFullInstall: m.requiresFullInstall(),
fullInstallPath: fullInstallPath,
variation: m.ModuleSubDir(),
+ prebuilt: IsModulePrebuilt(m, m.Module()),
})
return fullInstallPath
@@ -867,6 +878,7 @@ func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name str
requiresFullInstall: m.requiresFullInstall(),
fullInstallPath: fullInstallPath,
variation: m.ModuleSubDir(),
+ prebuilt: IsModulePrebuilt(m, m.Module()),
})
return fullInstallPath
@@ -964,22 +976,6 @@ func (m *moduleContext) ComplianceMetadataInfo() *ComplianceMetadataInfo {
return m.complianceMetadataInfo
}
-// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
-// be tagged with `android:"path" to support automatic source module dependency resolution.
-//
-// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
-func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
- return PathsForModuleSrcExcludes(m, srcFiles, excludes)
-}
-
-// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
-// be tagged with `android:"path" to support automatic source module dependency resolution.
-//
-// Deprecated: use PathForModuleSrc instead.
-func (m *moduleContext) ExpandSource(srcFile, _ string) Path {
- return PathForModuleSrc(m, srcFile)
-}
-
// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
// dependency resolution.
@@ -1018,6 +1014,15 @@ func (c *moduleContext) DistForGoalWithFilename(goal string, path Path, filename
c.DistForGoalsWithFilename([]string{goal}, path, filename)
}
+func (c *moduleContext) DistForGoalWithFilenameTag(goal string, path Path, filename string) {
+ insertBeforeExtension := func(file, insertion string) string {
+ ext := filepath.Ext(file)
+ return strings.TrimSuffix(file, ext) + insertion + ext
+ }
+
+ c.DistForGoalWithFilename(goal, path, insertBeforeExtension(filename, "-FILE_NAME_TAG_PLACEHOLDER"))
+}
+
func (c *moduleContext) DistForGoals(goals []string, paths ...Path) {
var copies distCopies
for _, path := range paths {
@@ -1038,3 +1043,15 @@ func (c *moduleContext) DistForGoalsWithFilename(goals []string, path Path, file
paths: distCopies{{from: path, dest: filename}},
})
}
+
+func (c *moduleContext) SetTestSuiteInfo(info TestSuiteInfo) {
+ if c.testSuiteInfoSet {
+ panic("Cannot call SetTestSuiteInfo twice")
+ }
+ c.testSuiteInfo = info
+ c.testSuiteInfoSet = true
+}
+
+func (c *moduleContext) FreeModuleAfterGenerateBuildActions() {
+ c.bp.FreeModuleAfterGenerateBuildActions()
+}