blob: e63c672e9de30452be36ec7a2124236b7dbdd5da [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
234 // SetOutputFiles stores the outputFiles to outputFiles property, which is used
235 // to set the OutputFilesProvider later.
236 SetOutputFiles(outputFiles Paths, tag string)
Wei Lia1aa2972024-06-21 13:08:51 -0700237
Yu Liu876b7ce2024-08-21 18:20:13 +0000238 GetOutputFiles() OutputFilesInfo
239
Yu Liubad1eef2024-08-21 22:37:35 +0000240 // SetLicenseInstallMap stores the set of dependency module:location mappings for files in an
241 // apex container for use when generation the license metadata file.
242 SetLicenseInstallMap(installMap []string)
243
Wei Lia1aa2972024-06-21 13:08:51 -0700244 // ComplianceMetadataInfo returns a ComplianceMetadataInfo instance for different module types to dump metadata,
245 // which usually happens in GenerateAndroidBuildActions() of a module type.
246 // See android.ModuleBase.complianceMetadataInfo
247 ComplianceMetadataInfo() *ComplianceMetadataInfo
Yu Liu9a993132024-08-27 23:21:06 +0000248
249 // Get the information about the containers this module belongs to.
250 getContainersInfo() ContainersInfo
251 setContainersInfo(info ContainersInfo)
252
253 setAconfigPaths(paths Paths)
Colin Cross69452e12023-11-15 11:20:53 -0800254}
255
256type moduleContext struct {
257 bp blueprint.ModuleContext
258 baseModuleContext
Colin Crossa6182ab2024-08-21 10:47:44 -0700259 packagingSpecs []PackagingSpec
260 installFiles InstallPaths
261 checkbuildFiles Paths
262 checkbuildTarget Path
263 uncheckedModule bool
264 module Module
265 phonies map[string]Paths
Yu Liu876b7ce2024-08-21 18:20:13 +0000266 // outputFiles stores the output of a module by tag and is used to set
267 // the OutputFilesProvider in GenerateBuildActions
268 outputFiles OutputFilesInfo
Colin Cross69452e12023-11-15 11:20:53 -0800269
Colin Crossa14fb6a2024-10-23 16:57:06 -0700270 TransitiveInstallFiles depset.DepSet[InstallPath]
Yu Liubad1eef2024-08-21 22:37:35 +0000271
272 // set of dependency module:location mappings used to populate the license metadata for
273 // apex containers.
274 licenseInstallMap []string
275
Yu Liuec810542024-08-26 18:09:15 +0000276 // The path to the generated license metadata file for the module.
277 licenseMetadataFile WritablePath
278
Yu Liud46e5ae2024-08-15 18:46:17 +0000279 katiInstalls katiInstalls
280 katiSymlinks katiInstalls
Yu Liu82a6d142024-08-27 19:02:29 +0000281 // katiInitRcInstalls and katiVintfInstalls track the install rules created by Soong that are
282 // allowed to have duplicates across modules and variants.
283 katiInitRcInstalls katiInstalls
284 katiVintfInstalls katiInstalls
285 initRcPaths Paths
286 vintfFragmentsPaths Paths
287 installedInitRcPaths InstallPaths
288 installedVintfFragmentsPaths InstallPaths
Colin Cross69452e12023-11-15 11:20:53 -0800289
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800290 testData []DataPath
291
Colin Cross69452e12023-11-15 11:20:53 -0800292 // For tests
293 buildParams []BuildParams
294 ruleParams map[blueprint.Rule]blueprint.RuleParams
295 variables map[string]string
Yu Liu4297ad92024-08-27 19:50:13 +0000296
297 // moduleInfoJSON can be filled out by GenerateAndroidBuildActions to write a JSON file that will
298 // be included in the final module-info.json produced by Make.
299 moduleInfoJSON *ModuleInfoJSON
Yu Liu9a993132024-08-27 23:21:06 +0000300
301 // containersInfo stores the information about the containers and the information of the
302 // apexes the module belongs to.
303 containersInfo ContainersInfo
304
305 // Merged Aconfig files for all transitive deps.
306 aconfigFilePaths Paths
307
308 // complianceMetadataInfo is for different module types to dump metadata.
309 // See android.ModuleContext interface.
310 complianceMetadataInfo *ComplianceMetadataInfo
Colin Cross69452e12023-11-15 11:20:53 -0800311}
312
Cole Faust02987bd2024-03-21 17:58:43 -0700313var _ ModuleContext = &moduleContext{}
314
Colin Cross69452e12023-11-15 11:20:53 -0800315func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
316 return pctx, BuildParams{
317 Rule: ErrorRule,
318 Description: params.Description,
319 Output: params.Output,
320 Outputs: params.Outputs,
321 ImplicitOutput: params.ImplicitOutput,
322 ImplicitOutputs: params.ImplicitOutputs,
323 Args: map[string]string{
324 "error": err.Error(),
325 },
326 }
327}
328
329func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
330 m.Build(pctx, BuildParams(params))
331}
332
Colin Cross69452e12023-11-15 11:20:53 -0800333// Convert build parameters from their concrete Android types into their string representations,
334// and combine the singular and plural fields of the same type (e.g. Output and Outputs).
335func convertBuildParams(params BuildParams) blueprint.BuildParams {
336 bparams := blueprint.BuildParams{
337 Rule: params.Rule,
338 Description: params.Description,
339 Deps: params.Deps,
340 Outputs: params.Outputs.Strings(),
341 ImplicitOutputs: params.ImplicitOutputs.Strings(),
Colin Cross69452e12023-11-15 11:20:53 -0800342 Inputs: params.Inputs.Strings(),
343 Implicits: params.Implicits.Strings(),
344 OrderOnly: params.OrderOnly.Strings(),
345 Validations: params.Validations.Strings(),
346 Args: params.Args,
Cole Faust451912d2025-01-10 11:21:18 -0800347 Default: params.Default,
Colin Cross69452e12023-11-15 11:20:53 -0800348 }
349
350 if params.Depfile != nil {
351 bparams.Depfile = params.Depfile.String()
352 }
353 if params.Output != nil {
354 bparams.Outputs = append(bparams.Outputs, params.Output.String())
355 }
Colin Cross69452e12023-11-15 11:20:53 -0800356 if params.ImplicitOutput != nil {
357 bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
358 }
359 if params.Input != nil {
360 bparams.Inputs = append(bparams.Inputs, params.Input.String())
361 }
362 if params.Implicit != nil {
363 bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
364 }
365 if params.Validation != nil {
366 bparams.Validations = append(bparams.Validations, params.Validation.String())
367 }
368
369 bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
370 bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
Colin Cross69452e12023-11-15 11:20:53 -0800371 bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
372 bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
373 bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
374 bparams.Validations = proptools.NinjaEscapeList(bparams.Validations)
375 bparams.Depfile = proptools.NinjaEscape(bparams.Depfile)
376
377 return bparams
378}
379
380func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
381 if m.config.captureBuild {
382 m.variables[name] = value
383 }
384
385 m.bp.Variable(pctx.PackageContext, name, value)
386}
387
388func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
389 argNames ...string) blueprint.Rule {
390
391 if m.config.UseRemoteBuild() {
392 if params.Pool == nil {
393 // When USE_GOMA=true or USE_RBE=true are set and the rule is not supported by goma/RBE, restrict
394 // jobs to the local parallelism value
395 params.Pool = localPool
396 } else if params.Pool == remotePool {
397 // remotePool is a fake pool used to identify rule that are supported for remoting. If the rule's
398 // pool is the remotePool, replace with nil so that ninja runs it at NINJA_REMOTE_NUM_JOBS
399 // parallelism.
400 params.Pool = nil
401 }
402 }
403
404 rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
405
406 if m.config.captureBuild {
407 m.ruleParams[rule] = params
408 }
409
410 return rule
411}
412
413func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
414 if params.Description != "" {
415 params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
416 }
417
418 if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 {
419 pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n",
420 m.ModuleName(), strings.Join(missingDeps, ", ")))
421 }
422
423 if m.config.captureBuild {
424 m.buildParams = append(m.buildParams, params)
425 }
426
427 bparams := convertBuildParams(params)
Colin Cross69452e12023-11-15 11:20:53 -0800428 m.bp.Build(pctx.PackageContext, bparams)
429}
430
431func (m *moduleContext) Phony(name string, deps ...Path) {
Yu Liu54513622024-08-19 20:00:32 +0000432 m.phonies[name] = append(m.phonies[name], deps...)
Colin Cross69452e12023-11-15 11:20:53 -0800433}
434
435func (m *moduleContext) GetMissingDependencies() []string {
436 var missingDeps []string
437 missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
438 missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
439 missingDeps = FirstUniqueStrings(missingDeps)
440 return missingDeps
441}
442
Yu Liud3228ac2024-11-08 23:11:47 +0000443func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) Module {
Yu Liu3ae96652024-12-17 22:27:38 +0000444 deps := m.getDirectDepsInternal(name, tag)
445 if len(deps) == 1 {
446 return deps[0]
447 } else if len(deps) >= 2 {
448 panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
449 name, m.ModuleName()))
450 } else {
451 return nil
Yu Liud3228ac2024-11-08 23:11:47 +0000452 }
Yu Liu3ae96652024-12-17 22:27:38 +0000453}
454
455func (m *moduleContext) GetDirectDepProxyWithTag(name string, tag blueprint.DependencyTag) *ModuleProxy {
456 deps := m.getDirectDepsProxyInternal(name, tag)
457 if len(deps) == 1 {
458 return &deps[0]
459 } else if len(deps) >= 2 {
460 panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
461 name, m.ModuleName()))
462 } else {
463 return nil
464 }
Colin Cross69452e12023-11-15 11:20:53 -0800465}
466
467func (m *moduleContext) ModuleSubDir() string {
468 return m.bp.ModuleSubDir()
469}
470
Colin Cross69452e12023-11-15 11:20:53 -0800471func (m *moduleContext) InstallInData() bool {
472 return m.module.InstallInData()
473}
474
475func (m *moduleContext) InstallInTestcases() bool {
476 return m.module.InstallInTestcases()
477}
478
479func (m *moduleContext) InstallInSanitizerDir() bool {
480 return m.module.InstallInSanitizerDir()
481}
482
483func (m *moduleContext) InstallInRamdisk() bool {
484 return m.module.InstallInRamdisk()
485}
486
487func (m *moduleContext) InstallInVendorRamdisk() bool {
488 return m.module.InstallInVendorRamdisk()
489}
490
491func (m *moduleContext) InstallInDebugRamdisk() bool {
492 return m.module.InstallInDebugRamdisk()
493}
494
495func (m *moduleContext) InstallInRecovery() bool {
496 return m.module.InstallInRecovery()
497}
498
499func (m *moduleContext) InstallInRoot() bool {
500 return m.module.InstallInRoot()
501}
502
503func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
504 return m.module.InstallForceOS()
505}
506
Colin Crossea30d852023-11-29 16:00:16 -0800507func (m *moduleContext) InstallInOdm() bool {
508 return m.module.InstallInOdm()
509}
510
511func (m *moduleContext) InstallInProduct() bool {
512 return m.module.InstallInProduct()
513}
514
Colin Cross69452e12023-11-15 11:20:53 -0800515func (m *moduleContext) InstallInVendor() bool {
516 return m.module.InstallInVendor()
517}
518
Spandan Das27ff7672024-11-06 19:23:57 +0000519func (m *moduleContext) InstallInSystemDlkm() bool {
520 return m.module.InstallInSystemDlkm()
521}
522
523func (m *moduleContext) InstallInVendorDlkm() bool {
524 return m.module.InstallInVendorDlkm()
525}
526
527func (m *moduleContext) InstallInOdmDlkm() bool {
528 return m.module.InstallInOdmDlkm()
529}
530
Colin Cross69452e12023-11-15 11:20:53 -0800531func (m *moduleContext) skipInstall() bool {
532 if m.module.base().commonProperties.SkipInstall {
533 return true
534 }
535
Colin Cross69452e12023-11-15 11:20:53 -0800536 // We'll need a solution for choosing which of modules with the same name in different
537 // namespaces to install. For now, reuse the list of namespaces exported to Make as the
538 // list of namespaces to install in a Soong-only build.
539 if !m.module.base().commonProperties.NamespaceExportedToMake {
540 return true
541 }
542
543 return false
544}
545
Jiyong Park3f627e62024-05-01 16:14:38 +0900546// Tells whether this module is installed to the full install path (ex:
547// out/target/product/<name>/<partition>) or not. If this returns false, the install build rule is
548// not created and this module can only be installed to packaging modules like android_filesystem.
549func (m *moduleContext) requiresFullInstall() bool {
550 if m.skipInstall() {
551 return false
552 }
553
Spandan Das034af2c2024-10-30 21:45:09 +0000554 if m.module.base().commonProperties.HideFromMake {
555 return false
556 }
557
Jiyong Park3f627e62024-05-01 16:14:38 +0900558 if proptools.Bool(m.module.base().commonProperties.No_full_install) {
559 return false
560 }
561
562 return true
563}
564
Colin Cross69452e12023-11-15 11:20:53 -0800565func (m *moduleContext) InstallFile(installPath InstallPath, name string, srcPath Path,
Colin Cross09ad3a62023-11-15 12:29:33 -0800566 deps ...InstallPath) InstallPath {
Colin Crossa6182ab2024-08-21 10:47:44 -0700567 return m.installFile(installPath, name, srcPath, deps, false, true, true, nil)
568}
569
570func (m *moduleContext) InstallFileWithoutCheckbuild(installPath InstallPath, name string, srcPath Path,
571 deps ...InstallPath) InstallPath {
572 return m.installFile(installPath, name, srcPath, deps, false, true, false, nil)
Colin Cross69452e12023-11-15 11:20:53 -0800573}
574
575func (m *moduleContext) InstallExecutable(installPath InstallPath, name string, srcPath Path,
Colin Cross09ad3a62023-11-15 12:29:33 -0800576 deps ...InstallPath) InstallPath {
Colin Crossa6182ab2024-08-21 10:47:44 -0700577 return m.installFile(installPath, name, srcPath, deps, true, true, true, nil)
Colin Cross69452e12023-11-15 11:20:53 -0800578}
579
580func (m *moduleContext) InstallFileWithExtraFilesZip(installPath InstallPath, name string, srcPath Path,
Colin Cross09ad3a62023-11-15 12:29:33 -0800581 extraZip Path, deps ...InstallPath) InstallPath {
Colin Crossa6182ab2024-08-21 10:47:44 -0700582 return m.installFile(installPath, name, srcPath, deps, false, true, true, &extraFilesZip{
Colin Cross69452e12023-11-15 11:20:53 -0800583 zip: extraZip,
584 dir: installPath,
585 })
586}
587
588func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
589 fullInstallPath := installPath.Join(m, name)
590 return m.packageFile(fullInstallPath, srcPath, false)
591}
592
Colin Crossf0c1ede2025-01-23 13:30:36 -0800593func (m *moduleContext) getAconfigPaths() Paths {
594 return m.aconfigFilePaths
Yu Liu9a993132024-08-27 23:21:06 +0000595}
596
597func (m *moduleContext) setAconfigPaths(paths Paths) {
598 m.aconfigFilePaths = paths
Justin Yun74f3f302024-05-07 14:32:14 +0900599}
600
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000601func (m *moduleContext) getOwnerAndOverrides() (string, []string) {
602 owner := m.ModuleName()
603 overrides := slices.Clone(m.Module().base().commonProperties.Overrides)
604 if b, ok := m.Module().(OverridableModule); ok {
605 if b.GetOverriddenBy() != "" {
606 // overriding variant of base module
607 overrides = append(overrides, m.ModuleName()) // com.android.foo
608 owner = m.Module().Name() // com.company.android.foo
609 }
610 }
611 return owner, overrides
612}
613
Colin Cross69452e12023-11-15 11:20:53 -0800614func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec {
615 licenseFiles := m.Module().EffectiveLicenseFiles()
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000616 owner, overrides := m.getOwnerAndOverrides()
Colin Cross69452e12023-11-15 11:20:53 -0800617 spec := PackagingSpec{
618 relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
619 srcPath: srcPath,
620 symlinkTarget: "",
621 executable: executable,
Colin Crossf0c1ede2025-01-23 13:30:36 -0800622 effectiveLicenseFiles: uniquelist.Make(licenseFiles),
Colin Cross69452e12023-11-15 11:20:53 -0800623 partition: fullInstallPath.partition,
Jiyong Park4152b192024-04-30 21:24:21 +0900624 skipInstall: m.skipInstall(),
Colin Crossf0c1ede2025-01-23 13:30:36 -0800625 aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
Jiyong Parkc6a773d2024-05-14 21:49:11 +0900626 archType: m.target.Arch.ArchType,
Colin Crossf0c1ede2025-01-23 13:30:36 -0800627 overrides: uniquelist.Make(overrides),
628 owner: owner,
Colin Cross69452e12023-11-15 11:20:53 -0800629 }
630 m.packagingSpecs = append(m.packagingSpecs, spec)
631 return spec
632}
633
Colin Cross09ad3a62023-11-15 12:29:33 -0800634func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
Colin Crossa6182ab2024-08-21 10:47:44 -0700635 executable bool, hooks bool, checkbuild bool, extraZip *extraFilesZip) InstallPath {
Colin Cross69452e12023-11-15 11:20:53 -0800636
637 fullInstallPath := installPath.Join(m, name)
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800638 if hooks {
639 m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, false)
640 }
Colin Cross69452e12023-11-15 11:20:53 -0800641
Jiyong Park3f627e62024-05-01 16:14:38 +0900642 if m.requiresFullInstall() {
Yu Liubad1eef2024-08-21 22:37:35 +0000643 deps = append(deps, InstallPaths(m.TransitiveInstallFiles.ToList())...)
Cole Faust74d243c2024-12-11 17:57:34 -0800644 if m.config.KatiEnabled() {
645 deps = append(deps, m.installedInitRcPaths...)
646 deps = append(deps, m.installedVintfFragmentsPaths...)
647 }
Colin Cross69452e12023-11-15 11:20:53 -0800648
649 var implicitDeps, orderOnlyDeps Paths
650
651 if m.Host() {
652 // Installed host modules might be used during the build, depend directly on their
653 // dependencies so their timestamp is updated whenever their dependency is updated
Colin Cross09ad3a62023-11-15 12:29:33 -0800654 implicitDeps = InstallPaths(deps).Paths()
Colin Cross69452e12023-11-15 11:20:53 -0800655 } else {
Colin Cross09ad3a62023-11-15 12:29:33 -0800656 orderOnlyDeps = InstallPaths(deps).Paths()
Colin Cross69452e12023-11-15 11:20:53 -0800657 }
658
Cole Faust866ab392025-01-23 12:56:20 -0800659 // When creating the install rule in Soong but embedding in Make, write the rule to a
660 // makefile instead of directly to the ninja file so that main.mk can add the
661 // dependencies from the `required` property that are hard to resolve in Soong.
662 // In soong-only builds, the katiInstall will still be created for semi-legacy code paths
663 // such as module-info.json or compliance, but it will not be used for actually installing
664 // the file.
665 m.katiInstalls = append(m.katiInstalls, katiInstall{
666 from: srcPath,
667 to: fullInstallPath,
668 implicitDeps: implicitDeps,
669 orderOnlyDeps: orderOnlyDeps,
670 executable: executable,
671 extraFiles: extraZip,
672 })
673 if !m.Config().KatiEnabled() {
Spandan Das4d78e012025-01-22 23:25:39 +0000674 rule := CpWithBash
Colin Cross69452e12023-11-15 11:20:53 -0800675 if executable {
Spandan Das4d78e012025-01-22 23:25:39 +0000676 rule = CpExecutableWithBash
Colin Cross69452e12023-11-15 11:20:53 -0800677 }
678
679 extraCmds := ""
680 if extraZip != nil {
681 extraCmds += fmt.Sprintf(" && ( unzip -qDD -d '%s' '%s' 2>&1 | grep -v \"zipfile is empty\"; exit $${PIPESTATUS[0]} )",
682 extraZip.dir.String(), extraZip.zip.String())
683 extraCmds += " || ( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )"
684 implicitDeps = append(implicitDeps, extraZip.zip)
685 }
686
687 m.Build(pctx, BuildParams{
688 Rule: rule,
689 Description: "install " + fullInstallPath.Base(),
690 Output: fullInstallPath,
691 Input: srcPath,
692 Implicits: implicitDeps,
693 OrderOnly: orderOnlyDeps,
Colin Cross69452e12023-11-15 11:20:53 -0800694 Args: map[string]string{
695 "extraCmds": extraCmds,
Spandan Das4d78e012025-01-22 23:25:39 +0000696 "cpFlags": "-f",
Colin Cross69452e12023-11-15 11:20:53 -0800697 },
698 })
699 }
700
701 m.installFiles = append(m.installFiles, fullInstallPath)
702 }
703
704 m.packageFile(fullInstallPath, srcPath, executable)
705
Colin Crossa6182ab2024-08-21 10:47:44 -0700706 if checkbuild {
707 m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
708 }
Colin Cross69452e12023-11-15 11:20:53 -0800709
710 return fullInstallPath
711}
712
713func (m *moduleContext) InstallSymlink(installPath InstallPath, name string, srcPath InstallPath) InstallPath {
714 fullInstallPath := installPath.Join(m, name)
715 m.module.base().hooks.runInstallHooks(m, srcPath, fullInstallPath, true)
716
717 relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
718 if err != nil {
719 panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
720 }
Jiyong Park3f627e62024-05-01 16:14:38 +0900721 if m.requiresFullInstall() {
Colin Cross69452e12023-11-15 11:20:53 -0800722
Cole Faust866ab392025-01-23 12:56:20 -0800723 // When creating the symlink rule in Soong but embedding in Make, write the rule to a
724 // makefile instead of directly to the ninja file so that main.mk can add the
725 // dependencies from the `required` property that are hard to resolve in Soong.
726 // In soong-only builds, the katiInstall will still be created for semi-legacy code paths
727 // such as module-info.json or compliance, but it will not be used for actually installing
728 // the file.
729 m.katiSymlinks = append(m.katiSymlinks, katiInstall{
730 from: srcPath,
731 to: fullInstallPath,
732 })
733 if !m.Config().KatiEnabled() {
Colin Cross69452e12023-11-15 11:20:53 -0800734 // The symlink doesn't need updating when the target is modified, but we sometimes
735 // have a dependency on a symlink to a binary instead of to the binary directly, and
736 // the mtime of the symlink must be updated when the binary is modified, so use a
737 // normal dependency here instead of an order-only dependency.
738 m.Build(pctx, BuildParams{
Spandan Das4d78e012025-01-22 23:25:39 +0000739 Rule: SymlinkWithBash,
Colin Cross69452e12023-11-15 11:20:53 -0800740 Description: "install symlink " + fullInstallPath.Base(),
741 Output: fullInstallPath,
742 Input: srcPath,
Colin Cross69452e12023-11-15 11:20:53 -0800743 Args: map[string]string{
744 "fromPath": relPath,
745 },
746 })
747 }
748
749 m.installFiles = append(m.installFiles, fullInstallPath)
Colin Cross69452e12023-11-15 11:20:53 -0800750 }
751
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000752 owner, overrides := m.getOwnerAndOverrides()
Colin Cross69452e12023-11-15 11:20:53 -0800753 m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
754 relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
755 srcPath: nil,
756 symlinkTarget: relPath,
757 executable: false,
758 partition: fullInstallPath.partition,
Jiyong Park4152b192024-04-30 21:24:21 +0900759 skipInstall: m.skipInstall(),
Colin Crossf0c1ede2025-01-23 13:30:36 -0800760 aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
Jiyong Parkc6a773d2024-05-14 21:49:11 +0900761 archType: m.target.Arch.ArchType,
Colin Crossf0c1ede2025-01-23 13:30:36 -0800762 overrides: uniquelist.Make(overrides),
763 owner: owner,
Colin Cross69452e12023-11-15 11:20:53 -0800764 })
765
766 return fullInstallPath
767}
768
769// installPath/name -> absPath where absPath might be a path that is available only at runtime
770// (e.g. /apex/...)
771func (m *moduleContext) InstallAbsoluteSymlink(installPath InstallPath, name string, absPath string) InstallPath {
772 fullInstallPath := installPath.Join(m, name)
773 m.module.base().hooks.runInstallHooks(m, nil, fullInstallPath, true)
774
Jiyong Park3f627e62024-05-01 16:14:38 +0900775 if m.requiresFullInstall() {
Cole Faust866ab392025-01-23 12:56:20 -0800776 // When creating the symlink rule in Soong but embedding in Make, write the rule to a
777 // makefile instead of directly to the ninja file so that main.mk can add the
778 // dependencies from the `required` property that are hard to resolve in Soong.
779 // In soong-only builds, the katiInstall will still be created for semi-legacy code paths
780 // such as module-info.json or compliance, but it will not be used for actually installing
781 // the file.
782 m.katiSymlinks = append(m.katiSymlinks, katiInstall{
783 absFrom: absPath,
784 to: fullInstallPath,
785 })
786 if !m.Config().KatiEnabled() {
Colin Cross69452e12023-11-15 11:20:53 -0800787 m.Build(pctx, BuildParams{
788 Rule: Symlink,
789 Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
790 Output: fullInstallPath,
Colin Cross69452e12023-11-15 11:20:53 -0800791 Args: map[string]string{
792 "fromPath": absPath,
793 },
794 })
795 }
796
797 m.installFiles = append(m.installFiles, fullInstallPath)
798 }
799
Spandan Dasc1ded7e2024-11-01 00:52:33 +0000800 owner, overrides := m.getOwnerAndOverrides()
Colin Cross69452e12023-11-15 11:20:53 -0800801 m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
802 relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
803 srcPath: nil,
804 symlinkTarget: absPath,
805 executable: false,
806 partition: fullInstallPath.partition,
Jiyong Park4152b192024-04-30 21:24:21 +0900807 skipInstall: m.skipInstall(),
Colin Crossf0c1ede2025-01-23 13:30:36 -0800808 aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
Jiyong Parkc6a773d2024-05-14 21:49:11 +0900809 archType: m.target.Arch.ArchType,
Colin Crossf0c1ede2025-01-23 13:30:36 -0800810 overrides: uniquelist.Make(overrides),
811 owner: owner,
Colin Cross69452e12023-11-15 11:20:53 -0800812 })
813
814 return fullInstallPath
815}
816
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800817func (m *moduleContext) InstallTestData(installPath InstallPath, data []DataPath) InstallPaths {
818 m.testData = append(m.testData, data...)
819
820 ret := make(InstallPaths, 0, len(data))
821 for _, d := range data {
822 relPath := d.ToRelativeInstallPath()
Colin Crossa6182ab2024-08-21 10:47:44 -0700823 installed := m.installFile(installPath, relPath, d.SrcPath, nil, false, false, true, nil)
Colin Cross5c1d5fb2023-11-15 12:39:40 -0800824 ret = append(ret, installed)
825 }
826
827 return ret
828}
829
Colin Crossa6182ab2024-08-21 10:47:44 -0700830// CheckbuildFile specifies the output files that should be built by checkbuild.
831func (m *moduleContext) CheckbuildFile(srcPaths ...Path) {
832 m.checkbuildFiles = append(m.checkbuildFiles, srcPaths...)
833}
834
835// UncheckedModule marks the current module has having no files that should be built by checkbuild.
836func (m *moduleContext) UncheckedModule() {
837 m.uncheckedModule = true
Colin Cross69452e12023-11-15 11:20:53 -0800838}
839
Colin Cross1496fb12024-09-09 16:44:10 -0700840func (m *moduleContext) BlueprintModuleContext() blueprint.ModuleContext {
Colin Cross69452e12023-11-15 11:20:53 -0800841 return m.bp
842}
843
844func (m *moduleContext) LicenseMetadataFile() Path {
Yu Liuec810542024-08-26 18:09:15 +0000845 return m.licenseMetadataFile
Colin Cross69452e12023-11-15 11:20:53 -0800846}
847
Colin Crossd6fd0132023-11-06 13:54:06 -0800848func (m *moduleContext) ModuleInfoJSON() *ModuleInfoJSON {
Yu Liu4297ad92024-08-27 19:50:13 +0000849 if moduleInfoJSON := m.moduleInfoJSON; moduleInfoJSON != nil {
Colin Crossd6fd0132023-11-06 13:54:06 -0800850 return moduleInfoJSON
851 }
852 moduleInfoJSON := &ModuleInfoJSON{}
Yu Liu4297ad92024-08-27 19:50:13 +0000853 m.moduleInfoJSON = moduleInfoJSON
Colin Crossd6fd0132023-11-06 13:54:06 -0800854 return moduleInfoJSON
855}
856
mrziwange6c85812024-05-22 14:36:09 -0700857func (m *moduleContext) SetOutputFiles(outputFiles Paths, tag string) {
Cole Faust5146e782024-11-15 14:47:49 -0800858 for _, outputFile := range outputFiles {
859 if outputFile == nil {
860 panic("outputfiles cannot be nil")
861 }
862 }
mrziwange6c85812024-05-22 14:36:09 -0700863 if tag == "" {
Yu Liu876b7ce2024-08-21 18:20:13 +0000864 if len(m.outputFiles.DefaultOutputFiles) > 0 {
mrziwange6c85812024-05-22 14:36:09 -0700865 m.ModuleErrorf("Module %s default OutputFiles cannot be overwritten", m.ModuleName())
866 }
Yu Liu876b7ce2024-08-21 18:20:13 +0000867 m.outputFiles.DefaultOutputFiles = outputFiles
mrziwange6c85812024-05-22 14:36:09 -0700868 } else {
Yu Liu876b7ce2024-08-21 18:20:13 +0000869 if m.outputFiles.TaggedOutputFiles == nil {
870 m.outputFiles.TaggedOutputFiles = make(map[string]Paths)
mrziwang57768d72024-06-06 11:31:51 -0700871 }
Yu Liu876b7ce2024-08-21 18:20:13 +0000872 if _, exists := m.outputFiles.TaggedOutputFiles[tag]; exists {
mrziwange6c85812024-05-22 14:36:09 -0700873 m.ModuleErrorf("Module %s OutputFiles at tag %s cannot be overwritten", m.ModuleName(), tag)
874 } else {
Yu Liu876b7ce2024-08-21 18:20:13 +0000875 m.outputFiles.TaggedOutputFiles[tag] = outputFiles
mrziwange6c85812024-05-22 14:36:09 -0700876 }
877 }
878}
879
Yu Liu876b7ce2024-08-21 18:20:13 +0000880func (m *moduleContext) GetOutputFiles() OutputFilesInfo {
881 return m.outputFiles
882}
883
Yu Liubad1eef2024-08-21 22:37:35 +0000884func (m *moduleContext) SetLicenseInstallMap(installMap []string) {
885 m.licenseInstallMap = append(m.licenseInstallMap, installMap...)
886}
887
Wei Lia1aa2972024-06-21 13:08:51 -0700888func (m *moduleContext) ComplianceMetadataInfo() *ComplianceMetadataInfo {
Yu Liu9a993132024-08-27 23:21:06 +0000889 if m.complianceMetadataInfo == nil {
890 m.complianceMetadataInfo = NewComplianceMetadataInfo()
Wei Lia1aa2972024-06-21 13:08:51 -0700891 }
Yu Liu9a993132024-08-27 23:21:06 +0000892 return m.complianceMetadataInfo
Wei Lia1aa2972024-06-21 13:08:51 -0700893}
894
Colin Cross69452e12023-11-15 11:20:53 -0800895// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
896// be tagged with `android:"path" to support automatic source module dependency resolution.
897//
898// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
899func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
900 return PathsForModuleSrcExcludes(m, srcFiles, excludes)
901}
902
903// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
904// be tagged with `android:"path" to support automatic source module dependency resolution.
905//
906// Deprecated: use PathForModuleSrc instead.
907func (m *moduleContext) ExpandSource(srcFile, _ string) Path {
908 return PathForModuleSrc(m, srcFile)
909}
910
911// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
912// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
913// dependency resolution.
914func (m *moduleContext) ExpandOptionalSource(srcFile *string, _ string) OptionalPath {
915 if srcFile != nil {
916 return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
917 }
918 return OptionalPath{}
919}
920
Cole Fauste8a87832024-09-11 11:35:46 -0700921func (m *moduleContext) RequiredModuleNames(ctx ConfigurableEvaluatorContext) []string {
Cole Faust43ddd082024-06-17 12:32:40 -0700922 return m.module.RequiredModuleNames(ctx)
Colin Cross69452e12023-11-15 11:20:53 -0800923}
924
925func (m *moduleContext) HostRequiredModuleNames() []string {
926 return m.module.HostRequiredModuleNames()
927}
928
929func (m *moduleContext) TargetRequiredModuleNames() []string {
930 return m.module.TargetRequiredModuleNames()
931}
Yu Liu9a993132024-08-27 23:21:06 +0000932
933func (m *moduleContext) getContainersInfo() ContainersInfo {
934 return m.containersInfo
935}
936
937func (m *moduleContext) setContainersInfo(info ContainersInfo) {
938 m.containersInfo = info
939}