blob: 516fa787890206a545c5c7b5e981e20449f853f3 [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 Cross0875c522017-11-28 17:34:01 -080021 "sort"
Colin Cross6ff51382015-12-17 16:39:19 -080022 "strings"
Colin Crossaabf6792017-11-29 00:27:14 -080023 "text/scanner"
Colin Crossf6566ed2015-03-24 11:13:38 -070024
25 "github.com/google/blueprint"
Colin Cross7f19f372016-11-01 11:10:25 -070026 "github.com/google/blueprint/pathtools"
Colin Crossfe4bc362018-09-12 10:02:13 -070027 "github.com/google/blueprint/proptools"
Colin Cross3f40fa42015-01-30 17:27:36 -080028)
29
30var (
31 DeviceSharedLibrary = "shared_library"
32 DeviceStaticLibrary = "static_library"
33 DeviceExecutable = "executable"
34 HostSharedLibrary = "host_shared_library"
35 HostStaticLibrary = "host_static_library"
36 HostExecutable = "host_executable"
37)
38
Colin Crossae887032017-10-23 17:16:14 -070039type BuildParams struct {
Dan Willemsen9f3c5742016-11-03 14:28:31 -070040 Rule blueprint.Rule
Colin Cross33bfb0a2016-11-21 17:23:08 -080041 Deps blueprint.Deps
42 Depfile WritablePath
Colin Cross67a5c132017-05-09 13:45:28 -070043 Description string
Dan Willemsen9f3c5742016-11-03 14:28:31 -070044 Output WritablePath
45 Outputs WritablePaths
46 ImplicitOutput WritablePath
47 ImplicitOutputs WritablePaths
48 Input Path
49 Inputs Paths
50 Implicit Path
51 Implicits Paths
52 OrderOnly Paths
53 Default bool
54 Args map[string]string
Dan Willemsen34cc69e2015-09-23 15:26:20 -070055}
56
Colin Crossae887032017-10-23 17:16:14 -070057type ModuleBuildParams BuildParams
58
Colin Crossf6566ed2015-03-24 11:13:38 -070059type androidBaseContext interface {
Colin Crossa1ad8d12016-06-01 17:09:44 -070060 Target() Target
Colin Cross8b74d172016-09-13 09:59:14 -070061 TargetPrimary() bool
Colin Crossee0bc3b2018-10-02 22:01:37 -070062 MultiTargets() []Target
Colin Crossf6566ed2015-03-24 11:13:38 -070063 Arch() Arch
Colin Crossa1ad8d12016-06-01 17:09:44 -070064 Os() OsType
Colin Crossf6566ed2015-03-24 11:13:38 -070065 Host() bool
66 Device() bool
Colin Cross0af4b842015-04-30 16:36:18 -070067 Darwin() bool
Doug Horn21b94272019-01-16 12:06:11 -080068 Fuchsia() bool
Colin Cross3edeee12017-04-04 12:59:48 -070069 Windows() bool
Colin Crossf6566ed2015-03-24 11:13:38 -070070 Debug() bool
Colin Cross1e7d3702016-08-24 15:25:47 -070071 PrimaryArch() bool
Jiyong Park2db76922017-11-08 16:03:48 +090072 Platform() bool
73 DeviceSpecific() bool
74 SocSpecific() bool
75 ProductSpecific() bool
Dario Frenifd05a742018-05-29 13:28:54 +010076 ProductServicesSpecific() bool
Colin Cross1332b002015-04-07 17:11:30 -070077 AConfig() Config
Colin Cross9272ade2016-08-17 15:24:12 -070078 DeviceConfig() DeviceConfig
Colin Crossf6566ed2015-03-24 11:13:38 -070079}
80
Colin Cross635c3b02016-05-18 15:37:25 -070081type BaseContext interface {
Colin Crossaabf6792017-11-29 00:27:14 -080082 BaseModuleContext
Colin Crossf6566ed2015-03-24 11:13:38 -070083 androidBaseContext
84}
85
Colin Crossaabf6792017-11-29 00:27:14 -080086// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
87// a Config instead of an interface{}.
88type BaseModuleContext interface {
89 ModuleName() string
90 ModuleDir() string
91 Config() Config
92
93 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
105 Fs() pathtools.FileSystem
106 AddNinjaFileDeps(deps ...string)
107}
108
Colin Cross635c3b02016-05-18 15:37:25 -0700109type ModuleContext interface {
Colin Crossf6566ed2015-03-24 11:13:38 -0700110 androidBaseContext
Colin Crossaabf6792017-11-29 00:27:14 -0800111 BaseModuleContext
Colin Cross3f40fa42015-01-30 17:27:36 -0800112
Colin Crossae887032017-10-23 17:16:14 -0700113 // Deprecated: use ModuleContext.Build instead.
Colin Cross0875c522017-11-28 17:34:01 -0800114 ModuleBuild(pctx PackageContext, params ModuleBuildParams)
Colin Cross8f101b42015-06-17 15:09:06 -0700115
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700116 ExpandSources(srcFiles, excludes []string) Paths
Colin Cross366938f2017-12-11 16:29:02 -0800117 ExpandSource(srcFile, prop string) Path
Colin Cross2383f3b2018-02-06 14:40:13 -0800118 ExpandOptionalSource(srcFile *string, prop string) OptionalPath
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800119 ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths
Colin Cross7f19f372016-11-01 11:10:25 -0700120 Glob(globPattern string, excludes []string) Paths
Nan Zhang581fd212018-01-10 16:06:12 -0800121 GlobFiles(globPattern string, excludes []string) Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700122
Colin Cross5c517922017-08-31 12:29:17 -0700123 InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
124 InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
Colin Cross3854a602016-01-11 12:49:11 -0800125 InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700126 CheckbuildFile(srcPath Path)
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800127
128 AddMissingDependencies(deps []string)
Colin Cross8d8f8e22016-08-03 11:57:50 -0700129
Colin Cross8d8f8e22016-08-03 11:57:50 -0700130 InstallInData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700131 InstallInSanitizerDir() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900132 InstallInRecovery() bool
Nan Zhang6d34b302017-02-04 17:47:46 -0800133
134 RequiredModuleNames() []string
Colin Cross3f68a132017-10-23 17:10:29 -0700135
136 // android.ModuleContext methods
137 // These are duplicated instead of embedded so that can eventually be wrapped to take an
138 // android.Module instead of a blueprint.Module
139 OtherModuleName(m blueprint.Module) string
140 OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
141 OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
142
143 GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
144 GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
145
146 ModuleSubDir() string
147
Colin Cross35143d02017-11-16 00:11:20 -0800148 VisitDirectDepsBlueprint(visit func(blueprint.Module))
Colin Crossd11fcda2017-10-23 17:59:01 -0700149 VisitDirectDeps(visit func(Module))
Colin Crossee6143c2017-12-30 17:54:27 -0800150 VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
Colin Crossd11fcda2017-10-23 17:59:01 -0700151 VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
Colin Cross6b753602018-06-21 13:03:07 -0700152 // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
Colin Crossd11fcda2017-10-23 17:59:01 -0700153 VisitDepsDepthFirst(visit func(Module))
Colin Cross6b753602018-06-21 13:03:07 -0700154 // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
Colin Crossd11fcda2017-10-23 17:59:01 -0700155 VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
156 WalkDeps(visit func(Module, Module) bool)
Alex Light778127a2019-02-27 14:19:50 -0800157 WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
Colin Cross3f68a132017-10-23 17:10:29 -0700158
Colin Cross0875c522017-11-28 17:34:01 -0800159 Variable(pctx PackageContext, name, value string)
160 Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
Colin Crossae887032017-10-23 17:16:14 -0700161 // Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
162 // and performs more verification.
Colin Cross0875c522017-11-28 17:34:01 -0800163 Build(pctx PackageContext, params BuildParams)
Colin Cross3f68a132017-10-23 17:10:29 -0700164
Colin Cross0875c522017-11-28 17:34:01 -0800165 PrimaryModule() Module
166 FinalModule() Module
167 VisitAllModuleVariants(visit func(Module))
Colin Cross3f68a132017-10-23 17:10:29 -0700168
169 GetMissingDependencies() []string
Jeff Gaston088e29e2017-11-29 16:47:17 -0800170 Namespace() blueprint.Namespace
Colin Cross3f40fa42015-01-30 17:27:36 -0800171}
172
Colin Cross635c3b02016-05-18 15:37:25 -0700173type Module interface {
Colin Cross3f40fa42015-01-30 17:27:36 -0800174 blueprint.Module
175
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700176 // GenerateAndroidBuildActions is analogous to Blueprints' GenerateBuildActions,
177 // but GenerateAndroidBuildActions also has access to Android-specific information.
178 // For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
Colin Cross635c3b02016-05-18 15:37:25 -0700179 GenerateAndroidBuildActions(ModuleContext)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700180
Colin Cross1e676be2016-10-12 14:38:15 -0700181 DepsMutator(BottomUpMutatorContext)
Colin Cross3f40fa42015-01-30 17:27:36 -0800182
Colin Cross635c3b02016-05-18 15:37:25 -0700183 base() *ModuleBase
Dan Willemsen0effe062015-11-30 16:06:01 -0800184 Enabled() bool
Colin Crossa1ad8d12016-06-01 17:09:44 -0700185 Target() Target
Dan Willemsen782a2d12015-12-21 14:55:28 -0800186 InstallInData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700187 InstallInSanitizerDir() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900188 InstallInRecovery() bool
Colin Crossa2f296f2016-11-29 15:16:18 -0800189 SkipInstall()
Jiyong Park374510b2018-03-19 18:23:01 +0900190 ExportedToMake() bool
Colin Cross36242852017-06-23 15:06:31 -0700191
192 AddProperties(props ...interface{})
193 GetProperties() []interface{}
Colin Crosscec81712017-07-13 14:43:27 -0700194
Colin Crossae887032017-10-23 17:16:14 -0700195 BuildParamsForTests() []BuildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800196 VariablesForTests() map[string]string
Colin Cross3f40fa42015-01-30 17:27:36 -0800197}
198
Colin Crossfc754582016-05-17 16:34:16 -0700199type nameProperties struct {
200 // The name of the module. Must be unique across all modules.
Nan Zhang0007d812017-11-07 10:57:05 -0800201 Name *string
Colin Crossfc754582016-05-17 16:34:16 -0700202}
203
204type commonProperties struct {
Dan Willemsen0effe062015-11-30 16:06:01 -0800205 // emit build rules for this module
206 Enabled *bool `android:"arch_variant"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800207
Colin Cross7d5136f2015-05-11 13:39:40 -0700208 // control whether this module compiles for 32-bit, 64-bit, or both. Possible values
Colin Cross3f40fa42015-01-30 17:27:36 -0800209 // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both
210 // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit
211 // platform
Colin Cross7d716ba2017-11-01 10:38:29 -0700212 Compile_multilib *string `android:"arch_variant"`
Colin Cross69617d32016-09-06 10:39:07 -0700213
214 Target struct {
215 Host struct {
Colin Cross7d716ba2017-11-01 10:38:29 -0700216 Compile_multilib *string
Colin Cross69617d32016-09-06 10:39:07 -0700217 }
218 Android struct {
Colin Cross7d716ba2017-11-01 10:38:29 -0700219 Compile_multilib *string
Colin Cross69617d32016-09-06 10:39:07 -0700220 }
221 }
222
Colin Crossee0bc3b2018-10-02 22:01:37 -0700223 UseTargetVariants bool `blueprint:"mutated"`
224 Default_multilib string `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800225
Dan Willemsen782a2d12015-12-21 14:55:28 -0800226 // whether this is a proprietary vendor module, and should be installed into /vendor
Colin Cross7d716ba2017-11-01 10:38:29 -0700227 Proprietary *bool
Dan Willemsen782a2d12015-12-21 14:55:28 -0800228
Colin Cross55708f32017-03-20 13:23:34 -0700229 // vendor who owns this module
Dan Willemsenefac4a82017-07-18 19:42:09 -0700230 Owner *string
Colin Cross55708f32017-03-20 13:23:34 -0700231
Jiyong Park2db76922017-11-08 16:03:48 +0900232 // whether this module is specific to an SoC (System-On-a-Chip). When set to true,
233 // it is installed into /vendor (or /system/vendor if vendor partition does not exist).
234 // Use `soc_specific` instead for better meaning.
Colin Cross7d716ba2017-11-01 10:38:29 -0700235 Vendor *bool
Dan Willemsenaa118f92017-04-06 12:49:58 -0700236
Jiyong Park2db76922017-11-08 16:03:48 +0900237 // whether this module is specific to an SoC (System-On-a-Chip). When set to true,
238 // it is installed into /vendor (or /system/vendor if vendor partition does not exist).
239 Soc_specific *bool
240
241 // whether this module is specific to a device, not only for SoC, but also for off-chip
242 // peripherals. When set to true, it is installed into /odm (or /vendor/odm if odm partition
243 // does not exist, or /system/vendor/odm if both odm and vendor partitions do not exist).
244 // This implies `soc_specific:true`.
245 Device_specific *bool
246
247 // whether this module is specific to a software configuration of a product (e.g. country,
Jaekyun Seok5cfbfbb2018-01-10 19:00:15 +0900248 // network operator, etc). When set to true, it is installed into /product (or
249 // /system/product if product partition does not exist).
Jiyong Park2db76922017-11-08 16:03:48 +0900250 Product_specific *bool
251
Dario Frenifd05a742018-05-29 13:28:54 +0100252 // whether this module provides services owned by the OS provider to the core platform. When set
Dario Freni95cf7672018-08-17 00:57:57 +0100253 // to true, it is installed into /product_services (or /system/product_services if
254 // product_services partition does not exist).
255 Product_services_specific *bool
Dario Frenifd05a742018-05-29 13:28:54 +0100256
Jiyong Parkf9332f12018-02-01 00:54:12 +0900257 // Whether this module is installed to recovery partition
258 Recovery *bool
259
Dan Willemsen2277bcb2016-07-25 20:27:39 -0700260 // init.rc files to be installed if this module is installed
261 Init_rc []string
262
Steven Moreland57a23d22018-04-04 15:42:19 -0700263 // VINTF manifest fragments to be installed if this module is installed
264 Vintf_fragments []string
265
Chris Wolfe998306e2016-08-15 14:47:23 -0400266 // names of other modules to install if this module is installed
Colin Crossc602b7d2017-05-05 13:36:36 -0700267 Required []string `android:"arch_variant"`
Chris Wolfe998306e2016-08-15 14:47:23 -0400268
Colin Cross5aac3622017-08-31 15:07:09 -0700269 // relative path to a file to include in the list of notices for the device
270 Notice *string
271
Dan Willemsen569edc52018-11-19 09:33:29 -0800272 Dist struct {
273 // copy the output of this module to the $DIST_DIR when `dist` is specified on the
274 // command line and any of these targets are also on the command line, or otherwise
275 // built
276 Targets []string `android:"arch_variant"`
277
278 // The name of the output artifact. This defaults to the basename of the output of
279 // the module.
280 Dest *string `android:"arch_variant"`
281
282 // The directory within the dist directory to store the artifact. Defaults to the
283 // top level directory ("").
284 Dir *string `android:"arch_variant"`
285
286 // A suffix to add to the artifact file name (before any extension).
287 Suffix *string `android:"arch_variant"`
288 } `android:"arch_variant"`
289
Colin Crossa1ad8d12016-06-01 17:09:44 -0700290 // Set by TargetMutator
Colin Crossee0bc3b2018-10-02 22:01:37 -0700291 CompileTarget Target `blueprint:"mutated"`
292 CompileMultiTargets []Target `blueprint:"mutated"`
293 CompilePrimary bool `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800294
295 // Set by InitAndroidModule
296 HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
Dan Willemsen0b24c742016-10-04 15:13:37 -0700297 ArchSpecific bool `blueprint:"mutated"`
Colin Crossce75d2c2016-10-06 16:12:58 -0700298
299 SkipInstall bool `blueprint:"mutated"`
Jeff Gaston088e29e2017-11-29 16:47:17 -0800300
301 NamespaceExportedToMake bool `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800302}
303
304type hostAndDeviceProperties struct {
Colin Cross4e81d702018-11-09 10:36:55 -0800305 // If set to true, build a variant of the module for the host. Defaults to false.
306 Host_supported *bool
307
308 // If set to true, build a variant of the module for the device. Defaults to true.
Colin Crossa4190c12016-07-12 13:11:25 -0700309 Device_supported *bool
Colin Cross3f40fa42015-01-30 17:27:36 -0800310}
311
Colin Crossc472d572015-03-17 15:06:21 -0700312type Multilib string
313
314const (
Colin Cross6b4a32d2017-12-05 13:42:45 -0800315 MultilibBoth Multilib = "both"
316 MultilibFirst Multilib = "first"
317 MultilibCommon Multilib = "common"
318 MultilibCommonFirst Multilib = "common_first"
319 MultilibDefault Multilib = ""
Colin Crossc472d572015-03-17 15:06:21 -0700320)
321
Colin Crossa1ad8d12016-06-01 17:09:44 -0700322type HostOrDeviceSupported int
323
324const (
325 _ HostOrDeviceSupported = iota
Dan Albert0981b5c2018-08-02 13:46:35 -0700326
327 // Host and HostCross are built by default. Device is not supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700328 HostSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700329
330 // Host is built by default. HostCross and Device are not supported.
Dan Albertc6345fb2016-10-20 01:36:11 -0700331 HostSupportedNoCross
Dan Albert0981b5c2018-08-02 13:46:35 -0700332
333 // Device is built by default. Host and HostCross are not supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700334 DeviceSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700335
336 // Device is built by default. Host and HostCross are supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700337 HostAndDeviceSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700338
339 // Host, HostCross, and Device are built by default.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700340 HostAndDeviceDefault
Dan Albert0981b5c2018-08-02 13:46:35 -0700341
342 // Nothing is supported. This is not exposed to the user, but used to mark a
343 // host only module as unsupported when the module type is not supported on
344 // the host OS. E.g. benchmarks are supported on Linux but not Darwin.
Dan Willemsen0b24c742016-10-04 15:13:37 -0700345 NeitherHostNorDeviceSupported
Colin Crossa1ad8d12016-06-01 17:09:44 -0700346)
347
Jiyong Park2db76922017-11-08 16:03:48 +0900348type moduleKind int
349
350const (
351 platformModule moduleKind = iota
352 deviceSpecificModule
353 socSpecificModule
354 productSpecificModule
Dario Frenifd05a742018-05-29 13:28:54 +0100355 productServicesSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +0900356)
357
358func (k moduleKind) String() string {
359 switch k {
360 case platformModule:
361 return "platform"
362 case deviceSpecificModule:
363 return "device-specific"
364 case socSpecificModule:
365 return "soc-specific"
366 case productSpecificModule:
367 return "product-specific"
Dario Frenifd05a742018-05-29 13:28:54 +0100368 case productServicesSpecificModule:
369 return "productservices-specific"
Jiyong Park2db76922017-11-08 16:03:48 +0900370 default:
371 panic(fmt.Errorf("unknown module kind %d", k))
372 }
373}
374
Colin Cross36242852017-06-23 15:06:31 -0700375func InitAndroidModule(m Module) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800376 base := m.base()
377 base.module = m
Colin Cross5049f022015-03-18 13:28:46 -0700378
Colin Cross36242852017-06-23 15:06:31 -0700379 m.AddProperties(
Colin Crossfc754582016-05-17 16:34:16 -0700380 &base.nameProperties,
381 &base.commonProperties,
382 &base.variableProperties)
Pirama Arumuga Nainar955dc492018-04-17 14:58:42 -0700383 base.customizableProperties = m.GetProperties()
Colin Cross5049f022015-03-18 13:28:46 -0700384}
385
Colin Cross36242852017-06-23 15:06:31 -0700386func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
387 InitAndroidModule(m)
Colin Cross5049f022015-03-18 13:28:46 -0700388
389 base := m.base()
Colin Cross3f40fa42015-01-30 17:27:36 -0800390 base.commonProperties.HostOrDeviceSupported = hod
Colin Cross69617d32016-09-06 10:39:07 -0700391 base.commonProperties.Default_multilib = string(defaultMultilib)
Dan Willemsen0b24c742016-10-04 15:13:37 -0700392 base.commonProperties.ArchSpecific = true
Colin Crossee0bc3b2018-10-02 22:01:37 -0700393 base.commonProperties.UseTargetVariants = true
Colin Cross3f40fa42015-01-30 17:27:36 -0800394
Dan Willemsen218f6562015-07-08 18:13:11 -0700395 switch hod {
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700396 case HostAndDeviceSupported, HostAndDeviceDefault:
Colin Cross36242852017-06-23 15:06:31 -0700397 m.AddProperties(&base.hostAndDeviceProperties)
Colin Cross3f40fa42015-01-30 17:27:36 -0800398 }
399
Colin Cross36242852017-06-23 15:06:31 -0700400 InitArchModule(m)
Colin Cross3f40fa42015-01-30 17:27:36 -0800401}
402
Colin Crossee0bc3b2018-10-02 22:01:37 -0700403func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
404 InitAndroidArchModule(m, hod, defaultMultilib)
405 m.base().commonProperties.UseTargetVariants = false
406}
407
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800408// A ModuleBase object contains the properties that are common to all Android
Colin Cross3f40fa42015-01-30 17:27:36 -0800409// modules. It should be included as an anonymous field in every module
410// struct definition. InitAndroidModule should then be called from the module's
411// factory function, and the return values from InitAndroidModule should be
412// returned from the factory function.
413//
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800414// The ModuleBase type is responsible for implementing the GenerateBuildActions
415// method to support the blueprint.Module interface. This method will then call
416// the module's GenerateAndroidBuildActions method once for each build variant
417// that is to be built. GenerateAndroidBuildActions is passed a
418// AndroidModuleContext rather than the usual blueprint.ModuleContext.
Colin Cross3f40fa42015-01-30 17:27:36 -0800419// AndroidModuleContext exposes extra functionality specific to the Android build
420// system including details about the particular build variant that is to be
421// generated.
422//
423// For example:
424//
425// import (
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800426// "android/soong/android"
Colin Cross3f40fa42015-01-30 17:27:36 -0800427// )
428//
429// type myModule struct {
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800430// android.ModuleBase
Colin Cross3f40fa42015-01-30 17:27:36 -0800431// properties struct {
432// MyProperty string
433// }
434// }
435//
Colin Cross36242852017-06-23 15:06:31 -0700436// func NewMyModule() android.Module) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800437// m := &myModule{}
Colin Cross36242852017-06-23 15:06:31 -0700438// m.AddProperties(&m.properties)
439// android.InitAndroidModule(m)
440// return m
Colin Cross3f40fa42015-01-30 17:27:36 -0800441// }
442//
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800443// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800444// // Get the CPU architecture for the current build variant.
445// variantArch := ctx.Arch()
446//
447// // ...
448// }
Colin Cross635c3b02016-05-18 15:37:25 -0700449type ModuleBase struct {
Colin Cross3f40fa42015-01-30 17:27:36 -0800450 // Putting the curiously recurring thing pointing to the thing that contains
451 // the thing pattern to good use.
Colin Cross36242852017-06-23 15:06:31 -0700452 // TODO: remove this
Colin Cross635c3b02016-05-18 15:37:25 -0700453 module Module
Colin Cross3f40fa42015-01-30 17:27:36 -0800454
Colin Crossfc754582016-05-17 16:34:16 -0700455 nameProperties nameProperties
Colin Cross3f40fa42015-01-30 17:27:36 -0800456 commonProperties commonProperties
Colin Cross7f64b6d2015-07-09 13:57:48 -0700457 variableProperties variableProperties
Colin Cross3f40fa42015-01-30 17:27:36 -0800458 hostAndDeviceProperties hostAndDeviceProperties
459 generalProperties []interface{}
Colin Crossc17727d2018-10-24 12:42:09 -0700460 archProperties [][]interface{}
Colin Crossa120ec12016-08-19 16:07:38 -0700461 customizableProperties []interface{}
Colin Cross3f40fa42015-01-30 17:27:36 -0800462
463 noAddressSanitizer bool
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700464 installFiles Paths
465 checkbuildFiles Paths
Jaewoong Jung62707f72018-11-16 13:26:43 -0800466 noticeFile Path
Colin Cross1f8c52b2015-06-16 16:38:17 -0700467
468 // Used by buildTargetSingleton to create checkbuild and per-directory build targets
469 // Only set on the final variant of each module
Colin Cross0875c522017-11-28 17:34:01 -0800470 installTarget WritablePath
471 checkbuildTarget WritablePath
Colin Cross1f8c52b2015-06-16 16:38:17 -0700472 blueprintDir string
Colin Crossa120ec12016-08-19 16:07:38 -0700473
Colin Cross178a5092016-09-13 13:42:32 -0700474 hooks hooks
Colin Cross36242852017-06-23 15:06:31 -0700475
476 registerProps []interface{}
Colin Crosscec81712017-07-13 14:43:27 -0700477
478 // For tests
Colin Crossae887032017-10-23 17:16:14 -0700479 buildParams []BuildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800480 variables map[string]string
Colin Crossa9d8bee2018-10-02 13:59:46 -0700481
482 prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
Colin Cross36242852017-06-23 15:06:31 -0700483}
484
Colin Cross5f692ec2019-02-01 16:53:07 -0800485func (a *ModuleBase) DepsMutator(BottomUpMutatorContext) {}
486
Colin Cross36242852017-06-23 15:06:31 -0700487func (a *ModuleBase) AddProperties(props ...interface{}) {
488 a.registerProps = append(a.registerProps, props...)
489}
490
491func (a *ModuleBase) GetProperties() []interface{} {
492 return a.registerProps
Colin Cross3f40fa42015-01-30 17:27:36 -0800493}
494
Colin Crossae887032017-10-23 17:16:14 -0700495func (a *ModuleBase) BuildParamsForTests() []BuildParams {
Colin Crosscec81712017-07-13 14:43:27 -0700496 return a.buildParams
497}
498
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800499func (a *ModuleBase) VariablesForTests() map[string]string {
500 return a.variables
501}
502
Colin Crossa9d8bee2018-10-02 13:59:46 -0700503func (a *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
504 a.prefer32 = prefer32
505}
506
Colin Crossce75d2c2016-10-06 16:12:58 -0700507// Name returns the name of the module. It may be overridden by individual module types, for
508// example prebuilts will prepend prebuilt_ to the name.
Colin Crossfc754582016-05-17 16:34:16 -0700509func (a *ModuleBase) Name() string {
Nan Zhang0007d812017-11-07 10:57:05 -0800510 return String(a.nameProperties.Name)
Colin Crossfc754582016-05-17 16:34:16 -0700511}
512
Colin Crossce75d2c2016-10-06 16:12:58 -0700513// BaseModuleName returns the name of the module as specified in the blueprints file.
514func (a *ModuleBase) BaseModuleName() string {
Nan Zhang0007d812017-11-07 10:57:05 -0800515 return String(a.nameProperties.Name)
Colin Crossce75d2c2016-10-06 16:12:58 -0700516}
517
Colin Cross635c3b02016-05-18 15:37:25 -0700518func (a *ModuleBase) base() *ModuleBase {
Colin Cross3f40fa42015-01-30 17:27:36 -0800519 return a
520}
521
Colin Crossee0bc3b2018-10-02 22:01:37 -0700522func (a *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700523 a.commonProperties.CompileTarget = target
Colin Crossee0bc3b2018-10-02 22:01:37 -0700524 a.commonProperties.CompileMultiTargets = multiTargets
Colin Cross8b74d172016-09-13 09:59:14 -0700525 a.commonProperties.CompilePrimary = primary
Colin Crossd3ba0392015-05-07 14:11:29 -0700526}
527
Colin Crossa1ad8d12016-06-01 17:09:44 -0700528func (a *ModuleBase) Target() Target {
529 return a.commonProperties.CompileTarget
Dan Willemsen490fd492015-11-24 17:53:15 -0800530}
531
Colin Cross8b74d172016-09-13 09:59:14 -0700532func (a *ModuleBase) TargetPrimary() bool {
533 return a.commonProperties.CompilePrimary
534}
535
Colin Crossee0bc3b2018-10-02 22:01:37 -0700536func (a *ModuleBase) MultiTargets() []Target {
537 return a.commonProperties.CompileMultiTargets
538}
539
Colin Crossa1ad8d12016-06-01 17:09:44 -0700540func (a *ModuleBase) Os() OsType {
541 return a.Target().Os
Dan Willemsen490fd492015-11-24 17:53:15 -0800542}
543
Colin Cross635c3b02016-05-18 15:37:25 -0700544func (a *ModuleBase) Host() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700545 return a.Os().Class == Host || a.Os().Class == HostCross
Dan Willemsen97750522016-02-09 17:43:51 -0800546}
547
Colin Cross635c3b02016-05-18 15:37:25 -0700548func (a *ModuleBase) Arch() Arch {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700549 return a.Target().Arch
Dan Willemsen97750522016-02-09 17:43:51 -0800550}
551
Dan Willemsen0b24c742016-10-04 15:13:37 -0700552func (a *ModuleBase) ArchSpecific() bool {
553 return a.commonProperties.ArchSpecific
554}
555
Colin Crossa1ad8d12016-06-01 17:09:44 -0700556func (a *ModuleBase) OsClassSupported() []OsClass {
557 switch a.commonProperties.HostOrDeviceSupported {
558 case HostSupported:
Colin Crossa1ad8d12016-06-01 17:09:44 -0700559 return []OsClass{Host, HostCross}
Dan Albertc6345fb2016-10-20 01:36:11 -0700560 case HostSupportedNoCross:
561 return []OsClass{Host}
Colin Crossa1ad8d12016-06-01 17:09:44 -0700562 case DeviceSupported:
563 return []OsClass{Device}
Dan Albert0981b5c2018-08-02 13:46:35 -0700564 case HostAndDeviceSupported, HostAndDeviceDefault:
Colin Crossa1ad8d12016-06-01 17:09:44 -0700565 var supported []OsClass
Dan Albert0981b5c2018-08-02 13:46:35 -0700566 if Bool(a.hostAndDeviceProperties.Host_supported) ||
567 (a.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
568 a.hostAndDeviceProperties.Host_supported == nil) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700569 supported = append(supported, Host, HostCross)
570 }
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700571 if a.hostAndDeviceProperties.Device_supported == nil ||
572 *a.hostAndDeviceProperties.Device_supported {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700573 supported = append(supported, Device)
574 }
575 return supported
576 default:
577 return nil
578 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800579}
580
Colin Cross635c3b02016-05-18 15:37:25 -0700581func (a *ModuleBase) DeviceSupported() bool {
Colin Cross3f40fa42015-01-30 17:27:36 -0800582 return a.commonProperties.HostOrDeviceSupported == DeviceSupported ||
583 a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700584 (a.hostAndDeviceProperties.Device_supported == nil ||
585 *a.hostAndDeviceProperties.Device_supported)
Colin Cross3f40fa42015-01-30 17:27:36 -0800586}
587
Jiyong Parkc678ad32018-04-10 13:07:10 +0900588func (a *ModuleBase) Platform() bool {
Dario Frenifd05a742018-05-29 13:28:54 +0100589 return !a.DeviceSpecific() && !a.SocSpecific() && !a.ProductSpecific() && !a.ProductServicesSpecific()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900590}
591
592func (a *ModuleBase) DeviceSpecific() bool {
593 return Bool(a.commonProperties.Device_specific)
594}
595
596func (a *ModuleBase) SocSpecific() bool {
597 return Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
598}
599
600func (a *ModuleBase) ProductSpecific() bool {
601 return Bool(a.commonProperties.Product_specific)
602}
603
Dario Frenifd05a742018-05-29 13:28:54 +0100604func (a *ModuleBase) ProductServicesSpecific() bool {
Dario Freni95cf7672018-08-17 00:57:57 +0100605 return Bool(a.commonProperties.Product_services_specific)
Dario Frenifd05a742018-05-29 13:28:54 +0100606}
607
Colin Cross635c3b02016-05-18 15:37:25 -0700608func (a *ModuleBase) Enabled() bool {
Dan Willemsen0effe062015-11-30 16:06:01 -0800609 if a.commonProperties.Enabled == nil {
Dan Willemsen0a37a2a2016-11-13 10:16:05 -0800610 return !a.Os().DefaultDisabled
Dan Willemsen490fd492015-11-24 17:53:15 -0800611 }
Dan Willemsen0effe062015-11-30 16:06:01 -0800612 return *a.commonProperties.Enabled
Colin Cross3f40fa42015-01-30 17:27:36 -0800613}
614
Colin Crossce75d2c2016-10-06 16:12:58 -0700615func (a *ModuleBase) SkipInstall() {
616 a.commonProperties.SkipInstall = true
617}
618
Jiyong Park374510b2018-03-19 18:23:01 +0900619func (a *ModuleBase) ExportedToMake() bool {
620 return a.commonProperties.NamespaceExportedToMake
621}
622
Colin Cross635c3b02016-05-18 15:37:25 -0700623func (a *ModuleBase) computeInstallDeps(
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700624 ctx blueprint.ModuleContext) Paths {
Colin Cross3f40fa42015-01-30 17:27:36 -0800625
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700626 result := Paths{}
Colin Cross6b753602018-06-21 13:03:07 -0700627 // TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
Colin Cross3f40fa42015-01-30 17:27:36 -0800628 ctx.VisitDepsDepthFirstIf(isFileInstaller,
629 func(m blueprint.Module) {
630 fileInstaller := m.(fileInstaller)
631 files := fileInstaller.filesToInstall()
632 result = append(result, files...)
633 })
634
635 return result
636}
637
Colin Cross635c3b02016-05-18 15:37:25 -0700638func (a *ModuleBase) filesToInstall() Paths {
Colin Cross3f40fa42015-01-30 17:27:36 -0800639 return a.installFiles
640}
641
Colin Cross635c3b02016-05-18 15:37:25 -0700642func (p *ModuleBase) NoAddressSanitizer() bool {
Colin Cross3f40fa42015-01-30 17:27:36 -0800643 return p.noAddressSanitizer
644}
645
Colin Cross635c3b02016-05-18 15:37:25 -0700646func (p *ModuleBase) InstallInData() bool {
Dan Willemsen782a2d12015-12-21 14:55:28 -0800647 return false
648}
649
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700650func (p *ModuleBase) InstallInSanitizerDir() bool {
651 return false
652}
653
Jiyong Parkf9332f12018-02-01 00:54:12 +0900654func (p *ModuleBase) InstallInRecovery() bool {
655 return Bool(p.commonProperties.Recovery)
656}
657
Sundong Ahn4fd04bb2018-08-31 18:01:37 +0900658func (a *ModuleBase) Owner() string {
659 return String(a.commonProperties.Owner)
660}
661
Colin Cross0875c522017-11-28 17:34:01 -0800662func (a *ModuleBase) generateModuleTarget(ctx ModuleContext) {
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700663 allInstalledFiles := Paths{}
664 allCheckbuildFiles := Paths{}
Colin Cross0875c522017-11-28 17:34:01 -0800665 ctx.VisitAllModuleVariants(func(module Module) {
666 a := module.base()
Colin Crossc9404352015-03-26 16:10:12 -0700667 allInstalledFiles = append(allInstalledFiles, a.installFiles...)
668 allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800669 })
670
Colin Cross0875c522017-11-28 17:34:01 -0800671 var deps Paths
Colin Cross9454bfa2015-03-17 13:24:18 -0700672
Jeff Gaston088e29e2017-11-29 16:47:17 -0800673 namespacePrefix := ctx.Namespace().(*Namespace).id
674 if namespacePrefix != "" {
675 namespacePrefix = namespacePrefix + "-"
676 }
677
Colin Cross3f40fa42015-01-30 17:27:36 -0800678 if len(allInstalledFiles) > 0 {
Jeff Gaston088e29e2017-11-29 16:47:17 -0800679 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-install")
Colin Cross0875c522017-11-28 17:34:01 -0800680 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700681 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -0800682 Output: name,
683 Implicits: allInstalledFiles,
Colin Crossaabf6792017-11-29 00:27:14 -0800684 Default: !ctx.Config().EmbeddedInMake(),
Colin Cross9454bfa2015-03-17 13:24:18 -0700685 })
686 deps = append(deps, name)
Colin Cross1f8c52b2015-06-16 16:38:17 -0700687 a.installTarget = name
Colin Cross9454bfa2015-03-17 13:24:18 -0700688 }
689
690 if len(allCheckbuildFiles) > 0 {
Jeff Gaston088e29e2017-11-29 16:47:17 -0800691 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-checkbuild")
Colin Cross0875c522017-11-28 17:34:01 -0800692 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700693 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -0800694 Output: name,
695 Implicits: allCheckbuildFiles,
Colin Cross9454bfa2015-03-17 13:24:18 -0700696 })
697 deps = append(deps, name)
Colin Cross1f8c52b2015-06-16 16:38:17 -0700698 a.checkbuildTarget = name
Colin Cross9454bfa2015-03-17 13:24:18 -0700699 }
700
701 if len(deps) > 0 {
Dan Willemsen5ba07e82015-12-11 13:51:06 -0800702 suffix := ""
Colin Crossaabf6792017-11-29 00:27:14 -0800703 if ctx.Config().EmbeddedInMake() {
Dan Willemsen5ba07e82015-12-11 13:51:06 -0800704 suffix = "-soong"
705 }
706
Jeff Gaston088e29e2017-11-29 16:47:17 -0800707 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+suffix)
Colin Cross0875c522017-11-28 17:34:01 -0800708 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700709 Rule: blueprint.Phony,
Jeff Gaston088e29e2017-11-29 16:47:17 -0800710 Outputs: []WritablePath{name},
Colin Cross9454bfa2015-03-17 13:24:18 -0700711 Implicits: deps,
Colin Cross3f40fa42015-01-30 17:27:36 -0800712 })
Colin Cross1f8c52b2015-06-16 16:38:17 -0700713
714 a.blueprintDir = ctx.ModuleDir()
Colin Cross3f40fa42015-01-30 17:27:36 -0800715 }
716}
717
Jiyong Park2db76922017-11-08 16:03:48 +0900718func determineModuleKind(a *ModuleBase, ctx blueprint.BaseModuleContext) moduleKind {
719 var socSpecific = Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
720 var deviceSpecific = Bool(a.commonProperties.Device_specific)
721 var productSpecific = Bool(a.commonProperties.Product_specific)
Dario Freni95cf7672018-08-17 00:57:57 +0100722 var productServicesSpecific = Bool(a.commonProperties.Product_services_specific)
Jiyong Park2db76922017-11-08 16:03:48 +0900723
Dario Frenifd05a742018-05-29 13:28:54 +0100724 msg := "conflicting value set here"
725 if socSpecific && deviceSpecific {
726 ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
Jiyong Park2db76922017-11-08 16:03:48 +0900727 if Bool(a.commonProperties.Vendor) {
728 ctx.PropertyErrorf("vendor", msg)
729 }
730 if Bool(a.commonProperties.Proprietary) {
731 ctx.PropertyErrorf("proprietary", msg)
732 }
733 if Bool(a.commonProperties.Soc_specific) {
734 ctx.PropertyErrorf("soc_specific", msg)
735 }
736 }
737
Dario Frenifd05a742018-05-29 13:28:54 +0100738 if productSpecific && productServicesSpecific {
739 ctx.PropertyErrorf("product_specific", "a module cannot be specific to product and product_services at the same time.")
740 ctx.PropertyErrorf("product_services_specific", msg)
741 }
742
743 if (socSpecific || deviceSpecific) && (productSpecific || productServicesSpecific) {
744 if productSpecific {
745 ctx.PropertyErrorf("product_specific", "a module cannot be specific to SoC or device and product at the same time.")
746 } else {
747 ctx.PropertyErrorf("product_services_specific", "a module cannot be specific to SoC or device and product_services at the same time.")
748 }
749 if deviceSpecific {
750 ctx.PropertyErrorf("device_specific", msg)
751 } else {
752 if Bool(a.commonProperties.Vendor) {
753 ctx.PropertyErrorf("vendor", msg)
754 }
755 if Bool(a.commonProperties.Proprietary) {
756 ctx.PropertyErrorf("proprietary", msg)
757 }
758 if Bool(a.commonProperties.Soc_specific) {
759 ctx.PropertyErrorf("soc_specific", msg)
760 }
761 }
762 }
763
Jiyong Park2db76922017-11-08 16:03:48 +0900764 if productSpecific {
765 return productSpecificModule
Dario Frenifd05a742018-05-29 13:28:54 +0100766 } else if productServicesSpecific {
767 return productServicesSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +0900768 } else if deviceSpecific {
769 return deviceSpecificModule
770 } else if socSpecific {
771 return socSpecificModule
772 } else {
773 return platformModule
774 }
775}
776
Colin Cross635c3b02016-05-18 15:37:25 -0700777func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
Colin Cross6362e272015-10-29 15:25:03 -0700778 return androidBaseContextImpl{
Colin Cross8b74d172016-09-13 09:59:14 -0700779 target: a.commonProperties.CompileTarget,
780 targetPrimary: a.commonProperties.CompilePrimary,
Colin Crossee0bc3b2018-10-02 22:01:37 -0700781 multiTargets: a.commonProperties.CompileMultiTargets,
Jiyong Park2db76922017-11-08 16:03:48 +0900782 kind: determineModuleKind(a, ctx),
Colin Cross8b74d172016-09-13 09:59:14 -0700783 config: ctx.Config().(Config),
Colin Cross3f40fa42015-01-30 17:27:36 -0800784 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800785}
786
Colin Cross0875c522017-11-28 17:34:01 -0800787func (a *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
788 ctx := &androidModuleContext{
Colin Cross8d8f8e22016-08-03 11:57:50 -0700789 module: a.module,
Colin Cross0875c522017-11-28 17:34:01 -0800790 ModuleContext: blueprintCtx,
791 androidBaseContextImpl: a.androidBaseContextFactory(blueprintCtx),
792 installDeps: a.computeInstallDeps(blueprintCtx),
Colin Cross6362e272015-10-29 15:25:03 -0700793 installFiles: a.installFiles,
Colin Cross0875c522017-11-28 17:34:01 -0800794 missingDeps: blueprintCtx.GetMissingDependencies(),
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800795 variables: make(map[string]string),
Colin Cross3f40fa42015-01-30 17:27:36 -0800796 }
797
Colin Cross67a5c132017-05-09 13:45:28 -0700798 desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
799 var suffix []string
Colin Cross0875c522017-11-28 17:34:01 -0800800 if ctx.Os().Class != Device && ctx.Os().Class != Generic {
801 suffix = append(suffix, ctx.Os().String())
Colin Cross67a5c132017-05-09 13:45:28 -0700802 }
Colin Cross0875c522017-11-28 17:34:01 -0800803 if !ctx.PrimaryArch() {
804 suffix = append(suffix, ctx.Arch().ArchType.String())
Colin Cross67a5c132017-05-09 13:45:28 -0700805 }
806
807 ctx.Variable(pctx, "moduleDesc", desc)
808
809 s := ""
810 if len(suffix) > 0 {
811 s = " [" + strings.Join(suffix, " ") + "]"
812 }
813 ctx.Variable(pctx, "moduleDescSuffix", s)
814
Dan Willemsen569edc52018-11-19 09:33:29 -0800815 // Some common property checks for properties that will be used later in androidmk.go
816 if a.commonProperties.Dist.Dest != nil {
817 _, err := validateSafePath(*a.commonProperties.Dist.Dest)
818 if err != nil {
819 ctx.PropertyErrorf("dist.dest", "%s", err.Error())
820 }
821 }
822 if a.commonProperties.Dist.Dir != nil {
823 _, err := validateSafePath(*a.commonProperties.Dist.Dir)
824 if err != nil {
825 ctx.PropertyErrorf("dist.dir", "%s", err.Error())
826 }
827 }
828 if a.commonProperties.Dist.Suffix != nil {
829 if strings.Contains(*a.commonProperties.Dist.Suffix, "/") {
830 ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
831 }
832 }
833
Colin Cross9b1d13d2016-09-19 15:18:11 -0700834 if a.Enabled() {
Colin Cross0875c522017-11-28 17:34:01 -0800835 a.module.GenerateAndroidBuildActions(ctx)
Colin Cross9b1d13d2016-09-19 15:18:11 -0700836 if ctx.Failed() {
837 return
838 }
839
Colin Cross0875c522017-11-28 17:34:01 -0800840 a.installFiles = append(a.installFiles, ctx.installFiles...)
841 a.checkbuildFiles = append(a.checkbuildFiles, ctx.checkbuildFiles...)
Jaewoong Jung62707f72018-11-16 13:26:43 -0800842
843 if a.commonProperties.Notice != nil {
844 // For filegroup-based notice file references.
845 a.noticeFile = ctx.ExpandSource(*a.commonProperties.Notice, "notice")
846 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800847 }
848
Colin Cross9b1d13d2016-09-19 15:18:11 -0700849 if a == ctx.FinalModule().(Module).base() {
850 a.generateModuleTarget(ctx)
851 if ctx.Failed() {
852 return
853 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800854 }
Colin Crosscec81712017-07-13 14:43:27 -0700855
Colin Cross0875c522017-11-28 17:34:01 -0800856 a.buildParams = ctx.buildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800857 a.variables = ctx.variables
Colin Cross3f40fa42015-01-30 17:27:36 -0800858}
859
Colin Crossf6566ed2015-03-24 11:13:38 -0700860type androidBaseContextImpl struct {
Colin Cross8b74d172016-09-13 09:59:14 -0700861 target Target
Colin Crossee0bc3b2018-10-02 22:01:37 -0700862 multiTargets []Target
Colin Cross8b74d172016-09-13 09:59:14 -0700863 targetPrimary bool
864 debug bool
Jiyong Park2db76922017-11-08 16:03:48 +0900865 kind moduleKind
Colin Cross8b74d172016-09-13 09:59:14 -0700866 config Config
Colin Crossf6566ed2015-03-24 11:13:38 -0700867}
868
Colin Cross3f40fa42015-01-30 17:27:36 -0800869type androidModuleContext struct {
870 blueprint.ModuleContext
Colin Crossf6566ed2015-03-24 11:13:38 -0700871 androidBaseContextImpl
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700872 installDeps Paths
873 installFiles Paths
874 checkbuildFiles Paths
Colin Cross6ff51382015-12-17 16:39:19 -0800875 missingDeps []string
Colin Cross8d8f8e22016-08-03 11:57:50 -0700876 module Module
Colin Crosscec81712017-07-13 14:43:27 -0700877
878 // For tests
Colin Crossae887032017-10-23 17:16:14 -0700879 buildParams []BuildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800880 variables map[string]string
Colin Cross6ff51382015-12-17 16:39:19 -0800881}
882
Colin Cross67a5c132017-05-09 13:45:28 -0700883func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
Colin Cross0875c522017-11-28 17:34:01 -0800884 a.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{
Colin Cross67a5c132017-05-09 13:45:28 -0700885 Rule: ErrorRule,
886 Description: desc,
887 Outputs: outputs,
888 Optional: true,
Colin Cross6ff51382015-12-17 16:39:19 -0800889 Args: map[string]string{
890 "error": err.Error(),
891 },
892 })
893 return
Colin Cross3f40fa42015-01-30 17:27:36 -0800894}
895
Colin Crossaabf6792017-11-29 00:27:14 -0800896func (a *androidModuleContext) Config() Config {
897 return a.ModuleContext.Config().(Config)
898}
899
Colin Cross0875c522017-11-28 17:34:01 -0800900func (a *androidModuleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
Colin Crossae887032017-10-23 17:16:14 -0700901 a.Build(pctx, BuildParams(params))
Colin Cross3f40fa42015-01-30 17:27:36 -0800902}
903
Colin Cross0875c522017-11-28 17:34:01 -0800904func convertBuildParams(params BuildParams) blueprint.BuildParams {
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700905 bparams := blueprint.BuildParams{
Dan Willemsen9f3c5742016-11-03 14:28:31 -0700906 Rule: params.Rule,
Colin Cross0875c522017-11-28 17:34:01 -0800907 Description: params.Description,
Colin Cross33bfb0a2016-11-21 17:23:08 -0800908 Deps: params.Deps,
Dan Willemsen9f3c5742016-11-03 14:28:31 -0700909 Outputs: params.Outputs.Strings(),
910 ImplicitOutputs: params.ImplicitOutputs.Strings(),
911 Inputs: params.Inputs.Strings(),
912 Implicits: params.Implicits.Strings(),
913 OrderOnly: params.OrderOnly.Strings(),
914 Args: params.Args,
915 Optional: !params.Default,
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700916 }
917
Colin Cross33bfb0a2016-11-21 17:23:08 -0800918 if params.Depfile != nil {
919 bparams.Depfile = params.Depfile.String()
920 }
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700921 if params.Output != nil {
922 bparams.Outputs = append(bparams.Outputs, params.Output.String())
923 }
Dan Willemsen9f3c5742016-11-03 14:28:31 -0700924 if params.ImplicitOutput != nil {
925 bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
926 }
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700927 if params.Input != nil {
928 bparams.Inputs = append(bparams.Inputs, params.Input.String())
929 }
930 if params.Implicit != nil {
931 bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
932 }
933
Colin Cross0b9f31f2019-02-28 11:00:01 -0800934 bparams.Outputs = proptools.NinjaEscapeList(bparams.Outputs)
935 bparams.ImplicitOutputs = proptools.NinjaEscapeList(bparams.ImplicitOutputs)
936 bparams.Inputs = proptools.NinjaEscapeList(bparams.Inputs)
937 bparams.Implicits = proptools.NinjaEscapeList(bparams.Implicits)
938 bparams.OrderOnly = proptools.NinjaEscapeList(bparams.OrderOnly)
939 bparams.Depfile = proptools.NinjaEscapeList([]string{bparams.Depfile})[0]
Colin Crossfe4bc362018-09-12 10:02:13 -0700940
Colin Cross0875c522017-11-28 17:34:01 -0800941 return bparams
942}
943
944func (a *androidModuleContext) Variable(pctx PackageContext, name, value string) {
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800945 if a.config.captureBuild {
946 a.variables[name] = value
947 }
948
Colin Cross0875c522017-11-28 17:34:01 -0800949 a.ModuleContext.Variable(pctx.PackageContext, name, value)
950}
951
952func (a *androidModuleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
953 argNames ...string) blueprint.Rule {
954
955 return a.ModuleContext.Rule(pctx.PackageContext, name, params, argNames...)
956}
957
958func (a *androidModuleContext) Build(pctx PackageContext, params BuildParams) {
959 if a.config.captureBuild {
960 a.buildParams = append(a.buildParams, params)
961 }
962
963 bparams := convertBuildParams(params)
964
965 if bparams.Description != "" {
966 bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
967 }
968
Colin Cross6ff51382015-12-17 16:39:19 -0800969 if a.missingDeps != nil {
Colin Cross67a5c132017-05-09 13:45:28 -0700970 a.ninjaError(bparams.Description, bparams.Outputs,
971 fmt.Errorf("module %s missing dependencies: %s\n",
972 a.ModuleName(), strings.Join(a.missingDeps, ", ")))
Colin Cross6ff51382015-12-17 16:39:19 -0800973 return
974 }
975
Colin Cross0875c522017-11-28 17:34:01 -0800976 a.ModuleContext.Build(pctx.PackageContext, bparams)
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700977}
978
Colin Cross6ff51382015-12-17 16:39:19 -0800979func (a *androidModuleContext) GetMissingDependencies() []string {
980 return a.missingDeps
981}
982
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800983func (a *androidModuleContext) AddMissingDependencies(deps []string) {
984 if deps != nil {
985 a.missingDeps = append(a.missingDeps, deps...)
Colin Crossd11fcda2017-10-23 17:59:01 -0700986 a.missingDeps = FirstUniqueStrings(a.missingDeps)
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800987 }
988}
989
Colin Crossd11fcda2017-10-23 17:59:01 -0700990func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Module {
991 aModule, _ := module.(Module)
992 if aModule == nil {
993 a.ModuleErrorf("module %q not an android module", a.OtherModuleName(aModule))
994 return nil
995 }
996
997 if !aModule.Enabled() {
Colin Cross6510f912017-11-29 00:27:14 -0800998 if a.Config().AllowMissingDependencies() {
Colin Crossd11fcda2017-10-23 17:59:01 -0700999 a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
1000 } else {
1001 a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
1002 }
1003 return nil
1004 }
1005
1006 return aModule
1007}
1008
Colin Cross35143d02017-11-16 00:11:20 -08001009func (a *androidModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
1010 a.ModuleContext.VisitDirectDeps(visit)
1011}
1012
Colin Crossd11fcda2017-10-23 17:59:01 -07001013func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
1014 a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
1015 if aModule := a.validateAndroidModule(module); aModule != nil {
1016 visit(aModule)
1017 }
1018 })
1019}
1020
Colin Crossee6143c2017-12-30 17:54:27 -08001021func (a *androidModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
1022 a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
1023 if aModule := a.validateAndroidModule(module); aModule != nil {
1024 if a.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
1025 visit(aModule)
1026 }
1027 }
1028 })
1029}
1030
Colin Crossd11fcda2017-10-23 17:59:01 -07001031func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
1032 a.ModuleContext.VisitDirectDepsIf(
1033 // pred
1034 func(module blueprint.Module) bool {
1035 if aModule := a.validateAndroidModule(module); aModule != nil {
1036 return pred(aModule)
1037 } else {
1038 return false
1039 }
1040 },
1041 // visit
1042 func(module blueprint.Module) {
1043 visit(module.(Module))
1044 })
1045}
1046
1047func (a *androidModuleContext) VisitDepsDepthFirst(visit func(Module)) {
1048 a.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
1049 if aModule := a.validateAndroidModule(module); aModule != nil {
1050 visit(aModule)
1051 }
1052 })
1053}
1054
1055func (a *androidModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
1056 a.ModuleContext.VisitDepsDepthFirstIf(
1057 // pred
1058 func(module blueprint.Module) bool {
1059 if aModule := a.validateAndroidModule(module); aModule != nil {
1060 return pred(aModule)
1061 } else {
1062 return false
1063 }
1064 },
1065 // visit
1066 func(module blueprint.Module) {
1067 visit(module.(Module))
1068 })
1069}
1070
Alex Light778127a2019-02-27 14:19:50 -08001071func (a *androidModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
1072 a.ModuleContext.WalkDeps(visit)
1073}
1074
Colin Crossd11fcda2017-10-23 17:59:01 -07001075func (a *androidModuleContext) WalkDeps(visit func(Module, Module) bool) {
1076 a.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
1077 childAndroidModule := a.validateAndroidModule(child)
1078 parentAndroidModule := a.validateAndroidModule(parent)
1079 if childAndroidModule != nil && parentAndroidModule != nil {
1080 return visit(childAndroidModule, parentAndroidModule)
1081 } else {
1082 return false
1083 }
1084 })
1085}
1086
Colin Cross0875c522017-11-28 17:34:01 -08001087func (a *androidModuleContext) VisitAllModuleVariants(visit func(Module)) {
1088 a.ModuleContext.VisitAllModuleVariants(func(module blueprint.Module) {
1089 visit(module.(Module))
1090 })
1091}
1092
1093func (a *androidModuleContext) PrimaryModule() Module {
1094 return a.ModuleContext.PrimaryModule().(Module)
1095}
1096
1097func (a *androidModuleContext) FinalModule() Module {
1098 return a.ModuleContext.FinalModule().(Module)
1099}
1100
Colin Crossa1ad8d12016-06-01 17:09:44 -07001101func (a *androidBaseContextImpl) Target() Target {
1102 return a.target
1103}
1104
Colin Cross8b74d172016-09-13 09:59:14 -07001105func (a *androidBaseContextImpl) TargetPrimary() bool {
1106 return a.targetPrimary
1107}
1108
Colin Crossee0bc3b2018-10-02 22:01:37 -07001109func (a *androidBaseContextImpl) MultiTargets() []Target {
1110 return a.multiTargets
1111}
1112
Colin Crossf6566ed2015-03-24 11:13:38 -07001113func (a *androidBaseContextImpl) Arch() Arch {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001114 return a.target.Arch
Colin Cross3f40fa42015-01-30 17:27:36 -08001115}
1116
Colin Crossa1ad8d12016-06-01 17:09:44 -07001117func (a *androidBaseContextImpl) Os() OsType {
1118 return a.target.Os
Dan Willemsen490fd492015-11-24 17:53:15 -08001119}
1120
Colin Crossf6566ed2015-03-24 11:13:38 -07001121func (a *androidBaseContextImpl) Host() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001122 return a.target.Os.Class == Host || a.target.Os.Class == HostCross
Colin Crossf6566ed2015-03-24 11:13:38 -07001123}
1124
1125func (a *androidBaseContextImpl) Device() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001126 return a.target.Os.Class == Device
Colin Crossf6566ed2015-03-24 11:13:38 -07001127}
1128
Colin Cross0af4b842015-04-30 16:36:18 -07001129func (a *androidBaseContextImpl) Darwin() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001130 return a.target.Os == Darwin
Colin Cross0af4b842015-04-30 16:36:18 -07001131}
1132
Doug Horn21b94272019-01-16 12:06:11 -08001133func (a *androidBaseContextImpl) Fuchsia() bool {
1134 return a.target.Os == Fuchsia
1135}
1136
Colin Cross3edeee12017-04-04 12:59:48 -07001137func (a *androidBaseContextImpl) Windows() bool {
1138 return a.target.Os == Windows
1139}
1140
Colin Crossf6566ed2015-03-24 11:13:38 -07001141func (a *androidBaseContextImpl) Debug() bool {
1142 return a.debug
1143}
1144
Colin Cross1e7d3702016-08-24 15:25:47 -07001145func (a *androidBaseContextImpl) PrimaryArch() bool {
Dan Willemsen0ef639b2018-10-10 17:02:29 -07001146 if len(a.config.Targets[a.target.Os]) <= 1 {
Colin Cross67a5c132017-05-09 13:45:28 -07001147 return true
1148 }
Dan Willemsen0ef639b2018-10-10 17:02:29 -07001149 return a.target.Arch.ArchType == a.config.Targets[a.target.Os][0].Arch.ArchType
Colin Cross1e7d3702016-08-24 15:25:47 -07001150}
1151
Colin Cross1332b002015-04-07 17:11:30 -07001152func (a *androidBaseContextImpl) AConfig() Config {
1153 return a.config
1154}
1155
Colin Cross9272ade2016-08-17 15:24:12 -07001156func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
1157 return DeviceConfig{a.config.deviceConfig}
1158}
1159
Jiyong Park2db76922017-11-08 16:03:48 +09001160func (a *androidBaseContextImpl) Platform() bool {
1161 return a.kind == platformModule
1162}
1163
1164func (a *androidBaseContextImpl) DeviceSpecific() bool {
1165 return a.kind == deviceSpecificModule
1166}
1167
1168func (a *androidBaseContextImpl) SocSpecific() bool {
1169 return a.kind == socSpecificModule
1170}
1171
1172func (a *androidBaseContextImpl) ProductSpecific() bool {
1173 return a.kind == productSpecificModule
Dan Willemsen782a2d12015-12-21 14:55:28 -08001174}
1175
Dario Frenifd05a742018-05-29 13:28:54 +01001176func (a *androidBaseContextImpl) ProductServicesSpecific() bool {
1177 return a.kind == productServicesSpecificModule
1178}
1179
Jiyong Park5baac542018-08-28 09:55:37 +09001180// Makes this module a platform module, i.e. not specific to soc, device,
1181// product, or product_services.
1182func (a *ModuleBase) MakeAsPlatform() {
1183 a.commonProperties.Vendor = boolPtr(false)
1184 a.commonProperties.Proprietary = boolPtr(false)
1185 a.commonProperties.Soc_specific = boolPtr(false)
1186 a.commonProperties.Product_specific = boolPtr(false)
1187 a.commonProperties.Product_services_specific = boolPtr(false)
1188}
1189
Colin Cross8d8f8e22016-08-03 11:57:50 -07001190func (a *androidModuleContext) InstallInData() bool {
1191 return a.module.InstallInData()
Dan Willemsen782a2d12015-12-21 14:55:28 -08001192}
1193
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001194func (a *androidModuleContext) InstallInSanitizerDir() bool {
1195 return a.module.InstallInSanitizerDir()
1196}
1197
Jiyong Parkf9332f12018-02-01 00:54:12 +09001198func (a *androidModuleContext) InstallInRecovery() bool {
1199 return a.module.InstallInRecovery()
1200}
1201
Colin Cross893d8162017-04-26 17:34:03 -07001202func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
1203 if a.module.base().commonProperties.SkipInstall {
1204 return true
1205 }
1206
Colin Cross3607f212018-05-07 15:28:05 -07001207 // We'll need a solution for choosing which of modules with the same name in different
1208 // namespaces to install. For now, reuse the list of namespaces exported to Make as the
1209 // list of namespaces to install in a Soong-only build.
1210 if !a.module.base().commonProperties.NamespaceExportedToMake {
1211 return true
1212 }
1213
Colin Cross893d8162017-04-26 17:34:03 -07001214 if a.Device() {
Colin Cross6510f912017-11-29 00:27:14 -08001215 if a.Config().SkipDeviceInstall() {
Colin Cross893d8162017-04-26 17:34:03 -07001216 return true
1217 }
1218
Colin Cross6510f912017-11-29 00:27:14 -08001219 if a.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
Colin Cross893d8162017-04-26 17:34:03 -07001220 return true
1221 }
1222 }
1223
1224 return false
1225}
1226
Colin Cross5c517922017-08-31 12:29:17 -07001227func (a *androidModuleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
Colin Crossa2344662016-03-24 13:14:12 -07001228 deps ...Path) OutputPath {
Colin Cross5c517922017-08-31 12:29:17 -07001229 return a.installFile(installPath, name, srcPath, Cp, deps)
1230}
1231
1232func (a *androidModuleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path,
1233 deps ...Path) OutputPath {
1234 return a.installFile(installPath, name, srcPath, CpExecutable, deps)
1235}
1236
1237func (a *androidModuleContext) installFile(installPath OutputPath, name string, srcPath Path,
1238 rule blueprint.Rule, deps []Path) OutputPath {
Colin Cross35cec122015-04-02 14:37:16 -07001239
Dan Willemsen782a2d12015-12-21 14:55:28 -08001240 fullInstallPath := installPath.Join(a, name)
Colin Cross178a5092016-09-13 13:42:32 -07001241 a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
Colin Cross3f40fa42015-01-30 17:27:36 -08001242
Colin Cross893d8162017-04-26 17:34:03 -07001243 if !a.skipInstall(fullInstallPath) {
Colin Crossce75d2c2016-10-06 16:12:58 -07001244
Dan Willemsen322acaf2016-01-12 23:07:05 -08001245 deps = append(deps, a.installDeps...)
Colin Cross35cec122015-04-02 14:37:16 -07001246
Colin Cross89562dc2016-10-03 17:47:19 -07001247 var implicitDeps, orderOnlyDeps Paths
1248
1249 if a.Host() {
1250 // Installed host modules might be used during the build, depend directly on their
1251 // dependencies so their timestamp is updated whenever their dependency is updated
1252 implicitDeps = deps
1253 } else {
1254 orderOnlyDeps = deps
1255 }
1256
Colin Crossae887032017-10-23 17:16:14 -07001257 a.Build(pctx, BuildParams{
Colin Cross5c517922017-08-31 12:29:17 -07001258 Rule: rule,
Colin Cross67a5c132017-05-09 13:45:28 -07001259 Description: "install " + fullInstallPath.Base(),
1260 Output: fullInstallPath,
1261 Input: srcPath,
1262 Implicits: implicitDeps,
1263 OrderOnly: orderOnlyDeps,
Colin Cross6510f912017-11-29 00:27:14 -08001264 Default: !a.Config().EmbeddedInMake(),
Dan Willemsen322acaf2016-01-12 23:07:05 -08001265 })
Colin Cross3f40fa42015-01-30 17:27:36 -08001266
Dan Willemsen322acaf2016-01-12 23:07:05 -08001267 a.installFiles = append(a.installFiles, fullInstallPath)
1268 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001269 a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
Colin Cross35cec122015-04-02 14:37:16 -07001270 return fullInstallPath
1271}
1272
Colin Cross3854a602016-01-11 12:49:11 -08001273func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
1274 fullInstallPath := installPath.Join(a, name)
Colin Cross178a5092016-09-13 13:42:32 -07001275 a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
Colin Cross3854a602016-01-11 12:49:11 -08001276
Colin Cross893d8162017-04-26 17:34:03 -07001277 if !a.skipInstall(fullInstallPath) {
Colin Crossce75d2c2016-10-06 16:12:58 -07001278
Alex Lightfb4353d2019-01-17 13:57:45 -08001279 relPath, err := filepath.Rel(path.Dir(fullInstallPath.String()), srcPath.String())
1280 if err != nil {
1281 panic(fmt.Sprintf("Unable to generate symlink between %q and %q: %s", fullInstallPath.Base(), srcPath.Base(), err))
1282 }
Colin Crossae887032017-10-23 17:16:14 -07001283 a.Build(pctx, BuildParams{
Colin Cross67a5c132017-05-09 13:45:28 -07001284 Rule: Symlink,
1285 Description: "install symlink " + fullInstallPath.Base(),
1286 Output: fullInstallPath,
1287 OrderOnly: Paths{srcPath},
Colin Cross6510f912017-11-29 00:27:14 -08001288 Default: !a.Config().EmbeddedInMake(),
Colin Cross12fc4972016-01-11 12:49:11 -08001289 Args: map[string]string{
Alex Lightfb4353d2019-01-17 13:57:45 -08001290 "fromPath": relPath,
Colin Cross12fc4972016-01-11 12:49:11 -08001291 },
1292 })
Colin Cross3854a602016-01-11 12:49:11 -08001293
Colin Cross12fc4972016-01-11 12:49:11 -08001294 a.installFiles = append(a.installFiles, fullInstallPath)
1295 a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
1296 }
Colin Cross3854a602016-01-11 12:49:11 -08001297 return fullInstallPath
1298}
1299
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001300func (a *androidModuleContext) CheckbuildFile(srcPath Path) {
Colin Cross3f40fa42015-01-30 17:27:36 -08001301 a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
1302}
1303
Colin Cross3f40fa42015-01-30 17:27:36 -08001304type fileInstaller interface {
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001305 filesToInstall() Paths
Colin Cross3f40fa42015-01-30 17:27:36 -08001306}
1307
1308func isFileInstaller(m blueprint.Module) bool {
1309 _, ok := m.(fileInstaller)
1310 return ok
1311}
1312
1313func isAndroidModule(m blueprint.Module) bool {
Colin Cross635c3b02016-05-18 15:37:25 -07001314 _, ok := m.(Module)
Colin Cross3f40fa42015-01-30 17:27:36 -08001315 return ok
1316}
Colin Crossfce53272015-04-08 11:21:40 -07001317
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001318func findStringInSlice(str string, slice []string) int {
1319 for i, s := range slice {
1320 if s == str {
1321 return i
Colin Crossfce53272015-04-08 11:21:40 -07001322 }
1323 }
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001324 return -1
1325}
1326
Colin Cross068e0fe2016-12-13 15:23:47 -08001327func SrcIsModule(s string) string {
1328 if len(s) > 1 && s[0] == ':' {
1329 return s[1:]
1330 }
1331 return ""
1332}
1333
1334type sourceDependencyTag struct {
1335 blueprint.BaseDependencyTag
1336}
1337
1338var SourceDepTag sourceDependencyTag
1339
Colin Cross366938f2017-12-11 16:29:02 -08001340// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
1341// using ":module" syntax, if any.
Colin Cross068e0fe2016-12-13 15:23:47 -08001342func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
1343 var deps []string
Nan Zhang2439eb72017-04-10 11:27:50 -07001344 set := make(map[string]bool)
1345
Colin Cross068e0fe2016-12-13 15:23:47 -08001346 for _, s := range srcFiles {
1347 if m := SrcIsModule(s); m != "" {
Nan Zhang2439eb72017-04-10 11:27:50 -07001348 if _, found := set[m]; found {
1349 ctx.ModuleErrorf("found source dependency duplicate: %q!", m)
1350 } else {
1351 set[m] = true
1352 deps = append(deps, m)
1353 }
Colin Cross068e0fe2016-12-13 15:23:47 -08001354 }
1355 }
1356
1357 ctx.AddDependency(ctx.Module(), SourceDepTag, deps...)
1358}
1359
Colin Cross366938f2017-12-11 16:29:02 -08001360// Adds necessary dependencies to satisfy filegroup or generated sources modules specified in s
1361// using ":module" syntax, if any.
1362func ExtractSourceDeps(ctx BottomUpMutatorContext, s *string) {
1363 if s != nil {
1364 if m := SrcIsModule(*s); m != "" {
1365 ctx.AddDependency(ctx.Module(), SourceDepTag, m)
1366 }
1367 }
1368}
1369
Colin Cross068e0fe2016-12-13 15:23:47 -08001370type SourceFileProducer interface {
1371 Srcs() Paths
1372}
1373
1374// Returns a list of paths expanded from globs and modules referenced using ":module" syntax.
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001375// ExtractSourcesDeps must have already been called during the dependency resolution phase.
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001376func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001377 return ctx.ExpandSourcesSubDir(srcFiles, excludes, "")
1378}
1379
Colin Cross366938f2017-12-11 16:29:02 -08001380// Returns a single path expanded from globs and modules referenced using ":module" syntax.
1381// ExtractSourceDeps must have already been called during the dependency resolution phase.
1382func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path {
1383 srcFiles := ctx.ExpandSourcesSubDir([]string{srcFile}, nil, "")
1384 if len(srcFiles) == 1 {
1385 return srcFiles[0]
Jaewoong Jung62707f72018-11-16 13:26:43 -08001386 } else if len(srcFiles) == 0 {
1387 if ctx.Config().AllowMissingDependencies() {
1388 ctx.AddMissingDependencies([]string{srcFile})
1389 } else {
1390 ctx.PropertyErrorf(prop, "%s path %s does not exist", prop, srcFile)
1391 }
1392 return nil
Colin Cross366938f2017-12-11 16:29:02 -08001393 } else {
1394 ctx.PropertyErrorf(prop, "module providing %s must produce exactly one file", prop)
1395 return nil
1396 }
1397}
1398
Colin Cross2383f3b2018-02-06 14:40:13 -08001399// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
1400// the srcFile is non-nil.
1401// ExtractSourceDeps must have already been called during the dependency resolution phase.
1402func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
1403 if srcFile != nil {
1404 return OptionalPathForPath(ctx.ExpandSource(*srcFile, prop))
1405 }
1406 return OptionalPath{}
1407}
1408
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001409func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths {
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001410 prefix := PathForModuleSrc(ctx).String()
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001411
Colin Cross461b4452018-02-23 09:22:42 -08001412 var expandedExcludes []string
1413 if excludes != nil {
1414 expandedExcludes = make([]string, 0, len(excludes))
1415 }
Nan Zhang27e284d2018-02-09 21:03:53 +00001416
1417 for _, e := range excludes {
1418 if m := SrcIsModule(e); m != "" {
1419 module := ctx.GetDirectDepWithTag(m, SourceDepTag)
1420 if module == nil {
1421 // Error will have been handled by ExtractSourcesDeps
1422 continue
1423 }
1424 if srcProducer, ok := module.(SourceFileProducer); ok {
1425 expandedExcludes = append(expandedExcludes, srcProducer.Srcs().Strings()...)
1426 } else {
1427 ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
1428 }
1429 } else {
1430 expandedExcludes = append(expandedExcludes, filepath.Join(prefix, e))
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001431 }
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001432 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001433 expandedSrcFiles := make(Paths, 0, len(srcFiles))
Colin Cross8f101b42015-06-17 15:09:06 -07001434 for _, s := range srcFiles {
Colin Cross068e0fe2016-12-13 15:23:47 -08001435 if m := SrcIsModule(s); m != "" {
1436 module := ctx.GetDirectDepWithTag(m, SourceDepTag)
Colin Cross0617bb82017-10-24 13:01:18 -07001437 if module == nil {
1438 // Error will have been handled by ExtractSourcesDeps
1439 continue
1440 }
Colin Cross068e0fe2016-12-13 15:23:47 -08001441 if srcProducer, ok := module.(SourceFileProducer); ok {
Nan Zhang27e284d2018-02-09 21:03:53 +00001442 moduleSrcs := srcProducer.Srcs()
1443 for _, e := range expandedExcludes {
1444 for j, ms := range moduleSrcs {
1445 if ms.String() == e {
1446 moduleSrcs = append(moduleSrcs[:j], moduleSrcs[j+1:]...)
1447 }
1448 }
1449 }
1450 expandedSrcFiles = append(expandedSrcFiles, moduleSrcs...)
Colin Cross068e0fe2016-12-13 15:23:47 -08001451 } else {
1452 ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
1453 }
1454 } else if pathtools.IsGlob(s) {
Dan Willemsen540a78c2018-02-26 21:50:08 -08001455 globbedSrcFiles := ctx.GlobFiles(filepath.Join(prefix, s), expandedExcludes)
Colin Cross05a39cb2017-10-09 13:35:19 -07001456 for i, s := range globbedSrcFiles {
1457 globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001458 }
Colin Cross05a39cb2017-10-09 13:35:19 -07001459 expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
Colin Cross8f101b42015-06-17 15:09:06 -07001460 } else {
Nan Zhang27e284d2018-02-09 21:03:53 +00001461 p := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
1462 j := findStringInSlice(p.String(), expandedExcludes)
1463 if j == -1 {
1464 expandedSrcFiles = append(expandedSrcFiles, p)
1465 }
1466
Colin Cross8f101b42015-06-17 15:09:06 -07001467 }
1468 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001469 return expandedSrcFiles
Colin Cross8f101b42015-06-17 15:09:06 -07001470}
1471
Nan Zhang6d34b302017-02-04 17:47:46 -08001472func (ctx *androidModuleContext) RequiredModuleNames() []string {
1473 return ctx.module.base().commonProperties.Required
1474}
1475
Colin Cross7f19f372016-11-01 11:10:25 -07001476func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
1477 ret, err := ctx.GlobWithDeps(globPattern, excludes)
Colin Cross8f101b42015-06-17 15:09:06 -07001478 if err != nil {
1479 ctx.ModuleErrorf("glob: %s", err.Error())
1480 }
Dan Willemsen540a78c2018-02-26 21:50:08 -08001481 return pathsForModuleSrcFromFullPath(ctx, ret, true)
Colin Crossfce53272015-04-08 11:21:40 -07001482}
Colin Cross1f8c52b2015-06-16 16:38:17 -07001483
Nan Zhang581fd212018-01-10 16:06:12 -08001484func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
Dan Willemsen540a78c2018-02-26 21:50:08 -08001485 ret, err := ctx.GlobWithDeps(globPattern, excludes)
Nan Zhang581fd212018-01-10 16:06:12 -08001486 if err != nil {
1487 ctx.ModuleErrorf("glob: %s", err.Error())
1488 }
Dan Willemsen540a78c2018-02-26 21:50:08 -08001489 return pathsForModuleSrcFromFullPath(ctx, ret, false)
Nan Zhang581fd212018-01-10 16:06:12 -08001490}
1491
Colin Cross463a90e2015-06-17 14:20:06 -07001492func init() {
Colin Cross798bfce2016-10-12 14:28:16 -07001493 RegisterSingletonType("buildtarget", BuildTargetSingleton)
Colin Cross463a90e2015-06-17 14:20:06 -07001494}
1495
Colin Cross0875c522017-11-28 17:34:01 -08001496func BuildTargetSingleton() Singleton {
Colin Cross1f8c52b2015-06-16 16:38:17 -07001497 return &buildTargetSingleton{}
1498}
1499
Colin Cross87d8b562017-04-25 10:01:55 -07001500func parentDir(dir string) string {
1501 dir, _ = filepath.Split(dir)
1502 return filepath.Clean(dir)
1503}
1504
Colin Cross1f8c52b2015-06-16 16:38:17 -07001505type buildTargetSingleton struct{}
1506
Colin Cross0875c522017-11-28 17:34:01 -08001507func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
1508 var checkbuildDeps Paths
Colin Cross1f8c52b2015-06-16 16:38:17 -07001509
Colin Cross0875c522017-11-28 17:34:01 -08001510 mmTarget := func(dir string) WritablePath {
1511 return PathForPhony(ctx,
1512 "MODULES-IN-"+strings.Replace(filepath.Clean(dir), "/", "-", -1))
Colin Cross87d8b562017-04-25 10:01:55 -07001513 }
1514
Colin Cross0875c522017-11-28 17:34:01 -08001515 modulesInDir := make(map[string]Paths)
Colin Cross1f8c52b2015-06-16 16:38:17 -07001516
Colin Cross0875c522017-11-28 17:34:01 -08001517 ctx.VisitAllModules(func(module Module) {
1518 blueprintDir := module.base().blueprintDir
1519 installTarget := module.base().installTarget
1520 checkbuildTarget := module.base().checkbuildTarget
Colin Cross1f8c52b2015-06-16 16:38:17 -07001521
Colin Cross0875c522017-11-28 17:34:01 -08001522 if checkbuildTarget != nil {
1523 checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
1524 modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
1525 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001526
Colin Cross0875c522017-11-28 17:34:01 -08001527 if installTarget != nil {
1528 modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
Colin Cross1f8c52b2015-06-16 16:38:17 -07001529 }
1530 })
1531
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001532 suffix := ""
Colin Crossaabf6792017-11-29 00:27:14 -08001533 if ctx.Config().EmbeddedInMake() {
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001534 suffix = "-soong"
1535 }
1536
Colin Cross1f8c52b2015-06-16 16:38:17 -07001537 // Create a top-level checkbuild target that depends on all modules
Colin Cross0875c522017-11-28 17:34:01 -08001538 ctx.Build(pctx, BuildParams{
Colin Cross1f8c52b2015-06-16 16:38:17 -07001539 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001540 Output: PathForPhony(ctx, "checkbuild"+suffix),
Colin Cross1f8c52b2015-06-16 16:38:17 -07001541 Implicits: checkbuildDeps,
Colin Cross1f8c52b2015-06-16 16:38:17 -07001542 })
1543
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001544 // Make will generate the MODULES-IN-* targets
Colin Crossaabf6792017-11-29 00:27:14 -08001545 if ctx.Config().EmbeddedInMake() {
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001546 return
1547 }
1548
Colin Cross0875c522017-11-28 17:34:01 -08001549 sortedKeys := func(m map[string]Paths) []string {
1550 s := make([]string, 0, len(m))
1551 for k := range m {
1552 s = append(s, k)
1553 }
1554 sort.Strings(s)
1555 return s
1556 }
1557
Colin Cross87d8b562017-04-25 10:01:55 -07001558 // Ensure ancestor directories are in modulesInDir
1559 dirs := sortedKeys(modulesInDir)
1560 for _, dir := range dirs {
1561 dir := parentDir(dir)
1562 for dir != "." && dir != "/" {
1563 if _, exists := modulesInDir[dir]; exists {
1564 break
1565 }
1566 modulesInDir[dir] = nil
1567 dir = parentDir(dir)
1568 }
1569 }
1570
1571 // Make directories build their direct subdirectories
1572 dirs = sortedKeys(modulesInDir)
1573 for _, dir := range dirs {
1574 p := parentDir(dir)
1575 if p != "." && p != "/" {
1576 modulesInDir[p] = append(modulesInDir[p], mmTarget(dir))
1577 }
1578 }
1579
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001580 // Create a MODULES-IN-<directory> target that depends on all modules in a directory, and
1581 // depends on the MODULES-IN-* targets of all of its subdirectories that contain Android.bp
1582 // files.
Colin Cross1f8c52b2015-06-16 16:38:17 -07001583 for _, dir := range dirs {
Colin Cross0875c522017-11-28 17:34:01 -08001584 ctx.Build(pctx, BuildParams{
Colin Cross1f8c52b2015-06-16 16:38:17 -07001585 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001586 Output: mmTarget(dir),
Colin Cross87d8b562017-04-25 10:01:55 -07001587 Implicits: modulesInDir[dir],
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001588 // HACK: checkbuild should be an optional build, but force it
1589 // enabled for now in standalone builds
Colin Crossaabf6792017-11-29 00:27:14 -08001590 Default: !ctx.Config().EmbeddedInMake(),
Colin Cross1f8c52b2015-06-16 16:38:17 -07001591 })
1592 }
Dan Willemsen61d88b82017-09-20 17:29:08 -07001593
1594 // Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
1595 osDeps := map[OsType]Paths{}
Colin Cross0875c522017-11-28 17:34:01 -08001596 ctx.VisitAllModules(func(module Module) {
1597 if module.Enabled() {
1598 os := module.Target().Os
1599 osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001600 }
1601 })
1602
Colin Cross0875c522017-11-28 17:34:01 -08001603 osClass := make(map[string]Paths)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001604 for os, deps := range osDeps {
1605 var className string
1606
1607 switch os.Class {
1608 case Host:
1609 className = "host"
1610 case HostCross:
1611 className = "host-cross"
1612 case Device:
1613 className = "target"
1614 default:
1615 continue
1616 }
1617
Colin Cross0875c522017-11-28 17:34:01 -08001618 name := PathForPhony(ctx, className+"-"+os.Name)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001619 osClass[className] = append(osClass[className], name)
1620
Colin Cross0875c522017-11-28 17:34:01 -08001621 ctx.Build(pctx, BuildParams{
Dan Willemsen61d88b82017-09-20 17:29:08 -07001622 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001623 Output: name,
1624 Implicits: deps,
Dan Willemsen61d88b82017-09-20 17:29:08 -07001625 })
1626 }
1627
1628 // Wrap those into host|host-cross|target phony rules
1629 osClasses := sortedKeys(osClass)
1630 for _, class := range osClasses {
Colin Cross0875c522017-11-28 17:34:01 -08001631 ctx.Build(pctx, BuildParams{
Dan Willemsen61d88b82017-09-20 17:29:08 -07001632 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001633 Output: PathForPhony(ctx, class),
Dan Willemsen61d88b82017-09-20 17:29:08 -07001634 Implicits: osClass[class],
Dan Willemsen61d88b82017-09-20 17:29:08 -07001635 })
1636 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001637}
Colin Crossd779da42015-12-17 18:00:23 -08001638
Brandon Lee5d45c6f2018-08-15 15:35:38 -07001639// Collect information for opening IDE project files in java/jdeps.go.
1640type IDEInfo interface {
1641 IDEInfo(ideInfo *IdeInfo)
1642 BaseModuleName() string
1643}
1644
1645// Extract the base module name from the Import name.
1646// Often the Import name has a prefix "prebuilt_".
1647// Remove the prefix explicitly if needed
1648// until we find a better solution to get the Import name.
1649type IDECustomizedModuleName interface {
1650 IDECustomizedModuleName() string
1651}
1652
1653type IdeInfo struct {
1654 Deps []string `json:"dependencies,omitempty"`
1655 Srcs []string `json:"srcs,omitempty"`
1656 Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"`
1657 Jarjar_rules []string `json:"jarjar_rules,omitempty"`
1658 Jars []string `json:"jars,omitempty"`
1659 Classes []string `json:"class,omitempty"`
1660 Installed_paths []string `json:"installed,omitempty"`
1661}