blob: 6e285225ae73939bce03adb00a7522ce39a7f6fe [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
Joe Onorato09e94ab2017-11-18 18:23:14 -0800119 protoOutParams []string // Flags that modify the output of proto generated files
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700120 aidlFlags []string // Flags that apply to aidl source files
121 rsFlags []string // Flags that apply to renderscript source files
122 LdFlags []string // Flags that apply to linker command lines
123 libFlags []string // Flags to add libraries early to the link order
124 TidyFlags []string // Flags that apply to clang-tidy
125 SAbiFlags []string // Flags that apply to header-abi-dumper
126 YasmFlags []string // Flags that apply to yasm assembly source files
Colin Cross28344522015-04-22 13:07:53 -0700127
Colin Crossc3199482017-03-30 15:03:04 -0700128 // Global include flags that apply to C, C++, and assembly source files
129 // These must be after any module include flags, which will be in GlobalFlags.
130 SystemIncludeFlags []string
131
Colin Crossb98c8b02016-07-29 13:44:28 -0700132 Toolchain config.Toolchain
Colin Cross28344522015-04-22 13:07:53 -0700133 Clang bool
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700134 Tidy bool
Dan Willemsen581341d2017-02-09 16:16:31 -0800135 Coverage bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800136 SAbiDump bool
Colin Crossca860ac2016-01-04 14:34:37 -0800137
138 RequiredInstructionSet string
Colin Cross16b23492016-01-06 14:41:07 -0800139 DynamicLinker string
140
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700141 CFlagsDeps android.Paths // Files depended on by compiler flags
142 LdFlagsDeps android.Paths // Files depended on by linker flags
Colin Cross18c0c5a2016-12-01 14:45:23 -0800143
144 GroupStaticLibs bool
Colin Crossc472d572015-03-17 15:06:21 -0700145}
146
Colin Cross81413472016-04-11 14:37:39 -0700147type ObjectLinkerProperties struct {
148 // names of other cc_object modules to link into this module using partial linking
149 Objs []string `android:"arch_variant"`
Dan Willemsenefb1dd92017-09-18 22:47:20 -0700150
151 // if set, add an extra objcopy --prefix-symbols= step
Nan Zhang0007d812017-11-07 10:57:05 -0800152 Prefix_symbols *string
Colin Cross81413472016-04-11 14:37:39 -0700153}
154
Colin Crossca860ac2016-01-04 14:34:37 -0800155// Properties used to compile all C or C++ modules
156type BaseProperties struct {
157 // compile module with clang instead of gcc
158 Clang *bool `android:"arch_variant"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700159
160 // Minimum sdk version supported when compiling against the ndk
Nan Zhang0007d812017-11-07 10:57:05 -0800161 Sdk_version *string
Colin Cross7d5136f2015-05-11 13:39:40 -0700162
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700163 AndroidMkSharedLibs []string `blueprint:"mutated"`
164 HideFromMake bool `blueprint:"mutated"`
165 PreventInstall bool `blueprint:"mutated"`
166
167 UseVndk bool `blueprint:"mutated"`
Colin Cross5beccee2017-12-07 15:28:59 -0800168
169 // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
170 // file
171 Logtags []string
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700172}
173
174type VendorProperties struct {
Jiyong Park82e2bf32017-08-16 14:05:54 +0900175 // whether this module should be allowed to be directly depended by other
176 // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`.
177 // If set to true, two variants will be built separately, one like
178 // normal, and the other limited to the set of libraries and headers
179 // that are exposed to /vendor modules.
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700180 //
181 // The vendor variant may be used with a different (newer) /system,
182 // so it shouldn't have any unversioned runtime dependencies, or
183 // make assumptions about the system that may not be true in the
184 // future.
185 //
Jiyong Park82e2bf32017-08-16 14:05:54 +0900186 // If set to false, this module becomes inaccessible from /vendor modules.
187 //
188 // Default value is true when vndk: {enabled: true} or vendor: true.
189 //
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700190 // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk
191 Vendor_available *bool
Colin Crossca860ac2016-01-04 14:34:37 -0800192}
193
Colin Crossca860ac2016-01-04 14:34:37 -0800194type UnusedProperties struct {
Dan Willemsen581341d2017-02-09 16:16:31 -0800195 Tags []string
Colin Crosscfad1192015-11-02 16:43:11 -0800196}
197
Colin Crossca860ac2016-01-04 14:34:37 -0800198type ModuleContextIntf interface {
Colin Crossca860ac2016-01-04 14:34:37 -0800199 static() bool
200 staticBinary() bool
201 clang() bool
Colin Crossb98c8b02016-07-29 13:44:28 -0700202 toolchain() config.Toolchain
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700203 useSdk() bool
Colin Crossca860ac2016-01-04 14:34:37 -0800204 sdkVersion() string
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700205 useVndk() bool
Justin Yun8effde42017-06-23 19:24:43 +0900206 isVndk() bool
207 isVndkSp() bool
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800208 createVndkSourceAbiDump() bool
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700209 selectedStl() string
Colin Crossce75d2c2016-10-06 16:12:58 -0700210 baseModuleName() string
Colin Crossca860ac2016-01-04 14:34:37 -0800211}
212
213type ModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700214 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800215 ModuleContextIntf
216}
217
218type BaseModuleContext interface {
Colin Cross635c3b02016-05-18 15:37:25 -0700219 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800220 ModuleContextIntf
221}
222
Colin Cross37047f12016-12-13 17:06:13 -0800223type DepsContext interface {
224 android.BottomUpMutatorContext
225 ModuleContextIntf
226}
227
Colin Crossca860ac2016-01-04 14:34:37 -0800228type feature interface {
229 begin(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800230 deps(ctx DepsContext, deps Deps) Deps
Colin Crossca860ac2016-01-04 14:34:37 -0800231 flags(ctx ModuleContext, flags Flags) Flags
232 props() []interface{}
233}
234
235type compiler interface {
Colin Cross42742b82016-08-01 13:20:05 -0700236 compilerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800237 compilerDeps(ctx DepsContext, deps Deps) Deps
Colin Crossf18e1102017-11-16 14:33:08 -0800238 compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags
Colin Cross42742b82016-08-01 13:20:05 -0700239 compilerProps() []interface{}
240
Colin Cross76fada02016-07-27 10:31:13 -0700241 appendCflags([]string)
242 appendAsflags([]string)
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700243 compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800244}
245
246type linker interface {
Colin Cross42742b82016-08-01 13:20:05 -0700247 linkerInit(ctx BaseModuleContext)
Colin Cross37047f12016-12-13 17:06:13 -0800248 linkerDeps(ctx DepsContext, deps Deps) Deps
Colin Cross42742b82016-08-01 13:20:05 -0700249 linkerFlags(ctx ModuleContext, flags Flags) Flags
250 linkerProps() []interface{}
251
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700252 link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path
Colin Cross76fada02016-07-27 10:31:13 -0700253 appendLdflags([]string)
Colin Crossca860ac2016-01-04 14:34:37 -0800254}
255
256type installer interface {
Colin Cross42742b82016-08-01 13:20:05 -0700257 installerProps() []interface{}
Colin Cross635c3b02016-05-18 15:37:25 -0700258 install(ctx ModuleContext, path android.Path)
Colin Crossca860ac2016-01-04 14:34:37 -0800259 inData() bool
Vishwath Mohan1dd88392017-03-29 22:00:18 -0700260 inSanitizerDir() bool
Dan Willemsen4aa75ca2016-09-28 16:18:03 -0700261 hostToolPath() android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800262}
263
Colin Crossc99deeb2016-04-11 15:06:20 -0700264type dependencyTag struct {
265 blueprint.BaseDependencyTag
266 name string
267 library bool
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700268
269 reexportFlags bool
Colin Crossc99deeb2016-04-11 15:06:20 -0700270}
271
272var (
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700273 sharedDepTag = dependencyTag{name: "shared", library: true}
274 sharedExportDepTag = dependencyTag{name: "shared", library: true, reexportFlags: true}
275 lateSharedDepTag = dependencyTag{name: "late shared", library: true}
276 staticDepTag = dependencyTag{name: "static", library: true}
277 staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true}
278 lateStaticDepTag = dependencyTag{name: "late static", library: true}
279 wholeStaticDepTag = dependencyTag{name: "whole static", library: true, reexportFlags: true}
Colin Cross32ec36c2016-12-15 07:39:51 -0800280 headerDepTag = dependencyTag{name: "header", library: true}
281 headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700282 genSourceDepTag = dependencyTag{name: "gen source"}
283 genHeaderDepTag = dependencyTag{name: "gen header"}
284 genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
285 objDepTag = dependencyTag{name: "obj"}
286 crtBeginDepTag = dependencyTag{name: "crtbegin"}
287 crtEndDepTag = dependencyTag{name: "crtend"}
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700288 linkerScriptDepTag = dependencyTag{name: "linker script"}
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700289 reuseObjTag = dependencyTag{name: "reuse objects"}
290 ndkStubDepTag = dependencyTag{name: "ndk stub", library: true}
291 ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true}
Colin Crossc99deeb2016-04-11 15:06:20 -0700292)
293
Colin Crossca860ac2016-01-04 14:34:37 -0800294// Module contains the properties and members used by all C/C++ module types, and implements
295// the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces
296// to construct the output file. Behavior can be customized with a Customizer interface
297type Module struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700298 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -0700299 android.DefaultableModuleBase
Colin Crossc472d572015-03-17 15:06:21 -0700300
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700301 Properties BaseProperties
302 VendorProperties VendorProperties
303 unused UnusedProperties
Colin Crossfa138792015-04-24 17:31:52 -0700304
Colin Crossca860ac2016-01-04 14:34:37 -0800305 // initialize before calling Init
Colin Cross635c3b02016-05-18 15:37:25 -0700306 hod android.HostOrDeviceSupported
307 multilib android.Multilib
Colin Crossc472d572015-03-17 15:06:21 -0700308
Colin Crossca860ac2016-01-04 14:34:37 -0800309 // delegates, initialize before calling Init
Colin Crossb4ce0ec2016-09-13 13:41:39 -0700310 features []feature
311 compiler compiler
312 linker linker
313 installer installer
314 stl *stl
315 sanitize *sanitize
Dan Willemsen581341d2017-02-09 16:16:31 -0800316 coverage *coverage
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800317 sabi *sabi
Justin Yun8effde42017-06-23 19:24:43 +0900318 vndkdep *vndkdep
Stephen Craneba090d12017-05-09 15:44:35 -0700319 lto *lto
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700320 pgo *pgo
Colin Cross16b23492016-01-06 14:41:07 -0800321
322 androidMkSharedLibDeps []string
Colin Cross74d1ec02015-04-28 13:30:13 -0700323
Colin Cross635c3b02016-05-18 15:37:25 -0700324 outputFile android.OptionalPath
Colin Crossca860ac2016-01-04 14:34:37 -0800325
Colin Crossb98c8b02016-07-29 13:44:28 -0700326 cachedToolchain config.Toolchain
Colin Crossb916a382016-07-29 17:28:03 -0700327
328 subAndroidMkOnce map[subAndroidMkProvider]bool
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800329
330 // Flags used to compile this module
331 flags Flags
Jeff Gaston294356f2017-09-27 17:05:30 -0700332
333 // 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 -0800334 // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive
Jeff Gaston294356f2017-09-27 17:05:30 -0700335 // deps of this module
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800336 depsInLinkOrder android.Paths
337
338 // only non-nil when this is a shared library that reuses the objects of a static library
339 staticVariant *Module
Colin Crossc472d572015-03-17 15:06:21 -0700340}
341
Colin Cross36242852017-06-23 15:06:31 -0700342func (c *Module) Init() android.Module {
Dan Willemsen3e5bdf22017-09-13 18:37:08 -0700343 c.AddProperties(&c.Properties, &c.VendorProperties, &c.unused)
Colin Crossca860ac2016-01-04 14:34:37 -0800344 if c.compiler != nil {
Colin Cross36242852017-06-23 15:06:31 -0700345 c.AddProperties(c.compiler.compilerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800346 }
347 if c.linker != nil {
Colin Cross36242852017-06-23 15:06:31 -0700348 c.AddProperties(c.linker.linkerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800349 }
350 if c.installer != nil {
Colin Cross36242852017-06-23 15:06:31 -0700351 c.AddProperties(c.installer.installerProps()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800352 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700353 if c.stl != nil {
Colin Cross36242852017-06-23 15:06:31 -0700354 c.AddProperties(c.stl.props()...)
Colin Crossa8e07cc2016-04-04 15:07:06 -0700355 }
Colin Cross16b23492016-01-06 14:41:07 -0800356 if c.sanitize != nil {
Colin Cross36242852017-06-23 15:06:31 -0700357 c.AddProperties(c.sanitize.props()...)
Colin Cross16b23492016-01-06 14:41:07 -0800358 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800359 if c.coverage != nil {
Colin Cross36242852017-06-23 15:06:31 -0700360 c.AddProperties(c.coverage.props()...)
Dan Willemsen581341d2017-02-09 16:16:31 -0800361 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800362 if c.sabi != nil {
Colin Cross36242852017-06-23 15:06:31 -0700363 c.AddProperties(c.sabi.props()...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800364 }
Justin Yun8effde42017-06-23 19:24:43 +0900365 if c.vndkdep != nil {
366 c.AddProperties(c.vndkdep.props()...)
367 }
Stephen Craneba090d12017-05-09 15:44:35 -0700368 if c.lto != nil {
369 c.AddProperties(c.lto.props()...)
370 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700371 if c.pgo != nil {
372 c.AddProperties(c.pgo.props()...)
373 }
Colin Crossca860ac2016-01-04 14:34:37 -0800374 for _, feature := range c.features {
Colin Cross36242852017-06-23 15:06:31 -0700375 c.AddProperties(feature.props()...)
Colin Crossca860ac2016-01-04 14:34:37 -0800376 }
Colin Crossc472d572015-03-17 15:06:21 -0700377
Colin Cross36242852017-06-23 15:06:31 -0700378 android.InitAndroidArchModule(c, c.hod, c.multilib)
Colin Crossc472d572015-03-17 15:06:21 -0700379
Colin Cross1f44a3a2017-07-07 14:33:33 -0700380 android.InitDefaultableModule(c)
Colin Cross36242852017-06-23 15:06:31 -0700381
382 return c
Colin Crossc472d572015-03-17 15:06:21 -0700383}
384
Colin Crossb916a382016-07-29 17:28:03 -0700385// Returns true for dependency roots (binaries)
386// TODO(ccross): also handle dlopenable libraries
387func (c *Module) isDependencyRoot() bool {
388 if root, ok := c.linker.(interface {
389 isDependencyRoot() bool
390 }); ok {
391 return root.isDependencyRoot()
392 }
393 return false
394}
395
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700396func (c *Module) useVndk() bool {
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700397 return c.Properties.UseVndk
398}
399
Justin Yun8effde42017-06-23 19:24:43 +0900400func (c *Module) isVndk() bool {
401 if c.vndkdep != nil {
402 return c.vndkdep.isVndk()
403 }
404 return false
405}
406
Jiyong Park82e2bf32017-08-16 14:05:54 +0900407// Returns true only when this module is configured to have core and vendor
408// variants.
409func (c *Module) hasVendorVariant() bool {
410 return c.isVndk() || Bool(c.VendorProperties.Vendor_available)
411}
412
Colin Crossca860ac2016-01-04 14:34:37 -0800413type baseModuleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700414 android.BaseContext
Colin Crossca860ac2016-01-04 14:34:37 -0800415 moduleContextImpl
416}
417
Colin Cross37047f12016-12-13 17:06:13 -0800418type depsContext struct {
419 android.BottomUpMutatorContext
420 moduleContextImpl
421}
422
Colin Crossca860ac2016-01-04 14:34:37 -0800423type moduleContext struct {
Colin Cross635c3b02016-05-18 15:37:25 -0700424 android.ModuleContext
Colin Crossca860ac2016-01-04 14:34:37 -0800425 moduleContextImpl
426}
427
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700428func (ctx *moduleContext) InstallOnVendorPartition() bool {
429 return ctx.ModuleContext.InstallOnVendorPartition() || (ctx.mod.useVndk() && !ctx.mod.isVndk())
Dan Willemsen4416e5d2017-04-06 12:43:22 -0700430}
431
Colin Crossca860ac2016-01-04 14:34:37 -0800432type moduleContextImpl struct {
433 mod *Module
434 ctx BaseModuleContext
435}
436
Colin Crossca860ac2016-01-04 14:34:37 -0800437func (ctx *moduleContextImpl) clang() bool {
438 return ctx.mod.clang(ctx.ctx)
439}
440
Colin Crossb98c8b02016-07-29 13:44:28 -0700441func (ctx *moduleContextImpl) toolchain() config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800442 return ctx.mod.toolchain(ctx.ctx)
443}
444
445func (ctx *moduleContextImpl) static() bool {
Vishwath Mohanb743e9c2017-11-01 09:20:21 +0000446 return ctx.mod.static()
Colin Crossca860ac2016-01-04 14:34:37 -0800447}
448
449func (ctx *moduleContextImpl) staticBinary() bool {
Colin Crossb916a382016-07-29 17:28:03 -0700450 if static, ok := ctx.mod.linker.(interface {
451 staticBinary() bool
452 }); ok {
453 return static.staticBinary()
Colin Crossca860ac2016-01-04 14:34:37 -0800454 }
Colin Crossb916a382016-07-29 17:28:03 -0700455 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800456}
457
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700458func (ctx *moduleContextImpl) useSdk() bool {
459 if ctx.ctx.Device() && !ctx.useVndk() {
Nan Zhang0007d812017-11-07 10:57:05 -0800460 return String(ctx.mod.Properties.Sdk_version) != ""
Dan Willemsena96ff642016-06-07 12:34:45 -0700461 }
462 return false
Colin Crossca860ac2016-01-04 14:34:37 -0800463}
464
465func (ctx *moduleContextImpl) sdkVersion() string {
Dan Willemsena96ff642016-06-07 12:34:45 -0700466 if ctx.ctx.Device() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700467 if ctx.useVndk() {
Dan Willemsen11b26142017-03-19 18:30:37 -0700468 return "current"
Dan Willemsend2ede872016-11-18 14:54:24 -0800469 } else {
Nan Zhang0007d812017-11-07 10:57:05 -0800470 return String(ctx.mod.Properties.Sdk_version)
Dan Willemsend2ede872016-11-18 14:54:24 -0800471 }
Dan Willemsena96ff642016-06-07 12:34:45 -0700472 }
473 return ""
Colin Crossca860ac2016-01-04 14:34:37 -0800474}
475
Justin Yun8effde42017-06-23 19:24:43 +0900476func (ctx *moduleContextImpl) isVndk() bool {
477 return ctx.mod.isVndk()
478}
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700479func (ctx *moduleContextImpl) useVndk() bool {
480 return ctx.mod.useVndk()
481}
Justin Yun8effde42017-06-23 19:24:43 +0900482
483func (ctx *moduleContextImpl) isVndkSp() bool {
484 if vndk := ctx.mod.vndkdep; vndk != nil {
485 return vndk.isVndkSp()
486 }
487 return false
488}
489
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800490// Create source abi dumps if the module belongs to the list of VndkLibraries.
491func (ctx *moduleContextImpl) createVndkSourceAbiDump() bool {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700492 return ctx.ctx.Device() && ((ctx.useVndk() && ctx.isVndk()) || inList(ctx.baseModuleName(), llndkLibraries))
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800493}
494
Dan Willemsen8146b2f2016-03-30 21:00:30 -0700495func (ctx *moduleContextImpl) selectedStl() string {
496 if stl := ctx.mod.stl; stl != nil {
497 return stl.Properties.SelectedStl
498 }
499 return ""
500}
501
Colin Crossce75d2c2016-10-06 16:12:58 -0700502func (ctx *moduleContextImpl) baseModuleName() string {
503 return ctx.mod.ModuleBase.BaseModuleName()
504}
505
Colin Cross635c3b02016-05-18 15:37:25 -0700506func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800507 return &Module{
508 hod: hod,
509 multilib: multilib,
510 }
511}
512
Colin Cross635c3b02016-05-18 15:37:25 -0700513func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
Colin Crossca860ac2016-01-04 14:34:37 -0800514 module := newBaseModule(hod, multilib)
Dan Willemsena03cf6d2016-09-26 15:45:04 -0700515 module.features = []feature{
516 &tidyFeature{},
517 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700518 module.stl = &stl{}
Colin Cross16b23492016-01-06 14:41:07 -0800519 module.sanitize = &sanitize{}
Dan Willemsen581341d2017-02-09 16:16:31 -0800520 module.coverage = &coverage{}
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800521 module.sabi = &sabi{}
Justin Yun8effde42017-06-23 19:24:43 +0900522 module.vndkdep = &vndkdep{}
Stephen Craneba090d12017-05-09 15:44:35 -0700523 module.lto = &lto{}
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700524 module.pgo = &pgo{}
Colin Crossca860ac2016-01-04 14:34:37 -0800525 return module
526}
527
Colin Crossce75d2c2016-10-06 16:12:58 -0700528func (c *Module) Prebuilt() *android.Prebuilt {
529 if p, ok := c.linker.(prebuiltLinkerInterface); ok {
530 return p.prebuilt()
531 }
532 return nil
533}
534
535func (c *Module) Name() string {
536 name := c.ModuleBase.Name()
Dan Willemsen01a90592017-04-07 15:21:13 -0700537 if p, ok := c.linker.(interface {
538 Name(string) string
539 }); ok {
Colin Crossce75d2c2016-10-06 16:12:58 -0700540 name = p.Name(name)
541 }
542 return name
543}
544
Jeff Gaston294356f2017-09-27 17:05:30 -0700545// orderDeps reorders dependencies into a list such that if module A depends on B, then
546// A will precede B in the resultant list.
547// This is convenient for passing into a linker.
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800548// Note that directSharedDeps should be the analogous static library for each shared lib dep
549func 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 -0700550 // If A depends on B, then
551 // Every list containing A will also contain B later in the list
552 // So, after concatenating all lists, the final instance of B will have come from the same
553 // original list as the final instance of A
554 // So, the final instance of B will be later in the concatenation than the final A
555 // So, keeping only the final instance of A and of B ensures that A is earlier in the output
556 // list than B
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800557 for _, dep := range directStaticDeps {
Jeff Gaston294356f2017-09-27 17:05:30 -0700558 orderedAllDeps = append(orderedAllDeps, dep)
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800559 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
560 }
561 for _, dep := range directSharedDeps {
562 orderedAllDeps = append(orderedAllDeps, dep)
563 orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...)
Jeff Gaston294356f2017-09-27 17:05:30 -0700564 }
565
Colin Crossb6715442017-10-24 11:13:31 -0700566 orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700567
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800568 // We don't want to add any new dependencies into directStaticDeps (to allow the caller to
Jeff Gaston294356f2017-09-27 17:05:30 -0700569 // intentionally exclude or replace any unwanted transitive dependencies), so we limit the
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800570 // resultant list to only what the caller has chosen to include in directStaticDeps
571 _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700572
573 return orderedAllDeps, orderedDeclaredDeps
574}
575
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800576func orderStaticModuleDeps(module *Module, staticDeps []*Module, sharedDeps []*Module) (results []android.Path) {
577 // convert Module to Path
578 allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps))
579 staticDepFiles := []android.Path{}
580 for _, dep := range staticDeps {
581 allTransitiveDeps[dep.outputFile.Path()] = dep.depsInLinkOrder
582 staticDepFiles = append(staticDepFiles, dep.outputFile.Path())
Jeff Gaston294356f2017-09-27 17:05:30 -0700583 }
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800584 sharedDepFiles := []android.Path{}
585 for _, sharedDep := range sharedDeps {
586 staticAnalogue := sharedDep.staticVariant
587 if staticAnalogue != nil {
588 allTransitiveDeps[staticAnalogue.outputFile.Path()] = staticAnalogue.depsInLinkOrder
589 sharedDepFiles = append(sharedDepFiles, staticAnalogue.outputFile.Path())
590 }
Jeff Gaston294356f2017-09-27 17:05:30 -0700591 }
592
593 // reorder the dependencies based on transitive dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -0800594 module.depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps)
Jeff Gaston294356f2017-09-27 17:05:30 -0700595
596 return results
Jeff Gaston294356f2017-09-27 17:05:30 -0700597}
598
Colin Cross635c3b02016-05-18 15:37:25 -0700599func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700600
Colin Crossca860ac2016-01-04 14:34:37 -0800601 ctx := &moduleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700602 ModuleContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800603 moduleContextImpl: moduleContextImpl{
604 mod: c,
605 },
606 }
607 ctx.ctx = ctx
608
Colin Crossf18e1102017-11-16 14:33:08 -0800609 deps := c.depsToPaths(ctx)
610 if ctx.Failed() {
611 return
612 }
613
Colin Crossca860ac2016-01-04 14:34:37 -0800614 flags := Flags{
615 Toolchain: c.toolchain(ctx),
616 Clang: c.clang(ctx),
617 }
Colin Crossca860ac2016-01-04 14:34:37 -0800618 if c.compiler != nil {
Colin Crossf18e1102017-11-16 14:33:08 -0800619 flags = c.compiler.compilerFlags(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800620 }
621 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700622 flags = c.linker.linkerFlags(ctx, flags)
Colin Crossca860ac2016-01-04 14:34:37 -0800623 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700624 if c.stl != nil {
625 flags = c.stl.flags(ctx, flags)
626 }
Colin Cross16b23492016-01-06 14:41:07 -0800627 if c.sanitize != nil {
628 flags = c.sanitize.flags(ctx, flags)
629 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800630 if c.coverage != nil {
631 flags = c.coverage.flags(ctx, flags)
632 }
Stephen Craneba090d12017-05-09 15:44:35 -0700633 if c.lto != nil {
634 flags = c.lto.flags(ctx, flags)
635 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700636 if c.pgo != nil {
637 flags = c.pgo.flags(ctx, flags)
638 }
Colin Crossca860ac2016-01-04 14:34:37 -0800639 for _, feature := range c.features {
640 flags = feature.flags(ctx, flags)
641 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800642 if ctx.Failed() {
643 return
644 }
645
Colin Crossb98c8b02016-07-29 13:44:28 -0700646 flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags)
647 flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags)
648 flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags)
Colin Cross3f40fa42015-01-30 17:27:36 -0800649
Fabien Sanglardd61f1f42017-01-10 16:21:22 -0800650 flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
651 c.flags = flags
Jayant Chowdhary9677e8c2017-06-15 14:45:18 -0700652 // We need access to all the flags seen by a source file.
653 if c.sabi != nil {
654 flags = c.sabi.flags(ctx, flags)
655 }
Colin Crossca860ac2016-01-04 14:34:37 -0800656 // Optimization to reduce size of build.ninja
657 // Replace the long list of flags for each file with a module-local variable
658 ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
659 ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " "))
660 ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " "))
661 flags.CFlags = []string{"$cflags"}
662 flags.CppFlags = []string{"$cppflags"}
663 flags.AsFlags = []string{"$asflags"}
664
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700665 var objs Objects
Colin Crossca860ac2016-01-04 14:34:37 -0800666 if c.compiler != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700667 objs = c.compiler.compile(ctx, flags, deps)
Colin Crossca860ac2016-01-04 14:34:37 -0800668 if ctx.Failed() {
669 return
670 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800671 }
672
Colin Crossca860ac2016-01-04 14:34:37 -0800673 if c.linker != nil {
Dan Willemsen5cb580f2016-09-26 17:33:01 -0700674 outputFile := c.linker.link(ctx, flags, deps, objs)
Colin Crossca860ac2016-01-04 14:34:37 -0800675 if ctx.Failed() {
676 return
677 }
Colin Cross635c3b02016-05-18 15:37:25 -0700678 c.outputFile = android.OptionalPathForPath(outputFile)
Colin Crossce75d2c2016-10-06 16:12:58 -0700679 }
Colin Cross5049f022015-03-18 13:28:46 -0700680
Colin Crossce75d2c2016-10-06 16:12:58 -0700681 if c.installer != nil && !c.Properties.PreventInstall && c.outputFile.Valid() {
682 c.installer.install(ctx, c.outputFile.Path())
683 if ctx.Failed() {
684 return
Colin Crossca860ac2016-01-04 14:34:37 -0800685 }
Dan Albertc403f7c2015-03-18 14:01:18 -0700686 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800687}
688
Colin Crossb98c8b02016-07-29 13:44:28 -0700689func (c *Module) toolchain(ctx BaseModuleContext) config.Toolchain {
Colin Crossca860ac2016-01-04 14:34:37 -0800690 if c.cachedToolchain == nil {
Colin Crossb98c8b02016-07-29 13:44:28 -0700691 c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
Colin Cross3f40fa42015-01-30 17:27:36 -0800692 }
Colin Crossca860ac2016-01-04 14:34:37 -0800693 return c.cachedToolchain
Colin Cross3f40fa42015-01-30 17:27:36 -0800694}
695
Colin Crossca860ac2016-01-04 14:34:37 -0800696func (c *Module) begin(ctx BaseModuleContext) {
697 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700698 c.compiler.compilerInit(ctx)
Colin Cross21b9a242015-03-24 14:15:58 -0700699 }
Colin Crossca860ac2016-01-04 14:34:37 -0800700 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700701 c.linker.linkerInit(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800702 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700703 if c.stl != nil {
704 c.stl.begin(ctx)
705 }
Colin Cross16b23492016-01-06 14:41:07 -0800706 if c.sanitize != nil {
707 c.sanitize.begin(ctx)
708 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800709 if c.coverage != nil {
710 c.coverage.begin(ctx)
711 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800712 if c.sabi != nil {
713 c.sabi.begin(ctx)
714 }
Justin Yun8effde42017-06-23 19:24:43 +0900715 if c.vndkdep != nil {
716 c.vndkdep.begin(ctx)
717 }
Stephen Craneba090d12017-05-09 15:44:35 -0700718 if c.lto != nil {
719 c.lto.begin(ctx)
720 }
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -0700721 if c.pgo != nil {
722 c.pgo.begin(ctx)
723 }
Colin Crossca860ac2016-01-04 14:34:37 -0800724 for _, feature := range c.features {
725 feature.begin(ctx)
726 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700727 if ctx.useSdk() {
Dan Albertf5415d72017-08-17 16:19:59 -0700728 version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch())
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700729 if err != nil {
730 ctx.PropertyErrorf("sdk_version", err.Error())
731 }
Nan Zhang0007d812017-11-07 10:57:05 -0800732 c.Properties.Sdk_version = StringPtr(version)
Dan Albert7fa7b2e2016-08-05 16:37:52 -0700733 }
Colin Crossca860ac2016-01-04 14:34:37 -0800734}
735
Colin Cross37047f12016-12-13 17:06:13 -0800736func (c *Module) deps(ctx DepsContext) Deps {
Colin Crossc99deeb2016-04-11 15:06:20 -0700737 deps := Deps{}
738
739 if c.compiler != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700740 deps = c.compiler.compilerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700741 }
Pirama Arumuga Nainar49b53d52017-10-04 16:47:29 -0700742 // Add the PGO dependency (the clang_rt.profile runtime library), which
743 // sometimes depends on symbols from libgcc, before libgcc gets added
744 // in linkerDeps().
745 if c.pgo != nil {
746 deps = c.pgo.deps(ctx, deps)
747 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700748 if c.linker != nil {
Colin Cross42742b82016-08-01 13:20:05 -0700749 deps = c.linker.linkerDeps(ctx, deps)
Colin Crossc99deeb2016-04-11 15:06:20 -0700750 }
Colin Crossa8e07cc2016-04-04 15:07:06 -0700751 if c.stl != nil {
752 deps = c.stl.deps(ctx, deps)
753 }
Colin Cross16b23492016-01-06 14:41:07 -0800754 if c.sanitize != nil {
755 deps = c.sanitize.deps(ctx, deps)
756 }
Dan Willemsen581341d2017-02-09 16:16:31 -0800757 if c.coverage != nil {
758 deps = c.coverage.deps(ctx, deps)
759 }
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -0800760 if c.sabi != nil {
761 deps = c.sabi.deps(ctx, deps)
762 }
Justin Yun8effde42017-06-23 19:24:43 +0900763 if c.vndkdep != nil {
764 deps = c.vndkdep.deps(ctx, deps)
765 }
Stephen Craneba090d12017-05-09 15:44:35 -0700766 if c.lto != nil {
767 deps = c.lto.deps(ctx, deps)
768 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700769 for _, feature := range c.features {
770 deps = feature.deps(ctx, deps)
771 }
772
Colin Crossb6715442017-10-24 11:13:31 -0700773 deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
774 deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
775 deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
776 deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
777 deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
778 deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
Colin Crossc99deeb2016-04-11 15:06:20 -0700779
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700780 for _, lib := range deps.ReexportSharedLibHeaders {
781 if !inList(lib, deps.SharedLibs) {
782 ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
783 }
784 }
785
786 for _, lib := range deps.ReexportStaticLibHeaders {
787 if !inList(lib, deps.StaticLibs) {
788 ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib)
789 }
790 }
791
Colin Cross5950f382016-12-13 12:50:57 -0800792 for _, lib := range deps.ReexportHeaderLibHeaders {
793 if !inList(lib, deps.HeaderLibs) {
794 ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
795 }
796 }
797
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700798 for _, gen := range deps.ReexportGeneratedHeaders {
799 if !inList(gen, deps.GeneratedHeaders) {
800 ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
801 }
802 }
803
Colin Crossc99deeb2016-04-11 15:06:20 -0700804 return deps
805}
806
Dan Albert7e9d2952016-08-04 13:02:36 -0700807func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
Colin Crossca860ac2016-01-04 14:34:37 -0800808 ctx := &baseModuleContext{
Colin Cross635c3b02016-05-18 15:37:25 -0700809 BaseContext: actx,
Colin Crossca860ac2016-01-04 14:34:37 -0800810 moduleContextImpl: moduleContextImpl{
811 mod: c,
812 },
813 }
814 ctx.ctx = ctx
815
Colin Crossca860ac2016-01-04 14:34:37 -0800816 c.begin(ctx)
Dan Albert7e9d2952016-08-04 13:02:36 -0700817}
818
Colin Cross1e676be2016-10-12 14:38:15 -0700819func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
820 if !c.Enabled() {
821 return
822 }
823
Colin Cross37047f12016-12-13 17:06:13 -0800824 ctx := &depsContext{
825 BottomUpMutatorContext: actx,
Dan Albert7e9d2952016-08-04 13:02:36 -0700826 moduleContextImpl: moduleContextImpl{
827 mod: c,
828 },
829 }
830 ctx.ctx = ctx
Colin Crossca860ac2016-01-04 14:34:37 -0800831
Colin Crossc99deeb2016-04-11 15:06:20 -0700832 deps := c.deps(ctx)
Colin Crossca860ac2016-01-04 14:34:37 -0800833
Dan Albert914449f2016-06-17 16:45:24 -0700834 variantNdkLibs := []string{}
835 variantLateNdkLibs := []string{}
Dan Willemsenb916b802017-03-19 13:44:32 -0700836 if ctx.Os() == android.Android {
Dan Albert914449f2016-06-17 16:45:24 -0700837 version := ctx.sdkVersion()
Dan Willemsen72d39932016-07-08 23:23:48 -0700838
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700839 // rewriteNdkLibs takes a list of names of shared libraries and scans it for three types
840 // of names:
Dan Albert914449f2016-06-17 16:45:24 -0700841 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700842 // 1. Name of an NDK library that refers to a prebuilt module.
843 // For each of these, it adds the name of the prebuilt module (which will be in
844 // prebuilts/ndk) to the list of nonvariant libs.
845 // 2. Name of an NDK library that refers to an ndk_library module.
846 // For each of these, it adds the name of the ndk_library module to the list of
847 // variant libs.
848 // 3. Anything else (so anything that isn't an NDK library).
849 // It adds these to the nonvariantLibs list.
Dan Albert914449f2016-06-17 16:45:24 -0700850 //
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700851 // The caller can then know to add the variantLibs dependencies differently from the
852 // nonvariantLibs
853 rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
854 variantLibs = []string{}
855 nonvariantLibs = []string{}
Dan Albert914449f2016-06-17 16:45:24 -0700856 for _, entry := range list {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700857 if ctx.useSdk() && inList(entry, ndkPrebuiltSharedLibraries) {
Dan Albert914449f2016-06-17 16:45:24 -0700858 if !inList(entry, ndkMigratedLibs) {
859 nonvariantLibs = append(nonvariantLibs, entry+".ndk."+version)
860 } else {
861 variantLibs = append(variantLibs, entry+ndkLibrarySuffix)
862 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700863 } else if ctx.useVndk() && inList(entry, llndkLibraries) {
Dan Willemsenb916b802017-03-19 13:44:32 -0700864 nonvariantLibs = append(nonvariantLibs, entry+llndkLibrarySuffix)
Dan Albert914449f2016-06-17 16:45:24 -0700865 } else {
Dan Willemsen7cbf5f82017-03-28 00:08:30 -0700866 nonvariantLibs = append(nonvariantLibs, entry)
Dan Willemsen72d39932016-07-08 23:23:48 -0700867 }
868 }
Dan Albert914449f2016-06-17 16:45:24 -0700869 return nonvariantLibs, variantLibs
Dan Willemsen72d39932016-07-08 23:23:48 -0700870 }
871
Dan Albert914449f2016-06-17 16:45:24 -0700872 deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs)
873 deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
Jiyong Park4c35af02017-07-05 13:41:55 +0900874 deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
Dan Willemsen72d39932016-07-08 23:23:48 -0700875 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700876
Colin Cross32ec36c2016-12-15 07:39:51 -0800877 for _, lib := range deps.HeaderLibs {
878 depTag := headerDepTag
879 if inList(lib, deps.ReexportHeaderLibHeaders) {
880 depTag = headerExportDepTag
881 }
882 actx.AddVariationDependencies(nil, depTag, lib)
883 }
Colin Cross5950f382016-12-13 12:50:57 -0800884
Colin Crossc99deeb2016-04-11 15:06:20 -0700885 actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, wholeStaticDepTag,
886 deps.WholeStaticLibs...)
887
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700888 for _, lib := range deps.StaticLibs {
889 depTag := staticDepTag
890 if inList(lib, deps.ReexportStaticLibHeaders) {
891 depTag = staticExportDepTag
892 }
Colin Cross15a0d462016-07-14 14:49:58 -0700893 actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700894 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700895
896 actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, lateStaticDepTag,
897 deps.LateStaticLibs...)
898
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700899 for _, lib := range deps.SharedLibs {
900 depTag := sharedDepTag
901 if inList(lib, deps.ReexportSharedLibHeaders) {
902 depTag = sharedExportDepTag
903 }
Colin Cross15a0d462016-07-14 14:49:58 -0700904 actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, depTag, lib)
Dan Willemsen490a8dc2016-06-06 18:22:19 -0700905 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700906
907 actx.AddVariationDependencies([]blueprint.Variation{{"link", "shared"}}, lateSharedDepTag,
908 deps.LateSharedLibs...)
909
Colin Cross68861832016-07-08 10:41:41 -0700910 actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...)
Dan Willemsenb3454ab2016-09-28 17:34:58 -0700911
912 for _, gen := range deps.GeneratedHeaders {
913 depTag := genHeaderDepTag
914 if inList(gen, deps.ReexportGeneratedHeaders) {
915 depTag = genHeaderExportDepTag
916 }
917 actx.AddDependency(c, depTag, gen)
918 }
Dan Willemsenb40aab62016-04-20 14:21:14 -0700919
Colin Cross68861832016-07-08 10:41:41 -0700920 actx.AddDependency(c, objDepTag, deps.ObjFiles...)
Colin Crossc99deeb2016-04-11 15:06:20 -0700921
922 if deps.CrtBegin != "" {
Colin Cross68861832016-07-08 10:41:41 -0700923 actx.AddDependency(c, crtBeginDepTag, deps.CrtBegin)
Colin Crossca860ac2016-01-04 14:34:37 -0800924 }
Colin Crossc99deeb2016-04-11 15:06:20 -0700925 if deps.CrtEnd != "" {
Colin Cross68861832016-07-08 10:41:41 -0700926 actx.AddDependency(c, crtEndDepTag, deps.CrtEnd)
Colin Cross21b9a242015-03-24 14:15:58 -0700927 }
Dan Willemsenc77a0b32017-09-18 23:19:12 -0700928 if deps.LinkerScript != "" {
929 actx.AddDependency(c, linkerScriptDepTag, deps.LinkerScript)
930 }
Dan Albert914449f2016-06-17 16:45:24 -0700931
932 version := ctx.sdkVersion()
933 actx.AddVariationDependencies([]blueprint.Variation{
934 {"ndk_api", version}, {"link", "shared"}}, ndkStubDepTag, variantNdkLibs...)
935 actx.AddVariationDependencies([]blueprint.Variation{
936 {"ndk_api", version}, {"link", "shared"}}, ndkLateStubDepTag, variantLateNdkLibs...)
Colin Cross6362e272015-10-29 15:25:03 -0700937}
Colin Cross21b9a242015-03-24 14:15:58 -0700938
Dan Albert7e9d2952016-08-04 13:02:36 -0700939func beginMutator(ctx android.BottomUpMutatorContext) {
940 if c, ok := ctx.Module().(*Module); ok && c.Enabled() {
941 c.beginMutator(ctx)
942 }
943}
944
Colin Crossca860ac2016-01-04 14:34:37 -0800945func (c *Module) clang(ctx BaseModuleContext) bool {
946 clang := Bool(c.Properties.Clang)
947
948 if c.Properties.Clang == nil {
949 if ctx.Host() {
950 clang = true
951 }
952
Colin Cross6510f912017-11-29 00:27:14 -0800953 if ctx.Device() && ctx.Config().DeviceUsesClang() {
Colin Crossca860ac2016-01-04 14:34:37 -0800954 clang = true
955 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800956 }
Colin Cross28344522015-04-22 13:07:53 -0700957
Colin Crossca860ac2016-01-04 14:34:37 -0800958 if !c.toolchain(ctx).ClangSupported() {
959 clang = false
960 }
961
962 return clang
963}
964
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700965// Whether a module can link to another module, taking into
966// account NDK linking.
967func checkLinkType(ctx android.ModuleContext, from *Module, to *Module) {
968 if from.Target().Os != android.Android {
969 // Host code is not restricted
970 return
971 }
972 if from.Properties.UseVndk {
973 // Though vendor code is limited by the vendor mutator,
974 // each vendor-available module needs to check
975 // link-type for VNDK.
976 if from.vndkdep != nil {
977 from.vndkdep.vndkCheckLinkType(ctx, to)
978 }
979 return
980 }
Nan Zhang0007d812017-11-07 10:57:05 -0800981 if String(from.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -0700982 // Platform code can link to anything
983 return
984 }
985 if _, ok := to.linker.(*toolchainLibraryDecorator); ok {
986 // These are always allowed
987 return
988 }
989 if _, ok := to.linker.(*ndkPrebuiltLibraryLinker); ok {
990 // These are allowed, but they don't set sdk_version
991 return
992 }
993 if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok {
994 // These are allowed, but they don't set sdk_version
995 return
996 }
997 if _, ok := to.linker.(*stubDecorator); ok {
998 // These aren't real libraries, but are the stub shared libraries that are included in
999 // the NDK.
1000 return
1001 }
Nan Zhang0007d812017-11-07 10:57:05 -08001002 if String(to.Properties.Sdk_version) == "" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001003 // NDK code linking to platform code is never okay.
1004 ctx.ModuleErrorf("depends on non-NDK-built library %q",
1005 ctx.OtherModuleName(to))
1006 }
1007
1008 // At this point we know we have two NDK libraries, but we need to
1009 // check that we're not linking against anything built against a higher
1010 // API level, as it is only valid to link against older or equivalent
1011 // APIs.
1012
Nan Zhang0007d812017-11-07 10:57:05 -08001013 if String(from.Properties.Sdk_version) == "current" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001014 // Current can link against anything.
1015 return
Nan Zhang0007d812017-11-07 10:57:05 -08001016 } else if String(to.Properties.Sdk_version) == "current" {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001017 // Current can't be linked against by anything else.
1018 ctx.ModuleErrorf("links %q built against newer API version %q",
1019 ctx.OtherModuleName(to), "current")
1020 }
1021
Nan Zhang0007d812017-11-07 10:57:05 -08001022 fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001023 if err != nil {
1024 ctx.PropertyErrorf("sdk_version",
1025 "Invalid sdk_version value (must be int): %q",
Nan Zhang0007d812017-11-07 10:57:05 -08001026 String(from.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001027 }
Nan Zhang0007d812017-11-07 10:57:05 -08001028 toApi, err := strconv.Atoi(String(to.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001029 if err != nil {
1030 ctx.PropertyErrorf("sdk_version",
1031 "Invalid sdk_version value (must be int): %q",
Nan Zhang0007d812017-11-07 10:57:05 -08001032 String(to.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001033 }
1034
1035 if toApi > fromApi {
1036 ctx.ModuleErrorf("links %q built against newer API version %q",
Nan Zhang0007d812017-11-07 10:57:05 -08001037 ctx.OtherModuleName(to), String(to.Properties.Sdk_version))
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001038 }
1039}
1040
Colin Crossc99deeb2016-04-11 15:06:20 -07001041// Convert dependencies to paths. Returns a PathDeps containing paths
Colin Cross635c3b02016-05-18 15:37:25 -07001042func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
Colin Crossca860ac2016-01-04 14:34:37 -08001043 var depPaths PathDeps
Colin Crossca860ac2016-01-04 14:34:37 -08001044
Jeff Gaston294356f2017-09-27 17:05:30 -07001045 directStaticDeps := []*Module{}
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001046 directSharedDeps := []*Module{}
Jeff Gaston294356f2017-09-27 17:05:30 -07001047
Colin Crossd11fcda2017-10-23 17:59:01 -07001048 ctx.VisitDirectDeps(func(dep android.Module) {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001049 depName := ctx.OtherModuleName(dep)
1050 depTag := ctx.OtherModuleDependencyTag(dep)
Dan Albert9e10cd42016-08-03 14:12:14 -07001051
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001052 ccDep, _ := dep.(*Module)
1053 if ccDep == nil {
1054 // handling for a few module types that aren't cc Module but that are also supported
1055 switch depTag {
Colin Cross068e0fe2016-12-13 15:23:47 -08001056 case android.DefaultsDepTag, android.SourceDepTag:
Dan Willemsend6ba0d52017-09-13 15:46:47 -07001057 // Nothing to do
Dan Willemsenb40aab62016-04-20 14:21:14 -07001058 case genSourceDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001059 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001060 depPaths.GeneratedSources = append(depPaths.GeneratedSources,
1061 genRule.GeneratedSourceFiles()...)
1062 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001063 ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001064 }
Colin Crosse90bfd12017-04-26 16:59:26 -07001065 // Support exported headers from a generated_sources dependency
1066 fallthrough
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001067 case genHeaderDepTag, genHeaderExportDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001068 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenb40aab62016-04-20 14:21:14 -07001069 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
1070 genRule.GeneratedSourceFiles()...)
Colin Cross5ed99c62016-11-22 12:55:55 -08001071 flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001072 depPaths.Flags = append(depPaths.Flags, flags)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001073 if depTag == genHeaderExportDepTag {
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001074 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001075 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
1076 genRule.GeneratedSourceFiles()...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001077 // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
1078 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
1079
Dan Willemsenb3454ab2016-09-28 17:34:58 -07001080 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001081 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001082 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenb40aab62016-04-20 14:21:14 -07001083 }
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001084 case linkerScriptDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001085 if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001086 files := genRule.GeneratedSourceFiles()
1087 if len(files) == 1 {
1088 depPaths.LinkerScript = android.OptionalPathForPath(files[0])
1089 } else if len(files) > 1 {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001090 ctx.ModuleErrorf("module %q can only generate a single file if used for a linker script", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001091 }
1092 } else {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001093 ctx.ModuleErrorf("module %q is not a genrule", depName)
Dan Willemsenc77a0b32017-09-18 23:19:12 -07001094 }
Dan Willemsenb40aab62016-04-20 14:21:14 -07001095 default:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001096 ctx.ModuleErrorf("depends on non-cc module %q", depName)
Colin Crossca860ac2016-01-04 14:34:37 -08001097 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001098 return
1099 }
1100
Colin Crossd11fcda2017-10-23 17:59:01 -07001101 if dep.Target().Os != ctx.Os() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001102 ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
1103 return
1104 }
Colin Crossd11fcda2017-10-23 17:59:01 -07001105 if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001106 ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
Colin Crossa1ad8d12016-06-01 17:09:44 -07001107 return
1108 }
1109
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001110 // re-exporting flags
1111 if depTag == reuseObjTag {
1112 if l, ok := ccDep.compiler.(libraryInterface); ok {
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001113 c.staticVariant = ccDep
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001114 objs, flags, deps := l.reuseObjs()
Colin Cross10d22312017-05-03 11:01:58 -07001115 depPaths.Objs = depPaths.Objs.Append(objs)
1116 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Colin Crossbbc9f4d2017-05-03 16:24:55 -07001117 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Colin Crossbba99042016-11-23 15:45:05 -08001118 return
1119 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001120 }
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001121 if t, ok := depTag.(dependencyTag); ok && t.library {
1122 if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
Dan Willemsen76f08272016-07-09 00:14:08 -07001123 flags := i.exportedFlags()
Dan Willemsen847dcc72016-09-29 12:13:36 -07001124 deps := i.exportedFlagsDeps()
Dan Willemsen76f08272016-07-09 00:14:08 -07001125 depPaths.Flags = append(depPaths.Flags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001126 depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001127
1128 if t.reexportFlags {
Dan Willemsen76f08272016-07-09 00:14:08 -07001129 depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
Dan Willemsen847dcc72016-09-29 12:13:36 -07001130 depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
Jayant Chowdhary715cac32017-04-20 06:53:59 -07001131 // 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 -07001132 // Re-exported shared library headers must be included as well since they can help us with type information
1133 // about template instantiations (instantiated from their headers).
1134 c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001135 }
Colin Crossc99deeb2016-04-11 15:06:20 -07001136 }
Dan Willemsena96ff642016-06-07 12:34:45 -07001137
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001138 checkLinkType(ctx, c, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001139 }
1140
Colin Cross26c34ed2016-09-30 17:10:16 -07001141 var ptr *android.Paths
Colin Cross635c3b02016-05-18 15:37:25 -07001142 var depPtr *android.Paths
Colin Crossc99deeb2016-04-11 15:06:20 -07001143
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001144 linkFile := ccDep.outputFile
Colin Cross26c34ed2016-09-30 17:10:16 -07001145 depFile := android.OptionalPath{}
1146
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001147 switch depTag {
Dan Albert914449f2016-06-17 16:45:24 -07001148 case ndkStubDepTag, sharedDepTag, sharedExportDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001149 ptr = &depPaths.SharedLibs
1150 depPtr = &depPaths.SharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001151 depFile = ccDep.linker.(libraryInterface).toc()
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001152 directSharedDeps = append(directSharedDeps, ccDep)
Dan Albert914449f2016-06-17 16:45:24 -07001153 case lateSharedDepTag, ndkLateStubDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001154 ptr = &depPaths.LateSharedLibs
1155 depPtr = &depPaths.LateSharedLibsDeps
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001156 depFile = ccDep.linker.(libraryInterface).toc()
Dan Willemsen490a8dc2016-06-06 18:22:19 -07001157 case staticDepTag, staticExportDepTag:
Jeff Gaston294356f2017-09-27 17:05:30 -07001158 ptr = nil
1159 directStaticDeps = append(directStaticDeps, ccDep)
Colin Crossc99deeb2016-04-11 15:06:20 -07001160 case lateStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001161 ptr = &depPaths.LateStaticLibs
Colin Crossc99deeb2016-04-11 15:06:20 -07001162 case wholeStaticDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001163 ptr = &depPaths.WholeStaticLibs
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001164 staticLib, ok := ccDep.linker.(libraryInterface)
Colin Crossb916a382016-07-29 17:28:03 -07001165 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001166 ctx.ModuleErrorf("module %q not a static library", depName)
Colin Crossc99deeb2016-04-11 15:06:20 -07001167 return
1168 }
1169
1170 if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001171 postfix := " (required by " + ctx.OtherModuleName(dep) + ")"
Colin Crossc99deeb2016-04-11 15:06:20 -07001172 for i := range missingDeps {
1173 missingDeps[i] += postfix
1174 }
1175 ctx.AddMissingDependencies(missingDeps)
1176 }
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001177 depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
Colin Cross5950f382016-12-13 12:50:57 -08001178 case headerDepTag:
1179 // Nothing
Colin Crossc99deeb2016-04-11 15:06:20 -07001180 case objDepTag:
Dan Willemsen5cb580f2016-09-26 17:33:01 -07001181 depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
Colin Crossc99deeb2016-04-11 15:06:20 -07001182 case crtBeginDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001183 depPaths.CrtBegin = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001184 case crtEndDepTag:
Colin Cross26c34ed2016-09-30 17:10:16 -07001185 depPaths.CrtEnd = linkFile
Colin Crossc99deeb2016-04-11 15:06:20 -07001186 }
1187
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001188 switch depTag {
Dan Willemsen581341d2017-02-09 16:16:31 -08001189 case staticDepTag, staticExportDepTag, lateStaticDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001190 staticLib, ok := ccDep.linker.(libraryInterface)
Dan Willemsen581341d2017-02-09 16:16:31 -08001191 if !ok || !staticLib.static() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001192 ctx.ModuleErrorf("module %q not a static library", depName)
Dan Willemsen581341d2017-02-09 16:16:31 -08001193 return
1194 }
1195
1196 // When combining coverage files for shared libraries and executables, coverage files
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001197 // in static libraries act as if they were whole static libraries. The same goes for
1198 // source based Abi dump files.
Dan Willemsen581341d2017-02-09 16:16:31 -08001199 depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles,
1200 staticLib.objs().coverageFiles...)
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001201 depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles,
1202 staticLib.objs().sAbiDumpFiles...)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001203
Dan Willemsen581341d2017-02-09 16:16:31 -08001204 }
1205
Colin Cross26c34ed2016-09-30 17:10:16 -07001206 if ptr != nil {
Colin Crossce75d2c2016-10-06 16:12:58 -07001207 if !linkFile.Valid() {
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001208 ctx.ModuleErrorf("module %q missing output file", depName)
Colin Crossce75d2c2016-10-06 16:12:58 -07001209 return
1210 }
Colin Cross26c34ed2016-09-30 17:10:16 -07001211 *ptr = append(*ptr, linkFile.Path())
1212 }
1213
Colin Crossc99deeb2016-04-11 15:06:20 -07001214 if depPtr != nil {
Colin Cross26c34ed2016-09-30 17:10:16 -07001215 dep := depFile
1216 if !dep.Valid() {
1217 dep = linkFile
1218 }
1219 *depPtr = append(*depPtr, dep.Path())
Colin Crossca860ac2016-01-04 14:34:37 -08001220 }
Jiyong Park27b188b2017-07-18 13:23:39 +09001221
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001222 // Export the shared libs to Make.
1223 switch depTag {
Jiyong Park27b188b2017-07-18 13:23:39 +09001224 case sharedDepTag, sharedExportDepTag, lateSharedDepTag:
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001225 libName := strings.TrimSuffix(depName, llndkLibrarySuffix)
Jiyong Park27b188b2017-07-18 13:23:39 +09001226 libName = strings.TrimPrefix(libName, "prebuilt_")
Jiyong Parkd5b18a52017-08-03 21:22:50 +09001227 isLLndk := inList(libName, llndkLibraries)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001228 var makeLibName string
1229 bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk
1230 if c.useVndk() && bothVendorAndCoreVariantsExist {
1231 // The vendor module in Make will have been renamed to not conflict with the core
1232 // module, so update the dependency name here accordingly.
1233 makeLibName = libName + vendorSuffix
1234 } else {
1235 makeLibName = libName
Jiyong Park27b188b2017-07-18 13:23:39 +09001236 }
1237 // Note: the order of libs in this list is not important because
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001238 // they merely serve as Make dependencies and do not affect this lib itself.
1239 c.Properties.AndroidMkSharedLibs = append(c.Properties.AndroidMkSharedLibs, makeLibName)
Jiyong Park27b188b2017-07-18 13:23:39 +09001240 }
Colin Crossca860ac2016-01-04 14:34:37 -08001241 })
1242
Jeff Gaston294356f2017-09-27 17:05:30 -07001243 // use the ordered dependencies as this module's dependencies
Jeff Gastonf5b6e8f2017-11-27 15:48:57 -08001244 depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...)
Jeff Gaston294356f2017-09-27 17:05:30 -07001245
Colin Crossdd84e052017-05-17 13:44:16 -07001246 // Dedup exported flags from dependencies
Colin Crossb6715442017-10-24 11:13:31 -07001247 depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001248 depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
Colin Crossb6715442017-10-24 11:13:31 -07001249 depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001250 depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
1251
1252 if c.sabi != nil {
Colin Crossb6715442017-10-24 11:13:31 -07001253 c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
Dan Willemsenfe92c962017-08-29 12:28:37 -07001254 }
Colin Crossdd84e052017-05-17 13:44:16 -07001255
Colin Crossca860ac2016-01-04 14:34:37 -08001256 return depPaths
1257}
1258
1259func (c *Module) InstallInData() bool {
1260 if c.installer == nil {
1261 return false
1262 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001263 return c.installer.inData()
1264}
1265
1266func (c *Module) InstallInSanitizerDir() bool {
1267 if c.installer == nil {
1268 return false
1269 }
1270 if c.sanitize != nil && c.sanitize.inSanitizerDir() {
Colin Cross94610402016-08-29 13:41:32 -07001271 return true
1272 }
Vishwath Mohan1dd88392017-03-29 22:00:18 -07001273 return c.installer.inSanitizerDir()
Colin Crossca860ac2016-01-04 14:34:37 -08001274}
1275
Dan Willemsen4aa75ca2016-09-28 16:18:03 -07001276func (c *Module) HostToolPath() android.OptionalPath {
1277 if c.installer == nil {
1278 return android.OptionalPath{}
1279 }
1280 return c.installer.hostToolPath()
1281}
1282
Nan Zhangd4e641b2017-07-12 12:55:28 -07001283func (c *Module) IntermPathForModuleOut() android.OptionalPath {
1284 return c.outputFile
1285}
1286
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001287func (c *Module) Srcs() android.Paths {
1288 if c.outputFile.Valid() {
1289 return android.Paths{c.outputFile.Path()}
1290 }
1291 return android.Paths{}
1292}
1293
Vishwath Mohanb743e9c2017-11-01 09:20:21 +00001294func (c *Module) static() bool {
1295 if static, ok := c.linker.(interface {
1296 static() bool
1297 }); ok {
1298 return static.static()
1299 }
1300 return false
1301}
1302
Colin Cross2ba19d92015-05-07 15:44:20 -07001303//
Colin Crosscfad1192015-11-02 16:43:11 -08001304// Defaults
1305//
Colin Crossca860ac2016-01-04 14:34:37 -08001306type Defaults struct {
Colin Cross635c3b02016-05-18 15:37:25 -07001307 android.ModuleBase
Colin Cross1f44a3a2017-07-07 14:33:33 -07001308 android.DefaultsModuleBase
Colin Crosscfad1192015-11-02 16:43:11 -08001309}
1310
Colin Cross635c3b02016-05-18 15:37:25 -07001311func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Colin Crosscfad1192015-11-02 16:43:11 -08001312}
1313
Colin Cross1e676be2016-10-12 14:38:15 -07001314func (d *Defaults) DepsMutator(ctx android.BottomUpMutatorContext) {
1315}
1316
Colin Cross36242852017-06-23 15:06:31 -07001317func defaultsFactory() android.Module {
Colin Crosse1d764e2016-08-18 14:18:32 -07001318 return DefaultsFactory()
1319}
1320
Colin Cross36242852017-06-23 15:06:31 -07001321func DefaultsFactory(props ...interface{}) android.Module {
Colin Crossca860ac2016-01-04 14:34:37 -08001322 module := &Defaults{}
Colin Crosscfad1192015-11-02 16:43:11 -08001323
Colin Cross36242852017-06-23 15:06:31 -07001324 module.AddProperties(props...)
1325 module.AddProperties(
Colin Crossca860ac2016-01-04 14:34:37 -08001326 &BaseProperties{},
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001327 &VendorProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001328 &BaseCompilerProperties{},
1329 &BaseLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001330 &LibraryProperties{},
Colin Cross919281a2016-04-05 16:42:05 -07001331 &FlagExporterProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001332 &BinaryLinkerProperties{},
Colin Crossb916a382016-07-29 17:28:03 -07001333 &TestProperties{},
1334 &TestBinaryProperties{},
Colin Crossca860ac2016-01-04 14:34:37 -08001335 &UnusedProperties{},
1336 &StlProperties{},
Colin Cross16b23492016-01-06 14:41:07 -08001337 &SanitizeProperties{},
Colin Cross665dce92016-04-28 14:50:03 -07001338 &StripProperties{},
Dan Willemsen7424d612016-09-01 13:45:39 -07001339 &InstallerProperties{},
Dan Willemsena03cf6d2016-09-26 15:45:04 -07001340 &TidyProperties{},
Dan Willemsen581341d2017-02-09 16:16:31 -08001341 &CoverageProperties{},
Jayant Chowdhary3e231fd2017-02-08 13:45:53 -08001342 &SAbiProperties{},
Justin Yun4b2382f2017-07-26 14:22:10 +09001343 &VndkProperties{},
Stephen Craneba090d12017-05-09 15:44:35 -07001344 &LTOProperties{},
Pirama Arumuga Nainarada83ec2017-08-31 23:38:27 -07001345 &PgoProperties{},
Colin Crosse1d764e2016-08-18 14:18:32 -07001346 )
Colin Crosscfad1192015-11-02 16:43:11 -08001347
Colin Cross1f44a3a2017-07-07 14:33:33 -07001348 android.InitDefaultsModule(module)
Colin Cross36242852017-06-23 15:06:31 -07001349
1350 return module
Colin Crosscfad1192015-11-02 16:43:11 -08001351}
1352
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001353const (
1354 // coreMode is the variant used for framework-private libraries, or
1355 // SDK libraries. (which framework-private libraries can use)
1356 coreMode = "core"
1357
1358 // vendorMode is the variant used for /vendor code that compiles
1359 // against the VNDK.
1360 vendorMode = "vendor"
1361)
1362
Jiyong Park6a43f042017-10-12 23:05:00 +09001363func squashVendorSrcs(m *Module) {
1364 if lib, ok := m.compiler.(*libraryDecorator); ok {
1365 lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
1366 lib.baseCompiler.Properties.Target.Vendor.Srcs...)
1367
1368 lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
1369 lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
1370 }
1371}
1372
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001373func vendorMutator(mctx android.BottomUpMutatorContext) {
1374 if mctx.Os() != android.Android {
1375 return
1376 }
1377
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001378 if genrule, ok := mctx.Module().(*genrule.Module); ok {
1379 if props, ok := genrule.Extra.(*VendorProperties); ok {
Justin Yun71549282017-11-17 12:10:28 +09001380 if mctx.DeviceConfig().VndkVersion() == "" {
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001381 mctx.CreateVariations(coreMode)
1382 } else if Bool(props.Vendor_available) {
1383 mctx.CreateVariations(coreMode, vendorMode)
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001384 } else if mctx.InstallOnVendorPartition() {
Dan Willemsen3e5bdf22017-09-13 18:37:08 -07001385 mctx.CreateVariations(vendorMode)
1386 } else {
1387 mctx.CreateVariations(coreMode)
1388 }
1389 }
1390 }
1391
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001392 m, ok := mctx.Module().(*Module)
1393 if !ok {
1394 return
1395 }
1396
1397 // Sanity check
Jeff Gastonaf3cc2d2017-09-27 17:01:44 -07001398 if m.VendorProperties.Vendor_available != nil && mctx.InstallOnVendorPartition() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001399 mctx.PropertyErrorf("vendor_available",
1400 "doesn't make sense at the same time as `vendor: true` or `proprietary: true`")
1401 return
1402 }
Justin Yun8effde42017-06-23 19:24:43 +09001403 if vndk := m.vndkdep; vndk != nil {
Jiyong Park82e2bf32017-08-16 14:05:54 +09001404 if vndk.isVndk() && m.VendorProperties.Vendor_available == nil {
Justin Yun8effde42017-06-23 19:24:43 +09001405 mctx.PropertyErrorf("vndk",
Jiyong Park82e2bf32017-08-16 14:05:54 +09001406 "vendor_available must be set to either true or false when `vndk: {enabled: true}`")
Justin Yun8effde42017-06-23 19:24:43 +09001407 return
1408 }
1409 if !vndk.isVndk() && vndk.isVndkSp() {
1410 mctx.PropertyErrorf("vndk",
1411 "must set `enabled: true` to set `support_system_process: true`")
1412 return
1413 }
1414 }
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001415
Justin Yun71549282017-11-17 12:10:28 +09001416 if mctx.DeviceConfig().VndkVersion() == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001417 // If the device isn't compiling against the VNDK, we always
1418 // use the core mode.
1419 mctx.CreateVariations(coreMode)
1420 } else if _, ok := m.linker.(*llndkStubDecorator); ok {
1421 // LL-NDK stubs only exist in the vendor variant, since the
1422 // real libraries will be used in the core variant.
1423 mctx.CreateVariations(vendorMode)
Jiyong Park2a454122017-10-19 15:59:33 +09001424 } else if _, ok := m.linker.(*llndkHeadersDecorator); ok {
1425 // ... and LL-NDK headers as well
Jiyong Parka46a4d52017-12-14 19:54:34 +09001426 mod := mctx.CreateVariations(vendorMode)
1427 vendor := mod[0].(*Module)
1428 vendor.Properties.UseVndk = true
Justin Yun71549282017-11-17 12:10:28 +09001429 } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok {
1430 // Make vendor variants only for the versions in BOARD_VNDK_VERSION and
1431 // PRODUCT_EXTRA_VNDK_VERSIONS.
1432 mod := mctx.CreateVariations(vendorMode)
1433 vendor := mod[0].(*Module)
1434 vendor.Properties.UseVndk = true
Jiyong Park82e2bf32017-08-16 14:05:54 +09001435 } else if m.hasVendorVariant() {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001436 // This will be available in both /system and /vendor
Justin Yun8effde42017-06-23 19:24:43 +09001437 // or a /system directory that is available to vendor.
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001438 mod := mctx.CreateVariations(coreMode, vendorMode)
Jiyong Park6a43f042017-10-12 23:05:00 +09001439 vendor := mod[1].(*Module)
1440 vendor.Properties.UseVndk = true
1441 squashVendorSrcs(vendor)
Nan Zhang0007d812017-11-07 10:57:05 -08001442 } else if mctx.InstallOnVendorPartition() && String(m.Properties.Sdk_version) == "" {
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001443 // This will be available in /vendor only
1444 mod := mctx.CreateVariations(vendorMode)
Jiyong Park6a43f042017-10-12 23:05:00 +09001445 vendor := mod[0].(*Module)
1446 vendor.Properties.UseVndk = true
1447 squashVendorSrcs(vendor)
Dan Willemsen4416e5d2017-04-06 12:43:22 -07001448 } else {
1449 // This is either in /system (or similar: /data), or is a
1450 // modules built with the NDK. Modules built with the NDK
1451 // will be restricted using the existing link type checks.
1452 mctx.CreateVariations(coreMode)
1453 }
1454}
1455
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001456func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
Colin Cross6510f912017-11-29 00:27:14 -08001457 if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001458 return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
1459 }
Colin Cross6510f912017-11-29 00:27:14 -08001460 return ctx.Config().PlatformSdkVersion()
Jayant Chowdhary6e8115a2017-05-09 10:21:52 -07001461}
1462
Colin Cross06a931b2015-10-28 17:23:31 -07001463var Bool = proptools.Bool
Nan Zhang0007d812017-11-07 10:57:05 -08001464var BoolPtr = proptools.BoolPtr
1465var String = proptools.String
1466var StringPtr = proptools.StringPtr