blob: d3c5370976ef7e087a814a06241bb52c067eeaba [file] [log] [blame]
Colin Cross69452e12023-11-15 11:20:53 -08001// Copyright 2015 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package android
16
17import (
18 "fmt"
Colin Cross69452e12023-11-15 11:20:53 -080019 "path"
20 "path/filepath"
Spandan Dasc1ded7e2024-11-01 00:52:33 +000021 "slices"
Colin Cross69452e12023-11-15 11:20:53 -080022 "strings"
Cole Faust9a346f62024-01-18 20:12:02 +000023
24 "github.com/google/blueprint"
Yu Liud3228ac2024-11-08 23:11:47 +000025 "github.com/google/blueprint/depset"
Cole Faust9a346f62024-01-18 20:12:02 +000026 "github.com/google/blueprint/proptools"
Colin Crossf0c1ede2025-01-23 13:30:36 -080027 "github.com/google/blueprint/uniquelist"
Colin Cross69452e12023-11-15 11:20:53 -080028)
29
30// BuildParameters describes the set of potential parameters to build a Ninja rule.
31// In general, these correspond to a Ninja concept.
32type BuildParams struct {
33 // A Ninja Rule that will be written to the Ninja file. This allows factoring out common code
34 // among multiple modules to reduce repetition in the Ninja file of action requirements. A rule
35 // can contain variables that should be provided in Args.
36 Rule blueprint.Rule
37 // Deps represents the depfile format. When using RuleBuilder, this defaults to GCC when depfiles
38 // are used.
39 Deps blueprint.Deps
40 // Depfile is a writeable path that allows correct incremental builds when the inputs have not
41 // been fully specified by the Ninja rule. Ninja supports a subset of the Makefile depfile syntax.
42 Depfile WritablePath
43 // A description of the build action.
44 Description string
45 // Output is an output file of the action. When using this field, references to $out in the Ninja
46 // command will refer to this file.
47 Output WritablePath
48 // Outputs is a slice of output file of the action. When using this field, references to $out in
49 // the Ninja command will refer to these files.
50 Outputs WritablePaths
Colin Cross69452e12023-11-15 11:20:53 -080051 // ImplicitOutput is an output file generated by the action. Note: references to `$out` in the
52 // Ninja command will NOT include references to this file.
53 ImplicitOutput WritablePath
54 // ImplicitOutputs is a slice of output files generated by the action. Note: references to `$out`
55 // in the Ninja command will NOT include references to these files.
56 ImplicitOutputs WritablePaths
57 // Input is an input file to the Ninja action. When using this field, references to $in in the
58 // Ninja command will refer to this file.
59 Input Path
60 // Inputs is a slice of input files to the Ninja action. When using this field, references to $in
61 // in the Ninja command will refer to these files.
62 Inputs Paths
63 // Implicit is an input file to the Ninja action. Note: references to `$in` in the Ninja command
64 // will NOT include references to this file.
65 Implicit Path
66 // Implicits is a slice of input files to the Ninja action. Note: references to `$in` in the Ninja
67 // command will NOT include references to these files.
68 Implicits Paths
69 // OrderOnly are Ninja order-only inputs to the action. When these are out of date, the output is
70 // not rebuilt until they are built, but changes in order-only dependencies alone do not cause the
71 // output to be rebuilt.
72 OrderOnly Paths
73 // Validation is an output path for a validation action. Validation outputs imply lower
74 // non-blocking priority to building non-validation outputs.
75 Validation Path
76 // Validations is a slice of output path for a validation action. Validation outputs imply lower
77 // non-blocking priority to building non-validation outputs.
78 Validations Paths
Cole Faust451912d2025-01-10 11:21:18 -080079 // Whether to output a default target statement which will be built by Ninja when no
Colin Cross69452e12023-11-15 11:20:53 -080080 // targets are specified on Ninja's command line.
81 Default bool
82 // Args is a key value mapping for replacements of variables within the Rule
83 Args map[string]string
84}
85
86type ModuleBuildParams BuildParams
87
88type ModuleContext interface {
89 BaseModuleContext
90
Colin Cross1496fb12024-09-09 16:44:10 -070091 // BlueprintModuleContext returns the blueprint.ModuleContext that the ModuleContext wraps. It may only be
92 // used by the golang module types that need to call into the bootstrap module types.
93 BlueprintModuleContext() blueprint.ModuleContext
Colin Cross69452e12023-11-15 11:20:53 -080094
95 // Deprecated: use ModuleContext.Build instead.
96 ModuleBuild(pctx PackageContext, params ModuleBuildParams)
97
98 // Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
99 // be tagged with `android:"path" to support automatic source module dependency resolution.
100 //
101 // Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
102 ExpandSources(srcFiles, excludes []string) Paths
103
104 // Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
105 // be tagged with `android:"path" to support automatic source module dependency resolution.
106 //
107 // Deprecated: use PathForModuleSrc instead.
108 ExpandSource(srcFile, prop string) Path
109
110 ExpandOptionalSource(srcFile *string, prop string) OptionalPath
111
112 // InstallExecutable creates a rule to copy srcPath to name in the installPath directory,
113 // with the given additional dependencies. The file is marked executable after copying.
114 //
Yu Liubad1eef2024-08-21 22:37:35 +0000115 // The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
116 // for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
117 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
118 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross09ad3a62023-11-15 12:29:33 -0800119 InstallExecutable(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
Colin Cross69452e12023-11-15 11:20:53 -0800120
121 // InstallFile creates a rule to copy srcPath to name in the installPath directory,
122 // with the given additional dependencies.
123 //
Yu Liubad1eef2024-08-21 22:37:35 +0000124 // The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
125 // for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
126 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
127 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross09ad3a62023-11-15 12:29:33 -0800128 InstallFile(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
Colin Cross69452e12023-11-15 11:20:53 -0800129
Colin Crossa6182ab2024-08-21 10:47:44 -0700130 // InstallFileWithoutCheckbuild creates a rule to copy srcPath to name in the installPath directory,
131 // with the given additional dependencies, but does not add the file to the list of files to build
132 // during `m checkbuild`.
133 //
134 // The installed file will be returned by FilesToInstall(), and the PackagingSpec for the
135 // installed file will be returned by PackagingSpecs() on this module or by
136 // TransitivePackagingSpecs() on modules that depend on this module through dependency tags
137 // for which IsInstallDepNeeded returns true.
138 InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path, deps ...InstallPath) InstallPath
139
Colin Cross69452e12023-11-15 11:20:53 -0800140 // InstallFileWithExtraFilesZip creates a rule to copy srcPath to name in the installPath
141 // directory, and also unzip a zip file containing extra files to install into the same
142 // directory.
143 //
Yu Liubad1eef2024-08-21 22:37:35 +0000144 // The installed file can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
145 // for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
146 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
147 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross09ad3a62023-11-15 12:29:33 -0800148 InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path, extraZip Path, deps ...InstallPath) InstallPath
Colin Cross69452e12023-11-15 11:20:53 -0800149
150 // InstallSymlink creates a rule to create a symlink from src srcPath to name in the installPath
151 // directory.
152 //
Yu Liubad1eef2024-08-21 22:37:35 +0000153 // The installed symlink can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
154 // for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
155 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
156 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross69452e12023-11-15 11:20:53 -0800157 InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath
158
159 // InstallAbsoluteSymlink creates a rule to create an absolute symlink from src srcPath to name
160 // in the installPath directory.
161 //
Yu Liubad1eef2024-08-21 22:37:35 +0000162 // The installed symlink can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
163 // for the installed file can be accessed by InstallFilesInfo.PackagingSpecs on this module
164 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
165 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross69452e12023-11-15 11:20:53 -0800166 InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath
167
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800168 // InstallTestData creates rules to install test data (e.g. data files used during a test) into
169 // the installPath directory.
170 //
Yu Liubad1eef2024-08-21 22:37:35 +0000171 // The installed files can be accessed by InstallFilesInfo.InstallFiles, and the PackagingSpec
172 // for the installed files can be accessed by InstallFilesInfo.PackagingSpecs on this module
173 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
174 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800175 InstallTestData(installPath InstallPath, data []DataPath) InstallPaths
176
Colin Cross69452e12023-11-15 11:20:53 -0800177 // PackageFile creates a PackagingSpec as if InstallFile was called, but without creating
178 // the rule to copy the file. This is useful to define how a module would be packaged
179 // without installing it into the global installation directories.
180 //
Yu Liubad1eef2024-08-21 22:37:35 +0000181 // The created PackagingSpec can be accessed by InstallFilesInfo.PackagingSpecs on this module
182 // or by InstallFilesInfo.TransitivePackagingSpecs on modules that depend on this module through
183 // dependency tags for which IsInstallDepNeeded returns true.
Colin Cross69452e12023-11-15 11:20:53 -0800184 PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec
185
Colin Crossa6182ab2024-08-21 10:47:44 -0700186 CheckbuildFile(srcPaths ...Path)
187 UncheckedModule()
Colin Cross69452e12023-11-15 11:20:53 -0800188
189 InstallInData() bool
190 InstallInTestcases() bool
191 InstallInSanitizerDir() bool
192 InstallInRamdisk() bool
193 InstallInVendorRamdisk() bool
194 InstallInDebugRamdisk() bool
195 InstallInRecovery() bool
196 InstallInRoot() bool
Colin Crossea30d852023-11-29 16:00:16 -0800197 InstallInOdm() bool
198 InstallInProduct() bool
Colin Cross69452e12023-11-15 11:20:53 -0800199 InstallInVendor() bool
Spandan Das27ff7672024-11-06 19:23:57 +0000200 InstallInSystemDlkm() bool
201 InstallInVendorDlkm() bool
202 InstallInOdmDlkm() bool
Colin Cross69452e12023-11-15 11:20:53 -0800203 InstallForceOS() (*OsType, *ArchType)
204
Cole Fauste8a87832024-09-11 11:35:46 -0700205 RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string
Colin Cross69452e12023-11-15 11:20:53 -0800206 HostRequiredModuleNames() []string
207 TargetRequiredModuleNames() []string
208
209 ModuleSubDir() string
Colin Cross69452e12023-11-15 11:20:53 -0800210
211 Variable(pctx PackageContext, name, value string)
212 Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
213 // Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
214 // and performs more verification.
215 Build(pctx PackageContext, params BuildParams)
216 // Phony creates a Make-style phony rule, a rule with no commands that can depend on other
217 // phony rules or real files. Phony can be called on the same name multiple times to add
218 // additional dependencies.
219 Phony(phony string, deps ...Path)
220
221 // GetMissingDependencies returns the list of dependencies that were passed to AddDependencies or related methods,
222 // but do not exist.
223 GetMissingDependencies() []string
224
225 // LicenseMetadataFile returns the path where the license metadata for this module will be
226 // generated.
227 LicenseMetadataFile() Path
Colin Crossd6fd0132023-11-06 13:54:06 -0800228
229 // ModuleInfoJSON returns a pointer to the ModuleInfoJSON struct that can be filled out by
230 // GenerateAndroidBuildActions. If it is called then the struct will be written out and included in
231 // the module-info.json generated by Make, and Make will not generate its own data for this module.
232 ModuleInfoJSON() *ModuleInfoJSON
mrziwange6c85812024-05-22 14:36:09 -0700233
Jihoon Kangd4063812025-01-24 00:25:30 +0000234 // Simiar to ModuleInfoJSON, ExtraModuleInfoJSON also returns a pointer to the ModuleInfoJSON struct.
235 // This should only be called by a module that generates multiple AndroidMkEntries struct.
236 ExtraModuleInfoJSON() *ModuleInfoJSON
237
mrziwange6c85812024-05-22 14:36:09 -0700238 // SetOutputFiles stores the outputFiles to outputFiles property, which is used
239 // to set the OutputFilesProvider later.
240 SetOutputFiles(outputFiles Paths, tag string)
Wei Lia1aa2972024-06-21 13:08:51 -0700241
Yu Liu876b7ce2024-08-21 18:20:13 +0000242 GetOutputFiles() OutputFilesInfo
243
Yu Liubad1eef2024-08-21 22:37:35 +0000244 // SetLicenseInstallMap stores the set of dependency module:location mappings for files in an
245 // apex container for use when generation the license metadata file.
246 SetLicenseInstallMap(installMap []string)
247
Wei Lia1aa2972024-06-21 13:08:51 -0700248 // ComplianceMetadataInfo returns a ComplianceMetadataInfo instance for different module types to dump metadata,
249 // which usually happens in GenerateAndroidBuildActions() of a module type.
250 // See android.ModuleBase.complianceMetadataInfo
251 ComplianceMetadataInfo() *ComplianceMetadataInfo
Yu Liu9a993132024-08-27 23:21:06 +0000252
253 // Get the information about the containers this module belongs to.
254 getContainersInfo() ContainersInfo
255 setContainersInfo(info ContainersInfo)
256
257 setAconfigPaths(paths Paths)
Colin Cross69452e12023-11-15 11:20:53 -0800258}
259
260type moduleContext struct {
261 bp blueprint.ModuleContext
262 baseModuleContext
Colin Crossa6182ab2024-08-21 10:47:44 -0700263 packagingSpecs []PackagingSpec
264 installFiles InstallPaths
265 checkbuildFiles Paths
266 checkbuildTarget Path
267 uncheckedModule bool
268 module Module
269 phonies map[string]Paths
Yu Liu876b7ce2024-08-21 18:20:13 +0000270 // outputFiles stores the output of a module by tag and is used to set
271 // the OutputFilesProvider in GenerateBuildActions
272 outputFiles OutputFilesInfo
Colin Cross69452e12023-11-15 11:20:53 -0800273
Colin Crossa14fb6a2024-10-23 16:57:06 -0700274 TransitiveInstallFiles depset.DepSet[InstallPath]
Yu Liubad1eef2024-08-21 22:37:35 +0000275
276 // set of dependency module:location mappings used to populate the license metadata for
277 // apex containers.
278 licenseInstallMap []string
279
Yu Liuec810542024-08-26 18:09:15 +0000280 // The path to the generated license metadata file for the module.
281 licenseMetadataFile WritablePath
282
Yu Liud46e5ae2024-08-15 18:46:17 +0000283 katiInstalls katiInstalls
284 katiSymlinks katiInstalls
Yu Liu82a6d142024-08-27 19:02:29 +0000285 // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
286 // allowed to have duplicates across modules and variants.
287 katiInitRcInstalls katiInstalls
288 katiVintfInstalls katiInstalls
289 initRcPaths Paths
290 vintfFragmentsPaths Paths
291 installedInitRcPaths InstallPaths
292 installedVintfFragmentsPaths InstallPaths
Colin Cross69452e12023-11-15 11:20:53 -0800293
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800294 testData []DataPath
295
Colin Cross69452e12023-11-15 11:20:53 -0800296 // For tests
297 buildParams []BuildParams
298 ruleParams map[blueprint.Rule]blueprint.RuleParams
299 variables map[string]string
Yu Liu4297ad92024-08-27 19:50:13 +0000300
301 // moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
302 // be included in the final module-info.json produced by Make.
Jihoon Kangd4063812025-01-24 00:25:30 +0000303 moduleInfoJSON []*ModuleInfoJSON
Yu Liu9a993132024-08-27 23:21:06 +0000304
305 // containersInfo stores the information about the containers and the information of the
306 // apexes the module belongs to.
307 containersInfo ContainersInfo
308
309 // Merged Aconfig files for all transitive deps.
310 aconfigFilePaths Paths
311
312 // complianceMetadataInfo is for different module types to dump metadata.
313 // See android.ModuleContext interface.
314 complianceMetadataInfo *ComplianceMetadataInfo
Colin Cross69452e12023-11-15 11:20:53 -0800315}
316
Cole Faust02987bd2024-03-21 17:58:43 -0700317var _ ModuleContext = &moduleContext{}
318
Colin Cross69452e12023-11-15 11:20:53 -0800319func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
320 return pctx, BuildParams{
321 Rule: ErrorRule,
322 Description: params.Description,
323 Output: params.Output,
324 Outputs: params.Outputs,
325 ImplicitOutput: params.ImplicitOutput,
326 ImplicitOutputs: params.ImplicitOutputs,
327 Args: map[string]string{
328 "error": err.Error(),
329 },
330 }
331}
332
333func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
334 m.Build(pctx, BuildParams(params))
335}
336
Colin Cross69452e12023-11-15 11:20:53 -0800337// Convert build parameters from their concrete Android types into their string representations,
338// and combine the singular and plural fields of the same type (e.g. Output and Outputs).
339func convertBuildParams(params BuildParams) blueprint.BuildParams {
340 bparams := blueprint.BuildParams{
341 Rule: params.Rule,
342 Description: params.Description,
343 Deps: params.Deps,
344 Outputs: params.Outputs.Strings(),
345 ImplicitOutputs: params.ImplicitOutputs.Strings(),
Colin Cross69452e12023-11-15 11:20:53 -0800346 Inputs: params.Inputs.Strings(),
347 Implicits: params.Implicits.Strings(),
348 OrderOnly: params.OrderOnly.Strings(),
349 Validations: params.Validations.Strings(),
350 Args: params.Args,
Cole Faust451912d2025-01-10 11:21:18 -0800351 Default: params.Default,
Colin Cross69452e12023-11-15 11:20:53 -0800352 }
353
354 if params.Depfile != nil {
355 bparams.Depfile = params.Depfile.String()
356 }
357 if params.Output != nil {
358 bparams.Outputs = append(bparams.Outputs, params.Output.String())
359 }
Colin Cross69452e12023-11-15 11:20:53 -0800360 if params.ImplicitOutput != nil {
361 bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
362 }
363 if params.Input != nil {
364 bparams.Inputs = append(bparams.Inputs, params.Input.String())
365 }
366 if params.Implicit != nil {
367 bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
368 }
369 if params.Validation != nil {
370 bparams.Validations = append(bparams.Validations, params.Validation.String())
371 }
372
373 bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
374 bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
Colin Cross69452e12023-11-15 11:20:53 -0800375 bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
376 bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
377 bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
378 bparams.Validations = proptools.NinjaEscapeList(bparams.Validations)
379 bparams.Depfile = proptools.NinjaEscape(bparams.Depfile)
380
381 return bparams
382}
383
384func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
385 if m.config.captureBuild {
386 m.variables[name] = value
387 }
388
389 m.bp.Variable(pctx.PackageContext, name, value)
390}
391
392func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
393 argNames ...string) blueprint.Rule {
394
395 if m.config.UseRemoteBuild() {
396 if params.Pool == nil {
397 // When USE_GOMA=true or USE_RBE=true are set and the rule is not supported by goma/RBE, restrict
398 // jobs to the local parallelism value
399 params.Pool = localPool
400 } else if params.Pool == remotePool {
401 // remotePool is a fake pool used to identify rule that are supported for remoting. If the rule's
402 // pool is the remotePool, replace with nil so that ninja runs it at NINJA_REMOTE_NUM_JOBS
403 // parallelism.
404 params.Pool = nil
405 }
406 }
407
408 rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
409
410 if m.config.captureBuild {
411 m.ruleParams[rule] = params
412 }
413
414 return rule
415}
416
417func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
418 if params.Description != "" {
419 params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
420 }
421
422 if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 {
423 pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n",
424 m.ModuleName(), strings.Join(missingDeps, ", ")))
425 }
426
427 if m.config.captureBuild {
428 m.buildParams = append(m.buildParams, params)
429 }
430
431 bparams := convertBuildParams(params)
Colin Cross69452e12023-11-15 11:20:53 -0800432 m.bp.Build(pctx.PackageContext, bparams)
433}
434
435func (m *moduleContext) Phony(name string, deps ...Path) {
Yu Liu54513622024-08-19 20:00:32 +0000436 m.phonies[name] = append(m.phonies[name], deps...)
Colin Cross69452e12023-11-15 11:20:53 -0800437}
438
439func (m *moduleContext) GetMissingDependencies() []string {
440 var missingDeps []string
441 missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
442 missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
443 missingDeps = FirstUniqueStrings(missingDeps)
444 return missingDeps
445}
446
Yu Liud3228ac2024-11-08 23:11:47 +0000447func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module {
Yu Liu3ae96652024-12-17 22:27:38 +0000448 deps := m.getDirectDepsInternal(name, tag)
449 if len(deps) == 1 {
450 return deps[0]
451 } else if len(deps) >= 2 {
452 panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
453 name, m.ModuleName()))
454 } else {
455 return nil
Yu Liud3228ac2024-11-08 23:11:47 +0000456 }
Yu Liu3ae96652024-12-17 22:27:38 +0000457}
458
459func (m *moduleContext) GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) *ModuleProxy {
460 deps := m.getDirectDepsProxyInternal(name, tag)
461 if len(deps) == 1 {
462 return &deps[0]
463 } else if len(deps) >= 2 {
464 panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
465 name, m.ModuleName()))
466 } else {
467 return nil
468 }
Colin Cross69452e12023-11-15 11:20:53 -0800469}
470
471func (m *moduleContext) ModuleSubDir() string {
472 return m.bp.ModuleSubDir()
473}
474
Colin Cross69452e12023-11-15 11:20:53 -0800475func (m *moduleContext) InstallInData() bool {
476 return m.module.InstallInData()
477}
478
479func (m *moduleContext) InstallInTestcases() bool {
480 return m.module.InstallInTestcases()
481}
482
483func (m *moduleContext) InstallInSanitizerDir() bool {
484 return m.module.InstallInSanitizerDir()
485}
486
487func (m *moduleContext) InstallInRamdisk() bool {
488 return m.module.InstallInRamdisk()
489}
490
491func (m *moduleContext) InstallInVendorRamdisk() bool {
492 return m.module.InstallInVendorRamdisk()
493}
494
495func (m *moduleContext) InstallInDebugRamdisk() bool {
496 return m.module.InstallInDebugRamdisk()
497}
498
499func (m *moduleContext) InstallInRecovery() bool {
500 return m.module.InstallInRecovery()
501}
502
503func (m *moduleContext) InstallInRoot() bool {
504 return m.module.InstallInRoot()
505}
506
507func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
508 return m.module.InstallForceOS()
509}
510
Colin Crossea30d852023-11-29 16:00:16 -0800511func (m *moduleContext) InstallInOdm() bool {
512 return m.module.InstallInOdm()
513}
514
515func (m *moduleContext) InstallInProduct() bool {
516 return m.module.InstallInProduct()
517}
518
Colin Cross69452e12023-11-15 11:20:53 -0800519func (m *moduleContext) InstallInVendor() bool {
520 return m.module.InstallInVendor()
521}
522
Spandan Das27ff7672024-11-06 19:23:57 +0000523func (m *moduleContext) InstallInSystemDlkm() bool {
524 return m.module.InstallInSystemDlkm()
525}
526
527func (m *moduleContext) InstallInVendorDlkm() bool {
528 return m.module.InstallInVendorDlkm()
529}
530
531func (m *moduleContext) InstallInOdmDlkm() bool {
532 return m.module.InstallInOdmDlkm()
533}
534
Colin Cross69452e12023-11-15 11:20:53 -0800535func (m *moduleContext) skipInstall() bool {
536 if m.module.base().commonProperties.SkipInstall {
537 return true
538 }
539
Colin Cross69452e12023-11-15 11:20:53 -0800540 // We'll need a solution for choosing which of modules with the same name in different
541 // namespaces to install. For now, reuse the list of namespaces exported to Make as the
542 // list of namespaces to install in a Soong-only build.
543 if !m.module.base().commonProperties.NamespaceExportedToMake {
544 return true
545 }
546
547 return false
548}
549
Jiyong Park3f627e62024-05-01 16:14:38 +0900550// Tells whether this module is installed to the full install path (ex:
551// out/target/product/<name>/<partition>) or not. If this returns false, the install build rule is
552// not created and this module can only be installed to packaging modules like android_filesystem.
553func (m *moduleContext) requiresFullInstall() bool {
554 if m.skipInstall() {
555 return false
556 }
557
Spandan Das034af2c2024-10-30 21:45:09 +0000558 if m.module.base().commonProperties.HideFromMake {
559 return false
560 }
561
Jiyong Park3f627e62024-05-01 16:14:38 +0900562 if proptools.Bool(m.module.base().commonProperties.No_full_install) {
563 return false
564 }
565
566 return true
567}
568
Colin Cross69452e12023-11-15 11:20:53 -0800569func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
Colin Cross09ad3a62023-11-15 12:29:33 -0800570 deps ...InstallPath) InstallPath {
Colin Crossa6182ab2024-08-21 10:47:44 -0700571 return m.installFile(installPath, name, srcPath, deps, false, true, true, nil)
572}
573
574func (m *moduleContext) InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path,
575 deps ...InstallPath) InstallPath {
576 return m.installFile(installPath, name, srcPath, deps, false, true, false, nil)
Colin Cross69452e12023-11-15 11:20:53 -0800577}
578
579func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
Colin Cross09ad3a62023-11-15 12:29:33 -0800580 deps ...InstallPath) InstallPath {
Colin Crossa6182ab2024-08-21 10:47:44 -0700581 return m.installFile(installPath, name, srcPath, deps, true, true, true, nil)
Colin Cross69452e12023-11-15 11:20:53 -0800582}
583
584func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
Colin Cross09ad3a62023-11-15 12:29:33 -0800585 extraZip Path, deps ...InstallPath) InstallPath {
Colin Crossa6182ab2024-08-21 10:47:44 -0700586 return m.installFile(installPath, name, srcPath, deps, false, true, true, &extraFilesZip{
Colin Cross69452e12023-11-15 11:20:53 -0800587 zip: extraZip,
588 dir: installPath,
589 })
590}
591
592func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
593 fullInstallPath := installPath.Join(m, name)
Cole Faust19fbb072025-01-30 18:19:29 -0800594 return m.packageFile(fullInstallPath, srcPath, false, false)
Colin Cross69452e12023-11-15 11:20:53 -0800595}
596
Colin Crossf0c1ede2025-01-23 13:30:36 -0800597func (m *moduleContext) getAconfigPaths() Paths {
598 return m.aconfigFilePaths
Yu Liu9a993132024-08-27 23:21:06 +0000599}
600
601func (m *moduleContext) setAconfigPaths(paths Paths) {
602 m.aconfigFilePaths = paths
Justin Yun74f3f302024-05-07 14:32:14 +0900603}
604
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000605func (m *moduleContext) getOwnerAndOverrides() (string, []string) {
606 owner := m.ModuleName()
607 overrides := slices.Clone(m.Module().base().commonProperties.Overrides)
608 if b, ok := m.Module().(OverridableModule); ok {
609 if b.GetOverriddenBy() != "" {
610 // overriding variant of base module
611 overrides = append(overrides, m.ModuleName()) // com.android.foo
612 owner = m.Module().Name() // com.company.android.foo
613 }
614 }
615 return owner, overrides
616}
617
Cole Faust19fbb072025-01-30 18:19:29 -0800618func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool, requiresFullInstall bool) PackagingSpec {
Colin Cross69452e12023-11-15 11:20:53 -0800619 licenseFiles := m.Module().EffectiveLicenseFiles()
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000620 owner, overrides := m.getOwnerAndOverrides()
Colin Cross69452e12023-11-15 11:20:53 -0800621 spec := PackagingSpec{
622 relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
623 srcPath: srcPath,
624 symlinkTarget: "",
625 executable: executable,
Colin Crossf0c1ede2025-01-23 13:30:36 -0800626 effectiveLicenseFiles: uniquelist.Make(licenseFiles),
Colin Cross69452e12023-11-15 11:20:53 -0800627 partition: fullInstallPath.partition,
Jiyong Park4152b192024-04-30 21:24:21 +0900628 skipInstall: m.skipInstall(),
Colin Crossf0c1ede2025-01-23 13:30:36 -0800629 aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
Jiyong Parkc6a773d2024-05-14 21:49:11 +0900630 archType: m.target.Arch.ArchType,
Jihoon Kangd4063812025-01-24 00:25:30 +0000631 overrides: uniquelist.Make(overrides),
632 owner: owner,
Cole Faust19fbb072025-01-30 18:19:29 -0800633 requiresFullInstall: requiresFullInstall,
634 fullInstallPath: fullInstallPath,
Colin Cross69452e12023-11-15 11:20:53 -0800635 }
636 m.packagingSpecs = append(m.packagingSpecs, spec)
637 return spec
638}
639
Colin Cross09ad3a62023-11-15 12:29:33 -0800640func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
Colin Crossa6182ab2024-08-21 10:47:44 -0700641 executable bool, hooks bool, checkbuild bool, extraZip *extraFilesZip) InstallPath {
Spandan Dasd718aa52025-02-04 21:18:36 +0000642 if _, ok := srcPath.(InstallPath); ok {
643 m.ModuleErrorf("Src path cannot be another installed file. Please use a path from source or intermediates instead.")
644 }
Colin Cross69452e12023-11-15 11:20:53 -0800645
646 fullInstallPath := installPath.Join(m, name)
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800647 if hooks {
648 m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
649 }
Colin Cross69452e12023-11-15 11:20:53 -0800650
Jiyong Park3f627e62024-05-01 16:14:38 +0900651 if m.requiresFullInstall() {
Yu Liubad1eef2024-08-21 22:37:35 +0000652 deps = append(deps, InstallPaths(m.TransitiveInstallFiles.ToList())...)
Cole Faust74d243c2024-12-11 17:57:34 -0800653 if m.config.KatiEnabled() {
654 deps = append(deps, m.installedInitRcPaths...)
655 deps = append(deps, m.installedVintfFragmentsPaths...)
656 }
Colin Cross69452e12023-11-15 11:20:53 -0800657
658 var implicitDeps, orderOnlyDeps Paths
659
660 if m.Host() {
661 // Installed host modules might be used during the build, depend directly on their
662 // dependencies so their timestamp is updated whenever their dependency is updated
Colin Cross09ad3a62023-11-15 12:29:33 -0800663 implicitDeps = InstallPaths(deps).Paths()
Colin Cross69452e12023-11-15 11:20:53 -0800664 } else {
Colin Cross09ad3a62023-11-15 12:29:33 -0800665 orderOnlyDeps = InstallPaths(deps).Paths()
Colin Cross69452e12023-11-15 11:20:53 -0800666 }
667
Cole Faust866ab392025-01-23 12:56:20 -0800668 // When creating the install rule in Soong but embedding in Make, write the rule to a
669 // makefile instead of directly to the ninja file so that main.mk can add the
670 // dependencies from the `required` property that are hard to resolve in Soong.
671 // In soong-only builds, the katiInstall will still be created for semi-legacy code paths
672 // such as module-info.json or compliance, but it will not be used for actually installing
673 // the file.
674 m.katiInstalls = append(m.katiInstalls, katiInstall{
675 from: srcPath,
676 to: fullInstallPath,
677 implicitDeps: implicitDeps,
678 orderOnlyDeps: orderOnlyDeps,
679 executable: executable,
680 extraFiles: extraZip,
681 })
682 if !m.Config().KatiEnabled() {
Spandan Das4d78e012025-01-22 23:25:39 +0000683 rule := CpWithBash
Colin Cross69452e12023-11-15 11:20:53 -0800684 if executable {
Spandan Das4d78e012025-01-22 23:25:39 +0000685 rule = CpExecutableWithBash
Colin Cross69452e12023-11-15 11:20:53 -0800686 }
687
688 extraCmds := ""
689 if extraZip != nil {
690 extraCmds += fmt.Sprintf(" && ( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} )",
691 extraZip.dir.String(), extraZip.zip.String())
692 extraCmds += " || ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )"
693 implicitDeps = append(implicitDeps, extraZip.zip)
694 }
695
696 m.Build(pctx, BuildParams{
697 Rule: rule,
698 Description: "install " + fullInstallPath.Base(),
699 Output: fullInstallPath,
700 Input: srcPath,
701 Implicits: implicitDeps,
702 OrderOnly: orderOnlyDeps,
Colin Cross69452e12023-11-15 11:20:53 -0800703 Args: map[string]string{
704 "extraCmds": extraCmds,
Spandan Das4d78e012025-01-22 23:25:39 +0000705 "cpFlags": "-f",
Colin Cross69452e12023-11-15 11:20:53 -0800706 },
707 })
708 }
709
710 m.installFiles = append(m.installFiles, fullInstallPath)
711 }
712
Cole Faust19fbb072025-01-30 18:19:29 -0800713 m.packageFile(fullInstallPath, srcPath, executable, m.requiresFullInstall())
Colin Cross69452e12023-11-15 11:20:53 -0800714
Colin Crossa6182ab2024-08-21 10:47:44 -0700715 if checkbuild {
716 m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
717 }
Colin Cross69452e12023-11-15 11:20:53 -0800718
719 return fullInstallPath
720}
721
722func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
723 fullInstallPath := installPath.Join(m, name)
724 m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, true)
725
726 relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
727 if err != nil {
728 panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
729 }
Jiyong Park3f627e62024-05-01 16:14:38 +0900730 if m.requiresFullInstall() {
Colin Cross69452e12023-11-15 11:20:53 -0800731
Cole Faust866ab392025-01-23 12:56:20 -0800732 // When creating the symlink rule in Soong but embedding in Make, write the rule to a
733 // makefile instead of directly to the ninja file so that main.mk can add the
734 // dependencies from the `required` property that are hard to resolve in Soong.
735 // In soong-only builds, the katiInstall will still be created for semi-legacy code paths
736 // such as module-info.json or compliance, but it will not be used for actually installing
737 // the file.
738 m.katiSymlinks = append(m.katiSymlinks, katiInstall{
739 from: srcPath,
740 to: fullInstallPath,
741 })
742 if !m.Config().KatiEnabled() {
Colin Cross69452e12023-11-15 11:20:53 -0800743 // The symlink doesn't need updating when the target is modified, but we sometimes
744 // have a dependency on a symlink to a binary instead of to the binary directly, and
745 // the mtime of the symlink must be updated when the binary is modified, so use a
746 // normal dependency here instead of an order-only dependency.
747 m.Build(pctx, BuildParams{
Spandan Das4d78e012025-01-22 23:25:39 +0000748 Rule: SymlinkWithBash,
Colin Cross69452e12023-11-15 11:20:53 -0800749 Description: "install symlink " + fullInstallPath.Base(),
750 Output: fullInstallPath,
751 Input: srcPath,
Colin Cross69452e12023-11-15 11:20:53 -0800752 Args: map[string]string{
753 "fromPath": relPath,
754 },
755 })
756 }
757
758 m.installFiles = append(m.installFiles, fullInstallPath)
Colin Cross69452e12023-11-15 11:20:53 -0800759 }
760
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000761 owner, overrides := m.getOwnerAndOverrides()
Colin Cross69452e12023-11-15 11:20:53 -0800762 m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
Cole Faust19fbb072025-01-30 18:19:29 -0800763 relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
764 srcPath: nil,
765 symlinkTarget: relPath,
766 executable: false,
767 partition: fullInstallPath.partition,
768 skipInstall: m.skipInstall(),
769 aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
770 archType: m.target.Arch.ArchType,
771 overrides: uniquelist.Make(overrides),
772 owner: owner,
773 requiresFullInstall: m.requiresFullInstall(),
774 fullInstallPath: fullInstallPath,
Colin Cross69452e12023-11-15 11:20:53 -0800775 })
776
777 return fullInstallPath
778}
779
780// installPath/name -> absPath where absPath might be a path that is available only at runtime
781// (e.g. /apex/...)
782func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
783 fullInstallPath := installPath.Join(m, name)
784 m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
785
Jiyong Park3f627e62024-05-01 16:14:38 +0900786 if m.requiresFullInstall() {
Cole Faust866ab392025-01-23 12:56:20 -0800787 // When creating the symlink rule in Soong but embedding in Make, write the rule to a
788 // makefile instead of directly to the ninja file so that main.mk can add the
789 // dependencies from the `required` property that are hard to resolve in Soong.
790 // In soong-only builds, the katiInstall will still be created for semi-legacy code paths
791 // such as module-info.json or compliance, but it will not be used for actually installing
792 // the file.
793 m.katiSymlinks = append(m.katiSymlinks, katiInstall{
794 absFrom: absPath,
795 to: fullInstallPath,
796 })
797 if !m.Config().KatiEnabled() {
Colin Cross69452e12023-11-15 11:20:53 -0800798 m.Build(pctx, BuildParams{
799 Rule: Symlink,
800 Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
801 Output: fullInstallPath,
Colin Cross69452e12023-11-15 11:20:53 -0800802 Args: map[string]string{
803 "fromPath": absPath,
804 },
805 })
806 }
807
808 m.installFiles = append(m.installFiles, fullInstallPath)
809 }
810
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000811 owner, overrides := m.getOwnerAndOverrides()
Colin Cross69452e12023-11-15 11:20:53 -0800812 m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
Cole Faust19fbb072025-01-30 18:19:29 -0800813 relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
814 srcPath: nil,
815 symlinkTarget: absPath,
816 executable: false,
817 partition: fullInstallPath.partition,
818 skipInstall: m.skipInstall(),
819 aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
820 archType: m.target.Arch.ArchType,
821 overrides: uniquelist.Make(overrides),
822 owner: owner,
823 requiresFullInstall: m.requiresFullInstall(),
824 fullInstallPath: fullInstallPath,
Colin Cross69452e12023-11-15 11:20:53 -0800825 })
826
827 return fullInstallPath
828}
829
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800830func (m *moduleContext) InstallTestData(installPath InstallPath, data []DataPath) InstallPaths {
831 m.testData = append(m.testData, data...)
832
833 ret := make(InstallPaths, 0, len(data))
834 for _, d := range data {
835 relPath := d.ToRelativeInstallPath()
Colin Crossa6182ab2024-08-21 10:47:44 -0700836 installed := m.installFile(installPath, relPath, d.SrcPath, nil, false, false, true, nil)
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800837 ret = append(ret, installed)
838 }
839
840 return ret
841}
842
Colin Crossa6182ab2024-08-21 10:47:44 -0700843// CheckbuildFile specifies the output files that should be built by checkbuild.
844func (m *moduleContext) CheckbuildFile(srcPaths ...Path) {
845 m.checkbuildFiles = append(m.checkbuildFiles, srcPaths...)
846}
847
848// UncheckedModule marks the current module has having no files that should be built by checkbuild.
849func (m *moduleContext) UncheckedModule() {
850 m.uncheckedModule = true
Colin Cross69452e12023-11-15 11:20:53 -0800851}
852
Colin Cross1496fb12024-09-09 16:44:10 -0700853func (m *moduleContext) BlueprintModuleContext() blueprint.ModuleContext {
Colin Cross69452e12023-11-15 11:20:53 -0800854 return m.bp
855}
856
857func (m *moduleContext) LicenseMetadataFile() Path {
Yu Liuec810542024-08-26 18:09:15 +0000858 return m.licenseMetadataFile
Colin Cross69452e12023-11-15 11:20:53 -0800859}
860
Colin Crossd6fd0132023-11-06 13:54:06 -0800861func (m *moduleContext) ModuleInfoJSON() *ModuleInfoJSON {
Jihoon Kangd4063812025-01-24 00:25:30 +0000862 if len(m.moduleInfoJSON) == 0 {
863 moduleInfoJSON := &ModuleInfoJSON{}
864 m.moduleInfoJSON = append(m.moduleInfoJSON, moduleInfoJSON)
Colin Crossd6fd0132023-11-06 13:54:06 -0800865 }
Jihoon Kangd4063812025-01-24 00:25:30 +0000866 return m.moduleInfoJSON[0]
867}
868
869func (m *moduleContext) ExtraModuleInfoJSON() *ModuleInfoJSON {
870 if len(m.moduleInfoJSON) == 0 {
871 panic("call ModuleInfoJSON() instead")
872 }
873
Colin Crossd6fd0132023-11-06 13:54:06 -0800874 moduleInfoJSON := &ModuleInfoJSON{}
Jihoon Kangd4063812025-01-24 00:25:30 +0000875 m.moduleInfoJSON = append(m.moduleInfoJSON, moduleInfoJSON)
Colin Crossd6fd0132023-11-06 13:54:06 -0800876 return moduleInfoJSON
877}
878
mrziwange6c85812024-05-22 14:36:09 -0700879func (m *moduleContext) SetOutputFiles(outputFiles Paths, tag string) {
Cole Faust5146e782024-11-15 14:47:49 -0800880 for _, outputFile := range outputFiles {
881 if outputFile == nil {
882 panic("outputfiles cannot be nil")
883 }
884 }
mrziwange6c85812024-05-22 14:36:09 -0700885 if tag == "" {
Yu Liu876b7ce2024-08-21 18:20:13 +0000886 if len(m.outputFiles.DefaultOutputFiles) > 0 {
mrziwange6c85812024-05-22 14:36:09 -0700887 m.ModuleErrorf("Module %s default OutputFiles cannot be overwritten", m.ModuleName())
888 }
Yu Liu876b7ce2024-08-21 18:20:13 +0000889 m.outputFiles.DefaultOutputFiles = outputFiles
mrziwange6c85812024-05-22 14:36:09 -0700890 } else {
Yu Liu876b7ce2024-08-21 18:20:13 +0000891 if m.outputFiles.TaggedOutputFiles == nil {
892 m.outputFiles.TaggedOutputFiles = make(map[string]Paths)
mrziwang57768d72024-06-06 11:31:51 -0700893 }
Yu Liu876b7ce2024-08-21 18:20:13 +0000894 if _, exists := m.outputFiles.TaggedOutputFiles[tag]; exists {
mrziwange6c85812024-05-22 14:36:09 -0700895 m.ModuleErrorf("Module %s OutputFiles at tag %s cannot be overwritten", m.ModuleName(), tag)
896 } else {
Yu Liu876b7ce2024-08-21 18:20:13 +0000897 m.outputFiles.TaggedOutputFiles[tag] = outputFiles
mrziwange6c85812024-05-22 14:36:09 -0700898 }
899 }
900}
901
Yu Liu876b7ce2024-08-21 18:20:13 +0000902func (m *moduleContext) GetOutputFiles() OutputFilesInfo {
903 return m.outputFiles
904}
905
Yu Liubad1eef2024-08-21 22:37:35 +0000906func (m *moduleContext) SetLicenseInstallMap(installMap []string) {
907 m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
908}
909
Wei Lia1aa2972024-06-21 13:08:51 -0700910func (m *moduleContext) ComplianceMetadataInfo() *ComplianceMetadataInfo {
Yu Liu9a993132024-08-27 23:21:06 +0000911 if m.complianceMetadataInfo == nil {
912 m.complianceMetadataInfo = NewComplianceMetadataInfo()
Wei Lia1aa2972024-06-21 13:08:51 -0700913 }
Yu Liu9a993132024-08-27 23:21:06 +0000914 return m.complianceMetadataInfo
Wei Lia1aa2972024-06-21 13:08:51 -0700915}
916
Colin Cross69452e12023-11-15 11:20:53 -0800917// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
918// be tagged with `android:"path" to support automatic source module dependency resolution.
919//
920// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
921func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
922 return PathsForModuleSrcExcludes(m, srcFiles, excludes)
923}
924
925// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
926// be tagged with `android:"path" to support automatic source module dependency resolution.
927//
928// Deprecated: use PathForModuleSrc instead.
929func (m *moduleContext) ExpandSource(srcFile, _ string) Path {
930 return PathForModuleSrc(m, srcFile)
931}
932
933// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
934// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
935// dependency resolution.
936func (m *moduleContext) ExpandOptionalSource(srcFile *string, _ string) OptionalPath {
937 if srcFile != nil {
938 return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
939 }
940 return OptionalPath{}
941}
942
Cole Fauste8a87832024-09-11 11:35:46 -0700943func (m *moduleContext) RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string {
Cole Faust43ddd082024-06-17 12:32:40 -0700944 return m.module.RequiredModuleNames(ctx)
Colin Cross69452e12023-11-15 11:20:53 -0800945}
946
947func (m *moduleContext) HostRequiredModuleNames() []string {
948 return m.module.HostRequiredModuleNames()
949}
950
951func (m *moduleContext) TargetRequiredModuleNames() []string {
952 return m.module.TargetRequiredModuleNames()
953}
Yu Liu9a993132024-08-27 23:21:06 +0000954
955func (m *moduleContext) getContainersInfo() ContainersInfo {
956 return m.containersInfo
957}
958
959func (m *moduleContext) setContainersInfo(info ContainersInfo) {
960 m.containersInfo = info
961}