Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 1 | // Copyright 2015 Google Inc. All rights reserved. |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package 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 | |
| 21 | import ( |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 22 | "fmt" |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 23 | "io" |
Dan Albert | 9e10cd4 | 2016-08-03 14:12:14 -0700 | [diff] [blame] | 24 | "strconv" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 25 | "strings" |
| 26 | |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 27 | "github.com/google/blueprint" |
Colin Cross | 06a931b | 2015-10-28 17:23:31 -0700 | [diff] [blame] | 28 | "github.com/google/blueprint/proptools" |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 29 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 30 | "android/soong/android" |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 31 | "android/soong/cc/config" |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 32 | "android/soong/genrule" |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 33 | ) |
| 34 | |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 35 | func init() { |
Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 36 | RegisterCCBuildComponents(android.InitRegistrationContext) |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 37 | |
Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 38 | pctx.Import("android/soong/cc/config") |
| 39 | } |
| 40 | |
| 41 | func RegisterCCBuildComponents(ctx android.RegistrationContext) { |
| 42 | ctx.RegisterModuleType("cc_defaults", defaultsFactory) |
| 43 | |
| 44 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 45 | ctx.BottomUp("sdk", sdkMutator).Parallel() |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 46 | ctx.BottomUp("vndk", VndkMutator).Parallel() |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 47 | ctx.BottomUp("link", LinkageMutator).Parallel() |
Jooyung Han | b90e491 | 2019-12-09 18:21:48 +0900 | [diff] [blame] | 48 | ctx.BottomUp("ndk_api", NdkApiMutator).Parallel() |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 49 | ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 50 | ctx.BottomUp("version", VersionMutator).Parallel() |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 51 | ctx.BottomUp("begin", BeginMutator).Parallel() |
Inseob Kim | ac1e986 | 2019-12-09 18:15:47 +0900 | [diff] [blame] | 52 | ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel() |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 53 | ctx.BottomUp("vendor_snapshot", VendorSnapshotMutator).Parallel() |
| 54 | ctx.BottomUp("vendor_snapshot_source", VendorSnapshotSourceMutator).Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 55 | }) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 56 | |
Paul Duffin | 036e700 | 2019-12-19 19:16:28 +0000 | [diff] [blame] | 57 | ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 58 | ctx.TopDown("asan_deps", sanitizerDepsMutator(asan)) |
| 59 | ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel() |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 60 | |
Evgenii Stepanov | d97a6e9 | 2018-08-02 16:19:13 -0700 | [diff] [blame] | 61 | ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan)) |
| 62 | ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel() |
| 63 | |
Mitch Phillips | bfeade6 | 2019-05-01 14:42:05 -0700 | [diff] [blame] | 64 | ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(fuzzer)) |
| 65 | ctx.BottomUp("fuzzer", sanitizerMutator(fuzzer)).Parallel() |
| 66 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 67 | // cfi mutator shouldn't run before sanitizers that return true for |
| 68 | // incompatibleWithCfi() |
Vishwath Mohan | b743e9c | 2017-11-01 09:20:21 +0000 | [diff] [blame] | 69 | ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi)) |
| 70 | ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel() |
| 71 | |
Peter Collingbourne | 8c7e6e2 | 2018-11-19 16:03:58 -0800 | [diff] [blame] | 72 | ctx.TopDown("scs_deps", sanitizerDepsMutator(scs)) |
| 73 | ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel() |
| 74 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 75 | ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan)) |
| 76 | ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel() |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 77 | |
Colin Cross | 0b90833 | 2019-06-19 23:00:20 -0700 | [diff] [blame] | 78 | ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel() |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 79 | ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel() |
Ivan Lozano | 30c5db2 | 2018-02-21 15:49:20 -0800 | [diff] [blame] | 80 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 81 | ctx.BottomUp("coverage", coverageMutator).Parallel() |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 82 | ctx.TopDown("vndk_deps", sabiDepsMutator) |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 83 | |
| 84 | ctx.TopDown("lto_deps", ltoDepsMutator) |
| 85 | ctx.BottomUp("lto", ltoMutator).Parallel() |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 86 | |
| 87 | ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 88 | }) |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 89 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 90 | android.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory) |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 93 | type Deps struct { |
| 94 | SharedLibs, LateSharedLibs []string |
| 95 | StaticLibs, LateStaticLibs, WholeStaticLibs []string |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 96 | HeaderLibs []string |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 97 | RuntimeLibs []string |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 98 | |
Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 99 | // Used for data dependencies adjacent to tests |
| 100 | DataLibs []string |
| 101 | |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 102 | StaticUnwinderIfLegacy bool |
| 103 | |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 104 | ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 105 | |
Colin Cross | 8141347 | 2016-04-11 14:37:39 -0700 | [diff] [blame] | 106 | ObjFiles []string |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 107 | |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 108 | GeneratedSources []string |
| 109 | GeneratedHeaders []string |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 110 | GeneratedDeps []string |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 111 | |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 112 | ReexportGeneratedHeaders []string |
| 113 | |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 114 | CrtBegin, CrtEnd string |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 115 | |
| 116 | // Used for host bionic |
| 117 | LinkerFlagsFile string |
| 118 | DynamicLinker string |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 121 | type PathDeps struct { |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 122 | // Paths to .so files |
Jiyong Park | 64a44f2 | 2019-01-18 14:37:08 +0900 | [diff] [blame] | 123 | SharedLibs, EarlySharedLibs, LateSharedLibs android.Paths |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 124 | // Paths to the dependencies to use for .so files (.so.toc files) |
Jiyong Park | 64a44f2 | 2019-01-18 14:37:08 +0900 | [diff] [blame] | 125 | SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 126 | // Paths to .a files |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 127 | StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 128 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 129 | // Paths to .o files |
Martin Stjernholm | 391d94c | 2020-04-17 17:34:31 +0100 | [diff] [blame] | 130 | Objs Objects |
| 131 | // Paths to .o files in dependencies that provide them. Note that these lists |
| 132 | // aren't complete since prebuilt modules don't provide the .o files. |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 133 | StaticLibObjs Objects |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 134 | WholeStaticLibObjs Objects |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 135 | |
Martin Stjernholm | 391d94c | 2020-04-17 17:34:31 +0100 | [diff] [blame] | 136 | // Paths to .a files in prebuilts. Complements WholeStaticLibObjs to contain |
| 137 | // the libs from all whole_static_lib dependencies. |
| 138 | WholeStaticLibsFromPrebuilts android.Paths |
| 139 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 140 | // Paths to generated source files |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 141 | GeneratedSources android.Paths |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 142 | GeneratedDeps android.Paths |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 143 | |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 144 | Flags []string |
| 145 | IncludeDirs android.Paths |
| 146 | SystemIncludeDirs android.Paths |
| 147 | ReexportedDirs android.Paths |
| 148 | ReexportedSystemDirs android.Paths |
| 149 | ReexportedFlags []string |
| 150 | ReexportedGeneratedHeaders android.Paths |
| 151 | ReexportedDeps android.Paths |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 152 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 153 | // Paths to crt*.o files |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 154 | CrtBegin, CrtEnd android.OptionalPath |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 155 | |
| 156 | // Path to the file container flags to use with the linker |
| 157 | LinkerFlagsFile android.OptionalPath |
| 158 | |
| 159 | // Path to the dynamic linker binary |
| 160 | DynamicLinker android.OptionalPath |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 163 | // LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module |
| 164 | // tracked separately, in order to maintain the required ordering (most of the global flags need to go first on the |
| 165 | // command line so they can be overridden by the local module flags). |
| 166 | type LocalOrGlobalFlags struct { |
| 167 | CommonFlags []string // Flags that apply to C, C++, and assembly source files |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 168 | AsFlags []string // Flags that apply to assembly source files |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 169 | YasmFlags []string // Flags that apply to yasm assembly source files |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 170 | CFlags []string // Flags that apply to C and C++ source files |
| 171 | ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools |
| 172 | ConlyFlags []string // Flags that apply to C source files |
| 173 | CppFlags []string // Flags that apply to C++ source files |
| 174 | ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 175 | LdFlags []string // Flags that apply to linker command lines |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | type Flags struct { |
| 179 | Local LocalOrGlobalFlags |
| 180 | Global LocalOrGlobalFlags |
| 181 | |
| 182 | aidlFlags []string // Flags that apply to aidl source files |
| 183 | rsFlags []string // Flags that apply to renderscript source files |
| 184 | libFlags []string // Flags to add libraries early to the link order |
| 185 | extraLibFlags []string // Flags to add libraries late in the link order after LdFlags |
| 186 | TidyFlags []string // Flags that apply to clang-tidy |
| 187 | SAbiFlags []string // Flags that apply to header-abi-dumper |
Colin Cross | 2834452 | 2015-04-22 13:07:53 -0700 | [diff] [blame] | 188 | |
Colin Cross | c319948 | 2017-03-30 15:03:04 -0700 | [diff] [blame] | 189 | // Global include flags that apply to C, C++, and assembly source files |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 190 | // These must be after any module include flags, which will be in CommonFlags. |
Colin Cross | c319948 | 2017-03-30 15:03:04 -0700 | [diff] [blame] | 191 | SystemIncludeFlags []string |
| 192 | |
Oliver Nguyen | 0452678 | 2020-04-21 12:40:27 -0700 | [diff] [blame] | 193 | Toolchain config.Toolchain |
| 194 | Tidy bool |
| 195 | GcovCoverage bool |
| 196 | SAbiDump bool |
| 197 | EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 198 | |
| 199 | RequiredInstructionSet string |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 200 | DynamicLinker string |
| 201 | |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 202 | CFlagsDeps android.Paths // Files depended on by compiler flags |
| 203 | LdFlagsDeps android.Paths // Files depended on by linker flags |
Colin Cross | 18c0c5a | 2016-12-01 14:45:23 -0800 | [diff] [blame] | 204 | |
Dan Willemsen | 98ab311 | 2019-08-27 21:20:40 -0700 | [diff] [blame] | 205 | AssemblerWithCpp bool |
| 206 | GroupStaticLibs bool |
Dan Willemsen | 60e62f0 | 2018-11-16 21:05:32 -0800 | [diff] [blame] | 207 | |
Colin Cross | 19878da | 2019-03-28 14:45:07 -0700 | [diff] [blame] | 208 | proto android.ProtoFlags |
Colin Cross | 19878da | 2019-03-28 14:45:07 -0700 | [diff] [blame] | 209 | protoC bool // Whether to use C instead of C++ |
| 210 | protoOptionsFile bool // Whether to look for a .options file next to the .proto |
Dan Willemsen | 4e0aa23 | 2019-04-10 22:59:54 -0700 | [diff] [blame] | 211 | |
| 212 | Yacc *YaccProperties |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 215 | // Properties used to compile all C or C++ modules |
| 216 | type BaseProperties struct { |
Dan Willemsen | 742a545 | 2018-07-23 17:19:36 -0700 | [diff] [blame] | 217 | // Deprecated. true is the default, false is invalid. |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 218 | Clang *bool `android:"arch_variant"` |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 219 | |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 220 | // Minimum sdk version supported when compiling against the ndk. Setting this property causes |
| 221 | // two variants to be built, one for the platform and one for apps. |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 222 | Sdk_version *string |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 223 | |
Jooyung Han | 379660c | 2020-04-21 15:24:00 +0900 | [diff] [blame] | 224 | // Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX). |
| 225 | Min_sdk_version *string |
| 226 | |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 227 | // If true, always create an sdk variant and don't create a platform variant. |
| 228 | Sdk_variant_only *bool |
| 229 | |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 230 | AndroidMkSharedLibs []string `blueprint:"mutated"` |
| 231 | AndroidMkStaticLibs []string `blueprint:"mutated"` |
| 232 | AndroidMkRuntimeLibs []string `blueprint:"mutated"` |
| 233 | AndroidMkWholeStaticLibs []string `blueprint:"mutated"` |
Bill Peckham | a46de70 | 2020-04-21 17:23:37 -0700 | [diff] [blame] | 234 | AndroidMkHeaderLibs []string `blueprint:"mutated"` |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 235 | HideFromMake bool `blueprint:"mutated"` |
| 236 | PreventInstall bool `blueprint:"mutated"` |
| 237 | ApexesProvidingSharedLibs []string `blueprint:"mutated"` |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 238 | |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 239 | ImageVariationPrefix string `blueprint:"mutated"` |
| 240 | VndkVersion string `blueprint:"mutated"` |
| 241 | SubName string `blueprint:"mutated"` |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 242 | |
| 243 | // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags |
| 244 | // file |
| 245 | Logtags []string |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 246 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 247 | // Make this module available when building for ramdisk |
| 248 | Ramdisk_available *bool |
| 249 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 250 | // Make this module available when building for recovery |
| 251 | Recovery_available *bool |
| 252 | |
Colin Cross | ae6c520 | 2019-11-20 13:35:50 -0800 | [diff] [blame] | 253 | // Set by imageMutator |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 254 | CoreVariantNeeded bool `blueprint:"mutated"` |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 255 | RamdiskVariantNeeded bool `blueprint:"mutated"` |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 256 | RecoveryVariantNeeded bool `blueprint:"mutated"` |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 257 | ExtraVariants []string `blueprint:"mutated"` |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 258 | |
| 259 | // Allows this module to use non-APEX version of libraries. Useful |
| 260 | // for building binaries that are started before APEXes are activated. |
| 261 | Bootstrap *bool |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 262 | |
| 263 | // Even if DeviceConfig().VndkUseCoreVariant() is set, this module must use vendor variant. |
| 264 | // see soong/cc/config/vndk.go |
| 265 | MustUseVendorVariant bool `blueprint:"mutated"` |
Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 266 | |
| 267 | // Used by vendor snapshot to record dependencies from snapshot modules. |
| 268 | SnapshotSharedLibs []string `blueprint:"mutated"` |
| 269 | SnapshotRuntimeLibs []string `blueprint:"mutated"` |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 270 | |
| 271 | Installable *bool |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 272 | |
| 273 | // Set by factories of module types that can only be referenced from variants compiled against |
| 274 | // the SDK. |
| 275 | AlwaysSdk bool `blueprint:"mutated"` |
| 276 | |
| 277 | // Variant is an SDK variant created by sdkMutator |
| 278 | IsSdkVariant bool `blueprint:"mutated"` |
| 279 | // Set when both SDK and platform variants are exported to Make to trigger renaming the SDK |
| 280 | // variant to have a ".sdk" suffix. |
| 281 | SdkAndPlatformVariantVisibleToMake bool `blueprint:"mutated"` |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | type VendorProperties struct { |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 285 | // whether this module should be allowed to be directly depended by other |
| 286 | // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`. |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 287 | // In addition, this module should be allowed to be directly depended by |
| 288 | // product modules with `product_specific: true`. |
| 289 | // If set to true, three variants will be built separately, one like |
| 290 | // normal, another limited to the set of libraries and headers |
| 291 | // that are exposed to /vendor modules, and the other to /product modules. |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 292 | // |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 293 | // The vendor and product variants may be used with a different (newer) /system, |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 294 | // so it shouldn't have any unversioned runtime dependencies, or |
| 295 | // make assumptions about the system that may not be true in the |
| 296 | // future. |
| 297 | // |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 298 | // If set to false, this module becomes inaccessible from /vendor or /product |
| 299 | // modules. |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 300 | // |
| 301 | // Default value is true when vndk: {enabled: true} or vendor: true. |
| 302 | // |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 303 | // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 304 | // If PRODUCT_PRODUCT_VNDK_VERSION isn't set, product variant will not be used. |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 305 | Vendor_available *bool |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 306 | |
| 307 | // whether this module is capable of being loaded with other instance |
| 308 | // (possibly an older version) of the same module in the same process. |
| 309 | // Currently, a shared library that is a member of VNDK (vndk: {enabled: true}) |
| 310 | // can be double loaded in a vendor process if the library is also a |
| 311 | // (direct and indirect) dependency of an LLNDK library. Such libraries must be |
| 312 | // explicitly marked as `double_loadable: true` by the owner, or the dependency |
| 313 | // from the LLNDK lib should be cut if the lib is not designed to be double loaded. |
| 314 | Double_loadable *bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 317 | type ModuleContextIntf interface { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 318 | static() bool |
| 319 | staticBinary() bool |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 320 | header() bool |
Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 321 | binary() bool |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 322 | object() bool |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 323 | toolchain() config.Toolchain |
Jooyung Han | ccce2f2 | 2020-03-07 03:45:53 +0900 | [diff] [blame] | 324 | canUseSdk() bool |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 325 | useSdk() bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 326 | sdkVersion() string |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 327 | useVndk() bool |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 328 | isNdk() bool |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 329 | isLlndk(config android.Config) bool |
| 330 | isLlndkPublic(config android.Config) bool |
| 331 | isVndkPrivate(config android.Config) bool |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 332 | isVndk() bool |
| 333 | isVndkSp() bool |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 334 | isVndkExt() bool |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 335 | inProduct() bool |
| 336 | inVendor() bool |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 337 | inRamdisk() bool |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 338 | inRecovery() bool |
Hsin-Yi Chen | af17d74 | 2019-07-29 17:46:59 +0800 | [diff] [blame] | 339 | shouldCreateSourceAbiDump() bool |
Dan Willemsen | 8146b2f | 2016-03-30 21:00:30 -0700 | [diff] [blame] | 340 | selectedStl() string |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 341 | baseModuleName() string |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 342 | getVndkExtendsModuleName() string |
Yi Kong | 7e53c57 | 2018-02-14 18:16:12 +0800 | [diff] [blame] | 343 | isPgoCompile() bool |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 344 | isNDKStubLibrary() bool |
Ivan Lozano | bd72126 | 2018-11-27 14:33:03 -0800 | [diff] [blame] | 345 | useClangLld(actx ModuleContext) bool |
Logan Chien | e274fc9 | 2019-12-03 11:18:32 -0800 | [diff] [blame] | 346 | isForPlatform() bool |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 347 | apexName() string |
Jooyung Han | ccce2f2 | 2020-03-07 03:45:53 +0900 | [diff] [blame] | 348 | apexSdkVersion() int |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 349 | hasStubsVariants() bool |
| 350 | isStubs() bool |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 351 | bootstrap() bool |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 352 | mustUseVendorVariant() bool |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 353 | nativeCoverage() bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | type ModuleContext interface { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 357 | android.ModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 358 | ModuleContextIntf |
| 359 | } |
| 360 | |
| 361 | type BaseModuleContext interface { |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 362 | android.BaseModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 363 | ModuleContextIntf |
| 364 | } |
| 365 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 366 | type DepsContext interface { |
| 367 | android.BottomUpMutatorContext |
| 368 | ModuleContextIntf |
| 369 | } |
| 370 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 371 | type feature interface { |
| 372 | begin(ctx BaseModuleContext) |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 373 | deps(ctx DepsContext, deps Deps) Deps |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 374 | flags(ctx ModuleContext, flags Flags) Flags |
| 375 | props() []interface{} |
| 376 | } |
| 377 | |
| 378 | type compiler interface { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 379 | compilerInit(ctx BaseModuleContext) |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 380 | compilerDeps(ctx DepsContext, deps Deps) Deps |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 381 | compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 382 | compilerProps() []interface{} |
| 383 | |
Colin Cross | 76fada0 | 2016-07-27 10:31:13 -0700 | [diff] [blame] | 384 | appendCflags([]string) |
| 385 | appendAsflags([]string) |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 386 | compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 387 | } |
| 388 | |
| 389 | type linker interface { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 390 | linkerInit(ctx BaseModuleContext) |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 391 | linkerDeps(ctx DepsContext, deps Deps) Deps |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 392 | linkerFlags(ctx ModuleContext, flags Flags) Flags |
| 393 | linkerProps() []interface{} |
Ivan Lozano | bd72126 | 2018-11-27 14:33:03 -0800 | [diff] [blame] | 394 | useClangLld(actx ModuleContext) bool |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 395 | |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 396 | link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path |
Colin Cross | 76fada0 | 2016-07-27 10:31:13 -0700 | [diff] [blame] | 397 | appendLdflags([]string) |
Jiyong Park | af6d895 | 2019-01-31 12:21:23 +0900 | [diff] [blame] | 398 | unstrippedOutputFilePath() android.Path |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 399 | |
| 400 | nativeCoverage() bool |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 401 | coverageOutputFilePath() android.OptionalPath |
Paul Duffin | 13f0271 | 2020-03-06 12:30:43 +0000 | [diff] [blame] | 402 | |
| 403 | // Get the deps that have been explicitly specified in the properties. |
| 404 | // Only updates the |
| 405 | linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps |
| 406 | } |
| 407 | |
| 408 | type specifiedDeps struct { |
| 409 | sharedLibs []string |
Martin Stjernholm | 10566a0 | 2020-03-24 01:19:52 +0000 | [diff] [blame] | 410 | systemSharedLibs []string // Note nil and [] are semantically distinct. |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | type installer interface { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 414 | installerProps() []interface{} |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 415 | install(ctx ModuleContext, path android.Path) |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 416 | everInstallable() bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 417 | inData() bool |
Vishwath Mohan | 1dd8839 | 2017-03-29 22:00:18 -0700 | [diff] [blame] | 418 | inSanitizerDir() bool |
Dan Willemsen | 4aa75ca | 2016-09-28 16:18:03 -0700 | [diff] [blame] | 419 | hostToolPath() android.OptionalPath |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 420 | relativeInstallPath() string |
Martin Stjernholm | 9e9bb7f | 2020-08-06 22:34:42 +0100 | [diff] [blame] | 421 | makeUninstallable(mod *Module) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 422 | } |
| 423 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 424 | type xref interface { |
| 425 | XrefCcFiles() android.Paths |
| 426 | } |
| 427 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 428 | type libraryDependencyKind int |
| 429 | |
| 430 | const ( |
| 431 | headerLibraryDependency = iota |
| 432 | sharedLibraryDependency |
| 433 | staticLibraryDependency |
| 434 | ) |
| 435 | |
| 436 | func (k libraryDependencyKind) String() string { |
| 437 | switch k { |
| 438 | case headerLibraryDependency: |
| 439 | return "headerLibraryDependency" |
| 440 | case sharedLibraryDependency: |
| 441 | return "sharedLibraryDependency" |
| 442 | case staticLibraryDependency: |
| 443 | return "staticLibraryDependency" |
| 444 | default: |
| 445 | panic(fmt.Errorf("unknown libraryDependencyKind %d", k)) |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | type libraryDependencyOrder int |
| 450 | |
| 451 | const ( |
| 452 | earlyLibraryDependency = -1 |
| 453 | normalLibraryDependency = 0 |
| 454 | lateLibraryDependency = 1 |
| 455 | ) |
| 456 | |
| 457 | func (o libraryDependencyOrder) String() string { |
| 458 | switch o { |
| 459 | case earlyLibraryDependency: |
| 460 | return "earlyLibraryDependency" |
| 461 | case normalLibraryDependency: |
| 462 | return "normalLibraryDependency" |
| 463 | case lateLibraryDependency: |
| 464 | return "lateLibraryDependency" |
| 465 | default: |
| 466 | panic(fmt.Errorf("unknown libraryDependencyOrder %d", o)) |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | // libraryDependencyTag is used to tag dependencies on libraries. Unlike many dependency |
| 471 | // tags that have a set of predefined tag objects that are reused for each dependency, a |
| 472 | // libraryDependencyTag is designed to contain extra metadata and is constructed as needed. |
| 473 | // That means that comparing a libraryDependencyTag for equality will only be equal if all |
| 474 | // of the metadata is equal. Most usages will want to type assert to libraryDependencyTag and |
| 475 | // then check individual metadata fields instead. |
| 476 | type libraryDependencyTag struct { |
| 477 | blueprint.BaseDependencyTag |
| 478 | |
| 479 | // These are exported so that fmt.Printf("%#v") can call their String methods. |
| 480 | Kind libraryDependencyKind |
| 481 | Order libraryDependencyOrder |
| 482 | |
| 483 | wholeStatic bool |
| 484 | |
| 485 | reexportFlags bool |
| 486 | explicitlyVersioned bool |
| 487 | dataLib bool |
| 488 | ndk bool |
| 489 | |
| 490 | staticUnwinder bool |
| 491 | |
| 492 | makeSuffix string |
| 493 | } |
| 494 | |
| 495 | // header returns true if the libraryDependencyTag is tagging a header lib dependency. |
| 496 | func (d libraryDependencyTag) header() bool { |
| 497 | return d.Kind == headerLibraryDependency |
| 498 | } |
| 499 | |
| 500 | // shared returns true if the libraryDependencyTag is tagging a shared lib dependency. |
| 501 | func (d libraryDependencyTag) shared() bool { |
| 502 | return d.Kind == sharedLibraryDependency |
| 503 | } |
| 504 | |
| 505 | // shared returns true if the libraryDependencyTag is tagging a static lib dependency. |
| 506 | func (d libraryDependencyTag) static() bool { |
| 507 | return d.Kind == staticLibraryDependency |
| 508 | } |
| 509 | |
| 510 | // dependencyTag is used for tagging miscellanous dependency types that don't fit into |
| 511 | // libraryDependencyTag. Each tag object is created globally and reused for multiple |
| 512 | // dependencies (although since the object contains no references, assigning a tag to a |
| 513 | // variable and modifying it will not modify the original). Users can compare the tag |
| 514 | // returned by ctx.OtherModuleDependencyTag against the global original |
| 515 | type dependencyTag struct { |
| 516 | blueprint.BaseDependencyTag |
| 517 | name string |
| 518 | } |
| 519 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 520 | var ( |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 521 | genSourceDepTag = dependencyTag{name: "gen source"} |
| 522 | genHeaderDepTag = dependencyTag{name: "gen header"} |
| 523 | genHeaderExportDepTag = dependencyTag{name: "gen header export"} |
| 524 | objDepTag = dependencyTag{name: "obj"} |
| 525 | linkerFlagsDepTag = dependencyTag{name: "linker flags file"} |
| 526 | dynamicLinkerDepTag = dependencyTag{name: "dynamic linker"} |
| 527 | reuseObjTag = dependencyTag{name: "reuse objects"} |
| 528 | staticVariantTag = dependencyTag{name: "static variant"} |
| 529 | vndkExtDepTag = dependencyTag{name: "vndk extends"} |
| 530 | dataLibDepTag = dependencyTag{name: "data lib"} |
| 531 | runtimeDepTag = dependencyTag{name: "runtime lib"} |
| 532 | testPerSrcDepTag = dependencyTag{name: "test_per_src"} |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 533 | ) |
| 534 | |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 535 | func IsSharedDepTag(depTag blueprint.DependencyTag) bool { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 536 | ccLibDepTag, ok := depTag.(libraryDependencyTag) |
| 537 | return ok && ccLibDepTag.shared() |
| 538 | } |
| 539 | |
| 540 | func IsStaticDepTag(depTag blueprint.DependencyTag) bool { |
| 541 | ccLibDepTag, ok := depTag.(libraryDependencyTag) |
| 542 | return ok && ccLibDepTag.static() |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 546 | ccDepTag, ok := depTag.(dependencyTag) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 547 | return ok && ccDepTag == runtimeDepTag |
| 548 | } |
| 549 | |
| 550 | func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 551 | ccDepTag, ok := depTag.(dependencyTag) |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 552 | return ok && ccDepTag == testPerSrcDepTag |
| 553 | } |
| 554 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 555 | // Module contains the properties and members used by all C/C++ module types, and implements |
| 556 | // the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces |
| 557 | // to construct the output file. Behavior can be customized with a Customizer interface |
| 558 | type Module struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 559 | android.ModuleBase |
Colin Cross | 1f44a3a | 2017-07-07 14:33:33 -0700 | [diff] [blame] | 560 | android.DefaultableModuleBase |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 561 | android.ApexModuleBase |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 562 | android.SdkBase |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 563 | |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 564 | Properties BaseProperties |
| 565 | VendorProperties VendorProperties |
Colin Cross | fa13879 | 2015-04-24 17:31:52 -0700 | [diff] [blame] | 566 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 567 | // initialize before calling Init |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 568 | hod android.HostOrDeviceSupported |
| 569 | multilib android.Multilib |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 570 | |
Paul Duffin | a0843f6 | 2019-12-13 19:50:38 +0000 | [diff] [blame] | 571 | // Allowable SdkMemberTypes of this module type. |
| 572 | sdkMemberTypes []android.SdkMemberType |
| 573 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 574 | // delegates, initialize before calling Init |
Colin Cross | b4ce0ec | 2016-09-13 13:41:39 -0700 | [diff] [blame] | 575 | features []feature |
| 576 | compiler compiler |
| 577 | linker linker |
| 578 | installer installer |
| 579 | stl *stl |
| 580 | sanitize *sanitize |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 581 | coverage *coverage |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 582 | sabi *sabi |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 583 | vndkdep *vndkdep |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 584 | lto *lto |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 585 | pgo *pgo |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 586 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 587 | outputFile android.OptionalPath |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 588 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 589 | cachedToolchain config.Toolchain |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 590 | |
| 591 | subAndroidMkOnce map[subAndroidMkProvider]bool |
Fabien Sanglard | d61f1f4 | 2017-01-10 16:21:22 -0800 | [diff] [blame] | 592 | |
| 593 | // Flags used to compile this module |
| 594 | flags Flags |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 595 | |
| 596 | // When calling a linker, if module A depends on module B, then A must precede B in its command |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 597 | // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 598 | // deps of this module |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 599 | depsInLinkOrder android.Paths |
| 600 | |
| 601 | // only non-nil when this is a shared library that reuses the objects of a static library |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 602 | staticVariant LinkableInterface |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 603 | |
| 604 | makeLinkType string |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 605 | // Kythe (source file indexer) paths for this compilation module |
| 606 | kytheFiles android.Paths |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 607 | |
| 608 | // For apex variants, this is set as apex.min_sdk_version |
| 609 | apexSdkVersion int |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 612 | func (c *Module) Toc() android.OptionalPath { |
| 613 | if c.linker != nil { |
| 614 | if library, ok := c.linker.(libraryInterface); ok { |
| 615 | return library.toc() |
| 616 | } |
| 617 | } |
| 618 | panic(fmt.Errorf("Toc() called on non-library module: %q", c.BaseModuleName())) |
| 619 | } |
| 620 | |
| 621 | func (c *Module) ApiLevel() string { |
| 622 | if c.linker != nil { |
| 623 | if stub, ok := c.linker.(*stubDecorator); ok { |
| 624 | return stub.properties.ApiLevel |
| 625 | } |
| 626 | } |
| 627 | panic(fmt.Errorf("ApiLevel() called on non-stub library module: %q", c.BaseModuleName())) |
| 628 | } |
| 629 | |
| 630 | func (c *Module) Static() bool { |
| 631 | if c.linker != nil { |
| 632 | if library, ok := c.linker.(libraryInterface); ok { |
| 633 | return library.static() |
| 634 | } |
| 635 | } |
| 636 | panic(fmt.Errorf("Static() called on non-library module: %q", c.BaseModuleName())) |
| 637 | } |
| 638 | |
| 639 | func (c *Module) Shared() bool { |
| 640 | if c.linker != nil { |
| 641 | if library, ok := c.linker.(libraryInterface); ok { |
| 642 | return library.shared() |
| 643 | } |
| 644 | } |
| 645 | panic(fmt.Errorf("Shared() called on non-library module: %q", c.BaseModuleName())) |
| 646 | } |
| 647 | |
| 648 | func (c *Module) SelectedStl() string { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 649 | if c.stl != nil { |
| 650 | return c.stl.Properties.SelectedStl |
| 651 | } |
| 652 | return "" |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | func (c *Module) ToolchainLibrary() bool { |
| 656 | if _, ok := c.linker.(*toolchainLibraryDecorator); ok { |
| 657 | return true |
| 658 | } |
| 659 | return false |
| 660 | } |
| 661 | |
| 662 | func (c *Module) NdkPrebuiltStl() bool { |
| 663 | if _, ok := c.linker.(*ndkPrebuiltStlLinker); ok { |
| 664 | return true |
| 665 | } |
| 666 | return false |
| 667 | } |
| 668 | |
| 669 | func (c *Module) StubDecorator() bool { |
| 670 | if _, ok := c.linker.(*stubDecorator); ok { |
| 671 | return true |
| 672 | } |
| 673 | return false |
| 674 | } |
| 675 | |
| 676 | func (c *Module) SdkVersion() string { |
| 677 | return String(c.Properties.Sdk_version) |
| 678 | } |
| 679 | |
Artur Satayev | 480e25b | 2020-04-27 18:53:18 +0100 | [diff] [blame] | 680 | func (c *Module) MinSdkVersion() string { |
| 681 | return String(c.Properties.Min_sdk_version) |
| 682 | } |
| 683 | |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 684 | func (c *Module) SplitPerApiLevel() bool { |
| 685 | if linker, ok := c.linker.(*objectLinker); ok { |
| 686 | return linker.isCrt() |
| 687 | } |
| 688 | return false |
| 689 | } |
| 690 | |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 691 | func (c *Module) AlwaysSdk() bool { |
| 692 | return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only) |
| 693 | } |
| 694 | |
Ivan Lozano | e0833b1 | 2019-11-06 19:15:49 -0800 | [diff] [blame] | 695 | func (c *Module) IncludeDirs() android.Paths { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 696 | if c.linker != nil { |
| 697 | if library, ok := c.linker.(exportedFlagsProducer); ok { |
| 698 | return library.exportedDirs() |
| 699 | } |
| 700 | } |
| 701 | panic(fmt.Errorf("IncludeDirs called on non-exportedFlagsProducer module: %q", c.BaseModuleName())) |
| 702 | } |
| 703 | |
| 704 | func (c *Module) HasStaticVariant() bool { |
| 705 | if c.staticVariant != nil { |
| 706 | return true |
| 707 | } |
| 708 | return false |
| 709 | } |
| 710 | |
| 711 | func (c *Module) GetStaticVariant() LinkableInterface { |
| 712 | return c.staticVariant |
| 713 | } |
| 714 | |
| 715 | func (c *Module) SetDepsInLinkOrder(depsInLinkOrder []android.Path) { |
| 716 | c.depsInLinkOrder = depsInLinkOrder |
| 717 | } |
| 718 | |
| 719 | func (c *Module) GetDepsInLinkOrder() []android.Path { |
| 720 | return c.depsInLinkOrder |
| 721 | } |
| 722 | |
| 723 | func (c *Module) StubsVersions() []string { |
| 724 | if c.linker != nil { |
| 725 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 726 | return library.Properties.Stubs.Versions |
| 727 | } |
| 728 | } |
| 729 | panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName())) |
| 730 | } |
| 731 | |
| 732 | func (c *Module) CcLibrary() bool { |
| 733 | if c.linker != nil { |
| 734 | if _, ok := c.linker.(*libraryDecorator); ok { |
| 735 | return true |
| 736 | } |
| 737 | } |
| 738 | return false |
| 739 | } |
| 740 | |
| 741 | func (c *Module) CcLibraryInterface() bool { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 742 | if _, ok := c.linker.(libraryInterface); ok { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 743 | return true |
| 744 | } |
| 745 | return false |
| 746 | } |
| 747 | |
Ivan Lozano | 2b26297 | 2019-11-21 12:30:50 -0800 | [diff] [blame] | 748 | func (c *Module) NonCcVariants() bool { |
| 749 | return false |
| 750 | } |
| 751 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 752 | func (c *Module) SetBuildStubs() { |
| 753 | if c.linker != nil { |
| 754 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 755 | library.MutatedProperties.BuildStubs = true |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 756 | c.Properties.HideFromMake = true |
| 757 | c.sanitize = nil |
| 758 | c.stl = nil |
| 759 | c.Properties.PreventInstall = true |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 760 | return |
| 761 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 762 | if _, ok := c.linker.(*llndkStubDecorator); ok { |
| 763 | c.Properties.HideFromMake = true |
| 764 | return |
| 765 | } |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 766 | } |
| 767 | panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName())) |
| 768 | } |
| 769 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 770 | func (c *Module) BuildStubs() bool { |
| 771 | if c.linker != nil { |
| 772 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 773 | return library.buildStubs() |
| 774 | } |
| 775 | } |
| 776 | panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName())) |
| 777 | } |
| 778 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 779 | func (c *Module) SetStubsVersions(version string) { |
| 780 | if c.linker != nil { |
| 781 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 782 | library.MutatedProperties.StubsVersion = version |
| 783 | return |
| 784 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 785 | if llndk, ok := c.linker.(*llndkStubDecorator); ok { |
| 786 | llndk.libraryDecorator.MutatedProperties.StubsVersion = version |
| 787 | return |
| 788 | } |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 789 | } |
| 790 | panic(fmt.Errorf("SetStubsVersions called on non-library module: %q", c.BaseModuleName())) |
| 791 | } |
| 792 | |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 793 | func (c *Module) StubsVersion() string { |
| 794 | if c.linker != nil { |
| 795 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 796 | return library.MutatedProperties.StubsVersion |
| 797 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 798 | if llndk, ok := c.linker.(*llndkStubDecorator); ok { |
| 799 | return llndk.libraryDecorator.MutatedProperties.StubsVersion |
| 800 | } |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 801 | } |
| 802 | panic(fmt.Errorf("StubsVersion called on non-library module: %q", c.BaseModuleName())) |
| 803 | } |
| 804 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 805 | func (c *Module) SetStatic() { |
| 806 | if c.linker != nil { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 807 | if library, ok := c.linker.(libraryInterface); ok { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 808 | library.setStatic() |
| 809 | return |
| 810 | } |
| 811 | } |
| 812 | panic(fmt.Errorf("SetStatic called on non-library module: %q", c.BaseModuleName())) |
| 813 | } |
| 814 | |
| 815 | func (c *Module) SetShared() { |
| 816 | if c.linker != nil { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 817 | if library, ok := c.linker.(libraryInterface); ok { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 818 | library.setShared() |
| 819 | return |
| 820 | } |
| 821 | } |
| 822 | panic(fmt.Errorf("SetShared called on non-library module: %q", c.BaseModuleName())) |
| 823 | } |
| 824 | |
| 825 | func (c *Module) BuildStaticVariant() bool { |
| 826 | if c.linker != nil { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 827 | if library, ok := c.linker.(libraryInterface); ok { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 828 | return library.buildStatic() |
| 829 | } |
| 830 | } |
| 831 | panic(fmt.Errorf("BuildStaticVariant called on non-library module: %q", c.BaseModuleName())) |
| 832 | } |
| 833 | |
| 834 | func (c *Module) BuildSharedVariant() bool { |
| 835 | if c.linker != nil { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 836 | if library, ok := c.linker.(libraryInterface); ok { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 837 | return library.buildShared() |
| 838 | } |
| 839 | } |
| 840 | panic(fmt.Errorf("BuildSharedVariant called on non-library module: %q", c.BaseModuleName())) |
| 841 | } |
| 842 | |
| 843 | func (c *Module) Module() android.Module { |
| 844 | return c |
| 845 | } |
| 846 | |
Jiyong Park | c20eee3 | 2018-09-05 22:36:17 +0900 | [diff] [blame] | 847 | func (c *Module) OutputFile() android.OptionalPath { |
| 848 | return c.outputFile |
| 849 | } |
| 850 | |
Ivan Lozano | a0cd8f9 | 2020-04-09 09:56:02 -0400 | [diff] [blame] | 851 | func (c *Module) CoverageFiles() android.Paths { |
| 852 | if c.linker != nil { |
| 853 | if library, ok := c.linker.(libraryInterface); ok { |
| 854 | return library.objs().coverageFiles |
| 855 | } |
| 856 | } |
| 857 | panic(fmt.Errorf("CoverageFiles called on non-library module: %q", c.BaseModuleName())) |
| 858 | } |
| 859 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 860 | var _ LinkableInterface = (*Module)(nil) |
| 861 | |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 862 | func (c *Module) UnstrippedOutputFile() android.Path { |
Jiyong Park | af6d895 | 2019-01-31 12:21:23 +0900 | [diff] [blame] | 863 | if c.linker != nil { |
| 864 | return c.linker.unstrippedOutputFilePath() |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 865 | } |
| 866 | return nil |
| 867 | } |
| 868 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 869 | func (c *Module) CoverageOutputFile() android.OptionalPath { |
| 870 | if c.linker != nil { |
| 871 | return c.linker.coverageOutputFilePath() |
| 872 | } |
| 873 | return android.OptionalPath{} |
| 874 | } |
| 875 | |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 876 | func (c *Module) RelativeInstallPath() string { |
| 877 | if c.installer != nil { |
| 878 | return c.installer.relativeInstallPath() |
| 879 | } |
| 880 | return "" |
| 881 | } |
| 882 | |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 883 | func (c *Module) VndkVersion() string { |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 884 | return c.Properties.VndkVersion |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 885 | } |
| 886 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 887 | func (c *Module) Init() android.Module { |
Dan Willemsen | f923f2b | 2018-05-09 13:45:03 -0700 | [diff] [blame] | 888 | c.AddProperties(&c.Properties, &c.VendorProperties) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 889 | if c.compiler != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 890 | c.AddProperties(c.compiler.compilerProps()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 891 | } |
| 892 | if c.linker != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 893 | c.AddProperties(c.linker.linkerProps()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 894 | } |
| 895 | if c.installer != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 896 | c.AddProperties(c.installer.installerProps()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 897 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 898 | if c.stl != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 899 | c.AddProperties(c.stl.props()...) |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 900 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 901 | if c.sanitize != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 902 | c.AddProperties(c.sanitize.props()...) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 903 | } |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 904 | if c.coverage != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 905 | c.AddProperties(c.coverage.props()...) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 906 | } |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 907 | if c.sabi != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 908 | c.AddProperties(c.sabi.props()...) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 909 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 910 | if c.vndkdep != nil { |
| 911 | c.AddProperties(c.vndkdep.props()...) |
| 912 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 913 | if c.lto != nil { |
| 914 | c.AddProperties(c.lto.props()...) |
| 915 | } |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 916 | if c.pgo != nil { |
| 917 | c.AddProperties(c.pgo.props()...) |
| 918 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 919 | for _, feature := range c.features { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 920 | c.AddProperties(feature.props()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 921 | } |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 922 | |
Colin Cross | a9d8bee | 2018-10-02 13:59:46 -0700 | [diff] [blame] | 923 | c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool { |
Elliott Hughes | 79ae341 | 2020-04-17 15:49:49 -0700 | [diff] [blame] | 924 | // Windows builds always prefer 32-bit |
| 925 | return class == android.HostCross |
Colin Cross | a9d8bee | 2018-10-02 13:59:46 -0700 | [diff] [blame] | 926 | }) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 927 | android.InitAndroidArchModule(c, c.hod, c.multilib) |
Jiyong Park | 7916bfc | 2019-09-30 19:13:12 +0900 | [diff] [blame] | 928 | android.InitApexModule(c) |
Jiyong Park | d1063c1 | 2019-07-17 20:08:41 +0900 | [diff] [blame] | 929 | android.InitSdkAwareModule(c) |
Jooyung Han | 18020ea | 2019-11-13 10:50:48 +0900 | [diff] [blame] | 930 | android.InitDefaultableModule(c) |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 931 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 932 | return c |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 933 | } |
| 934 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 935 | // Returns true for dependency roots (binaries) |
| 936 | // TODO(ccross): also handle dlopenable libraries |
| 937 | func (c *Module) isDependencyRoot() bool { |
| 938 | if root, ok := c.linker.(interface { |
| 939 | isDependencyRoot() bool |
| 940 | }); ok { |
| 941 | return root.isDependencyRoot() |
| 942 | } |
| 943 | return false |
| 944 | } |
| 945 | |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 946 | // Returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64. |
| 947 | // "product" and "vendor" variant modules return true for this function. |
| 948 | // When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true", |
| 949 | // "soc_specific: true" and more vendor installed modules are included here. |
| 950 | // When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "vendor_available: true" or |
| 951 | // "product_specific: true" modules are included here. |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 952 | func (c *Module) UseVndk() bool { |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 953 | return c.Properties.VndkVersion != "" |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 954 | } |
| 955 | |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 956 | func (c *Module) canUseSdk() bool { |
| 957 | return c.Os() == android.Android && !c.UseVndk() && !c.InRamdisk() && !c.InRecovery() |
| 958 | } |
| 959 | |
| 960 | func (c *Module) UseSdk() bool { |
| 961 | if c.canUseSdk() { |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 962 | return String(c.Properties.Sdk_version) != "" || c.SplitPerApiLevel() |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 963 | } |
| 964 | return false |
| 965 | } |
| 966 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 967 | func (c *Module) isCoverageVariant() bool { |
| 968 | return c.coverage.Properties.IsCoverageVariant |
| 969 | } |
| 970 | |
Peter Collingbourne | ad84f97 | 2019-12-17 16:46:18 -0800 | [diff] [blame] | 971 | func (c *Module) IsNdk() bool { |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 972 | return inList(c.Name(), ndkKnownLibs) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 973 | } |
| 974 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 975 | func (c *Module) isLlndk(config android.Config) bool { |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 976 | // Returns true for both LLNDK (public) and LLNDK-private libs. |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 977 | return isLlndkLibrary(c.BaseModuleName(), config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 978 | } |
| 979 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 980 | func (c *Module) isLlndkPublic(config android.Config) bool { |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 981 | // Returns true only for LLNDK (public) libs. |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 982 | name := c.BaseModuleName() |
| 983 | return isLlndkLibrary(name, config) && !isVndkPrivateLibrary(name, config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 984 | } |
| 985 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 986 | func (c *Module) isVndkPrivate(config android.Config) bool { |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 987 | // Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private. |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 988 | return isVndkPrivateLibrary(c.BaseModuleName(), config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 989 | } |
| 990 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 991 | func (c *Module) IsVndk() bool { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 992 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 993 | return vndkdep.isVndk() |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 994 | } |
| 995 | return false |
| 996 | } |
| 997 | |
Yi Kong | 7e53c57 | 2018-02-14 18:16:12 +0800 | [diff] [blame] | 998 | func (c *Module) isPgoCompile() bool { |
| 999 | if pgo := c.pgo; pgo != nil { |
| 1000 | return pgo.Properties.PgoCompile |
| 1001 | } |
| 1002 | return false |
| 1003 | } |
| 1004 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 1005 | func (c *Module) isNDKStubLibrary() bool { |
| 1006 | if _, ok := c.compiler.(*stubDecorator); ok { |
| 1007 | return true |
| 1008 | } |
| 1009 | return false |
| 1010 | } |
| 1011 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1012 | func (c *Module) isVndkSp() bool { |
| 1013 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 1014 | return vndkdep.isVndkSp() |
| 1015 | } |
| 1016 | return false |
| 1017 | } |
| 1018 | |
| 1019 | func (c *Module) isVndkExt() bool { |
| 1020 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 1021 | return vndkdep.isVndkExt() |
| 1022 | } |
| 1023 | return false |
| 1024 | } |
| 1025 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 1026 | func (c *Module) MustUseVendorVariant() bool { |
Jooyung Han | 097087b | 2019-10-22 19:32:18 +0900 | [diff] [blame] | 1027 | return c.isVndkSp() || c.Properties.MustUseVendorVariant |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 1028 | } |
| 1029 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1030 | func (c *Module) getVndkExtendsModuleName() string { |
| 1031 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 1032 | return vndkdep.getVndkExtendsModuleName() |
| 1033 | } |
| 1034 | return "" |
| 1035 | } |
| 1036 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1037 | func (c *Module) IsStubs() bool { |
| 1038 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 1039 | return library.buildStubs() |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 1040 | } else if _, ok := c.linker.(*llndkStubDecorator); ok { |
| 1041 | return true |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1042 | } |
| 1043 | return false |
| 1044 | } |
| 1045 | |
| 1046 | func (c *Module) HasStubsVariants() bool { |
| 1047 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 1048 | return len(library.Properties.Stubs.Versions) > 0 |
| 1049 | } |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 1050 | if library, ok := c.linker.(*prebuiltLibraryLinker); ok { |
| 1051 | return len(library.Properties.Stubs.Versions) > 0 |
| 1052 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1053 | return false |
| 1054 | } |
| 1055 | |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 1056 | func (c *Module) bootstrap() bool { |
| 1057 | return Bool(c.Properties.Bootstrap) |
| 1058 | } |
| 1059 | |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 1060 | func (c *Module) nativeCoverage() bool { |
Pirama Arumuga Nainar | 5f69b9a | 2019-09-12 13:18:48 -0700 | [diff] [blame] | 1061 | // Bug: http://b/137883967 - native-bridge modules do not currently work with coverage |
| 1062 | if c.Target().NativeBridge == android.NativeBridgeEnabled { |
| 1063 | return false |
| 1064 | } |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 1065 | return c.linker != nil && c.linker.nativeCoverage() |
| 1066 | } |
| 1067 | |
Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1068 | func (c *Module) isSnapshotPrebuilt() bool { |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 1069 | if p, ok := c.linker.(interface{ isSnapshotPrebuilt() bool }); ok { |
| 1070 | return p.isSnapshotPrebuilt() |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1071 | } |
| 1072 | return false |
Inseob Kim | 8471cda | 2019-11-15 09:59:12 +0900 | [diff] [blame] | 1073 | } |
| 1074 | |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 1075 | func (c *Module) ExportedIncludeDirs() android.Paths { |
| 1076 | if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok { |
| 1077 | return flagsProducer.exportedDirs() |
| 1078 | } |
Jiyong Park | 232e785 | 2019-11-04 12:23:40 +0900 | [diff] [blame] | 1079 | return nil |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | func (c *Module) ExportedSystemIncludeDirs() android.Paths { |
| 1083 | if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok { |
| 1084 | return flagsProducer.exportedSystemDirs() |
| 1085 | } |
Jiyong Park | 232e785 | 2019-11-04 12:23:40 +0900 | [diff] [blame] | 1086 | return nil |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | func (c *Module) ExportedFlags() []string { |
| 1090 | if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok { |
| 1091 | return flagsProducer.exportedFlags() |
| 1092 | } |
Jiyong Park | 232e785 | 2019-11-04 12:23:40 +0900 | [diff] [blame] | 1093 | return nil |
| 1094 | } |
| 1095 | |
| 1096 | func (c *Module) ExportedDeps() android.Paths { |
| 1097 | if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok { |
| 1098 | return flagsProducer.exportedDeps() |
| 1099 | } |
| 1100 | return nil |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 1101 | } |
| 1102 | |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 1103 | func (c *Module) ExportedGeneratedHeaders() android.Paths { |
| 1104 | if flagsProducer, ok := c.linker.(exportedFlagsProducer); ok { |
| 1105 | return flagsProducer.exportedGeneratedHeaders() |
| 1106 | } |
| 1107 | return nil |
| 1108 | } |
| 1109 | |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 1110 | func isBionic(name string) bool { |
| 1111 | switch name { |
Martin Stjernholm | 203489b | 2019-11-11 15:33:27 +0000 | [diff] [blame] | 1112 | case "libc", "libm", "libdl", "libdl_android", "linker": |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 1113 | return true |
| 1114 | } |
| 1115 | return false |
| 1116 | } |
| 1117 | |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 1118 | func InstallToBootstrap(name string, config android.Config) bool { |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 1119 | if name == "libclang_rt.hwasan-aarch64-android" { |
Jooyung Han | 8ce8db9 | 2020-05-15 19:05:05 +0900 | [diff] [blame] | 1120 | return true |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 1121 | } |
| 1122 | return isBionic(name) |
| 1123 | } |
| 1124 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1125 | func (c *Module) XrefCcFiles() android.Paths { |
| 1126 | return c.kytheFiles |
| 1127 | } |
| 1128 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1129 | type baseModuleContext struct { |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1130 | android.BaseModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1131 | moduleContextImpl |
| 1132 | } |
| 1133 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 1134 | type depsContext struct { |
| 1135 | android.BottomUpMutatorContext |
| 1136 | moduleContextImpl |
| 1137 | } |
| 1138 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1139 | type moduleContext struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1140 | android.ModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1141 | moduleContextImpl |
| 1142 | } |
| 1143 | |
| 1144 | type moduleContextImpl struct { |
| 1145 | mod *Module |
| 1146 | ctx BaseModuleContext |
| 1147 | } |
| 1148 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 1149 | func (ctx *moduleContextImpl) toolchain() config.Toolchain { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1150 | return ctx.mod.toolchain(ctx.ctx) |
| 1151 | } |
| 1152 | |
| 1153 | func (ctx *moduleContextImpl) static() bool { |
Vishwath Mohan | b743e9c | 2017-11-01 09:20:21 +0000 | [diff] [blame] | 1154 | return ctx.mod.static() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1155 | } |
| 1156 | |
| 1157 | func (ctx *moduleContextImpl) staticBinary() bool { |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 1158 | return ctx.mod.staticBinary() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1159 | } |
| 1160 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 1161 | func (ctx *moduleContextImpl) header() bool { |
| 1162 | return ctx.mod.header() |
| 1163 | } |
| 1164 | |
Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 1165 | func (ctx *moduleContextImpl) binary() bool { |
| 1166 | return ctx.mod.binary() |
| 1167 | } |
| 1168 | |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 1169 | func (ctx *moduleContextImpl) object() bool { |
| 1170 | return ctx.mod.object() |
| 1171 | } |
| 1172 | |
Jooyung Han | ccce2f2 | 2020-03-07 03:45:53 +0900 | [diff] [blame] | 1173 | func (ctx *moduleContextImpl) canUseSdk() bool { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 1174 | return ctx.mod.canUseSdk() |
Jooyung Han | ccce2f2 | 2020-03-07 03:45:53 +0900 | [diff] [blame] | 1175 | } |
| 1176 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1177 | func (ctx *moduleContextImpl) useSdk() bool { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 1178 | return ctx.mod.UseSdk() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1179 | } |
| 1180 | |
| 1181 | func (ctx *moduleContextImpl) sdkVersion() string { |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 1182 | if ctx.ctx.Device() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1183 | if ctx.useVndk() { |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 1184 | vndkVer := ctx.mod.VndkVersion() |
Jooyung Han | 03302ee | 2020-04-08 09:22:26 +0900 | [diff] [blame] | 1185 | if inList(vndkVer, ctx.ctx.Config().PlatformVersionActiveCodenames()) { |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 1186 | return "current" |
Justin Yun | 732aa6a | 2018-03-23 17:43:47 +0900 | [diff] [blame] | 1187 | } |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 1188 | return vndkVer |
Dan Willemsen | d2ede87 | 2016-11-18 14:54:24 -0800 | [diff] [blame] | 1189 | } |
Justin Yun | 732aa6a | 2018-03-23 17:43:47 +0900 | [diff] [blame] | 1190 | return String(ctx.mod.Properties.Sdk_version) |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 1191 | } |
| 1192 | return "" |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1193 | } |
| 1194 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1195 | func (ctx *moduleContextImpl) useVndk() bool { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 1196 | return ctx.mod.UseVndk() |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1197 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1198 | |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 1199 | func (ctx *moduleContextImpl) isNdk() bool { |
Peter Collingbourne | ad84f97 | 2019-12-17 16:46:18 -0800 | [diff] [blame] | 1200 | return ctx.mod.IsNdk() |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 1201 | } |
| 1202 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1203 | func (ctx *moduleContextImpl) isLlndk(config android.Config) bool { |
| 1204 | return ctx.mod.isLlndk(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 1205 | } |
| 1206 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1207 | func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool { |
| 1208 | return ctx.mod.isLlndkPublic(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 1209 | } |
| 1210 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1211 | func (ctx *moduleContextImpl) isVndkPrivate(config android.Config) bool { |
| 1212 | return ctx.mod.isVndkPrivate(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 1213 | } |
| 1214 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1215 | func (ctx *moduleContextImpl) isVndk() bool { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 1216 | return ctx.mod.IsVndk() |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1217 | } |
| 1218 | |
Yi Kong | 7e53c57 | 2018-02-14 18:16:12 +0800 | [diff] [blame] | 1219 | func (ctx *moduleContextImpl) isPgoCompile() bool { |
| 1220 | return ctx.mod.isPgoCompile() |
| 1221 | } |
| 1222 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 1223 | func (ctx *moduleContextImpl) isNDKStubLibrary() bool { |
| 1224 | return ctx.mod.isNDKStubLibrary() |
| 1225 | } |
| 1226 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1227 | func (ctx *moduleContextImpl) isVndkSp() bool { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1228 | return ctx.mod.isVndkSp() |
| 1229 | } |
| 1230 | |
| 1231 | func (ctx *moduleContextImpl) isVndkExt() bool { |
| 1232 | return ctx.mod.isVndkExt() |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1233 | } |
| 1234 | |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 1235 | func (ctx *moduleContextImpl) mustUseVendorVariant() bool { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 1236 | return ctx.mod.MustUseVendorVariant() |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 1237 | } |
| 1238 | |
Logan Chien | 2f2b890 | 2018-07-10 15:01:19 +0800 | [diff] [blame] | 1239 | // Check whether ABI dumps should be created for this module. |
Hsin-Yi Chen | af17d74 | 2019-07-29 17:46:59 +0800 | [diff] [blame] | 1240 | func (ctx *moduleContextImpl) shouldCreateSourceAbiDump() bool { |
Logan Chien | 2f2b890 | 2018-07-10 15:01:19 +0800 | [diff] [blame] | 1241 | if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") { |
| 1242 | return false |
Jayant Chowdhary | ea0a2e1 | 2018-03-01 19:12:16 -0800 | [diff] [blame] | 1243 | } |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 1244 | |
Hsin-Yi Chen | f81bb65 | 2020-04-07 21:42:19 +0800 | [diff] [blame] | 1245 | // Coverage builds have extra symbols. |
| 1246 | if ctx.mod.isCoverageVariant() { |
| 1247 | return false |
| 1248 | } |
| 1249 | |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 1250 | if ctx.ctx.Fuchsia() { |
| 1251 | return false |
| 1252 | } |
| 1253 | |
Logan Chien | 2f2b890 | 2018-07-10 15:01:19 +0800 | [diff] [blame] | 1254 | if sanitize := ctx.mod.sanitize; sanitize != nil { |
| 1255 | if !sanitize.isVariantOnProductionDevice() { |
| 1256 | return false |
| 1257 | } |
| 1258 | } |
| 1259 | if !ctx.ctx.Device() { |
| 1260 | // Host modules do not need ABI dumps. |
| 1261 | return false |
| 1262 | } |
Hsin-Yi Chen | d245168 | 2020-01-10 16:47:50 +0800 | [diff] [blame] | 1263 | if ctx.isStubs() || ctx.isNDKStubLibrary() { |
Hsin-Yi Chen | f6a9546 | 2019-06-25 14:46:52 +0800 | [diff] [blame] | 1264 | // Stubs do not need ABI dumps. |
| 1265 | return false |
| 1266 | } |
Hsin-Yi Chen | af17d74 | 2019-07-29 17:46:59 +0800 | [diff] [blame] | 1267 | return true |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1268 | } |
| 1269 | |
Dan Willemsen | 8146b2f | 2016-03-30 21:00:30 -0700 | [diff] [blame] | 1270 | func (ctx *moduleContextImpl) selectedStl() string { |
| 1271 | if stl := ctx.mod.stl; stl != nil { |
| 1272 | return stl.Properties.SelectedStl |
| 1273 | } |
| 1274 | return "" |
| 1275 | } |
| 1276 | |
Ivan Lozano | bd72126 | 2018-11-27 14:33:03 -0800 | [diff] [blame] | 1277 | func (ctx *moduleContextImpl) useClangLld(actx ModuleContext) bool { |
| 1278 | return ctx.mod.linker.useClangLld(actx) |
| 1279 | } |
| 1280 | |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1281 | func (ctx *moduleContextImpl) baseModuleName() string { |
| 1282 | return ctx.mod.ModuleBase.BaseModuleName() |
| 1283 | } |
| 1284 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1285 | func (ctx *moduleContextImpl) getVndkExtendsModuleName() string { |
| 1286 | return ctx.mod.getVndkExtendsModuleName() |
| 1287 | } |
| 1288 | |
Logan Chien | e274fc9 | 2019-12-03 11:18:32 -0800 | [diff] [blame] | 1289 | func (ctx *moduleContextImpl) isForPlatform() bool { |
| 1290 | return ctx.mod.IsForPlatform() |
| 1291 | } |
| 1292 | |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 1293 | func (ctx *moduleContextImpl) apexName() string { |
| 1294 | return ctx.mod.ApexName() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1295 | } |
| 1296 | |
Jooyung Han | ccce2f2 | 2020-03-07 03:45:53 +0900 | [diff] [blame] | 1297 | func (ctx *moduleContextImpl) apexSdkVersion() int { |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 1298 | return ctx.mod.apexSdkVersion |
Jooyung Han | ccce2f2 | 2020-03-07 03:45:53 +0900 | [diff] [blame] | 1299 | } |
| 1300 | |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1301 | func (ctx *moduleContextImpl) hasStubsVariants() bool { |
| 1302 | return ctx.mod.HasStubsVariants() |
| 1303 | } |
| 1304 | |
| 1305 | func (ctx *moduleContextImpl) isStubs() bool { |
| 1306 | return ctx.mod.IsStubs() |
| 1307 | } |
| 1308 | |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 1309 | func (ctx *moduleContextImpl) bootstrap() bool { |
| 1310 | return ctx.mod.bootstrap() |
| 1311 | } |
| 1312 | |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 1313 | func (ctx *moduleContextImpl) nativeCoverage() bool { |
| 1314 | return ctx.mod.nativeCoverage() |
| 1315 | } |
| 1316 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1317 | func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1318 | return &Module{ |
| 1319 | hod: hod, |
| 1320 | multilib: multilib, |
| 1321 | } |
| 1322 | } |
| 1323 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1324 | func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1325 | module := newBaseModule(hod, multilib) |
Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 1326 | module.features = []feature{ |
| 1327 | &tidyFeature{}, |
| 1328 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1329 | module.stl = &stl{} |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1330 | module.sanitize = &sanitize{} |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1331 | module.coverage = &coverage{} |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1332 | module.sabi = &sabi{} |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1333 | module.vndkdep = &vndkdep{} |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1334 | module.lto = <o{} |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 1335 | module.pgo = &pgo{} |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1336 | return module |
| 1337 | } |
| 1338 | |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1339 | func (c *Module) Prebuilt() *android.Prebuilt { |
| 1340 | if p, ok := c.linker.(prebuiltLinkerInterface); ok { |
| 1341 | return p.prebuilt() |
| 1342 | } |
| 1343 | return nil |
| 1344 | } |
| 1345 | |
| 1346 | func (c *Module) Name() string { |
| 1347 | name := c.ModuleBase.Name() |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 1348 | if p, ok := c.linker.(interface { |
| 1349 | Name(string) string |
| 1350 | }); ok { |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1351 | name = p.Name(name) |
| 1352 | } |
| 1353 | return name |
| 1354 | } |
| 1355 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 1356 | func (c *Module) Symlinks() []string { |
| 1357 | if p, ok := c.installer.(interface { |
| 1358 | symlinkList() []string |
| 1359 | }); ok { |
| 1360 | return p.symlinkList() |
| 1361 | } |
| 1362 | return nil |
| 1363 | } |
| 1364 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1365 | // orderDeps reorders dependencies into a list such that if module A depends on B, then |
| 1366 | // A will precede B in the resultant list. |
| 1367 | // This is convenient for passing into a linker. |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1368 | // Note that directSharedDeps should be the analogous static library for each shared lib dep |
| 1369 | func orderDeps(directStaticDeps []android.Path, directSharedDeps []android.Path, allTransitiveDeps map[android.Path][]android.Path) (orderedAllDeps []android.Path, orderedDeclaredDeps []android.Path) { |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1370 | // If A depends on B, then |
| 1371 | // Every list containing A will also contain B later in the list |
| 1372 | // So, after concatenating all lists, the final instance of B will have come from the same |
| 1373 | // original list as the final instance of A |
| 1374 | // So, the final instance of B will be later in the concatenation than the final A |
| 1375 | // So, keeping only the final instance of A and of B ensures that A is earlier in the output |
| 1376 | // list than B |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1377 | for _, dep := range directStaticDeps { |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1378 | orderedAllDeps = append(orderedAllDeps, dep) |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1379 | orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...) |
| 1380 | } |
| 1381 | for _, dep := range directSharedDeps { |
| 1382 | orderedAllDeps = append(orderedAllDeps, dep) |
| 1383 | orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1384 | } |
| 1385 | |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 1386 | orderedAllDeps = android.LastUniquePaths(orderedAllDeps) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1387 | |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1388 | // We don't want to add any new dependencies into directStaticDeps (to allow the caller to |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1389 | // intentionally exclude or replace any unwanted transitive dependencies), so we limit the |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1390 | // resultant list to only what the caller has chosen to include in directStaticDeps |
| 1391 | _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1392 | |
| 1393 | return orderedAllDeps, orderedDeclaredDeps |
| 1394 | } |
| 1395 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 1396 | func orderStaticModuleDeps(module LinkableInterface, staticDeps []LinkableInterface, sharedDeps []LinkableInterface) (results []android.Path) { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1397 | // convert Module to Path |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 1398 | var depsInLinkOrder []android.Path |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1399 | allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps)) |
| 1400 | staticDepFiles := []android.Path{} |
| 1401 | for _, dep := range staticDeps { |
Nicolas Geoffray | 0b78766 | 2020-02-04 18:27:55 +0000 | [diff] [blame] | 1402 | // The OutputFile may not be valid for a variant not present, and the AllowMissingDependencies flag is set. |
| 1403 | if dep.OutputFile().Valid() { |
| 1404 | allTransitiveDeps[dep.OutputFile().Path()] = dep.GetDepsInLinkOrder() |
| 1405 | staticDepFiles = append(staticDepFiles, dep.OutputFile().Path()) |
| 1406 | } |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1407 | } |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1408 | sharedDepFiles := []android.Path{} |
| 1409 | for _, sharedDep := range sharedDeps { |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 1410 | if sharedDep.HasStaticVariant() { |
| 1411 | staticAnalogue := sharedDep.GetStaticVariant() |
| 1412 | allTransitiveDeps[staticAnalogue.OutputFile().Path()] = staticAnalogue.GetDepsInLinkOrder() |
| 1413 | sharedDepFiles = append(sharedDepFiles, staticAnalogue.OutputFile().Path()) |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1414 | } |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1415 | } |
| 1416 | |
| 1417 | // reorder the dependencies based on transitive dependencies |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 1418 | depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps) |
| 1419 | module.SetDepsInLinkOrder(depsInLinkOrder) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1420 | |
| 1421 | return results |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1422 | } |
| 1423 | |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1424 | func (c *Module) IsTestPerSrcAllTestsVariation() bool { |
| 1425 | test, ok := c.linker.(testPerSrc) |
| 1426 | return ok && test.isAllTestsVariation() |
| 1427 | } |
| 1428 | |
Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 1429 | func (c *Module) DataPaths() []android.DataPath { |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1430 | if p, ok := c.installer.(interface { |
Chris Parsons | 216e10a | 2020-07-09 17:12:52 -0400 | [diff] [blame] | 1431 | dataPaths() []android.DataPath |
Liz Kammer | 1c14a21 | 2020-05-12 15:26:55 -0700 | [diff] [blame] | 1432 | }); ok { |
| 1433 | return p.dataPaths() |
| 1434 | } |
| 1435 | return nil |
| 1436 | } |
| 1437 | |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 1438 | func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string { |
| 1439 | // Returns the name suffix for product and vendor variants. If the VNDK version is not |
| 1440 | // "current", it will append the VNDK version to the name suffix. |
| 1441 | var vndkVersion string |
| 1442 | var nameSuffix string |
| 1443 | if c.inProduct() { |
| 1444 | vndkVersion = ctx.DeviceConfig().ProductVndkVersion() |
| 1445 | nameSuffix = productSuffix |
| 1446 | } else { |
| 1447 | vndkVersion = ctx.DeviceConfig().VndkVersion() |
| 1448 | nameSuffix = vendorSuffix |
| 1449 | } |
| 1450 | if vndkVersion == "current" { |
| 1451 | vndkVersion = ctx.DeviceConfig().PlatformVndkVersion() |
| 1452 | } |
| 1453 | if c.Properties.VndkVersion != vndkVersion { |
| 1454 | // add version suffix only if the module is using different vndk version than the |
| 1455 | // version in product or vendor partition. |
| 1456 | nameSuffix += "." + c.Properties.VndkVersion |
| 1457 | } |
| 1458 | return nameSuffix |
| 1459 | } |
| 1460 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1461 | func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { |
Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1462 | // Handle the case of a test module split by `test_per_src` mutator. |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 1463 | // |
| 1464 | // The `test_per_src` mutator adds an extra variation named "", depending on all the other |
| 1465 | // `test_per_src` variations of the test module. Set `outputFile` to an empty path for this |
| 1466 | // module and return early, as this module does not produce an output file per se. |
| 1467 | if c.IsTestPerSrcAllTestsVariation() { |
| 1468 | c.outputFile = android.OptionalPath{} |
| 1469 | return |
Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1470 | } |
| 1471 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 1472 | c.makeLinkType = c.getMakeLinkType(actx) |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1473 | |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 1474 | c.Properties.SubName = "" |
| 1475 | |
| 1476 | if c.Target().NativeBridge == android.NativeBridgeEnabled { |
| 1477 | c.Properties.SubName += nativeBridgeSuffix |
| 1478 | } |
| 1479 | |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 1480 | _, llndk := c.linker.(*llndkStubDecorator) |
| 1481 | _, llndkHeader := c.linker.(*llndkHeadersDecorator) |
| 1482 | if llndk || llndkHeader || (c.UseVndk() && c.HasVendorVariant()) { |
| 1483 | // .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is |
| 1484 | // added for product variant only when we have vendor and product variants with core |
| 1485 | // variant. The suffix is not added for vendor-only or product-only module. |
| 1486 | c.Properties.SubName += c.getNameSuffixWithVndkVersion(actx) |
| 1487 | } else if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok { |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 1488 | // .vendor suffix is added for backward compatibility with VNDK snapshot whose names with |
| 1489 | // such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp. |
| 1490 | c.Properties.SubName += vendorSuffix |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 1491 | } else if c.InRamdisk() && !c.OnlyInRamdisk() { |
| 1492 | c.Properties.SubName += ramdiskSuffix |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 1493 | } else if c.InRecovery() && !c.OnlyInRecovery() { |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 1494 | c.Properties.SubName += recoverySuffix |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 1495 | } else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) { |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 1496 | c.Properties.SubName += sdkSuffix |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 1497 | if c.SplitPerApiLevel() { |
| 1498 | c.Properties.SubName += "." + c.SdkVersion() |
| 1499 | } |
Inseob Kim | 64c4395 | 2019-08-26 16:52:35 +0900 | [diff] [blame] | 1500 | } |
| 1501 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1502 | ctx := &moduleContext{ |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1503 | ModuleContext: actx, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1504 | moduleContextImpl: moduleContextImpl{ |
| 1505 | mod: c, |
| 1506 | }, |
| 1507 | } |
| 1508 | ctx.ctx = ctx |
| 1509 | |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 1510 | deps := c.depsToPaths(ctx) |
| 1511 | if ctx.Failed() { |
| 1512 | return |
| 1513 | } |
| 1514 | |
Dan Willemsen | 8536d6b | 2018-10-07 20:54:34 -0700 | [diff] [blame] | 1515 | if c.Properties.Clang != nil && *c.Properties.Clang == false { |
| 1516 | ctx.PropertyErrorf("clang", "false (GCC) is no longer supported") |
| 1517 | } |
| 1518 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1519 | flags := Flags{ |
| 1520 | Toolchain: c.toolchain(ctx), |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1521 | EmitXrefs: ctx.Config().EmitXrefRules(), |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1522 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1523 | if c.compiler != nil { |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 1524 | flags = c.compiler.compilerFlags(ctx, flags, deps) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1525 | } |
| 1526 | if c.linker != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1527 | flags = c.linker.linkerFlags(ctx, flags) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1528 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1529 | if c.stl != nil { |
| 1530 | flags = c.stl.flags(ctx, flags) |
| 1531 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1532 | if c.sanitize != nil { |
| 1533 | flags = c.sanitize.flags(ctx, flags) |
| 1534 | } |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1535 | if c.coverage != nil { |
Pirama Arumuga Nainar | 82fe59b | 2019-07-02 14:55:35 -0700 | [diff] [blame] | 1536 | flags, deps = c.coverage.flags(ctx, flags, deps) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1537 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1538 | if c.lto != nil { |
| 1539 | flags = c.lto.flags(ctx, flags) |
| 1540 | } |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 1541 | if c.pgo != nil { |
| 1542 | flags = c.pgo.flags(ctx, flags) |
| 1543 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1544 | for _, feature := range c.features { |
| 1545 | flags = feature.flags(ctx, flags) |
| 1546 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1547 | if ctx.Failed() { |
| 1548 | return |
| 1549 | } |
| 1550 | |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 1551 | flags.Local.CFlags, _ = filterList(flags.Local.CFlags, config.IllegalFlags) |
| 1552 | flags.Local.CppFlags, _ = filterList(flags.Local.CppFlags, config.IllegalFlags) |
| 1553 | flags.Local.ConlyFlags, _ = filterList(flags.Local.ConlyFlags, config.IllegalFlags) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1554 | |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 1555 | flags.Local.CommonFlags = append(flags.Local.CommonFlags, deps.Flags...) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1556 | |
| 1557 | for _, dir := range deps.IncludeDirs { |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 1558 | flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1559 | } |
| 1560 | for _, dir := range deps.SystemIncludeDirs { |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 1561 | flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-isystem "+dir.String()) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1562 | } |
| 1563 | |
Fabien Sanglard | d61f1f4 | 2017-01-10 16:21:22 -0800 | [diff] [blame] | 1564 | c.flags = flags |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 1565 | // We need access to all the flags seen by a source file. |
| 1566 | if c.sabi != nil { |
| 1567 | flags = c.sabi.flags(ctx, flags) |
| 1568 | } |
Dan Willemsen | 98ab311 | 2019-08-27 21:20:40 -0700 | [diff] [blame] | 1569 | |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 1570 | flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.Local.AsFlags) |
Dan Willemsen | 98ab311 | 2019-08-27 21:20:40 -0700 | [diff] [blame] | 1571 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1572 | // Optimization to reduce size of build.ninja |
| 1573 | // Replace the long list of flags for each file with a module-local variable |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 1574 | ctx.Variable(pctx, "cflags", strings.Join(flags.Local.CFlags, " ")) |
| 1575 | ctx.Variable(pctx, "cppflags", strings.Join(flags.Local.CppFlags, " ")) |
| 1576 | ctx.Variable(pctx, "asflags", strings.Join(flags.Local.AsFlags, " ")) |
| 1577 | flags.Local.CFlags = []string{"$cflags"} |
| 1578 | flags.Local.CppFlags = []string{"$cppflags"} |
| 1579 | flags.Local.AsFlags = []string{"$asflags"} |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1580 | |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1581 | var objs Objects |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1582 | if c.compiler != nil { |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1583 | objs = c.compiler.compile(ctx, flags, deps) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1584 | if ctx.Failed() { |
| 1585 | return |
| 1586 | } |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1587 | c.kytheFiles = objs.kytheFiles |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1588 | } |
| 1589 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1590 | if c.linker != nil { |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1591 | outputFile := c.linker.link(ctx, flags, deps, objs) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1592 | if ctx.Failed() { |
| 1593 | return |
| 1594 | } |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1595 | c.outputFile = android.OptionalPathForPath(outputFile) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1596 | |
| 1597 | // If a lib is directly included in any of the APEXes, unhide the stubs |
| 1598 | // variant having the latest version gets visible to make. In addition, |
| 1599 | // the non-stubs variant is renamed to <libname>.bootstrap. This is to |
| 1600 | // force anything in the make world to link against the stubs library. |
| 1601 | // (unless it is explicitly referenced via .bootstrap suffix or the |
| 1602 | // module is marked with 'bootstrap: true'). |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 1603 | if c.HasStubsVariants() && |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 1604 | android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && !c.InRamdisk() && |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 1605 | !c.InRecovery() && !c.UseVndk() && !c.static() && !c.isCoverageVariant() && |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 1606 | c.IsStubs() { |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1607 | c.Properties.HideFromMake = false // unhide |
| 1608 | // Note: this is still non-installable |
| 1609 | } |
Inseob Kim | eda2e9c | 2020-03-03 22:06:32 +0900 | [diff] [blame] | 1610 | |
| 1611 | // glob exported headers for snapshot, if BOARD_VNDK_VERSION is current. |
| 1612 | if i, ok := c.linker.(snapshotLibraryInterface); ok && ctx.DeviceConfig().VndkVersion() == "current" { |
| 1613 | if isSnapshotAware(ctx, c) { |
| 1614 | i.collectHeadersForSnapshot(ctx) |
| 1615 | } |
| 1616 | } |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1617 | } |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 1618 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 1619 | if c.installable() { |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1620 | c.installer.install(ctx, c.outputFile.Path()) |
| 1621 | if ctx.Failed() { |
| 1622 | return |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1623 | } |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 1624 | } else if !proptools.BoolDefault(c.Properties.Installable, true) { |
| 1625 | // If the module has been specifically configure to not be installed then |
| 1626 | // skip the installation as otherwise it will break when running inside make |
| 1627 | // as the output path to install will not be specified. Not all uninstallable |
| 1628 | // modules can skip installation as some are needed for resolving make side |
| 1629 | // dependencies. |
| 1630 | c.SkipInstall() |
Dan Albert | c403f7c | 2015-03-18 14:01:18 -0700 | [diff] [blame] | 1631 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1632 | } |
| 1633 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1634 | func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1635 | if c.cachedToolchain == nil { |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 1636 | c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch()) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1637 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1638 | return c.cachedToolchain |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1639 | } |
| 1640 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1641 | func (c *Module) begin(ctx BaseModuleContext) { |
| 1642 | if c.compiler != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1643 | c.compiler.compilerInit(ctx) |
Colin Cross | 21b9a24 | 2015-03-24 14:15:58 -0700 | [diff] [blame] | 1644 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1645 | if c.linker != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1646 | c.linker.linkerInit(ctx) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1647 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1648 | if c.stl != nil { |
| 1649 | c.stl.begin(ctx) |
| 1650 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1651 | if c.sanitize != nil { |
| 1652 | c.sanitize.begin(ctx) |
| 1653 | } |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1654 | if c.coverage != nil { |
| 1655 | c.coverage.begin(ctx) |
| 1656 | } |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1657 | if c.sabi != nil { |
| 1658 | c.sabi.begin(ctx) |
| 1659 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1660 | if c.vndkdep != nil { |
| 1661 | c.vndkdep.begin(ctx) |
| 1662 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1663 | if c.lto != nil { |
| 1664 | c.lto.begin(ctx) |
| 1665 | } |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 1666 | if c.pgo != nil { |
| 1667 | c.pgo.begin(ctx) |
| 1668 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1669 | for _, feature := range c.features { |
| 1670 | feature.begin(ctx) |
| 1671 | } |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 1672 | if ctx.useSdk() && c.IsSdkVariant() { |
Dan Albert | f5415d7 | 2017-08-17 16:19:59 -0700 | [diff] [blame] | 1673 | version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch()) |
Dan Albert | 7fa7b2e | 2016-08-05 16:37:52 -0700 | [diff] [blame] | 1674 | if err != nil { |
| 1675 | ctx.PropertyErrorf("sdk_version", err.Error()) |
| 1676 | } |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 1677 | c.Properties.Sdk_version = StringPtr(version) |
Dan Albert | 7fa7b2e | 2016-08-05 16:37:52 -0700 | [diff] [blame] | 1678 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1679 | } |
| 1680 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 1681 | func (c *Module) deps(ctx DepsContext) Deps { |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1682 | deps := Deps{} |
| 1683 | |
| 1684 | if c.compiler != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1685 | deps = c.compiler.compilerDeps(ctx, deps) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1686 | } |
Pirama Arumuga Nainar | 0b882f0 | 2018-04-23 22:44:39 +0000 | [diff] [blame] | 1687 | // Add the PGO dependency (the clang_rt.profile runtime library), which |
| 1688 | // sometimes depends on symbols from libgcc, before libgcc gets added |
| 1689 | // in linkerDeps(). |
Pirama Arumuga Nainar | 49b53d5 | 2017-10-04 16:47:29 -0700 | [diff] [blame] | 1690 | if c.pgo != nil { |
| 1691 | deps = c.pgo.deps(ctx, deps) |
| 1692 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1693 | if c.linker != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1694 | deps = c.linker.linkerDeps(ctx, deps) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1695 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1696 | if c.stl != nil { |
| 1697 | deps = c.stl.deps(ctx, deps) |
| 1698 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1699 | if c.sanitize != nil { |
| 1700 | deps = c.sanitize.deps(ctx, deps) |
| 1701 | } |
Pirama Arumuga Nainar | 0b882f0 | 2018-04-23 22:44:39 +0000 | [diff] [blame] | 1702 | if c.coverage != nil { |
| 1703 | deps = c.coverage.deps(ctx, deps) |
| 1704 | } |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1705 | if c.sabi != nil { |
| 1706 | deps = c.sabi.deps(ctx, deps) |
| 1707 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1708 | if c.vndkdep != nil { |
| 1709 | deps = c.vndkdep.deps(ctx, deps) |
| 1710 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1711 | if c.lto != nil { |
| 1712 | deps = c.lto.deps(ctx, deps) |
| 1713 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1714 | for _, feature := range c.features { |
| 1715 | deps = feature.deps(ctx, deps) |
| 1716 | } |
| 1717 | |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 1718 | deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs) |
| 1719 | deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs) |
| 1720 | deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs) |
| 1721 | deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs) |
| 1722 | deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs) |
| 1723 | deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1724 | deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1725 | |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1726 | for _, lib := range deps.ReexportSharedLibHeaders { |
| 1727 | if !inList(lib, deps.SharedLibs) { |
| 1728 | ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib) |
| 1729 | } |
| 1730 | } |
| 1731 | |
| 1732 | for _, lib := range deps.ReexportStaticLibHeaders { |
| 1733 | if !inList(lib, deps.StaticLibs) { |
| 1734 | ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib) |
| 1735 | } |
| 1736 | } |
| 1737 | |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 1738 | for _, lib := range deps.ReexportHeaderLibHeaders { |
| 1739 | if !inList(lib, deps.HeaderLibs) { |
| 1740 | ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib) |
| 1741 | } |
| 1742 | } |
| 1743 | |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 1744 | for _, gen := range deps.ReexportGeneratedHeaders { |
| 1745 | if !inList(gen, deps.GeneratedHeaders) { |
| 1746 | ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen) |
| 1747 | } |
| 1748 | } |
| 1749 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1750 | return deps |
| 1751 | } |
| 1752 | |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1753 | func (c *Module) beginMutator(actx android.BottomUpMutatorContext) { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1754 | ctx := &baseModuleContext{ |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1755 | BaseModuleContext: actx, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1756 | moduleContextImpl: moduleContextImpl{ |
| 1757 | mod: c, |
| 1758 | }, |
| 1759 | } |
| 1760 | ctx.ctx = ctx |
| 1761 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1762 | c.begin(ctx) |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1763 | } |
| 1764 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1765 | // Split name#version into name and version |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 1766 | func StubsLibNameAndVersion(name string) (string, string) { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1767 | if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 { |
| 1768 | version := name[sharp+1:] |
| 1769 | libname := name[:sharp] |
| 1770 | return libname, version |
| 1771 | } |
| 1772 | return name, "" |
| 1773 | } |
| 1774 | |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 1775 | func GetCrtVariations(ctx android.BottomUpMutatorContext, |
| 1776 | m LinkableInterface) []blueprint.Variation { |
| 1777 | if ctx.Os() != android.Android { |
| 1778 | return nil |
| 1779 | } |
| 1780 | if m.UseSdk() { |
| 1781 | return []blueprint.Variation{ |
| 1782 | {Mutator: "sdk", Variation: "sdk"}, |
| 1783 | {Mutator: "ndk_api", Variation: m.SdkVersion()}, |
| 1784 | } |
| 1785 | } |
| 1786 | return []blueprint.Variation{ |
| 1787 | {Mutator: "sdk", Variation: ""}, |
| 1788 | } |
| 1789 | } |
| 1790 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 1791 | func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1792 | if !c.Enabled() { |
| 1793 | return |
| 1794 | } |
| 1795 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 1796 | ctx := &depsContext{ |
| 1797 | BottomUpMutatorContext: actx, |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1798 | moduleContextImpl: moduleContextImpl{ |
| 1799 | mod: c, |
| 1800 | }, |
| 1801 | } |
| 1802 | ctx.ctx = ctx |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1803 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1804 | deps := c.deps(ctx) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1805 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1806 | variantNdkLibs := []string{} |
| 1807 | variantLateNdkLibs := []string{} |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 1808 | if ctx.Os() == android.Android { |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1809 | // rewriteLibs takes a list of names of shared libraries and scans it for three types |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1810 | // of names: |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1811 | // |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1812 | // 1. Name of an NDK library that refers to a prebuilt module. |
| 1813 | // For each of these, it adds the name of the prebuilt module (which will be in |
| 1814 | // prebuilts/ndk) to the list of nonvariant libs. |
| 1815 | // 2. Name of an NDK library that refers to an ndk_library module. |
| 1816 | // For each of these, it adds the name of the ndk_library module to the list of |
| 1817 | // variant libs. |
| 1818 | // 3. Anything else (so anything that isn't an NDK library). |
| 1819 | // It adds these to the nonvariantLibs list. |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1820 | // |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1821 | // The caller can then know to add the variantLibs dependencies differently from the |
| 1822 | // nonvariantLibs |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1823 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1824 | vendorPublicLibraries := vendorPublicLibraries(actx.Config()) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1825 | vendorSnapshotSharedLibs := vendorSnapshotSharedLibs(actx.Config()) |
| 1826 | |
| 1827 | rewriteVendorLibs := func(lib string) string { |
| 1828 | if isLlndkLibrary(lib, ctx.Config()) { |
| 1829 | return lib + llndkLibrarySuffix |
| 1830 | } |
| 1831 | |
| 1832 | // only modules with BOARD_VNDK_VERSION uses snapshot. |
| 1833 | if c.VndkVersion() != actx.DeviceConfig().VndkVersion() { |
| 1834 | return lib |
| 1835 | } |
| 1836 | |
| 1837 | if snapshot, ok := vendorSnapshotSharedLibs.get(lib, actx.Arch().ArchType); ok { |
| 1838 | return snapshot |
| 1839 | } |
| 1840 | |
| 1841 | return lib |
| 1842 | } |
| 1843 | |
| 1844 | rewriteLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1845 | variantLibs = []string{} |
| 1846 | nonvariantLibs = []string{} |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1847 | for _, entry := range list { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1848 | // strip #version suffix out |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 1849 | name, _ := StubsLibNameAndVersion(entry) |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 1850 | if ctx.useSdk() && inList(name, ndkKnownLibs) { |
| 1851 | variantLibs = append(variantLibs, name+ndkLibrarySuffix) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1852 | } else if ctx.useVndk() { |
| 1853 | nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry)) |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1854 | } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1855 | vendorPublicLib := name + vendorPublicLibrarySuffix |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 1856 | if actx.OtherModuleExists(vendorPublicLib) { |
| 1857 | nonvariantLibs = append(nonvariantLibs, vendorPublicLib) |
| 1858 | } else { |
| 1859 | // This can happen if vendor_public_library module is defined in a |
| 1860 | // namespace that isn't visible to the current module. In that case, |
| 1861 | // link to the original library. |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1862 | nonvariantLibs = append(nonvariantLibs, name) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 1863 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1864 | } else { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1865 | // put name#version back |
Dan Willemsen | 7cbf5f8 | 2017-03-28 00:08:30 -0700 | [diff] [blame] | 1866 | nonvariantLibs = append(nonvariantLibs, entry) |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1867 | } |
| 1868 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1869 | return nonvariantLibs, variantLibs |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1870 | } |
| 1871 | |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1872 | deps.SharedLibs, variantNdkLibs = rewriteLibs(deps.SharedLibs) |
| 1873 | deps.LateSharedLibs, variantLateNdkLibs = rewriteLibs(deps.LateSharedLibs) |
| 1874 | deps.ReexportSharedLibHeaders, _ = rewriteLibs(deps.ReexportSharedLibHeaders) |
| 1875 | if ctx.useVndk() { |
| 1876 | for idx, lib := range deps.RuntimeLibs { |
| 1877 | deps.RuntimeLibs[idx] = rewriteVendorLibs(lib) |
| 1878 | } |
| 1879 | } |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1880 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1881 | |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1882 | buildStubs := false |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1883 | if c.linker != nil { |
| 1884 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 1885 | if library.buildStubs() { |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1886 | buildStubs = true |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1887 | } |
| 1888 | } |
| 1889 | } |
| 1890 | |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1891 | rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string { |
| 1892 | // only modules with BOARD_VNDK_VERSION uses snapshot. |
| 1893 | if c.VndkVersion() != actx.DeviceConfig().VndkVersion() { |
| 1894 | return lib |
| 1895 | } |
| 1896 | |
| 1897 | if snapshot, ok := snapshotMap.get(lib, actx.Arch().ArchType); ok { |
| 1898 | return snapshot |
| 1899 | } |
| 1900 | |
| 1901 | return lib |
| 1902 | } |
| 1903 | |
| 1904 | vendorSnapshotHeaderLibs := vendorSnapshotHeaderLibs(actx.Config()) |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 1905 | for _, lib := range deps.HeaderLibs { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1906 | depTag := libraryDependencyTag{Kind: headerLibraryDependency} |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 1907 | if inList(lib, deps.ReexportHeaderLibHeaders) { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1908 | depTag.reexportFlags = true |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 1909 | } |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1910 | |
| 1911 | lib = rewriteSnapshotLibs(lib, vendorSnapshotHeaderLibs) |
| 1912 | |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1913 | if buildStubs { |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 1914 | actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()), |
Colin Cross | 0f7d2ef | 2019-10-16 11:03:10 -0700 | [diff] [blame] | 1915 | depTag, lib) |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1916 | } else { |
| 1917 | actx.AddVariationDependencies(nil, depTag, lib) |
| 1918 | } |
| 1919 | } |
| 1920 | |
| 1921 | if buildStubs { |
| 1922 | // Stubs lib does not have dependency to other static/shared libraries. |
| 1923 | // Don't proceed. |
| 1924 | return |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 1925 | } |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 1926 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1927 | syspropImplLibraries := syspropImplLibraries(actx.Config()) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1928 | vendorSnapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config()) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1929 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 1930 | for _, lib := range deps.WholeStaticLibs { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1931 | depTag := libraryDependencyTag{Kind: staticLibraryDependency, wholeStatic: true, reexportFlags: true} |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 1932 | if impl, ok := syspropImplLibraries[lib]; ok { |
| 1933 | lib = impl |
| 1934 | } |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1935 | |
| 1936 | lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs) |
| 1937 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 1938 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1939 | {Mutator: "link", Variation: "static"}, |
| 1940 | }, depTag, lib) |
| 1941 | } |
| 1942 | |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1943 | for _, lib := range deps.StaticLibs { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1944 | depTag := libraryDependencyTag{Kind: staticLibraryDependency} |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1945 | if inList(lib, deps.ReexportStaticLibHeaders) { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1946 | depTag.reexportFlags = true |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1947 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1948 | |
| 1949 | if impl, ok := syspropImplLibraries[lib]; ok { |
| 1950 | lib = impl |
| 1951 | } |
| 1952 | |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1953 | lib = rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs) |
| 1954 | |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1955 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1956 | {Mutator: "link", Variation: "static"}, |
| 1957 | }, depTag, lib) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1958 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1959 | |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 1960 | // staticUnwinderDep is treated as staticDep for Q apexes |
| 1961 | // so that native libraries/binaries are linked with static unwinder |
| 1962 | // because Q libc doesn't have unwinder APIs |
| 1963 | if deps.StaticUnwinderIfLegacy { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1964 | depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true} |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 1965 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1966 | {Mutator: "link", Variation: "static"}, |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1967 | }, depTag, rewriteSnapshotLibs(staticUnwinder(actx), vendorSnapshotStaticLibs)) |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 1968 | } |
| 1969 | |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1970 | for _, lib := range deps.LateStaticLibs { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1971 | depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency} |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1972 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1973 | {Mutator: "link", Variation: "static"}, |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1974 | }, depTag, rewriteSnapshotLibs(lib, vendorSnapshotStaticLibs)) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 1975 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1976 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1977 | addSharedLibDependencies := func(depTag libraryDependencyTag, name string, version string) { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1978 | var variations []blueprint.Variation |
| 1979 | variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"}) |
Jooyung Han | 624d35c | 2020-04-10 12:57:24 +0900 | [diff] [blame] | 1980 | if version != "" && VersionVariantAvailable(c) { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1981 | // Version is explicitly specified. i.e. libFoo#30 |
| 1982 | variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version}) |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 1983 | depTag.explicitlyVersioned = true |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1984 | } |
| 1985 | actx.AddVariationDependencies(variations, depTag, name) |
| 1986 | |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1987 | // If the version is not specified, add dependency to all stubs libraries. |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1988 | // The stubs library will be used when the depending module is built for APEX and |
| 1989 | // the dependent module is not in the same APEX. |
Jooyung Han | 624d35c | 2020-04-10 12:57:24 +0900 | [diff] [blame] | 1990 | if version == "" && VersionVariantAvailable(c) { |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 1991 | for _, ver := range stubsVersionsFor(actx.Config())[name] { |
| 1992 | // Note that depTag.ExplicitlyVersioned is false in this case. |
| 1993 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1994 | {Mutator: "link", Variation: "shared"}, |
| 1995 | {Mutator: "version", Variation: ver}, |
| 1996 | }, depTag, name) |
| 1997 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1998 | } |
| 1999 | } |
| 2000 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2001 | // shared lib names without the #version suffix |
| 2002 | var sharedLibNames []string |
| 2003 | |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 2004 | for _, lib := range deps.SharedLibs { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2005 | depTag := libraryDependencyTag{Kind: sharedLibraryDependency} |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 2006 | if inList(lib, deps.ReexportSharedLibHeaders) { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2007 | depTag.reexportFlags = true |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 2008 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 2009 | |
| 2010 | if impl, ok := syspropImplLibraries[lib]; ok { |
| 2011 | lib = impl |
| 2012 | } |
| 2013 | |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 2014 | name, version := StubsLibNameAndVersion(lib) |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 2015 | sharedLibNames = append(sharedLibNames, name) |
| 2016 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2017 | addSharedLibDependencies(depTag, name, version) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 2018 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2019 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2020 | for _, lib := range deps.LateSharedLibs { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2021 | if inList(lib, sharedLibNames) { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2022 | // This is to handle the case that some of the late shared libs (libc, libdl, libm, ...) |
| 2023 | // are added also to SharedLibs with version (e.g., libc#10). If not skipped, we will be |
| 2024 | // linking against both the stubs lib and the non-stubs lib at the same time. |
| 2025 | continue |
| 2026 | } |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2027 | depTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency} |
| 2028 | addSharedLibDependencies(depTag, lib, "") |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2029 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2030 | |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 2031 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 2032 | {Mutator: "link", Variation: "shared"}, |
Chris Parsons | 79d66a5 | 2020-06-05 17:26:16 -0400 | [diff] [blame] | 2033 | }, dataLibDepTag, deps.DataLibs...) |
| 2034 | |
| 2035 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 2036 | {Mutator: "link", Variation: "shared"}, |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 2037 | }, runtimeDepTag, deps.RuntimeLibs...) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 2038 | |
Colin Cross | 6886183 | 2016-07-08 10:41:41 -0700 | [diff] [blame] | 2039 | actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...) |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 2040 | |
| 2041 | for _, gen := range deps.GeneratedHeaders { |
| 2042 | depTag := genHeaderDepTag |
| 2043 | if inList(gen, deps.ReexportGeneratedHeaders) { |
| 2044 | depTag = genHeaderExportDepTag |
| 2045 | } |
| 2046 | actx.AddDependency(c, depTag, gen) |
| 2047 | } |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 2048 | |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 2049 | actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2050 | |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 2051 | vendorSnapshotObjects := vendorSnapshotObjects(actx.Config()) |
| 2052 | |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 2053 | crtVariations := GetCrtVariations(ctx, c) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2054 | if deps.CrtBegin != "" { |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 2055 | actx.AddVariationDependencies(crtVariations, CrtBeginDepTag, |
| 2056 | rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects)) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2057 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2058 | if deps.CrtEnd != "" { |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 2059 | actx.AddVariationDependencies(crtVariations, CrtEndDepTag, |
| 2060 | rewriteSnapshotLibs(deps.CrtEnd, vendorSnapshotObjects)) |
Colin Cross | 21b9a24 | 2015-03-24 14:15:58 -0700 | [diff] [blame] | 2061 | } |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 2062 | if deps.LinkerFlagsFile != "" { |
| 2063 | actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile) |
| 2064 | } |
| 2065 | if deps.DynamicLinker != "" { |
| 2066 | actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 2067 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 2068 | |
| 2069 | version := ctx.sdkVersion() |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2070 | |
| 2071 | ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version} |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 2072 | actx.AddVariationDependencies([]blueprint.Variation{ |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 2073 | {Mutator: "ndk_api", Variation: version}, |
| 2074 | {Mutator: "link", Variation: "shared"}, |
| 2075 | }, ndkStubDepTag, variantNdkLibs...) |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2076 | |
| 2077 | ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version} |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 2078 | actx.AddVariationDependencies([]blueprint.Variation{ |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 2079 | {Mutator: "ndk_api", Variation: version}, |
| 2080 | {Mutator: "link", Variation: "shared"}, |
| 2081 | }, ndkLateStubDepTag, variantLateNdkLibs...) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2082 | |
| 2083 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 2084 | if vndkdep.isVndkExt() { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2085 | actx.AddVariationDependencies([]blueprint.Variation{ |
Colin Cross | 7228ecd | 2019-11-18 16:00:16 -0800 | [diff] [blame] | 2086 | c.ImageVariation(), |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 2087 | {Mutator: "link", Variation: "shared"}, |
| 2088 | }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName()) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2089 | } |
| 2090 | } |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 2091 | } |
Colin Cross | 21b9a24 | 2015-03-24 14:15:58 -0700 | [diff] [blame] | 2092 | |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 2093 | func BeginMutator(ctx android.BottomUpMutatorContext) { |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 2094 | if c, ok := ctx.Module().(*Module); ok && c.Enabled() { |
| 2095 | c.beginMutator(ctx) |
| 2096 | } |
| 2097 | } |
| 2098 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2099 | // Whether a module can link to another module, taking into |
| 2100 | // account NDK linking. |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2101 | func checkLinkType(ctx android.ModuleContext, from LinkableInterface, to LinkableInterface, |
| 2102 | tag blueprint.DependencyTag) { |
| 2103 | |
| 2104 | switch t := tag.(type) { |
| 2105 | case dependencyTag: |
| 2106 | if t != vndkExtDepTag { |
| 2107 | return |
| 2108 | } |
| 2109 | case libraryDependencyTag: |
| 2110 | default: |
| 2111 | return |
| 2112 | } |
| 2113 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2114 | if from.Module().Target().Os != android.Android { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2115 | // Host code is not restricted |
| 2116 | return |
| 2117 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2118 | |
| 2119 | // VNDK is cc.Module supported only for now. |
| 2120 | if ccFrom, ok := from.(*Module); ok && from.UseVndk() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2121 | // Though vendor code is limited by the vendor mutator, |
| 2122 | // each vendor-available module needs to check |
| 2123 | // link-type for VNDK. |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2124 | if ccTo, ok := to.(*Module); ok { |
| 2125 | if ccFrom.vndkdep != nil { |
| 2126 | ccFrom.vndkdep.vndkCheckLinkType(ctx, ccTo, tag) |
| 2127 | } |
| 2128 | } else { |
| 2129 | ctx.ModuleErrorf("Attempting to link VNDK cc.Module with unsupported module type") |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2130 | } |
| 2131 | return |
| 2132 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2133 | if from.SdkVersion() == "" { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2134 | // Platform code can link to anything |
| 2135 | return |
| 2136 | } |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 2137 | if from.InRamdisk() { |
| 2138 | // Ramdisk code is not NDK |
| 2139 | return |
| 2140 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2141 | if from.InRecovery() { |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2142 | // Recovery code is not NDK |
| 2143 | return |
| 2144 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2145 | if to.ToolchainLibrary() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2146 | // These are always allowed |
| 2147 | return |
| 2148 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2149 | if to.NdkPrebuiltStl() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2150 | // These are allowed, but they don't set sdk_version |
| 2151 | return |
| 2152 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2153 | if to.StubDecorator() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2154 | // These aren't real libraries, but are the stub shared libraries that are included in |
| 2155 | // the NDK. |
| 2156 | return |
| 2157 | } |
Logan Chien | 834b9a6 | 2019-01-14 15:39:03 +0800 | [diff] [blame] | 2158 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2159 | if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Module().Name() == "libc++" { |
Logan Chien | 834b9a6 | 2019-01-14 15:39:03 +0800 | [diff] [blame] | 2160 | // Bug: http://b/121358700 - Allow libclang_rt.* shared libraries (with sdk_version) |
| 2161 | // to link to libc++ (non-NDK and without sdk_version). |
| 2162 | return |
| 2163 | } |
| 2164 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2165 | if to.SdkVersion() == "" { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2166 | // NDK code linking to platform code is never okay. |
| 2167 | ctx.ModuleErrorf("depends on non-NDK-built library %q", |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2168 | ctx.OtherModuleName(to.Module())) |
Dan Willemsen | 155d17c | 2019-02-06 18:30:02 -0800 | [diff] [blame] | 2169 | return |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2170 | } |
| 2171 | |
| 2172 | // At this point we know we have two NDK libraries, but we need to |
| 2173 | // check that we're not linking against anything built against a higher |
| 2174 | // API level, as it is only valid to link against older or equivalent |
| 2175 | // APIs. |
| 2176 | |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2177 | // Current can link against anything. |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2178 | if from.SdkVersion() != "current" { |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2179 | // Otherwise we need to check. |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2180 | if to.SdkVersion() == "current" { |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2181 | // Current can't be linked against by anything else. |
| 2182 | ctx.ModuleErrorf("links %q built against newer API version %q", |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2183 | ctx.OtherModuleName(to.Module()), "current") |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2184 | } else { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2185 | fromApi, err := strconv.Atoi(from.SdkVersion()) |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2186 | if err != nil { |
| 2187 | ctx.PropertyErrorf("sdk_version", |
Inseob Kim | 34b2283 | 2018-04-11 10:13:16 +0900 | [diff] [blame] | 2188 | "Invalid sdk_version value (must be int or current): %q", |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2189 | from.SdkVersion()) |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2190 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2191 | toApi, err := strconv.Atoi(to.SdkVersion()) |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2192 | if err != nil { |
| 2193 | ctx.PropertyErrorf("sdk_version", |
Inseob Kim | 34b2283 | 2018-04-11 10:13:16 +0900 | [diff] [blame] | 2194 | "Invalid sdk_version value (must be int or current): %q", |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2195 | to.SdkVersion()) |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2196 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2197 | |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2198 | if toApi > fromApi { |
| 2199 | ctx.ModuleErrorf("links %q built against newer API version %q", |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2200 | ctx.OtherModuleName(to.Module()), to.SdkVersion()) |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 2201 | } |
| 2202 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2203 | } |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 2204 | |
| 2205 | // Also check that the two STL choices are compatible. |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2206 | fromStl := from.SelectedStl() |
| 2207 | toStl := to.SelectedStl() |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 2208 | if fromStl == "" || toStl == "" { |
| 2209 | // Libraries that don't use the STL are unrestricted. |
Inseob Kim | da2171a | 2018-04-11 15:41:38 +0900 | [diff] [blame] | 2210 | } else if fromStl == "ndk_system" || toStl == "ndk_system" { |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 2211 | // We can be permissive with the system "STL" since it is only the C++ |
| 2212 | // ABI layer, but in the future we should make sure that everyone is |
| 2213 | // using either libc++ or nothing. |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2214 | } else if getNdkStlFamily(from) != getNdkStlFamily(to) { |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 2215 | ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q", |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2216 | from.SelectedStl(), ctx.OtherModuleName(to.Module()), |
| 2217 | to.SelectedStl()) |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 2218 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2219 | } |
| 2220 | |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 2221 | // Tests whether the dependent library is okay to be double loaded inside a single process. |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2222 | // If a library has a vendor variant and is a (transitive) dependency of an LLNDK library, |
| 2223 | // it is subject to be double loaded. Such lib should be explicitly marked as double_loadable: true |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 2224 | // or as vndk-sp (vndk: { enabled: true, support_system_process: true}). |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2225 | func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { |
| 2226 | check := func(child, parent android.Module) bool { |
| 2227 | to, ok := child.(*Module) |
| 2228 | if !ok { |
| 2229 | // follow thru cc.Defaults, etc. |
| 2230 | return true |
| 2231 | } |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 2232 | |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2233 | if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() { |
| 2234 | return false |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 2235 | } |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2236 | |
| 2237 | // if target lib has no vendor variant, keep checking dependency graph |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2238 | if !to.HasVendorVariant() { |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2239 | return true |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 2240 | } |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2241 | |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 2242 | if to.isVndkSp() || to.isLlndk(ctx.Config()) || Bool(to.VendorProperties.Double_loadable) { |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2243 | return false |
| 2244 | } |
| 2245 | |
| 2246 | var stringPath []string |
| 2247 | for _, m := range ctx.GetWalkPath() { |
| 2248 | stringPath = append(stringPath, m.Name()) |
| 2249 | } |
| 2250 | ctx.ModuleErrorf("links a library %q which is not LL-NDK, "+ |
| 2251 | "VNDK-SP, or explicitly marked as 'double_loadable:true'. "+ |
| 2252 | "(dependency: %s)", ctx.OtherModuleName(to), strings.Join(stringPath, " -> ")) |
| 2253 | return false |
| 2254 | } |
| 2255 | if module, ok := ctx.Module().(*Module); ok { |
| 2256 | if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() { |
Jooyung Han | 0302a84 | 2019-10-30 18:43:49 +0900 | [diff] [blame] | 2257 | if module.isLlndk(ctx.Config()) || Bool(module.VendorProperties.Double_loadable) { |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 2258 | ctx.WalkDeps(check) |
| 2259 | } |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 2260 | } |
| 2261 | } |
| 2262 | } |
| 2263 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2264 | // Convert dependencies to paths. Returns a PathDeps containing paths |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 2265 | func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2266 | var depPaths PathDeps |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2267 | |
Ivan Lozano | 183a321 | 2019-10-18 14:18:45 -0700 | [diff] [blame] | 2268 | directStaticDeps := []LinkableInterface{} |
| 2269 | directSharedDeps := []LinkableInterface{} |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 2270 | |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2271 | reexportExporter := func(exporter exportedFlagsProducer) { |
| 2272 | depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.exportedDirs()...) |
| 2273 | depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.exportedSystemDirs()...) |
| 2274 | depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.exportedFlags()...) |
| 2275 | depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.exportedDeps()...) |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 2276 | depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, exporter.exportedGeneratedHeaders()...) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2277 | } |
| 2278 | |
Jooyung Han | de34d23 | 2020-07-23 13:04:15 +0900 | [diff] [blame] | 2279 | // For the dependency from platform to apex, use the latest stubs |
| 2280 | c.apexSdkVersion = android.FutureApiLevel |
| 2281 | if !c.IsForPlatform() { |
| 2282 | c.apexSdkVersion = c.ApexProperties.Info.MinSdkVersion |
| 2283 | } |
| 2284 | |
| 2285 | if android.InList("hwaddress", ctx.Config().SanitizeDevice()) { |
| 2286 | // In hwasan build, we override apexSdkVersion to the FutureApiLevel(10000) |
| 2287 | // so that even Q(29/Android10) apexes could use the dynamic unwinder by linking the newer stubs(e.g libc(R+)). |
| 2288 | // (b/144430859) |
| 2289 | c.apexSdkVersion = android.FutureApiLevel |
| 2290 | } |
| 2291 | |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 2292 | ctx.VisitDirectDeps(func(dep android.Module) { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2293 | depName := ctx.OtherModuleName(dep) |
| 2294 | depTag := ctx.OtherModuleDependencyTag(dep) |
Dan Albert | 9e10cd4 | 2016-08-03 14:12:14 -0700 | [diff] [blame] | 2295 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2296 | ccDep, ok := dep.(LinkableInterface) |
| 2297 | if !ok { |
| 2298 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2299 | // handling for a few module types that aren't cc Module but that are also supported |
| 2300 | switch depTag { |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 2301 | case genSourceDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2302 | if genRule, ok := dep.(genrule.SourceFileGenerator); ok { |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 2303 | depPaths.GeneratedSources = append(depPaths.GeneratedSources, |
| 2304 | genRule.GeneratedSourceFiles()...) |
| 2305 | } else { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2306 | ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName) |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 2307 | } |
Colin Cross | e90bfd1 | 2017-04-26 16:59:26 -0700 | [diff] [blame] | 2308 | // Support exported headers from a generated_sources dependency |
| 2309 | fallthrough |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 2310 | case genHeaderDepTag, genHeaderExportDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2311 | if genRule, ok := dep.(genrule.SourceFileGenerator); ok { |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 2312 | depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, |
Dan Willemsen | 9da9d49 | 2018-02-21 18:28:18 -0800 | [diff] [blame] | 2313 | genRule.GeneratedDeps()...) |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 2314 | dirs := genRule.GeneratedHeaderDirs() |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2315 | depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2316 | if depTag == genHeaderExportDepTag { |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2317 | depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...) |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 2318 | depPaths.ReexportedGeneratedHeaders = append(depPaths.ReexportedGeneratedHeaders, |
| 2319 | genRule.GeneratedSourceFiles()...) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2320 | depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...) |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 2321 | // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 2322 | c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs.Strings()...) |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 2323 | |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 2324 | } |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 2325 | } else { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2326 | ctx.ModuleErrorf("module %q is not a genrule", depName) |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 2327 | } |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 2328 | case linkerFlagsDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2329 | if genRule, ok := dep.(genrule.SourceFileGenerator); ok { |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 2330 | files := genRule.GeneratedSourceFiles() |
| 2331 | if len(files) == 1 { |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 2332 | depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0]) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 2333 | } else if len(files) > 1 { |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 2334 | ctx.ModuleErrorf("module %q can only generate a single file if used for a linker flag file", depName) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 2335 | } |
| 2336 | } else { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2337 | ctx.ModuleErrorf("module %q is not a genrule", depName) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 2338 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2339 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2340 | return |
| 2341 | } |
| 2342 | |
Colin Cross | fe17f6f | 2019-03-28 19:30:56 -0700 | [diff] [blame] | 2343 | if depTag == android.ProtoPluginDepTag { |
| 2344 | return |
| 2345 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 2346 | if depTag == llndkImplDep { |
| 2347 | return |
| 2348 | } |
Colin Cross | fe17f6f | 2019-03-28 19:30:56 -0700 | [diff] [blame] | 2349 | |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 2350 | if dep.Target().Os != ctx.Os() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2351 | ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName) |
| 2352 | return |
| 2353 | } |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 2354 | if dep.Target().Arch.ArchType != ctx.Arch().ArchType { |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 2355 | ctx.ModuleErrorf("Arch mismatch between %q(%v) and %q(%v)", |
| 2356 | ctx.ModuleName(), ctx.Arch().ArchType, depName, dep.Target().Arch.ArchType) |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 2357 | return |
| 2358 | } |
| 2359 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 2360 | // re-exporting flags |
| 2361 | if depTag == reuseObjTag { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2362 | // reusing objects only make sense for cc.Modules. |
| 2363 | if ccReuseDep, ok := ccDep.(*Module); ok && ccDep.CcLibraryInterface() { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 2364 | c.staticVariant = ccDep |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2365 | objs, exporter := ccReuseDep.compiler.(libraryInterface).reuseObjs() |
Colin Cross | 10d2231 | 2017-05-03 11:01:58 -0700 | [diff] [blame] | 2366 | depPaths.Objs = depPaths.Objs.Append(objs) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2367 | reexportExporter(exporter) |
Colin Cross | bba9904 | 2016-11-23 15:45:05 -0800 | [diff] [blame] | 2368 | return |
| 2369 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2370 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2371 | |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 2372 | if depTag == staticVariantTag { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2373 | // staticVariants are a cc.Module specific concept. |
| 2374 | if _, ok := ccDep.(*Module); ok && ccDep.CcLibraryInterface() { |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 2375 | c.staticVariant = ccDep |
| 2376 | return |
| 2377 | } |
| 2378 | } |
| 2379 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2380 | checkLinkType(ctx, c, ccDep, depTag) |
| 2381 | |
| 2382 | linkFile := ccDep.OutputFile() |
| 2383 | |
| 2384 | if libDepTag, ok := depTag.(libraryDependencyTag); ok { |
| 2385 | // Only use static unwinder for legacy (min_sdk_version = 29) apexes (b/144430859) |
| 2386 | if libDepTag.staticUnwinder && c.apexSdkVersion > android.SdkVersion_Android10 { |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 2387 | return |
| 2388 | } |
Peter Collingbourne | dc4f986 | 2020-02-12 17:13:25 -0800 | [diff] [blame] | 2389 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2390 | if ccDep.CcLibrary() && !libDepTag.static() { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2391 | depIsStubs := ccDep.BuildStubs() |
Jooyung Han | 624d35c | 2020-04-10 12:57:24 +0900 | [diff] [blame] | 2392 | depHasStubs := VersionVariantAvailable(c) && ccDep.HasStubsVariants() |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 2393 | depInSameApex := android.DirectlyInApex(c.ApexName(), depName) |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 2394 | depInPlatform := !android.DirectlyInAnyApex(ctx, depName) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2395 | |
| 2396 | var useThisDep bool |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2397 | if depIsStubs && libDepTag.explicitlyVersioned { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2398 | // Always respect dependency to the versioned stubs (i.e. libX#10) |
| 2399 | useThisDep = true |
| 2400 | } else if !depHasStubs { |
| 2401 | // Use non-stub variant if that is the only choice |
| 2402 | // (i.e. depending on a lib without stubs.version property) |
| 2403 | useThisDep = true |
| 2404 | } else if c.IsForPlatform() { |
| 2405 | // If not building for APEX, use stubs only when it is from |
| 2406 | // an APEX (and not from platform) |
| 2407 | useThisDep = (depInPlatform != depIsStubs) |
Jooyung Han | 624d35c | 2020-04-10 12:57:24 +0900 | [diff] [blame] | 2408 | if c.bootstrap() { |
| 2409 | // However, for host, ramdisk, recovery or bootstrap modules, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2410 | // always link to non-stub variant |
| 2411 | useThisDep = !depIsStubs |
| 2412 | } |
Jiyong Park | 62304bb | 2020-04-13 16:19:48 +0900 | [diff] [blame] | 2413 | for _, testFor := range c.TestFor() { |
| 2414 | // Another exception: if this module is bundled with an APEX, then |
| 2415 | // it is linked with the non-stub variant of a module in the APEX |
| 2416 | // as if this is part of the APEX. |
| 2417 | if android.DirectlyInApex(testFor, depName) { |
| 2418 | useThisDep = !depIsStubs |
| 2419 | break |
| 2420 | } |
| 2421 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2422 | } else { |
| 2423 | // If building for APEX, use stubs only when it is not from |
| 2424 | // the same APEX |
| 2425 | useThisDep = (depInSameApex != depIsStubs) |
| 2426 | } |
| 2427 | |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 2428 | // when to use (unspecified) stubs, check min_sdk_version and choose the right one |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2429 | if useThisDep && depIsStubs && !libDepTag.explicitlyVersioned { |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 2430 | versionToUse, err := c.ChooseSdkVersion(ccDep.StubsVersions(), c.apexSdkVersion) |
Jooyung Han | 03b5185 | 2020-02-26 22:45:42 +0900 | [diff] [blame] | 2431 | if err != nil { |
| 2432 | ctx.OtherModuleErrorf(dep, err.Error()) |
| 2433 | return |
| 2434 | } |
| 2435 | if versionToUse != ccDep.StubsVersion() { |
| 2436 | useThisDep = false |
| 2437 | } |
| 2438 | } |
| 2439 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2440 | if !useThisDep { |
| 2441 | return // stop processing this dep |
| 2442 | } |
| 2443 | } |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 2444 | if c.UseVndk() { |
| 2445 | if m, ok := ccDep.(*Module); ok && m.IsStubs() { // LLNDK |
| 2446 | // by default, use current version of LLNDK |
| 2447 | versionToUse := "" |
| 2448 | versions := stubsVersionsFor(ctx.Config())[depName] |
| 2449 | if c.ApexName() != "" && len(versions) > 0 { |
| 2450 | // if this is for use_vendor apex && dep has stubsVersions |
| 2451 | // apply the same rule of apex sdk enforcement to choose right version |
| 2452 | var err error |
Jooyung Han | 7556839 | 2020-03-20 04:29:24 +0900 | [diff] [blame] | 2453 | versionToUse, err = c.ChooseSdkVersion(versions, c.apexSdkVersion) |
Jooyung Han | 61b66e9 | 2020-03-21 14:21:46 +0000 | [diff] [blame] | 2454 | if err != nil { |
| 2455 | ctx.OtherModuleErrorf(dep, err.Error()) |
| 2456 | return |
| 2457 | } |
| 2458 | } |
| 2459 | if versionToUse != ccDep.StubsVersion() { |
| 2460 | return |
| 2461 | } |
| 2462 | } |
| 2463 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 2464 | |
Ivan Lozano | e0833b1 | 2019-11-06 19:15:49 -0800 | [diff] [blame] | 2465 | depPaths.IncludeDirs = append(depPaths.IncludeDirs, ccDep.IncludeDirs()...) |
| 2466 | |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2467 | // Exporting flags only makes sense for cc.Modules |
| 2468 | if _, ok := ccDep.(*Module); ok { |
| 2469 | if i, ok := ccDep.(*Module).linker.(exportedFlagsProducer); ok { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2470 | depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...) |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 2471 | depPaths.GeneratedDeps = append(depPaths.GeneratedDeps, i.exportedDeps()...) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2472 | depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 2473 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2474 | if libDepTag.reexportFlags { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2475 | reexportExporter(i) |
| 2476 | // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. |
| 2477 | // Re-exported shared library headers must be included as well since they can help us with type information |
| 2478 | // about template instantiations (instantiated from their headers). |
| 2479 | // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version |
| 2480 | // scripts. |
| 2481 | c.sabi.Properties.ReexportedIncludes = append( |
| 2482 | c.sabi.Properties.ReexportedIncludes, i.exportedDirs().Strings()...) |
| 2483 | } |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 2484 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2485 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2486 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2487 | var ptr *android.Paths |
| 2488 | var depPtr *android.Paths |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2489 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2490 | depFile := android.OptionalPath{} |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 2491 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2492 | switch { |
| 2493 | case libDepTag.header(): |
| 2494 | // nothing |
| 2495 | case libDepTag.shared(): |
| 2496 | ptr = &depPaths.SharedLibs |
| 2497 | switch libDepTag.Order { |
| 2498 | case earlyLibraryDependency: |
| 2499 | ptr = &depPaths.EarlySharedLibs |
| 2500 | depPtr = &depPaths.EarlySharedLibsDeps |
| 2501 | case normalLibraryDependency: |
| 2502 | ptr = &depPaths.SharedLibs |
| 2503 | depPtr = &depPaths.SharedLibsDeps |
| 2504 | directSharedDeps = append(directSharedDeps, ccDep) |
| 2505 | case lateLibraryDependency: |
| 2506 | ptr = &depPaths.LateSharedLibs |
| 2507 | depPtr = &depPaths.LateSharedLibsDeps |
| 2508 | default: |
| 2509 | panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order)) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 2510 | } |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2511 | depFile = ccDep.Toc() |
| 2512 | case libDepTag.static(): |
| 2513 | if libDepTag.wholeStatic { |
| 2514 | ptr = &depPaths.WholeStaticLibs |
| 2515 | if !ccDep.CcLibraryInterface() || !ccDep.Static() { |
| 2516 | ctx.ModuleErrorf("module %q not a static library", depName) |
| 2517 | return |
Inseob Kim | 752edec | 2020-03-14 01:30:34 +0900 | [diff] [blame] | 2518 | } |
| 2519 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2520 | // Because the static library objects are included, this only makes sense |
| 2521 | // in the context of proper cc.Modules. |
| 2522 | if ccWholeStaticLib, ok := ccDep.(*Module); ok { |
| 2523 | staticLib := ccWholeStaticLib.linker.(libraryInterface) |
| 2524 | if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil { |
| 2525 | postfix := " (required by " + ctx.OtherModuleName(dep) + ")" |
| 2526 | for i := range missingDeps { |
| 2527 | missingDeps[i] += postfix |
| 2528 | } |
| 2529 | ctx.AddMissingDependencies(missingDeps) |
| 2530 | } |
| 2531 | if _, ok := ccWholeStaticLib.linker.(prebuiltLinkerInterface); ok { |
| 2532 | depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts, linkFile.Path()) |
| 2533 | } else { |
| 2534 | depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs()) |
| 2535 | } |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 2536 | } else { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2537 | ctx.ModuleErrorf( |
| 2538 | "non-cc.Modules cannot be included as whole static libraries.", depName) |
| 2539 | return |
| 2540 | } |
| 2541 | |
| 2542 | } else { |
| 2543 | switch libDepTag.Order { |
| 2544 | case earlyLibraryDependency: |
| 2545 | panic(fmt.Errorf("early static libs not suppported")) |
| 2546 | case normalLibraryDependency: |
| 2547 | // static dependencies will be handled separately so they can be ordered |
| 2548 | // using transitive dependencies. |
| 2549 | ptr = nil |
| 2550 | directStaticDeps = append(directStaticDeps, ccDep) |
| 2551 | case lateLibraryDependency: |
| 2552 | ptr = &depPaths.LateStaticLibs |
| 2553 | default: |
| 2554 | panic(fmt.Errorf("unexpected library dependency order %d", libDepTag.Order)) |
Inseob Kim | eec88e1 | 2020-01-22 11:11:29 +0900 | [diff] [blame] | 2555 | } |
| 2556 | } |
| 2557 | } |
| 2558 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2559 | if libDepTag.static() && !libDepTag.wholeStatic { |
| 2560 | if !ccDep.CcLibraryInterface() || !ccDep.Static() { |
| 2561 | ctx.ModuleErrorf("module %q not a static library", depName) |
| 2562 | return |
| 2563 | } |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 2564 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2565 | // When combining coverage files for shared libraries and executables, coverage files |
| 2566 | // in static libraries act as if they were whole static libraries. The same goes for |
| 2567 | // source based Abi dump files. |
| 2568 | if c, ok := ccDep.(*Module); ok { |
| 2569 | staticLib := c.linker.(libraryInterface) |
| 2570 | depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, |
| 2571 | staticLib.objs().coverageFiles...) |
| 2572 | depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles, |
| 2573 | staticLib.objs().sAbiDumpFiles...) |
| 2574 | } else if c, ok := ccDep.(LinkableInterface); ok { |
| 2575 | // Handle non-CC modules here |
| 2576 | depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, |
| 2577 | c.CoverageFiles()...) |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 2578 | } |
| 2579 | } |
| 2580 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2581 | if ptr != nil { |
| 2582 | if !linkFile.Valid() { |
| 2583 | if !ctx.Config().AllowMissingDependencies() { |
| 2584 | ctx.ModuleErrorf("module %q missing output file", depName) |
| 2585 | } else { |
| 2586 | ctx.AddMissingDependencies([]string{depName}) |
| 2587 | } |
| 2588 | return |
| 2589 | } |
| 2590 | *ptr = append(*ptr, linkFile.Path()) |
| 2591 | } |
| 2592 | |
| 2593 | if depPtr != nil { |
| 2594 | dep := depFile |
| 2595 | if !dep.Valid() { |
| 2596 | dep = linkFile |
| 2597 | } |
| 2598 | *depPtr = append(*depPtr, dep.Path()) |
| 2599 | } |
| 2600 | |
| 2601 | makeLibName := c.makeLibName(ctx, ccDep, depName) + libDepTag.makeSuffix |
| 2602 | switch { |
| 2603 | case libDepTag.header(): |
| 2604 | // TODO(ccross): The reexportFlags check is there to maintain previous |
| 2605 | // behavior when adding libraryDependencyTag and should be removed. |
| 2606 | if !libDepTag.reexportFlags { |
| 2607 | c.Properties.AndroidMkHeaderLibs = append( |
| 2608 | c.Properties.AndroidMkHeaderLibs, makeLibName) |
| 2609 | } |
| 2610 | case libDepTag.shared(): |
| 2611 | if ccDep.CcLibrary() { |
| 2612 | if ccDep.BuildStubs() && android.InAnyApex(depName) { |
| 2613 | // Add the dependency to the APEX(es) providing the library so that |
| 2614 | // m <module> can trigger building the APEXes as well. |
| 2615 | for _, an := range android.GetApexesForModule(depName) { |
| 2616 | c.Properties.ApexesProvidingSharedLibs = append( |
| 2617 | c.Properties.ApexesProvidingSharedLibs, an) |
| 2618 | } |
| 2619 | } |
| 2620 | } |
| 2621 | |
| 2622 | // Note: the order of libs in this list is not important because |
| 2623 | // they merely serve as Make dependencies and do not affect this lib itself. |
| 2624 | // TODO(ccross): The reexportFlags, order and ndk checks are there to |
| 2625 | // maintain previous behavior when adding libraryDependencyTag and |
| 2626 | // should be removed. |
| 2627 | if !c.static() || libDepTag.reexportFlags || libDepTag.Order == lateLibraryDependency || libDepTag.ndk { |
| 2628 | c.Properties.AndroidMkSharedLibs = append( |
| 2629 | c.Properties.AndroidMkSharedLibs, makeLibName) |
| 2630 | } |
| 2631 | // Record baseLibName for snapshots. |
| 2632 | c.Properties.SnapshotSharedLibs = append(c.Properties.SnapshotSharedLibs, baseLibName(depName)) |
| 2633 | case libDepTag.static(): |
| 2634 | if libDepTag.wholeStatic { |
| 2635 | c.Properties.AndroidMkWholeStaticLibs = append( |
| 2636 | c.Properties.AndroidMkWholeStaticLibs, makeLibName) |
| 2637 | } else { |
| 2638 | c.Properties.AndroidMkStaticLibs = append( |
| 2639 | c.Properties.AndroidMkStaticLibs, makeLibName) |
| 2640 | } |
| 2641 | } |
| 2642 | } else { |
| 2643 | switch depTag { |
| 2644 | case runtimeDepTag: |
| 2645 | c.Properties.AndroidMkRuntimeLibs = append( |
| 2646 | c.Properties.AndroidMkRuntimeLibs, c.makeLibName(ctx, ccDep, depName)+libDepTag.makeSuffix) |
| 2647 | // Record baseLibName for snapshots. |
| 2648 | c.Properties.SnapshotRuntimeLibs = append(c.Properties.SnapshotRuntimeLibs, baseLibName(depName)) |
| 2649 | case objDepTag: |
| 2650 | depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path()) |
| 2651 | case CrtBeginDepTag: |
| 2652 | depPaths.CrtBegin = linkFile |
| 2653 | case CrtEndDepTag: |
| 2654 | depPaths.CrtEnd = linkFile |
| 2655 | case dynamicLinkerDepTag: |
| 2656 | depPaths.DynamicLinker = linkFile |
| 2657 | } |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 2658 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2659 | }) |
| 2660 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 2661 | // use the ordered dependencies as this module's dependencies |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 2662 | depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 2663 | |
Colin Cross | dd84e05 | 2017-05-17 13:44:16 -0700 | [diff] [blame] | 2664 | // Dedup exported flags from dependencies |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 2665 | depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags) |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 2666 | depPaths.IncludeDirs = android.FirstUniquePaths(depPaths.IncludeDirs) |
| 2667 | depPaths.SystemIncludeDirs = android.FirstUniquePaths(depPaths.SystemIncludeDirs) |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 2668 | depPaths.GeneratedDeps = android.FirstUniquePaths(depPaths.GeneratedDeps) |
Jiyong Park | 7495504 | 2019-10-22 20:19:51 +0900 | [diff] [blame] | 2669 | depPaths.ReexportedDirs = android.FirstUniquePaths(depPaths.ReexportedDirs) |
| 2670 | depPaths.ReexportedSystemDirs = android.FirstUniquePaths(depPaths.ReexportedSystemDirs) |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 2671 | depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2672 | depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps) |
Inseob Kim | d110f87 | 2019-12-06 13:15:38 +0900 | [diff] [blame] | 2673 | depPaths.ReexportedGeneratedHeaders = android.FirstUniquePaths(depPaths.ReexportedGeneratedHeaders) |
Dan Willemsen | fe92c96 | 2017-08-29 12:28:37 -0700 | [diff] [blame] | 2674 | |
| 2675 | if c.sabi != nil { |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 2676 | c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes) |
Dan Willemsen | fe92c96 | 2017-08-29 12:28:37 -0700 | [diff] [blame] | 2677 | } |
Colin Cross | dd84e05 | 2017-05-17 13:44:16 -0700 | [diff] [blame] | 2678 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2679 | return depPaths |
| 2680 | } |
| 2681 | |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2682 | // baseLibName trims known prefixes and suffixes |
| 2683 | func baseLibName(depName string) string { |
| 2684 | libName := strings.TrimSuffix(depName, llndkLibrarySuffix) |
| 2685 | libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix) |
| 2686 | libName = strings.TrimPrefix(libName, "prebuilt_") |
| 2687 | return libName |
| 2688 | } |
| 2689 | |
| 2690 | func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface, depName string) string { |
| 2691 | vendorSuffixModules := vendorSuffixModules(ctx.Config()) |
| 2692 | vendorPublicLibraries := vendorPublicLibraries(ctx.Config()) |
| 2693 | |
| 2694 | libName := baseLibName(depName) |
| 2695 | isLLndk := isLlndkLibrary(libName, ctx.Config()) |
| 2696 | isVendorPublicLib := inList(libName, *vendorPublicLibraries) |
| 2697 | bothVendorAndCoreVariantsExist := ccDep.HasVendorVariant() || isLLndk |
| 2698 | |
| 2699 | if c, ok := ccDep.(*Module); ok { |
| 2700 | // Use base module name for snapshots when exporting to Makefile. |
| 2701 | if c.isSnapshotPrebuilt() { |
| 2702 | baseName := c.BaseModuleName() |
| 2703 | |
| 2704 | if c.IsVndk() { |
| 2705 | return baseName + ".vendor" |
| 2706 | } |
| 2707 | |
| 2708 | if vendorSuffixModules[baseName] { |
| 2709 | return baseName + ".vendor" |
| 2710 | } else { |
| 2711 | return baseName |
| 2712 | } |
| 2713 | } |
| 2714 | } |
| 2715 | |
| 2716 | if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.IsVndk() && !ccDep.MustUseVendorVariant() && !c.InRamdisk() && !c.InRecovery() { |
| 2717 | // The vendor module is a no-vendor-variant VNDK library. Depend on the |
| 2718 | // core module instead. |
| 2719 | return libName |
| 2720 | } else if c.UseVndk() && bothVendorAndCoreVariantsExist { |
| 2721 | // The vendor module in Make will have been renamed to not conflict with the core |
| 2722 | // module, so update the dependency name here accordingly. |
| 2723 | return libName + c.getNameSuffixWithVndkVersion(ctx) |
| 2724 | } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib { |
| 2725 | return libName + vendorPublicLibrarySuffix |
| 2726 | } else if ccDep.InRamdisk() && !ccDep.OnlyInRamdisk() { |
| 2727 | return libName + ramdiskSuffix |
| 2728 | } else if ccDep.InRecovery() && !ccDep.OnlyInRecovery() { |
| 2729 | return libName + recoverySuffix |
| 2730 | } else if ccDep.Module().Target().NativeBridge == android.NativeBridgeEnabled { |
| 2731 | return libName + nativeBridgeSuffix |
| 2732 | } else { |
| 2733 | return libName |
| 2734 | } |
| 2735 | } |
| 2736 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2737 | func (c *Module) InstallInData() bool { |
| 2738 | if c.installer == nil { |
| 2739 | return false |
| 2740 | } |
Vishwath Mohan | 1dd8839 | 2017-03-29 22:00:18 -0700 | [diff] [blame] | 2741 | return c.installer.inData() |
| 2742 | } |
| 2743 | |
| 2744 | func (c *Module) InstallInSanitizerDir() bool { |
| 2745 | if c.installer == nil { |
| 2746 | return false |
| 2747 | } |
| 2748 | if c.sanitize != nil && c.sanitize.inSanitizerDir() { |
Colin Cross | 9461040 | 2016-08-29 13:41:32 -0700 | [diff] [blame] | 2749 | return true |
| 2750 | } |
Vishwath Mohan | 1dd8839 | 2017-03-29 22:00:18 -0700 | [diff] [blame] | 2751 | return c.installer.inSanitizerDir() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2752 | } |
| 2753 | |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 2754 | func (c *Module) InstallInRamdisk() bool { |
| 2755 | return c.InRamdisk() |
| 2756 | } |
| 2757 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2758 | func (c *Module) InstallInRecovery() bool { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2759 | return c.InRecovery() |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2760 | } |
| 2761 | |
Martin Stjernholm | 9e9bb7f | 2020-08-06 22:34:42 +0100 | [diff] [blame] | 2762 | func (c *Module) MakeUninstallable() { |
Martin Stjernholm | bf37d16 | 2020-03-31 16:05:34 +0100 | [diff] [blame] | 2763 | if c.installer == nil { |
Martin Stjernholm | 9e9bb7f | 2020-08-06 22:34:42 +0100 | [diff] [blame] | 2764 | c.ModuleBase.MakeUninstallable() |
Martin Stjernholm | bf37d16 | 2020-03-31 16:05:34 +0100 | [diff] [blame] | 2765 | return |
| 2766 | } |
Martin Stjernholm | 9e9bb7f | 2020-08-06 22:34:42 +0100 | [diff] [blame] | 2767 | c.installer.makeUninstallable(c) |
Martin Stjernholm | bf37d16 | 2020-03-31 16:05:34 +0100 | [diff] [blame] | 2768 | } |
| 2769 | |
Dan Willemsen | 4aa75ca | 2016-09-28 16:18:03 -0700 | [diff] [blame] | 2770 | func (c *Module) HostToolPath() android.OptionalPath { |
| 2771 | if c.installer == nil { |
| 2772 | return android.OptionalPath{} |
| 2773 | } |
| 2774 | return c.installer.hostToolPath() |
| 2775 | } |
| 2776 | |
Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 2777 | func (c *Module) IntermPathForModuleOut() android.OptionalPath { |
| 2778 | return c.outputFile |
| 2779 | } |
| 2780 | |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 2781 | func (c *Module) OutputFiles(tag string) (android.Paths, error) { |
| 2782 | switch tag { |
| 2783 | case "": |
| 2784 | if c.outputFile.Valid() { |
| 2785 | return android.Paths{c.outputFile.Path()}, nil |
| 2786 | } |
| 2787 | return android.Paths{}, nil |
| 2788 | default: |
| 2789 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2790 | } |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2791 | } |
| 2792 | |
Vishwath Mohan | b743e9c | 2017-11-01 09:20:21 +0000 | [diff] [blame] | 2793 | func (c *Module) static() bool { |
| 2794 | if static, ok := c.linker.(interface { |
| 2795 | static() bool |
| 2796 | }); ok { |
| 2797 | return static.static() |
| 2798 | } |
| 2799 | return false |
| 2800 | } |
| 2801 | |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 2802 | func (c *Module) staticBinary() bool { |
| 2803 | if static, ok := c.linker.(interface { |
| 2804 | staticBinary() bool |
| 2805 | }); ok { |
| 2806 | return static.staticBinary() |
| 2807 | } |
| 2808 | return false |
| 2809 | } |
| 2810 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 2811 | func (c *Module) header() bool { |
| 2812 | if h, ok := c.linker.(interface { |
| 2813 | header() bool |
| 2814 | }); ok { |
| 2815 | return h.header() |
| 2816 | } |
| 2817 | return false |
| 2818 | } |
| 2819 | |
Inseob Kim | 7f283f4 | 2020-06-01 21:53:49 +0900 | [diff] [blame] | 2820 | func (c *Module) binary() bool { |
| 2821 | if b, ok := c.linker.(interface { |
| 2822 | binary() bool |
| 2823 | }); ok { |
| 2824 | return b.binary() |
| 2825 | } |
| 2826 | return false |
| 2827 | } |
| 2828 | |
Inseob Kim | 1042d29 | 2020-06-01 23:23:05 +0900 | [diff] [blame] | 2829 | func (c *Module) object() bool { |
| 2830 | if o, ok := c.linker.(interface { |
| 2831 | object() bool |
| 2832 | }); ok { |
| 2833 | return o.object() |
| 2834 | } |
| 2835 | return false |
| 2836 | } |
| 2837 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2838 | func (c *Module) getMakeLinkType(actx android.ModuleContext) string { |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2839 | if c.UseVndk() { |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2840 | if lib, ok := c.linker.(*llndkStubDecorator); ok { |
| 2841 | if Bool(lib.Properties.Vendor_available) { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2842 | return "native:vndk" |
| 2843 | } |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2844 | return "native:vndk_private" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2845 | } |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2846 | if c.IsVndk() && !c.isVndkExt() { |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2847 | if Bool(c.VendorProperties.Vendor_available) { |
| 2848 | return "native:vndk" |
| 2849 | } |
| 2850 | return "native:vndk_private" |
| 2851 | } |
Justin Yun | 5f7f7e8 | 2019-11-18 19:52:14 +0900 | [diff] [blame] | 2852 | if c.inProduct() { |
| 2853 | return "native:product" |
| 2854 | } |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2855 | return "native:vendor" |
Yifan Hong | 1b3348d | 2020-01-21 15:53:22 -0800 | [diff] [blame] | 2856 | } else if c.InRamdisk() { |
| 2857 | return "native:ramdisk" |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2858 | } else if c.InRecovery() { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2859 | return "native:recovery" |
| 2860 | } else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" { |
| 2861 | return "native:ndk:none:none" |
| 2862 | // TODO(b/114741097): use the correct ndk stl once build errors have been fixed |
| 2863 | //family, link := getNdkStlFamilyAndLinkType(c) |
| 2864 | //return fmt.Sprintf("native:ndk:%s:%s", family, link) |
Ivan Lozano | 52767be | 2019-10-18 14:49:46 -0700 | [diff] [blame] | 2865 | } else if actx.DeviceConfig().VndkUseCoreVariant() && !c.MustUseVendorVariant() { |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 2866 | return "native:platform_vndk" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2867 | } else { |
| 2868 | return "native:platform" |
| 2869 | } |
| 2870 | } |
| 2871 | |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2872 | // Overrides ApexModule.IsInstallabeToApex() |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2873 | // Only shared/runtime libraries and "test_per_src" tests are installable to APEX. |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2874 | func (c *Module) IsInstallableToApex() bool { |
| 2875 | if shared, ok := c.linker.(interface { |
| 2876 | shared() bool |
| 2877 | }); ok { |
Jiyong Park | 73c54ee | 2019-10-22 20:31:18 +0900 | [diff] [blame] | 2878 | // Stub libs and prebuilt libs in a versioned SDK are not |
| 2879 | // installable to APEX even though they are shared libs. |
| 2880 | return shared.shared() && !c.IsStubs() && c.ContainingSdk().Unversioned() |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2881 | } else if _, ok := c.linker.(testPerSrc); ok { |
| 2882 | return true |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2883 | } |
| 2884 | return false |
| 2885 | } |
| 2886 | |
Jiyong Park | a90ca00 | 2019-10-07 15:47:24 +0900 | [diff] [blame] | 2887 | func (c *Module) AvailableFor(what string) bool { |
| 2888 | if linker, ok := c.linker.(interface { |
| 2889 | availableFor(string) bool |
| 2890 | }); ok { |
| 2891 | return c.ApexModuleBase.AvailableFor(what) || linker.availableFor(what) |
| 2892 | } else { |
| 2893 | return c.ApexModuleBase.AvailableFor(what) |
| 2894 | } |
| 2895 | } |
| 2896 | |
Jiyong Park | 62304bb | 2020-04-13 16:19:48 +0900 | [diff] [blame] | 2897 | func (c *Module) TestFor() []string { |
| 2898 | if test, ok := c.linker.(interface { |
| 2899 | testFor() []string |
| 2900 | }); ok { |
| 2901 | return test.testFor() |
| 2902 | } else { |
| 2903 | return c.ApexModuleBase.TestFor() |
| 2904 | } |
| 2905 | } |
| 2906 | |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 2907 | // Return true if the module is ever installable. |
| 2908 | func (c *Module) EverInstallable() bool { |
| 2909 | return c.installer != nil && |
| 2910 | // Check to see whether the module is actually ever installable. |
| 2911 | c.installer.everInstallable() |
| 2912 | } |
| 2913 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 2914 | func (c *Module) installable() bool { |
Paul Duffin | 0cb37b9 | 2020-03-04 14:52:46 +0000 | [diff] [blame] | 2915 | ret := c.EverInstallable() && |
| 2916 | // Check to see whether the module has been configured to not be installed. |
| 2917 | proptools.BoolDefault(c.Properties.Installable, true) && |
| 2918 | !c.Properties.PreventInstall && c.outputFile.Valid() |
Jiyong Park | fe9a430 | 2020-01-07 16:59:44 +0900 | [diff] [blame] | 2919 | |
| 2920 | // The platform variant doesn't need further condition. Apex variants however might not |
| 2921 | // be installable because it will likely to be included in the APEX and won't appear |
| 2922 | // in the system partition. |
| 2923 | if c.IsForPlatform() { |
| 2924 | return ret |
| 2925 | } |
| 2926 | |
| 2927 | // Special case for modules that are configured to be installed to /data, which includes |
| 2928 | // test modules. For these modules, both APEX and non-APEX variants are considered as |
| 2929 | // installable. This is because even the APEX variants won't be included in the APEX, but |
| 2930 | // will anyway be installed to /data/*. |
| 2931 | // See b/146995717 |
| 2932 | if c.InstallInData() { |
| 2933 | return ret |
| 2934 | } |
| 2935 | |
| 2936 | return false |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 2937 | } |
| 2938 | |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 2939 | func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) { |
| 2940 | if c.linker != nil { |
| 2941 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 2942 | library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w) |
| 2943 | } |
| 2944 | } |
| 2945 | } |
| 2946 | |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 2947 | func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2948 | depTag := ctx.OtherModuleDependencyTag(dep) |
| 2949 | libDepTag, isLibDepTag := depTag.(libraryDependencyTag) |
| 2950 | |
| 2951 | if cc, ok := dep.(*Module); ok { |
| 2952 | if cc.HasStubsVariants() { |
| 2953 | if isLibDepTag && libDepTag.shared() { |
| 2954 | // dynamic dep to a stubs lib crosses APEX boundary |
| 2955 | return false |
Jiyong Park | d7536ba | 2020-01-16 17:14:23 +0900 | [diff] [blame] | 2956 | } |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2957 | if IsRuntimeDepTag(depTag) { |
| 2958 | // runtime dep to a stubs lib also crosses APEX boundary |
Jiyong Park | d7536ba | 2020-01-16 17:14:23 +0900 | [diff] [blame] | 2959 | return false |
| 2960 | } |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 2961 | } |
Colin Cross | 6e511a9 | 2020-07-27 21:26:48 -0700 | [diff] [blame] | 2962 | // TODO(ccross): The libDepTag.reexportFlags is there to maintain previous behavior |
| 2963 | // when adding libraryDependencyTag and should be removed. |
| 2964 | if isLibDepTag && c.static() && libDepTag.shared() && !libDepTag.reexportFlags { |
| 2965 | // shared_lib dependency from a static lib is considered as crossing |
| 2966 | // the APEX boundary because the dependency doesn't actually is |
| 2967 | // linked; the dependency is used only during the compilation phase. |
| 2968 | return false |
| 2969 | } |
| 2970 | } |
| 2971 | if depTag == llndkImplDep { |
Jiyong Park | 7d95a51 | 2020-05-10 15:16:24 +0900 | [diff] [blame] | 2972 | // We don't track beyond LLNDK |
| 2973 | return false |
Jiyong Park | a7bc8ad | 2019-10-15 15:20:07 +0900 | [diff] [blame] | 2974 | } |
| 2975 | return true |
| 2976 | } |
| 2977 | |
Jooyung Han | 749dc69 | 2020-04-15 11:03:39 +0900 | [diff] [blame] | 2978 | // b/154667674: refactor this to handle "current" in a consistent way |
| 2979 | func decodeSdkVersionString(ctx android.BaseModuleContext, versionString string) (int, error) { |
| 2980 | if versionString == "" { |
| 2981 | return 0, fmt.Errorf("not specified") |
| 2982 | } |
| 2983 | if versionString == "current" { |
| 2984 | if ctx.Config().PlatformSdkCodename() == "REL" { |
| 2985 | return ctx.Config().PlatformSdkVersionInt(), nil |
| 2986 | } |
| 2987 | return android.FutureApiLevel, nil |
| 2988 | } |
| 2989 | return android.ApiStrToNum(ctx, versionString) |
| 2990 | } |
| 2991 | |
| 2992 | func (c *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { |
| 2993 | // We ignore libclang_rt.* prebuilt libs since they declare sdk_version: 14(b/121358700) |
| 2994 | if strings.HasPrefix(ctx.OtherModuleName(c), "libclang_rt") { |
| 2995 | return nil |
| 2996 | } |
| 2997 | // b/154569636: set min_sdk_version correctly for toolchain_libraries |
| 2998 | if c.ToolchainLibrary() { |
| 2999 | return nil |
| 3000 | } |
| 3001 | // We don't check for prebuilt modules |
| 3002 | if _, ok := c.linker.(prebuiltLinkerInterface); ok { |
| 3003 | return nil |
| 3004 | } |
| 3005 | minSdkVersion := c.MinSdkVersion() |
| 3006 | if minSdkVersion == "apex_inherit" { |
| 3007 | return nil |
| 3008 | } |
| 3009 | if minSdkVersion == "" { |
| 3010 | // JNI libs within APK-in-APEX fall into here |
| 3011 | // Those are okay to set sdk_version instead |
| 3012 | // We don't have to check if this is a SDK variant because |
| 3013 | // non-SDK variant resets sdk_version, which works too. |
| 3014 | minSdkVersion = c.SdkVersion() |
| 3015 | } |
| 3016 | ver, err := decodeSdkVersionString(ctx, minSdkVersion) |
| 3017 | if err != nil { |
| 3018 | return err |
| 3019 | } |
| 3020 | if ver > sdkVersion { |
| 3021 | return fmt.Errorf("newer SDK(%v)", ver) |
| 3022 | } |
| 3023 | return nil |
| 3024 | } |
| 3025 | |
Colin Cross | 2ba19d9 | 2015-05-07 15:44:20 -0700 | [diff] [blame] | 3026 | // |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 3027 | // Defaults |
| 3028 | // |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 3029 | type Defaults struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 3030 | android.ModuleBase |
Colin Cross | 1f44a3a | 2017-07-07 14:33:33 -0700 | [diff] [blame] | 3031 | android.DefaultsModuleBase |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 3032 | android.ApexModuleBase |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 3033 | } |
| 3034 | |
Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 3035 | // cc_defaults provides a set of properties that can be inherited by other cc |
| 3036 | // modules. A module can use the properties from a cc_defaults using |
| 3037 | // `defaults: ["<:default_module_name>"]`. Properties of both modules are |
| 3038 | // merged (when possible) by prepending the default module's values to the |
| 3039 | // depending module's values. |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 3040 | func defaultsFactory() android.Module { |
Colin Cross | e1d764e | 2016-08-18 14:18:32 -0700 | [diff] [blame] | 3041 | return DefaultsFactory() |
| 3042 | } |
| 3043 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 3044 | func DefaultsFactory(props ...interface{}) android.Module { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 3045 | module := &Defaults{} |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 3046 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 3047 | module.AddProperties(props...) |
| 3048 | module.AddProperties( |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 3049 | &BaseProperties{}, |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 3050 | &VendorProperties{}, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 3051 | &BaseCompilerProperties{}, |
| 3052 | &BaseLinkerProperties{}, |
Paul Duffin | a37832a | 2019-07-18 12:31:26 +0100 | [diff] [blame] | 3053 | &ObjectLinkerProperties{}, |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 3054 | &LibraryProperties{}, |
Colin Cross | e1bb5d0 | 2019-09-24 14:55:04 -0700 | [diff] [blame] | 3055 | &StaticProperties{}, |
| 3056 | &SharedProperties{}, |
Colin Cross | 919281a | 2016-04-05 16:42:05 -0700 | [diff] [blame] | 3057 | &FlagExporterProperties{}, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 3058 | &BinaryLinkerProperties{}, |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 3059 | &TestProperties{}, |
| 3060 | &TestBinaryProperties{}, |
Colin Cross | 4328765 | 2020-06-30 10:15:07 -0700 | [diff] [blame] | 3061 | &BenchmarkProperties{}, |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame] | 3062 | &FuzzProperties{}, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 3063 | &StlProperties{}, |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 3064 | &SanitizeProperties{}, |
Colin Cross | 665dce9 | 2016-04-28 14:50:03 -0700 | [diff] [blame] | 3065 | &StripProperties{}, |
Dan Willemsen | 7424d61 | 2016-09-01 13:45:39 -0700 | [diff] [blame] | 3066 | &InstallerProperties{}, |
Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 3067 | &TidyProperties{}, |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 3068 | &CoverageProperties{}, |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 3069 | &SAbiProperties{}, |
Justin Yun | 4b2382f | 2017-07-26 14:22:10 +0900 | [diff] [blame] | 3070 | &VndkProperties{}, |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 3071 | <OProperties{}, |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 3072 | &PgoProperties{}, |
Dan Willemsen | 6424d17 | 2018-03-08 13:27:59 -0800 | [diff] [blame] | 3073 | &android.ProtoProperties{}, |
Colin Cross | e1d764e | 2016-08-18 14:18:32 -0700 | [diff] [blame] | 3074 | ) |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 3075 | |
Jooyung Han | cc372c5 | 2019-09-25 15:18:44 +0900 | [diff] [blame] | 3076 | android.InitDefaultsModule(module) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 3077 | |
| 3078 | return module |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 3079 | } |
| 3080 | |
Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 3081 | func squashVendorSrcs(m *Module) { |
| 3082 | if lib, ok := m.compiler.(*libraryDecorator); ok { |
| 3083 | lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, |
| 3084 | lib.baseCompiler.Properties.Target.Vendor.Srcs...) |
| 3085 | |
| 3086 | lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, |
| 3087 | lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...) |
Jooyung Han | ac07f88 | 2020-07-05 03:54:35 +0900 | [diff] [blame] | 3088 | |
| 3089 | lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources, |
| 3090 | lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...) |
Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 3091 | } |
| 3092 | } |
| 3093 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 3094 | func squashRecoverySrcs(m *Module) { |
| 3095 | if lib, ok := m.compiler.(*libraryDecorator); ok { |
| 3096 | lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, |
| 3097 | lib.baseCompiler.Properties.Target.Recovery.Srcs...) |
| 3098 | |
| 3099 | lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, |
| 3100 | lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...) |
Jooyung Han | ac07f88 | 2020-07-05 03:54:35 +0900 | [diff] [blame] | 3101 | |
| 3102 | lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources, |
| 3103 | lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...) |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 3104 | } |
| 3105 | } |
| 3106 | |
Jiyong Park | 2286afd | 2020-06-16 21:58:53 +0900 | [diff] [blame] | 3107 | func (c *Module) IsSdkVariant() bool { |
Dan Albert | 92fe740 | 2020-07-15 13:33:30 -0700 | [diff] [blame^] | 3108 | return c.Properties.IsSdkVariant || c.AlwaysSdk() |
Jiyong Park | 2286afd | 2020-06-16 21:58:53 +0900 | [diff] [blame] | 3109 | } |
| 3110 | |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 3111 | func getCurrentNdkPrebuiltVersion(ctx DepsContext) string { |
Colin Cross | 6510f91 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 3112 | if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt { |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 3113 | return strconv.Itoa(config.NdkMaxPrebuiltVersionInt) |
| 3114 | } |
Colin Cross | 6510f91 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 3115 | return ctx.Config().PlatformSdkVersion() |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 3116 | } |
| 3117 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 3118 | func kytheExtractAllFactory() android.Singleton { |
| 3119 | return &kytheExtractAllSingleton{} |
| 3120 | } |
| 3121 | |
| 3122 | type kytheExtractAllSingleton struct { |
| 3123 | } |
| 3124 | |
| 3125 | func (ks *kytheExtractAllSingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 3126 | var xrefTargets android.Paths |
| 3127 | ctx.VisitAllModules(func(module android.Module) { |
| 3128 | if ccModule, ok := module.(xref); ok { |
| 3129 | xrefTargets = append(xrefTargets, ccModule.XrefCcFiles()...) |
| 3130 | } |
| 3131 | }) |
| 3132 | // TODO(asmundak): Perhaps emit a rule to output a warning if there were no xrefTargets |
| 3133 | if len(xrefTargets) > 0 { |
Colin Cross | c3d87d3 | 2020-06-04 13:25:17 -0700 | [diff] [blame] | 3134 | ctx.Phony("xref_cxx", xrefTargets...) |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 3135 | } |
| 3136 | } |
| 3137 | |
Colin Cross | 06a931b | 2015-10-28 17:23:31 -0700 | [diff] [blame] | 3138 | var Bool = proptools.Bool |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 3139 | var BoolDefault = proptools.BoolDefault |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 3140 | var BoolPtr = proptools.BoolPtr |
| 3141 | var String = proptools.String |
| 3142 | var StringPtr = proptools.StringPtr |