blob: 138b9cd6a7fa8075c92e55b272d16283fc480634 [file] [log] [blame]
Colin Cross3f40fa42015-01-30 17:27:36 -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
Colin Cross635c3b02016-05-18 15:37:25 -070015package android
Colin Cross3f40fa42015-01-30 17:27:36 -080016
17import (
Colin Cross6ff51382015-12-17 16:39:19 -080018 "fmt"
Alex Lightfb4353d2019-01-17 13:57:45 -080019 "path"
Colin Cross3f40fa42015-01-30 17:27:36 -080020 "path/filepath"
Colin Cross6ff51382015-12-17 16:39:19 -080021 "strings"
Colin Crossaabf6792017-11-29 00:27:14 -080022 "text/scanner"
Colin Crossf6566ed2015-03-24 11:13:38 -070023
24 "github.com/google/blueprint"
Colin Cross7f19f372016-11-01 11:10:25 -070025 "github.com/google/blueprint/pathtools"
Colin Crossfe4bc362018-09-12 10:02:13 -070026 "github.com/google/blueprint/proptools"
Colin Cross3f40fa42015-01-30 17:27:36 -080027)
28
29var (
30 DeviceSharedLibrary = "shared_library"
31 DeviceStaticLibrary = "static_library"
32 DeviceExecutable = "executable"
33 HostSharedLibrary = "host_shared_library"
34 HostStaticLibrary = "host_static_library"
35 HostExecutable = "host_executable"
36)
37
Colin Crossae887032017-10-23 17:16:14 -070038type BuildParams struct {
Dan Willemsen9f3c5742016-11-03 14:28:31 -070039 Rule blueprint.Rule
Colin Cross33bfb0a2016-11-21 17:23:08 -080040 Deps blueprint.Deps
41 Depfile WritablePath
Colin Cross67a5c132017-05-09 13:45:28 -070042 Description string
Dan Willemsen9f3c5742016-11-03 14:28:31 -070043 Output WritablePath
44 Outputs WritablePaths
45 ImplicitOutput WritablePath
46 ImplicitOutputs WritablePaths
47 Input Path
48 Inputs Paths
49 Implicit Path
50 Implicits Paths
51 OrderOnly Paths
52 Default bool
53 Args map[string]string
Dan Willemsen34cc69e2015-09-23 15:26:20 -070054}
55
Colin Crossae887032017-10-23 17:16:14 -070056type ModuleBuildParams BuildParams
57
Colin Cross0ea8ba82019-06-06 14:33:29 -070058// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
Colin Crossdc35e212019-06-06 16:13:11 -070059// a Config instead of an interface{}, and some methods have been wrapped to use an android.Module
60// instead of a blueprint.Module, plus some extra methods that return Android-specific information
Colin Cross0ea8ba82019-06-06 14:33:29 -070061// about the current module.
62type BaseModuleContext interface {
Colin Crossdc35e212019-06-06 16:13:11 -070063 Module() Module
Colin Cross0ea8ba82019-06-06 14:33:29 -070064 ModuleName() string
65 ModuleDir() string
66 ModuleType() string
67 Config() Config
68
Colin Crossdc35e212019-06-06 16:13:11 -070069 OtherModuleName(m blueprint.Module) string
70 OtherModuleDir(m blueprint.Module) string
71 OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
72 OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
73 OtherModuleExists(name string) bool
74
75 GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
76 GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
77 GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
78
79 VisitDirectDepsBlueprint(visit func(blueprint.Module))
80 VisitDirectDeps(visit func(Module))
81 VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
82 VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
83 // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
84 VisitDepsDepthFirst(visit func(Module))
85 // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
86 VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
87 WalkDeps(visit func(Module, Module) bool)
88 WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
89 // GetWalkPath is supposed to be called in visit function passed in WalkDeps()
90 // and returns a top-down dependency path from a start module to current child module.
91 GetWalkPath() []Module
92
Colin Cross0ea8ba82019-06-06 14:33:29 -070093 ContainsProperty(name string) bool
94 Errorf(pos scanner.Position, fmt string, args ...interface{})
95 ModuleErrorf(fmt string, args ...interface{})
96 PropertyErrorf(property, fmt string, args ...interface{})
97 Failed() bool
98
99 // GlobWithDeps returns a list of files that match the specified pattern but do not match any
100 // of the patterns in excludes. It also adds efficient dependencies to rerun the primary
101 // builder whenever a file matching the pattern as added or removed, without rerunning if a
102 // file that does not match the pattern is added to a searched directory.
103 GlobWithDeps(pattern string, excludes []string) ([]string, error)
104
Colin Crossdc35e212019-06-06 16:13:11 -0700105 Glob(globPattern string, excludes []string) Paths
106 GlobFiles(globPattern string, excludes []string) Paths
107
Colin Cross0ea8ba82019-06-06 14:33:29 -0700108 Fs() pathtools.FileSystem
109 AddNinjaFileDeps(deps ...string)
110
Colin Crossdc35e212019-06-06 16:13:11 -0700111 AddMissingDependencies(missingDeps []string)
112
Colin Crossa1ad8d12016-06-01 17:09:44 -0700113 Target() Target
Colin Cross8b74d172016-09-13 09:59:14 -0700114 TargetPrimary() bool
Colin Crossee0bc3b2018-10-02 22:01:37 -0700115 MultiTargets() []Target
Colin Crossf6566ed2015-03-24 11:13:38 -0700116 Arch() Arch
Colin Crossa1ad8d12016-06-01 17:09:44 -0700117 Os() OsType
Colin Crossf6566ed2015-03-24 11:13:38 -0700118 Host() bool
119 Device() bool
Colin Cross0af4b842015-04-30 16:36:18 -0700120 Darwin() bool
Doug Horn21b94272019-01-16 12:06:11 -0800121 Fuchsia() bool
Colin Cross3edeee12017-04-04 12:59:48 -0700122 Windows() bool
Colin Crossf6566ed2015-03-24 11:13:38 -0700123 Debug() bool
Colin Cross1e7d3702016-08-24 15:25:47 -0700124 PrimaryArch() bool
Jiyong Park2db76922017-11-08 16:03:48 +0900125 Platform() bool
126 DeviceSpecific() bool
127 SocSpecific() bool
128 ProductSpecific() bool
Justin Yund5f6c822019-06-25 16:47:17 +0900129 SystemExtSpecific() bool
Colin Cross1332b002015-04-07 17:11:30 -0700130 AConfig() Config
Colin Cross9272ade2016-08-17 15:24:12 -0700131 DeviceConfig() DeviceConfig
Colin Crossf6566ed2015-03-24 11:13:38 -0700132}
133
Colin Cross0ea8ba82019-06-06 14:33:29 -0700134// Deprecated: use BaseModuleContext instead
Colin Cross635c3b02016-05-18 15:37:25 -0700135type BaseContext interface {
Colin Crossaabf6792017-11-29 00:27:14 -0800136 BaseModuleContext
Colin Crossaabf6792017-11-29 00:27:14 -0800137}
138
Colin Cross635c3b02016-05-18 15:37:25 -0700139type ModuleContext interface {
Colin Crossaabf6792017-11-29 00:27:14 -0800140 BaseModuleContext
Colin Cross3f40fa42015-01-30 17:27:36 -0800141
Colin Crossae887032017-10-23 17:16:14 -0700142 // Deprecated: use ModuleContext.Build instead.
Colin Cross0875c522017-11-28 17:34:01 -0800143 ModuleBuild(pctx PackageContext, params ModuleBuildParams)
Colin Cross8f101b42015-06-17 15:09:06 -0700144
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700145 ExpandSources(srcFiles, excludes []string) Paths
Colin Cross366938f2017-12-11 16:29:02 -0800146 ExpandSource(srcFile, prop string) Path
Colin Cross2383f3b2018-02-06 14:40:13 -0800147 ExpandOptionalSource(srcFile *string, prop string) OptionalPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700148
Colin Cross5c517922017-08-31 12:29:17 -0700149 InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
150 InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
Colin Cross3854a602016-01-11 12:49:11 -0800151 InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath
Jiyong Parkf1194352019-02-25 11:05:47 +0900152 InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700153 CheckbuildFile(srcPath Path)
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800154
Colin Cross8d8f8e22016-08-03 11:57:50 -0700155 InstallInData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700156 InstallInSanitizerDir() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900157 InstallInRecovery() bool
Nan Zhang6d34b302017-02-04 17:47:46 -0800158
159 RequiredModuleNames() []string
Sasha Smundakb6d23052019-04-01 18:37:36 -0700160 HostRequiredModuleNames() []string
161 TargetRequiredModuleNames() []string
Colin Cross3f68a132017-10-23 17:10:29 -0700162
Colin Cross3f68a132017-10-23 17:10:29 -0700163 ModuleSubDir() string
164
Colin Cross0875c522017-11-28 17:34:01 -0800165 Variable(pctx PackageContext, name, value string)
166 Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
Colin Crossae887032017-10-23 17:16:14 -0700167 // Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
168 // and performs more verification.
Colin Cross0875c522017-11-28 17:34:01 -0800169 Build(pctx PackageContext, params BuildParams)
Colin Cross3f68a132017-10-23 17:10:29 -0700170
Colin Cross0875c522017-11-28 17:34:01 -0800171 PrimaryModule() Module
172 FinalModule() Module
173 VisitAllModuleVariants(visit func(Module))
Colin Cross3f68a132017-10-23 17:10:29 -0700174
175 GetMissingDependencies() []string
Jeff Gaston088e29e2017-11-29 16:47:17 -0800176 Namespace() blueprint.Namespace
Colin Cross3f40fa42015-01-30 17:27:36 -0800177}
178
Colin Cross635c3b02016-05-18 15:37:25 -0700179type Module interface {
Colin Cross3f40fa42015-01-30 17:27:36 -0800180 blueprint.Module
181
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700182 // GenerateAndroidBuildActions is analogous to Blueprints' GenerateBuildActions,
183 // but GenerateAndroidBuildActions also has access to Android-specific information.
184 // For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
Colin Cross635c3b02016-05-18 15:37:25 -0700185 GenerateAndroidBuildActions(ModuleContext)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700186
Colin Cross1e676be2016-10-12 14:38:15 -0700187 DepsMutator(BottomUpMutatorContext)
Colin Cross3f40fa42015-01-30 17:27:36 -0800188
Colin Cross635c3b02016-05-18 15:37:25 -0700189 base() *ModuleBase
Dan Willemsen0effe062015-11-30 16:06:01 -0800190 Enabled() bool
Colin Crossa1ad8d12016-06-01 17:09:44 -0700191 Target() Target
Dan Willemsen782a2d12015-12-21 14:55:28 -0800192 InstallInData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700193 InstallInSanitizerDir() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900194 InstallInRecovery() bool
Colin Crossa2f296f2016-11-29 15:16:18 -0800195 SkipInstall()
Jiyong Park374510b2018-03-19 18:23:01 +0900196 ExportedToMake() bool
Jiyong Park52818fc2019-03-18 12:01:38 +0900197 NoticeFile() OptionalPath
Colin Cross36242852017-06-23 15:06:31 -0700198
199 AddProperties(props ...interface{})
200 GetProperties() []interface{}
Colin Crosscec81712017-07-13 14:43:27 -0700201
Colin Crossae887032017-10-23 17:16:14 -0700202 BuildParamsForTests() []BuildParams
Colin Cross4c83e5c2019-02-25 14:54:28 -0800203 RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800204 VariablesForTests() map[string]string
Paul Duffine2453c72019-05-31 14:00:04 +0100205
Colin Cross9a362232019-07-01 15:32:45 -0700206 // String returns a string that includes the module name and variants for printing during debugging.
207 String() string
208
Paul Duffine2453c72019-05-31 14:00:04 +0100209 // Get the qualified module id for this module.
210 qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName
211
212 // Get information about the properties that can contain visibility rules.
213 visibilityProperties() []visibilityProperty
Paul Duffin63c6e182019-07-24 14:24:38 +0100214
215 // Get the visibility rules that control the visibility of this module.
216 visibility() []string
Paul Duffine2453c72019-05-31 14:00:04 +0100217}
218
219// Qualified id for a module
220type qualifiedModuleName struct {
221 // The package (i.e. directory) in which the module is defined, without trailing /
222 pkg string
223
224 // The name of the module, empty string if package.
225 name string
226}
227
228func (q qualifiedModuleName) String() string {
229 if q.name == "" {
230 return "//" + q.pkg
231 }
232 return "//" + q.pkg + ":" + q.name
233}
234
Paul Duffine484f472019-06-20 16:38:08 +0100235func (q qualifiedModuleName) isRootPackage() bool {
236 return q.pkg == "" && q.name == ""
237}
238
Paul Duffine2453c72019-05-31 14:00:04 +0100239// Get the id for the package containing this module.
240func (q qualifiedModuleName) getContainingPackageId() qualifiedModuleName {
241 pkg := q.pkg
242 if q.name == "" {
Paul Duffine484f472019-06-20 16:38:08 +0100243 if pkg == "" {
244 panic(fmt.Errorf("Cannot get containing package id of root package"))
245 }
246
247 index := strings.LastIndex(pkg, "/")
248 if index == -1 {
249 pkg = ""
250 } else {
251 pkg = pkg[:index]
252 }
Paul Duffine2453c72019-05-31 14:00:04 +0100253 }
254 return newPackageId(pkg)
255}
256
257func newPackageId(pkg string) qualifiedModuleName {
258 // A qualified id for a package module has no name.
259 return qualifiedModuleName{pkg: pkg, name: ""}
Colin Cross3f40fa42015-01-30 17:27:36 -0800260}
261
Colin Crossfc754582016-05-17 16:34:16 -0700262type nameProperties struct {
263 // The name of the module. Must be unique across all modules.
Nan Zhang0007d812017-11-07 10:57:05 -0800264 Name *string
Colin Crossfc754582016-05-17 16:34:16 -0700265}
266
267type commonProperties struct {
Dan Willemsen0effe062015-11-30 16:06:01 -0800268 // emit build rules for this module
269 Enabled *bool `android:"arch_variant"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800270
Paul Duffin2e61fa62019-03-28 14:10:57 +0000271 // Controls the visibility of this module to other modules. Allowable values are one or more of
272 // these formats:
273 //
274 // ["//visibility:public"]: Anyone can use this module.
275 // ["//visibility:private"]: Only rules in the module's package (not its subpackages) can use
276 // this module.
277 // ["//some/package:__pkg__", "//other/package:__pkg__"]: Only modules in some/package and
278 // other/package (defined in some/package/*.bp and other/package/*.bp) have access to
279 // this module. Note that sub-packages do not have access to the rule; for example,
280 // //some/package/foo:bar or //other/package/testing:bla wouldn't have access. __pkg__
281 // is a special module and must be used verbatim. It represents all of the modules in the
282 // package.
283 // ["//project:__subpackages__", "//other:__subpackages__"]: Only modules in packages project
284 // or other or in one of their sub-packages have access to this module. For example,
285 // //project:rule, //project/library:lib or //other/testing/internal:munge are allowed
286 // to depend on this rule (but not //independent:evil)
287 // ["//project"]: This is shorthand for ["//project:__pkg__"]
288 // [":__subpackages__"]: This is shorthand for ["//project:__subpackages__"] where
289 // //project is the module's package. e.g. using [":__subpackages__"] in
290 // packages/apps/Settings/Android.bp is equivalent to
291 // //packages/apps/Settings:__subpackages__.
292 // ["//visibility:legacy_public"]: The default visibility, behaves as //visibility:public
293 // for now. It is an error if it is used in a module.
Paul Duffine2453c72019-05-31 14:00:04 +0100294 //
295 // If a module does not specify the `visibility` property then it uses the
296 // `default_visibility` property of the `package` module in the module's package.
297 //
Paul Duffine484f472019-06-20 16:38:08 +0100298 // If a module does not specify the `visibility` property then it uses the
299 // `default_visibility` property of the `package` module in the module's package.
300 //
Paul Duffine2453c72019-05-31 14:00:04 +0100301 // If the `default_visibility` property is not set for the module's package then
Paul Duffine484f472019-06-20 16:38:08 +0100302 // it will use the `default_visibility` of its closest ancestor package for which
303 // a `default_visibility` property is specified.
304 //
305 // If no `default_visibility` property can be found then the module uses the
306 // global default of `//visibility:legacy_public`.
Paul Duffine2453c72019-05-31 14:00:04 +0100307 //
Paul Duffin95d53b52019-07-24 13:45:05 +0100308 // The `visibility` property has no effect on a defaults module although it does
309 // apply to any non-defaults module that uses it. To set the visibility of a
310 // defaults module, use the `defaults_visibility` property on the defaults module;
311 // not to be confused with the `default_visibility` property on the package module.
312 //
Paul Duffin2e61fa62019-03-28 14:10:57 +0000313 // See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for
314 // more details.
315 Visibility []string
316
Colin Cross7d5136f2015-05-11 13:39:40 -0700317 // control whether this module compiles for 32-bit, 64-bit, or both. Possible values
Colin Cross3f40fa42015-01-30 17:27:36 -0800318 // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both
319 // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit
320 // platform
Colin Cross7d716ba2017-11-01 10:38:29 -0700321 Compile_multilib *string `android:"arch_variant"`
Colin Cross69617d32016-09-06 10:39:07 -0700322
323 Target struct {
324 Host struct {
Colin Cross7d716ba2017-11-01 10:38:29 -0700325 Compile_multilib *string
Colin Cross69617d32016-09-06 10:39:07 -0700326 }
327 Android struct {
Colin Cross7d716ba2017-11-01 10:38:29 -0700328 Compile_multilib *string
Colin Cross69617d32016-09-06 10:39:07 -0700329 }
330 }
331
Colin Crossee0bc3b2018-10-02 22:01:37 -0700332 UseTargetVariants bool `blueprint:"mutated"`
333 Default_multilib string `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800334
Dan Willemsen782a2d12015-12-21 14:55:28 -0800335 // whether this is a proprietary vendor module, and should be installed into /vendor
Colin Cross7d716ba2017-11-01 10:38:29 -0700336 Proprietary *bool
Dan Willemsen782a2d12015-12-21 14:55:28 -0800337
Colin Cross55708f32017-03-20 13:23:34 -0700338 // vendor who owns this module
Dan Willemsenefac4a82017-07-18 19:42:09 -0700339 Owner *string
Colin Cross55708f32017-03-20 13:23:34 -0700340
Jiyong Park2db76922017-11-08 16:03:48 +0900341 // whether this module is specific to an SoC (System-On-a-Chip). When set to true,
342 // it is installed into /vendor (or /system/vendor if vendor partition does not exist).
343 // Use `soc_specific` instead for better meaning.
Colin Cross7d716ba2017-11-01 10:38:29 -0700344 Vendor *bool
Dan Willemsenaa118f92017-04-06 12:49:58 -0700345
Jiyong Park2db76922017-11-08 16:03:48 +0900346 // whether this module is specific to an SoC (System-On-a-Chip). When set to true,
347 // it is installed into /vendor (or /system/vendor if vendor partition does not exist).
348 Soc_specific *bool
349
350 // whether this module is specific to a device, not only for SoC, but also for off-chip
351 // peripherals. When set to true, it is installed into /odm (or /vendor/odm if odm partition
352 // does not exist, or /system/vendor/odm if both odm and vendor partitions do not exist).
353 // This implies `soc_specific:true`.
354 Device_specific *bool
355
356 // whether this module is specific to a software configuration of a product (e.g. country,
Jaekyun Seok5cfbfbb2018-01-10 19:00:15 +0900357 // network operator, etc). When set to true, it is installed into /product (or
358 // /system/product if product partition does not exist).
Jiyong Park2db76922017-11-08 16:03:48 +0900359 Product_specific *bool
360
Justin Yund5f6c822019-06-25 16:47:17 +0900361 // TODO(b/135957588) Product_services_specific will be removed once we clear all Android.bp
362 // files that have 'product_services_specific: true'. This will be converted to
363 // Product_speicific as a workaround.
Dario Freni95cf7672018-08-17 00:57:57 +0100364 Product_services_specific *bool
Dario Frenifd05a742018-05-29 13:28:54 +0100365
Justin Yund5f6c822019-06-25 16:47:17 +0900366 // whether this module extends system. When set to true, it is installed into /system_ext
367 // (or /system/system_ext if system_ext partition does not exist).
368 System_ext_specific *bool
369
Jiyong Parkf9332f12018-02-01 00:54:12 +0900370 // Whether this module is installed to recovery partition
371 Recovery *bool
372
dimitry1f33e402019-03-26 12:39:31 +0100373 // Whether this module is built for non-native architecures (also known as native bridge binary)
374 Native_bridge_supported *bool `android:"arch_variant"`
375
Dan Willemsen2277bcb2016-07-25 20:27:39 -0700376 // init.rc files to be installed if this module is installed
Colin Cross27b922f2019-03-04 22:35:41 -0800377 Init_rc []string `android:"path"`
Dan Willemsen2277bcb2016-07-25 20:27:39 -0700378
Steven Moreland57a23d22018-04-04 15:42:19 -0700379 // VINTF manifest fragments to be installed if this module is installed
Colin Cross27b922f2019-03-04 22:35:41 -0800380 Vintf_fragments []string `android:"path"`
Steven Moreland57a23d22018-04-04 15:42:19 -0700381
Chris Wolfe998306e2016-08-15 14:47:23 -0400382 // names of other modules to install if this module is installed
Colin Crossc602b7d2017-05-05 13:36:36 -0700383 Required []string `android:"arch_variant"`
Chris Wolfe998306e2016-08-15 14:47:23 -0400384
Sasha Smundakb6d23052019-04-01 18:37:36 -0700385 // names of other modules to install on host if this module is installed
386 Host_required []string `android:"arch_variant"`
387
388 // names of other modules to install on target if this module is installed
389 Target_required []string `android:"arch_variant"`
390
Colin Cross5aac3622017-08-31 15:07:09 -0700391 // relative path to a file to include in the list of notices for the device
Colin Cross27b922f2019-03-04 22:35:41 -0800392 Notice *string `android:"path"`
Colin Cross5aac3622017-08-31 15:07:09 -0700393
Dan Willemsen569edc52018-11-19 09:33:29 -0800394 Dist struct {
395 // copy the output of this module to the $DIST_DIR when `dist` is specified on the
396 // command line and any of these targets are also on the command line, or otherwise
397 // built
398 Targets []string `android:"arch_variant"`
399
400 // The name of the output artifact. This defaults to the basename of the output of
401 // the module.
402 Dest *string `android:"arch_variant"`
403
404 // The directory within the dist directory to store the artifact. Defaults to the
405 // top level directory ("").
406 Dir *string `android:"arch_variant"`
407
408 // A suffix to add to the artifact file name (before any extension).
409 Suffix *string `android:"arch_variant"`
410 } `android:"arch_variant"`
411
Colin Crossa1ad8d12016-06-01 17:09:44 -0700412 // Set by TargetMutator
Colin Crossee0bc3b2018-10-02 22:01:37 -0700413 CompileTarget Target `blueprint:"mutated"`
414 CompileMultiTargets []Target `blueprint:"mutated"`
415 CompilePrimary bool `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800416
417 // Set by InitAndroidModule
418 HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
Dan Willemsen0b24c742016-10-04 15:13:37 -0700419 ArchSpecific bool `blueprint:"mutated"`
Colin Crossce75d2c2016-10-06 16:12:58 -0700420
421 SkipInstall bool `blueprint:"mutated"`
Jeff Gaston088e29e2017-11-29 16:47:17 -0800422
423 NamespaceExportedToMake bool `blueprint:"mutated"`
Colin Cross6c4f21f2019-06-06 15:41:36 -0700424
425 MissingDeps []string `blueprint:"mutated"`
Colin Cross9a362232019-07-01 15:32:45 -0700426
427 // Name and variant strings stored by mutators to enable Module.String()
428 DebugName string `blueprint:"mutated"`
429 DebugMutators []string `blueprint:"mutated"`
430 DebugVariations []string `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800431}
432
433type hostAndDeviceProperties struct {
Colin Cross4e81d702018-11-09 10:36:55 -0800434 // If set to true, build a variant of the module for the host. Defaults to false.
435 Host_supported *bool
436
437 // If set to true, build a variant of the module for the device. Defaults to true.
Colin Crossa4190c12016-07-12 13:11:25 -0700438 Device_supported *bool
Colin Cross3f40fa42015-01-30 17:27:36 -0800439}
440
Colin Crossc472d572015-03-17 15:06:21 -0700441type Multilib string
442
443const (
Colin Cross6b4a32d2017-12-05 13:42:45 -0800444 MultilibBoth Multilib = "both"
445 MultilibFirst Multilib = "first"
446 MultilibCommon Multilib = "common"
447 MultilibCommonFirst Multilib = "common_first"
448 MultilibDefault Multilib = ""
Colin Crossc472d572015-03-17 15:06:21 -0700449)
450
Colin Crossa1ad8d12016-06-01 17:09:44 -0700451type HostOrDeviceSupported int
452
453const (
454 _ HostOrDeviceSupported = iota
Dan Albert0981b5c2018-08-02 13:46:35 -0700455
456 // Host and HostCross are built by default. Device is not supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700457 HostSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700458
459 // Host is built by default. HostCross and Device are not supported.
Dan Albertc6345fb2016-10-20 01:36:11 -0700460 HostSupportedNoCross
Dan Albert0981b5c2018-08-02 13:46:35 -0700461
462 // Device is built by default. Host and HostCross are not supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700463 DeviceSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700464
465 // Device is built by default. Host and HostCross are supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700466 HostAndDeviceSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700467
468 // Host, HostCross, and Device are built by default.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700469 HostAndDeviceDefault
Dan Albert0981b5c2018-08-02 13:46:35 -0700470
471 // Nothing is supported. This is not exposed to the user, but used to mark a
472 // host only module as unsupported when the module type is not supported on
473 // the host OS. E.g. benchmarks are supported on Linux but not Darwin.
Dan Willemsen0b24c742016-10-04 15:13:37 -0700474 NeitherHostNorDeviceSupported
Colin Crossa1ad8d12016-06-01 17:09:44 -0700475)
476
Jiyong Park2db76922017-11-08 16:03:48 +0900477type moduleKind int
478
479const (
480 platformModule moduleKind = iota
481 deviceSpecificModule
482 socSpecificModule
483 productSpecificModule
Justin Yund5f6c822019-06-25 16:47:17 +0900484 systemExtSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +0900485)
486
487func (k moduleKind) String() string {
488 switch k {
489 case platformModule:
490 return "platform"
491 case deviceSpecificModule:
492 return "device-specific"
493 case socSpecificModule:
494 return "soc-specific"
495 case productSpecificModule:
496 return "product-specific"
Justin Yund5f6c822019-06-25 16:47:17 +0900497 case systemExtSpecificModule:
498 return "systemext-specific"
Jiyong Park2db76922017-11-08 16:03:48 +0900499 default:
500 panic(fmt.Errorf("unknown module kind %d", k))
501 }
502}
503
Colin Cross36242852017-06-23 15:06:31 -0700504func InitAndroidModule(m Module) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800505 base := m.base()
506 base.module = m
Colin Cross5049f022015-03-18 13:28:46 -0700507
Colin Cross36242852017-06-23 15:06:31 -0700508 m.AddProperties(
Colin Crossfc754582016-05-17 16:34:16 -0700509 &base.nameProperties,
510 &base.commonProperties,
511 &base.variableProperties)
Colin Crossa3a97412019-03-18 12:24:29 -0700512 base.generalProperties = m.GetProperties()
Pirama Arumuga Nainar955dc492018-04-17 14:58:42 -0700513 base.customizableProperties = m.GetProperties()
Paul Duffin63c6e182019-07-24 14:24:38 +0100514
515 // The default_visibility property needs to be checked and parsed by the visibility module during
516 // its checking and parsing phases.
517 base.primaryVisibilityProperty =
518 newVisibilityProperty("visibility", &base.commonProperties.Visibility)
519 base.visibilityPropertyInfo = []visibilityProperty{base.primaryVisibilityProperty}
Colin Cross5049f022015-03-18 13:28:46 -0700520}
521
Colin Cross36242852017-06-23 15:06:31 -0700522func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
523 InitAndroidModule(m)
Colin Cross5049f022015-03-18 13:28:46 -0700524
525 base := m.base()
Colin Cross3f40fa42015-01-30 17:27:36 -0800526 base.commonProperties.HostOrDeviceSupported = hod
Colin Cross69617d32016-09-06 10:39:07 -0700527 base.commonProperties.Default_multilib = string(defaultMultilib)
Dan Willemsen0b24c742016-10-04 15:13:37 -0700528 base.commonProperties.ArchSpecific = true
Colin Crossee0bc3b2018-10-02 22:01:37 -0700529 base.commonProperties.UseTargetVariants = true
Colin Cross3f40fa42015-01-30 17:27:36 -0800530
Dan Willemsen218f6562015-07-08 18:13:11 -0700531 switch hod {
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700532 case HostAndDeviceSupported, HostAndDeviceDefault:
Colin Cross36242852017-06-23 15:06:31 -0700533 m.AddProperties(&base.hostAndDeviceProperties)
Colin Cross3f40fa42015-01-30 17:27:36 -0800534 }
535
Colin Cross36242852017-06-23 15:06:31 -0700536 InitArchModule(m)
Colin Cross3f40fa42015-01-30 17:27:36 -0800537}
538
Colin Crossee0bc3b2018-10-02 22:01:37 -0700539func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
540 InitAndroidArchModule(m, hod, defaultMultilib)
541 m.base().commonProperties.UseTargetVariants = false
542}
543
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800544// A ModuleBase object contains the properties that are common to all Android
Colin Cross3f40fa42015-01-30 17:27:36 -0800545// modules. It should be included as an anonymous field in every module
546// struct definition. InitAndroidModule should then be called from the module's
547// factory function, and the return values from InitAndroidModule should be
548// returned from the factory function.
549//
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800550// The ModuleBase type is responsible for implementing the GenerateBuildActions
551// method to support the blueprint.Module interface. This method will then call
552// the module's GenerateAndroidBuildActions method once for each build variant
Colin Cross25de6c32019-06-06 14:29:25 -0700553// that is to be built. GenerateAndroidBuildActions is passed a ModuleContext
554// rather than the usual blueprint.ModuleContext.
555// ModuleContext exposes extra functionality specific to the Android build
Colin Cross3f40fa42015-01-30 17:27:36 -0800556// system including details about the particular build variant that is to be
557// generated.
558//
559// For example:
560//
561// import (
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800562// "android/soong/android"
Colin Cross3f40fa42015-01-30 17:27:36 -0800563// )
564//
565// type myModule struct {
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800566// android.ModuleBase
Colin Cross3f40fa42015-01-30 17:27:36 -0800567// properties struct {
568// MyProperty string
569// }
570// }
571//
Colin Cross36242852017-06-23 15:06:31 -0700572// func NewMyModule() android.Module) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800573// m := &myModule{}
Colin Cross36242852017-06-23 15:06:31 -0700574// m.AddProperties(&m.properties)
575// android.InitAndroidModule(m)
576// return m
Colin Cross3f40fa42015-01-30 17:27:36 -0800577// }
578//
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800579// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800580// // Get the CPU architecture for the current build variant.
581// variantArch := ctx.Arch()
582//
583// // ...
584// }
Colin Cross635c3b02016-05-18 15:37:25 -0700585type ModuleBase struct {
Colin Cross3f40fa42015-01-30 17:27:36 -0800586 // Putting the curiously recurring thing pointing to the thing that contains
587 // the thing pattern to good use.
Colin Cross36242852017-06-23 15:06:31 -0700588 // TODO: remove this
Colin Cross635c3b02016-05-18 15:37:25 -0700589 module Module
Colin Cross3f40fa42015-01-30 17:27:36 -0800590
Colin Crossfc754582016-05-17 16:34:16 -0700591 nameProperties nameProperties
Colin Cross3f40fa42015-01-30 17:27:36 -0800592 commonProperties commonProperties
Colin Cross7f64b6d2015-07-09 13:57:48 -0700593 variableProperties variableProperties
Colin Cross3f40fa42015-01-30 17:27:36 -0800594 hostAndDeviceProperties hostAndDeviceProperties
595 generalProperties []interface{}
Colin Crossc17727d2018-10-24 12:42:09 -0700596 archProperties [][]interface{}
Colin Crossa120ec12016-08-19 16:07:38 -0700597 customizableProperties []interface{}
Colin Cross3f40fa42015-01-30 17:27:36 -0800598
Paul Duffin63c6e182019-07-24 14:24:38 +0100599 // Information about all the properties on the module that contains visibility rules that need
600 // checking.
601 visibilityPropertyInfo []visibilityProperty
602
603 // The primary visibility property, may be nil, that controls access to the module.
604 primaryVisibilityProperty visibilityProperty
605
Colin Cross3f40fa42015-01-30 17:27:36 -0800606 noAddressSanitizer bool
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700607 installFiles Paths
608 checkbuildFiles Paths
Jiyong Park52818fc2019-03-18 12:01:38 +0900609 noticeFile OptionalPath
Colin Cross1f8c52b2015-06-16 16:38:17 -0700610
611 // Used by buildTargetSingleton to create checkbuild and per-directory build targets
612 // Only set on the final variant of each module
Colin Cross0875c522017-11-28 17:34:01 -0800613 installTarget WritablePath
614 checkbuildTarget WritablePath
Colin Cross1f8c52b2015-06-16 16:38:17 -0700615 blueprintDir string
Colin Crossa120ec12016-08-19 16:07:38 -0700616
Colin Cross178a5092016-09-13 13:42:32 -0700617 hooks hooks
Colin Cross36242852017-06-23 15:06:31 -0700618
619 registerProps []interface{}
Colin Crosscec81712017-07-13 14:43:27 -0700620
621 // For tests
Colin Crossae887032017-10-23 17:16:14 -0700622 buildParams []BuildParams
Colin Cross4c83e5c2019-02-25 14:54:28 -0800623 ruleParams map[blueprint.Rule]blueprint.RuleParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800624 variables map[string]string
Colin Crossa9d8bee2018-10-02 13:59:46 -0700625
626 prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
Colin Cross36242852017-06-23 15:06:31 -0700627}
628
Colin Cross4157e882019-06-06 16:57:04 -0700629func (m *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
Colin Cross5f692ec2019-02-01 16:53:07 -0800630
Colin Cross4157e882019-06-06 16:57:04 -0700631func (m *ModuleBase) AddProperties(props ...interface{}) {
632 m.registerProps = append(m.registerProps, props...)
Colin Cross36242852017-06-23 15:06:31 -0700633}
634
Colin Cross4157e882019-06-06 16:57:04 -0700635func (m *ModuleBase) GetProperties() []interface{} {
636 return m.registerProps
Colin Cross3f40fa42015-01-30 17:27:36 -0800637}
638
Colin Cross4157e882019-06-06 16:57:04 -0700639func (m *ModuleBase) BuildParamsForTests() []BuildParams {
640 return m.buildParams
Colin Crosscec81712017-07-13 14:43:27 -0700641}
642
Colin Cross4157e882019-06-06 16:57:04 -0700643func (m *ModuleBase) RuleParamsForTests() map[blueprint.Rule]blueprint.RuleParams {
644 return m.ruleParams
Colin Cross4c83e5c2019-02-25 14:54:28 -0800645}
646
Colin Cross4157e882019-06-06 16:57:04 -0700647func (m *ModuleBase) VariablesForTests() map[string]string {
648 return m.variables
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800649}
650
Colin Cross4157e882019-06-06 16:57:04 -0700651func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
652 m.prefer32 = prefer32
Colin Crossa9d8bee2018-10-02 13:59:46 -0700653}
654
Colin Crossce75d2c2016-10-06 16:12:58 -0700655// Name returns the name of the module. It may be overridden by individual module types, for
656// example prebuilts will prepend prebuilt_ to the name.
Colin Cross4157e882019-06-06 16:57:04 -0700657func (m *ModuleBase) Name() string {
658 return String(m.nameProperties.Name)
Colin Crossfc754582016-05-17 16:34:16 -0700659}
660
Colin Cross9a362232019-07-01 15:32:45 -0700661// String returns a string that includes the module name and variants for printing during debugging.
662func (m *ModuleBase) String() string {
663 sb := strings.Builder{}
664 sb.WriteString(m.commonProperties.DebugName)
665 sb.WriteString("{")
666 for i := range m.commonProperties.DebugMutators {
667 if i != 0 {
668 sb.WriteString(",")
669 }
670 sb.WriteString(m.commonProperties.DebugMutators[i])
671 sb.WriteString(":")
672 sb.WriteString(m.commonProperties.DebugVariations[i])
673 }
674 sb.WriteString("}")
675 return sb.String()
676}
677
Colin Crossce75d2c2016-10-06 16:12:58 -0700678// BaseModuleName returns the name of the module as specified in the blueprints file.
Colin Cross4157e882019-06-06 16:57:04 -0700679func (m *ModuleBase) BaseModuleName() string {
680 return String(m.nameProperties.Name)
Colin Crossce75d2c2016-10-06 16:12:58 -0700681}
682
Colin Cross4157e882019-06-06 16:57:04 -0700683func (m *ModuleBase) base() *ModuleBase {
684 return m
Colin Cross3f40fa42015-01-30 17:27:36 -0800685}
686
Paul Duffine2453c72019-05-31 14:00:04 +0100687func (m *ModuleBase) qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName {
688 return qualifiedModuleName{pkg: ctx.ModuleDir(), name: ctx.ModuleName()}
689}
690
691func (m *ModuleBase) visibilityProperties() []visibilityProperty {
Paul Duffin63c6e182019-07-24 14:24:38 +0100692 return m.visibilityPropertyInfo
693}
694
695func (m *ModuleBase) visibility() []string {
696 // The soong_namespace module does not initialize the primaryVisibilityProperty.
697 if m.primaryVisibilityProperty != nil {
698 return m.primaryVisibilityProperty.getStrings()
699 } else {
700 return nil
Paul Duffine2453c72019-05-31 14:00:04 +0100701 }
702}
703
Colin Cross4157e882019-06-06 16:57:04 -0700704func (m *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
705 m.commonProperties.CompileTarget = target
706 m.commonProperties.CompileMultiTargets = multiTargets
707 m.commonProperties.CompilePrimary = primary
Colin Crossd3ba0392015-05-07 14:11:29 -0700708}
709
Colin Cross4157e882019-06-06 16:57:04 -0700710func (m *ModuleBase) Target() Target {
711 return m.commonProperties.CompileTarget
Dan Willemsen490fd492015-11-24 17:53:15 -0800712}
713
Colin Cross4157e882019-06-06 16:57:04 -0700714func (m *ModuleBase) TargetPrimary() bool {
715 return m.commonProperties.CompilePrimary
Colin Cross8b74d172016-09-13 09:59:14 -0700716}
717
Colin Cross4157e882019-06-06 16:57:04 -0700718func (m *ModuleBase) MultiTargets() []Target {
719 return m.commonProperties.CompileMultiTargets
Colin Crossee0bc3b2018-10-02 22:01:37 -0700720}
721
Colin Cross4157e882019-06-06 16:57:04 -0700722func (m *ModuleBase) Os() OsType {
723 return m.Target().Os
Dan Willemsen490fd492015-11-24 17:53:15 -0800724}
725
Colin Cross4157e882019-06-06 16:57:04 -0700726func (m *ModuleBase) Host() bool {
727 return m.Os().Class == Host || m.Os().Class == HostCross
Dan Willemsen97750522016-02-09 17:43:51 -0800728}
729
Colin Cross4157e882019-06-06 16:57:04 -0700730func (m *ModuleBase) Arch() Arch {
731 return m.Target().Arch
Dan Willemsen97750522016-02-09 17:43:51 -0800732}
733
Colin Cross4157e882019-06-06 16:57:04 -0700734func (m *ModuleBase) ArchSpecific() bool {
735 return m.commonProperties.ArchSpecific
Dan Willemsen0b24c742016-10-04 15:13:37 -0700736}
737
Colin Cross4157e882019-06-06 16:57:04 -0700738func (m *ModuleBase) OsClassSupported() []OsClass {
739 switch m.commonProperties.HostOrDeviceSupported {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700740 case HostSupported:
Colin Crossa1ad8d12016-06-01 17:09:44 -0700741 return []OsClass{Host, HostCross}
Dan Albertc6345fb2016-10-20 01:36:11 -0700742 case HostSupportedNoCross:
743 return []OsClass{Host}
Colin Crossa1ad8d12016-06-01 17:09:44 -0700744 case DeviceSupported:
745 return []OsClass{Device}
Dan Albert0981b5c2018-08-02 13:46:35 -0700746 case HostAndDeviceSupported, HostAndDeviceDefault:
Colin Crossa1ad8d12016-06-01 17:09:44 -0700747 var supported []OsClass
Colin Cross4157e882019-06-06 16:57:04 -0700748 if Bool(m.hostAndDeviceProperties.Host_supported) ||
749 (m.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
750 m.hostAndDeviceProperties.Host_supported == nil) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700751 supported = append(supported, Host, HostCross)
752 }
Colin Cross4157e882019-06-06 16:57:04 -0700753 if m.hostAndDeviceProperties.Device_supported == nil ||
754 *m.hostAndDeviceProperties.Device_supported {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700755 supported = append(supported, Device)
756 }
757 return supported
758 default:
759 return nil
760 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800761}
762
Colin Cross4157e882019-06-06 16:57:04 -0700763func (m *ModuleBase) DeviceSupported() bool {
764 return m.commonProperties.HostOrDeviceSupported == DeviceSupported ||
765 m.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
766 (m.hostAndDeviceProperties.Device_supported == nil ||
767 *m.hostAndDeviceProperties.Device_supported)
Colin Cross3f40fa42015-01-30 17:27:36 -0800768}
769
Colin Cross4157e882019-06-06 16:57:04 -0700770func (m *ModuleBase) Platform() bool {
Justin Yund5f6c822019-06-25 16:47:17 +0900771 return !m.DeviceSpecific() && !m.SocSpecific() && !m.ProductSpecific() && !m.SystemExtSpecific()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900772}
773
Colin Cross4157e882019-06-06 16:57:04 -0700774func (m *ModuleBase) DeviceSpecific() bool {
775 return Bool(m.commonProperties.Device_specific)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900776}
777
Colin Cross4157e882019-06-06 16:57:04 -0700778func (m *ModuleBase) SocSpecific() bool {
779 return Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900780}
781
Colin Cross4157e882019-06-06 16:57:04 -0700782func (m *ModuleBase) ProductSpecific() bool {
783 return Bool(m.commonProperties.Product_specific)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900784}
785
Justin Yund5f6c822019-06-25 16:47:17 +0900786func (m *ModuleBase) SystemExtSpecific() bool {
787 return Bool(m.commonProperties.System_ext_specific)
Dario Frenifd05a742018-05-29 13:28:54 +0100788}
789
Colin Cross4157e882019-06-06 16:57:04 -0700790func (m *ModuleBase) Enabled() bool {
791 if m.commonProperties.Enabled == nil {
792 return !m.Os().DefaultDisabled
Dan Willemsen490fd492015-11-24 17:53:15 -0800793 }
Colin Cross4157e882019-06-06 16:57:04 -0700794 return *m.commonProperties.Enabled
Colin Cross3f40fa42015-01-30 17:27:36 -0800795}
796
Colin Cross4157e882019-06-06 16:57:04 -0700797func (m *ModuleBase) SkipInstall() {
798 m.commonProperties.SkipInstall = true
Colin Crossce75d2c2016-10-06 16:12:58 -0700799}
800
Colin Cross4157e882019-06-06 16:57:04 -0700801func (m *ModuleBase) ExportedToMake() bool {
802 return m.commonProperties.NamespaceExportedToMake
Jiyong Park374510b2018-03-19 18:23:01 +0900803}
804
Colin Cross4157e882019-06-06 16:57:04 -0700805func (m *ModuleBase) computeInstallDeps(
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700806 ctx blueprint.ModuleContext) Paths {
Colin Cross3f40fa42015-01-30 17:27:36 -0800807
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700808 result := Paths{}
Colin Cross6b753602018-06-21 13:03:07 -0700809 // TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
Colin Cross3f40fa42015-01-30 17:27:36 -0800810 ctx.VisitDepsDepthFirstIf(isFileInstaller,
811 func(m blueprint.Module) {
812 fileInstaller := m.(fileInstaller)
813 files := fileInstaller.filesToInstall()
814 result = append(result, files...)
815 })
816
817 return result
818}
819
Colin Cross4157e882019-06-06 16:57:04 -0700820func (m *ModuleBase) filesToInstall() Paths {
821 return m.installFiles
Colin Cross3f40fa42015-01-30 17:27:36 -0800822}
823
Colin Cross4157e882019-06-06 16:57:04 -0700824func (m *ModuleBase) NoAddressSanitizer() bool {
825 return m.noAddressSanitizer
Colin Cross3f40fa42015-01-30 17:27:36 -0800826}
827
Colin Cross4157e882019-06-06 16:57:04 -0700828func (m *ModuleBase) InstallInData() bool {
Dan Willemsen782a2d12015-12-21 14:55:28 -0800829 return false
830}
831
Colin Cross4157e882019-06-06 16:57:04 -0700832func (m *ModuleBase) InstallInSanitizerDir() bool {
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700833 return false
834}
835
Colin Cross4157e882019-06-06 16:57:04 -0700836func (m *ModuleBase) InstallInRecovery() bool {
837 return Bool(m.commonProperties.Recovery)
Jiyong Parkf9332f12018-02-01 00:54:12 +0900838}
839
Colin Cross4157e882019-06-06 16:57:04 -0700840func (m *ModuleBase) Owner() string {
841 return String(m.commonProperties.Owner)
Sundong Ahn4fd04bb2018-08-31 18:01:37 +0900842}
843
Colin Cross4157e882019-06-06 16:57:04 -0700844func (m *ModuleBase) NoticeFile() OptionalPath {
845 return m.noticeFile
Jiyong Park52818fc2019-03-18 12:01:38 +0900846}
847
Colin Cross4157e882019-06-06 16:57:04 -0700848func (m *ModuleBase) generateModuleTarget(ctx ModuleContext) {
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700849 allInstalledFiles := Paths{}
850 allCheckbuildFiles := Paths{}
Colin Cross0875c522017-11-28 17:34:01 -0800851 ctx.VisitAllModuleVariants(func(module Module) {
852 a := module.base()
Colin Crossc9404352015-03-26 16:10:12 -0700853 allInstalledFiles = append(allInstalledFiles, a.installFiles...)
854 allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800855 })
856
Colin Cross0875c522017-11-28 17:34:01 -0800857 var deps Paths
Colin Cross9454bfa2015-03-17 13:24:18 -0700858
Jeff Gaston088e29e2017-11-29 16:47:17 -0800859 namespacePrefix := ctx.Namespace().(*Namespace).id
860 if namespacePrefix != "" {
861 namespacePrefix = namespacePrefix + "-"
862 }
863
Colin Cross3f40fa42015-01-30 17:27:36 -0800864 if len(allInstalledFiles) > 0 {
Jeff Gaston088e29e2017-11-29 16:47:17 -0800865 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-install")
Colin Cross0875c522017-11-28 17:34:01 -0800866 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700867 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -0800868 Output: name,
869 Implicits: allInstalledFiles,
Colin Crossaabf6792017-11-29 00:27:14 -0800870 Default: !ctx.Config().EmbeddedInMake(),
Colin Cross9454bfa2015-03-17 13:24:18 -0700871 })
872 deps = append(deps, name)
Colin Cross4157e882019-06-06 16:57:04 -0700873 m.installTarget = name
Colin Cross9454bfa2015-03-17 13:24:18 -0700874 }
875
876 if len(allCheckbuildFiles) > 0 {
Jeff Gaston088e29e2017-11-29 16:47:17 -0800877 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-checkbuild")
Colin Cross0875c522017-11-28 17:34:01 -0800878 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700879 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -0800880 Output: name,
881 Implicits: allCheckbuildFiles,
Colin Cross9454bfa2015-03-17 13:24:18 -0700882 })
883 deps = append(deps, name)
Colin Cross4157e882019-06-06 16:57:04 -0700884 m.checkbuildTarget = name
Colin Cross9454bfa2015-03-17 13:24:18 -0700885 }
886
887 if len(deps) > 0 {
Dan Willemsen5ba07e82015-12-11 13:51:06 -0800888 suffix := ""
Colin Crossaabf6792017-11-29 00:27:14 -0800889 if ctx.Config().EmbeddedInMake() {
Dan Willemsen5ba07e82015-12-11 13:51:06 -0800890 suffix = "-soong"
891 }
892
Jeff Gaston088e29e2017-11-29 16:47:17 -0800893 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+suffix)
Colin Cross0875c522017-11-28 17:34:01 -0800894 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700895 Rule: blueprint.Phony,
Jeff Gaston088e29e2017-11-29 16:47:17 -0800896 Outputs: []WritablePath{name},
Colin Cross9454bfa2015-03-17 13:24:18 -0700897 Implicits: deps,
Colin Cross3f40fa42015-01-30 17:27:36 -0800898 })
Colin Cross1f8c52b2015-06-16 16:38:17 -0700899
Colin Cross4157e882019-06-06 16:57:04 -0700900 m.blueprintDir = ctx.ModuleDir()
Colin Cross3f40fa42015-01-30 17:27:36 -0800901 }
902}
903
Colin Cross4157e882019-06-06 16:57:04 -0700904func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleKind {
905 var socSpecific = Bool(m.commonProperties.Vendor) || Bool(m.commonProperties.Proprietary) || Bool(m.commonProperties.Soc_specific)
906 var deviceSpecific = Bool(m.commonProperties.Device_specific)
907 var productSpecific = Bool(m.commonProperties.Product_specific)
Justin Yund5f6c822019-06-25 16:47:17 +0900908 var systemExtSpecific = Bool(m.commonProperties.System_ext_specific)
Jiyong Park2db76922017-11-08 16:03:48 +0900909
Dario Frenifd05a742018-05-29 13:28:54 +0100910 msg := "conflicting value set here"
911 if socSpecific && deviceSpecific {
912 ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
Colin Cross4157e882019-06-06 16:57:04 -0700913 if Bool(m.commonProperties.Vendor) {
Jiyong Park2db76922017-11-08 16:03:48 +0900914 ctx.PropertyErrorf("vendor", msg)
915 }
Colin Cross4157e882019-06-06 16:57:04 -0700916 if Bool(m.commonProperties.Proprietary) {
Jiyong Park2db76922017-11-08 16:03:48 +0900917 ctx.PropertyErrorf("proprietary", msg)
918 }
Colin Cross4157e882019-06-06 16:57:04 -0700919 if Bool(m.commonProperties.Soc_specific) {
Jiyong Park2db76922017-11-08 16:03:48 +0900920 ctx.PropertyErrorf("soc_specific", msg)
921 }
922 }
923
Justin Yund5f6c822019-06-25 16:47:17 +0900924 if productSpecific && systemExtSpecific {
925 ctx.PropertyErrorf("product_specific", "a module cannot be specific to product and system_ext at the same time.")
926 ctx.PropertyErrorf("system_ext_specific", msg)
Dario Frenifd05a742018-05-29 13:28:54 +0100927 }
928
Justin Yund5f6c822019-06-25 16:47:17 +0900929 if (socSpecific || deviceSpecific) && (productSpecific || systemExtSpecific) {
Dario Frenifd05a742018-05-29 13:28:54 +0100930 if productSpecific {
931 ctx.PropertyErrorf("product_specific", "a module cannot be specific to SoC or device and product at the same time.")
932 } else {
Justin Yund5f6c822019-06-25 16:47:17 +0900933 ctx.PropertyErrorf("system_ext_specific", "a module cannot be specific to SoC or device and system_ext at the same time.")
Dario Frenifd05a742018-05-29 13:28:54 +0100934 }
935 if deviceSpecific {
936 ctx.PropertyErrorf("device_specific", msg)
937 } else {
Colin Cross4157e882019-06-06 16:57:04 -0700938 if Bool(m.commonProperties.Vendor) {
Dario Frenifd05a742018-05-29 13:28:54 +0100939 ctx.PropertyErrorf("vendor", msg)
940 }
Colin Cross4157e882019-06-06 16:57:04 -0700941 if Bool(m.commonProperties.Proprietary) {
Dario Frenifd05a742018-05-29 13:28:54 +0100942 ctx.PropertyErrorf("proprietary", msg)
943 }
Colin Cross4157e882019-06-06 16:57:04 -0700944 if Bool(m.commonProperties.Soc_specific) {
Dario Frenifd05a742018-05-29 13:28:54 +0100945 ctx.PropertyErrorf("soc_specific", msg)
946 }
947 }
948 }
949
Jiyong Park2db76922017-11-08 16:03:48 +0900950 if productSpecific {
951 return productSpecificModule
Justin Yund5f6c822019-06-25 16:47:17 +0900952 } else if systemExtSpecific {
953 return systemExtSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +0900954 } else if deviceSpecific {
955 return deviceSpecificModule
956 } else if socSpecific {
957 return socSpecificModule
958 } else {
959 return platformModule
960 }
961}
962
Colin Cross0ea8ba82019-06-06 14:33:29 -0700963func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
964 return baseModuleContext{
965 BaseModuleContext: ctx,
966 target: m.commonProperties.CompileTarget,
967 targetPrimary: m.commonProperties.CompilePrimary,
968 multiTargets: m.commonProperties.CompileMultiTargets,
969 kind: determineModuleKind(m, ctx),
970 config: ctx.Config().(Config),
Colin Cross3f40fa42015-01-30 17:27:36 -0800971 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800972}
973
Colin Cross4157e882019-06-06 16:57:04 -0700974func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
Colin Cross25de6c32019-06-06 14:29:25 -0700975 ctx := &moduleContext{
Colin Cross0ea8ba82019-06-06 14:33:29 -0700976 module: m.module,
Colin Crossdc35e212019-06-06 16:13:11 -0700977 bp: blueprintCtx,
Colin Cross0ea8ba82019-06-06 14:33:29 -0700978 baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
979 installDeps: m.computeInstallDeps(blueprintCtx),
980 installFiles: m.installFiles,
Colin Cross0ea8ba82019-06-06 14:33:29 -0700981 variables: make(map[string]string),
Colin Cross3f40fa42015-01-30 17:27:36 -0800982 }
983
Colin Cross6c4f21f2019-06-06 15:41:36 -0700984 // Temporarily continue to call blueprintCtx.GetMissingDependencies() to maintain the previous behavior of never
985 // reporting missing dependency errors in Blueprint when AllowMissingDependencies == true.
986 // TODO: This will be removed once defaults modules handle missing dependency errors
987 blueprintCtx.GetMissingDependencies()
988
Colin Crossdc35e212019-06-06 16:13:11 -0700989 // For the final GenerateAndroidBuildActions pass, require that all visited dependencies Soong modules and
990 // are enabled.
991 ctx.baseModuleContext.strictVisitDeps = true
992
Colin Cross4c83e5c2019-02-25 14:54:28 -0800993 if ctx.config.captureBuild {
994 ctx.ruleParams = make(map[blueprint.Rule]blueprint.RuleParams)
995 }
996
Colin Cross67a5c132017-05-09 13:45:28 -0700997 desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
998 var suffix []string
Colin Cross0875c522017-11-28 17:34:01 -0800999 if ctx.Os().Class != Device && ctx.Os().Class != Generic {
1000 suffix = append(suffix, ctx.Os().String())
Colin Cross67a5c132017-05-09 13:45:28 -07001001 }
Colin Cross0875c522017-11-28 17:34:01 -08001002 if !ctx.PrimaryArch() {
1003 suffix = append(suffix, ctx.Arch().ArchType.String())
Colin Cross67a5c132017-05-09 13:45:28 -07001004 }
1005
1006 ctx.Variable(pctx, "moduleDesc", desc)
1007
1008 s := ""
1009 if len(suffix) > 0 {
1010 s = " [" + strings.Join(suffix, " ") + "]"
1011 }
1012 ctx.Variable(pctx, "moduleDescSuffix", s)
1013
Dan Willemsen569edc52018-11-19 09:33:29 -08001014 // Some common property checks for properties that will be used later in androidmk.go
Colin Cross4157e882019-06-06 16:57:04 -07001015 if m.commonProperties.Dist.Dest != nil {
1016 _, err := validateSafePath(*m.commonProperties.Dist.Dest)
Dan Willemsen569edc52018-11-19 09:33:29 -08001017 if err != nil {
1018 ctx.PropertyErrorf("dist.dest", "%s", err.Error())
1019 }
1020 }
Colin Cross4157e882019-06-06 16:57:04 -07001021 if m.commonProperties.Dist.Dir != nil {
1022 _, err := validateSafePath(*m.commonProperties.Dist.Dir)
Dan Willemsen569edc52018-11-19 09:33:29 -08001023 if err != nil {
1024 ctx.PropertyErrorf("dist.dir", "%s", err.Error())
1025 }
1026 }
Colin Cross4157e882019-06-06 16:57:04 -07001027 if m.commonProperties.Dist.Suffix != nil {
1028 if strings.Contains(*m.commonProperties.Dist.Suffix, "/") {
Dan Willemsen569edc52018-11-19 09:33:29 -08001029 ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
1030 }
1031 }
1032
Colin Cross4157e882019-06-06 16:57:04 -07001033 if m.Enabled() {
Colin Cross4157e882019-06-06 16:57:04 -07001034 notice := proptools.StringDefault(m.commonProperties.Notice, "NOTICE")
1035 if module := SrcIsModule(notice); module != "" {
1036 m.noticeFile = ctx.ExpandOptionalSource(&notice, "notice")
Jiyong Park52818fc2019-03-18 12:01:38 +09001037 } else {
1038 noticePath := filepath.Join(ctx.ModuleDir(), notice)
Colin Cross4157e882019-06-06 16:57:04 -07001039 m.noticeFile = ExistentPathForSource(ctx, noticePath)
Jaewoong Jung62707f72018-11-16 13:26:43 -08001040 }
Jaewoong Jung5b425e22019-06-17 17:40:56 -07001041
1042 m.module.GenerateAndroidBuildActions(ctx)
1043 if ctx.Failed() {
1044 return
1045 }
1046
1047 m.installFiles = append(m.installFiles, ctx.installFiles...)
1048 m.checkbuildFiles = append(m.checkbuildFiles, ctx.checkbuildFiles...)
Colin Crossdc35e212019-06-06 16:13:11 -07001049 } else if ctx.Config().AllowMissingDependencies() {
1050 // If the module is not enabled it will not create any build rules, nothing will call
1051 // ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled
1052 // and report them as an error even when AllowMissingDependencies = true. Call
1053 // ctx.GetMissingDependencies() here to tell blueprint not to handle them.
1054 ctx.GetMissingDependencies()
Colin Cross3f40fa42015-01-30 17:27:36 -08001055 }
1056
Colin Cross4157e882019-06-06 16:57:04 -07001057 if m == ctx.FinalModule().(Module).base() {
1058 m.generateModuleTarget(ctx)
Colin Cross9b1d13d2016-09-19 15:18:11 -07001059 if ctx.Failed() {
1060 return
1061 }
Colin Cross3f40fa42015-01-30 17:27:36 -08001062 }
Colin Crosscec81712017-07-13 14:43:27 -07001063
Colin Cross4157e882019-06-06 16:57:04 -07001064 m.buildParams = ctx.buildParams
1065 m.ruleParams = ctx.ruleParams
1066 m.variables = ctx.variables
Colin Cross3f40fa42015-01-30 17:27:36 -08001067}
1068
Colin Cross0ea8ba82019-06-06 14:33:29 -07001069type baseModuleContext struct {
1070 blueprint.BaseModuleContext
Colin Cross8b74d172016-09-13 09:59:14 -07001071 target Target
Colin Crossee0bc3b2018-10-02 22:01:37 -07001072 multiTargets []Target
Colin Cross8b74d172016-09-13 09:59:14 -07001073 targetPrimary bool
1074 debug bool
Jiyong Park2db76922017-11-08 16:03:48 +09001075 kind moduleKind
Colin Cross8b74d172016-09-13 09:59:14 -07001076 config Config
Colin Crossdc35e212019-06-06 16:13:11 -07001077
1078 walkPath []Module
1079
1080 strictVisitDeps bool // If true, enforce that all dependencies are enabled
Colin Crossf6566ed2015-03-24 11:13:38 -07001081}
1082
Colin Cross25de6c32019-06-06 14:29:25 -07001083type moduleContext struct {
Colin Crossdc35e212019-06-06 16:13:11 -07001084 bp blueprint.ModuleContext
Colin Cross0ea8ba82019-06-06 14:33:29 -07001085 baseModuleContext
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001086 installDeps Paths
1087 installFiles Paths
1088 checkbuildFiles Paths
Colin Cross8d8f8e22016-08-03 11:57:50 -07001089 module Module
Colin Crosscec81712017-07-13 14:43:27 -07001090
1091 // For tests
Colin Crossae887032017-10-23 17:16:14 -07001092 buildParams []BuildParams
Colin Cross4c83e5c2019-02-25 14:54:28 -08001093 ruleParams map[blueprint.Rule]blueprint.RuleParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -08001094 variables map[string]string
Colin Cross6ff51382015-12-17 16:39:19 -08001095}
1096
Colin Crossb88b3c52019-06-10 15:15:17 -07001097func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
1098 return pctx, BuildParams{
Colin Cross4b69c492019-06-07 13:06:06 -07001099 Rule: ErrorRule,
1100 Description: params.Description,
1101 Output: params.Output,
1102 Outputs: params.Outputs,
1103 ImplicitOutput: params.ImplicitOutput,
1104 ImplicitOutputs: params.ImplicitOutputs,
Colin Cross6ff51382015-12-17 16:39:19 -08001105 Args: map[string]string{
1106 "error": err.Error(),
1107 },
Colin Crossb88b3c52019-06-10 15:15:17 -07001108 }
Colin Cross3f40fa42015-01-30 17:27:36 -08001109}
1110
Colin Cross25de6c32019-06-06 14:29:25 -07001111func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
1112 m.Build(pctx, BuildParams(params))
Colin Cross3f40fa42015-01-30 17:27:36 -08001113}
1114
Colin Cross0875c522017-11-28 17:34:01 -08001115func convertBuildParams(params BuildParams) blueprint.BuildParams {
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001116 bparams := blueprint.BuildParams{
Dan Willemsen9f3c5742016-11-03 14:28:31 -07001117 Rule: params.Rule,
Colin Cross0875c522017-11-28 17:34:01 -08001118 Description: params.Description,
Colin Cross33bfb0a2016-11-21 17:23:08 -08001119 Deps: params.Deps,
Dan Willemsen9f3c5742016-11-03 14:28:31 -07001120 Outputs: params.Outputs.Strings(),
1121 ImplicitOutputs: params.ImplicitOutputs.Strings(),
1122 Inputs: params.Inputs.Strings(),
1123 Implicits: params.Implicits.Strings(),
1124 OrderOnly: params.OrderOnly.Strings(),
1125 Args: params.Args,
1126 Optional: !params.Default,
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001127 }
1128
Colin Cross33bfb0a2016-11-21 17:23:08 -08001129 if params.Depfile != nil {
1130 bparams.Depfile = params.Depfile.String()
1131 }
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001132 if params.Output != nil {
1133 bparams.Outputs = append(bparams.Outputs, params.Output.String())
1134 }
Dan Willemsen9f3c5742016-11-03 14:28:31 -07001135 if params.ImplicitOutput != nil {
1136 bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
1137 }
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001138 if params.Input != nil {
1139 bparams.Inputs = append(bparams.Inputs, params.Input.String())
1140 }
1141 if params.Implicit != nil {
1142 bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
1143 }
1144
Colin Cross0b9f31f2019-02-28 11:00:01 -08001145 bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
1146 bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
1147 bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
1148 bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
1149 bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
1150 bparams.Depfile = proptools.NinjaEscapeList([]string{bparams.Depfile})[0]
Colin Crossfe4bc362018-09-12 10:02:13 -07001151
Colin Cross0875c522017-11-28 17:34:01 -08001152 return bparams
1153}
1154
Colin Cross25de6c32019-06-06 14:29:25 -07001155func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
1156 if m.config.captureBuild {
1157 m.variables[name] = value
Jaewoong Jung38e4fb22018-12-12 09:01:34 -08001158 }
1159
Colin Crossdc35e212019-06-06 16:13:11 -07001160 m.bp.Variable(pctx.PackageContext, name, value)
Colin Cross0875c522017-11-28 17:34:01 -08001161}
1162
Colin Cross25de6c32019-06-06 14:29:25 -07001163func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
Colin Cross0875c522017-11-28 17:34:01 -08001164 argNames ...string) blueprint.Rule {
1165
Colin Crossdc35e212019-06-06 16:13:11 -07001166 rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
Colin Cross4c83e5c2019-02-25 14:54:28 -08001167
Colin Cross25de6c32019-06-06 14:29:25 -07001168 if m.config.captureBuild {
1169 m.ruleParams[rule] = params
Colin Cross4c83e5c2019-02-25 14:54:28 -08001170 }
1171
1172 return rule
Colin Cross0875c522017-11-28 17:34:01 -08001173}
1174
Colin Cross25de6c32019-06-06 14:29:25 -07001175func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
Colin Crossb88b3c52019-06-10 15:15:17 -07001176 if params.Description != "" {
1177 params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
1178 }
1179
1180 if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 {
1181 pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n",
1182 m.ModuleName(), strings.Join(missingDeps, ", ")))
1183 }
1184
Colin Cross25de6c32019-06-06 14:29:25 -07001185 if m.config.captureBuild {
1186 m.buildParams = append(m.buildParams, params)
Colin Cross0875c522017-11-28 17:34:01 -08001187 }
1188
Colin Crossdc35e212019-06-06 16:13:11 -07001189 m.bp.Build(pctx.PackageContext, convertBuildParams(params))
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001190}
1191
Colin Crossdc35e212019-06-06 16:13:11 -07001192func (b *baseModuleContext) Module() Module {
1193 module, _ := b.BaseModuleContext.Module().(Module)
1194 return module
1195}
1196
1197func (b *baseModuleContext) Config() Config {
1198 return b.BaseModuleContext.Config().(Config)
Colin Cross6c4f21f2019-06-06 15:41:36 -07001199}
1200
Colin Cross25de6c32019-06-06 14:29:25 -07001201func (m *moduleContext) GetMissingDependencies() []string {
Colin Cross6c4f21f2019-06-06 15:41:36 -07001202 var missingDeps []string
1203 missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
Colin Crossdc35e212019-06-06 16:13:11 -07001204 missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
Colin Cross6c4f21f2019-06-06 15:41:36 -07001205 missingDeps = FirstUniqueStrings(missingDeps)
1206 return missingDeps
Colin Cross6ff51382015-12-17 16:39:19 -08001207}
1208
Colin Crossdc35e212019-06-06 16:13:11 -07001209func (b *baseModuleContext) AddMissingDependencies(deps []string) {
Dan Willemsen6553f5e2016-03-10 18:14:25 -08001210 if deps != nil {
Colin Crossdc35e212019-06-06 16:13:11 -07001211 missingDeps := &b.Module().base().commonProperties.MissingDeps
Colin Cross6c4f21f2019-06-06 15:41:36 -07001212 *missingDeps = append(*missingDeps, deps...)
1213 *missingDeps = FirstUniqueStrings(*missingDeps)
Dan Willemsen6553f5e2016-03-10 18:14:25 -08001214 }
1215}
1216
Colin Crossdc35e212019-06-06 16:13:11 -07001217func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, strict bool) Module {
Colin Crossd11fcda2017-10-23 17:59:01 -07001218 aModule, _ := module.(Module)
Colin Crossdc35e212019-06-06 16:13:11 -07001219
1220 if !strict {
1221 return aModule
1222 }
1223
Colin Cross380c69a2019-06-10 17:49:58 +00001224 if aModule == nil {
Colin Crossdc35e212019-06-06 16:13:11 -07001225 b.ModuleErrorf("module %q not an android module", b.OtherModuleName(module))
Colin Cross380c69a2019-06-10 17:49:58 +00001226 return nil
1227 }
1228
1229 if !aModule.Enabled() {
Colin Crossdc35e212019-06-06 16:13:11 -07001230 if b.Config().AllowMissingDependencies() {
1231 b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
Colin Cross380c69a2019-06-10 17:49:58 +00001232 } else {
Colin Crossdc35e212019-06-06 16:13:11 -07001233 b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule))
Colin Cross380c69a2019-06-10 17:49:58 +00001234 }
1235 return nil
1236 }
Colin Crossd11fcda2017-10-23 17:59:01 -07001237 return aModule
1238}
1239
Colin Crossdc35e212019-06-06 16:13:11 -07001240func (b *baseModuleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
Jiyong Parkf2976302019-04-17 21:47:37 +09001241 type dep struct {
1242 mod blueprint.Module
1243 tag blueprint.DependencyTag
1244 }
1245 var deps []dep
Colin Crossdc35e212019-06-06 16:13:11 -07001246 b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
Colin Cross25de6c32019-06-06 14:29:25 -07001247 if aModule, _ := module.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
Colin Crossdc35e212019-06-06 16:13:11 -07001248 returnedTag := b.BaseModuleContext.OtherModuleDependencyTag(aModule)
Jiyong Parkf2976302019-04-17 21:47:37 +09001249 if tag == nil || returnedTag == tag {
1250 deps = append(deps, dep{aModule, returnedTag})
1251 }
1252 }
1253 })
1254 if len(deps) == 1 {
1255 return deps[0].mod, deps[0].tag
1256 } else if len(deps) >= 2 {
1257 panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
Colin Crossdc35e212019-06-06 16:13:11 -07001258 name, b.ModuleName()))
Jiyong Parkf2976302019-04-17 21:47:37 +09001259 } else {
1260 return nil, nil
1261 }
1262}
1263
Colin Crossdc35e212019-06-06 16:13:11 -07001264func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
Colin Cross0ef08162019-05-01 15:50:51 -07001265 var deps []Module
Colin Crossdc35e212019-06-06 16:13:11 -07001266 b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
Colin Cross25de6c32019-06-06 14:29:25 -07001267 if aModule, _ := module.(Module); aModule != nil {
Colin Crossdc35e212019-06-06 16:13:11 -07001268 if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
Colin Cross0ef08162019-05-01 15:50:51 -07001269 deps = append(deps, aModule)
1270 }
1271 }
1272 })
1273 return deps
1274}
1275
Colin Cross25de6c32019-06-06 14:29:25 -07001276func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module {
1277 module, _ := m.getDirectDepInternal(name, tag)
1278 return module
Jiyong Parkf2976302019-04-17 21:47:37 +09001279}
1280
Colin Crossdc35e212019-06-06 16:13:11 -07001281func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
1282 return b.getDirectDepInternal(name, nil)
Jiyong Parkf2976302019-04-17 21:47:37 +09001283}
1284
Colin Crossdc35e212019-06-06 16:13:11 -07001285func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
1286 b.BaseModuleContext.VisitDirectDeps(visit)
Colin Cross35143d02017-11-16 00:11:20 -08001287}
1288
Colin Crossdc35e212019-06-06 16:13:11 -07001289func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
1290 b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
1291 if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
Colin Crossd11fcda2017-10-23 17:59:01 -07001292 visit(aModule)
1293 }
1294 })
1295}
1296
Colin Crossdc35e212019-06-06 16:13:11 -07001297func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
1298 b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
1299 if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
1300 if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
Colin Crossee6143c2017-12-30 17:54:27 -08001301 visit(aModule)
1302 }
1303 }
1304 })
1305}
1306
Colin Crossdc35e212019-06-06 16:13:11 -07001307func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
1308 b.BaseModuleContext.VisitDirectDepsIf(
Colin Crossd11fcda2017-10-23 17:59:01 -07001309 // pred
1310 func(module blueprint.Module) bool {
Colin Crossdc35e212019-06-06 16:13:11 -07001311 if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
Colin Crossd11fcda2017-10-23 17:59:01 -07001312 return pred(aModule)
1313 } else {
1314 return false
1315 }
1316 },
1317 // visit
1318 func(module blueprint.Module) {
1319 visit(module.(Module))
1320 })
1321}
1322
Colin Crossdc35e212019-06-06 16:13:11 -07001323func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
1324 b.BaseModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
1325 if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
Colin Crossd11fcda2017-10-23 17:59:01 -07001326 visit(aModule)
1327 }
1328 })
1329}
1330
Colin Crossdc35e212019-06-06 16:13:11 -07001331func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
1332 b.BaseModuleContext.VisitDepsDepthFirstIf(
Colin Crossd11fcda2017-10-23 17:59:01 -07001333 // pred
1334 func(module blueprint.Module) bool {
Colin Crossdc35e212019-06-06 16:13:11 -07001335 if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
Colin Crossd11fcda2017-10-23 17:59:01 -07001336 return pred(aModule)
1337 } else {
1338 return false
1339 }
1340 },
1341 // visit
1342 func(module blueprint.Module) {
1343 visit(module.(Module))
1344 })
1345}
1346
Colin Crossdc35e212019-06-06 16:13:11 -07001347func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
1348 b.BaseModuleContext.WalkDeps(visit)
Alex Light778127a2019-02-27 14:19:50 -08001349}
1350
Colin Crossdc35e212019-06-06 16:13:11 -07001351func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
1352 b.walkPath = []Module{b.Module()}
1353 b.BaseModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
1354 childAndroidModule, _ := child.(Module)
1355 parentAndroidModule, _ := parent.(Module)
Colin Crossd11fcda2017-10-23 17:59:01 -07001356 if childAndroidModule != nil && parentAndroidModule != nil {
Colin Crossdc35e212019-06-06 16:13:11 -07001357 // record walkPath before visit
1358 for b.walkPath[len(b.walkPath)-1] != parentAndroidModule {
1359 b.walkPath = b.walkPath[0 : len(b.walkPath)-1]
1360 }
1361 b.walkPath = append(b.walkPath, childAndroidModule)
Colin Crossd11fcda2017-10-23 17:59:01 -07001362 return visit(childAndroidModule, parentAndroidModule)
1363 } else {
1364 return false
1365 }
1366 })
1367}
1368
Colin Crossdc35e212019-06-06 16:13:11 -07001369func (b *baseModuleContext) GetWalkPath() []Module {
1370 return b.walkPath
1371}
1372
Colin Cross25de6c32019-06-06 14:29:25 -07001373func (m *moduleContext) VisitAllModuleVariants(visit func(Module)) {
Colin Crossdc35e212019-06-06 16:13:11 -07001374 m.bp.VisitAllModuleVariants(func(module blueprint.Module) {
Colin Cross0875c522017-11-28 17:34:01 -08001375 visit(module.(Module))
1376 })
1377}
1378
Colin Cross25de6c32019-06-06 14:29:25 -07001379func (m *moduleContext) PrimaryModule() Module {
Colin Crossdc35e212019-06-06 16:13:11 -07001380 return m.bp.PrimaryModule().(Module)
Colin Cross0875c522017-11-28 17:34:01 -08001381}
1382
Colin Cross25de6c32019-06-06 14:29:25 -07001383func (m *moduleContext) FinalModule() Module {
Colin Crossdc35e212019-06-06 16:13:11 -07001384 return m.bp.FinalModule().(Module)
1385}
1386
1387func (m *moduleContext) ModuleSubDir() string {
1388 return m.bp.ModuleSubDir()
Colin Cross0875c522017-11-28 17:34:01 -08001389}
1390
Colin Cross0ea8ba82019-06-06 14:33:29 -07001391func (b *baseModuleContext) Target() Target {
Colin Cross25de6c32019-06-06 14:29:25 -07001392 return b.target
Colin Crossa1ad8d12016-06-01 17:09:44 -07001393}
1394
Colin Cross0ea8ba82019-06-06 14:33:29 -07001395func (b *baseModuleContext) TargetPrimary() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001396 return b.targetPrimary
Colin Cross8b74d172016-09-13 09:59:14 -07001397}
1398
Colin Cross0ea8ba82019-06-06 14:33:29 -07001399func (b *baseModuleContext) MultiTargets() []Target {
Colin Cross25de6c32019-06-06 14:29:25 -07001400 return b.multiTargets
Colin Crossee0bc3b2018-10-02 22:01:37 -07001401}
1402
Colin Cross0ea8ba82019-06-06 14:33:29 -07001403func (b *baseModuleContext) Arch() Arch {
Colin Cross25de6c32019-06-06 14:29:25 -07001404 return b.target.Arch
Colin Cross3f40fa42015-01-30 17:27:36 -08001405}
1406
Colin Cross0ea8ba82019-06-06 14:33:29 -07001407func (b *baseModuleContext) Os() OsType {
Colin Cross25de6c32019-06-06 14:29:25 -07001408 return b.target.Os
Dan Willemsen490fd492015-11-24 17:53:15 -08001409}
1410
Colin Cross0ea8ba82019-06-06 14:33:29 -07001411func (b *baseModuleContext) Host() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001412 return b.target.Os.Class == Host || b.target.Os.Class == HostCross
Colin Crossf6566ed2015-03-24 11:13:38 -07001413}
1414
Colin Cross0ea8ba82019-06-06 14:33:29 -07001415func (b *baseModuleContext) Device() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001416 return b.target.Os.Class == Device
Colin Crossf6566ed2015-03-24 11:13:38 -07001417}
1418
Colin Cross0ea8ba82019-06-06 14:33:29 -07001419func (b *baseModuleContext) Darwin() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001420 return b.target.Os == Darwin
Colin Cross0af4b842015-04-30 16:36:18 -07001421}
1422
Colin Cross0ea8ba82019-06-06 14:33:29 -07001423func (b *baseModuleContext) Fuchsia() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001424 return b.target.Os == Fuchsia
Doug Horn21b94272019-01-16 12:06:11 -08001425}
1426
Colin Cross0ea8ba82019-06-06 14:33:29 -07001427func (b *baseModuleContext) Windows() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001428 return b.target.Os == Windows
Colin Cross3edeee12017-04-04 12:59:48 -07001429}
1430
Colin Cross0ea8ba82019-06-06 14:33:29 -07001431func (b *baseModuleContext) Debug() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001432 return b.debug
Colin Crossf6566ed2015-03-24 11:13:38 -07001433}
1434
Colin Cross0ea8ba82019-06-06 14:33:29 -07001435func (b *baseModuleContext) PrimaryArch() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001436 if len(b.config.Targets[b.target.Os]) <= 1 {
Colin Cross67a5c132017-05-09 13:45:28 -07001437 return true
1438 }
Colin Cross25de6c32019-06-06 14:29:25 -07001439 return b.target.Arch.ArchType == b.config.Targets[b.target.Os][0].Arch.ArchType
Colin Cross1e7d3702016-08-24 15:25:47 -07001440}
1441
Colin Cross0ea8ba82019-06-06 14:33:29 -07001442func (b *baseModuleContext) AConfig() Config {
Colin Cross25de6c32019-06-06 14:29:25 -07001443 return b.config
Colin Cross1332b002015-04-07 17:11:30 -07001444}
1445
Colin Cross0ea8ba82019-06-06 14:33:29 -07001446func (b *baseModuleContext) DeviceConfig() DeviceConfig {
Colin Cross25de6c32019-06-06 14:29:25 -07001447 return DeviceConfig{b.config.deviceConfig}
Colin Cross9272ade2016-08-17 15:24:12 -07001448}
1449
Colin Cross0ea8ba82019-06-06 14:33:29 -07001450func (b *baseModuleContext) Platform() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001451 return b.kind == platformModule
Jiyong Park2db76922017-11-08 16:03:48 +09001452}
1453
Colin Cross0ea8ba82019-06-06 14:33:29 -07001454func (b *baseModuleContext) DeviceSpecific() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001455 return b.kind == deviceSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +09001456}
1457
Colin Cross0ea8ba82019-06-06 14:33:29 -07001458func (b *baseModuleContext) SocSpecific() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001459 return b.kind == socSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +09001460}
1461
Colin Cross0ea8ba82019-06-06 14:33:29 -07001462func (b *baseModuleContext) ProductSpecific() bool {
Colin Cross25de6c32019-06-06 14:29:25 -07001463 return b.kind == productSpecificModule
Dan Willemsen782a2d12015-12-21 14:55:28 -08001464}
1465
Justin Yund5f6c822019-06-25 16:47:17 +09001466func (b *baseModuleContext) SystemExtSpecific() bool {
1467 return b.kind == systemExtSpecificModule
Dario Frenifd05a742018-05-29 13:28:54 +01001468}
1469
Jiyong Park5baac542018-08-28 09:55:37 +09001470// Makes this module a platform module, i.e. not specific to soc, device,
Justin Yund5f6c822019-06-25 16:47:17 +09001471// product, or system_ext.
Colin Cross4157e882019-06-06 16:57:04 -07001472func (m *ModuleBase) MakeAsPlatform() {
1473 m.commonProperties.Vendor = boolPtr(false)
1474 m.commonProperties.Proprietary = boolPtr(false)
1475 m.commonProperties.Soc_specific = boolPtr(false)
1476 m.commonProperties.Product_specific = boolPtr(false)
Justin Yund5f6c822019-06-25 16:47:17 +09001477 m.commonProperties.System_ext_specific = boolPtr(false)
Jiyong Park5baac542018-08-28 09:55:37 +09001478}
1479
Colin Cross4157e882019-06-06 16:57:04 -07001480func (m *ModuleBase) EnableNativeBridgeSupportByDefault() {
1481 m.commonProperties.Native_bridge_supported = boolPtr(true)
dimitry03dc3f62019-05-09 14:07:34 +02001482}
1483
Colin Cross25de6c32019-06-06 14:29:25 -07001484func (m *moduleContext) InstallInData() bool {
1485 return m.module.InstallInData()
Dan Willemsen782a2d12015-12-21 14:55:28 -08001486}
1487
Colin Cross25de6c32019-06-06 14:29:25 -07001488func (m *moduleContext) InstallInSanitizerDir() bool {
1489 return m.module.InstallInSanitizerDir()
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001490}
1491
Colin Cross25de6c32019-06-06 14:29:25 -07001492func (m *moduleContext) InstallInRecovery() bool {
1493 return m.module.InstallInRecovery()
Jiyong Parkf9332f12018-02-01 00:54:12 +09001494}
1495
Colin Cross25de6c32019-06-06 14:29:25 -07001496func (m *moduleContext) skipInstall(fullInstallPath OutputPath) bool {
1497 if m.module.base().commonProperties.SkipInstall {
Colin Cross893d8162017-04-26 17:34:03 -07001498 return true
1499 }
1500
Colin Cross3607f212018-05-07 15:28:05 -07001501 // We'll need a solution for choosing which of modules with the same name in different
1502 // namespaces to install. For now, reuse the list of namespaces exported to Make as the
1503 // list of namespaces to install in a Soong-only build.
Colin Cross25de6c32019-06-06 14:29:25 -07001504 if !m.module.base().commonProperties.NamespaceExportedToMake {
Colin Cross3607f212018-05-07 15:28:05 -07001505 return true
1506 }
1507
Colin Cross25de6c32019-06-06 14:29:25 -07001508 if m.Device() {
1509 if m.Config().SkipDeviceInstall() {
Colin Cross893d8162017-04-26 17:34:03 -07001510 return true
1511 }
1512
Colin Cross25de6c32019-06-06 14:29:25 -07001513 if m.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
Colin Cross893d8162017-04-26 17:34:03 -07001514 return true
1515 }
1516 }
1517
1518 return false
1519}
1520
Colin Cross25de6c32019-06-06 14:29:25 -07001521func (m *moduleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
Colin Crossa2344662016-03-24 13:14:12 -07001522 deps ...Path) OutputPath {
Colin Cross25de6c32019-06-06 14:29:25 -07001523 return m.installFile(installPath, name, srcPath, Cp, deps)
Colin Cross5c517922017-08-31 12:29:17 -07001524}
1525
Colin Cross25de6c32019-06-06 14:29:25 -07001526func (m *moduleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path,
Colin Cross5c517922017-08-31 12:29:17 -07001527 deps ...Path) OutputPath {
Colin Cross25de6c32019-06-06 14:29:25 -07001528 return m.installFile(installPath, name, srcPath, CpExecutable, deps)
Colin Cross5c517922017-08-31 12:29:17 -07001529}
1530
Colin Cross25de6c32019-06-06 14:29:25 -07001531func (m *moduleContext) installFile(installPath OutputPath, name string, srcPath Path,
Colin Cross5c517922017-08-31 12:29:17 -07001532 rule blueprint.Rule, deps []Path) OutputPath {
Colin Cross35cec122015-04-02 14:37:16 -07001533
Colin Cross25de6c32019-06-06 14:29:25 -07001534 fullInstallPath := installPath.Join(m, name)
1535 m.module.base().hooks.runInstallHooks(m, fullInstallPath, false)
Colin Cross3f40fa42015-01-30 17:27:36 -08001536
Colin Cross25de6c32019-06-06 14:29:25 -07001537 if !m.skipInstall(fullInstallPath) {
Colin Crossce75d2c2016-10-06 16:12:58 -07001538
Colin Cross25de6c32019-06-06 14:29:25 -07001539 deps = append(deps, m.installDeps...)
Colin Cross35cec122015-04-02 14:37:16 -07001540
Colin Cross89562dc2016-10-03 17:47:19 -07001541 var implicitDeps, orderOnlyDeps Paths
1542
Colin Cross25de6c32019-06-06 14:29:25 -07001543 if m.Host() {
Colin Cross89562dc2016-10-03 17:47:19 -07001544 // Installed host modules might be used during the build, depend directly on their
1545 // dependencies so their timestamp is updated whenever their dependency is updated
1546 implicitDeps = deps
1547 } else {
1548 orderOnlyDeps = deps
1549 }
1550
Colin Cross25de6c32019-06-06 14:29:25 -07001551 m.Build(pctx, BuildParams{
Colin Cross5c517922017-08-31 12:29:17 -07001552 Rule: rule,
Colin Cross67a5c132017-05-09 13:45:28 -07001553 Description: "install " + fullInstallPath.Base(),
1554 Output: fullInstallPath,
1555 Input: srcPath,
1556 Implicits: implicitDeps,
1557 OrderOnly: orderOnlyDeps,
Colin Cross25de6c32019-06-06 14:29:25 -07001558 Default: !m.Config().EmbeddedInMake(),
Dan Willemsen322acaf2016-01-12 23:07:05 -08001559 })
Colin Cross3f40fa42015-01-30 17:27:36 -08001560
Colin Cross25de6c32019-06-06 14:29:25 -07001561 m.installFiles = append(m.installFiles, fullInstallPath)
Dan Willemsen322acaf2016-01-12 23:07:05 -08001562 }
Colin Cross25de6c32019-06-06 14:29:25 -07001563 m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
Colin Cross35cec122015-04-02 14:37:16 -07001564 return fullInstallPath
1565}
1566
Colin Cross25de6c32019-06-06 14:29:25 -07001567func (m *moduleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
1568 fullInstallPath := installPath.Join(m, name)
1569 m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
Colin Cross3854a602016-01-11 12:49:11 -08001570
Colin Cross25de6c32019-06-06 14:29:25 -07001571 if !m.skipInstall(fullInstallPath) {
Colin Crossce75d2c2016-10-06 16:12:58 -07001572
Alex Lightfb4353d2019-01-17 13:57:45 -08001573 relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
1574 if err != nil {
1575 panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
1576 }
Colin Cross25de6c32019-06-06 14:29:25 -07001577 m.Build(pctx, BuildParams{
Colin Cross67a5c132017-05-09 13:45:28 -07001578 Rule: Symlink,
1579 Description: "install symlink " + fullInstallPath.Base(),
1580 Output: fullInstallPath,
1581 OrderOnly: Paths{srcPath},
Colin Cross25de6c32019-06-06 14:29:25 -07001582 Default: !m.Config().EmbeddedInMake(),
Colin Cross12fc4972016-01-11 12:49:11 -08001583 Args: map[string]string{
Alex Lightfb4353d2019-01-17 13:57:45 -08001584 "fromPath": relPath,
Colin Cross12fc4972016-01-11 12:49:11 -08001585 },
1586 })
Colin Cross3854a602016-01-11 12:49:11 -08001587
Colin Cross25de6c32019-06-06 14:29:25 -07001588 m.installFiles = append(m.installFiles, fullInstallPath)
1589 m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
Colin Cross12fc4972016-01-11 12:49:11 -08001590 }
Colin Cross3854a602016-01-11 12:49:11 -08001591 return fullInstallPath
1592}
1593
Jiyong Parkf1194352019-02-25 11:05:47 +09001594// installPath/name -> absPath where absPath might be a path that is available only at runtime
1595// (e.g. /apex/...)
Colin Cross25de6c32019-06-06 14:29:25 -07001596func (m *moduleContext) InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath {
1597 fullInstallPath := installPath.Join(m, name)
1598 m.module.base().hooks.runInstallHooks(m, fullInstallPath, true)
Jiyong Parkf1194352019-02-25 11:05:47 +09001599
Colin Cross25de6c32019-06-06 14:29:25 -07001600 if !m.skipInstall(fullInstallPath) {
1601 m.Build(pctx, BuildParams{
Jiyong Parkf1194352019-02-25 11:05:47 +09001602 Rule: Symlink,
1603 Description: "install symlink " + fullInstallPath.Base() + " -> " + absPath,
1604 Output: fullInstallPath,
Colin Cross25de6c32019-06-06 14:29:25 -07001605 Default: !m.Config().EmbeddedInMake(),
Jiyong Parkf1194352019-02-25 11:05:47 +09001606 Args: map[string]string{
1607 "fromPath": absPath,
1608 },
1609 })
1610
Colin Cross25de6c32019-06-06 14:29:25 -07001611 m.installFiles = append(m.installFiles, fullInstallPath)
Jiyong Parkf1194352019-02-25 11:05:47 +09001612 }
1613 return fullInstallPath
1614}
1615
Colin Cross25de6c32019-06-06 14:29:25 -07001616func (m *moduleContext) CheckbuildFile(srcPath Path) {
1617 m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
Colin Cross3f40fa42015-01-30 17:27:36 -08001618}
1619
Colin Cross3f40fa42015-01-30 17:27:36 -08001620type fileInstaller interface {
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001621 filesToInstall() Paths
Colin Cross3f40fa42015-01-30 17:27:36 -08001622}
1623
1624func isFileInstaller(m blueprint.Module) bool {
1625 _, ok := m.(fileInstaller)
1626 return ok
1627}
1628
1629func isAndroidModule(m blueprint.Module) bool {
Colin Cross635c3b02016-05-18 15:37:25 -07001630 _, ok := m.(Module)
Colin Cross3f40fa42015-01-30 17:27:36 -08001631 return ok
1632}
Colin Crossfce53272015-04-08 11:21:40 -07001633
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001634func findStringInSlice(str string, slice []string) int {
1635 for i, s := range slice {
1636 if s == str {
1637 return i
Colin Crossfce53272015-04-08 11:21:40 -07001638 }
1639 }
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001640 return -1
1641}
1642
Colin Cross41955e82019-05-29 14:40:35 -07001643// SrcIsModule decodes module references in the format ":name" into the module name, or empty string if the input
1644// was not a module reference.
1645func SrcIsModule(s string) (module string) {
Colin Cross068e0fe2016-12-13 15:23:47 -08001646 if len(s) > 1 && s[0] == ':' {
1647 return s[1:]
1648 }
1649 return ""
1650}
1651
Colin Cross41955e82019-05-29 14:40:35 -07001652// SrcIsModule decodes module references in the format ":name{.tag}" into the module name and tag, ":name" into the
1653// module name and an empty string for the tag, or empty strings if the input was not a module reference.
1654func SrcIsModuleWithTag(s string) (module, tag string) {
1655 if len(s) > 1 && s[0] == ':' {
1656 module = s[1:]
1657 if tagStart := strings.IndexByte(module, '{'); tagStart > 0 {
1658 if module[len(module)-1] == '}' {
1659 tag = module[tagStart+1 : len(module)-1]
1660 module = module[:tagStart]
1661 return module, tag
1662 }
1663 }
1664 return module, ""
1665 }
1666 return "", ""
Colin Cross068e0fe2016-12-13 15:23:47 -08001667}
1668
Colin Cross41955e82019-05-29 14:40:35 -07001669type sourceOrOutputDependencyTag struct {
1670 blueprint.BaseDependencyTag
1671 tag string
1672}
1673
1674func sourceOrOutputDepTag(tag string) blueprint.DependencyTag {
1675 return sourceOrOutputDependencyTag{tag: tag}
1676}
1677
1678var SourceDepTag = sourceOrOutputDepTag("")
Colin Cross068e0fe2016-12-13 15:23:47 -08001679
Colin Cross366938f2017-12-11 16:29:02 -08001680// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
1681// using ":module" syntax, if any.
Colin Cross27b922f2019-03-04 22:35:41 -08001682//
1683// Deprecated: tag the property with `android:"path"` instead.
Colin Cross068e0fe2016-12-13 15:23:47 -08001684func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
Nan Zhang2439eb72017-04-10 11:27:50 -07001685 set := make(map[string]bool)
1686
Colin Cross068e0fe2016-12-13 15:23:47 -08001687 for _, s := range srcFiles {
Colin Cross41955e82019-05-29 14:40:35 -07001688 if m, t := SrcIsModuleWithTag(s); m != "" {
1689 if _, found := set[s]; found {
1690 ctx.ModuleErrorf("found source dependency duplicate: %q!", s)
Nan Zhang2439eb72017-04-10 11:27:50 -07001691 } else {
Colin Cross41955e82019-05-29 14:40:35 -07001692 set[s] = true
1693 ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(t), m)
Nan Zhang2439eb72017-04-10 11:27:50 -07001694 }
Colin Cross068e0fe2016-12-13 15:23:47 -08001695 }
1696 }
Colin Cross068e0fe2016-12-13 15:23:47 -08001697}
1698
Colin Cross366938f2017-12-11 16:29:02 -08001699// Adds necessary dependencies to satisfy filegroup or generated sources modules specified in s
1700// using ":module" syntax, if any.
Colin Cross27b922f2019-03-04 22:35:41 -08001701//
1702// Deprecated: tag the property with `android:"path"` instead.
Colin Cross366938f2017-12-11 16:29:02 -08001703func ExtractSourceDeps(ctx BottomUpMutatorContext, s *string) {
1704 if s != nil {
Colin Cross41955e82019-05-29 14:40:35 -07001705 if m, t := SrcIsModuleWithTag(*s); m != "" {
1706 ctx.AddDependency(ctx.Module(), sourceOrOutputDepTag(t), m)
Colin Cross366938f2017-12-11 16:29:02 -08001707 }
1708 }
1709}
1710
Colin Cross41955e82019-05-29 14:40:35 -07001711// A module that implements SourceFileProducer can be referenced from any property that is tagged with `android:"path"`
1712// using the ":module" syntax and provides a list of paths to be used as if they were listed in the property.
Colin Cross068e0fe2016-12-13 15:23:47 -08001713type SourceFileProducer interface {
1714 Srcs() Paths
1715}
1716
Colin Cross41955e82019-05-29 14:40:35 -07001717// A module that implements OutputFileProducer can be referenced from any property that is tagged with `android:"path"`
1718// using the ":module" syntax or ":module{.tag}" syntax and provides a list of otuput files to be used as if they were
1719// listed in the property.
1720type OutputFileProducer interface {
1721 OutputFiles(tag string) (Paths, error)
1722}
1723
Colin Crossfe17f6f2019-03-28 19:30:56 -07001724type HostToolProvider interface {
1725 HostToolPath() OptionalPath
1726}
1727
Colin Cross27b922f2019-03-04 22:35:41 -08001728// Returns a list of paths expanded from globs and modules referenced using ":module" syntax. The property must
1729// be tagged with `android:"path" to support automatic source module dependency resolution.
Colin Cross8a497952019-03-05 22:25:09 -08001730//
1731// Deprecated: use PathsForModuleSrc or PathsForModuleSrcExcludes instead.
Colin Cross25de6c32019-06-06 14:29:25 -07001732func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths {
1733 return PathsForModuleSrcExcludes(m, srcFiles, excludes)
Colin Cross8f101b42015-06-17 15:09:06 -07001734}
1735
Colin Cross2fafa3e2019-03-05 12:39:51 -08001736// Returns a single path expanded from globs and modules referenced using ":module" syntax. The property must
1737// be tagged with `android:"path" to support automatic source module dependency resolution.
Colin Cross8a497952019-03-05 22:25:09 -08001738//
1739// Deprecated: use PathForModuleSrc instead.
Colin Cross25de6c32019-06-06 14:29:25 -07001740func (m *moduleContext) ExpandSource(srcFile, prop string) Path {
1741 return PathForModuleSrc(m, srcFile)
Colin Cross2fafa3e2019-03-05 12:39:51 -08001742}
1743
1744// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
1745// the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module
1746// dependency resolution.
Colin Cross25de6c32019-06-06 14:29:25 -07001747func (m *moduleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
Colin Cross2fafa3e2019-03-05 12:39:51 -08001748 if srcFile != nil {
Colin Cross25de6c32019-06-06 14:29:25 -07001749 return OptionalPathForPath(PathForModuleSrc(m, *srcFile))
Colin Cross2fafa3e2019-03-05 12:39:51 -08001750 }
1751 return OptionalPath{}
1752}
1753
Colin Cross25de6c32019-06-06 14:29:25 -07001754func (m *moduleContext) RequiredModuleNames() []string {
1755 return m.module.base().commonProperties.Required
Nan Zhang6d34b302017-02-04 17:47:46 -08001756}
1757
Colin Cross25de6c32019-06-06 14:29:25 -07001758func (m *moduleContext) HostRequiredModuleNames() []string {
1759 return m.module.base().commonProperties.Host_required
Sasha Smundakb6d23052019-04-01 18:37:36 -07001760}
1761
Colin Cross25de6c32019-06-06 14:29:25 -07001762func (m *moduleContext) TargetRequiredModuleNames() []string {
1763 return m.module.base().commonProperties.Target_required
Sasha Smundakb6d23052019-04-01 18:37:36 -07001764}
1765
Colin Crossdc35e212019-06-06 16:13:11 -07001766func (b *baseModuleContext) Glob(globPattern string, excludes []string) Paths {
1767 ret, err := b.GlobWithDeps(globPattern, excludes)
Colin Cross8f101b42015-06-17 15:09:06 -07001768 if err != nil {
Colin Crossdc35e212019-06-06 16:13:11 -07001769 b.ModuleErrorf("glob: %s", err.Error())
Colin Cross8f101b42015-06-17 15:09:06 -07001770 }
Colin Crossdc35e212019-06-06 16:13:11 -07001771 return pathsForModuleSrcFromFullPath(b, ret, true)
Colin Crossfce53272015-04-08 11:21:40 -07001772}
Colin Cross1f8c52b2015-06-16 16:38:17 -07001773
Colin Crossdc35e212019-06-06 16:13:11 -07001774func (b *baseModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
1775 ret, err := b.GlobWithDeps(globPattern, excludes)
Nan Zhang581fd212018-01-10 16:06:12 -08001776 if err != nil {
Colin Crossdc35e212019-06-06 16:13:11 -07001777 b.ModuleErrorf("glob: %s", err.Error())
Nan Zhang581fd212018-01-10 16:06:12 -08001778 }
Colin Crossdc35e212019-06-06 16:13:11 -07001779 return pathsForModuleSrcFromFullPath(b, ret, false)
Nan Zhang581fd212018-01-10 16:06:12 -08001780}
1781
Colin Cross463a90e2015-06-17 14:20:06 -07001782func init() {
Colin Cross798bfce2016-10-12 14:28:16 -07001783 RegisterSingletonType("buildtarget", BuildTargetSingleton)
Colin Cross463a90e2015-06-17 14:20:06 -07001784}
1785
Colin Cross0875c522017-11-28 17:34:01 -08001786func BuildTargetSingleton() Singleton {
Colin Cross1f8c52b2015-06-16 16:38:17 -07001787 return &buildTargetSingleton{}
1788}
1789
Colin Cross87d8b562017-04-25 10:01:55 -07001790func parentDir(dir string) string {
1791 dir, _ = filepath.Split(dir)
1792 return filepath.Clean(dir)
1793}
1794
Colin Cross1f8c52b2015-06-16 16:38:17 -07001795type buildTargetSingleton struct{}
1796
Colin Cross0875c522017-11-28 17:34:01 -08001797func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
1798 var checkbuildDeps Paths
Colin Cross1f8c52b2015-06-16 16:38:17 -07001799
Colin Cross0875c522017-11-28 17:34:01 -08001800 mmTarget := func(dir string) WritablePath {
1801 return PathForPhony(ctx,
1802 "MODULES-IN-"+strings.Replace(filepath.Clean(dir), "/", "-", -1))
Colin Cross87d8b562017-04-25 10:01:55 -07001803 }
1804
Colin Cross0875c522017-11-28 17:34:01 -08001805 modulesInDir := make(map[string]Paths)
Colin Cross1f8c52b2015-06-16 16:38:17 -07001806
Colin Cross0875c522017-11-28 17:34:01 -08001807 ctx.VisitAllModules(func(module Module) {
1808 blueprintDir := module.base().blueprintDir
1809 installTarget := module.base().installTarget
1810 checkbuildTarget := module.base().checkbuildTarget
Colin Cross1f8c52b2015-06-16 16:38:17 -07001811
Colin Cross0875c522017-11-28 17:34:01 -08001812 if checkbuildTarget != nil {
1813 checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
1814 modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
1815 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001816
Colin Cross0875c522017-11-28 17:34:01 -08001817 if installTarget != nil {
1818 modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
Colin Cross1f8c52b2015-06-16 16:38:17 -07001819 }
1820 })
1821
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001822 suffix := ""
Colin Crossaabf6792017-11-29 00:27:14 -08001823 if ctx.Config().EmbeddedInMake() {
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001824 suffix = "-soong"
1825 }
1826
Colin Cross1f8c52b2015-06-16 16:38:17 -07001827 // Create a top-level checkbuild target that depends on all modules
Colin Cross0875c522017-11-28 17:34:01 -08001828 ctx.Build(pctx, BuildParams{
Colin Cross1f8c52b2015-06-16 16:38:17 -07001829 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001830 Output: PathForPhony(ctx, "checkbuild"+suffix),
Colin Cross1f8c52b2015-06-16 16:38:17 -07001831 Implicits: checkbuildDeps,
Colin Cross1f8c52b2015-06-16 16:38:17 -07001832 })
1833
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001834 // Make will generate the MODULES-IN-* targets
Colin Crossaabf6792017-11-29 00:27:14 -08001835 if ctx.Config().EmbeddedInMake() {
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001836 return
1837 }
1838
Colin Cross87d8b562017-04-25 10:01:55 -07001839 // Ensure ancestor directories are in modulesInDir
Inseob Kim1a365c62019-06-08 15:47:51 +09001840 dirs := SortedStringKeys(modulesInDir)
Colin Cross87d8b562017-04-25 10:01:55 -07001841 for _, dir := range dirs {
1842 dir := parentDir(dir)
1843 for dir != "." && dir != "/" {
1844 if _, exists := modulesInDir[dir]; exists {
1845 break
1846 }
1847 modulesInDir[dir] = nil
1848 dir = parentDir(dir)
1849 }
1850 }
1851
1852 // Make directories build their direct subdirectories
Colin Cross87d8b562017-04-25 10:01:55 -07001853 for _, dir := range dirs {
1854 p := parentDir(dir)
1855 if p != "." && p != "/" {
1856 modulesInDir[p] = append(modulesInDir[p], mmTarget(dir))
1857 }
1858 }
1859
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001860 // Create a MODULES-IN-<directory> target that depends on all modules in a directory, and
1861 // depends on the MODULES-IN-* targets of all of its subdirectories that contain Android.bp
1862 // files.
Colin Cross1f8c52b2015-06-16 16:38:17 -07001863 for _, dir := range dirs {
Colin Cross0875c522017-11-28 17:34:01 -08001864 ctx.Build(pctx, BuildParams{
Colin Cross1f8c52b2015-06-16 16:38:17 -07001865 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001866 Output: mmTarget(dir),
Colin Cross87d8b562017-04-25 10:01:55 -07001867 Implicits: modulesInDir[dir],
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001868 // HACK: checkbuild should be an optional build, but force it
1869 // enabled for now in standalone builds
Colin Crossaabf6792017-11-29 00:27:14 -08001870 Default: !ctx.Config().EmbeddedInMake(),
Colin Cross1f8c52b2015-06-16 16:38:17 -07001871 })
1872 }
Dan Willemsen61d88b82017-09-20 17:29:08 -07001873
1874 // Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
1875 osDeps := map[OsType]Paths{}
Colin Cross0875c522017-11-28 17:34:01 -08001876 ctx.VisitAllModules(func(module Module) {
1877 if module.Enabled() {
1878 os := module.Target().Os
1879 osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001880 }
1881 })
1882
Colin Cross0875c522017-11-28 17:34:01 -08001883 osClass := make(map[string]Paths)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001884 for os, deps := range osDeps {
1885 var className string
1886
1887 switch os.Class {
1888 case Host:
1889 className = "host"
1890 case HostCross:
1891 className = "host-cross"
1892 case Device:
1893 className = "target"
1894 default:
1895 continue
1896 }
1897
Colin Cross0875c522017-11-28 17:34:01 -08001898 name := PathForPhony(ctx, className+"-"+os.Name)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001899 osClass[className] = append(osClass[className], name)
1900
Colin Cross0875c522017-11-28 17:34:01 -08001901 ctx.Build(pctx, BuildParams{
Dan Willemsen61d88b82017-09-20 17:29:08 -07001902 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001903 Output: name,
1904 Implicits: deps,
Dan Willemsen61d88b82017-09-20 17:29:08 -07001905 })
1906 }
1907
1908 // Wrap those into host|host-cross|target phony rules
Inseob Kim1a365c62019-06-08 15:47:51 +09001909 for _, class := range SortedStringKeys(osClass) {
Colin Cross0875c522017-11-28 17:34:01 -08001910 ctx.Build(pctx, BuildParams{
Dan Willemsen61d88b82017-09-20 17:29:08 -07001911 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001912 Output: PathForPhony(ctx, class),
Dan Willemsen61d88b82017-09-20 17:29:08 -07001913 Implicits: osClass[class],
Dan Willemsen61d88b82017-09-20 17:29:08 -07001914 })
1915 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001916}
Colin Crossd779da42015-12-17 18:00:23 -08001917
Brandon Lee5d45c6f2018-08-15 15:35:38 -07001918// Collect information for opening IDE project files in java/jdeps.go.
1919type IDEInfo interface {
1920 IDEInfo(ideInfo *IdeInfo)
1921 BaseModuleName() string
1922}
1923
1924// Extract the base module name from the Import name.
1925// Often the Import name has a prefix "prebuilt_".
1926// Remove the prefix explicitly if needed
1927// until we find a better solution to get the Import name.
1928type IDECustomizedModuleName interface {
1929 IDECustomizedModuleName() string
1930}
1931
1932type IdeInfo struct {
1933 Deps []string `json:"dependencies,omitempty"`
1934 Srcs []string `json:"srcs,omitempty"`
1935 Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"`
1936 Jarjar_rules []string `json:"jarjar_rules,omitempty"`
1937 Jars []string `json:"jars,omitempty"`
1938 Classes []string `json:"class,omitempty"`
1939 Installed_paths []string `json:"installed,omitempty"`
patricktu18c82ff2019-05-10 15:48:50 +08001940 SrcJars []string `json:"srcjars,omitempty"`
Brandon Lee5d45c6f2018-08-15 15:35:38 -07001941}