xref: /aosp_15_r20/build/soong/android/module_context.go (revision 333d2b3687b3a337dbcca9d65000bca186795e39)
1*333d2b36SAndroid Build Coastguard Worker// Copyright 2015 Google Inc. All rights reserved.
2*333d2b36SAndroid Build Coastguard Worker//
3*333d2b36SAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License");
4*333d2b36SAndroid Build Coastguard Worker// you may not use this file except in compliance with the License.
5*333d2b36SAndroid Build Coastguard Worker// You may obtain a copy of the License at
6*333d2b36SAndroid Build Coastguard Worker//
7*333d2b36SAndroid Build Coastguard Worker//     http://www.apache.org/licenses/LICENSE-2.0
8*333d2b36SAndroid Build Coastguard Worker//
9*333d2b36SAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*333d2b36SAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS,
11*333d2b36SAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*333d2b36SAndroid Build Coastguard Worker// See the License for the specific language governing permissions and
13*333d2b36SAndroid Build Coastguard Worker// limitations under the License.
14*333d2b36SAndroid Build Coastguard Worker
15*333d2b36SAndroid Build Coastguard Workerpackage android
16*333d2b36SAndroid Build Coastguard Worker
17*333d2b36SAndroid Build Coastguard Workerimport (
18*333d2b36SAndroid Build Coastguard Worker	"fmt"
19*333d2b36SAndroid Build Coastguard Worker	"path"
20*333d2b36SAndroid Build Coastguard Worker	"path/filepath"
21*333d2b36SAndroid Build Coastguard Worker	"slices"
22*333d2b36SAndroid Build Coastguard Worker	"strings"
23*333d2b36SAndroid Build Coastguard Worker
24*333d2b36SAndroid Build Coastguard Worker	"github.com/google/blueprint"
25*333d2b36SAndroid Build Coastguard Worker	"github.com/google/blueprint/depset"
26*333d2b36SAndroid Build Coastguard Worker	"github.com/google/blueprint/proptools"
27*333d2b36SAndroid Build Coastguard Worker)
28*333d2b36SAndroid Build Coastguard Worker
29*333d2b36SAndroid Build Coastguard Worker// BuildParameters describes the set of potential parameters to build a Ninja rule.
30*333d2b36SAndroid Build Coastguard Worker// In general, these correspond to a Ninja concept.
31*333d2b36SAndroid Build Coastguard Workertype BuildParams struct {
32*333d2b36SAndroid Build Coastguard Worker	// A Ninja Rule that will be written to the Ninja file. This allows factoring out common code
33*333d2b36SAndroid Build Coastguard Worker	// among multiple modules to reduce repetition in the Ninja file of action requirements. A rule
34*333d2b36SAndroid Build Coastguard Worker	// can contain variables that should be provided in Args.
35*333d2b36SAndroid Build Coastguard Worker	Rule blueprint.Rule
36*333d2b36SAndroid Build Coastguard Worker	// Deps represents the depfile format. When using RuleBuilder, this defaults to GCC when depfiles
37*333d2b36SAndroid Build Coastguard Worker	// are used.
38*333d2b36SAndroid Build Coastguard Worker	Deps blueprint.Deps
39*333d2b36SAndroid Build Coastguard Worker	// Depfile is a writeable path that allows correct incremental builds when the inputs have not
40*333d2b36SAndroid Build Coastguard Worker	// been fully specified by the Ninja rule. Ninja supports a subset of the Makefile depfile syntax.
41*333d2b36SAndroid Build Coastguard Worker	Depfile WritablePath
42*333d2b36SAndroid Build Coastguard Worker	// A description of the build action.
43*333d2b36SAndroid Build Coastguard Worker	Description string
44*333d2b36SAndroid Build Coastguard Worker	// Output is an output file of the action. When using this field, references to $out in the Ninja
45*333d2b36SAndroid Build Coastguard Worker	// command will refer to this file.
46*333d2b36SAndroid Build Coastguard Worker	Output WritablePath
47*333d2b36SAndroid Build Coastguard Worker	// Outputs is a slice of output file of the action. When using this field, references to $out in
48*333d2b36SAndroid Build Coastguard Worker	// the Ninja command will refer to these files.
49*333d2b36SAndroid Build Coastguard Worker	Outputs WritablePaths
50*333d2b36SAndroid Build Coastguard Worker	// ImplicitOutput is an output file generated by the action. Note: references to `$out` in the
51*333d2b36SAndroid Build Coastguard Worker	// Ninja command will NOT include references to this file.
52*333d2b36SAndroid Build Coastguard Worker	ImplicitOutput WritablePath
53*333d2b36SAndroid Build Coastguard Worker	// ImplicitOutputs is a slice of output files generated by the action. Note: references to `$out`
54*333d2b36SAndroid Build Coastguard Worker	// in the Ninja command will NOT include references to these files.
55*333d2b36SAndroid Build Coastguard Worker	ImplicitOutputs WritablePaths
56*333d2b36SAndroid Build Coastguard Worker	// Input is an input file to the Ninja action. When using this field, references to $in in the
57*333d2b36SAndroid Build Coastguard Worker	// Ninja command will refer to this file.
58*333d2b36SAndroid Build Coastguard Worker	Input Path
59*333d2b36SAndroid Build Coastguard Worker	// Inputs is a slice of input files to the Ninja action. When using this field, references to $in
60*333d2b36SAndroid Build Coastguard Worker	// in the Ninja command will refer to these files.
61*333d2b36SAndroid Build Coastguard Worker	Inputs Paths
62*333d2b36SAndroid Build Coastguard Worker	// Implicit is an input file to the Ninja action. Note: references to `$in` in the Ninja command
63*333d2b36SAndroid Build Coastguard Worker	// will NOT include references to this file.
64*333d2b36SAndroid Build Coastguard Worker	Implicit Path
65*333d2b36SAndroid Build Coastguard Worker	// Implicits is a slice of input files to the Ninja action. Note: references to `$in` in the Ninja
66*333d2b36SAndroid Build Coastguard Worker	// command will NOT include references to these files.
67*333d2b36SAndroid Build Coastguard Worker	Implicits Paths
68*333d2b36SAndroid Build Coastguard Worker	// OrderOnly are Ninja order-only inputs to the action. When these are out of date, the output is
69*333d2b36SAndroid Build Coastguard Worker	// not rebuilt until they are built, but changes in order-only dependencies alone do not cause the
70*333d2b36SAndroid Build Coastguard Worker	// output to be rebuilt.
71*333d2b36SAndroid Build Coastguard Worker	OrderOnly Paths
72*333d2b36SAndroid Build Coastguard Worker	// Validation is an output path for a validation action. Validation outputs imply lower
73*333d2b36SAndroid Build Coastguard Worker	// non-blocking priority to building non-validation outputs.
74*333d2b36SAndroid Build Coastguard Worker	Validation Path
75*333d2b36SAndroid Build Coastguard Worker	// Validations is a slice of output path for a validation action. Validation outputs imply lower
76*333d2b36SAndroid Build Coastguard Worker	// non-blocking priority to building non-validation outputs.
77*333d2b36SAndroid Build Coastguard Worker	Validations Paths
78*333d2b36SAndroid Build Coastguard Worker	// Whether to skip outputting a default target statement which will be built by Ninja when no
79*333d2b36SAndroid Build Coastguard Worker	// targets are specified on Ninja's command line.
80*333d2b36SAndroid Build Coastguard Worker	Default bool
81*333d2b36SAndroid Build Coastguard Worker	// Args is a key value mapping for replacements of variables within the Rule
82*333d2b36SAndroid Build Coastguard Worker	Args map[string]string
83*333d2b36SAndroid Build Coastguard Worker}
84*333d2b36SAndroid Build Coastguard Worker
85*333d2b36SAndroid Build Coastguard Workertype ModuleBuildParams BuildParams
86*333d2b36SAndroid Build Coastguard Worker
87*333d2b36SAndroid Build Coastguard Workertype ModuleContext interface {
88*333d2b36SAndroid Build Coastguard Worker	BaseModuleContext
89*333d2b36SAndroid Build Coastguard Worker
90*333d2b36SAndroid Build Coastguard Worker	// BlueprintModuleContext returns the blueprint.ModuleContext that the ModuleContext wraps.  It may only be
91*333d2b36SAndroid Build Coastguard Worker	// used by the golang module types that need to call into the bootstrap module types.
92*333d2b36SAndroid Build Coastguard Worker	BlueprintModuleContext() blueprint.ModuleContext
93*333d2b36SAndroid Build Coastguard Worker
94*333d2b36SAndroid Build Coastguard Worker	// Deprecated: use ModuleContext.Build instead.
95*333d2b36SAndroid Build Coastguard Worker	ModuleBuild(pctx PackageContext, params ModuleBuildParams)
96*333d2b36SAndroid Build Coastguard Worker
97*333d2b36SAndroid Build Coastguard Worker	// Returns a list of paths expanded from globs and modules referenced using ":module" syntax.  The property must
98*333d2b36SAndroid Build Coastguard Worker	// be tagged with `android:"path" to support automatic source module dependency resolution.
99*333d2b36SAndroid Build Coastguard Worker	//
100*333d2b36SAndroid Build Coastguard Worker	// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
101*333d2b36SAndroid Build Coastguard Worker	ExpandSources(srcFiles, excludes []string) Paths
102*333d2b36SAndroid Build Coastguard Worker
103*333d2b36SAndroid Build Coastguard Worker	// Returns a single path expanded from globs and modules referenced using ":module" syntax.  The property must
104*333d2b36SAndroid Build Coastguard Worker	// be tagged with `android:"path" to support automatic source module dependency resolution.
105*333d2b36SAndroid Build Coastguard Worker	//
106*333d2b36SAndroid Build Coastguard Worker	// Deprecated: use PathForModuleSrc instead.
107*333d2b36SAndroid Build Coastguard Worker	ExpandSource(srcFile, prop string) Path
108*333d2b36SAndroid Build Coastguard Worker
109*333d2b36SAndroid Build Coastguard Worker	ExpandOptionalSource(srcFile *string, prop string) OptionalPath
110*333d2b36SAndroid Build Coastguard Worker
111*333d2b36SAndroid Build Coastguard Worker	// InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
112*333d2b36SAndroid Build Coastguard Worker	// with the given additional dependencies.  The file is marked executable after copying.
113*333d2b36SAndroid Build Coastguard Worker	//
114*333d2b36SAndroid Build Coastguard Worker	// The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
115*333d2b36SAndroid Build Coastguard Worker	// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
116*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
117*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
118*333d2b36SAndroid Build Coastguard Worker	InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
119*333d2b36SAndroid Build Coastguard Worker
120*333d2b36SAndroid Build Coastguard Worker	// InstallFile creates a rule to copy srcPath to name in the installPath directory,
121*333d2b36SAndroid Build Coastguard Worker	// with the given additional dependencies.
122*333d2b36SAndroid Build Coastguard Worker	//
123*333d2b36SAndroid Build Coastguard Worker	// The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
124*333d2b36SAndroid Build Coastguard Worker	// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
125*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
126*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
127*333d2b36SAndroid Build Coastguard Worker	InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
128*333d2b36SAndroid Build Coastguard Worker
129*333d2b36SAndroid Build Coastguard Worker	// InstallFileWithoutCheckbuild creates a rule to copy srcPath to name in the installPath directory,
130*333d2b36SAndroid Build Coastguard Worker	// with the given additional dependencies, but does not add the file to the list of files to build
131*333d2b36SAndroid Build Coastguard Worker	// during `m checkbuild`.
132*333d2b36SAndroid Build Coastguard Worker	//
133*333d2b36SAndroid Build Coastguard Worker	// The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
134*333d2b36SAndroid Build Coastguard Worker	// installed file will be returned by PackagingSpecs() on this module or by
135*333d2b36SAndroid Build Coastguard Worker	// TransitivePackagingSpecs() on modules that depend on this module through dependency tags
136*333d2b36SAndroid Build Coastguard Worker	// for which IsInstallDepNeeded returns true.
137*333d2b36SAndroid Build Coastguard Worker	InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
138*333d2b36SAndroid Build Coastguard Worker
139*333d2b36SAndroid Build Coastguard Worker	// InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
140*333d2b36SAndroid Build Coastguard Worker	// directory, and also unzip a zip file containing extra files to install into the same
141*333d2b36SAndroid Build Coastguard Worker	// directory.
142*333d2b36SAndroid Build Coastguard Worker	//
143*333d2b36SAndroid Build Coastguard Worker	// The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
144*333d2b36SAndroid Build Coastguard Worker	// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
145*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
146*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
147*333d2b36SAndroid Build Coastguard Worker	InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...InstallPath) InstallPath
148*333d2b36SAndroid Build Coastguard Worker
149*333d2b36SAndroid Build Coastguard Worker	// InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath
150*333d2b36SAndroid Build Coastguard Worker	// directory.
151*333d2b36SAndroid Build Coastguard Worker	//
152*333d2b36SAndroid Build Coastguard Worker	// The installed symlink can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
153*333d2b36SAndroid Build Coastguard Worker	// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
154*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
155*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
156*333d2b36SAndroid Build Coastguard Worker	InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath
157*333d2b36SAndroid Build Coastguard Worker
158*333d2b36SAndroid Build Coastguard Worker	// InstallAbsoluteSymlink creates a rule to create an absolute symlink from src srcPath to name
159*333d2b36SAndroid Build Coastguard Worker	// in the installPath directory.
160*333d2b36SAndroid Build Coastguard Worker	//
161*333d2b36SAndroid Build Coastguard Worker	// The installed symlink can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
162*333d2b36SAndroid Build Coastguard Worker	// for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
163*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
164*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
165*333d2b36SAndroid Build Coastguard Worker	InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
166*333d2b36SAndroid Build Coastguard Worker
167*333d2b36SAndroid Build Coastguard Worker	// InstallTestData creates rules to install test data (e.g. data files used during a test) into
168*333d2b36SAndroid Build Coastguard Worker	// the installPath directory.
169*333d2b36SAndroid Build Coastguard Worker	//
170*333d2b36SAndroid Build Coastguard Worker	// The installed files can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
171*333d2b36SAndroid Build Coastguard Worker	// for the installed files can be accessed by InstallFilesInfo.PackagingSpecs on this module
172*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
173*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
174*333d2b36SAndroid Build Coastguard Worker	InstallTestData(installPath InstallPath, data []DataPath) InstallPaths
175*333d2b36SAndroid Build Coastguard Worker
176*333d2b36SAndroid Build Coastguard Worker	// PackageFile creates a PackagingSpec as if InstallFile was called, but without creating
177*333d2b36SAndroid Build Coastguard Worker	// the rule to copy the file.  This is useful to define how a module would be packaged
178*333d2b36SAndroid Build Coastguard Worker	// without installing it into the global installation directories.
179*333d2b36SAndroid Build Coastguard Worker	//
180*333d2b36SAndroid Build Coastguard Worker	// The created PackagingSpec can be accessed by InstallFilesInfo.PackagingSpecs on this module
181*333d2b36SAndroid Build Coastguard Worker	// or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
182*333d2b36SAndroid Build Coastguard Worker	// dependency tags for which IsInstallDepNeeded returns true.
183*333d2b36SAndroid Build Coastguard Worker	PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec
184*333d2b36SAndroid Build Coastguard Worker
185*333d2b36SAndroid Build Coastguard Worker	CheckbuildFile(srcPaths ...Path)
186*333d2b36SAndroid Build Coastguard Worker	UncheckedModule()
187*333d2b36SAndroid Build Coastguard Worker
188*333d2b36SAndroid Build Coastguard Worker	InstallInData() bool
189*333d2b36SAndroid Build Coastguard Worker	InstallInTestcases() bool
190*333d2b36SAndroid Build Coastguard Worker	InstallInSanitizerDir() bool
191*333d2b36SAndroid Build Coastguard Worker	InstallInRamdisk() bool
192*333d2b36SAndroid Build Coastguard Worker	InstallInVendorRamdisk() bool
193*333d2b36SAndroid Build Coastguard Worker	InstallInDebugRamdisk() bool
194*333d2b36SAndroid Build Coastguard Worker	InstallInRecovery() bool
195*333d2b36SAndroid Build Coastguard Worker	InstallInRoot() bool
196*333d2b36SAndroid Build Coastguard Worker	InstallInOdm() bool
197*333d2b36SAndroid Build Coastguard Worker	InstallInProduct() bool
198*333d2b36SAndroid Build Coastguard Worker	InstallInVendor() bool
199*333d2b36SAndroid Build Coastguard Worker	InstallInSystemDlkm() bool
200*333d2b36SAndroid Build Coastguard Worker	InstallInVendorDlkm() bool
201*333d2b36SAndroid Build Coastguard Worker	InstallInOdmDlkm() bool
202*333d2b36SAndroid Build Coastguard Worker	InstallForceOS() (*OsType, *ArchType)
203*333d2b36SAndroid Build Coastguard Worker
204*333d2b36SAndroid Build Coastguard Worker	RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string
205*333d2b36SAndroid Build Coastguard Worker	HostRequiredModuleNames() []string
206*333d2b36SAndroid Build Coastguard Worker	TargetRequiredModuleNames() []string
207*333d2b36SAndroid Build Coastguard Worker
208*333d2b36SAndroid Build Coastguard Worker	ModuleSubDir() string
209*333d2b36SAndroid Build Coastguard Worker
210*333d2b36SAndroid Build Coastguard Worker	Variable(pctx PackageContext, name, value string)
211*333d2b36SAndroid Build Coastguard Worker	Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
212*333d2b36SAndroid Build Coastguard Worker	// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
213*333d2b36SAndroid Build Coastguard Worker	// and performs more verification.
214*333d2b36SAndroid Build Coastguard Worker	Build(pctx PackageContext, params BuildParams)
215*333d2b36SAndroid Build Coastguard Worker	// Phony creates a Make-style phony rule, a rule with no commands that can depend on other
216*333d2b36SAndroid Build Coastguard Worker	// phony rules or real files.  Phony can be called on the same name multiple times to add
217*333d2b36SAndroid Build Coastguard Worker	// additional dependencies.
218*333d2b36SAndroid Build Coastguard Worker	Phony(phony string, deps ...Path)
219*333d2b36SAndroid Build Coastguard Worker
220*333d2b36SAndroid Build Coastguard Worker	// GetMissingDependencies returns the list of dependencies that were passed to AddDependencies or related methods,
221*333d2b36SAndroid Build Coastguard Worker	// but do not exist.
222*333d2b36SAndroid Build Coastguard Worker	GetMissingDependencies() []string
223*333d2b36SAndroid Build Coastguard Worker
224*333d2b36SAndroid Build Coastguard Worker	// LicenseMetadataFile returns the path where the license metadata for this module will be
225*333d2b36SAndroid Build Coastguard Worker	// generated.
226*333d2b36SAndroid Build Coastguard Worker	LicenseMetadataFile() Path
227*333d2b36SAndroid Build Coastguard Worker
228*333d2b36SAndroid Build Coastguard Worker	// ModuleInfoJSON returns a pointer to the ModuleInfoJSON struct that can be filled out by
229*333d2b36SAndroid Build Coastguard Worker	// GenerateAndroidBuildActions.  If it is called then the struct will be written out and included in
230*333d2b36SAndroid Build Coastguard Worker	// the module-info.json generated by Make, and Make will not generate its own data for this module.
231*333d2b36SAndroid Build Coastguard Worker	ModuleInfoJSON() *ModuleInfoJSON
232*333d2b36SAndroid Build Coastguard Worker
233*333d2b36SAndroid Build Coastguard Worker	// SetOutputFiles stores the outputFiles to outputFiles property, which is used
234*333d2b36SAndroid Build Coastguard Worker	// to set the OutputFilesProvider later.
235*333d2b36SAndroid Build Coastguard Worker	SetOutputFiles(outputFiles Paths, tag string)
236*333d2b36SAndroid Build Coastguard Worker
237*333d2b36SAndroid Build Coastguard Worker	GetOutputFiles() OutputFilesInfo
238*333d2b36SAndroid Build Coastguard Worker
239*333d2b36SAndroid Build Coastguard Worker	// SetLicenseInstallMap stores the set of dependency module:location mappings for files in an
240*333d2b36SAndroid Build Coastguard Worker	// apex container for use when generation the license metadata file.
241*333d2b36SAndroid Build Coastguard Worker	SetLicenseInstallMap(installMap []string)
242*333d2b36SAndroid Build Coastguard Worker
243*333d2b36SAndroid Build Coastguard Worker	// ComplianceMetadataInfo returns a ComplianceMetadataInfo instance for different module types to dump metadata,
244*333d2b36SAndroid Build Coastguard Worker	// which usually happens in GenerateAndroidBuildActions() of a module type.
245*333d2b36SAndroid Build Coastguard Worker	// See android.ModuleBase.complianceMetadataInfo
246*333d2b36SAndroid Build Coastguard Worker	ComplianceMetadataInfo() *ComplianceMetadataInfo
247*333d2b36SAndroid Build Coastguard Worker
248*333d2b36SAndroid Build Coastguard Worker	// Get the information about the containers this module belongs to.
249*333d2b36SAndroid Build Coastguard Worker	getContainersInfo() ContainersInfo
250*333d2b36SAndroid Build Coastguard Worker	setContainersInfo(info ContainersInfo)
251*333d2b36SAndroid Build Coastguard Worker
252*333d2b36SAndroid Build Coastguard Worker	setAconfigPaths(paths Paths)
253*333d2b36SAndroid Build Coastguard Worker}
254*333d2b36SAndroid Build Coastguard Worker
255*333d2b36SAndroid Build Coastguard Workertype moduleContext struct {
256*333d2b36SAndroid Build Coastguard Worker	bp blueprint.ModuleContext
257*333d2b36SAndroid Build Coastguard Worker	baseModuleContext
258*333d2b36SAndroid Build Coastguard Worker	packagingSpecs   []PackagingSpec
259*333d2b36SAndroid Build Coastguard Worker	installFiles     InstallPaths
260*333d2b36SAndroid Build Coastguard Worker	checkbuildFiles  Paths
261*333d2b36SAndroid Build Coastguard Worker	checkbuildTarget Path
262*333d2b36SAndroid Build Coastguard Worker	uncheckedModule  bool
263*333d2b36SAndroid Build Coastguard Worker	module           Module
264*333d2b36SAndroid Build Coastguard Worker	phonies          map[string]Paths
265*333d2b36SAndroid Build Coastguard Worker	// outputFiles stores the output of a module by tag and is used to set
266*333d2b36SAndroid Build Coastguard Worker	// the OutputFilesProvider in GenerateBuildActions
267*333d2b36SAndroid Build Coastguard Worker	outputFiles OutputFilesInfo
268*333d2b36SAndroid Build Coastguard Worker
269*333d2b36SAndroid Build Coastguard Worker	TransitiveInstallFiles depset.DepSet[InstallPath]
270*333d2b36SAndroid Build Coastguard Worker
271*333d2b36SAndroid Build Coastguard Worker	// set of dependency module:location mappings used to populate the license metadata for
272*333d2b36SAndroid Build Coastguard Worker	// apex containers.
273*333d2b36SAndroid Build Coastguard Worker	licenseInstallMap []string
274*333d2b36SAndroid Build Coastguard Worker
275*333d2b36SAndroid Build Coastguard Worker	// The path to the generated license metadata file for the module.
276*333d2b36SAndroid Build Coastguard Worker	licenseMetadataFile WritablePath
277*333d2b36SAndroid Build Coastguard Worker
278*333d2b36SAndroid Build Coastguard Worker	katiInstalls katiInstalls
279*333d2b36SAndroid Build Coastguard Worker	katiSymlinks katiInstalls
280*333d2b36SAndroid Build Coastguard Worker	// katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
281*333d2b36SAndroid Build Coastguard Worker	// allowed to have duplicates across modules and variants.
282*333d2b36SAndroid Build Coastguard Worker	katiInitRcInstalls           katiInstalls
283*333d2b36SAndroid Build Coastguard Worker	katiVintfInstalls            katiInstalls
284*333d2b36SAndroid Build Coastguard Worker	initRcPaths                  Paths
285*333d2b36SAndroid Build Coastguard Worker	vintfFragmentsPaths          Paths
286*333d2b36SAndroid Build Coastguard Worker	installedInitRcPaths         InstallPaths
287*333d2b36SAndroid Build Coastguard Worker	installedVintfFragmentsPaths InstallPaths
288*333d2b36SAndroid Build Coastguard Worker
289*333d2b36SAndroid Build Coastguard Worker	testData []DataPath
290*333d2b36SAndroid Build Coastguard Worker
291*333d2b36SAndroid Build Coastguard Worker	// For tests
292*333d2b36SAndroid Build Coastguard Worker	buildParams []BuildParams
293*333d2b36SAndroid Build Coastguard Worker	ruleParams  map[blueprint.Rule]blueprint.RuleParams
294*333d2b36SAndroid Build Coastguard Worker	variables   map[string]string
295*333d2b36SAndroid Build Coastguard Worker
296*333d2b36SAndroid Build Coastguard Worker	// moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
297*333d2b36SAndroid Build Coastguard Worker	// be included in the final module-info.json produced by Make.
298*333d2b36SAndroid Build Coastguard Worker	moduleInfoJSON *ModuleInfoJSON
299*333d2b36SAndroid Build Coastguard Worker
300*333d2b36SAndroid Build Coastguard Worker	// containersInfo stores the information about the containers and the information of the
301*333d2b36SAndroid Build Coastguard Worker	// apexes the module belongs to.
302*333d2b36SAndroid Build Coastguard Worker	containersInfo ContainersInfo
303*333d2b36SAndroid Build Coastguard Worker
304*333d2b36SAndroid Build Coastguard Worker	// Merged Aconfig files for all transitive deps.
305*333d2b36SAndroid Build Coastguard Worker	aconfigFilePaths Paths
306*333d2b36SAndroid Build Coastguard Worker
307*333d2b36SAndroid Build Coastguard Worker	// complianceMetadataInfo is for different module types to dump metadata.
308*333d2b36SAndroid Build Coastguard Worker	// See android.ModuleContext interface.
309*333d2b36SAndroid Build Coastguard Worker	complianceMetadataInfo *ComplianceMetadataInfo
310*333d2b36SAndroid Build Coastguard Worker}
311*333d2b36SAndroid Build Coastguard Worker
312*333d2b36SAndroid Build Coastguard Workervar _ ModuleContext = &moduleContext{}
313*333d2b36SAndroid Build Coastguard Worker
314*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
315*333d2b36SAndroid Build Coastguard Worker	return pctx, BuildParams{
316*333d2b36SAndroid Build Coastguard Worker		Rule:            ErrorRule,
317*333d2b36SAndroid Build Coastguard Worker		Description:     params.Description,
318*333d2b36SAndroid Build Coastguard Worker		Output:          params.Output,
319*333d2b36SAndroid Build Coastguard Worker		Outputs:         params.Outputs,
320*333d2b36SAndroid Build Coastguard Worker		ImplicitOutput:  params.ImplicitOutput,
321*333d2b36SAndroid Build Coastguard Worker		ImplicitOutputs: params.ImplicitOutputs,
322*333d2b36SAndroid Build Coastguard Worker		Args: map[string]string{
323*333d2b36SAndroid Build Coastguard Worker			"error": err.Error(),
324*333d2b36SAndroid Build Coastguard Worker		},
325*333d2b36SAndroid Build Coastguard Worker	}
326*333d2b36SAndroid Build Coastguard Worker}
327*333d2b36SAndroid Build Coastguard Worker
328*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
329*333d2b36SAndroid Build Coastguard Worker	m.Build(pctx, BuildParams(params))
330*333d2b36SAndroid Build Coastguard Worker}
331*333d2b36SAndroid Build Coastguard Worker
332*333d2b36SAndroid Build Coastguard Worker// Convert build parameters from their concrete Android types into their string representations,
333*333d2b36SAndroid Build Coastguard Worker// and combine the singular and plural fields of the same type (e.g. Output and Outputs).
334*333d2b36SAndroid Build Coastguard Workerfunc convertBuildParams(params BuildParams) blueprint.BuildParams {
335*333d2b36SAndroid Build Coastguard Worker	bparams := blueprint.BuildParams{
336*333d2b36SAndroid Build Coastguard Worker		Rule:            params.Rule,
337*333d2b36SAndroid Build Coastguard Worker		Description:     params.Description,
338*333d2b36SAndroid Build Coastguard Worker		Deps:            params.Deps,
339*333d2b36SAndroid Build Coastguard Worker		Outputs:         params.Outputs.Strings(),
340*333d2b36SAndroid Build Coastguard Worker		ImplicitOutputs: params.ImplicitOutputs.Strings(),
341*333d2b36SAndroid Build Coastguard Worker		Inputs:          params.Inputs.Strings(),
342*333d2b36SAndroid Build Coastguard Worker		Implicits:       params.Implicits.Strings(),
343*333d2b36SAndroid Build Coastguard Worker		OrderOnly:       params.OrderOnly.Strings(),
344*333d2b36SAndroid Build Coastguard Worker		Validations:     params.Validations.Strings(),
345*333d2b36SAndroid Build Coastguard Worker		Args:            params.Args,
346*333d2b36SAndroid Build Coastguard Worker		Optional:        !params.Default,
347*333d2b36SAndroid Build Coastguard Worker	}
348*333d2b36SAndroid Build Coastguard Worker
349*333d2b36SAndroid Build Coastguard Worker	if params.Depfile != nil {
350*333d2b36SAndroid Build Coastguard Worker		bparams.Depfile = params.Depfile.String()
351*333d2b36SAndroid Build Coastguard Worker	}
352*333d2b36SAndroid Build Coastguard Worker	if params.Output != nil {
353*333d2b36SAndroid Build Coastguard Worker		bparams.Outputs = append(bparams.Outputs, params.Output.String())
354*333d2b36SAndroid Build Coastguard Worker	}
355*333d2b36SAndroid Build Coastguard Worker	if params.ImplicitOutput != nil {
356*333d2b36SAndroid Build Coastguard Worker		bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
357*333d2b36SAndroid Build Coastguard Worker	}
358*333d2b36SAndroid Build Coastguard Worker	if params.Input != nil {
359*333d2b36SAndroid Build Coastguard Worker		bparams.Inputs = append(bparams.Inputs, params.Input.String())
360*333d2b36SAndroid Build Coastguard Worker	}
361*333d2b36SAndroid Build Coastguard Worker	if params.Implicit != nil {
362*333d2b36SAndroid Build Coastguard Worker		bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
363*333d2b36SAndroid Build Coastguard Worker	}
364*333d2b36SAndroid Build Coastguard Worker	if params.Validation != nil {
365*333d2b36SAndroid Build Coastguard Worker		bparams.Validations = append(bparams.Validations, params.Validation.String())
366*333d2b36SAndroid Build Coastguard Worker	}
367*333d2b36SAndroid Build Coastguard Worker
368*333d2b36SAndroid Build Coastguard Worker	bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
369*333d2b36SAndroid Build Coastguard Worker	bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
370*333d2b36SAndroid Build Coastguard Worker	bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
371*333d2b36SAndroid Build Coastguard Worker	bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
372*333d2b36SAndroid Build Coastguard Worker	bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
373*333d2b36SAndroid Build Coastguard Worker	bparams.Validations = proptools.NinjaEscapeList(bparams.Validations)
374*333d2b36SAndroid Build Coastguard Worker	bparams.Depfile = proptools.NinjaEscape(bparams.Depfile)
375*333d2b36SAndroid Build Coastguard Worker
376*333d2b36SAndroid Build Coastguard Worker	return bparams
377*333d2b36SAndroid Build Coastguard Worker}
378*333d2b36SAndroid Build Coastguard Worker
379*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) Variable(pctx PackageContext, name, value string) {
380*333d2b36SAndroid Build Coastguard Worker	if m.config.captureBuild {
381*333d2b36SAndroid Build Coastguard Worker		m.variables[name] = value
382*333d2b36SAndroid Build Coastguard Worker	}
383*333d2b36SAndroid Build Coastguard Worker
384*333d2b36SAndroid Build Coastguard Worker	m.bp.Variable(pctx.PackageContext, name, value)
385*333d2b36SAndroid Build Coastguard Worker}
386*333d2b36SAndroid Build Coastguard Worker
387*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
388*333d2b36SAndroid Build Coastguard Worker	argNames ...string) blueprint.Rule {
389*333d2b36SAndroid Build Coastguard Worker
390*333d2b36SAndroid Build Coastguard Worker	if m.config.UseRemoteBuild() {
391*333d2b36SAndroid Build Coastguard Worker		if params.Pool == nil {
392*333d2b36SAndroid Build Coastguard Worker			// When USE_GOMA=true or USE_RBE=true are set and the rule is not supported by goma/RBE, restrict
393*333d2b36SAndroid Build Coastguard Worker			// jobs to the local parallelism value
394*333d2b36SAndroid Build Coastguard Worker			params.Pool = localPool
395*333d2b36SAndroid Build Coastguard Worker		} else if params.Pool == remotePool {
396*333d2b36SAndroid Build Coastguard Worker			// remotePool is a fake pool used to identify rule that are supported for remoting. If the rule's
397*333d2b36SAndroid Build Coastguard Worker			// pool is the remotePool, replace with nil so that ninja runs it at NINJA_REMOTE_NUM_JOBS
398*333d2b36SAndroid Build Coastguard Worker			// parallelism.
399*333d2b36SAndroid Build Coastguard Worker			params.Pool = nil
400*333d2b36SAndroid Build Coastguard Worker		}
401*333d2b36SAndroid Build Coastguard Worker	}
402*333d2b36SAndroid Build Coastguard Worker
403*333d2b36SAndroid Build Coastguard Worker	rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
404*333d2b36SAndroid Build Coastguard Worker
405*333d2b36SAndroid Build Coastguard Worker	if m.config.captureBuild {
406*333d2b36SAndroid Build Coastguard Worker		m.ruleParams[rule] = params
407*333d2b36SAndroid Build Coastguard Worker	}
408*333d2b36SAndroid Build Coastguard Worker
409*333d2b36SAndroid Build Coastguard Worker	return rule
410*333d2b36SAndroid Build Coastguard Worker}
411*333d2b36SAndroid Build Coastguard Worker
412*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
413*333d2b36SAndroid Build Coastguard Worker	if params.Description != "" {
414*333d2b36SAndroid Build Coastguard Worker		params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
415*333d2b36SAndroid Build Coastguard Worker	}
416*333d2b36SAndroid Build Coastguard Worker
417*333d2b36SAndroid Build Coastguard Worker	if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 {
418*333d2b36SAndroid Build Coastguard Worker		pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n",
419*333d2b36SAndroid Build Coastguard Worker			m.ModuleName(), strings.Join(missingDeps, ", ")))
420*333d2b36SAndroid Build Coastguard Worker	}
421*333d2b36SAndroid Build Coastguard Worker
422*333d2b36SAndroid Build Coastguard Worker	if m.config.captureBuild {
423*333d2b36SAndroid Build Coastguard Worker		m.buildParams = append(m.buildParams, params)
424*333d2b36SAndroid Build Coastguard Worker	}
425*333d2b36SAndroid Build Coastguard Worker
426*333d2b36SAndroid Build Coastguard Worker	bparams := convertBuildParams(params)
427*333d2b36SAndroid Build Coastguard Worker	m.bp.Build(pctx.PackageContext, bparams)
428*333d2b36SAndroid Build Coastguard Worker}
429*333d2b36SAndroid Build Coastguard Worker
430*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) Phony(name string, deps ...Path) {
431*333d2b36SAndroid Build Coastguard Worker	m.phonies[name] = append(m.phonies[name], deps...)
432*333d2b36SAndroid Build Coastguard Worker}
433*333d2b36SAndroid Build Coastguard Worker
434*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) GetMissingDependencies() []string {
435*333d2b36SAndroid Build Coastguard Worker	var missingDeps []string
436*333d2b36SAndroid Build Coastguard Worker	missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
437*333d2b36SAndroid Build Coastguard Worker	missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
438*333d2b36SAndroid Build Coastguard Worker	missingDeps = FirstUniqueStrings(missingDeps)
439*333d2b36SAndroid Build Coastguard Worker	return missingDeps
440*333d2b36SAndroid Build Coastguard Worker}
441*333d2b36SAndroid Build Coastguard Worker
442*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module {
443*333d2b36SAndroid Build Coastguard Worker	if module, _ := m.getDirectDepInternal(name, tag); module != nil {
444*333d2b36SAndroid Build Coastguard Worker		return module.(Module)
445*333d2b36SAndroid Build Coastguard Worker	}
446*333d2b36SAndroid Build Coastguard Worker	return nil
447*333d2b36SAndroid Build Coastguard Worker}
448*333d2b36SAndroid Build Coastguard Worker
449*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ModuleSubDir() string {
450*333d2b36SAndroid Build Coastguard Worker	return m.bp.ModuleSubDir()
451*333d2b36SAndroid Build Coastguard Worker}
452*333d2b36SAndroid Build Coastguard Worker
453*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInData() bool {
454*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInData()
455*333d2b36SAndroid Build Coastguard Worker}
456*333d2b36SAndroid Build Coastguard Worker
457*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInTestcases() bool {
458*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInTestcases()
459*333d2b36SAndroid Build Coastguard Worker}
460*333d2b36SAndroid Build Coastguard Worker
461*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInSanitizerDir() bool {
462*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInSanitizerDir()
463*333d2b36SAndroid Build Coastguard Worker}
464*333d2b36SAndroid Build Coastguard Worker
465*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInRamdisk() bool {
466*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInRamdisk()
467*333d2b36SAndroid Build Coastguard Worker}
468*333d2b36SAndroid Build Coastguard Worker
469*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInVendorRamdisk() bool {
470*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInVendorRamdisk()
471*333d2b36SAndroid Build Coastguard Worker}
472*333d2b36SAndroid Build Coastguard Worker
473*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInDebugRamdisk() bool {
474*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInDebugRamdisk()
475*333d2b36SAndroid Build Coastguard Worker}
476*333d2b36SAndroid Build Coastguard Worker
477*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInRecovery() bool {
478*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInRecovery()
479*333d2b36SAndroid Build Coastguard Worker}
480*333d2b36SAndroid Build Coastguard Worker
481*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInRoot() bool {
482*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInRoot()
483*333d2b36SAndroid Build Coastguard Worker}
484*333d2b36SAndroid Build Coastguard Worker
485*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
486*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallForceOS()
487*333d2b36SAndroid Build Coastguard Worker}
488*333d2b36SAndroid Build Coastguard Worker
489*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInOdm() bool {
490*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInOdm()
491*333d2b36SAndroid Build Coastguard Worker}
492*333d2b36SAndroid Build Coastguard Worker
493*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInProduct() bool {
494*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInProduct()
495*333d2b36SAndroid Build Coastguard Worker}
496*333d2b36SAndroid Build Coastguard Worker
497*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInVendor() bool {
498*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInVendor()
499*333d2b36SAndroid Build Coastguard Worker}
500*333d2b36SAndroid Build Coastguard Worker
501*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInSystemDlkm() bool {
502*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInSystemDlkm()
503*333d2b36SAndroid Build Coastguard Worker}
504*333d2b36SAndroid Build Coastguard Worker
505*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInVendorDlkm() bool {
506*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInVendorDlkm()
507*333d2b36SAndroid Build Coastguard Worker}
508*333d2b36SAndroid Build Coastguard Worker
509*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallInOdmDlkm() bool {
510*333d2b36SAndroid Build Coastguard Worker	return m.module.InstallInOdmDlkm()
511*333d2b36SAndroid Build Coastguard Worker}
512*333d2b36SAndroid Build Coastguard Worker
513*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) skipInstall() bool {
514*333d2b36SAndroid Build Coastguard Worker	if m.module.base().commonProperties.SkipInstall {
515*333d2b36SAndroid Build Coastguard Worker		return true
516*333d2b36SAndroid Build Coastguard Worker	}
517*333d2b36SAndroid Build Coastguard Worker
518*333d2b36SAndroid Build Coastguard Worker	// We'll need a solution for choosing which of modules with the same name in different
519*333d2b36SAndroid Build Coastguard Worker	// namespaces to install.  For now, reuse the list of namespaces exported to Make as the
520*333d2b36SAndroid Build Coastguard Worker	// list of namespaces to install in a Soong-only build.
521*333d2b36SAndroid Build Coastguard Worker	if !m.module.base().commonProperties.NamespaceExportedToMake {
522*333d2b36SAndroid Build Coastguard Worker		return true
523*333d2b36SAndroid Build Coastguard Worker	}
524*333d2b36SAndroid Build Coastguard Worker
525*333d2b36SAndroid Build Coastguard Worker	return false
526*333d2b36SAndroid Build Coastguard Worker}
527*333d2b36SAndroid Build Coastguard Worker
528*333d2b36SAndroid Build Coastguard Worker// Tells whether this module is installed to the full install path (ex:
529*333d2b36SAndroid Build Coastguard Worker// out/target/product/<name>/<partition>) or not. If this returns false, the install build rule is
530*333d2b36SAndroid Build Coastguard Worker// not created and this module can only be installed to packaging modules like android_filesystem.
531*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) requiresFullInstall() bool {
532*333d2b36SAndroid Build Coastguard Worker	if m.skipInstall() {
533*333d2b36SAndroid Build Coastguard Worker		return false
534*333d2b36SAndroid Build Coastguard Worker	}
535*333d2b36SAndroid Build Coastguard Worker
536*333d2b36SAndroid Build Coastguard Worker	if m.module.base().commonProperties.HideFromMake {
537*333d2b36SAndroid Build Coastguard Worker		return false
538*333d2b36SAndroid Build Coastguard Worker	}
539*333d2b36SAndroid Build Coastguard Worker
540*333d2b36SAndroid Build Coastguard Worker	if proptools.Bool(m.module.base().commonProperties.No_full_install) {
541*333d2b36SAndroid Build Coastguard Worker		return false
542*333d2b36SAndroid Build Coastguard Worker	}
543*333d2b36SAndroid Build Coastguard Worker
544*333d2b36SAndroid Build Coastguard Worker	return true
545*333d2b36SAndroid Build Coastguard Worker}
546*333d2b36SAndroid Build Coastguard Worker
547*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
548*333d2b36SAndroid Build Coastguard Worker	deps ...InstallPath) InstallPath {
549*333d2b36SAndroid Build Coastguard Worker	return m.installFile(installPath, name, srcPath, deps, false, true, true, nil)
550*333d2b36SAndroid Build Coastguard Worker}
551*333d2b36SAndroid Build Coastguard Worker
552*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path,
553*333d2b36SAndroid Build Coastguard Worker	deps ...InstallPath) InstallPath {
554*333d2b36SAndroid Build Coastguard Worker	return m.installFile(installPath, name, srcPath, deps, false, true, false, nil)
555*333d2b36SAndroid Build Coastguard Worker}
556*333d2b36SAndroid Build Coastguard Worker
557*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
558*333d2b36SAndroid Build Coastguard Worker	deps ...InstallPath) InstallPath {
559*333d2b36SAndroid Build Coastguard Worker	return m.installFile(installPath, name, srcPath, deps, true, true, true, nil)
560*333d2b36SAndroid Build Coastguard Worker}
561*333d2b36SAndroid Build Coastguard Worker
562*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
563*333d2b36SAndroid Build Coastguard Worker	extraZip Path, deps ...InstallPath) InstallPath {
564*333d2b36SAndroid Build Coastguard Worker	return m.installFile(installPath, name, srcPath, deps, false, true, true, &extraFilesZip{
565*333d2b36SAndroid Build Coastguard Worker		zip: extraZip,
566*333d2b36SAndroid Build Coastguard Worker		dir: installPath,
567*333d2b36SAndroid Build Coastguard Worker	})
568*333d2b36SAndroid Build Coastguard Worker}
569*333d2b36SAndroid Build Coastguard Worker
570*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
571*333d2b36SAndroid Build Coastguard Worker	fullInstallPath := installPath.Join(m, name)
572*333d2b36SAndroid Build Coastguard Worker	return m.packageFile(fullInstallPath, srcPath, false)
573*333d2b36SAndroid Build Coastguard Worker}
574*333d2b36SAndroid Build Coastguard Worker
575*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) getAconfigPaths() *Paths {
576*333d2b36SAndroid Build Coastguard Worker	return &m.aconfigFilePaths
577*333d2b36SAndroid Build Coastguard Worker}
578*333d2b36SAndroid Build Coastguard Worker
579*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) setAconfigPaths(paths Paths) {
580*333d2b36SAndroid Build Coastguard Worker	m.aconfigFilePaths = paths
581*333d2b36SAndroid Build Coastguard Worker}
582*333d2b36SAndroid Build Coastguard Worker
583*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) getOwnerAndOverrides() (string, []string) {
584*333d2b36SAndroid Build Coastguard Worker	owner := m.ModuleName()
585*333d2b36SAndroid Build Coastguard Worker	overrides := slices.Clone(m.Module().base().commonProperties.Overrides)
586*333d2b36SAndroid Build Coastguard Worker	if b, ok := m.Module().(OverridableModule); ok {
587*333d2b36SAndroid Build Coastguard Worker		if b.GetOverriddenBy() != "" {
588*333d2b36SAndroid Build Coastguard Worker			// overriding variant of base module
589*333d2b36SAndroid Build Coastguard Worker			overrides = append(overrides, m.ModuleName()) // com.android.foo
590*333d2b36SAndroid Build Coastguard Worker			owner = m.Module().Name()                     // com.company.android.foo
591*333d2b36SAndroid Build Coastguard Worker		}
592*333d2b36SAndroid Build Coastguard Worker	}
593*333d2b36SAndroid Build Coastguard Worker	return owner, overrides
594*333d2b36SAndroid Build Coastguard Worker}
595*333d2b36SAndroid Build Coastguard Worker
596*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec {
597*333d2b36SAndroid Build Coastguard Worker	licenseFiles := m.Module().EffectiveLicenseFiles()
598*333d2b36SAndroid Build Coastguard Worker	owner, overrides := m.getOwnerAndOverrides()
599*333d2b36SAndroid Build Coastguard Worker	spec := PackagingSpec{
600*333d2b36SAndroid Build Coastguard Worker		relPathInPackage:      Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
601*333d2b36SAndroid Build Coastguard Worker		srcPath:               srcPath,
602*333d2b36SAndroid Build Coastguard Worker		symlinkTarget:         "",
603*333d2b36SAndroid Build Coastguard Worker		executable:            executable,
604*333d2b36SAndroid Build Coastguard Worker		effectiveLicenseFiles: &licenseFiles,
605*333d2b36SAndroid Build Coastguard Worker		partition:             fullInstallPath.partition,
606*333d2b36SAndroid Build Coastguard Worker		skipInstall:           m.skipInstall(),
607*333d2b36SAndroid Build Coastguard Worker		aconfigPaths:          m.getAconfigPaths(),
608*333d2b36SAndroid Build Coastguard Worker		archType:              m.target.Arch.ArchType,
609*333d2b36SAndroid Build Coastguard Worker		overrides:             &overrides,
610*333d2b36SAndroid Build Coastguard Worker		owner:                 owner,
611*333d2b36SAndroid Build Coastguard Worker	}
612*333d2b36SAndroid Build Coastguard Worker	m.packagingSpecs = append(m.packagingSpecs, spec)
613*333d2b36SAndroid Build Coastguard Worker	return spec
614*333d2b36SAndroid Build Coastguard Worker}
615*333d2b36SAndroid Build Coastguard Worker
616*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
617*333d2b36SAndroid Build Coastguard Worker	executable bool, hooks bool, checkbuild bool, extraZip *extraFilesZip) InstallPath {
618*333d2b36SAndroid Build Coastguard Worker
619*333d2b36SAndroid Build Coastguard Worker	fullInstallPath := installPath.Join(m, name)
620*333d2b36SAndroid Build Coastguard Worker	if hooks {
621*333d2b36SAndroid Build Coastguard Worker		m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
622*333d2b36SAndroid Build Coastguard Worker	}
623*333d2b36SAndroid Build Coastguard Worker
624*333d2b36SAndroid Build Coastguard Worker	if m.requiresFullInstall() {
625*333d2b36SAndroid Build Coastguard Worker		deps = append(deps, InstallPaths(m.TransitiveInstallFiles.ToList())...)
626*333d2b36SAndroid Build Coastguard Worker		deps = append(deps, m.installedInitRcPaths...)
627*333d2b36SAndroid Build Coastguard Worker		deps = append(deps, m.installedVintfFragmentsPaths...)
628*333d2b36SAndroid Build Coastguard Worker
629*333d2b36SAndroid Build Coastguard Worker		var implicitDeps, orderOnlyDeps Paths
630*333d2b36SAndroid Build Coastguard Worker
631*333d2b36SAndroid Build Coastguard Worker		if m.Host() {
632*333d2b36SAndroid Build Coastguard Worker			// Installed host modules might be used during the build, depend directly on their
633*333d2b36SAndroid Build Coastguard Worker			// dependencies so their timestamp is updated whenever their dependency is updated
634*333d2b36SAndroid Build Coastguard Worker			implicitDeps = InstallPaths(deps).Paths()
635*333d2b36SAndroid Build Coastguard Worker		} else {
636*333d2b36SAndroid Build Coastguard Worker			orderOnlyDeps = InstallPaths(deps).Paths()
637*333d2b36SAndroid Build Coastguard Worker		}
638*333d2b36SAndroid Build Coastguard Worker
639*333d2b36SAndroid Build Coastguard Worker		if m.Config().KatiEnabled() {
640*333d2b36SAndroid Build Coastguard Worker			// When creating the install rule in Soong but embedding in Make, write the rule to a
641*333d2b36SAndroid Build Coastguard Worker			// makefile instead of directly to the ninja file so that main.mk can add the
642*333d2b36SAndroid Build Coastguard Worker			// dependencies from the `required` property that are hard to resolve in Soong.
643*333d2b36SAndroid Build Coastguard Worker			m.katiInstalls = append(m.katiInstalls, katiInstall{
644*333d2b36SAndroid Build Coastguard Worker				from:          srcPath,
645*333d2b36SAndroid Build Coastguard Worker				to:            fullInstallPath,
646*333d2b36SAndroid Build Coastguard Worker				implicitDeps:  implicitDeps,
647*333d2b36SAndroid Build Coastguard Worker				orderOnlyDeps: orderOnlyDeps,
648*333d2b36SAndroid Build Coastguard Worker				executable:    executable,
649*333d2b36SAndroid Build Coastguard Worker				extraFiles:    extraZip,
650*333d2b36SAndroid Build Coastguard Worker			})
651*333d2b36SAndroid Build Coastguard Worker		} else {
652*333d2b36SAndroid Build Coastguard Worker			rule := Cp
653*333d2b36SAndroid Build Coastguard Worker			if executable {
654*333d2b36SAndroid Build Coastguard Worker				rule = CpExecutable
655*333d2b36SAndroid Build Coastguard Worker			}
656*333d2b36SAndroid Build Coastguard Worker
657*333d2b36SAndroid Build Coastguard Worker			extraCmds := ""
658*333d2b36SAndroid Build Coastguard Worker			if extraZip != nil {
659*333d2b36SAndroid Build Coastguard Worker				extraCmds += fmt.Sprintf(" && ( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} )",
660*333d2b36SAndroid Build Coastguard Worker					extraZip.dir.String(), extraZip.zip.String())
661*333d2b36SAndroid Build Coastguard Worker				extraCmds += " || ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )"
662*333d2b36SAndroid Build Coastguard Worker				implicitDeps = append(implicitDeps, extraZip.zip)
663*333d2b36SAndroid Build Coastguard Worker			}
664*333d2b36SAndroid Build Coastguard Worker
665*333d2b36SAndroid Build Coastguard Worker			m.Build(pctx, BuildParams{
666*333d2b36SAndroid Build Coastguard Worker				Rule:        rule,
667*333d2b36SAndroid Build Coastguard Worker				Description: "install " + fullInstallPath.Base(),
668*333d2b36SAndroid Build Coastguard Worker				Output:      fullInstallPath,
669*333d2b36SAndroid Build Coastguard Worker				Input:       srcPath,
670*333d2b36SAndroid Build Coastguard Worker				Implicits:   implicitDeps,
671*333d2b36SAndroid Build Coastguard Worker				OrderOnly:   orderOnlyDeps,
672*333d2b36SAndroid Build Coastguard Worker				Default:     !m.Config().KatiEnabled(),
673*333d2b36SAndroid Build Coastguard Worker				Args: map[string]string{
674*333d2b36SAndroid Build Coastguard Worker					"extraCmds": extraCmds,
675*333d2b36SAndroid Build Coastguard Worker				},
676*333d2b36SAndroid Build Coastguard Worker			})
677*333d2b36SAndroid Build Coastguard Worker		}
678*333d2b36SAndroid Build Coastguard Worker
679*333d2b36SAndroid Build Coastguard Worker		m.installFiles = append(m.installFiles, fullInstallPath)
680*333d2b36SAndroid Build Coastguard Worker	}
681*333d2b36SAndroid Build Coastguard Worker
682*333d2b36SAndroid Build Coastguard Worker	m.packageFile(fullInstallPath, srcPath, executable)
683*333d2b36SAndroid Build Coastguard Worker
684*333d2b36SAndroid Build Coastguard Worker	if checkbuild {
685*333d2b36SAndroid Build Coastguard Worker		m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
686*333d2b36SAndroid Build Coastguard Worker	}
687*333d2b36SAndroid Build Coastguard Worker
688*333d2b36SAndroid Build Coastguard Worker	return fullInstallPath
689*333d2b36SAndroid Build Coastguard Worker}
690*333d2b36SAndroid Build Coastguard Worker
691*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
692*333d2b36SAndroid Build Coastguard Worker	fullInstallPath := installPath.Join(m, name)
693*333d2b36SAndroid Build Coastguard Worker	m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, true)
694*333d2b36SAndroid Build Coastguard Worker
695*333d2b36SAndroid Build Coastguard Worker	relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
696*333d2b36SAndroid Build Coastguard Worker	if err != nil {
697*333d2b36SAndroid Build Coastguard Worker		panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
698*333d2b36SAndroid Build Coastguard Worker	}
699*333d2b36SAndroid Build Coastguard Worker	if m.requiresFullInstall() {
700*333d2b36SAndroid Build Coastguard Worker
701*333d2b36SAndroid Build Coastguard Worker		if m.Config().KatiEnabled() {
702*333d2b36SAndroid Build Coastguard Worker			// When creating the symlink rule in Soong but embedding in Make, write the rule to a
703*333d2b36SAndroid Build Coastguard Worker			// makefile instead of directly to the ninja file so that main.mk can add the
704*333d2b36SAndroid Build Coastguard Worker			// dependencies from the `required` property that are hard to resolve in Soong.
705*333d2b36SAndroid Build Coastguard Worker			m.katiSymlinks = append(m.katiSymlinks, katiInstall{
706*333d2b36SAndroid Build Coastguard Worker				from: srcPath,
707*333d2b36SAndroid Build Coastguard Worker				to:   fullInstallPath,
708*333d2b36SAndroid Build Coastguard Worker			})
709*333d2b36SAndroid Build Coastguard Worker		} else {
710*333d2b36SAndroid Build Coastguard Worker			// The symlink doesn't need updating when the target is modified, but we sometimes
711*333d2b36SAndroid Build Coastguard Worker			// have a dependency on a symlink to a binary instead of to the binary directly, and
712*333d2b36SAndroid Build Coastguard Worker			// the mtime of the symlink must be updated when the binary is modified, so use a
713*333d2b36SAndroid Build Coastguard Worker			// normal dependency here instead of an order-only dependency.
714*333d2b36SAndroid Build Coastguard Worker			m.Build(pctx, BuildParams{
715*333d2b36SAndroid Build Coastguard Worker				Rule:        Symlink,
716*333d2b36SAndroid Build Coastguard Worker				Description: "install symlink " + fullInstallPath.Base(),
717*333d2b36SAndroid Build Coastguard Worker				Output:      fullInstallPath,
718*333d2b36SAndroid Build Coastguard Worker				Input:       srcPath,
719*333d2b36SAndroid Build Coastguard Worker				Default:     !m.Config().KatiEnabled(),
720*333d2b36SAndroid Build Coastguard Worker				Args: map[string]string{
721*333d2b36SAndroid Build Coastguard Worker					"fromPath": relPath,
722*333d2b36SAndroid Build Coastguard Worker				},
723*333d2b36SAndroid Build Coastguard Worker			})
724*333d2b36SAndroid Build Coastguard Worker		}
725*333d2b36SAndroid Build Coastguard Worker
726*333d2b36SAndroid Build Coastguard Worker		m.installFiles = append(m.installFiles, fullInstallPath)
727*333d2b36SAndroid Build Coastguard Worker	}
728*333d2b36SAndroid Build Coastguard Worker
729*333d2b36SAndroid Build Coastguard Worker	owner, overrides := m.getOwnerAndOverrides()
730*333d2b36SAndroid Build Coastguard Worker	m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
731*333d2b36SAndroid Build Coastguard Worker		relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
732*333d2b36SAndroid Build Coastguard Worker		srcPath:          nil,
733*333d2b36SAndroid Build Coastguard Worker		symlinkTarget:    relPath,
734*333d2b36SAndroid Build Coastguard Worker		executable:       false,
735*333d2b36SAndroid Build Coastguard Worker		partition:        fullInstallPath.partition,
736*333d2b36SAndroid Build Coastguard Worker		skipInstall:      m.skipInstall(),
737*333d2b36SAndroid Build Coastguard Worker		aconfigPaths:     m.getAconfigPaths(),
738*333d2b36SAndroid Build Coastguard Worker		archType:         m.target.Arch.ArchType,
739*333d2b36SAndroid Build Coastguard Worker		overrides:        &overrides,
740*333d2b36SAndroid Build Coastguard Worker		owner:            owner,
741*333d2b36SAndroid Build Coastguard Worker	})
742*333d2b36SAndroid Build Coastguard Worker
743*333d2b36SAndroid Build Coastguard Worker	return fullInstallPath
744*333d2b36SAndroid Build Coastguard Worker}
745*333d2b36SAndroid Build Coastguard Worker
746*333d2b36SAndroid Build Coastguard Worker// installPath/name -> absPath where absPath might be a path that is available only at runtime
747*333d2b36SAndroid Build Coastguard Worker// (e.g. /apex/...)
748*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
749*333d2b36SAndroid Build Coastguard Worker	fullInstallPath := installPath.Join(m, name)
750*333d2b36SAndroid Build Coastguard Worker	m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
751*333d2b36SAndroid Build Coastguard Worker
752*333d2b36SAndroid Build Coastguard Worker	if m.requiresFullInstall() {
753*333d2b36SAndroid Build Coastguard Worker		if m.Config().KatiEnabled() {
754*333d2b36SAndroid Build Coastguard Worker			// When creating the symlink rule in Soong but embedding in Make, write the rule to a
755*333d2b36SAndroid Build Coastguard Worker			// makefile instead of directly to the ninja file so that main.mk can add the
756*333d2b36SAndroid Build Coastguard Worker			// dependencies from the `required` property that are hard to resolve in Soong.
757*333d2b36SAndroid Build Coastguard Worker			m.katiSymlinks = append(m.katiSymlinks, katiInstall{
758*333d2b36SAndroid Build Coastguard Worker				absFrom: absPath,
759*333d2b36SAndroid Build Coastguard Worker				to:      fullInstallPath,
760*333d2b36SAndroid Build Coastguard Worker			})
761*333d2b36SAndroid Build Coastguard Worker		} else {
762*333d2b36SAndroid Build Coastguard Worker			m.Build(pctx, BuildParams{
763*333d2b36SAndroid Build Coastguard Worker				Rule:        Symlink,
764*333d2b36SAndroid Build Coastguard Worker				Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
765*333d2b36SAndroid Build Coastguard Worker				Output:      fullInstallPath,
766*333d2b36SAndroid Build Coastguard Worker				Default:     !m.Config().KatiEnabled(),
767*333d2b36SAndroid Build Coastguard Worker				Args: map[string]string{
768*333d2b36SAndroid Build Coastguard Worker					"fromPath": absPath,
769*333d2b36SAndroid Build Coastguard Worker				},
770*333d2b36SAndroid Build Coastguard Worker			})
771*333d2b36SAndroid Build Coastguard Worker		}
772*333d2b36SAndroid Build Coastguard Worker
773*333d2b36SAndroid Build Coastguard Worker		m.installFiles = append(m.installFiles, fullInstallPath)
774*333d2b36SAndroid Build Coastguard Worker	}
775*333d2b36SAndroid Build Coastguard Worker
776*333d2b36SAndroid Build Coastguard Worker	owner, overrides := m.getOwnerAndOverrides()
777*333d2b36SAndroid Build Coastguard Worker	m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
778*333d2b36SAndroid Build Coastguard Worker		relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
779*333d2b36SAndroid Build Coastguard Worker		srcPath:          nil,
780*333d2b36SAndroid Build Coastguard Worker		symlinkTarget:    absPath,
781*333d2b36SAndroid Build Coastguard Worker		executable:       false,
782*333d2b36SAndroid Build Coastguard Worker		partition:        fullInstallPath.partition,
783*333d2b36SAndroid Build Coastguard Worker		skipInstall:      m.skipInstall(),
784*333d2b36SAndroid Build Coastguard Worker		aconfigPaths:     m.getAconfigPaths(),
785*333d2b36SAndroid Build Coastguard Worker		archType:         m.target.Arch.ArchType,
786*333d2b36SAndroid Build Coastguard Worker		overrides:        &overrides,
787*333d2b36SAndroid Build Coastguard Worker		owner:            owner,
788*333d2b36SAndroid Build Coastguard Worker	})
789*333d2b36SAndroid Build Coastguard Worker
790*333d2b36SAndroid Build Coastguard Worker	return fullInstallPath
791*333d2b36SAndroid Build Coastguard Worker}
792*333d2b36SAndroid Build Coastguard Worker
793*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) InstallTestData(installPath InstallPath, data []DataPath) InstallPaths {
794*333d2b36SAndroid Build Coastguard Worker	m.testData = append(m.testData, data...)
795*333d2b36SAndroid Build Coastguard Worker
796*333d2b36SAndroid Build Coastguard Worker	ret := make(InstallPaths, 0, len(data))
797*333d2b36SAndroid Build Coastguard Worker	for _, d := range data {
798*333d2b36SAndroid Build Coastguard Worker		relPath := d.ToRelativeInstallPath()
799*333d2b36SAndroid Build Coastguard Worker		installed := m.installFile(installPath, relPath, d.SrcPath, nil, false, false, true, nil)
800*333d2b36SAndroid Build Coastguard Worker		ret = append(ret, installed)
801*333d2b36SAndroid Build Coastguard Worker	}
802*333d2b36SAndroid Build Coastguard Worker
803*333d2b36SAndroid Build Coastguard Worker	return ret
804*333d2b36SAndroid Build Coastguard Worker}
805*333d2b36SAndroid Build Coastguard Worker
806*333d2b36SAndroid Build Coastguard Worker// CheckbuildFile specifies the output files that should be built by checkbuild.
807*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) CheckbuildFile(srcPaths ...Path) {
808*333d2b36SAndroid Build Coastguard Worker	m.checkbuildFiles = append(m.checkbuildFiles, srcPaths...)
809*333d2b36SAndroid Build Coastguard Worker}
810*333d2b36SAndroid Build Coastguard Worker
811*333d2b36SAndroid Build Coastguard Worker// UncheckedModule marks the current module has having no files that should be built by checkbuild.
812*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) UncheckedModule() {
813*333d2b36SAndroid Build Coastguard Worker	m.uncheckedModule = true
814*333d2b36SAndroid Build Coastguard Worker}
815*333d2b36SAndroid Build Coastguard Worker
816*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) BlueprintModuleContext() blueprint.ModuleContext {
817*333d2b36SAndroid Build Coastguard Worker	return m.bp
818*333d2b36SAndroid Build Coastguard Worker}
819*333d2b36SAndroid Build Coastguard Worker
820*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) LicenseMetadataFile() Path {
821*333d2b36SAndroid Build Coastguard Worker	return m.licenseMetadataFile
822*333d2b36SAndroid Build Coastguard Worker}
823*333d2b36SAndroid Build Coastguard Worker
824*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ModuleInfoJSON() *ModuleInfoJSON {
825*333d2b36SAndroid Build Coastguard Worker	if moduleInfoJSON := m.moduleInfoJSON; moduleInfoJSON != nil {
826*333d2b36SAndroid Build Coastguard Worker		return moduleInfoJSON
827*333d2b36SAndroid Build Coastguard Worker	}
828*333d2b36SAndroid Build Coastguard Worker	moduleInfoJSON := &ModuleInfoJSON{}
829*333d2b36SAndroid Build Coastguard Worker	m.moduleInfoJSON = moduleInfoJSON
830*333d2b36SAndroid Build Coastguard Worker	return moduleInfoJSON
831*333d2b36SAndroid Build Coastguard Worker}
832*333d2b36SAndroid Build Coastguard Worker
833*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) SetOutputFiles(outputFiles Paths, tag string) {
834*333d2b36SAndroid Build Coastguard Worker	for _, outputFile := range outputFiles {
835*333d2b36SAndroid Build Coastguard Worker		if outputFile == nil {
836*333d2b36SAndroid Build Coastguard Worker			panic("outputfiles cannot be nil")
837*333d2b36SAndroid Build Coastguard Worker		}
838*333d2b36SAndroid Build Coastguard Worker	}
839*333d2b36SAndroid Build Coastguard Worker	if tag == "" {
840*333d2b36SAndroid Build Coastguard Worker		if len(m.outputFiles.DefaultOutputFiles) > 0 {
841*333d2b36SAndroid Build Coastguard Worker			m.ModuleErrorf("Module %s default OutputFiles cannot be overwritten", m.ModuleName())
842*333d2b36SAndroid Build Coastguard Worker		}
843*333d2b36SAndroid Build Coastguard Worker		m.outputFiles.DefaultOutputFiles = outputFiles
844*333d2b36SAndroid Build Coastguard Worker	} else {
845*333d2b36SAndroid Build Coastguard Worker		if m.outputFiles.TaggedOutputFiles == nil {
846*333d2b36SAndroid Build Coastguard Worker			m.outputFiles.TaggedOutputFiles = make(map[string]Paths)
847*333d2b36SAndroid Build Coastguard Worker		}
848*333d2b36SAndroid Build Coastguard Worker		if _, exists := m.outputFiles.TaggedOutputFiles[tag]; exists {
849*333d2b36SAndroid Build Coastguard Worker			m.ModuleErrorf("Module %s OutputFiles at tag %s cannot be overwritten", m.ModuleName(), tag)
850*333d2b36SAndroid Build Coastguard Worker		} else {
851*333d2b36SAndroid Build Coastguard Worker			m.outputFiles.TaggedOutputFiles[tag] = outputFiles
852*333d2b36SAndroid Build Coastguard Worker		}
853*333d2b36SAndroid Build Coastguard Worker	}
854*333d2b36SAndroid Build Coastguard Worker}
855*333d2b36SAndroid Build Coastguard Worker
856*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) GetOutputFiles() OutputFilesInfo {
857*333d2b36SAndroid Build Coastguard Worker	return m.outputFiles
858*333d2b36SAndroid Build Coastguard Worker}
859*333d2b36SAndroid Build Coastguard Worker
860*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) SetLicenseInstallMap(installMap []string) {
861*333d2b36SAndroid Build Coastguard Worker	m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
862*333d2b36SAndroid Build Coastguard Worker}
863*333d2b36SAndroid Build Coastguard Worker
864*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ComplianceMetadataInfo() *ComplianceMetadataInfo {
865*333d2b36SAndroid Build Coastguard Worker	if m.complianceMetadataInfo == nil {
866*333d2b36SAndroid Build Coastguard Worker		m.complianceMetadataInfo = NewComplianceMetadataInfo()
867*333d2b36SAndroid Build Coastguard Worker	}
868*333d2b36SAndroid Build Coastguard Worker	return m.complianceMetadataInfo
869*333d2b36SAndroid Build Coastguard Worker}
870*333d2b36SAndroid Build Coastguard Worker
871*333d2b36SAndroid Build Coastguard Worker// Returns a list of paths expanded from globs and modules referenced using ":module" syntax.  The property must
872*333d2b36SAndroid Build Coastguard Worker// be tagged with `android:"path" to support automatic source module dependency resolution.
873*333d2b36SAndroid Build Coastguard Worker//
874*333d2b36SAndroid Build Coastguard Worker// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
875*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
876*333d2b36SAndroid Build Coastguard Worker	return PathsForModuleSrcExcludes(m, srcFiles, excludes)
877*333d2b36SAndroid Build Coastguard Worker}
878*333d2b36SAndroid Build Coastguard Worker
879*333d2b36SAndroid Build Coastguard Worker// Returns a single path expanded from globs and modules referenced using ":module" syntax.  The property must
880*333d2b36SAndroid Build Coastguard Worker// be tagged with `android:"path" to support automatic source module dependency resolution.
881*333d2b36SAndroid Build Coastguard Worker//
882*333d2b36SAndroid Build Coastguard Worker// Deprecated: use PathForModuleSrc instead.
883*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ExpandSource(srcFile, _ string) Path {
884*333d2b36SAndroid Build Coastguard Worker	return PathForModuleSrc(m, srcFile)
885*333d2b36SAndroid Build Coastguard Worker}
886*333d2b36SAndroid Build Coastguard Worker
887*333d2b36SAndroid Build Coastguard Worker// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
888*333d2b36SAndroid Build Coastguard Worker// the srcFile is non-nil.  The property must be tagged with `android:"path" to support automatic source module
889*333d2b36SAndroid Build Coastguard Worker// dependency resolution.
890*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) ExpandOptionalSource(srcFile *string, _ string) OptionalPath {
891*333d2b36SAndroid Build Coastguard Worker	if srcFile != nil {
892*333d2b36SAndroid Build Coastguard Worker		return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
893*333d2b36SAndroid Build Coastguard Worker	}
894*333d2b36SAndroid Build Coastguard Worker	return OptionalPath{}
895*333d2b36SAndroid Build Coastguard Worker}
896*333d2b36SAndroid Build Coastguard Worker
897*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string {
898*333d2b36SAndroid Build Coastguard Worker	return m.module.RequiredModuleNames(ctx)
899*333d2b36SAndroid Build Coastguard Worker}
900*333d2b36SAndroid Build Coastguard Worker
901*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) HostRequiredModuleNames() []string {
902*333d2b36SAndroid Build Coastguard Worker	return m.module.HostRequiredModuleNames()
903*333d2b36SAndroid Build Coastguard Worker}
904*333d2b36SAndroid Build Coastguard Worker
905*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) TargetRequiredModuleNames() []string {
906*333d2b36SAndroid Build Coastguard Worker	return m.module.TargetRequiredModuleNames()
907*333d2b36SAndroid Build Coastguard Worker}
908*333d2b36SAndroid Build Coastguard Worker
909*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) getContainersInfo() ContainersInfo {
910*333d2b36SAndroid Build Coastguard Worker	return m.containersInfo
911*333d2b36SAndroid Build Coastguard Worker}
912*333d2b36SAndroid Build Coastguard Worker
913*333d2b36SAndroid Build Coastguard Workerfunc (m *moduleContext) setContainersInfo(info ContainersInfo) {
914*333d2b36SAndroid Build Coastguard Worker	m.containersInfo = info
915*333d2b36SAndroid Build Coastguard Worker}
916