blob: d2f84ce52392f55b449c9acc4ddfd80017fb9b3b [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"
Colin Cross3f40fa42015-01-30 17:27:36 -080019 "path/filepath"
Colin Cross0875c522017-11-28 17:34:01 -080020 "sort"
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 Crossf6566ed2015-03-24 11:13:38 -070058type androidBaseContext interface {
Colin Crossa1ad8d12016-06-01 17:09:44 -070059 Target() Target
Colin Cross8b74d172016-09-13 09:59:14 -070060 TargetPrimary() bool
Colin Crossee0bc3b2018-10-02 22:01:37 -070061 MultiTargets() []Target
Colin Crossf6566ed2015-03-24 11:13:38 -070062 Arch() Arch
Colin Crossa1ad8d12016-06-01 17:09:44 -070063 Os() OsType
Colin Crossf6566ed2015-03-24 11:13:38 -070064 Host() bool
65 Device() bool
Colin Cross0af4b842015-04-30 16:36:18 -070066 Darwin() bool
Colin Cross3edeee12017-04-04 12:59:48 -070067 Windows() bool
Colin Crossf6566ed2015-03-24 11:13:38 -070068 Debug() bool
Colin Cross1e7d3702016-08-24 15:25:47 -070069 PrimaryArch() bool
Jiyong Park2db76922017-11-08 16:03:48 +090070 Platform() bool
71 DeviceSpecific() bool
72 SocSpecific() bool
73 ProductSpecific() bool
Dario Frenifd05a742018-05-29 13:28:54 +010074 ProductServicesSpecific() bool
Colin Cross1332b002015-04-07 17:11:30 -070075 AConfig() Config
Colin Cross9272ade2016-08-17 15:24:12 -070076 DeviceConfig() DeviceConfig
Colin Crossf6566ed2015-03-24 11:13:38 -070077}
78
Colin Cross635c3b02016-05-18 15:37:25 -070079type BaseContext interface {
Colin Crossaabf6792017-11-29 00:27:14 -080080 BaseModuleContext
Colin Crossf6566ed2015-03-24 11:13:38 -070081 androidBaseContext
82}
83
Colin Crossaabf6792017-11-29 00:27:14 -080084// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
85// a Config instead of an interface{}.
86type BaseModuleContext interface {
87 ModuleName() string
88 ModuleDir() string
89 Config() Config
90
91 ContainsProperty(name string) bool
92 Errorf(pos scanner.Position, fmt string, args ...interface{})
93 ModuleErrorf(fmt string, args ...interface{})
94 PropertyErrorf(property, fmt string, args ...interface{})
95 Failed() bool
96
97 // GlobWithDeps returns a list of files that match the specified pattern but do not match any
98 // of the patterns in excludes. It also adds efficient dependencies to rerun the primary
99 // builder whenever a file matching the pattern as added or removed, without rerunning if a
100 // file that does not match the pattern is added to a searched directory.
101 GlobWithDeps(pattern string, excludes []string) ([]string, error)
102
103 Fs() pathtools.FileSystem
104 AddNinjaFileDeps(deps ...string)
105}
106
Colin Cross635c3b02016-05-18 15:37:25 -0700107type ModuleContext interface {
Colin Crossf6566ed2015-03-24 11:13:38 -0700108 androidBaseContext
Colin Crossaabf6792017-11-29 00:27:14 -0800109 BaseModuleContext
Colin Cross3f40fa42015-01-30 17:27:36 -0800110
Colin Crossae887032017-10-23 17:16:14 -0700111 // Deprecated: use ModuleContext.Build instead.
Colin Cross0875c522017-11-28 17:34:01 -0800112 ModuleBuild(pctx PackageContext, params ModuleBuildParams)
Colin Cross8f101b42015-06-17 15:09:06 -0700113
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700114 ExpandSources(srcFiles, excludes []string) Paths
Colin Cross366938f2017-12-11 16:29:02 -0800115 ExpandSource(srcFile, prop string) Path
Colin Cross2383f3b2018-02-06 14:40:13 -0800116 ExpandOptionalSource(srcFile *string, prop string) OptionalPath
Colin Crossfaeb7aa2017-02-01 14:12:44 -0800117 ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths
Colin Cross7f19f372016-11-01 11:10:25 -0700118 Glob(globPattern string, excludes []string) Paths
Nan Zhang581fd212018-01-10 16:06:12 -0800119 GlobFiles(globPattern string, excludes []string) Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700120
Colin Cross5c517922017-08-31 12:29:17 -0700121 InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
122 InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
Colin Cross3854a602016-01-11 12:49:11 -0800123 InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700124 CheckbuildFile(srcPath Path)
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800125
126 AddMissingDependencies(deps []string)
Colin Cross8d8f8e22016-08-03 11:57:50 -0700127
Colin Cross8d8f8e22016-08-03 11:57:50 -0700128 InstallInData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700129 InstallInSanitizerDir() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900130 InstallInRecovery() bool
Nan Zhang6d34b302017-02-04 17:47:46 -0800131
132 RequiredModuleNames() []string
Colin Cross3f68a132017-10-23 17:10:29 -0700133
134 // android.ModuleContext methods
135 // These are duplicated instead of embedded so that can eventually be wrapped to take an
136 // android.Module instead of a blueprint.Module
137 OtherModuleName(m blueprint.Module) string
138 OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
139 OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
140
141 GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
142 GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
143
144 ModuleSubDir() string
145
Colin Cross35143d02017-11-16 00:11:20 -0800146 VisitDirectDepsBlueprint(visit func(blueprint.Module))
Colin Crossd11fcda2017-10-23 17:59:01 -0700147 VisitDirectDeps(visit func(Module))
Colin Crossee6143c2017-12-30 17:54:27 -0800148 VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
Colin Crossd11fcda2017-10-23 17:59:01 -0700149 VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
Colin Cross6b753602018-06-21 13:03:07 -0700150 // Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
Colin Crossd11fcda2017-10-23 17:59:01 -0700151 VisitDepsDepthFirst(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 VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
154 WalkDeps(visit func(Module, Module) bool)
Colin Cross3f68a132017-10-23 17:10:29 -0700155
Colin Cross0875c522017-11-28 17:34:01 -0800156 Variable(pctx PackageContext, name, value string)
157 Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
Colin Crossae887032017-10-23 17:16:14 -0700158 // Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
159 // and performs more verification.
Colin Cross0875c522017-11-28 17:34:01 -0800160 Build(pctx PackageContext, params BuildParams)
Colin Cross3f68a132017-10-23 17:10:29 -0700161
Colin Cross0875c522017-11-28 17:34:01 -0800162 PrimaryModule() Module
163 FinalModule() Module
164 VisitAllModuleVariants(visit func(Module))
Colin Cross3f68a132017-10-23 17:10:29 -0700165
166 GetMissingDependencies() []string
Jeff Gaston088e29e2017-11-29 16:47:17 -0800167 Namespace() blueprint.Namespace
Colin Cross3f40fa42015-01-30 17:27:36 -0800168}
169
Colin Cross635c3b02016-05-18 15:37:25 -0700170type Module interface {
Colin Cross3f40fa42015-01-30 17:27:36 -0800171 blueprint.Module
172
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700173 // GenerateAndroidBuildActions is analogous to Blueprints' GenerateBuildActions,
174 // but GenerateAndroidBuildActions also has access to Android-specific information.
175 // For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
Colin Cross635c3b02016-05-18 15:37:25 -0700176 GenerateAndroidBuildActions(ModuleContext)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700177
Colin Cross1e676be2016-10-12 14:38:15 -0700178 DepsMutator(BottomUpMutatorContext)
Colin Cross3f40fa42015-01-30 17:27:36 -0800179
Colin Cross635c3b02016-05-18 15:37:25 -0700180 base() *ModuleBase
Dan Willemsen0effe062015-11-30 16:06:01 -0800181 Enabled() bool
Colin Crossa1ad8d12016-06-01 17:09:44 -0700182 Target() Target
Dan Willemsen782a2d12015-12-21 14:55:28 -0800183 InstallInData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700184 InstallInSanitizerDir() bool
Jiyong Parkf9332f12018-02-01 00:54:12 +0900185 InstallInRecovery() bool
Colin Crossa2f296f2016-11-29 15:16:18 -0800186 SkipInstall()
Jiyong Park374510b2018-03-19 18:23:01 +0900187 ExportedToMake() bool
Colin Cross36242852017-06-23 15:06:31 -0700188
189 AddProperties(props ...interface{})
190 GetProperties() []interface{}
Colin Crosscec81712017-07-13 14:43:27 -0700191
Colin Crossae887032017-10-23 17:16:14 -0700192 BuildParamsForTests() []BuildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800193 VariablesForTests() map[string]string
Colin Cross3f40fa42015-01-30 17:27:36 -0800194}
195
Colin Crossfc754582016-05-17 16:34:16 -0700196type nameProperties struct {
197 // The name of the module. Must be unique across all modules.
Nan Zhang0007d812017-11-07 10:57:05 -0800198 Name *string
Colin Crossfc754582016-05-17 16:34:16 -0700199}
200
201type commonProperties struct {
Dan Willemsen0effe062015-11-30 16:06:01 -0800202 // emit build rules for this module
203 Enabled *bool `android:"arch_variant"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800204
Colin Cross7d5136f2015-05-11 13:39:40 -0700205 // control whether this module compiles for 32-bit, 64-bit, or both. Possible values
Colin Cross3f40fa42015-01-30 17:27:36 -0800206 // are "32" (compile for 32-bit only), "64" (compile for 64-bit only), "both" (compile for both
207 // architectures), or "first" (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit
208 // platform
Colin Cross7d716ba2017-11-01 10:38:29 -0700209 Compile_multilib *string `android:"arch_variant"`
Colin Cross69617d32016-09-06 10:39:07 -0700210
211 Target struct {
212 Host struct {
Colin Cross7d716ba2017-11-01 10:38:29 -0700213 Compile_multilib *string
Colin Cross69617d32016-09-06 10:39:07 -0700214 }
215 Android struct {
Colin Cross7d716ba2017-11-01 10:38:29 -0700216 Compile_multilib *string
Colin Cross69617d32016-09-06 10:39:07 -0700217 }
218 }
219
Colin Crossee0bc3b2018-10-02 22:01:37 -0700220 UseTargetVariants bool `blueprint:"mutated"`
221 Default_multilib string `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800222
Dan Willemsen782a2d12015-12-21 14:55:28 -0800223 // whether this is a proprietary vendor module, and should be installed into /vendor
Colin Cross7d716ba2017-11-01 10:38:29 -0700224 Proprietary *bool
Dan Willemsen782a2d12015-12-21 14:55:28 -0800225
Colin Cross55708f32017-03-20 13:23:34 -0700226 // vendor who owns this module
Dan Willemsenefac4a82017-07-18 19:42:09 -0700227 Owner *string
Colin Cross55708f32017-03-20 13:23:34 -0700228
Jiyong Park2db76922017-11-08 16:03:48 +0900229 // whether this module is specific to an SoC (System-On-a-Chip). When set to true,
230 // it is installed into /vendor (or /system/vendor if vendor partition does not exist).
231 // Use `soc_specific` instead for better meaning.
Colin Cross7d716ba2017-11-01 10:38:29 -0700232 Vendor *bool
Dan Willemsenaa118f92017-04-06 12:49:58 -0700233
Jiyong Park2db76922017-11-08 16:03:48 +0900234 // whether this module is specific to an SoC (System-On-a-Chip). When set to true,
235 // it is installed into /vendor (or /system/vendor if vendor partition does not exist).
236 Soc_specific *bool
237
238 // whether this module is specific to a device, not only for SoC, but also for off-chip
239 // peripherals. When set to true, it is installed into /odm (or /vendor/odm if odm partition
240 // does not exist, or /system/vendor/odm if both odm and vendor partitions do not exist).
241 // This implies `soc_specific:true`.
242 Device_specific *bool
243
244 // whether this module is specific to a software configuration of a product (e.g. country,
Jaekyun Seok5cfbfbb2018-01-10 19:00:15 +0900245 // network operator, etc). When set to true, it is installed into /product (or
246 // /system/product if product partition does not exist).
Jiyong Park2db76922017-11-08 16:03:48 +0900247 Product_specific *bool
248
Dario Frenifd05a742018-05-29 13:28:54 +0100249 // whether this module provides services owned by the OS provider to the core platform. When set
Dario Freni95cf7672018-08-17 00:57:57 +0100250 // to true, it is installed into /product_services (or /system/product_services if
251 // product_services partition does not exist).
252 Product_services_specific *bool
Dario Frenifd05a742018-05-29 13:28:54 +0100253
Jiyong Parkf9332f12018-02-01 00:54:12 +0900254 // Whether this module is installed to recovery partition
255 Recovery *bool
256
Dan Willemsen2277bcb2016-07-25 20:27:39 -0700257 // init.rc files to be installed if this module is installed
258 Init_rc []string
259
Steven Moreland57a23d22018-04-04 15:42:19 -0700260 // VINTF manifest fragments to be installed if this module is installed
261 Vintf_fragments []string
262
Chris Wolfe998306e2016-08-15 14:47:23 -0400263 // names of other modules to install if this module is installed
Colin Crossc602b7d2017-05-05 13:36:36 -0700264 Required []string `android:"arch_variant"`
Chris Wolfe998306e2016-08-15 14:47:23 -0400265
Colin Cross5aac3622017-08-31 15:07:09 -0700266 // relative path to a file to include in the list of notices for the device
267 Notice *string
268
Dan Willemsen569edc52018-11-19 09:33:29 -0800269 Dist struct {
270 // copy the output of this module to the $DIST_DIR when `dist` is specified on the
271 // command line and any of these targets are also on the command line, or otherwise
272 // built
273 Targets []string `android:"arch_variant"`
274
275 // The name of the output artifact. This defaults to the basename of the output of
276 // the module.
277 Dest *string `android:"arch_variant"`
278
279 // The directory within the dist directory to store the artifact. Defaults to the
280 // top level directory ("").
281 Dir *string `android:"arch_variant"`
282
283 // A suffix to add to the artifact file name (before any extension).
284 Suffix *string `android:"arch_variant"`
285 } `android:"arch_variant"`
286
Colin Crossa1ad8d12016-06-01 17:09:44 -0700287 // Set by TargetMutator
Colin Crossee0bc3b2018-10-02 22:01:37 -0700288 CompileTarget Target `blueprint:"mutated"`
289 CompileMultiTargets []Target `blueprint:"mutated"`
290 CompilePrimary bool `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800291
292 // Set by InitAndroidModule
293 HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
Dan Willemsen0b24c742016-10-04 15:13:37 -0700294 ArchSpecific bool `blueprint:"mutated"`
Colin Crossce75d2c2016-10-06 16:12:58 -0700295
296 SkipInstall bool `blueprint:"mutated"`
Jeff Gaston088e29e2017-11-29 16:47:17 -0800297
298 NamespaceExportedToMake bool `blueprint:"mutated"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800299}
300
301type hostAndDeviceProperties struct {
Colin Cross4e81d702018-11-09 10:36:55 -0800302 // If set to true, build a variant of the module for the host. Defaults to false.
303 Host_supported *bool
304
305 // If set to true, build a variant of the module for the device. Defaults to true.
Colin Crossa4190c12016-07-12 13:11:25 -0700306 Device_supported *bool
Colin Cross3f40fa42015-01-30 17:27:36 -0800307}
308
Colin Crossc472d572015-03-17 15:06:21 -0700309type Multilib string
310
311const (
Colin Cross6b4a32d2017-12-05 13:42:45 -0800312 MultilibBoth Multilib = "both"
313 MultilibFirst Multilib = "first"
314 MultilibCommon Multilib = "common"
315 MultilibCommonFirst Multilib = "common_first"
316 MultilibDefault Multilib = ""
Colin Crossc472d572015-03-17 15:06:21 -0700317)
318
Colin Crossa1ad8d12016-06-01 17:09:44 -0700319type HostOrDeviceSupported int
320
321const (
322 _ HostOrDeviceSupported = iota
Dan Albert0981b5c2018-08-02 13:46:35 -0700323
324 // Host and HostCross are built by default. Device is not supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700325 HostSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700326
327 // Host is built by default. HostCross and Device are not supported.
Dan Albertc6345fb2016-10-20 01:36:11 -0700328 HostSupportedNoCross
Dan Albert0981b5c2018-08-02 13:46:35 -0700329
330 // Device is built by default. Host and HostCross are not supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700331 DeviceSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700332
333 // Device is built by default. Host and HostCross are supported.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700334 HostAndDeviceSupported
Dan Albert0981b5c2018-08-02 13:46:35 -0700335
336 // Host, HostCross, and Device are built by default.
Colin Crossa1ad8d12016-06-01 17:09:44 -0700337 HostAndDeviceDefault
Dan Albert0981b5c2018-08-02 13:46:35 -0700338
339 // Nothing is supported. This is not exposed to the user, but used to mark a
340 // host only module as unsupported when the module type is not supported on
341 // the host OS. E.g. benchmarks are supported on Linux but not Darwin.
Dan Willemsen0b24c742016-10-04 15:13:37 -0700342 NeitherHostNorDeviceSupported
Colin Crossa1ad8d12016-06-01 17:09:44 -0700343)
344
Jiyong Park2db76922017-11-08 16:03:48 +0900345type moduleKind int
346
347const (
348 platformModule moduleKind = iota
349 deviceSpecificModule
350 socSpecificModule
351 productSpecificModule
Dario Frenifd05a742018-05-29 13:28:54 +0100352 productServicesSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +0900353)
354
355func (k moduleKind) String() string {
356 switch k {
357 case platformModule:
358 return "platform"
359 case deviceSpecificModule:
360 return "device-specific"
361 case socSpecificModule:
362 return "soc-specific"
363 case productSpecificModule:
364 return "product-specific"
Dario Frenifd05a742018-05-29 13:28:54 +0100365 case productServicesSpecificModule:
366 return "productservices-specific"
Jiyong Park2db76922017-11-08 16:03:48 +0900367 default:
368 panic(fmt.Errorf("unknown module kind %d", k))
369 }
370}
371
Colin Cross36242852017-06-23 15:06:31 -0700372func InitAndroidModule(m Module) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800373 base := m.base()
374 base.module = m
Colin Cross5049f022015-03-18 13:28:46 -0700375
Colin Cross36242852017-06-23 15:06:31 -0700376 m.AddProperties(
Colin Crossfc754582016-05-17 16:34:16 -0700377 &base.nameProperties,
378 &base.commonProperties,
379 &base.variableProperties)
Pirama Arumuga Nainar955dc492018-04-17 14:58:42 -0700380 base.customizableProperties = m.GetProperties()
Colin Cross5049f022015-03-18 13:28:46 -0700381}
382
Colin Cross36242852017-06-23 15:06:31 -0700383func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
384 InitAndroidModule(m)
Colin Cross5049f022015-03-18 13:28:46 -0700385
386 base := m.base()
Colin Cross3f40fa42015-01-30 17:27:36 -0800387 base.commonProperties.HostOrDeviceSupported = hod
Colin Cross69617d32016-09-06 10:39:07 -0700388 base.commonProperties.Default_multilib = string(defaultMultilib)
Dan Willemsen0b24c742016-10-04 15:13:37 -0700389 base.commonProperties.ArchSpecific = true
Colin Crossee0bc3b2018-10-02 22:01:37 -0700390 base.commonProperties.UseTargetVariants = true
Colin Cross3f40fa42015-01-30 17:27:36 -0800391
Dan Willemsen218f6562015-07-08 18:13:11 -0700392 switch hod {
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700393 case HostAndDeviceSupported, HostAndDeviceDefault:
Colin Cross36242852017-06-23 15:06:31 -0700394 m.AddProperties(&base.hostAndDeviceProperties)
Colin Cross3f40fa42015-01-30 17:27:36 -0800395 }
396
Colin Cross36242852017-06-23 15:06:31 -0700397 InitArchModule(m)
Colin Cross3f40fa42015-01-30 17:27:36 -0800398}
399
Colin Crossee0bc3b2018-10-02 22:01:37 -0700400func InitAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
401 InitAndroidArchModule(m, hod, defaultMultilib)
402 m.base().commonProperties.UseTargetVariants = false
403}
404
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800405// A ModuleBase object contains the properties that are common to all Android
Colin Cross3f40fa42015-01-30 17:27:36 -0800406// modules. It should be included as an anonymous field in every module
407// struct definition. InitAndroidModule should then be called from the module's
408// factory function, and the return values from InitAndroidModule should be
409// returned from the factory function.
410//
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800411// The ModuleBase type is responsible for implementing the GenerateBuildActions
412// method to support the blueprint.Module interface. This method will then call
413// the module's GenerateAndroidBuildActions method once for each build variant
414// that is to be built. GenerateAndroidBuildActions is passed a
415// AndroidModuleContext rather than the usual blueprint.ModuleContext.
Colin Cross3f40fa42015-01-30 17:27:36 -0800416// AndroidModuleContext exposes extra functionality specific to the Android build
417// system including details about the particular build variant that is to be
418// generated.
419//
420// For example:
421//
422// import (
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800423// "android/soong/android"
Colin Cross3f40fa42015-01-30 17:27:36 -0800424// )
425//
426// type myModule struct {
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800427// android.ModuleBase
Colin Cross3f40fa42015-01-30 17:27:36 -0800428// properties struct {
429// MyProperty string
430// }
431// }
432//
Colin Cross36242852017-06-23 15:06:31 -0700433// func NewMyModule() android.Module) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800434// m := &myModule{}
Colin Cross36242852017-06-23 15:06:31 -0700435// m.AddProperties(&m.properties)
436// android.InitAndroidModule(m)
437// return m
Colin Cross3f40fa42015-01-30 17:27:36 -0800438// }
439//
Nan Zhangb9eeb1d2017-02-02 10:46:07 -0800440// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Cross3f40fa42015-01-30 17:27:36 -0800441// // Get the CPU architecture for the current build variant.
442// variantArch := ctx.Arch()
443//
444// // ...
445// }
Colin Cross635c3b02016-05-18 15:37:25 -0700446type ModuleBase struct {
Colin Cross3f40fa42015-01-30 17:27:36 -0800447 // Putting the curiously recurring thing pointing to the thing that contains
448 // the thing pattern to good use.
Colin Cross36242852017-06-23 15:06:31 -0700449 // TODO: remove this
Colin Cross635c3b02016-05-18 15:37:25 -0700450 module Module
Colin Cross3f40fa42015-01-30 17:27:36 -0800451
Colin Crossfc754582016-05-17 16:34:16 -0700452 nameProperties nameProperties
Colin Cross3f40fa42015-01-30 17:27:36 -0800453 commonProperties commonProperties
Colin Cross7f64b6d2015-07-09 13:57:48 -0700454 variableProperties variableProperties
Colin Cross3f40fa42015-01-30 17:27:36 -0800455 hostAndDeviceProperties hostAndDeviceProperties
456 generalProperties []interface{}
Colin Crossc17727d2018-10-24 12:42:09 -0700457 archProperties [][]interface{}
Colin Crossa120ec12016-08-19 16:07:38 -0700458 customizableProperties []interface{}
Colin Cross3f40fa42015-01-30 17:27:36 -0800459
460 noAddressSanitizer bool
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700461 installFiles Paths
462 checkbuildFiles Paths
Jaewoong Jung62707f72018-11-16 13:26:43 -0800463 noticeFile Path
Colin Cross1f8c52b2015-06-16 16:38:17 -0700464
465 // Used by buildTargetSingleton to create checkbuild and per-directory build targets
466 // Only set on the final variant of each module
Colin Cross0875c522017-11-28 17:34:01 -0800467 installTarget WritablePath
468 checkbuildTarget WritablePath
Colin Cross1f8c52b2015-06-16 16:38:17 -0700469 blueprintDir string
Colin Crossa120ec12016-08-19 16:07:38 -0700470
Colin Cross178a5092016-09-13 13:42:32 -0700471 hooks hooks
Colin Cross36242852017-06-23 15:06:31 -0700472
473 registerProps []interface{}
Colin Crosscec81712017-07-13 14:43:27 -0700474
475 // For tests
Colin Crossae887032017-10-23 17:16:14 -0700476 buildParams []BuildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800477 variables map[string]string
Colin Crossa9d8bee2018-10-02 13:59:46 -0700478
479 prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
Colin Cross36242852017-06-23 15:06:31 -0700480}
481
482func (a *ModuleBase) AddProperties(props ...interface{}) {
483 a.registerProps = append(a.registerProps, props...)
484}
485
486func (a *ModuleBase) GetProperties() []interface{} {
487 return a.registerProps
Colin Cross3f40fa42015-01-30 17:27:36 -0800488}
489
Colin Crossae887032017-10-23 17:16:14 -0700490func (a *ModuleBase) BuildParamsForTests() []BuildParams {
Colin Crosscec81712017-07-13 14:43:27 -0700491 return a.buildParams
492}
493
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800494func (a *ModuleBase) VariablesForTests() map[string]string {
495 return a.variables
496}
497
Colin Crossa9d8bee2018-10-02 13:59:46 -0700498func (a *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
499 a.prefer32 = prefer32
500}
501
Colin Crossce75d2c2016-10-06 16:12:58 -0700502// Name returns the name of the module. It may be overridden by individual module types, for
503// example prebuilts will prepend prebuilt_ to the name.
Colin Crossfc754582016-05-17 16:34:16 -0700504func (a *ModuleBase) Name() string {
Nan Zhang0007d812017-11-07 10:57:05 -0800505 return String(a.nameProperties.Name)
Colin Crossfc754582016-05-17 16:34:16 -0700506}
507
Colin Crossce75d2c2016-10-06 16:12:58 -0700508// BaseModuleName returns the name of the module as specified in the blueprints file.
509func (a *ModuleBase) BaseModuleName() string {
Nan Zhang0007d812017-11-07 10:57:05 -0800510 return String(a.nameProperties.Name)
Colin Crossce75d2c2016-10-06 16:12:58 -0700511}
512
Colin Cross635c3b02016-05-18 15:37:25 -0700513func (a *ModuleBase) base() *ModuleBase {
Colin Cross3f40fa42015-01-30 17:27:36 -0800514 return a
515}
516
Colin Crossee0bc3b2018-10-02 22:01:37 -0700517func (a *ModuleBase) SetTarget(target Target, multiTargets []Target, primary bool) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700518 a.commonProperties.CompileTarget = target
Colin Crossee0bc3b2018-10-02 22:01:37 -0700519 a.commonProperties.CompileMultiTargets = multiTargets
Colin Cross8b74d172016-09-13 09:59:14 -0700520 a.commonProperties.CompilePrimary = primary
Colin Crossd3ba0392015-05-07 14:11:29 -0700521}
522
Colin Crossa1ad8d12016-06-01 17:09:44 -0700523func (a *ModuleBase) Target() Target {
524 return a.commonProperties.CompileTarget
Dan Willemsen490fd492015-11-24 17:53:15 -0800525}
526
Colin Cross8b74d172016-09-13 09:59:14 -0700527func (a *ModuleBase) TargetPrimary() bool {
528 return a.commonProperties.CompilePrimary
529}
530
Colin Crossee0bc3b2018-10-02 22:01:37 -0700531func (a *ModuleBase) MultiTargets() []Target {
532 return a.commonProperties.CompileMultiTargets
533}
534
Colin Crossa1ad8d12016-06-01 17:09:44 -0700535func (a *ModuleBase) Os() OsType {
536 return a.Target().Os
Dan Willemsen490fd492015-11-24 17:53:15 -0800537}
538
Colin Cross635c3b02016-05-18 15:37:25 -0700539func (a *ModuleBase) Host() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700540 return a.Os().Class == Host || a.Os().Class == HostCross
Dan Willemsen97750522016-02-09 17:43:51 -0800541}
542
Colin Cross635c3b02016-05-18 15:37:25 -0700543func (a *ModuleBase) Arch() Arch {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700544 return a.Target().Arch
Dan Willemsen97750522016-02-09 17:43:51 -0800545}
546
Dan Willemsen0b24c742016-10-04 15:13:37 -0700547func (a *ModuleBase) ArchSpecific() bool {
548 return a.commonProperties.ArchSpecific
549}
550
Colin Crossa1ad8d12016-06-01 17:09:44 -0700551func (a *ModuleBase) OsClassSupported() []OsClass {
552 switch a.commonProperties.HostOrDeviceSupported {
553 case HostSupported:
Colin Crossa1ad8d12016-06-01 17:09:44 -0700554 return []OsClass{Host, HostCross}
Dan Albertc6345fb2016-10-20 01:36:11 -0700555 case HostSupportedNoCross:
556 return []OsClass{Host}
Colin Crossa1ad8d12016-06-01 17:09:44 -0700557 case DeviceSupported:
558 return []OsClass{Device}
Dan Albert0981b5c2018-08-02 13:46:35 -0700559 case HostAndDeviceSupported, HostAndDeviceDefault:
Colin Crossa1ad8d12016-06-01 17:09:44 -0700560 var supported []OsClass
Dan Albert0981b5c2018-08-02 13:46:35 -0700561 if Bool(a.hostAndDeviceProperties.Host_supported) ||
562 (a.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
563 a.hostAndDeviceProperties.Host_supported == nil) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700564 supported = append(supported, Host, HostCross)
565 }
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700566 if a.hostAndDeviceProperties.Device_supported == nil ||
567 *a.hostAndDeviceProperties.Device_supported {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700568 supported = append(supported, Device)
569 }
570 return supported
571 default:
572 return nil
573 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800574}
575
Colin Cross635c3b02016-05-18 15:37:25 -0700576func (a *ModuleBase) DeviceSupported() bool {
Colin Cross3f40fa42015-01-30 17:27:36 -0800577 return a.commonProperties.HostOrDeviceSupported == DeviceSupported ||
578 a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
Nan Zhang1a0f09b2017-07-05 10:35:11 -0700579 (a.hostAndDeviceProperties.Device_supported == nil ||
580 *a.hostAndDeviceProperties.Device_supported)
Colin Cross3f40fa42015-01-30 17:27:36 -0800581}
582
Jiyong Parkc678ad32018-04-10 13:07:10 +0900583func (a *ModuleBase) Platform() bool {
Dario Frenifd05a742018-05-29 13:28:54 +0100584 return !a.DeviceSpecific() && !a.SocSpecific() && !a.ProductSpecific() && !a.ProductServicesSpecific()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900585}
586
587func (a *ModuleBase) DeviceSpecific() bool {
588 return Bool(a.commonProperties.Device_specific)
589}
590
591func (a *ModuleBase) SocSpecific() bool {
592 return Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
593}
594
595func (a *ModuleBase) ProductSpecific() bool {
596 return Bool(a.commonProperties.Product_specific)
597}
598
Dario Frenifd05a742018-05-29 13:28:54 +0100599func (a *ModuleBase) ProductServicesSpecific() bool {
Dario Freni95cf7672018-08-17 00:57:57 +0100600 return Bool(a.commonProperties.Product_services_specific)
Dario Frenifd05a742018-05-29 13:28:54 +0100601}
602
Colin Cross635c3b02016-05-18 15:37:25 -0700603func (a *ModuleBase) Enabled() bool {
Dan Willemsen0effe062015-11-30 16:06:01 -0800604 if a.commonProperties.Enabled == nil {
Dan Willemsen0a37a2a2016-11-13 10:16:05 -0800605 return !a.Os().DefaultDisabled
Dan Willemsen490fd492015-11-24 17:53:15 -0800606 }
Dan Willemsen0effe062015-11-30 16:06:01 -0800607 return *a.commonProperties.Enabled
Colin Cross3f40fa42015-01-30 17:27:36 -0800608}
609
Colin Crossce75d2c2016-10-06 16:12:58 -0700610func (a *ModuleBase) SkipInstall() {
611 a.commonProperties.SkipInstall = true
612}
613
Jiyong Park374510b2018-03-19 18:23:01 +0900614func (a *ModuleBase) ExportedToMake() bool {
615 return a.commonProperties.NamespaceExportedToMake
616}
617
Colin Cross635c3b02016-05-18 15:37:25 -0700618func (a *ModuleBase) computeInstallDeps(
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700619 ctx blueprint.ModuleContext) Paths {
Colin Cross3f40fa42015-01-30 17:27:36 -0800620
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700621 result := Paths{}
Colin Cross6b753602018-06-21 13:03:07 -0700622 // TODO(ccross): we need to use WalkDeps and have some way to know which dependencies require installation
Colin Cross3f40fa42015-01-30 17:27:36 -0800623 ctx.VisitDepsDepthFirstIf(isFileInstaller,
624 func(m blueprint.Module) {
625 fileInstaller := m.(fileInstaller)
626 files := fileInstaller.filesToInstall()
627 result = append(result, files...)
628 })
629
630 return result
631}
632
Colin Cross635c3b02016-05-18 15:37:25 -0700633func (a *ModuleBase) filesToInstall() Paths {
Colin Cross3f40fa42015-01-30 17:27:36 -0800634 return a.installFiles
635}
636
Colin Cross635c3b02016-05-18 15:37:25 -0700637func (p *ModuleBase) NoAddressSanitizer() bool {
Colin Cross3f40fa42015-01-30 17:27:36 -0800638 return p.noAddressSanitizer
639}
640
Colin Cross635c3b02016-05-18 15:37:25 -0700641func (p *ModuleBase) InstallInData() bool {
Dan Willemsen782a2d12015-12-21 14:55:28 -0800642 return false
643}
644
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700645func (p *ModuleBase) InstallInSanitizerDir() bool {
646 return false
647}
648
Jiyong Parkf9332f12018-02-01 00:54:12 +0900649func (p *ModuleBase) InstallInRecovery() bool {
650 return Bool(p.commonProperties.Recovery)
651}
652
Sundong Ahn4fd04bb2018-08-31 18:01:37 +0900653func (a *ModuleBase) Owner() string {
654 return String(a.commonProperties.Owner)
655}
656
Colin Cross0875c522017-11-28 17:34:01 -0800657func (a *ModuleBase) generateModuleTarget(ctx ModuleContext) {
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700658 allInstalledFiles := Paths{}
659 allCheckbuildFiles := Paths{}
Colin Cross0875c522017-11-28 17:34:01 -0800660 ctx.VisitAllModuleVariants(func(module Module) {
661 a := module.base()
Colin Crossc9404352015-03-26 16:10:12 -0700662 allInstalledFiles = append(allInstalledFiles, a.installFiles...)
663 allCheckbuildFiles = append(allCheckbuildFiles, a.checkbuildFiles...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800664 })
665
Colin Cross0875c522017-11-28 17:34:01 -0800666 var deps Paths
Colin Cross9454bfa2015-03-17 13:24:18 -0700667
Jeff Gaston088e29e2017-11-29 16:47:17 -0800668 namespacePrefix := ctx.Namespace().(*Namespace).id
669 if namespacePrefix != "" {
670 namespacePrefix = namespacePrefix + "-"
671 }
672
Colin Cross3f40fa42015-01-30 17:27:36 -0800673 if len(allInstalledFiles) > 0 {
Jeff Gaston088e29e2017-11-29 16:47:17 -0800674 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-install")
Colin Cross0875c522017-11-28 17:34:01 -0800675 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700676 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -0800677 Output: name,
678 Implicits: allInstalledFiles,
Colin Crossaabf6792017-11-29 00:27:14 -0800679 Default: !ctx.Config().EmbeddedInMake(),
Colin Cross9454bfa2015-03-17 13:24:18 -0700680 })
681 deps = append(deps, name)
Colin Cross1f8c52b2015-06-16 16:38:17 -0700682 a.installTarget = name
Colin Cross9454bfa2015-03-17 13:24:18 -0700683 }
684
685 if len(allCheckbuildFiles) > 0 {
Jeff Gaston088e29e2017-11-29 16:47:17 -0800686 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+"-checkbuild")
Colin Cross0875c522017-11-28 17:34:01 -0800687 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700688 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -0800689 Output: name,
690 Implicits: allCheckbuildFiles,
Colin Cross9454bfa2015-03-17 13:24:18 -0700691 })
692 deps = append(deps, name)
Colin Cross1f8c52b2015-06-16 16:38:17 -0700693 a.checkbuildTarget = name
Colin Cross9454bfa2015-03-17 13:24:18 -0700694 }
695
696 if len(deps) > 0 {
Dan Willemsen5ba07e82015-12-11 13:51:06 -0800697 suffix := ""
Colin Crossaabf6792017-11-29 00:27:14 -0800698 if ctx.Config().EmbeddedInMake() {
Dan Willemsen5ba07e82015-12-11 13:51:06 -0800699 suffix = "-soong"
700 }
701
Jeff Gaston088e29e2017-11-29 16:47:17 -0800702 name := PathForPhony(ctx, namespacePrefix+ctx.ModuleName()+suffix)
Colin Cross0875c522017-11-28 17:34:01 -0800703 ctx.Build(pctx, BuildParams{
Colin Cross9454bfa2015-03-17 13:24:18 -0700704 Rule: blueprint.Phony,
Jeff Gaston088e29e2017-11-29 16:47:17 -0800705 Outputs: []WritablePath{name},
Colin Cross9454bfa2015-03-17 13:24:18 -0700706 Implicits: deps,
Colin Cross3f40fa42015-01-30 17:27:36 -0800707 })
Colin Cross1f8c52b2015-06-16 16:38:17 -0700708
709 a.blueprintDir = ctx.ModuleDir()
Colin Cross3f40fa42015-01-30 17:27:36 -0800710 }
711}
712
Jiyong Park2db76922017-11-08 16:03:48 +0900713func determineModuleKind(a *ModuleBase, ctx blueprint.BaseModuleContext) moduleKind {
714 var socSpecific = Bool(a.commonProperties.Vendor) || Bool(a.commonProperties.Proprietary) || Bool(a.commonProperties.Soc_specific)
715 var deviceSpecific = Bool(a.commonProperties.Device_specific)
716 var productSpecific = Bool(a.commonProperties.Product_specific)
Dario Freni95cf7672018-08-17 00:57:57 +0100717 var productServicesSpecific = Bool(a.commonProperties.Product_services_specific)
Jiyong Park2db76922017-11-08 16:03:48 +0900718
Dario Frenifd05a742018-05-29 13:28:54 +0100719 msg := "conflicting value set here"
720 if socSpecific && deviceSpecific {
721 ctx.PropertyErrorf("device_specific", "a module cannot be specific to SoC and device at the same time.")
Jiyong Park2db76922017-11-08 16:03:48 +0900722 if Bool(a.commonProperties.Vendor) {
723 ctx.PropertyErrorf("vendor", msg)
724 }
725 if Bool(a.commonProperties.Proprietary) {
726 ctx.PropertyErrorf("proprietary", msg)
727 }
728 if Bool(a.commonProperties.Soc_specific) {
729 ctx.PropertyErrorf("soc_specific", msg)
730 }
731 }
732
Dario Frenifd05a742018-05-29 13:28:54 +0100733 if productSpecific && productServicesSpecific {
734 ctx.PropertyErrorf("product_specific", "a module cannot be specific to product and product_services at the same time.")
735 ctx.PropertyErrorf("product_services_specific", msg)
736 }
737
738 if (socSpecific || deviceSpecific) && (productSpecific || productServicesSpecific) {
739 if productSpecific {
740 ctx.PropertyErrorf("product_specific", "a module cannot be specific to SoC or device and product at the same time.")
741 } else {
742 ctx.PropertyErrorf("product_services_specific", "a module cannot be specific to SoC or device and product_services at the same time.")
743 }
744 if deviceSpecific {
745 ctx.PropertyErrorf("device_specific", msg)
746 } else {
747 if Bool(a.commonProperties.Vendor) {
748 ctx.PropertyErrorf("vendor", msg)
749 }
750 if Bool(a.commonProperties.Proprietary) {
751 ctx.PropertyErrorf("proprietary", msg)
752 }
753 if Bool(a.commonProperties.Soc_specific) {
754 ctx.PropertyErrorf("soc_specific", msg)
755 }
756 }
757 }
758
Jiyong Park2db76922017-11-08 16:03:48 +0900759 if productSpecific {
760 return productSpecificModule
Dario Frenifd05a742018-05-29 13:28:54 +0100761 } else if productServicesSpecific {
762 return productServicesSpecificModule
Jiyong Park2db76922017-11-08 16:03:48 +0900763 } else if deviceSpecific {
764 return deviceSpecificModule
765 } else if socSpecific {
766 return socSpecificModule
767 } else {
768 return platformModule
769 }
770}
771
Colin Cross635c3b02016-05-18 15:37:25 -0700772func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
Colin Cross6362e272015-10-29 15:25:03 -0700773 return androidBaseContextImpl{
Colin Cross8b74d172016-09-13 09:59:14 -0700774 target: a.commonProperties.CompileTarget,
775 targetPrimary: a.commonProperties.CompilePrimary,
Colin Crossee0bc3b2018-10-02 22:01:37 -0700776 multiTargets: a.commonProperties.CompileMultiTargets,
Jiyong Park2db76922017-11-08 16:03:48 +0900777 kind: determineModuleKind(a, ctx),
Colin Cross8b74d172016-09-13 09:59:14 -0700778 config: ctx.Config().(Config),
Colin Cross3f40fa42015-01-30 17:27:36 -0800779 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800780}
781
Colin Cross0875c522017-11-28 17:34:01 -0800782func (a *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
783 ctx := &androidModuleContext{
Colin Cross8d8f8e22016-08-03 11:57:50 -0700784 module: a.module,
Colin Cross0875c522017-11-28 17:34:01 -0800785 ModuleContext: blueprintCtx,
786 androidBaseContextImpl: a.androidBaseContextFactory(blueprintCtx),
787 installDeps: a.computeInstallDeps(blueprintCtx),
Colin Cross6362e272015-10-29 15:25:03 -0700788 installFiles: a.installFiles,
Colin Cross0875c522017-11-28 17:34:01 -0800789 missingDeps: blueprintCtx.GetMissingDependencies(),
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800790 variables: make(map[string]string),
Colin Cross3f40fa42015-01-30 17:27:36 -0800791 }
792
Colin Cross67a5c132017-05-09 13:45:28 -0700793 desc := "//" + ctx.ModuleDir() + ":" + ctx.ModuleName() + " "
794 var suffix []string
Colin Cross0875c522017-11-28 17:34:01 -0800795 if ctx.Os().Class != Device && ctx.Os().Class != Generic {
796 suffix = append(suffix, ctx.Os().String())
Colin Cross67a5c132017-05-09 13:45:28 -0700797 }
Colin Cross0875c522017-11-28 17:34:01 -0800798 if !ctx.PrimaryArch() {
799 suffix = append(suffix, ctx.Arch().ArchType.String())
Colin Cross67a5c132017-05-09 13:45:28 -0700800 }
801
802 ctx.Variable(pctx, "moduleDesc", desc)
803
804 s := ""
805 if len(suffix) > 0 {
806 s = " [" + strings.Join(suffix, " ") + "]"
807 }
808 ctx.Variable(pctx, "moduleDescSuffix", s)
809
Dan Willemsen569edc52018-11-19 09:33:29 -0800810 // Some common property checks for properties that will be used later in androidmk.go
811 if a.commonProperties.Dist.Dest != nil {
812 _, err := validateSafePath(*a.commonProperties.Dist.Dest)
813 if err != nil {
814 ctx.PropertyErrorf("dist.dest", "%s", err.Error())
815 }
816 }
817 if a.commonProperties.Dist.Dir != nil {
818 _, err := validateSafePath(*a.commonProperties.Dist.Dir)
819 if err != nil {
820 ctx.PropertyErrorf("dist.dir", "%s", err.Error())
821 }
822 }
823 if a.commonProperties.Dist.Suffix != nil {
824 if strings.Contains(*a.commonProperties.Dist.Suffix, "/") {
825 ctx.PropertyErrorf("dist.suffix", "Suffix may not contain a '/' character.")
826 }
827 }
828
Colin Cross9b1d13d2016-09-19 15:18:11 -0700829 if a.Enabled() {
Colin Cross0875c522017-11-28 17:34:01 -0800830 a.module.GenerateAndroidBuildActions(ctx)
Colin Cross9b1d13d2016-09-19 15:18:11 -0700831 if ctx.Failed() {
832 return
833 }
834
Colin Cross0875c522017-11-28 17:34:01 -0800835 a.installFiles = append(a.installFiles, ctx.installFiles...)
836 a.checkbuildFiles = append(a.checkbuildFiles, ctx.checkbuildFiles...)
Jaewoong Jung62707f72018-11-16 13:26:43 -0800837
838 if a.commonProperties.Notice != nil {
839 // For filegroup-based notice file references.
840 a.noticeFile = ctx.ExpandSource(*a.commonProperties.Notice, "notice")
841 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800842 }
843
Colin Cross9b1d13d2016-09-19 15:18:11 -0700844 if a == ctx.FinalModule().(Module).base() {
845 a.generateModuleTarget(ctx)
846 if ctx.Failed() {
847 return
848 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800849 }
Colin Crosscec81712017-07-13 14:43:27 -0700850
Colin Cross0875c522017-11-28 17:34:01 -0800851 a.buildParams = ctx.buildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800852 a.variables = ctx.variables
Colin Cross3f40fa42015-01-30 17:27:36 -0800853}
854
Colin Crossf6566ed2015-03-24 11:13:38 -0700855type androidBaseContextImpl struct {
Colin Cross8b74d172016-09-13 09:59:14 -0700856 target Target
Colin Crossee0bc3b2018-10-02 22:01:37 -0700857 multiTargets []Target
Colin Cross8b74d172016-09-13 09:59:14 -0700858 targetPrimary bool
859 debug bool
Jiyong Park2db76922017-11-08 16:03:48 +0900860 kind moduleKind
Colin Cross8b74d172016-09-13 09:59:14 -0700861 config Config
Colin Crossf6566ed2015-03-24 11:13:38 -0700862}
863
Colin Cross3f40fa42015-01-30 17:27:36 -0800864type androidModuleContext struct {
865 blueprint.ModuleContext
Colin Crossf6566ed2015-03-24 11:13:38 -0700866 androidBaseContextImpl
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700867 installDeps Paths
868 installFiles Paths
869 checkbuildFiles Paths
Colin Cross6ff51382015-12-17 16:39:19 -0800870 missingDeps []string
Colin Cross8d8f8e22016-08-03 11:57:50 -0700871 module Module
Colin Crosscec81712017-07-13 14:43:27 -0700872
873 // For tests
Colin Crossae887032017-10-23 17:16:14 -0700874 buildParams []BuildParams
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800875 variables map[string]string
Colin Cross6ff51382015-12-17 16:39:19 -0800876}
877
Colin Cross67a5c132017-05-09 13:45:28 -0700878func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
Colin Cross0875c522017-11-28 17:34:01 -0800879 a.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{
Colin Cross67a5c132017-05-09 13:45:28 -0700880 Rule: ErrorRule,
881 Description: desc,
882 Outputs: outputs,
883 Optional: true,
Colin Cross6ff51382015-12-17 16:39:19 -0800884 Args: map[string]string{
885 "error": err.Error(),
886 },
887 })
888 return
Colin Cross3f40fa42015-01-30 17:27:36 -0800889}
890
Colin Crossaabf6792017-11-29 00:27:14 -0800891func (a *androidModuleContext) Config() Config {
892 return a.ModuleContext.Config().(Config)
893}
894
Colin Cross0875c522017-11-28 17:34:01 -0800895func (a *androidModuleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
Colin Crossae887032017-10-23 17:16:14 -0700896 a.Build(pctx, BuildParams(params))
Colin Cross3f40fa42015-01-30 17:27:36 -0800897}
898
Colin Cross0875c522017-11-28 17:34:01 -0800899func convertBuildParams(params BuildParams) blueprint.BuildParams {
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700900 bparams := blueprint.BuildParams{
Dan Willemsen9f3c5742016-11-03 14:28:31 -0700901 Rule: params.Rule,
Colin Cross0875c522017-11-28 17:34:01 -0800902 Description: params.Description,
Colin Cross33bfb0a2016-11-21 17:23:08 -0800903 Deps: params.Deps,
Dan Willemsen9f3c5742016-11-03 14:28:31 -0700904 Outputs: params.Outputs.Strings(),
905 ImplicitOutputs: params.ImplicitOutputs.Strings(),
906 Inputs: params.Inputs.Strings(),
907 Implicits: params.Implicits.Strings(),
908 OrderOnly: params.OrderOnly.Strings(),
909 Args: params.Args,
910 Optional: !params.Default,
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700911 }
912
Colin Cross33bfb0a2016-11-21 17:23:08 -0800913 if params.Depfile != nil {
914 bparams.Depfile = params.Depfile.String()
915 }
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700916 if params.Output != nil {
917 bparams.Outputs = append(bparams.Outputs, params.Output.String())
918 }
Dan Willemsen9f3c5742016-11-03 14:28:31 -0700919 if params.ImplicitOutput != nil {
920 bparams.ImplicitOutputs = append(bparams.ImplicitOutputs, params.ImplicitOutput.String())
921 }
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700922 if params.Input != nil {
923 bparams.Inputs = append(bparams.Inputs, params.Input.String())
924 }
925 if params.Implicit != nil {
926 bparams.Implicits = append(bparams.Implicits, params.Implicit.String())
927 }
928
Colin Crossfe4bc362018-09-12 10:02:13 -0700929 bparams.Outputs = proptools.NinjaEscape(bparams.Outputs)
930 bparams.ImplicitOutputs = proptools.NinjaEscape(bparams.ImplicitOutputs)
931 bparams.Inputs = proptools.NinjaEscape(bparams.Inputs)
932 bparams.Implicits = proptools.NinjaEscape(bparams.Implicits)
933 bparams.OrderOnly = proptools.NinjaEscape(bparams.OrderOnly)
934 bparams.Depfile = proptools.NinjaEscape([]string{bparams.Depfile})[0]
935
Colin Cross0875c522017-11-28 17:34:01 -0800936 return bparams
937}
938
939func (a *androidModuleContext) Variable(pctx PackageContext, name, value string) {
Jaewoong Jung38e4fb22018-12-12 09:01:34 -0800940 if a.config.captureBuild {
941 a.variables[name] = value
942 }
943
Colin Cross0875c522017-11-28 17:34:01 -0800944 a.ModuleContext.Variable(pctx.PackageContext, name, value)
945}
946
947func (a *androidModuleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
948 argNames ...string) blueprint.Rule {
949
950 return a.ModuleContext.Rule(pctx.PackageContext, name, params, argNames...)
951}
952
953func (a *androidModuleContext) Build(pctx PackageContext, params BuildParams) {
954 if a.config.captureBuild {
955 a.buildParams = append(a.buildParams, params)
956 }
957
958 bparams := convertBuildParams(params)
959
960 if bparams.Description != "" {
961 bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
962 }
963
Colin Cross6ff51382015-12-17 16:39:19 -0800964 if a.missingDeps != nil {
Colin Cross67a5c132017-05-09 13:45:28 -0700965 a.ninjaError(bparams.Description, bparams.Outputs,
966 fmt.Errorf("module %s missing dependencies: %s\n",
967 a.ModuleName(), strings.Join(a.missingDeps, ", ")))
Colin Cross6ff51382015-12-17 16:39:19 -0800968 return
969 }
970
Colin Cross0875c522017-11-28 17:34:01 -0800971 a.ModuleContext.Build(pctx.PackageContext, bparams)
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700972}
973
Colin Cross6ff51382015-12-17 16:39:19 -0800974func (a *androidModuleContext) GetMissingDependencies() []string {
975 return a.missingDeps
976}
977
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800978func (a *androidModuleContext) AddMissingDependencies(deps []string) {
979 if deps != nil {
980 a.missingDeps = append(a.missingDeps, deps...)
Colin Crossd11fcda2017-10-23 17:59:01 -0700981 a.missingDeps = FirstUniqueStrings(a.missingDeps)
Dan Willemsen6553f5e2016-03-10 18:14:25 -0800982 }
983}
984
Colin Crossd11fcda2017-10-23 17:59:01 -0700985func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Module {
986 aModule, _ := module.(Module)
987 if aModule == nil {
988 a.ModuleErrorf("module %q not an android module", a.OtherModuleName(aModule))
989 return nil
990 }
991
992 if !aModule.Enabled() {
Colin Cross6510f912017-11-29 00:27:14 -0800993 if a.Config().AllowMissingDependencies() {
Colin Crossd11fcda2017-10-23 17:59:01 -0700994 a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
995 } else {
996 a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
997 }
998 return nil
999 }
1000
1001 return aModule
1002}
1003
Colin Cross35143d02017-11-16 00:11:20 -08001004func (a *androidModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
1005 a.ModuleContext.VisitDirectDeps(visit)
1006}
1007
Colin Crossd11fcda2017-10-23 17:59:01 -07001008func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
1009 a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
1010 if aModule := a.validateAndroidModule(module); aModule != nil {
1011 visit(aModule)
1012 }
1013 })
1014}
1015
Colin Crossee6143c2017-12-30 17:54:27 -08001016func (a *androidModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
1017 a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
1018 if aModule := a.validateAndroidModule(module); aModule != nil {
1019 if a.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
1020 visit(aModule)
1021 }
1022 }
1023 })
1024}
1025
Colin Crossd11fcda2017-10-23 17:59:01 -07001026func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
1027 a.ModuleContext.VisitDirectDepsIf(
1028 // pred
1029 func(module blueprint.Module) bool {
1030 if aModule := a.validateAndroidModule(module); aModule != nil {
1031 return pred(aModule)
1032 } else {
1033 return false
1034 }
1035 },
1036 // visit
1037 func(module blueprint.Module) {
1038 visit(module.(Module))
1039 })
1040}
1041
1042func (a *androidModuleContext) VisitDepsDepthFirst(visit func(Module)) {
1043 a.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
1044 if aModule := a.validateAndroidModule(module); aModule != nil {
1045 visit(aModule)
1046 }
1047 })
1048}
1049
1050func (a *androidModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
1051 a.ModuleContext.VisitDepsDepthFirstIf(
1052 // pred
1053 func(module blueprint.Module) bool {
1054 if aModule := a.validateAndroidModule(module); aModule != nil {
1055 return pred(aModule)
1056 } else {
1057 return false
1058 }
1059 },
1060 // visit
1061 func(module blueprint.Module) {
1062 visit(module.(Module))
1063 })
1064}
1065
1066func (a *androidModuleContext) WalkDeps(visit func(Module, Module) bool) {
1067 a.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
1068 childAndroidModule := a.validateAndroidModule(child)
1069 parentAndroidModule := a.validateAndroidModule(parent)
1070 if childAndroidModule != nil && parentAndroidModule != nil {
1071 return visit(childAndroidModule, parentAndroidModule)
1072 } else {
1073 return false
1074 }
1075 })
1076}
1077
Colin Cross0875c522017-11-28 17:34:01 -08001078func (a *androidModuleContext) VisitAllModuleVariants(visit func(Module)) {
1079 a.ModuleContext.VisitAllModuleVariants(func(module blueprint.Module) {
1080 visit(module.(Module))
1081 })
1082}
1083
1084func (a *androidModuleContext) PrimaryModule() Module {
1085 return a.ModuleContext.PrimaryModule().(Module)
1086}
1087
1088func (a *androidModuleContext) FinalModule() Module {
1089 return a.ModuleContext.FinalModule().(Module)
1090}
1091
Colin Crossa1ad8d12016-06-01 17:09:44 -07001092func (a *androidBaseContextImpl) Target() Target {
1093 return a.target
1094}
1095
Colin Cross8b74d172016-09-13 09:59:14 -07001096func (a *androidBaseContextImpl) TargetPrimary() bool {
1097 return a.targetPrimary
1098}
1099
Colin Crossee0bc3b2018-10-02 22:01:37 -07001100func (a *androidBaseContextImpl) MultiTargets() []Target {
1101 return a.multiTargets
1102}
1103
Colin Crossf6566ed2015-03-24 11:13:38 -07001104func (a *androidBaseContextImpl) Arch() Arch {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001105 return a.target.Arch
Colin Cross3f40fa42015-01-30 17:27:36 -08001106}
1107
Colin Crossa1ad8d12016-06-01 17:09:44 -07001108func (a *androidBaseContextImpl) Os() OsType {
1109 return a.target.Os
Dan Willemsen490fd492015-11-24 17:53:15 -08001110}
1111
Colin Crossf6566ed2015-03-24 11:13:38 -07001112func (a *androidBaseContextImpl) Host() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001113 return a.target.Os.Class == Host || a.target.Os.Class == HostCross
Colin Crossf6566ed2015-03-24 11:13:38 -07001114}
1115
1116func (a *androidBaseContextImpl) Device() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001117 return a.target.Os.Class == Device
Colin Crossf6566ed2015-03-24 11:13:38 -07001118}
1119
Colin Cross0af4b842015-04-30 16:36:18 -07001120func (a *androidBaseContextImpl) Darwin() bool {
Colin Crossa1ad8d12016-06-01 17:09:44 -07001121 return a.target.Os == Darwin
Colin Cross0af4b842015-04-30 16:36:18 -07001122}
1123
Colin Cross3edeee12017-04-04 12:59:48 -07001124func (a *androidBaseContextImpl) Windows() bool {
1125 return a.target.Os == Windows
1126}
1127
Colin Crossf6566ed2015-03-24 11:13:38 -07001128func (a *androidBaseContextImpl) Debug() bool {
1129 return a.debug
1130}
1131
Colin Cross1e7d3702016-08-24 15:25:47 -07001132func (a *androidBaseContextImpl) PrimaryArch() bool {
Dan Willemsen0ef639b2018-10-10 17:02:29 -07001133 if len(a.config.Targets[a.target.Os]) <= 1 {
Colin Cross67a5c132017-05-09 13:45:28 -07001134 return true
1135 }
Dan Willemsen0ef639b2018-10-10 17:02:29 -07001136 return a.target.Arch.ArchType == a.config.Targets[a.target.Os][0].Arch.ArchType
Colin Cross1e7d3702016-08-24 15:25:47 -07001137}
1138
Colin Cross1332b002015-04-07 17:11:30 -07001139func (a *androidBaseContextImpl) AConfig() Config {
1140 return a.config
1141}
1142
Colin Cross9272ade2016-08-17 15:24:12 -07001143func (a *androidBaseContextImpl) DeviceConfig() DeviceConfig {
1144 return DeviceConfig{a.config.deviceConfig}
1145}
1146
Jiyong Park2db76922017-11-08 16:03:48 +09001147func (a *androidBaseContextImpl) Platform() bool {
1148 return a.kind == platformModule
1149}
1150
1151func (a *androidBaseContextImpl) DeviceSpecific() bool {
1152 return a.kind == deviceSpecificModule
1153}
1154
1155func (a *androidBaseContextImpl) SocSpecific() bool {
1156 return a.kind == socSpecificModule
1157}
1158
1159func (a *androidBaseContextImpl) ProductSpecific() bool {
1160 return a.kind == productSpecificModule
Dan Willemsen782a2d12015-12-21 14:55:28 -08001161}
1162
Dario Frenifd05a742018-05-29 13:28:54 +01001163func (a *androidBaseContextImpl) ProductServicesSpecific() bool {
1164 return a.kind == productServicesSpecificModule
1165}
1166
Jiyong Park5baac542018-08-28 09:55:37 +09001167// Makes this module a platform module, i.e. not specific to soc, device,
1168// product, or product_services.
1169func (a *ModuleBase) MakeAsPlatform() {
1170 a.commonProperties.Vendor = boolPtr(false)
1171 a.commonProperties.Proprietary = boolPtr(false)
1172 a.commonProperties.Soc_specific = boolPtr(false)
1173 a.commonProperties.Product_specific = boolPtr(false)
1174 a.commonProperties.Product_services_specific = boolPtr(false)
1175}
1176
Colin Cross8d8f8e22016-08-03 11:57:50 -07001177func (a *androidModuleContext) InstallInData() bool {
1178 return a.module.InstallInData()
Dan Willemsen782a2d12015-12-21 14:55:28 -08001179}
1180
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001181func (a *androidModuleContext) InstallInSanitizerDir() bool {
1182 return a.module.InstallInSanitizerDir()
1183}
1184
Jiyong Parkf9332f12018-02-01 00:54:12 +09001185func (a *androidModuleContext) InstallInRecovery() bool {
1186 return a.module.InstallInRecovery()
1187}
1188
Colin Cross893d8162017-04-26 17:34:03 -07001189func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
1190 if a.module.base().commonProperties.SkipInstall {
1191 return true
1192 }
1193
Colin Cross3607f212018-05-07 15:28:05 -07001194 // We'll need a solution for choosing which of modules with the same name in different
1195 // namespaces to install. For now, reuse the list of namespaces exported to Make as the
1196 // list of namespaces to install in a Soong-only build.
1197 if !a.module.base().commonProperties.NamespaceExportedToMake {
1198 return true
1199 }
1200
Colin Cross893d8162017-04-26 17:34:03 -07001201 if a.Device() {
Colin Cross6510f912017-11-29 00:27:14 -08001202 if a.Config().SkipDeviceInstall() {
Colin Cross893d8162017-04-26 17:34:03 -07001203 return true
1204 }
1205
Colin Cross6510f912017-11-29 00:27:14 -08001206 if a.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
Colin Cross893d8162017-04-26 17:34:03 -07001207 return true
1208 }
1209 }
1210
1211 return false
1212}
1213
Colin Cross5c517922017-08-31 12:29:17 -07001214func (a *androidModuleContext) InstallFile(installPath OutputPath, name string, srcPath Path,
Colin Crossa2344662016-03-24 13:14:12 -07001215 deps ...Path) OutputPath {
Colin Cross5c517922017-08-31 12:29:17 -07001216 return a.installFile(installPath, name, srcPath, Cp, deps)
1217}
1218
1219func (a *androidModuleContext) InstallExecutable(installPath OutputPath, name string, srcPath Path,
1220 deps ...Path) OutputPath {
1221 return a.installFile(installPath, name, srcPath, CpExecutable, deps)
1222}
1223
1224func (a *androidModuleContext) installFile(installPath OutputPath, name string, srcPath Path,
1225 rule blueprint.Rule, deps []Path) OutputPath {
Colin Cross35cec122015-04-02 14:37:16 -07001226
Dan Willemsen782a2d12015-12-21 14:55:28 -08001227 fullInstallPath := installPath.Join(a, name)
Colin Cross178a5092016-09-13 13:42:32 -07001228 a.module.base().hooks.runInstallHooks(a, fullInstallPath, false)
Colin Cross3f40fa42015-01-30 17:27:36 -08001229
Colin Cross893d8162017-04-26 17:34:03 -07001230 if !a.skipInstall(fullInstallPath) {
Colin Crossce75d2c2016-10-06 16:12:58 -07001231
Dan Willemsen322acaf2016-01-12 23:07:05 -08001232 deps = append(deps, a.installDeps...)
Colin Cross35cec122015-04-02 14:37:16 -07001233
Colin Cross89562dc2016-10-03 17:47:19 -07001234 var implicitDeps, orderOnlyDeps Paths
1235
1236 if a.Host() {
1237 // Installed host modules might be used during the build, depend directly on their
1238 // dependencies so their timestamp is updated whenever their dependency is updated
1239 implicitDeps = deps
1240 } else {
1241 orderOnlyDeps = deps
1242 }
1243
Colin Crossae887032017-10-23 17:16:14 -07001244 a.Build(pctx, BuildParams{
Colin Cross5c517922017-08-31 12:29:17 -07001245 Rule: rule,
Colin Cross67a5c132017-05-09 13:45:28 -07001246 Description: "install " + fullInstallPath.Base(),
1247 Output: fullInstallPath,
1248 Input: srcPath,
1249 Implicits: implicitDeps,
1250 OrderOnly: orderOnlyDeps,
Colin Cross6510f912017-11-29 00:27:14 -08001251 Default: !a.Config().EmbeddedInMake(),
Dan Willemsen322acaf2016-01-12 23:07:05 -08001252 })
Colin Cross3f40fa42015-01-30 17:27:36 -08001253
Dan Willemsen322acaf2016-01-12 23:07:05 -08001254 a.installFiles = append(a.installFiles, fullInstallPath)
1255 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001256 a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
Colin Cross35cec122015-04-02 14:37:16 -07001257 return fullInstallPath
1258}
1259
Colin Cross3854a602016-01-11 12:49:11 -08001260func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name string, srcPath OutputPath) OutputPath {
1261 fullInstallPath := installPath.Join(a, name)
Colin Cross178a5092016-09-13 13:42:32 -07001262 a.module.base().hooks.runInstallHooks(a, fullInstallPath, true)
Colin Cross3854a602016-01-11 12:49:11 -08001263
Colin Cross893d8162017-04-26 17:34:03 -07001264 if !a.skipInstall(fullInstallPath) {
Colin Crossce75d2c2016-10-06 16:12:58 -07001265
Colin Crossae887032017-10-23 17:16:14 -07001266 a.Build(pctx, BuildParams{
Colin Cross67a5c132017-05-09 13:45:28 -07001267 Rule: Symlink,
1268 Description: "install symlink " + fullInstallPath.Base(),
1269 Output: fullInstallPath,
1270 OrderOnly: Paths{srcPath},
Colin Cross6510f912017-11-29 00:27:14 -08001271 Default: !a.Config().EmbeddedInMake(),
Colin Cross12fc4972016-01-11 12:49:11 -08001272 Args: map[string]string{
1273 "fromPath": srcPath.String(),
1274 },
1275 })
Colin Cross3854a602016-01-11 12:49:11 -08001276
Colin Cross12fc4972016-01-11 12:49:11 -08001277 a.installFiles = append(a.installFiles, fullInstallPath)
1278 a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
1279 }
Colin Cross3854a602016-01-11 12:49:11 -08001280 return fullInstallPath
1281}
1282
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001283func (a *androidModuleContext) CheckbuildFile(srcPath Path) {
Colin Cross3f40fa42015-01-30 17:27:36 -08001284 a.checkbuildFiles = append(a.checkbuildFiles, srcPath)
1285}
1286
Colin Cross3f40fa42015-01-30 17:27:36 -08001287type fileInstaller interface {
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001288 filesToInstall() Paths
Colin Cross3f40fa42015-01-30 17:27:36 -08001289}
1290
1291func isFileInstaller(m blueprint.Module) bool {
1292 _, ok := m.(fileInstaller)
1293 return ok
1294}
1295
1296func isAndroidModule(m blueprint.Module) bool {
Colin Cross635c3b02016-05-18 15:37:25 -07001297 _, ok := m.(Module)
Colin Cross3f40fa42015-01-30 17:27:36 -08001298 return ok
1299}
Colin Crossfce53272015-04-08 11:21:40 -07001300
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001301func findStringInSlice(str string, slice []string) int {
1302 for i, s := range slice {
1303 if s == str {
1304 return i
Colin Crossfce53272015-04-08 11:21:40 -07001305 }
1306 }
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001307 return -1
1308}
1309
Colin Cross068e0fe2016-12-13 15:23:47 -08001310func SrcIsModule(s string) string {
1311 if len(s) > 1 && s[0] == ':' {
1312 return s[1:]
1313 }
1314 return ""
1315}
1316
1317type sourceDependencyTag struct {
1318 blueprint.BaseDependencyTag
1319}
1320
1321var SourceDepTag sourceDependencyTag
1322
Colin Cross366938f2017-12-11 16:29:02 -08001323// Adds necessary dependencies to satisfy filegroup or generated sources modules listed in srcFiles
1324// using ":module" syntax, if any.
Colin Cross068e0fe2016-12-13 15:23:47 -08001325func ExtractSourcesDeps(ctx BottomUpMutatorContext, srcFiles []string) {
1326 var deps []string
Nan Zhang2439eb72017-04-10 11:27:50 -07001327 set := make(map[string]bool)
1328
Colin Cross068e0fe2016-12-13 15:23:47 -08001329 for _, s := range srcFiles {
1330 if m := SrcIsModule(s); m != "" {
Nan Zhang2439eb72017-04-10 11:27:50 -07001331 if _, found := set[m]; found {
1332 ctx.ModuleErrorf("found source dependency duplicate: %q!", m)
1333 } else {
1334 set[m] = true
1335 deps = append(deps, m)
1336 }
Colin Cross068e0fe2016-12-13 15:23:47 -08001337 }
1338 }
1339
1340 ctx.AddDependency(ctx.Module(), SourceDepTag, deps...)
1341}
1342
Colin Cross366938f2017-12-11 16:29:02 -08001343// Adds necessary dependencies to satisfy filegroup or generated sources modules specified in s
1344// using ":module" syntax, if any.
1345func ExtractSourceDeps(ctx BottomUpMutatorContext, s *string) {
1346 if s != nil {
1347 if m := SrcIsModule(*s); m != "" {
1348 ctx.AddDependency(ctx.Module(), SourceDepTag, m)
1349 }
1350 }
1351}
1352
Colin Cross068e0fe2016-12-13 15:23:47 -08001353type SourceFileProducer interface {
1354 Srcs() Paths
1355}
1356
1357// Returns a list of paths expanded from globs and modules referenced using ":module" syntax.
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001358// ExtractSourcesDeps must have already been called during the dependency resolution phase.
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001359func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) Paths {
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001360 return ctx.ExpandSourcesSubDir(srcFiles, excludes, "")
1361}
1362
Colin Cross366938f2017-12-11 16:29:02 -08001363// Returns a single path expanded from globs and modules referenced using ":module" syntax.
1364// ExtractSourceDeps must have already been called during the dependency resolution phase.
1365func (ctx *androidModuleContext) ExpandSource(srcFile, prop string) Path {
1366 srcFiles := ctx.ExpandSourcesSubDir([]string{srcFile}, nil, "")
1367 if len(srcFiles) == 1 {
1368 return srcFiles[0]
Jaewoong Jung62707f72018-11-16 13:26:43 -08001369 } else if len(srcFiles) == 0 {
1370 if ctx.Config().AllowMissingDependencies() {
1371 ctx.AddMissingDependencies([]string{srcFile})
1372 } else {
1373 ctx.PropertyErrorf(prop, "%s path %s does not exist", prop, srcFile)
1374 }
1375 return nil
Colin Cross366938f2017-12-11 16:29:02 -08001376 } else {
1377 ctx.PropertyErrorf(prop, "module providing %s must produce exactly one file", prop)
1378 return nil
1379 }
1380}
1381
Colin Cross2383f3b2018-02-06 14:40:13 -08001382// Returns an optional single path expanded from globs and modules referenced using ":module" syntax if
1383// the srcFile is non-nil.
1384// ExtractSourceDeps must have already been called during the dependency resolution phase.
1385func (ctx *androidModuleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath {
1386 if srcFile != nil {
1387 return OptionalPathForPath(ctx.ExpandSource(*srcFile, prop))
1388 }
1389 return OptionalPath{}
1390}
1391
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001392func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string, subDir string) Paths {
Dan Willemsen34cc69e2015-09-23 15:26:20 -07001393 prefix := PathForModuleSrc(ctx).String()
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001394
Colin Cross461b4452018-02-23 09:22:42 -08001395 var expandedExcludes []string
1396 if excludes != nil {
1397 expandedExcludes = make([]string, 0, len(excludes))
1398 }
Nan Zhang27e284d2018-02-09 21:03:53 +00001399
1400 for _, e := range excludes {
1401 if m := SrcIsModule(e); m != "" {
1402 module := ctx.GetDirectDepWithTag(m, SourceDepTag)
1403 if module == nil {
1404 // Error will have been handled by ExtractSourcesDeps
1405 continue
1406 }
1407 if srcProducer, ok := module.(SourceFileProducer); ok {
1408 expandedExcludes = append(expandedExcludes, srcProducer.Srcs().Strings()...)
1409 } else {
1410 ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
1411 }
1412 } else {
1413 expandedExcludes = append(expandedExcludes, filepath.Join(prefix, e))
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001414 }
Dan Willemsen2ef08f42015-06-30 18:15:24 -07001415 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001416 expandedSrcFiles := make(Paths, 0, len(srcFiles))
Colin Cross8f101b42015-06-17 15:09:06 -07001417 for _, s := range srcFiles {
Colin Cross068e0fe2016-12-13 15:23:47 -08001418 if m := SrcIsModule(s); m != "" {
1419 module := ctx.GetDirectDepWithTag(m, SourceDepTag)
Colin Cross0617bb82017-10-24 13:01:18 -07001420 if module == nil {
1421 // Error will have been handled by ExtractSourcesDeps
1422 continue
1423 }
Colin Cross068e0fe2016-12-13 15:23:47 -08001424 if srcProducer, ok := module.(SourceFileProducer); ok {
Nan Zhang27e284d2018-02-09 21:03:53 +00001425 moduleSrcs := srcProducer.Srcs()
1426 for _, e := range expandedExcludes {
1427 for j, ms := range moduleSrcs {
1428 if ms.String() == e {
1429 moduleSrcs = append(moduleSrcs[:j], moduleSrcs[j+1:]...)
1430 }
1431 }
1432 }
1433 expandedSrcFiles = append(expandedSrcFiles, moduleSrcs...)
Colin Cross068e0fe2016-12-13 15:23:47 -08001434 } else {
1435 ctx.ModuleErrorf("srcs dependency %q is not a source file producing module", m)
1436 }
1437 } else if pathtools.IsGlob(s) {
Dan Willemsen540a78c2018-02-26 21:50:08 -08001438 globbedSrcFiles := ctx.GlobFiles(filepath.Join(prefix, s), expandedExcludes)
Colin Cross05a39cb2017-10-09 13:35:19 -07001439 for i, s := range globbedSrcFiles {
1440 globbedSrcFiles[i] = s.(ModuleSrcPath).WithSubDir(ctx, subDir)
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001441 }
Colin Cross05a39cb2017-10-09 13:35:19 -07001442 expandedSrcFiles = append(expandedSrcFiles, globbedSrcFiles...)
Colin Cross8f101b42015-06-17 15:09:06 -07001443 } else {
Nan Zhang27e284d2018-02-09 21:03:53 +00001444 p := PathForModuleSrc(ctx, s).WithSubDir(ctx, subDir)
1445 j := findStringInSlice(p.String(), expandedExcludes)
1446 if j == -1 {
1447 expandedSrcFiles = append(expandedSrcFiles, p)
1448 }
1449
Colin Cross8f101b42015-06-17 15:09:06 -07001450 }
1451 }
Colin Crossfaeb7aa2017-02-01 14:12:44 -08001452 return expandedSrcFiles
Colin Cross8f101b42015-06-17 15:09:06 -07001453}
1454
Nan Zhang6d34b302017-02-04 17:47:46 -08001455func (ctx *androidModuleContext) RequiredModuleNames() []string {
1456 return ctx.module.base().commonProperties.Required
1457}
1458
Colin Cross7f19f372016-11-01 11:10:25 -07001459func (ctx *androidModuleContext) Glob(globPattern string, excludes []string) Paths {
1460 ret, err := ctx.GlobWithDeps(globPattern, excludes)
Colin Cross8f101b42015-06-17 15:09:06 -07001461 if err != nil {
1462 ctx.ModuleErrorf("glob: %s", err.Error())
1463 }
Dan Willemsen540a78c2018-02-26 21:50:08 -08001464 return pathsForModuleSrcFromFullPath(ctx, ret, true)
Colin Crossfce53272015-04-08 11:21:40 -07001465}
Colin Cross1f8c52b2015-06-16 16:38:17 -07001466
Nan Zhang581fd212018-01-10 16:06:12 -08001467func (ctx *androidModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
Dan Willemsen540a78c2018-02-26 21:50:08 -08001468 ret, err := ctx.GlobWithDeps(globPattern, excludes)
Nan Zhang581fd212018-01-10 16:06:12 -08001469 if err != nil {
1470 ctx.ModuleErrorf("glob: %s", err.Error())
1471 }
Dan Willemsen540a78c2018-02-26 21:50:08 -08001472 return pathsForModuleSrcFromFullPath(ctx, ret, false)
Nan Zhang581fd212018-01-10 16:06:12 -08001473}
1474
Colin Cross463a90e2015-06-17 14:20:06 -07001475func init() {
Colin Cross798bfce2016-10-12 14:28:16 -07001476 RegisterSingletonType("buildtarget", BuildTargetSingleton)
Colin Cross463a90e2015-06-17 14:20:06 -07001477}
1478
Colin Cross0875c522017-11-28 17:34:01 -08001479func BuildTargetSingleton() Singleton {
Colin Cross1f8c52b2015-06-16 16:38:17 -07001480 return &buildTargetSingleton{}
1481}
1482
Colin Cross87d8b562017-04-25 10:01:55 -07001483func parentDir(dir string) string {
1484 dir, _ = filepath.Split(dir)
1485 return filepath.Clean(dir)
1486}
1487
Colin Cross1f8c52b2015-06-16 16:38:17 -07001488type buildTargetSingleton struct{}
1489
Colin Cross0875c522017-11-28 17:34:01 -08001490func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
1491 var checkbuildDeps Paths
Colin Cross1f8c52b2015-06-16 16:38:17 -07001492
Colin Cross0875c522017-11-28 17:34:01 -08001493 mmTarget := func(dir string) WritablePath {
1494 return PathForPhony(ctx,
1495 "MODULES-IN-"+strings.Replace(filepath.Clean(dir), "/", "-", -1))
Colin Cross87d8b562017-04-25 10:01:55 -07001496 }
1497
Colin Cross0875c522017-11-28 17:34:01 -08001498 modulesInDir := make(map[string]Paths)
Colin Cross1f8c52b2015-06-16 16:38:17 -07001499
Colin Cross0875c522017-11-28 17:34:01 -08001500 ctx.VisitAllModules(func(module Module) {
1501 blueprintDir := module.base().blueprintDir
1502 installTarget := module.base().installTarget
1503 checkbuildTarget := module.base().checkbuildTarget
Colin Cross1f8c52b2015-06-16 16:38:17 -07001504
Colin Cross0875c522017-11-28 17:34:01 -08001505 if checkbuildTarget != nil {
1506 checkbuildDeps = append(checkbuildDeps, checkbuildTarget)
1507 modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], checkbuildTarget)
1508 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001509
Colin Cross0875c522017-11-28 17:34:01 -08001510 if installTarget != nil {
1511 modulesInDir[blueprintDir] = append(modulesInDir[blueprintDir], installTarget)
Colin Cross1f8c52b2015-06-16 16:38:17 -07001512 }
1513 })
1514
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001515 suffix := ""
Colin Crossaabf6792017-11-29 00:27:14 -08001516 if ctx.Config().EmbeddedInMake() {
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001517 suffix = "-soong"
1518 }
1519
Colin Cross1f8c52b2015-06-16 16:38:17 -07001520 // Create a top-level checkbuild target that depends on all modules
Colin Cross0875c522017-11-28 17:34:01 -08001521 ctx.Build(pctx, BuildParams{
Colin Cross1f8c52b2015-06-16 16:38:17 -07001522 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001523 Output: PathForPhony(ctx, "checkbuild"+suffix),
Colin Cross1f8c52b2015-06-16 16:38:17 -07001524 Implicits: checkbuildDeps,
Colin Cross1f8c52b2015-06-16 16:38:17 -07001525 })
1526
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001527 // Make will generate the MODULES-IN-* targets
Colin Crossaabf6792017-11-29 00:27:14 -08001528 if ctx.Config().EmbeddedInMake() {
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001529 return
1530 }
1531
Colin Cross0875c522017-11-28 17:34:01 -08001532 sortedKeys := func(m map[string]Paths) []string {
1533 s := make([]string, 0, len(m))
1534 for k := range m {
1535 s = append(s, k)
1536 }
1537 sort.Strings(s)
1538 return s
1539 }
1540
Colin Cross87d8b562017-04-25 10:01:55 -07001541 // Ensure ancestor directories are in modulesInDir
1542 dirs := sortedKeys(modulesInDir)
1543 for _, dir := range dirs {
1544 dir := parentDir(dir)
1545 for dir != "." && dir != "/" {
1546 if _, exists := modulesInDir[dir]; exists {
1547 break
1548 }
1549 modulesInDir[dir] = nil
1550 dir = parentDir(dir)
1551 }
1552 }
1553
1554 // Make directories build their direct subdirectories
1555 dirs = sortedKeys(modulesInDir)
1556 for _, dir := range dirs {
1557 p := parentDir(dir)
1558 if p != "." && p != "/" {
1559 modulesInDir[p] = append(modulesInDir[p], mmTarget(dir))
1560 }
1561 }
1562
Dan Willemsend2e95fb2017-09-20 14:30:50 -07001563 // Create a MODULES-IN-<directory> target that depends on all modules in a directory, and
1564 // depends on the MODULES-IN-* targets of all of its subdirectories that contain Android.bp
1565 // files.
Colin Cross1f8c52b2015-06-16 16:38:17 -07001566 for _, dir := range dirs {
Colin Cross0875c522017-11-28 17:34:01 -08001567 ctx.Build(pctx, BuildParams{
Colin Cross1f8c52b2015-06-16 16:38:17 -07001568 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001569 Output: mmTarget(dir),
Colin Cross87d8b562017-04-25 10:01:55 -07001570 Implicits: modulesInDir[dir],
Dan Willemsen5ba07e82015-12-11 13:51:06 -08001571 // HACK: checkbuild should be an optional build, but force it
1572 // enabled for now in standalone builds
Colin Crossaabf6792017-11-29 00:27:14 -08001573 Default: !ctx.Config().EmbeddedInMake(),
Colin Cross1f8c52b2015-06-16 16:38:17 -07001574 })
1575 }
Dan Willemsen61d88b82017-09-20 17:29:08 -07001576
1577 // Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
1578 osDeps := map[OsType]Paths{}
Colin Cross0875c522017-11-28 17:34:01 -08001579 ctx.VisitAllModules(func(module Module) {
1580 if module.Enabled() {
1581 os := module.Target().Os
1582 osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001583 }
1584 })
1585
Colin Cross0875c522017-11-28 17:34:01 -08001586 osClass := make(map[string]Paths)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001587 for os, deps := range osDeps {
1588 var className string
1589
1590 switch os.Class {
1591 case Host:
1592 className = "host"
1593 case HostCross:
1594 className = "host-cross"
1595 case Device:
1596 className = "target"
1597 default:
1598 continue
1599 }
1600
Colin Cross0875c522017-11-28 17:34:01 -08001601 name := PathForPhony(ctx, className+"-"+os.Name)
Dan Willemsen61d88b82017-09-20 17:29:08 -07001602 osClass[className] = append(osClass[className], name)
1603
Colin Cross0875c522017-11-28 17:34:01 -08001604 ctx.Build(pctx, BuildParams{
Dan Willemsen61d88b82017-09-20 17:29:08 -07001605 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001606 Output: name,
1607 Implicits: deps,
Dan Willemsen61d88b82017-09-20 17:29:08 -07001608 })
1609 }
1610
1611 // Wrap those into host|host-cross|target phony rules
1612 osClasses := sortedKeys(osClass)
1613 for _, class := range osClasses {
Colin Cross0875c522017-11-28 17:34:01 -08001614 ctx.Build(pctx, BuildParams{
Dan Willemsen61d88b82017-09-20 17:29:08 -07001615 Rule: blueprint.Phony,
Colin Cross0875c522017-11-28 17:34:01 -08001616 Output: PathForPhony(ctx, class),
Dan Willemsen61d88b82017-09-20 17:29:08 -07001617 Implicits: osClass[class],
Dan Willemsen61d88b82017-09-20 17:29:08 -07001618 })
1619 }
Colin Cross1f8c52b2015-06-16 16:38:17 -07001620}
Colin Crossd779da42015-12-17 18:00:23 -08001621
Colin Cross2465c3d2018-09-28 10:19:18 -07001622type ModulesByName struct {
1623 slice []blueprint.Module
Colin Crossd779da42015-12-17 18:00:23 -08001624 ctx interface {
1625 ModuleName(blueprint.Module) string
1626 ModuleSubDir(blueprint.Module) string
1627 }
1628}
1629
Colin Cross2465c3d2018-09-28 10:19:18 -07001630func (s ModulesByName) Len() int { return len(s.slice) }
1631func (s ModulesByName) Less(i, j int) bool {
Colin Crossd779da42015-12-17 18:00:23 -08001632 mi, mj := s.slice[i], s.slice[j]
1633 ni, nj := s.ctx.ModuleName(mi), s.ctx.ModuleName(mj)
1634
1635 if ni != nj {
1636 return ni < nj
1637 } else {
1638 return s.ctx.ModuleSubDir(mi) < s.ctx.ModuleSubDir(mj)
1639 }
1640}
Colin Cross2465c3d2018-09-28 10:19:18 -07001641func (s ModulesByName) Swap(i, j int) { s.slice[i], s.slice[j] = s.slice[j], s.slice[i] }
Brandon Lee5d45c6f2018-08-15 15:35:38 -07001642
1643// Collect information for opening IDE project files in java/jdeps.go.
1644type IDEInfo interface {
1645 IDEInfo(ideInfo *IdeInfo)
1646 BaseModuleName() string
1647}
1648
1649// Extract the base module name from the Import name.
1650// Often the Import name has a prefix "prebuilt_".
1651// Remove the prefix explicitly if needed
1652// until we find a better solution to get the Import name.
1653type IDECustomizedModuleName interface {
1654 IDECustomizedModuleName() string
1655}
1656
1657type IdeInfo struct {
1658 Deps []string `json:"dependencies,omitempty"`
1659 Srcs []string `json:"srcs,omitempty"`
1660 Aidl_include_dirs []string `json:"aidl_include_dirs,omitempty"`
1661 Jarjar_rules []string `json:"jarjar_rules,omitempty"`
1662 Jars []string `json:"jars,omitempty"`
1663 Classes []string `json:"class,omitempty"`
1664 Installed_paths []string `json:"installed,omitempty"`
1665}