blob: 715919fc05371406651f67134c05f5e9f8af9c40 [file] [log] [blame]
Colin Cross5049f022015-03-18 13:28:46 -07001// Copyright 2015 Google Inc. All rights reserved.
Colin Cross3f40fa42015-01-30 17:27:36 -08002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17// This file contains the module types for compiling C/C++ for Android, and converts the properties
18// into the flags and filenames necessary to pass to the compiler. The final creation of the rules
19// is handled in builder.go
20
21import (
Dan Albert9e10cd42016-08-03 14:12:14 -070022 "strconv"
Colin Cross3f40fa42015-01-30 17:27:36 -080023 "strings"
24
Colin Cross97ba0732015-03-23 17:50:24 -070025 "github.com/google/blueprint"
Colin Cross06a931b2015-10-28 17:23:31 -070026 "github.com/google/blueprint/proptools"
Colin Cross97ba0732015-03-23 17:50:24 -070027
Colin Cross635c3b02016-05-18 15:37:25 -070028 "android/soong/android"
Colin Crossb98c8b02016-07-29 13:44:28 -070029 "android/soong/cc/config"
Colin Cross5049f022015-03-18 13:28:46 -070030 "android/soong/genrule"
Colin Cross3f40fa42015-01-30 17:27:36 -080031)
32
Colin Cross463a90e2015-06-17 14:20:06 -070033func init() {
Colin Cross798bfce2016-10-12 14:28:16 -070034 android.RegisterModuleType("cc_defaults", defaultsFactory)
Colin Cross463a90e2015-06-17 14:20:06 -070035
Colin Cross1e676be2016-10-12 14:38:15 -070036 android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
Jiyong Park6a43f042017-10-12 23:05:00 +090037 ctx.BottomUp("image", vendorMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070038 ctx.BottomUp("link", linkageMutator).Parallel()
Jiyong Parkd5b18a52017-08-03 21:22:50 +090039 ctx.BottomUp("vndk", vndkMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070040 ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
41 ctx.BottomUp("test_per_src", testPerSrcMutator).Parallel()
42 ctx.BottomUp("begin", beginMutator).Parallel()
43 })
Colin Cross16b23492016-01-06 14:41:07 -080044
Colin Cross1e676be2016-10-12 14:38:15 -070045 android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
46 ctx.TopDown("asan_deps", sanitizerDepsMutator(asan))
47 ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel()
Colin Cross16b23492016-01-06 14:41:07 -080048
Vishwath Mohanb743e9c2017-11-01 09:20:21 +000049 ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
50 ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()
51
Colin Cross1e676be2016-10-12 14:38:15 -070052 ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
53 ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()
Dan Willemsen581341d2017-02-09 16:16:31 -080054
55 ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -080056 ctx.TopDown("vndk_deps", sabiDepsMutator)
Stephen Craneba090d12017-05-09 15:44:35 -070057
58 ctx.TopDown("lto_deps", ltoDepsMutator)
59 ctx.BottomUp("lto", ltoMutator).Parallel()
Colin Cross1e676be2016-10-12 14:38:15 -070060 })
Colin Crossb98c8b02016-07-29 13:44:28 -070061
62 pctx.Import("android/soong/cc/config")
Colin Cross463a90e2015-06-17 14:20:06 -070063}
64
Colin Crossca860ac2016-01-04 14:34:37 -080065type Deps struct {
66 SharedLibs, LateSharedLibs []string
67 StaticLibs, LateStaticLibs, WholeStaticLibs []string
Colin Cross5950f382016-12-13 12:50:57 -080068 HeaderLibs []string
Colin Crossc472d572015-03-17 15:06:21 -070069
Colin Cross5950f382016-12-13 12:50:57 -080070 ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
Dan Willemsen490a8dc2016-06-06 18:22:19 -070071
Colin Cross81413472016-04-11 14:37:39 -070072 ObjFiles []string
Dan Willemsen34cc69e2015-09-23 15:26:20 -070073
Dan Willemsenb40aab62016-04-20 14:21:14 -070074 GeneratedSources []string
75 GeneratedHeaders []string
76
Dan Willemsenb3454ab2016-09-28 17:34:58 -070077 ReexportGeneratedHeaders []string
78
Colin Cross97ba0732015-03-23 17:50:24 -070079 CrtBegin, CrtEnd string
Dan Willemsenc77a0b32017-09-18 23:19:12 -070080 LinkerScript string
Colin Crossc472d572015-03-17 15:06:21 -070081}
82
Colin Crossca860ac2016-01-04 14:34:37 -080083type PathDeps struct {
Colin Cross26c34ed2016-09-30 17:10:16 -070084 // Paths to .so files
85 SharedLibs, LateSharedLibs android.Paths
86 // Paths to the dependencies to use for .so files (.so.toc files)
87 SharedLibsDeps, LateSharedLibsDeps android.Paths
88 // Paths to .a files
Colin Cross635c3b02016-05-18 15:37:25 -070089 StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -070090
Colin Cross26c34ed2016-09-30 17:10:16 -070091 // Paths to .o files
Dan Willemsen5cb580f2016-09-26 17:33:01 -070092 Objs Objects
Dan Willemsen581341d2017-02-09 16:16:31 -080093 StaticLibObjs Objects
Dan Willemsen5cb580f2016-09-26 17:33:01 -070094 WholeStaticLibObjs Objects
Dan Willemsen34cc69e2015-09-23 15:26:20 -070095
Colin Cross26c34ed2016-09-30 17:10:16 -070096 // Paths to generated source files
Colin Cross635c3b02016-05-18 15:37:25 -070097 GeneratedSources android.Paths
98 GeneratedHeaders android.Paths
Dan Willemsenb40aab62016-04-20 14:21:14 -070099
Dan Willemsen76f08272016-07-09 00:14:08 -0700100 Flags, ReexportedFlags []string
Dan Willemsen847dcc72016-09-29 12:13:36 -0700101 ReexportedFlagsDeps android.Paths
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700102
Colin Cross26c34ed2016-09-30 17:10:16 -0700103 // Paths to crt*.o files
Colin Cross635c3b02016-05-18 15:37:25 -0700104 CrtBegin, CrtEnd android.OptionalPath
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700105 LinkerScript android.OptionalPath
Dan Willemsen34cc69e2015-09-23 15:26:20 -0700106}
107
Colin Crossca860ac2016-01-04 14:34:37 -0800108type Flags struct {
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700109 GlobalFlags []string // Flags that apply to C, C++, and assembly source files
110 ArFlags []string // Flags that apply to ar
111 AsFlags []string // Flags that apply to assembly source files
112 CFlags []string // Flags that apply to C and C++ source files
113 ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools
114 ConlyFlags []string // Flags that apply to C source files
115 CppFlags []string // Flags that apply to C++ source files
116 ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools
117 YaccFlags []string // Flags that apply to Yacc source files
118 protoFlags []string // Flags that apply to proto source files
119 aidlFlags []string // Flags that apply to aidl source files
120 rsFlags []string // Flags that apply to renderscript source files
121 LdFlags []string // Flags that apply to linker command lines
122 libFlags []string // Flags to add libraries early to the link order
123 TidyFlags []string // Flags that apply to clang-tidy
124 SAbiFlags []string // Flags that apply to header-abi-dumper
125 YasmFlags []string // Flags that apply to yasm assembly source files
Colin Cross28344522015-04-22 13:07:53 -0700126
Colin Crossc3199482017-03-30 15:03:04 -0700127 // Global include flags that apply to C, C++, and assembly source files
128 // These must be after any module include flags, which will be in GlobalFlags.
129 SystemIncludeFlags []string
130
Colin Crossb98c8b02016-07-29 13:44:28 -0700131 Toolchain config.Toolchain
Colin Cross28344522015-04-22 13:07:53 -0700132 Clang bool
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700133 Tidy bool
Dan Willemsen581341d2017-02-09 16:16:31 -0800134 Coverage bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800135 SAbiDump bool
Colin Crossca860ac2016-01-04 14:34:37 -0800136
137 RequiredInstructionSet string
Colin Cross16b23492016-01-06 14:41:07 -0800138 DynamicLinker string
139
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700140 CFlagsDeps android.Paths // Files depended on by compiler flags
141 LdFlagsDeps android.Paths // Files depended on by linker flags
Colin Cross18c0c5a2016-12-01 14:45:23 -0800142
143 GroupStaticLibs bool
Colin Crossc472d572015-03-17 15:06:21 -0700144}
145
Colin Cross81413472016-04-11 14:37:39 -0700146type ObjectLinkerProperties struct {
147 // names of other cc_object modules to link into this module using partial linking
148 Objs []string `android:"arch_variant"`
Dan Willemsenefb1dd92017-09-18 22:47:20 -0700149
150 // if set, add an extra objcopy --prefix-symbols= step
Nan Zhang0007d812017-11-07 10:57:05 -0800151 Prefix_symbols *string
Colin Cross81413472016-04-11 14:37:39 -0700152}
153
Colin Crossca860ac2016-01-04 14:34:37 -0800154// Properties used to compile all C or C++ modules
155type BaseProperties struct {
156 // compile module with clang instead of gcc
157 Clang *bool `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700158
159 // Minimum sdk version supported when compiling against the ndk
Nan Zhang0007d812017-11-07 10:57:05 -0800160 Sdk_version *string
Colin Cross7d5136f2015-05-11 13:39:40 -0700161
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700162 AndroidMkSharedLibs []string `blueprint:"mutated"`
163 HideFromMake bool `blueprint:"mutated"`
164 PreventInstall bool `blueprint:"mutated"`
165
166 UseVndk bool `blueprint:"mutated"`
Colin Cross5beccee2017-12-07 15:28:59 -0800167
168 // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
169 // file
170 Logtags []string
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700171}
172
173type VendorProperties struct {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900174 // whether this module should be allowed to be directly depended by other
175 // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
176 // If set to true, two variants will be built separately, one like
177 // normal, and the other limited to the set of libraries and headers
178 // that are exposed to /vendor modules.
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700179 //
180 // The vendor variant may be used with a different (newer) /system,
181 // so it shouldn't have any unversioned runtime dependencies, or
182 // make assumptions about the system that may not be true in the
183 // future.
184 //
Jiyong Park82e2bf32017-08-16 14:05:54 +0900185 // If set to false, this module becomes inaccessible from /vendor modules.
186 //
187 // Default value is true when vndk: {enabled: true} or vendor: true.
188 //
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700189 // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
190 Vendor_available *bool
Colin Crossca860ac2016-01-04 14:34:37 -0800191}
192
Colin Crossca860ac2016-01-04 14:34:37 -0800193type UnusedProperties struct {
Dan Willemsen581341d2017-02-09 16:16:31 -0800194 Tags []string
Colin Crosscfad1192015-11-02 16:43:11 -0800195}
196
Colin Crossca860ac2016-01-04 14:34:37 -0800197type ModuleContextIntf interface {
Colin Crossca860ac2016-01-04 14:34:37 -0800198 static() bool
199 staticBinary() bool
200 clang() bool
Colin Crossb98c8b02016-07-29 13:44:28 -0700201 toolchain() config.Toolchain
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700202 useSdk() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800203 sdkVersion() string
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700204 useVndk() bool
Justin Yun8effde42017-06-23 19:24:43 +0900205 isVndk() bool
206 isVndkSp() bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800207 createVndkSourceAbiDump() bool
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700208 selectedStl() string
Colin Crossce75d2c2016-10-06 16:12:58 -0700209 baseModuleName() string
Colin Crossca860ac2016-01-04 14:34:37 -0800210}
211
212type ModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700213 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800214 ModuleContextIntf
215}
216
217type BaseModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700218 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800219 ModuleContextIntf
220}
221
Colin Cross37047f12016-12-13 17:06:13 -0800222type DepsContext interface {
223 android.BottomUpMutatorContext
224 ModuleContextIntf
225}
226
Colin Crossca860ac2016-01-04 14:34:37 -0800227type feature interface {
228 begin(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800229 deps(ctx DepsContext, deps Deps) Deps
Colin Crossca860ac2016-01-04 14:34:37 -0800230 flags(ctx ModuleContext, flags Flags) Flags
231 props() []interface{}
232}
233
234type compiler interface {
Colin Cross42742b82016-08-01 13:20:05 -0700235 compilerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800236 compilerDeps(ctx DepsContext, deps Deps) Deps
Colin Crossf18e1102017-11-16 14:33:08 -0800237 compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
Colin Cross42742b82016-08-01 13:20:05 -0700238 compilerProps() []interface{}
239
Colin Cross76fada02016-07-27 10:31:13 -0700240 appendCflags([]string)
241 appendAsflags([]string)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700242 compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800243}
244
245type linker interface {
Colin Cross42742b82016-08-01 13:20:05 -0700246 linkerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800247 linkerDeps(ctx DepsContext, deps Deps) Deps
Colin Cross42742b82016-08-01 13:20:05 -0700248 linkerFlags(ctx ModuleContext, flags Flags) Flags
249 linkerProps() []interface{}
250
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700251 link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
Colin Cross76fada02016-07-27 10:31:13 -0700252 appendLdflags([]string)
Colin Crossca860ac2016-01-04 14:34:37 -0800253}
254
255type installer interface {
Colin Cross42742b82016-08-01 13:20:05 -0700256 installerProps() []interface{}
Colin Cross635c3b02016-05-18 15:37:25 -0700257 install(ctx ModuleContext, path android.Path)
Colin Crossca860ac2016-01-04 14:34:37 -0800258 inData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700259 inSanitizerDir() bool
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700260 hostToolPath() android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800261}
262
Colin Crossc99deeb2016-04-11 15:06:20 -0700263type dependencyTag struct {
264 blueprint.BaseDependencyTag
265 name string
266 library bool
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700267
268 reexportFlags bool
Colin Crossc99deeb2016-04-11 15:06:20 -0700269}
270
271var (
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700272 sharedDepTag = dependencyTag{name: "shared", library: true}
273 sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true}
274 lateSharedDepTag = dependencyTag{name: "late shared", library: true}
275 staticDepTag = dependencyTag{name: "static", library: true}
276 staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true}
277 lateStaticDepTag = dependencyTag{name: "late static", library: true}
278 wholeStaticDepTag = dependencyTag{name: "whole static", library: true, reexportFlags: true}
Colin Cross32ec36c2016-12-15 07:39:51 -0800279 headerDepTag = dependencyTag{name: "header", library: true}
280 headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700281 genSourceDepTag = dependencyTag{name: "gen source"}
282 genHeaderDepTag = dependencyTag{name: "gen header"}
283 genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
284 objDepTag = dependencyTag{name: "obj"}
285 crtBeginDepTag = dependencyTag{name: "crtbegin"}
286 crtEndDepTag = dependencyTag{name: "crtend"}
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700287 linkerScriptDepTag = dependencyTag{name: "linker script"}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700288 reuseObjTag = dependencyTag{name: "reuse objects"}
289 ndkStubDepTag = dependencyTag{name: "ndk stub", library: true}
290 ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true}
Colin Crossc99deeb2016-04-11 15:06:20 -0700291)
292
Colin Crossca860ac2016-01-04 14:34:37 -0800293// Module contains the properties and members used by all C/C++ module types, and implements
294// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
295// to construct the output file. Behavior can be customized with a Customizer interface
296type Module struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700297 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -0700298 android.DefaultableModuleBase
Colin Crossc472d572015-03-17 15:06:21 -0700299
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700300 Properties BaseProperties
301 VendorProperties VendorProperties
302 unused UnusedProperties
Colin Crossfa138792015-04-24 17:31:52 -0700303
Colin Crossca860ac2016-01-04 14:34:37 -0800304 // initialize before calling Init
Colin Cross635c3b02016-05-18 15:37:25 -0700305 hod android.HostOrDeviceSupported
306 multilib android.Multilib
Colin Crossc472d572015-03-17 15:06:21 -0700307
Colin Crossca860ac2016-01-04 14:34:37 -0800308 // delegates, initialize before calling Init
Colin Crossb4ce0ec2016-09-13 13:41:39 -0700309 features []feature
310 compiler compiler
311 linker linker
312 installer installer
313 stl *stl
314 sanitize *sanitize
Dan Willemsen581341d2017-02-09 16:16:31 -0800315 coverage *coverage
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800316 sabi *sabi
Justin Yun8effde42017-06-23 19:24:43 +0900317 vndkdep *vndkdep
Stephen Craneba090d12017-05-09 15:44:35 -0700318 lto *lto
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700319 pgo *pgo
Colin Cross16b23492016-01-06 14:41:07 -0800320
321 androidMkSharedLibDeps []string
Colin Cross74d1ec02015-04-28 13:30:13 -0700322
Colin Cross635c3b02016-05-18 15:37:25 -0700323 outputFile android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800324
Colin Crossb98c8b02016-07-29 13:44:28 -0700325 cachedToolchain config.Toolchain
Colin Crossb916a382016-07-29 17:28:03 -0700326
327 subAndroidMkOnce map[subAndroidMkProvider]bool
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800328
329 // Flags used to compile this module
330 flags Flags
Jeff Gaston294356f2017-09-27 17:05:30 -0700331
332 // When calling a linker, if module A depends on module B, then A must precede B in its command
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800333 // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive
Jeff Gaston294356f2017-09-27 17:05:30 -0700334 // deps of this module
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800335 depsInLinkOrder android.Paths
336
337 // only non-nil when this is a shared library that reuses the objects of a static library
338 staticVariant *Module
Colin Crossc472d572015-03-17 15:06:21 -0700339}
340
Colin Cross36242852017-06-23 15:06:31 -0700341func (c *Module) Init() android.Module {
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700342 c.AddProperties(&c.Properties, &c.VendorProperties, &c.unused)
Colin Crossca860ac2016-01-04 14:34:37 -0800343 if c.compiler != nil {
Colin Cross36242852017-06-23 15:06:31 -0700344 c.AddProperties(c.compiler.compilerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800345 }
346 if c.linker != nil {
Colin Cross36242852017-06-23 15:06:31 -0700347 c.AddProperties(c.linker.linkerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800348 }
349 if c.installer != nil {
Colin Cross36242852017-06-23 15:06:31 -0700350 c.AddProperties(c.installer.installerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800351 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700352 if c.stl != nil {
Colin Cross36242852017-06-23 15:06:31 -0700353 c.AddProperties(c.stl.props()...)
Colin Crossa8e07cc2016-04-04 15:07:06 -0700354 }
Colin Cross16b23492016-01-06 14:41:07 -0800355 if c.sanitize != nil {
Colin Cross36242852017-06-23 15:06:31 -0700356 c.AddProperties(c.sanitize.props()...)
Colin Cross16b23492016-01-06 14:41:07 -0800357 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800358 if c.coverage != nil {
Colin Cross36242852017-06-23 15:06:31 -0700359 c.AddProperties(c.coverage.props()...)
Dan Willemsen581341d2017-02-09 16:16:31 -0800360 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800361 if c.sabi != nil {
Colin Cross36242852017-06-23 15:06:31 -0700362 c.AddProperties(c.sabi.props()...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800363 }
Justin Yun8effde42017-06-23 19:24:43 +0900364 if c.vndkdep != nil {
365 c.AddProperties(c.vndkdep.props()...)
366 }
Stephen Craneba090d12017-05-09 15:44:35 -0700367 if c.lto != nil {
368 c.AddProperties(c.lto.props()...)
369 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700370 if c.pgo != nil {
371 c.AddProperties(c.pgo.props()...)
372 }
Colin Crossca860ac2016-01-04 14:34:37 -0800373 for _, feature := range c.features {
Colin Cross36242852017-06-23 15:06:31 -0700374 c.AddProperties(feature.props()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800375 }
Colin Crossc472d572015-03-17 15:06:21 -0700376
Colin Cross36242852017-06-23 15:06:31 -0700377 android.InitAndroidArchModule(c, c.hod, c.multilib)
Colin Crossc472d572015-03-17 15:06:21 -0700378
Colin Cross1f44a3a2017-07-07 14:33:33 -0700379 android.InitDefaultableModule(c)
Colin Cross36242852017-06-23 15:06:31 -0700380
381 return c
Colin Crossc472d572015-03-17 15:06:21 -0700382}
383
Colin Crossb916a382016-07-29 17:28:03 -0700384// Returns true for dependency roots (binaries)
385// TODO(ccross): also handle dlopenable libraries
386func (c *Module) isDependencyRoot() bool {
387 if root, ok := c.linker.(interface {
388 isDependencyRoot() bool
389 }); ok {
390 return root.isDependencyRoot()
391 }
392 return false
393}
394
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700395func (c *Module) useVndk() bool {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700396 return c.Properties.UseVndk
397}
398
Justin Yun8effde42017-06-23 19:24:43 +0900399func (c *Module) isVndk() bool {
400 if c.vndkdep != nil {
401 return c.vndkdep.isVndk()
402 }
403 return false
404}
405
Jiyong Park82e2bf32017-08-16 14:05:54 +0900406// Returns true only when this module is configured to have core and vendor
407// variants.
408func (c *Module) hasVendorVariant() bool {
409 return c.isVndk() || Bool(c.VendorProperties.Vendor_available)
410}
411
Colin Crossca860ac2016-01-04 14:34:37 -0800412type baseModuleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700413 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800414 moduleContextImpl
415}
416
Colin Cross37047f12016-12-13 17:06:13 -0800417type depsContext struct {
418 android.BottomUpMutatorContext
419 moduleContextImpl
420}
421
Colin Crossca860ac2016-01-04 14:34:37 -0800422type moduleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700423 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800424 moduleContextImpl
425}
426
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700427func (ctx *moduleContext) InstallOnVendorPartition() bool {
428 return ctx.ModuleContext.InstallOnVendorPartition() || (ctx.mod.useVndk() && !ctx.mod.isVndk())
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700429}
430
Colin Crossca860ac2016-01-04 14:34:37 -0800431type moduleContextImpl struct {
432 mod *Module
433 ctx BaseModuleContext
434}
435
Colin Crossca860ac2016-01-04 14:34:37 -0800436func (ctx *moduleContextImpl) clang() bool {
437 return ctx.mod.clang(ctx.ctx)
438}
439
Colin Crossb98c8b02016-07-29 13:44:28 -0700440func (ctx *moduleContextImpl) toolchain() config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800441 return ctx.mod.toolchain(ctx.ctx)
442}
443
444func (ctx *moduleContextImpl) static() bool {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000445 return ctx.mod.static()
Colin Crossca860ac2016-01-04 14:34:37 -0800446}
447
448func (ctx *moduleContextImpl) staticBinary() bool {
Colin Crossb916a382016-07-29 17:28:03 -0700449 if static, ok := ctx.mod.linker.(interface {
450 staticBinary() bool
451 }); ok {
452 return static.staticBinary()
Colin Crossca860ac2016-01-04 14:34:37 -0800453 }
Colin Crossb916a382016-07-29 17:28:03 -0700454 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800455}
456
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700457func (ctx *moduleContextImpl) useSdk() bool {
458 if ctx.ctx.Device() && !ctx.useVndk() {
Nan Zhang0007d812017-11-07 10:57:05 -0800459 return String(ctx.mod.Properties.Sdk_version) != ""
Dan Willemsena96ff642016-06-07 12:34:45 -0700460 }
461 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800462}
463
464func (ctx *moduleContextImpl) sdkVersion() string {
Dan Willemsena96ff642016-06-07 12:34:45 -0700465 if ctx.ctx.Device() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700466 if ctx.useVndk() {
Dan Willemsen11b26142017-03-19 18:30:37 -0700467 return "current"
Dan Willemsend2ede872016-11-18 14:54:24 -0800468 } else {
Nan Zhang0007d812017-11-07 10:57:05 -0800469 return String(ctx.mod.Properties.Sdk_version)
Dan Willemsend2ede872016-11-18 14:54:24 -0800470 }
Dan Willemsena96ff642016-06-07 12:34:45 -0700471 }
472 return ""
Colin Crossca860ac2016-01-04 14:34:37 -0800473}
474
Justin Yun8effde42017-06-23 19:24:43 +0900475func (ctx *moduleContextImpl) isVndk() bool {
476 return ctx.mod.isVndk()
477}
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700478func (ctx *moduleContextImpl) useVndk() bool {
479 return ctx.mod.useVndk()
480}
Justin Yun8effde42017-06-23 19:24:43 +0900481
482func (ctx *moduleContextImpl) isVndkSp() bool {
483 if vndk := ctx.mod.vndkdep; vndk != nil {
484 return vndk.isVndkSp()
485 }
486 return false
487}
488
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800489// Create source abi dumps if the module belongs to the list of VndkLibraries.
490func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700491 return ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries))
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800492}
493
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700494func (ctx *moduleContextImpl) selectedStl() string {
495 if stl := ctx.mod.stl; stl != nil {
496 return stl.Properties.SelectedStl
497 }
498 return ""
499}
500
Colin Crossce75d2c2016-10-06 16:12:58 -0700501func (ctx *moduleContextImpl) baseModuleName() string {
502 return ctx.mod.ModuleBase.BaseModuleName()
503}
504
Colin Cross635c3b02016-05-18 15:37:25 -0700505func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800506 return &Module{
507 hod: hod,
508 multilib: multilib,
509 }
510}
511
Colin Cross635c3b02016-05-18 15:37:25 -0700512func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800513 module := newBaseModule(hod, multilib)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700514 module.features = []feature{
515 &tidyFeature{},
516 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700517 module.stl = &stl{}
Colin Cross16b23492016-01-06 14:41:07 -0800518 module.sanitize = &sanitize{}
Dan Willemsen581341d2017-02-09 16:16:31 -0800519 module.coverage = &coverage{}
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800520 module.sabi = &sabi{}
Justin Yun8effde42017-06-23 19:24:43 +0900521 module.vndkdep = &vndkdep{}
Stephen Craneba090d12017-05-09 15:44:35 -0700522 module.lto = &lto{}
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700523 module.pgo = &pgo{}
Colin Crossca860ac2016-01-04 14:34:37 -0800524 return module
525}
526
Colin Crossce75d2c2016-10-06 16:12:58 -0700527func (c *Module) Prebuilt() *android.Prebuilt {
528 if p, ok := c.linker.(prebuiltLinkerInterface); ok {
529 return p.prebuilt()
530 }
531 return nil
532}
533
534func (c *Module) Name() string {
535 name := c.ModuleBase.Name()
Dan Willemsen01a90592017-04-07 15:21:13 -0700536 if p, ok := c.linker.(interface {
537 Name(string) string
538 }); ok {
Colin Crossce75d2c2016-10-06 16:12:58 -0700539 name = p.Name(name)
540 }
541 return name
542}
543
Jeff Gaston294356f2017-09-27 17:05:30 -0700544// orderDeps reorders dependencies into a list such that if module A depends on B, then
545// A will precede B in the resultant list.
546// This is convenient for passing into a linker.
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800547// Note that directSharedDeps should be the analogous static library for each shared lib dep
548func orderDeps(directStaticDeps []android.Path, directSharedDeps []android.Path, allTransitiveDeps map[android.Path][]android.Path) (orderedAllDeps []android.Path, orderedDeclaredDeps []android.Path) {
Jeff Gaston294356f2017-09-27 17:05:30 -0700549 // If A depends on B, then
550 // Every list containing A will also contain B later in the list
551 // So, after concatenating all lists, the final instance of B will have come from the same
552 // original list as the final instance of A
553 // So, the final instance of B will be later in the concatenation than the final A
554 // So, keeping only the final instance of A and of B ensures that A is earlier in the output
555 // list than B
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800556 for _, dep := range directStaticDeps {
Jeff Gaston294356f2017-09-27 17:05:30 -0700557 orderedAllDeps = append(orderedAllDeps, dep)
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800558 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
559 }
560 for _, dep := range directSharedDeps {
561 orderedAllDeps = append(orderedAllDeps, dep)
562 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
Jeff Gaston294356f2017-09-27 17:05:30 -0700563 }
564
Colin Crossb6715442017-10-24 11:13:31 -0700565 orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700566
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800567 // We don't want to add any new dependencies into directStaticDeps (to allow the caller to
Jeff Gaston294356f2017-09-27 17:05:30 -0700568 // intentionally exclude or replace any unwanted transitive dependencies), so we limit the
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800569 // resultant list to only what the caller has chosen to include in directStaticDeps
570 _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700571
572 return orderedAllDeps, orderedDeclaredDeps
573}
574
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800575func orderStaticModuleDeps(module *Module, staticDeps []*Module, sharedDeps []*Module) (results []android.Path) {
576 // convert Module to Path
577 allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps))
578 staticDepFiles := []android.Path{}
579 for _, dep := range staticDeps {
580 allTransitiveDeps[dep.outputFile.Path()] = dep.depsInLinkOrder
581 staticDepFiles = append(staticDepFiles, dep.outputFile.Path())
Jeff Gaston294356f2017-09-27 17:05:30 -0700582 }
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800583 sharedDepFiles := []android.Path{}
584 for _, sharedDep := range sharedDeps {
585 staticAnalogue := sharedDep.staticVariant
586 if staticAnalogue != nil {
587 allTransitiveDeps[staticAnalogue.outputFile.Path()] = staticAnalogue.depsInLinkOrder
588 sharedDepFiles = append(sharedDepFiles, staticAnalogue.outputFile.Path())
589 }
Jeff Gaston294356f2017-09-27 17:05:30 -0700590 }
591
592 // reorder the dependencies based on transitive dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800593 module.depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700594
595 return results
Jeff Gaston294356f2017-09-27 17:05:30 -0700596}
597
Colin Cross635c3b02016-05-18 15:37:25 -0700598func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700599
Colin Crossca860ac2016-01-04 14:34:37 -0800600 ctx := &moduleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700601 ModuleContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800602 moduleContextImpl: moduleContextImpl{
603 mod: c,
604 },
605 }
606 ctx.ctx = ctx
607
Colin Crossf18e1102017-11-16 14:33:08 -0800608 deps := c.depsToPaths(ctx)
609 if ctx.Failed() {
610 return
611 }
612
Colin Crossca860ac2016-01-04 14:34:37 -0800613 flags := Flags{
614 Toolchain: c.toolchain(ctx),
615 Clang: c.clang(ctx),
616 }
Colin Crossca860ac2016-01-04 14:34:37 -0800617 if c.compiler != nil {
Colin Crossf18e1102017-11-16 14:33:08 -0800618 flags = c.compiler.compilerFlags(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800619 }
620 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700621 flags = c.linker.linkerFlags(ctx, flags)
Colin Crossca860ac2016-01-04 14:34:37 -0800622 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700623 if c.stl != nil {
624 flags = c.stl.flags(ctx, flags)
625 }
Colin Cross16b23492016-01-06 14:41:07 -0800626 if c.sanitize != nil {
627 flags = c.sanitize.flags(ctx, flags)
628 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800629 if c.coverage != nil {
630 flags = c.coverage.flags(ctx, flags)
631 }
Stephen Craneba090d12017-05-09 15:44:35 -0700632 if c.lto != nil {
633 flags = c.lto.flags(ctx, flags)
634 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700635 if c.pgo != nil {
636 flags = c.pgo.flags(ctx, flags)
637 }
Colin Crossca860ac2016-01-04 14:34:37 -0800638 for _, feature := range c.features {
639 flags = feature.flags(ctx, flags)
640 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800641 if ctx.Failed() {
642 return
643 }
644
Colin Crossb98c8b02016-07-29 13:44:28 -0700645 flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags)
646 flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags)
647 flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags)
Colin Cross3f40fa42015-01-30 17:27:36 -0800648
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800649 flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
650 c.flags = flags
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700651 // We need access to all the flags seen by a source file.
652 if c.sabi != nil {
653 flags = c.sabi.flags(ctx, flags)
654 }
Colin Crossca860ac2016-01-04 14:34:37 -0800655 // Optimization to reduce size of build.ninja
656 // Replace the long list of flags for each file with a module-local variable
657 ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
658 ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " "))
659 ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " "))
660 flags.CFlags = []string{"$cflags"}
661 flags.CppFlags = []string{"$cppflags"}
662 flags.AsFlags = []string{"$asflags"}
663
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700664 var objs Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800665 if c.compiler != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700666 objs = c.compiler.compile(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800667 if ctx.Failed() {
668 return
669 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800670 }
671
Colin Crossca860ac2016-01-04 14:34:37 -0800672 if c.linker != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700673 outputFile := c.linker.link(ctx, flags, deps, objs)
Colin Crossca860ac2016-01-04 14:34:37 -0800674 if ctx.Failed() {
675 return
676 }
Colin Cross635c3b02016-05-18 15:37:25 -0700677 c.outputFile = android.OptionalPathForPath(outputFile)
Colin Crossce75d2c2016-10-06 16:12:58 -0700678 }
Colin Cross5049f022015-03-18 13:28:46 -0700679
Colin Crossce75d2c2016-10-06 16:12:58 -0700680 if c.installer != nil && !c.Properties.PreventInstall && c.outputFile.Valid() {
681 c.installer.install(ctx, c.outputFile.Path())
682 if ctx.Failed() {
683 return
Colin Crossca860ac2016-01-04 14:34:37 -0800684 }
Dan Albertc403f7c2015-03-18 14:01:18 -0700685 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800686}
687
Colin Crossb98c8b02016-07-29 13:44:28 -0700688func (c *Module) toolchain(ctx BaseModuleContext) config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800689 if c.cachedToolchain == nil {
Colin Crossb98c8b02016-07-29 13:44:28 -0700690 c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
Colin Cross3f40fa42015-01-30 17:27:36 -0800691 }
Colin Crossca860ac2016-01-04 14:34:37 -0800692 return c.cachedToolchain
Colin Cross3f40fa42015-01-30 17:27:36 -0800693}
694
Colin Crossca860ac2016-01-04 14:34:37 -0800695func (c *Module) begin(ctx BaseModuleContext) {
696 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700697 c.compiler.compilerInit(ctx)
Colin Cross21b9a242015-03-24 14:15:58 -0700698 }
Colin Crossca860ac2016-01-04 14:34:37 -0800699 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700700 c.linker.linkerInit(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800701 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700702 if c.stl != nil {
703 c.stl.begin(ctx)
704 }
Colin Cross16b23492016-01-06 14:41:07 -0800705 if c.sanitize != nil {
706 c.sanitize.begin(ctx)
707 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800708 if c.coverage != nil {
709 c.coverage.begin(ctx)
710 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800711 if c.sabi != nil {
712 c.sabi.begin(ctx)
713 }
Justin Yun8effde42017-06-23 19:24:43 +0900714 if c.vndkdep != nil {
715 c.vndkdep.begin(ctx)
716 }
Stephen Craneba090d12017-05-09 15:44:35 -0700717 if c.lto != nil {
718 c.lto.begin(ctx)
719 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700720 if c.pgo != nil {
721 c.pgo.begin(ctx)
722 }
Colin Crossca860ac2016-01-04 14:34:37 -0800723 for _, feature := range c.features {
724 feature.begin(ctx)
725 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700726 if ctx.useSdk() {
Dan Albertf5415d72017-08-17 16:19:59 -0700727 version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700728 if err != nil {
729 ctx.PropertyErrorf("sdk_version", err.Error())
730 }
Nan Zhang0007d812017-11-07 10:57:05 -0800731 c.Properties.Sdk_version = StringPtr(version)
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700732 }
Colin Crossca860ac2016-01-04 14:34:37 -0800733}
734
Colin Cross37047f12016-12-13 17:06:13 -0800735func (c *Module) deps(ctx DepsContext) Deps {
Colin Crossc99deeb2016-04-11 15:06:20 -0700736 deps := Deps{}
737
738 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700739 deps = c.compiler.compilerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700740 }
Pirama Arumuga Nainar49b53d52017-10-04 16:47:29 -0700741 // Add the PGO dependency (the clang_rt.profile runtime library), which
742 // sometimes depends on symbols from libgcc, before libgcc gets added
743 // in linkerDeps().
744 if c.pgo != nil {
745 deps = c.pgo.deps(ctx, deps)
746 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700747 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700748 deps = c.linker.linkerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700749 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700750 if c.stl != nil {
751 deps = c.stl.deps(ctx, deps)
752 }
Colin Cross16b23492016-01-06 14:41:07 -0800753 if c.sanitize != nil {
754 deps = c.sanitize.deps(ctx, deps)
755 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800756 if c.coverage != nil {
757 deps = c.coverage.deps(ctx, deps)
758 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800759 if c.sabi != nil {
760 deps = c.sabi.deps(ctx, deps)
761 }
Justin Yun8effde42017-06-23 19:24:43 +0900762 if c.vndkdep != nil {
763 deps = c.vndkdep.deps(ctx, deps)
764 }
Stephen Craneba090d12017-05-09 15:44:35 -0700765 if c.lto != nil {
766 deps = c.lto.deps(ctx, deps)
767 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700768 for _, feature := range c.features {
769 deps = feature.deps(ctx, deps)
770 }
771
Colin Crossb6715442017-10-24 11:13:31 -0700772 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
773 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
774 deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
775 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
776 deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
777 deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
Colin Crossc99deeb2016-04-11 15:06:20 -0700778
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700779 for _, lib := range deps.ReexportSharedLibHeaders {
780 if !inList(lib, deps.SharedLibs) {
781 ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
782 }
783 }
784
785 for _, lib := range deps.ReexportStaticLibHeaders {
786 if !inList(lib, deps.StaticLibs) {
787 ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib)
788 }
789 }
790
Colin Cross5950f382016-12-13 12:50:57 -0800791 for _, lib := range deps.ReexportHeaderLibHeaders {
792 if !inList(lib, deps.HeaderLibs) {
793 ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
794 }
795 }
796
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700797 for _, gen := range deps.ReexportGeneratedHeaders {
798 if !inList(gen, deps.GeneratedHeaders) {
799 ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
800 }
801 }
802
Colin Crossc99deeb2016-04-11 15:06:20 -0700803 return deps
804}
805
Dan Albert7e9d2952016-08-04 13:02:36 -0700806func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
Colin Crossca860ac2016-01-04 14:34:37 -0800807 ctx := &baseModuleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700808 BaseContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800809 moduleContextImpl: moduleContextImpl{
810 mod: c,
811 },
812 }
813 ctx.ctx = ctx
814
Colin Crossca860ac2016-01-04 14:34:37 -0800815 c.begin(ctx)
Dan Albert7e9d2952016-08-04 13:02:36 -0700816}
817
Colin Cross1e676be2016-10-12 14:38:15 -0700818func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
819 if !c.Enabled() {
820 return
821 }
822
Colin Cross37047f12016-12-13 17:06:13 -0800823 ctx := &depsContext{
824 BottomUpMutatorContext: actx,
Dan Albert7e9d2952016-08-04 13:02:36 -0700825 moduleContextImpl: moduleContextImpl{
826 mod: c,
827 },
828 }
829 ctx.ctx = ctx
Colin Crossca860ac2016-01-04 14:34:37 -0800830
Colin Crossc99deeb2016-04-11 15:06:20 -0700831 deps := c.deps(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800832
Dan Albert914449f2016-06-17 16:45:24 -0700833 variantNdkLibs := []string{}
834 variantLateNdkLibs := []string{}
Dan Willemsenb916b802017-03-19 13:44:32 -0700835 if ctx.Os() == android.Android {
Dan Albert914449f2016-06-17 16:45:24 -0700836 version := ctx.sdkVersion()
Dan Willemsen72d39932016-07-08 23:23:48 -0700837
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700838 // rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
839 // of names:
Dan Albert914449f2016-06-17 16:45:24 -0700840 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700841 // 1. Name of an NDK library that refers to a prebuilt module.
842 // For each of these, it adds the name of the prebuilt module (which will be in
843 // prebuilts/ndk) to the list of nonvariant libs.
844 // 2. Name of an NDK library that refers to an ndk_library module.
845 // For each of these, it adds the name of the ndk_library module to the list of
846 // variant libs.
847 // 3. Anything else (so anything that isn't an NDK library).
848 // It adds these to the nonvariantLibs list.
Dan Albert914449f2016-06-17 16:45:24 -0700849 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700850 // The caller can then know to add the variantLibs dependencies differently from the
851 // nonvariantLibs
852 rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
853 variantLibs = []string{}
854 nonvariantLibs = []string{}
Dan Albert914449f2016-06-17 16:45:24 -0700855 for _, entry := range list {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700856 if ctx.useSdk() && inList(entry, ndkPrebuiltSharedLibraries) {
Dan Albert914449f2016-06-17 16:45:24 -0700857 if !inList(entry, ndkMigratedLibs) {
858 nonvariantLibs = append(nonvariantLibs, entry+".ndk."+version)
859 } else {
860 variantLibs = append(variantLibs, entry+ndkLibrarySuffix)
861 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700862 } else if ctx.useVndk() && inList(entry, llndkLibraries) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700863 nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix)
Dan Albert914449f2016-06-17 16:45:24 -0700864 } else {
Dan Willemsen7cbf5f82017-03-28 00:08:30 -0700865 nonvariantLibs = append(nonvariantLibs, entry)
Dan Willemsen72d39932016-07-08 23:23:48 -0700866 }
867 }
Dan Albert914449f2016-06-17 16:45:24 -0700868 return nonvariantLibs, variantLibs
Dan Willemsen72d39932016-07-08 23:23:48 -0700869 }
870
Dan Albert914449f2016-06-17 16:45:24 -0700871 deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs)
872 deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
Jiyong Park4c35af02017-07-05 13:41:55 +0900873 deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
Dan Willemsen72d39932016-07-08 23:23:48 -0700874 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700875
Colin Cross32ec36c2016-12-15 07:39:51 -0800876 for _, lib := range deps.HeaderLibs {
877 depTag := headerDepTag
878 if inList(lib, deps.ReexportHeaderLibHeaders) {
879 depTag = headerExportDepTag
880 }
881 actx.AddVariationDependencies(nil, depTag, lib)
882 }
Colin Cross5950f382016-12-13 12:50:57 -0800883
Colin Crossc99deeb2016-04-11 15:06:20 -0700884 actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, wholeStaticDepTag,
885 deps.WholeStaticLibs...)
886
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700887 for _, lib := range deps.StaticLibs {
888 depTag := staticDepTag
889 if inList(lib, deps.ReexportStaticLibHeaders) {
890 depTag = staticExportDepTag
891 }
Colin Cross15a0d462016-07-14 14:49:58 -0700892 actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700893 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700894
895 actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, lateStaticDepTag,
896 deps.LateStaticLibs...)
897
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700898 for _, lib := range deps.SharedLibs {
899 depTag := sharedDepTag
900 if inList(lib, deps.ReexportSharedLibHeaders) {
901 depTag = sharedExportDepTag
902 }
Colin Cross15a0d462016-07-14 14:49:58 -0700903 actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700904 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700905
906 actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, lateSharedDepTag,
907 deps.LateSharedLibs...)
908
Colin Cross68861832016-07-08 10:41:41 -0700909 actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700910
911 for _, gen := range deps.GeneratedHeaders {
912 depTag := genHeaderDepTag
913 if inList(gen, deps.ReexportGeneratedHeaders) {
914 depTag = genHeaderExportDepTag
915 }
916 actx.AddDependency(c, depTag, gen)
917 }
Dan Willemsenb40aab62016-04-20 14:21:14 -0700918
Colin Cross68861832016-07-08 10:41:41 -0700919 actx.AddDependency(c, objDepTag, deps.ObjFiles...)
Colin Crossc99deeb2016-04-11 15:06:20 -0700920
921 if deps.CrtBegin != "" {
Colin Cross68861832016-07-08 10:41:41 -0700922 actx.AddDependency(c, crtBeginDepTag, deps.CrtBegin)
Colin Crossca860ac2016-01-04 14:34:37 -0800923 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700924 if deps.CrtEnd != "" {
Colin Cross68861832016-07-08 10:41:41 -0700925 actx.AddDependency(c, crtEndDepTag, deps.CrtEnd)
Colin Cross21b9a242015-03-24 14:15:58 -0700926 }
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700927 if deps.LinkerScript != "" {
928 actx.AddDependency(c, linkerScriptDepTag, deps.LinkerScript)
929 }
Dan Albert914449f2016-06-17 16:45:24 -0700930
931 version := ctx.sdkVersion()
932 actx.AddVariationDependencies([]blueprint.Variation{
933 {"ndk_api", version}, {"link", "shared"}}, ndkStubDepTag, variantNdkLibs...)
934 actx.AddVariationDependencies([]blueprint.Variation{
935 {"ndk_api", version}, {"link", "shared"}}, ndkLateStubDepTag, variantLateNdkLibs...)
Colin Cross6362e272015-10-29 15:25:03 -0700936}
Colin Cross21b9a242015-03-24 14:15:58 -0700937
Dan Albert7e9d2952016-08-04 13:02:36 -0700938func beginMutator(ctx android.BottomUpMutatorContext) {
939 if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
940 c.beginMutator(ctx)
941 }
942}
943
Colin Crossca860ac2016-01-04 14:34:37 -0800944func (c *Module) clang(ctx BaseModuleContext) bool {
945 clang := Bool(c.Properties.Clang)
946
947 if c.Properties.Clang == nil {
948 if ctx.Host() {
949 clang = true
950 }
951
Colin Cross6510f912017-11-29 00:27:14 -0800952 if ctx.Device() && ctx.Config().DeviceUsesClang() {
Colin Crossca860ac2016-01-04 14:34:37 -0800953 clang = true
954 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800955 }
Colin Cross28344522015-04-22 13:07:53 -0700956
Colin Crossca860ac2016-01-04 14:34:37 -0800957 if !c.toolchain(ctx).ClangSupported() {
958 clang = false
959 }
960
961 return clang
962}
963
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700964// Whether a module can link to another module, taking into
965// account NDK linking.
966func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
967 if from.Target().Os != android.Android {
968 // Host code is not restricted
969 return
970 }
971 if from.Properties.UseVndk {
972 // Though vendor code is limited by the vendor mutator,
973 // each vendor-available module needs to check
974 // link-type for VNDK.
975 if from.vndkdep != nil {
976 from.vndkdep.vndkCheckLinkType(ctx, to)
977 }
978 return
979 }
Nan Zhang0007d812017-11-07 10:57:05 -0800980 if String(from.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700981 // Platform code can link to anything
982 return
983 }
984 if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
985 // These are always allowed
986 return
987 }
988 if _, ok := to.linker.(*ndkPrebuiltLibraryLinker); ok {
989 // These are allowed, but they don't set sdk_version
990 return
991 }
992 if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
993 // These are allowed, but they don't set sdk_version
994 return
995 }
996 if _, ok := to.linker.(*stubDecorator); ok {
997 // These aren't real libraries, but are the stub shared libraries that are included in
998 // the NDK.
999 return
1000 }
Nan Zhang0007d812017-11-07 10:57:05 -08001001 if String(to.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001002 // NDK code linking to platform code is never okay.
1003 ctx.ModuleErrorf("depends on non-NDK-built library %q",
1004 ctx.OtherModuleName(to))
1005 }
1006
1007 // At this point we know we have two NDK libraries, but we need to
1008 // check that we're not linking against anything built against a higher
1009 // API level, as it is only valid to link against older or equivalent
1010 // APIs.
1011
Nan Zhang0007d812017-11-07 10:57:05 -08001012 if String(from.Properties.Sdk_version) == "current" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001013 // Current can link against anything.
1014 return
Nan Zhang0007d812017-11-07 10:57:05 -08001015 } else if String(to.Properties.Sdk_version) == "current" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001016 // Current can't be linked against by anything else.
1017 ctx.ModuleErrorf("links %q built against newer API version %q",
1018 ctx.OtherModuleName(to), "current")
1019 }
1020
Nan Zhang0007d812017-11-07 10:57:05 -08001021 fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001022 if err != nil {
1023 ctx.PropertyErrorf("sdk_version",
1024 "Invalid sdk_version value (must be int): %q",
Nan Zhang0007d812017-11-07 10:57:05 -08001025 String(from.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001026 }
Nan Zhang0007d812017-11-07 10:57:05 -08001027 toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001028 if err != nil {
1029 ctx.PropertyErrorf("sdk_version",
1030 "Invalid sdk_version value (must be int): %q",
Nan Zhang0007d812017-11-07 10:57:05 -08001031 String(to.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001032 }
1033
1034 if toApi > fromApi {
1035 ctx.ModuleErrorf("links %q built against newer API version %q",
Nan Zhang0007d812017-11-07 10:57:05 -08001036 ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001037 }
1038}
1039
Colin Crossc99deeb2016-04-11 15:06:20 -07001040// Convert dependencies to paths. Returns a PathDeps containing paths
Colin Cross635c3b02016-05-18 15:37:25 -07001041func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
Colin Crossca860ac2016-01-04 14:34:37 -08001042 var depPaths PathDeps
Colin Crossca860ac2016-01-04 14:34:37 -08001043
Jeff Gaston294356f2017-09-27 17:05:30 -07001044 directStaticDeps := []*Module{}
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001045 directSharedDeps := []*Module{}
Jeff Gaston294356f2017-09-27 17:05:30 -07001046
Colin Crossd11fcda2017-10-23 17:59:01 -07001047 ctx.VisitDirectDeps(func(dep android.Module) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001048 depName := ctx.OtherModuleName(dep)
1049 depTag := ctx.OtherModuleDependencyTag(dep)
Dan Albert9e10cd42016-08-03 14:12:14 -07001050
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001051 ccDep, _ := dep.(*Module)
1052 if ccDep == nil {
1053 // handling for a few module types that aren't cc Module but that are also supported
1054 switch depTag {
Colin Cross068e0fe2016-12-13 15:23:47 -08001055 case android.DefaultsDepTag, android.SourceDepTag:
Dan Willemsend6ba0d52017-09-13 15:46:47 -07001056 // Nothing to do
Dan Willemsenb40aab62016-04-20 14:21:14 -07001057 case genSourceDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001058 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001059 depPaths.GeneratedSources = append(depPaths.GeneratedSources,
1060 genRule.GeneratedSourceFiles()...)
1061 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001062 ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001063 }
Colin Crosse90bfd12017-04-26 16:59:26 -07001064 // Support exported headers from a generated_sources dependency
1065 fallthrough
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001066 case genHeaderDepTag, genHeaderExportDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001067 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001068 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
1069 genRule.GeneratedSourceFiles()...)
Colin Cross5ed99c62016-11-22 12:55:55 -08001070 flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001071 depPaths.Flags = append(depPaths.Flags, flags)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001072 if depTag == genHeaderExportDepTag {
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001073 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001074 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
1075 genRule.GeneratedSourceFiles()...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001076 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
1077 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
1078
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001079 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001080 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001081 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001082 }
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001083 case linkerScriptDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001084 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001085 files := genRule.GeneratedSourceFiles()
1086 if len(files) == 1 {
1087 depPaths.LinkerScript = android.OptionalPathForPath(files[0])
1088 } else if len(files) > 1 {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001089 ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001090 }
1091 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001092 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001093 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001094 default:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001095 ctx.ModuleErrorf("depends on non-cc module %q", depName)
Colin Crossca860ac2016-01-04 14:34:37 -08001096 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001097 return
1098 }
1099
Colin Crossd11fcda2017-10-23 17:59:01 -07001100 if dep.Target().Os != ctx.Os() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001101 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
1102 return
1103 }
Colin Crossd11fcda2017-10-23 17:59:01 -07001104 if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001105 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
Colin Crossa1ad8d12016-06-01 17:09:44 -07001106 return
1107 }
1108
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001109 // re-exporting flags
1110 if depTag == reuseObjTag {
1111 if l, ok := ccDep.compiler.(libraryInterface); ok {
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001112 c.staticVariant = ccDep
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001113 objs, flags, deps := l.reuseObjs()
Colin Cross10d22312017-05-03 11:01:58 -07001114 depPaths.Objs = depPaths.Objs.Append(objs)
1115 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001116 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Colin Crossbba99042016-11-23 15:45:05 -08001117 return
1118 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001119 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001120 if t, ok := depTag.(dependencyTag); ok && t.library {
1121 if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
Dan Willemsen76f08272016-07-09 00:14:08 -07001122 flags := i.exportedFlags()
Dan Willemsen847dcc72016-09-29 12:13:36 -07001123 deps := i.exportedFlagsDeps()
Dan Willemsen76f08272016-07-09 00:14:08 -07001124 depPaths.Flags = append(depPaths.Flags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001125 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001126
1127 if t.reexportFlags {
Dan Willemsen76f08272016-07-09 00:14:08 -07001128 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001129 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001130 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
Jayant Chowdharyaf6eb712017-08-23 16:08:29 -07001131 // Re-exported shared library headers must be included as well since they can help us with type information
1132 // about template instantiations (instantiated from their headers).
1133 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001134 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001135 }
Dan Willemsena96ff642016-06-07 12:34:45 -07001136
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001137 checkLinkType(ctx, c, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001138 }
1139
Colin Cross26c34ed2016-09-30 17:10:16 -07001140 var ptr *android.Paths
Colin Cross635c3b02016-05-18 15:37:25 -07001141 var depPtr *android.Paths
Colin Crossc99deeb2016-04-11 15:06:20 -07001142
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001143 linkFile := ccDep.outputFile
Colin Cross26c34ed2016-09-30 17:10:16 -07001144 depFile := android.OptionalPath{}
1145
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001146 switch depTag {
Dan Albert914449f2016-06-17 16:45:24 -07001147 case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001148 ptr = &depPaths.SharedLibs
1149 depPtr = &depPaths.SharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001150 depFile = ccDep.linker.(libraryInterface).toc()
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001151 directSharedDeps = append(directSharedDeps, ccDep)
Dan Albert914449f2016-06-17 16:45:24 -07001152 case lateSharedDepTag, ndkLateStubDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001153 ptr = &depPaths.LateSharedLibs
1154 depPtr = &depPaths.LateSharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001155 depFile = ccDep.linker.(libraryInterface).toc()
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001156 case staticDepTag, staticExportDepTag:
Jeff Gaston294356f2017-09-27 17:05:30 -07001157 ptr = nil
1158 directStaticDeps = append(directStaticDeps, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001159 case lateStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001160 ptr = &depPaths.LateStaticLibs
Colin Crossc99deeb2016-04-11 15:06:20 -07001161 case wholeStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001162 ptr = &depPaths.WholeStaticLibs
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001163 staticLib, ok := ccDep.linker.(libraryInterface)
Colin Crossb916a382016-07-29 17:28:03 -07001164 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001165 ctx.ModuleErrorf("module %q not a static library", depName)
Colin Crossc99deeb2016-04-11 15:06:20 -07001166 return
1167 }
1168
1169 if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001170 postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
Colin Crossc99deeb2016-04-11 15:06:20 -07001171 for i := range missingDeps {
1172 missingDeps[i] += postfix
1173 }
1174 ctx.AddMissingDependencies(missingDeps)
1175 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001176 depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
Colin Cross5950f382016-12-13 12:50:57 -08001177 case headerDepTag:
1178 // Nothing
Colin Crossc99deeb2016-04-11 15:06:20 -07001179 case objDepTag:
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001180 depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
Colin Crossc99deeb2016-04-11 15:06:20 -07001181 case crtBeginDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001182 depPaths.CrtBegin = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001183 case crtEndDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001184 depPaths.CrtEnd = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001185 }
1186
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001187 switch depTag {
Dan Willemsen581341d2017-02-09 16:16:31 -08001188 case staticDepTag, staticExportDepTag, lateStaticDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001189 staticLib, ok := ccDep.linker.(libraryInterface)
Dan Willemsen581341d2017-02-09 16:16:31 -08001190 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001191 ctx.ModuleErrorf("module %q not a static library", depName)
Dan Willemsen581341d2017-02-09 16:16:31 -08001192 return
1193 }
1194
1195 // When combining coverage files for shared libraries and executables, coverage files
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001196 // in static libraries act as if they were whole static libraries. The same goes for
1197 // source based Abi dump files.
Dan Willemsen581341d2017-02-09 16:16:31 -08001198 depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
1199 staticLib.objs().coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001200 depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
1201 staticLib.objs().sAbiDumpFiles...)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001202
Dan Willemsen581341d2017-02-09 16:16:31 -08001203 }
1204
Colin Cross26c34ed2016-09-30 17:10:16 -07001205 if ptr != nil {
Colin Crossce75d2c2016-10-06 16:12:58 -07001206 if !linkFile.Valid() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001207 ctx.ModuleErrorf("module %q missing output file", depName)
Colin Crossce75d2c2016-10-06 16:12:58 -07001208 return
1209 }
Colin Cross26c34ed2016-09-30 17:10:16 -07001210 *ptr = append(*ptr, linkFile.Path())
1211 }
1212
Colin Crossc99deeb2016-04-11 15:06:20 -07001213 if depPtr != nil {
Colin Cross26c34ed2016-09-30 17:10:16 -07001214 dep := depFile
1215 if !dep.Valid() {
1216 dep = linkFile
1217 }
1218 *depPtr = append(*depPtr, dep.Path())
Colin Crossca860ac2016-01-04 14:34:37 -08001219 }
Jiyong Park27b188b2017-07-18 13:23:39 +09001220
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001221 // Export the shared libs to Make.
1222 switch depTag {
Jiyong Park27b188b2017-07-18 13:23:39 +09001223 case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001224 libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
Jiyong Park27b188b2017-07-18 13:23:39 +09001225 libName = strings.TrimPrefix(libName, "prebuilt_")
Jiyong Parkd5b18a52017-08-03 21:22:50 +09001226 isLLndk := inList(libName, llndkLibraries)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001227 var makeLibName string
1228 bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
1229 if c.useVndk() && bothVendorAndCoreVariantsExist {
1230 // The vendor module in Make will have been renamed to not conflict with the core
1231 // module, so update the dependency name here accordingly.
1232 makeLibName = libName + vendorSuffix
1233 } else {
1234 makeLibName = libName
Jiyong Park27b188b2017-07-18 13:23:39 +09001235 }
1236 // Note: the order of libs in this list is not important because
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001237 // they merely serve as Make dependencies and do not affect this lib itself.
1238 c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, makeLibName)
Jiyong Park27b188b2017-07-18 13:23:39 +09001239 }
Colin Crossca860ac2016-01-04 14:34:37 -08001240 })
1241
Jeff Gaston294356f2017-09-27 17:05:30 -07001242 // use the ordered dependencies as this module's dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001243 depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...)
Jeff Gaston294356f2017-09-27 17:05:30 -07001244
Colin Crossdd84e052017-05-17 13:44:16 -07001245 // Dedup exported flags from dependencies
Colin Crossb6715442017-10-24 11:13:31 -07001246 depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001247 depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
Colin Crossb6715442017-10-24 11:13:31 -07001248 depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001249 depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
1250
1251 if c.sabi != nil {
Colin Crossb6715442017-10-24 11:13:31 -07001252 c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001253 }
Colin Crossdd84e052017-05-17 13:44:16 -07001254
Colin Crossca860ac2016-01-04 14:34:37 -08001255 return depPaths
1256}
1257
1258func (c *Module) InstallInData() bool {
1259 if c.installer == nil {
1260 return false
1261 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001262 return c.installer.inData()
1263}
1264
1265func (c *Module) InstallInSanitizerDir() bool {
1266 if c.installer == nil {
1267 return false
1268 }
1269 if c.sanitize != nil && c.sanitize.inSanitizerDir() {
Colin Cross94610402016-08-29 13:41:32 -07001270 return true
1271 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001272 return c.installer.inSanitizerDir()
Colin Crossca860ac2016-01-04 14:34:37 -08001273}
1274
Dan Willemsen4aa75ca2016-09-28 16:18:03 -07001275func (c *Module) HostToolPath() android.OptionalPath {
1276 if c.installer == nil {
1277 return android.OptionalPath{}
1278 }
1279 return c.installer.hostToolPath()
1280}
1281
Nan Zhangd4e641b2017-07-12 12:55:28 -07001282func (c *Module) IntermPathForModuleOut() android.OptionalPath {
1283 return c.outputFile
1284}
1285
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001286func (c *Module) Srcs() android.Paths {
1287 if c.outputFile.Valid() {
1288 return android.Paths{c.outputFile.Path()}
1289 }
1290 return android.Paths{}
1291}
1292
Vishwath Mohanb743e9c2017-11-01 09:20:21 +00001293func (c *Module) static() bool {
1294 if static, ok := c.linker.(interface {
1295 static() bool
1296 }); ok {
1297 return static.static()
1298 }
1299 return false
1300}
1301
Colin Cross2ba19d92015-05-07 15:44:20 -07001302//
Colin Crosscfad1192015-11-02 16:43:11 -08001303// Defaults
1304//
Colin Crossca860ac2016-01-04 14:34:37 -08001305type Defaults struct {
Colin Cross635c3b02016-05-18 15:37:25 -07001306 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -07001307 android.DefaultsModuleBase
Colin Crosscfad1192015-11-02 16:43:11 -08001308}
1309
Colin Cross635c3b02016-05-18 15:37:25 -07001310func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crosscfad1192015-11-02 16:43:11 -08001311}
1312
Colin Cross1e676be2016-10-12 14:38:15 -07001313func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
1314}
1315
Colin Cross36242852017-06-23 15:06:31 -07001316func defaultsFactory() android.Module {
Colin Crosse1d764e2016-08-18 14:18:32 -07001317 return DefaultsFactory()
1318}
1319
Colin Cross36242852017-06-23 15:06:31 -07001320func DefaultsFactory(props ...interface{}) android.Module {
Colin Crossca860ac2016-01-04 14:34:37 -08001321 module := &Defaults{}
Colin Crosscfad1192015-11-02 16:43:11 -08001322
Colin Cross36242852017-06-23 15:06:31 -07001323 module.AddProperties(props...)
1324 module.AddProperties(
Colin Crossca860ac2016-01-04 14:34:37 -08001325 &BaseProperties{},
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001326 &VendorProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001327 &BaseCompilerProperties{},
1328 &BaseLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001329 &LibraryProperties{},
Colin Cross919281a2016-04-05 16:42:05 -07001330 &FlagExporterProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001331 &BinaryLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001332 &TestProperties{},
1333 &TestBinaryProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001334 &UnusedProperties{},
1335 &StlProperties{},
Colin Cross16b23492016-01-06 14:41:07 -08001336 &SanitizeProperties{},
Colin Cross665dce92016-04-28 14:50:03 -07001337 &StripProperties{},
Dan Willemsen7424d612016-09-01 13:45:39 -07001338 &InstallerProperties{},
Dan Willemsena03cf6d2016-09-26 15:45:04 -07001339 &TidyProperties{},
Dan Willemsen581341d2017-02-09 16:16:31 -08001340 &CoverageProperties{},
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001341 &SAbiProperties{},
Justin Yun4b2382f2017-07-26 14:22:10 +09001342 &VndkProperties{},
Stephen Craneba090d12017-05-09 15:44:35 -07001343 &LTOProperties{},
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001344 &PgoProperties{},
Colin Crosse1d764e2016-08-18 14:18:32 -07001345 )
Colin Crosscfad1192015-11-02 16:43:11 -08001346
Colin Cross1f44a3a2017-07-07 14:33:33 -07001347 android.InitDefaultsModule(module)
Colin Cross36242852017-06-23 15:06:31 -07001348
1349 return module
Colin Crosscfad1192015-11-02 16:43:11 -08001350}
1351
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001352const (
1353 // coreMode is the variant used for framework-private libraries, or
1354 // SDK libraries. (which framework-private libraries can use)
1355 coreMode = "core"
1356
1357 // vendorMode is the variant used for /vendor code that compiles
1358 // against the VNDK.
1359 vendorMode = "vendor"
1360)
1361
Jiyong Park6a43f042017-10-12 23:05:00 +09001362func squashVendorSrcs(m *Module) {
1363 if lib, ok := m.compiler.(*libraryDecorator); ok {
1364 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
1365 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
1366
1367 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
1368 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
1369 }
1370}
1371
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001372func vendorMutator(mctx android.BottomUpMutatorContext) {
1373 if mctx.Os() != android.Android {
1374 return
1375 }
1376
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001377 if genrule, ok := mctx.Module().(*genrule.Module); ok {
1378 if props, ok := genrule.Extra.(*VendorProperties); ok {
Justin Yun71549282017-11-17 12:10:28 +09001379 if mctx.DeviceConfig().VndkVersion() == "" {
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001380 mctx.CreateVariations(coreMode)
1381 } else if Bool(props.Vendor_available) {
1382 mctx.CreateVariations(coreMode, vendorMode)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001383 } else if mctx.InstallOnVendorPartition() {
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001384 mctx.CreateVariations(vendorMode)
1385 } else {
1386 mctx.CreateVariations(coreMode)
1387 }
1388 }
1389 }
1390
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001391 m, ok := mctx.Module().(*Module)
1392 if !ok {
1393 return
1394 }
1395
1396 // Sanity check
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001397 if m.VendorProperties.Vendor_available != nil && mctx.InstallOnVendorPartition() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001398 mctx.PropertyErrorf("vendor_available",
1399 "doesn't make sense at the same time as `vendor: true` or `proprietary: true`")
1400 return
1401 }
Justin Yun8effde42017-06-23 19:24:43 +09001402 if vndk := m.vndkdep; vndk != nil {
Jiyong Park82e2bf32017-08-16 14:05:54 +09001403 if vndk.isVndk() && m.VendorProperties.Vendor_available == nil {
Justin Yun8effde42017-06-23 19:24:43 +09001404 mctx.PropertyErrorf("vndk",
Jiyong Park82e2bf32017-08-16 14:05:54 +09001405 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
Justin Yun8effde42017-06-23 19:24:43 +09001406 return
1407 }
1408 if !vndk.isVndk() && vndk.isVndkSp() {
1409 mctx.PropertyErrorf("vndk",
1410 "must set `enabled: true` to set `support_system_process: true`")
1411 return
1412 }
1413 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001414
Justin Yun71549282017-11-17 12:10:28 +09001415 if mctx.DeviceConfig().VndkVersion() == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001416 // If the device isn't compiling against the VNDK, we always
1417 // use the core mode.
1418 mctx.CreateVariations(coreMode)
1419 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
1420 // LL-NDK stubs only exist in the vendor variant, since the
1421 // real libraries will be used in the core variant.
1422 mctx.CreateVariations(vendorMode)
Jiyong Park2a454122017-10-19 15:59:33 +09001423 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
1424 // ... and LL-NDK headers as well
Jiyong Parka46a4d52017-12-14 19:54:34 +09001425 mod := mctx.CreateVariations(vendorMode)
1426 vendor := mod[0].(*Module)
1427 vendor.Properties.UseVndk = true
Justin Yun71549282017-11-17 12:10:28 +09001428 } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
1429 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
1430 // PRODUCT_EXTRA_VNDK_VERSIONS.
1431 mod := mctx.CreateVariations(vendorMode)
1432 vendor := mod[0].(*Module)
1433 vendor.Properties.UseVndk = true
Jiyong Park82e2bf32017-08-16 14:05:54 +09001434 } else if m.hasVendorVariant() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001435 // This will be available in both /system and /vendor
Justin Yun8effde42017-06-23 19:24:43 +09001436 // or a /system directory that is available to vendor.
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001437 mod := mctx.CreateVariations(coreMode, vendorMode)
Jiyong Park6a43f042017-10-12 23:05:00 +09001438 vendor := mod[1].(*Module)
1439 vendor.Properties.UseVndk = true
1440 squashVendorSrcs(vendor)
Nan Zhang0007d812017-11-07 10:57:05 -08001441 } else if mctx.InstallOnVendorPartition() && String(m.Properties.Sdk_version) == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001442 // This will be available in /vendor only
1443 mod := mctx.CreateVariations(vendorMode)
Jiyong Park6a43f042017-10-12 23:05:00 +09001444 vendor := mod[0].(*Module)
1445 vendor.Properties.UseVndk = true
1446 squashVendorSrcs(vendor)
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001447 } else {
1448 // This is either in /system (or similar: /data), or is a
1449 // modules built with the NDK. Modules built with the NDK
1450 // will be restricted using the existing link type checks.
1451 mctx.CreateVariations(coreMode)
1452 }
1453}
1454
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001455func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
Colin Cross6510f912017-11-29 00:27:14 -08001456 if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001457 return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
1458 }
Colin Cross6510f912017-11-29 00:27:14 -08001459 return ctx.Config().PlatformSdkVersion()
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001460}
1461
Colin Cross06a931b2015-10-28 17:23:31 -07001462var Bool = proptools.Bool
Nan Zhang0007d812017-11-07 10:57:05 -08001463var BoolPtr = proptools.BoolPtr
1464var String = proptools.String
1465var StringPtr = proptools.StringPtr