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