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() { |
Colin Cross | 798bfce | 2016-10-12 14:28:16 -0700 | [diff] [blame] | 36 | android.RegisterModuleType("cc_defaults", defaultsFactory) |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 37 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 38 | android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 39 | ctx.BottomUp("image", ImageMutator).Parallel() |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 40 | ctx.BottomUp("link", LinkageMutator).Parallel() |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 41 | ctx.BottomUp("vndk", VndkMutator).Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 42 | ctx.BottomUp("ndk_api", ndkApiMutator).Parallel() |
Roland Levillain | 9b5fde9 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 43 | ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 44 | ctx.BottomUp("version", VersionMutator).Parallel() |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 45 | ctx.BottomUp("begin", BeginMutator).Parallel() |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 46 | ctx.BottomUp("sysprop", SyspropMutator).Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 47 | }) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 48 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 49 | android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 50 | ctx.TopDown("asan_deps", sanitizerDepsMutator(asan)) |
| 51 | ctx.BottomUp("asan", sanitizerMutator(asan)).Parallel() |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 52 | |
Evgenii Stepanov | d97a6e9 | 2018-08-02 16:19:13 -0700 | [diff] [blame] | 53 | ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan)) |
| 54 | ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel() |
| 55 | |
Mitch Phillips | bfeade6 | 2019-05-01 14:42:05 -0700 | [diff] [blame] | 56 | ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(fuzzer)) |
| 57 | ctx.BottomUp("fuzzer", sanitizerMutator(fuzzer)).Parallel() |
| 58 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 59 | // cfi mutator shouldn't run before sanitizers that return true for |
| 60 | // incompatibleWithCfi() |
Vishwath Mohan | b743e9c | 2017-11-01 09:20:21 +0000 | [diff] [blame] | 61 | ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi)) |
| 62 | ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel() |
| 63 | |
Peter Collingbourne | 8c7e6e2 | 2018-11-19 16:03:58 -0800 | [diff] [blame] | 64 | ctx.TopDown("scs_deps", sanitizerDepsMutator(scs)) |
| 65 | ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel() |
| 66 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 67 | ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan)) |
| 68 | ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel() |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 69 | |
Colin Cross | 0b90833 | 2019-06-19 23:00:20 -0700 | [diff] [blame] | 70 | ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel() |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 71 | ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel() |
Ivan Lozano | 30c5db2 | 2018-02-21 15:49:20 -0800 | [diff] [blame] | 72 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 73 | ctx.BottomUp("coverage", coverageMutator).Parallel() |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 74 | ctx.TopDown("vndk_deps", sabiDepsMutator) |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 75 | |
| 76 | ctx.TopDown("lto_deps", ltoDepsMutator) |
| 77 | ctx.BottomUp("lto", ltoMutator).Parallel() |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 78 | |
| 79 | ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 80 | }) |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 81 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 82 | android.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory) |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 83 | pctx.Import("android/soong/cc/config") |
Colin Cross | 463a90e | 2015-06-17 14:20:06 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 86 | type Deps struct { |
| 87 | SharedLibs, LateSharedLibs []string |
| 88 | StaticLibs, LateStaticLibs, WholeStaticLibs []string |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 89 | HeaderLibs []string |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 90 | RuntimeLibs []string |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 91 | |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 92 | ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 93 | |
Colin Cross | 8141347 | 2016-04-11 14:37:39 -0700 | [diff] [blame] | 94 | ObjFiles []string |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 95 | |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 96 | GeneratedSources []string |
| 97 | GeneratedHeaders []string |
| 98 | |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 99 | ReexportGeneratedHeaders []string |
| 100 | |
Colin Cross | 97ba073 | 2015-03-23 17:50:24 -0700 | [diff] [blame] | 101 | CrtBegin, CrtEnd string |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 102 | |
| 103 | // Used for host bionic |
| 104 | LinkerFlagsFile string |
| 105 | DynamicLinker string |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 108 | type PathDeps struct { |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 109 | // Paths to .so files |
Jiyong Park | 64a44f2 | 2019-01-18 14:37:08 +0900 | [diff] [blame] | 110 | SharedLibs, EarlySharedLibs, LateSharedLibs android.Paths |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 111 | // Paths to the dependencies to use for .so files (.so.toc files) |
Jiyong Park | 64a44f2 | 2019-01-18 14:37:08 +0900 | [diff] [blame] | 112 | SharedLibsDeps, EarlySharedLibsDeps, LateSharedLibsDeps android.Paths |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 113 | // Paths to .a files |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 114 | StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 115 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 116 | // Paths to .o files |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 117 | Objs Objects |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 118 | StaticLibObjs Objects |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 119 | WholeStaticLibObjs Objects |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 120 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 121 | // Paths to generated source files |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 122 | GeneratedSources android.Paths |
| 123 | GeneratedHeaders android.Paths |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 124 | |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 125 | Flags []string |
| 126 | IncludeDirs []string |
| 127 | SystemIncludeDirs []string |
| 128 | ReexportedDirs []string |
| 129 | ReexportedSystemDirs []string |
| 130 | ReexportedFlags []string |
| 131 | ReexportedDeps android.Paths |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 132 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 133 | // Paths to crt*.o files |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 134 | CrtBegin, CrtEnd android.OptionalPath |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 135 | |
| 136 | // Path to the file container flags to use with the linker |
| 137 | LinkerFlagsFile android.OptionalPath |
| 138 | |
| 139 | // Path to the dynamic linker binary |
| 140 | DynamicLinker android.OptionalPath |
Dan Willemsen | 34cc69e | 2015-09-23 15:26:20 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 143 | type Flags struct { |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 144 | GlobalFlags []string // Flags that apply to C, C++, and assembly source files |
| 145 | ArFlags []string // Flags that apply to ar |
| 146 | AsFlags []string // Flags that apply to assembly source files |
| 147 | CFlags []string // Flags that apply to C and C++ source files |
| 148 | ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools |
| 149 | ConlyFlags []string // Flags that apply to C source files |
| 150 | CppFlags []string // Flags that apply to C++ source files |
| 151 | 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] | 152 | aidlFlags []string // Flags that apply to aidl source files |
| 153 | rsFlags []string // Flags that apply to renderscript source files |
| 154 | LdFlags []string // Flags that apply to linker command lines |
| 155 | libFlags []string // Flags to add libraries early to the link order |
Pete Bentley | 99f2fc2 | 2019-08-02 14:02:20 +0100 | [diff] [blame] | 156 | extraLibFlags []string // Flags to add libraries late in the link order after LdFlags |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 157 | TidyFlags []string // Flags that apply to clang-tidy |
| 158 | SAbiFlags []string // Flags that apply to header-abi-dumper |
| 159 | YasmFlags []string // Flags that apply to yasm assembly source files |
Colin Cross | 2834452 | 2015-04-22 13:07:53 -0700 | [diff] [blame] | 160 | |
Colin Cross | c319948 | 2017-03-30 15:03:04 -0700 | [diff] [blame] | 161 | // Global include flags that apply to C, C++, and assembly source files |
| 162 | // These must be after any module include flags, which will be in GlobalFlags. |
| 163 | SystemIncludeFlags []string |
| 164 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 165 | Toolchain config.Toolchain |
Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 166 | Tidy bool |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 167 | Coverage bool |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 168 | SAbiDump bool |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 169 | 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] | 170 | |
| 171 | RequiredInstructionSet string |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 172 | DynamicLinker string |
| 173 | |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 174 | CFlagsDeps android.Paths // Files depended on by compiler flags |
| 175 | LdFlagsDeps android.Paths // Files depended on by linker flags |
Colin Cross | 18c0c5a | 2016-12-01 14:45:23 -0800 | [diff] [blame] | 176 | |
Dan Willemsen | 98ab311 | 2019-08-27 21:20:40 -0700 | [diff] [blame] | 177 | AssemblerWithCpp bool |
| 178 | GroupStaticLibs bool |
Dan Willemsen | 60e62f0 | 2018-11-16 21:05:32 -0800 | [diff] [blame] | 179 | |
Colin Cross | 19878da | 2019-03-28 14:45:07 -0700 | [diff] [blame] | 180 | proto android.ProtoFlags |
Colin Cross | 19878da | 2019-03-28 14:45:07 -0700 | [diff] [blame] | 181 | protoC bool // Whether to use C instead of C++ |
| 182 | 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] | 183 | |
| 184 | Yacc *YaccProperties |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 187 | // Properties used to compile all C or C++ modules |
| 188 | type BaseProperties struct { |
Dan Willemsen | 742a545 | 2018-07-23 17:19:36 -0700 | [diff] [blame] | 189 | // Deprecated. true is the default, false is invalid. |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 190 | Clang *bool `android:"arch_variant"` |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 191 | |
| 192 | // Minimum sdk version supported when compiling against the ndk |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 193 | Sdk_version *string |
Colin Cross | 7d5136f | 2015-05-11 13:39:40 -0700 | [diff] [blame] | 194 | |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 195 | AndroidMkSharedLibs []string `blueprint:"mutated"` |
| 196 | AndroidMkStaticLibs []string `blueprint:"mutated"` |
| 197 | AndroidMkRuntimeLibs []string `blueprint:"mutated"` |
| 198 | AndroidMkWholeStaticLibs []string `blueprint:"mutated"` |
| 199 | HideFromMake bool `blueprint:"mutated"` |
| 200 | PreventInstall bool `blueprint:"mutated"` |
| 201 | ApexesProvidingSharedLibs []string `blueprint:"mutated"` |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 202 | |
| 203 | UseVndk bool `blueprint:"mutated"` |
Colin Cross | 5beccee | 2017-12-07 15:28:59 -0800 | [diff] [blame] | 204 | |
| 205 | // *.logtags files, to combine together in order to generate the /system/etc/event-log-tags |
| 206 | // file |
| 207 | Logtags []string |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 208 | |
| 209 | // Make this module available when building for recovery |
| 210 | Recovery_available *bool |
| 211 | |
| 212 | InRecovery bool `blueprint:"mutated"` |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 213 | |
| 214 | // Allows this module to use non-APEX version of libraries. Useful |
| 215 | // for building binaries that are started before APEXes are activated. |
| 216 | Bootstrap *bool |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | type VendorProperties struct { |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 220 | // whether this module should be allowed to be directly depended by other |
| 221 | // modules with `vendor: true`, `proprietary: true`, or `vendor_available:true`. |
| 222 | // If set to true, two variants will be built separately, one like |
| 223 | // normal, and the other limited to the set of libraries and headers |
| 224 | // that are exposed to /vendor modules. |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 225 | // |
| 226 | // The vendor variant may be used with a different (newer) /system, |
| 227 | // so it shouldn't have any unversioned runtime dependencies, or |
| 228 | // make assumptions about the system that may not be true in the |
| 229 | // future. |
| 230 | // |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 231 | // If set to false, this module becomes inaccessible from /vendor modules. |
| 232 | // |
| 233 | // Default value is true when vndk: {enabled: true} or vendor: true. |
| 234 | // |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 235 | // Nothing happens if BOARD_VNDK_VERSION isn't set in the BoardConfig.mk |
| 236 | Vendor_available *bool |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 237 | |
| 238 | // whether this module is capable of being loaded with other instance |
| 239 | // (possibly an older version) of the same module in the same process. |
| 240 | // Currently, a shared library that is a member of VNDK (vndk: {enabled: true}) |
| 241 | // can be double loaded in a vendor process if the library is also a |
| 242 | // (direct and indirect) dependency of an LLNDK library. Such libraries must be |
| 243 | // explicitly marked as `double_loadable: true` by the owner, or the dependency |
| 244 | // from the LLNDK lib should be cut if the lib is not designed to be double loaded. |
| 245 | Double_loadable *bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 246 | } |
| 247 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 248 | type ModuleContextIntf interface { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 249 | static() bool |
| 250 | staticBinary() bool |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 251 | header() bool |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 252 | toolchain() config.Toolchain |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 253 | useSdk() bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 254 | sdkVersion() string |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 255 | useVndk() bool |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 256 | isNdk() bool |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 257 | isLlndk(config android.Config) bool |
| 258 | isLlndkPublic(config android.Config) bool |
| 259 | isVndkPrivate(config android.Config) bool |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 260 | isVndk() bool |
| 261 | isVndkSp() bool |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 262 | isVndkExt() bool |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 263 | inRecovery() bool |
Hsin-Yi Chen | af17d74 | 2019-07-29 17:46:59 +0800 | [diff] [blame] | 264 | shouldCreateSourceAbiDump() bool |
Dan Willemsen | 8146b2f | 2016-03-30 21:00:30 -0700 | [diff] [blame] | 265 | selectedStl() string |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 266 | baseModuleName() string |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 267 | getVndkExtendsModuleName() string |
Yi Kong | 7e53c57 | 2018-02-14 18:16:12 +0800 | [diff] [blame] | 268 | isPgoCompile() bool |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 269 | isNDKStubLibrary() bool |
Ivan Lozano | bd72126 | 2018-11-27 14:33:03 -0800 | [diff] [blame] | 270 | useClangLld(actx ModuleContext) bool |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 271 | apexName() string |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 272 | hasStubsVariants() bool |
| 273 | isStubs() bool |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 274 | bootstrap() bool |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 275 | mustUseVendorVariant() bool |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 276 | nativeCoverage() bool |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | type ModuleContext interface { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 280 | android.ModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 281 | ModuleContextIntf |
| 282 | } |
| 283 | |
| 284 | type BaseModuleContext interface { |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 285 | android.BaseModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 286 | ModuleContextIntf |
| 287 | } |
| 288 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 289 | type DepsContext interface { |
| 290 | android.BottomUpMutatorContext |
| 291 | ModuleContextIntf |
| 292 | } |
| 293 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 294 | type feature interface { |
| 295 | begin(ctx BaseModuleContext) |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 296 | deps(ctx DepsContext, deps Deps) Deps |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 297 | flags(ctx ModuleContext, flags Flags) Flags |
| 298 | props() []interface{} |
| 299 | } |
| 300 | |
| 301 | type compiler interface { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 302 | compilerInit(ctx BaseModuleContext) |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 303 | compilerDeps(ctx DepsContext, deps Deps) Deps |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 304 | compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 305 | compilerProps() []interface{} |
| 306 | |
Colin Cross | 76fada0 | 2016-07-27 10:31:13 -0700 | [diff] [blame] | 307 | appendCflags([]string) |
| 308 | appendAsflags([]string) |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 309 | compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | type linker interface { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 313 | linkerInit(ctx BaseModuleContext) |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 314 | linkerDeps(ctx DepsContext, deps Deps) Deps |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 315 | linkerFlags(ctx ModuleContext, flags Flags) Flags |
| 316 | linkerProps() []interface{} |
Ivan Lozano | bd72126 | 2018-11-27 14:33:03 -0800 | [diff] [blame] | 317 | useClangLld(actx ModuleContext) bool |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 318 | |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 319 | link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path |
Colin Cross | 76fada0 | 2016-07-27 10:31:13 -0700 | [diff] [blame] | 320 | appendLdflags([]string) |
Jiyong Park | af6d895 | 2019-01-31 12:21:23 +0900 | [diff] [blame] | 321 | unstrippedOutputFilePath() android.Path |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 322 | |
| 323 | nativeCoverage() bool |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 324 | coverageOutputFilePath() android.OptionalPath |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | type installer interface { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 328 | installerProps() []interface{} |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 329 | install(ctx ModuleContext, path android.Path) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 330 | inData() bool |
Vishwath Mohan | 1dd8839 | 2017-03-29 22:00:18 -0700 | [diff] [blame] | 331 | inSanitizerDir() bool |
Dan Willemsen | 4aa75ca | 2016-09-28 16:18:03 -0700 | [diff] [blame] | 332 | hostToolPath() android.OptionalPath |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 333 | relativeInstallPath() string |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 334 | } |
| 335 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 336 | type dependencyTag struct { |
| 337 | blueprint.BaseDependencyTag |
| 338 | name string |
| 339 | library bool |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 340 | shared bool |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 341 | |
| 342 | reexportFlags bool |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 343 | |
| 344 | explicitlyVersioned bool |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 347 | type xref interface { |
| 348 | XrefCcFiles() android.Paths |
| 349 | } |
| 350 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 351 | var ( |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 352 | sharedDepTag = dependencyTag{name: "shared", library: true, shared: true} |
| 353 | sharedExportDepTag = dependencyTag{name: "shared", library: true, shared: true, reexportFlags: true} |
| 354 | earlySharedDepTag = dependencyTag{name: "early_shared", library: true, shared: true} |
| 355 | lateSharedDepTag = dependencyTag{name: "late shared", library: true, shared: true} |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 356 | staticDepTag = dependencyTag{name: "static", library: true} |
| 357 | staticExportDepTag = dependencyTag{name: "static", library: true, reexportFlags: true} |
| 358 | lateStaticDepTag = dependencyTag{name: "late static", library: true} |
| 359 | wholeStaticDepTag = dependencyTag{name: "whole static", library: true, reexportFlags: true} |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 360 | headerDepTag = dependencyTag{name: "header", library: true} |
| 361 | headerExportDepTag = dependencyTag{name: "header", library: true, reexportFlags: true} |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 362 | genSourceDepTag = dependencyTag{name: "gen source"} |
| 363 | genHeaderDepTag = dependencyTag{name: "gen header"} |
| 364 | genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true} |
| 365 | objDepTag = dependencyTag{name: "obj"} |
| 366 | crtBeginDepTag = dependencyTag{name: "crtbegin"} |
| 367 | crtEndDepTag = dependencyTag{name: "crtend"} |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 368 | linkerFlagsDepTag = dependencyTag{name: "linker flags file"} |
| 369 | dynamicLinkerDepTag = dependencyTag{name: "dynamic linker"} |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 370 | reuseObjTag = dependencyTag{name: "reuse objects"} |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 371 | staticVariantTag = dependencyTag{name: "static variant"} |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 372 | ndkStubDepTag = dependencyTag{name: "ndk stub", library: true} |
| 373 | ndkLateStubDepTag = dependencyTag{name: "ndk late stub", library: true} |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 374 | vndkExtDepTag = dependencyTag{name: "vndk extends", library: true} |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 375 | runtimeDepTag = dependencyTag{name: "runtime lib"} |
Pirama Arumuga Nainar | 82fe59b | 2019-07-02 14:55:35 -0700 | [diff] [blame] | 376 | coverageDepTag = dependencyTag{name: "coverage"} |
Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 377 | testPerSrcDepTag = dependencyTag{name: "test_per_src"} |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 378 | ) |
| 379 | |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 380 | func IsSharedDepTag(depTag blueprint.DependencyTag) bool { |
| 381 | ccDepTag, ok := depTag.(dependencyTag) |
| 382 | return ok && ccDepTag.shared |
| 383 | } |
| 384 | |
| 385 | func IsRuntimeDepTag(depTag blueprint.DependencyTag) bool { |
| 386 | ccDepTag, ok := depTag.(dependencyTag) |
| 387 | return ok && ccDepTag == runtimeDepTag |
| 388 | } |
| 389 | |
| 390 | func IsTestPerSrcDepTag(depTag blueprint.DependencyTag) bool { |
| 391 | ccDepTag, ok := depTag.(dependencyTag) |
| 392 | return ok && ccDepTag == testPerSrcDepTag |
| 393 | } |
| 394 | |
Ivan Lozano | ffee334 | 2019-08-27 12:03:00 -0700 | [diff] [blame] | 395 | func SharedDepTag() dependencyTag { |
| 396 | return sharedDepTag |
| 397 | } |
| 398 | |
| 399 | func StaticDepTag() dependencyTag { |
| 400 | return staticDepTag |
| 401 | } |
| 402 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 403 | // Module contains the properties and members used by all C/C++ module types, and implements |
| 404 | // the blueprint.Module interface. It delegates to compiler, linker, and installer interfaces |
| 405 | // to construct the output file. Behavior can be customized with a Customizer interface |
| 406 | type Module struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 407 | android.ModuleBase |
Colin Cross | 1f44a3a | 2017-07-07 14:33:33 -0700 | [diff] [blame] | 408 | android.DefaultableModuleBase |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 409 | android.ApexModuleBase |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 410 | |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 411 | Properties BaseProperties |
| 412 | VendorProperties VendorProperties |
Colin Cross | fa13879 | 2015-04-24 17:31:52 -0700 | [diff] [blame] | 413 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 414 | // initialize before calling Init |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 415 | hod android.HostOrDeviceSupported |
| 416 | multilib android.Multilib |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 417 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 418 | // delegates, initialize before calling Init |
Colin Cross | b4ce0ec | 2016-09-13 13:41:39 -0700 | [diff] [blame] | 419 | features []feature |
| 420 | compiler compiler |
| 421 | linker linker |
| 422 | installer installer |
| 423 | stl *stl |
| 424 | sanitize *sanitize |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 425 | coverage *coverage |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 426 | sabi *sabi |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 427 | vndkdep *vndkdep |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 428 | lto *lto |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 429 | pgo *pgo |
Ivan Lozano | 074ec48 | 2018-11-21 08:59:37 -0800 | [diff] [blame] | 430 | xom *xom |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 431 | |
| 432 | androidMkSharedLibDeps []string |
Colin Cross | 74d1ec0 | 2015-04-28 13:30:13 -0700 | [diff] [blame] | 433 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 434 | outputFile android.OptionalPath |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 435 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 436 | cachedToolchain config.Toolchain |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 437 | |
| 438 | subAndroidMkOnce map[subAndroidMkProvider]bool |
Fabien Sanglard | d61f1f4 | 2017-01-10 16:21:22 -0800 | [diff] [blame] | 439 | |
| 440 | // Flags used to compile this module |
| 441 | flags Flags |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 442 | |
| 443 | // 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] | 444 | // line invocation. depsInLinkOrder stores the proper ordering of all of the transitive |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 445 | // deps of this module |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 446 | depsInLinkOrder android.Paths |
| 447 | |
| 448 | // only non-nil when this is a shared library that reuses the objects of a static library |
| 449 | staticVariant *Module |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 450 | |
| 451 | makeLinkType string |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 452 | // Kythe (source file indexer) paths for this compilation module |
| 453 | kytheFiles android.Paths |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 454 | } |
| 455 | |
Jiyong Park | c20eee3 | 2018-09-05 22:36:17 +0900 | [diff] [blame] | 456 | func (c *Module) OutputFile() android.OptionalPath { |
| 457 | return c.outputFile |
| 458 | } |
| 459 | |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 460 | func (c *Module) UnstrippedOutputFile() android.Path { |
Jiyong Park | af6d895 | 2019-01-31 12:21:23 +0900 | [diff] [blame] | 461 | if c.linker != nil { |
| 462 | return c.linker.unstrippedOutputFilePath() |
Jiyong Park | 719b446 | 2019-01-13 00:39:51 +0900 | [diff] [blame] | 463 | } |
| 464 | return nil |
| 465 | } |
| 466 | |
Jiyong Park | ee9a98d | 2019-08-09 14:44:36 +0900 | [diff] [blame] | 467 | func (c *Module) CoverageOutputFile() android.OptionalPath { |
| 468 | if c.linker != nil { |
| 469 | return c.linker.coverageOutputFilePath() |
| 470 | } |
| 471 | return android.OptionalPath{} |
| 472 | } |
| 473 | |
Jiyong Park | b7c24df | 2019-02-01 12:03:59 +0900 | [diff] [blame] | 474 | func (c *Module) RelativeInstallPath() string { |
| 475 | if c.installer != nil { |
| 476 | return c.installer.relativeInstallPath() |
| 477 | } |
| 478 | return "" |
| 479 | } |
| 480 | |
Jooyung Han | 344d543 | 2019-08-23 11:17:39 +0900 | [diff] [blame] | 481 | // IsVndkOnSystem returns true if a module is supposed to be a vndk library provided by system to vendor |
| 482 | func (c *Module) IsVndkOnSystem() bool { |
| 483 | if linker, ok := c.linker.(libraryInterface); ok { |
| 484 | return linker.shared() && c.isVndk() && c.useVndk() && !c.isVndkExt() |
| 485 | } |
| 486 | |
| 487 | return false |
| 488 | } |
| 489 | |
| 490 | func (c *Module) VndkVersion() string { |
| 491 | return c.vndkVersion() |
| 492 | } |
| 493 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 494 | func (c *Module) Init() android.Module { |
Dan Willemsen | f923f2b | 2018-05-09 13:45:03 -0700 | [diff] [blame] | 495 | c.AddProperties(&c.Properties, &c.VendorProperties) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 496 | if c.compiler != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 497 | c.AddProperties(c.compiler.compilerProps()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 498 | } |
| 499 | if c.linker != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 500 | c.AddProperties(c.linker.linkerProps()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 501 | } |
| 502 | if c.installer != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 503 | c.AddProperties(c.installer.installerProps()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 504 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 505 | if c.stl != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 506 | c.AddProperties(c.stl.props()...) |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 507 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 508 | if c.sanitize != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 509 | c.AddProperties(c.sanitize.props()...) |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 510 | } |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 511 | if c.coverage != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 512 | c.AddProperties(c.coverage.props()...) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 513 | } |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 514 | if c.sabi != nil { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 515 | c.AddProperties(c.sabi.props()...) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 516 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 517 | if c.vndkdep != nil { |
| 518 | c.AddProperties(c.vndkdep.props()...) |
| 519 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 520 | if c.lto != nil { |
| 521 | c.AddProperties(c.lto.props()...) |
| 522 | } |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 523 | if c.pgo != nil { |
| 524 | c.AddProperties(c.pgo.props()...) |
| 525 | } |
Ivan Lozano | 074ec48 | 2018-11-21 08:59:37 -0800 | [diff] [blame] | 526 | if c.xom != nil { |
| 527 | c.AddProperties(c.xom.props()...) |
| 528 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 529 | for _, feature := range c.features { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 530 | c.AddProperties(feature.props()...) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 531 | } |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 532 | |
Colin Cross | a9d8bee | 2018-10-02 13:59:46 -0700 | [diff] [blame] | 533 | c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool { |
| 534 | switch class { |
| 535 | case android.Device: |
| 536 | return ctx.Config().DevicePrefer32BitExecutables() |
| 537 | case android.HostCross: |
| 538 | // Windows builds always prefer 32-bit |
| 539 | return true |
| 540 | default: |
| 541 | return false |
| 542 | } |
| 543 | }) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 544 | android.InitAndroidArchModule(c, c.hod, c.multilib) |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 545 | |
Colin Cross | 1f44a3a | 2017-07-07 14:33:33 -0700 | [diff] [blame] | 546 | android.InitDefaultableModule(c) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 547 | |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 548 | android.InitApexModule(c) |
| 549 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 550 | return c |
Colin Cross | c472d57 | 2015-03-17 15:06:21 -0700 | [diff] [blame] | 551 | } |
| 552 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 553 | // Returns true for dependency roots (binaries) |
| 554 | // TODO(ccross): also handle dlopenable libraries |
| 555 | func (c *Module) isDependencyRoot() bool { |
| 556 | if root, ok := c.linker.(interface { |
| 557 | isDependencyRoot() bool |
| 558 | }); ok { |
| 559 | return root.isDependencyRoot() |
| 560 | } |
| 561 | return false |
| 562 | } |
| 563 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 564 | func (c *Module) useVndk() bool { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 565 | return c.Properties.UseVndk |
| 566 | } |
| 567 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 568 | func (c *Module) isCoverageVariant() bool { |
| 569 | return c.coverage.Properties.IsCoverageVariant |
| 570 | } |
| 571 | |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 572 | func (c *Module) isNdk() bool { |
| 573 | return inList(c.Name(), ndkMigratedLibs) |
| 574 | } |
| 575 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 576 | func (c *Module) isLlndk(config android.Config) bool { |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 577 | // Returns true for both LLNDK (public) and LLNDK-private libs. |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 578 | return inList(c.Name(), *llndkLibraries(config)) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 579 | } |
| 580 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 581 | func (c *Module) isLlndkPublic(config android.Config) bool { |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 582 | // Returns true only for LLNDK (public) libs. |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 583 | return c.isLlndk(config) && !c.isVndkPrivate(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 584 | } |
| 585 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 586 | func (c *Module) isVndkPrivate(config android.Config) bool { |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 587 | // Returns true for LLNDK-private, VNDK-SP-private, and VNDK-core-private. |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 588 | return inList(c.Name(), *vndkPrivateLibraries(config)) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 589 | } |
| 590 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 591 | func (c *Module) isVndk() bool { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 592 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 593 | return vndkdep.isVndk() |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 594 | } |
| 595 | return false |
| 596 | } |
| 597 | |
Jooyung Han | 76106d9 | 2019-05-20 18:49:10 +0900 | [diff] [blame] | 598 | func (c *Module) vndkVersion() string { |
| 599 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 600 | return vndkdep.Properties.Vndk.Version |
| 601 | } |
| 602 | return "" |
| 603 | } |
| 604 | |
Yi Kong | 7e53c57 | 2018-02-14 18:16:12 +0800 | [diff] [blame] | 605 | func (c *Module) isPgoCompile() bool { |
| 606 | if pgo := c.pgo; pgo != nil { |
| 607 | return pgo.Properties.PgoCompile |
| 608 | } |
| 609 | return false |
| 610 | } |
| 611 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 612 | func (c *Module) isNDKStubLibrary() bool { |
| 613 | if _, ok := c.compiler.(*stubDecorator); ok { |
| 614 | return true |
| 615 | } |
| 616 | return false |
| 617 | } |
| 618 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 619 | func (c *Module) isVndkSp() bool { |
| 620 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 621 | return vndkdep.isVndkSp() |
| 622 | } |
| 623 | return false |
| 624 | } |
| 625 | |
| 626 | func (c *Module) isVndkExt() bool { |
| 627 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 628 | return vndkdep.isVndkExt() |
| 629 | } |
| 630 | return false |
| 631 | } |
| 632 | |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 633 | func (c *Module) mustUseVendorVariant() bool { |
| 634 | return c.isVndkSp() || inList(c.Name(), config.VndkMustUseVendorVariantList) |
| 635 | } |
| 636 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 637 | func (c *Module) getVndkExtendsModuleName() string { |
| 638 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 639 | return vndkdep.getVndkExtendsModuleName() |
| 640 | } |
| 641 | return "" |
| 642 | } |
| 643 | |
Jiyong Park | 82e2bf3 | 2017-08-16 14:05:54 +0900 | [diff] [blame] | 644 | // Returns true only when this module is configured to have core and vendor |
| 645 | // variants. |
| 646 | func (c *Module) hasVendorVariant() bool { |
| 647 | return c.isVndk() || Bool(c.VendorProperties.Vendor_available) |
| 648 | } |
| 649 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 650 | func (c *Module) inRecovery() bool { |
| 651 | return c.Properties.InRecovery || c.ModuleBase.InstallInRecovery() |
| 652 | } |
| 653 | |
| 654 | func (c *Module) onlyInRecovery() bool { |
| 655 | return c.ModuleBase.InstallInRecovery() |
| 656 | } |
| 657 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 658 | func (c *Module) IsStubs() bool { |
| 659 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 660 | return library.buildStubs() |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 661 | } else if _, ok := c.linker.(*llndkStubDecorator); ok { |
| 662 | return true |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 663 | } |
| 664 | return false |
| 665 | } |
| 666 | |
| 667 | func (c *Module) HasStubsVariants() bool { |
| 668 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 669 | return len(library.Properties.Stubs.Versions) > 0 |
| 670 | } |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 671 | if library, ok := c.linker.(*prebuiltLibraryLinker); ok { |
| 672 | return len(library.Properties.Stubs.Versions) > 0 |
| 673 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 674 | return false |
| 675 | } |
| 676 | |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 677 | func (c *Module) bootstrap() bool { |
| 678 | return Bool(c.Properties.Bootstrap) |
| 679 | } |
| 680 | |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 681 | func (c *Module) nativeCoverage() bool { |
Pirama Arumuga Nainar | 5f69b9a | 2019-09-12 13:18:48 -0700 | [diff] [blame] | 682 | // Bug: http://b/137883967 - native-bridge modules do not currently work with coverage |
| 683 | if c.Target().NativeBridge == android.NativeBridgeEnabled { |
| 684 | return false |
| 685 | } |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 686 | return c.linker != nil && c.linker.nativeCoverage() |
| 687 | } |
| 688 | |
Jiyong Park | f119435 | 2019-02-25 11:05:47 +0900 | [diff] [blame] | 689 | func isBionic(name string) bool { |
| 690 | switch name { |
| 691 | case "libc", "libm", "libdl", "linker": |
| 692 | return true |
| 693 | } |
| 694 | return false |
| 695 | } |
| 696 | |
Martin Stjernholm | 279de57 | 2019-09-10 23:18:20 +0100 | [diff] [blame] | 697 | func InstallToBootstrap(name string, config android.Config) bool { |
Peter Collingbourne | 3478bb2 | 2019-04-24 14:41:12 -0700 | [diff] [blame] | 698 | if name == "libclang_rt.hwasan-aarch64-android" { |
| 699 | return inList("hwaddress", config.SanitizeDevice()) |
| 700 | } |
| 701 | return isBionic(name) |
| 702 | } |
| 703 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 704 | func (c *Module) XrefCcFiles() android.Paths { |
| 705 | return c.kytheFiles |
| 706 | } |
| 707 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 708 | type baseModuleContext struct { |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 709 | android.BaseModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 710 | moduleContextImpl |
| 711 | } |
| 712 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 713 | type depsContext struct { |
| 714 | android.BottomUpMutatorContext |
| 715 | moduleContextImpl |
| 716 | } |
| 717 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 718 | type moduleContext struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 719 | android.ModuleContext |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 720 | moduleContextImpl |
| 721 | } |
| 722 | |
Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 723 | func (ctx *moduleContext) SocSpecific() bool { |
| 724 | return ctx.ModuleContext.SocSpecific() || |
| 725 | (ctx.mod.hasVendorVariant() && ctx.mod.useVndk() && !ctx.mod.isVndk()) |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 726 | } |
| 727 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 728 | type moduleContextImpl struct { |
| 729 | mod *Module |
| 730 | ctx BaseModuleContext |
| 731 | } |
| 732 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 733 | func (ctx *moduleContextImpl) toolchain() config.Toolchain { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 734 | return ctx.mod.toolchain(ctx.ctx) |
| 735 | } |
| 736 | |
| 737 | func (ctx *moduleContextImpl) static() bool { |
Vishwath Mohan | b743e9c | 2017-11-01 09:20:21 +0000 | [diff] [blame] | 738 | return ctx.mod.static() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | func (ctx *moduleContextImpl) staticBinary() bool { |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 742 | return ctx.mod.staticBinary() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 743 | } |
| 744 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 745 | func (ctx *moduleContextImpl) header() bool { |
| 746 | return ctx.mod.header() |
| 747 | } |
| 748 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 749 | func (ctx *moduleContextImpl) useSdk() bool { |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 750 | if ctx.ctx.Device() && !ctx.useVndk() && !ctx.inRecovery() && !ctx.ctx.Fuchsia() { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 751 | return String(ctx.mod.Properties.Sdk_version) != "" |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 752 | } |
| 753 | return false |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | func (ctx *moduleContextImpl) sdkVersion() string { |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 757 | if ctx.ctx.Device() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 758 | if ctx.useVndk() { |
Justin Yun | 732aa6a | 2018-03-23 17:43:47 +0900 | [diff] [blame] | 759 | vndk_ver := ctx.ctx.DeviceConfig().VndkVersion() |
Ryan Prichard | 0520611 | 2018-03-26 21:25:27 -0700 | [diff] [blame] | 760 | if vndk_ver == "current" { |
Justin Yun | 732aa6a | 2018-03-23 17:43:47 +0900 | [diff] [blame] | 761 | platform_vndk_ver := ctx.ctx.DeviceConfig().PlatformVndkVersion() |
| 762 | if inList(platform_vndk_ver, ctx.ctx.Config().PlatformVersionCombinedCodenames()) { |
| 763 | return "current" |
| 764 | } |
| 765 | return platform_vndk_ver |
| 766 | } |
| 767 | return vndk_ver |
Dan Willemsen | d2ede87 | 2016-11-18 14:54:24 -0800 | [diff] [blame] | 768 | } |
Justin Yun | 732aa6a | 2018-03-23 17:43:47 +0900 | [diff] [blame] | 769 | return String(ctx.mod.Properties.Sdk_version) |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 770 | } |
| 771 | return "" |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 772 | } |
| 773 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 774 | func (ctx *moduleContextImpl) useVndk() bool { |
| 775 | return ctx.mod.useVndk() |
| 776 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 777 | |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 778 | func (ctx *moduleContextImpl) isNdk() bool { |
| 779 | return ctx.mod.isNdk() |
| 780 | } |
| 781 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 782 | func (ctx *moduleContextImpl) isLlndk(config android.Config) bool { |
| 783 | return ctx.mod.isLlndk(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 784 | } |
| 785 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 786 | func (ctx *moduleContextImpl) isLlndkPublic(config android.Config) bool { |
| 787 | return ctx.mod.isLlndkPublic(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 788 | } |
| 789 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 790 | func (ctx *moduleContextImpl) isVndkPrivate(config android.Config) bool { |
| 791 | return ctx.mod.isVndkPrivate(config) |
Logan Chien | f6dbd9c | 2019-01-16 20:19:51 +0800 | [diff] [blame] | 792 | } |
| 793 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 794 | func (ctx *moduleContextImpl) isVndk() bool { |
| 795 | return ctx.mod.isVndk() |
| 796 | } |
| 797 | |
Yi Kong | 7e53c57 | 2018-02-14 18:16:12 +0800 | [diff] [blame] | 798 | func (ctx *moduleContextImpl) isPgoCompile() bool { |
| 799 | return ctx.mod.isPgoCompile() |
| 800 | } |
| 801 | |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 802 | func (ctx *moduleContextImpl) isNDKStubLibrary() bool { |
| 803 | return ctx.mod.isNDKStubLibrary() |
| 804 | } |
| 805 | |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 806 | func (ctx *moduleContextImpl) isVndkSp() bool { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 807 | return ctx.mod.isVndkSp() |
| 808 | } |
| 809 | |
| 810 | func (ctx *moduleContextImpl) isVndkExt() bool { |
| 811 | return ctx.mod.isVndkExt() |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 812 | } |
| 813 | |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 814 | func (ctx *moduleContextImpl) mustUseVendorVariant() bool { |
| 815 | return ctx.mod.mustUseVendorVariant() |
| 816 | } |
| 817 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 818 | func (ctx *moduleContextImpl) inRecovery() bool { |
| 819 | return ctx.mod.inRecovery() |
| 820 | } |
| 821 | |
Logan Chien | 2f2b890 | 2018-07-10 15:01:19 +0800 | [diff] [blame] | 822 | // Check whether ABI dumps should be created for this module. |
Hsin-Yi Chen | af17d74 | 2019-07-29 17:46:59 +0800 | [diff] [blame] | 823 | func (ctx *moduleContextImpl) shouldCreateSourceAbiDump() bool { |
Logan Chien | 2f2b890 | 2018-07-10 15:01:19 +0800 | [diff] [blame] | 824 | if ctx.ctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") { |
| 825 | return false |
Jayant Chowdhary | ea0a2e1 | 2018-03-01 19:12:16 -0800 | [diff] [blame] | 826 | } |
Doug Horn | c32c6b0 | 2019-01-17 14:44:05 -0800 | [diff] [blame] | 827 | |
| 828 | if ctx.ctx.Fuchsia() { |
| 829 | return false |
| 830 | } |
| 831 | |
Logan Chien | 2f2b890 | 2018-07-10 15:01:19 +0800 | [diff] [blame] | 832 | if sanitize := ctx.mod.sanitize; sanitize != nil { |
| 833 | if !sanitize.isVariantOnProductionDevice() { |
| 834 | return false |
| 835 | } |
| 836 | } |
| 837 | if !ctx.ctx.Device() { |
| 838 | // Host modules do not need ABI dumps. |
| 839 | return false |
| 840 | } |
Logan Chien | fa478c0 | 2018-12-28 16:25:39 +0800 | [diff] [blame] | 841 | if !ctx.mod.IsForPlatform() { |
| 842 | // APEX variants do not need ABI dumps. |
| 843 | return false |
| 844 | } |
Hsin-Yi Chen | f6a9546 | 2019-06-25 14:46:52 +0800 | [diff] [blame] | 845 | if ctx.isStubs() { |
| 846 | // Stubs do not need ABI dumps. |
| 847 | return false |
| 848 | } |
Hsin-Yi Chen | af17d74 | 2019-07-29 17:46:59 +0800 | [diff] [blame] | 849 | return true |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 850 | } |
| 851 | |
Dan Willemsen | 8146b2f | 2016-03-30 21:00:30 -0700 | [diff] [blame] | 852 | func (ctx *moduleContextImpl) selectedStl() string { |
| 853 | if stl := ctx.mod.stl; stl != nil { |
| 854 | return stl.Properties.SelectedStl |
| 855 | } |
| 856 | return "" |
| 857 | } |
| 858 | |
Ivan Lozano | bd72126 | 2018-11-27 14:33:03 -0800 | [diff] [blame] | 859 | func (ctx *moduleContextImpl) useClangLld(actx ModuleContext) bool { |
| 860 | return ctx.mod.linker.useClangLld(actx) |
| 861 | } |
| 862 | |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 863 | func (ctx *moduleContextImpl) baseModuleName() string { |
| 864 | return ctx.mod.ModuleBase.BaseModuleName() |
| 865 | } |
| 866 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 867 | func (ctx *moduleContextImpl) getVndkExtendsModuleName() string { |
| 868 | return ctx.mod.getVndkExtendsModuleName() |
| 869 | } |
| 870 | |
Jiyong Park | 58e364a | 2019-01-19 19:24:06 +0900 | [diff] [blame] | 871 | func (ctx *moduleContextImpl) apexName() string { |
| 872 | return ctx.mod.ApexName() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 873 | } |
| 874 | |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 875 | func (ctx *moduleContextImpl) hasStubsVariants() bool { |
| 876 | return ctx.mod.HasStubsVariants() |
| 877 | } |
| 878 | |
| 879 | func (ctx *moduleContextImpl) isStubs() bool { |
| 880 | return ctx.mod.IsStubs() |
| 881 | } |
| 882 | |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 883 | func (ctx *moduleContextImpl) bootstrap() bool { |
| 884 | return ctx.mod.bootstrap() |
| 885 | } |
| 886 | |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 887 | func (ctx *moduleContextImpl) nativeCoverage() bool { |
| 888 | return ctx.mod.nativeCoverage() |
| 889 | } |
| 890 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 891 | func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 892 | return &Module{ |
| 893 | hod: hod, |
| 894 | multilib: multilib, |
| 895 | } |
| 896 | } |
| 897 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 898 | func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 899 | module := newBaseModule(hod, multilib) |
Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 900 | module.features = []feature{ |
| 901 | &tidyFeature{}, |
| 902 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 903 | module.stl = &stl{} |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 904 | module.sanitize = &sanitize{} |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 905 | module.coverage = &coverage{} |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 906 | module.sabi = &sabi{} |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 907 | module.vndkdep = &vndkdep{} |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 908 | module.lto = <o{} |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 909 | module.pgo = &pgo{} |
Ivan Lozano | 074ec48 | 2018-11-21 08:59:37 -0800 | [diff] [blame] | 910 | module.xom = &xom{} |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 911 | return module |
| 912 | } |
| 913 | |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 914 | func (c *Module) Prebuilt() *android.Prebuilt { |
| 915 | if p, ok := c.linker.(prebuiltLinkerInterface); ok { |
| 916 | return p.prebuilt() |
| 917 | } |
| 918 | return nil |
| 919 | } |
| 920 | |
| 921 | func (c *Module) Name() string { |
| 922 | name := c.ModuleBase.Name() |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 923 | if p, ok := c.linker.(interface { |
| 924 | Name(string) string |
| 925 | }); ok { |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 926 | name = p.Name(name) |
| 927 | } |
| 928 | return name |
| 929 | } |
| 930 | |
Alex Light | 3d67359 | 2019-01-18 14:37:31 -0800 | [diff] [blame] | 931 | func (c *Module) Symlinks() []string { |
| 932 | if p, ok := c.installer.(interface { |
| 933 | symlinkList() []string |
| 934 | }); ok { |
| 935 | return p.symlinkList() |
| 936 | } |
| 937 | return nil |
| 938 | } |
| 939 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 940 | // orderDeps reorders dependencies into a list such that if module A depends on B, then |
| 941 | // A will precede B in the resultant list. |
| 942 | // This is convenient for passing into a linker. |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 943 | // Note that directSharedDeps should be the analogous static library for each shared lib dep |
| 944 | 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] | 945 | // If A depends on B, then |
| 946 | // Every list containing A will also contain B later in the list |
| 947 | // So, after concatenating all lists, the final instance of B will have come from the same |
| 948 | // original list as the final instance of A |
| 949 | // So, the final instance of B will be later in the concatenation than the final A |
| 950 | // So, keeping only the final instance of A and of B ensures that A is earlier in the output |
| 951 | // list than B |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 952 | for _, dep := range directStaticDeps { |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 953 | orderedAllDeps = append(orderedAllDeps, dep) |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 954 | orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...) |
| 955 | } |
| 956 | for _, dep := range directSharedDeps { |
| 957 | orderedAllDeps = append(orderedAllDeps, dep) |
| 958 | orderedAllDeps = append(orderedAllDeps, allTransitiveDeps[dep]...) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 959 | } |
| 960 | |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 961 | orderedAllDeps = android.LastUniquePaths(orderedAllDeps) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 962 | |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 963 | // 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] | 964 | // intentionally exclude or replace any unwanted transitive dependencies), so we limit the |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 965 | // resultant list to only what the caller has chosen to include in directStaticDeps |
| 966 | _, orderedDeclaredDeps = android.FilterPathList(orderedAllDeps, directStaticDeps) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 967 | |
| 968 | return orderedAllDeps, orderedDeclaredDeps |
| 969 | } |
| 970 | |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 971 | func orderStaticModuleDeps(module *Module, staticDeps []*Module, sharedDeps []*Module) (results []android.Path) { |
| 972 | // convert Module to Path |
| 973 | allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps)) |
| 974 | staticDepFiles := []android.Path{} |
| 975 | for _, dep := range staticDeps { |
| 976 | allTransitiveDeps[dep.outputFile.Path()] = dep.depsInLinkOrder |
| 977 | staticDepFiles = append(staticDepFiles, dep.outputFile.Path()) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 978 | } |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 979 | sharedDepFiles := []android.Path{} |
| 980 | for _, sharedDep := range sharedDeps { |
| 981 | staticAnalogue := sharedDep.staticVariant |
| 982 | if staticAnalogue != nil { |
| 983 | allTransitiveDeps[staticAnalogue.outputFile.Path()] = staticAnalogue.depsInLinkOrder |
| 984 | sharedDepFiles = append(sharedDepFiles, staticAnalogue.outputFile.Path()) |
| 985 | } |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | // reorder the dependencies based on transitive dependencies |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 989 | module.depsInLinkOrder, results = orderDeps(staticDepFiles, sharedDepFiles, allTransitiveDeps) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 990 | |
| 991 | return results |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 992 | } |
| 993 | |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 994 | func (c *Module) IsTestPerSrcAllTestsVariation() bool { |
| 995 | test, ok := c.linker.(testPerSrc) |
| 996 | return ok && test.isAllTestsVariation() |
| 997 | } |
| 998 | |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 999 | func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { |
Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1000 | // 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] | 1001 | // |
| 1002 | // The `test_per_src` mutator adds an extra variation named "", depending on all the other |
| 1003 | // `test_per_src` variations of the test module. Set `outputFile` to an empty path for this |
| 1004 | // module and return early, as this module does not produce an output file per se. |
| 1005 | if c.IsTestPerSrcAllTestsVariation() { |
| 1006 | c.outputFile = android.OptionalPath{} |
| 1007 | return |
Roland Levillain | f2fad97 | 2019-06-28 15:41:19 +0100 | [diff] [blame] | 1008 | } |
| 1009 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 1010 | c.makeLinkType = c.getMakeLinkType(actx) |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1011 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1012 | ctx := &moduleContext{ |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1013 | ModuleContext: actx, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1014 | moduleContextImpl: moduleContextImpl{ |
| 1015 | mod: c, |
| 1016 | }, |
| 1017 | } |
| 1018 | ctx.ctx = ctx |
| 1019 | |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 1020 | deps := c.depsToPaths(ctx) |
| 1021 | if ctx.Failed() { |
| 1022 | return |
| 1023 | } |
| 1024 | |
Dan Willemsen | 8536d6b | 2018-10-07 20:54:34 -0700 | [diff] [blame] | 1025 | if c.Properties.Clang != nil && *c.Properties.Clang == false { |
| 1026 | ctx.PropertyErrorf("clang", "false (GCC) is no longer supported") |
| 1027 | } |
| 1028 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1029 | flags := Flags{ |
| 1030 | Toolchain: c.toolchain(ctx), |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1031 | EmitXrefs: ctx.Config().EmitXrefRules(), |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1032 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1033 | if c.compiler != nil { |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 1034 | flags = c.compiler.compilerFlags(ctx, flags, deps) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1035 | } |
| 1036 | if c.linker != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1037 | flags = c.linker.linkerFlags(ctx, flags) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1038 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1039 | if c.stl != nil { |
| 1040 | flags = c.stl.flags(ctx, flags) |
| 1041 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1042 | if c.sanitize != nil { |
| 1043 | flags = c.sanitize.flags(ctx, flags) |
| 1044 | } |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1045 | if c.coverage != nil { |
Pirama Arumuga Nainar | 82fe59b | 2019-07-02 14:55:35 -0700 | [diff] [blame] | 1046 | flags, deps = c.coverage.flags(ctx, flags, deps) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1047 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1048 | if c.lto != nil { |
| 1049 | flags = c.lto.flags(ctx, flags) |
| 1050 | } |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 1051 | if c.pgo != nil { |
| 1052 | flags = c.pgo.flags(ctx, flags) |
| 1053 | } |
Ivan Lozano | 074ec48 | 2018-11-21 08:59:37 -0800 | [diff] [blame] | 1054 | if c.xom != nil { |
| 1055 | flags = c.xom.flags(ctx, flags) |
| 1056 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1057 | for _, feature := range c.features { |
| 1058 | flags = feature.flags(ctx, flags) |
| 1059 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1060 | if ctx.Failed() { |
| 1061 | return |
| 1062 | } |
| 1063 | |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 1064 | flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags) |
| 1065 | flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags) |
| 1066 | flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1067 | |
Fabien Sanglard | d61f1f4 | 2017-01-10 16:21:22 -0800 | [diff] [blame] | 1068 | flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1069 | |
| 1070 | for _, dir := range deps.IncludeDirs { |
| 1071 | flags.GlobalFlags = append(flags.GlobalFlags, "-I"+dir) |
| 1072 | } |
| 1073 | for _, dir := range deps.SystemIncludeDirs { |
| 1074 | flags.GlobalFlags = append(flags.GlobalFlags, "-isystem "+dir) |
| 1075 | } |
| 1076 | |
Fabien Sanglard | d61f1f4 | 2017-01-10 16:21:22 -0800 | [diff] [blame] | 1077 | c.flags = flags |
Jayant Chowdhary | 9677e8c | 2017-06-15 14:45:18 -0700 | [diff] [blame] | 1078 | // We need access to all the flags seen by a source file. |
| 1079 | if c.sabi != nil { |
| 1080 | flags = c.sabi.flags(ctx, flags) |
| 1081 | } |
Dan Willemsen | 98ab311 | 2019-08-27 21:20:40 -0700 | [diff] [blame] | 1082 | |
| 1083 | flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.AsFlags) |
| 1084 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1085 | // Optimization to reduce size of build.ninja |
| 1086 | // Replace the long list of flags for each file with a module-local variable |
| 1087 | ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " ")) |
| 1088 | ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " ")) |
| 1089 | ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " ")) |
| 1090 | flags.CFlags = []string{"$cflags"} |
| 1091 | flags.CppFlags = []string{"$cppflags"} |
| 1092 | flags.AsFlags = []string{"$asflags"} |
| 1093 | |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1094 | var objs Objects |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1095 | if c.compiler != nil { |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1096 | objs = c.compiler.compile(ctx, flags, deps) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1097 | if ctx.Failed() { |
| 1098 | return |
| 1099 | } |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 1100 | c.kytheFiles = objs.kytheFiles |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1101 | } |
| 1102 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1103 | if c.linker != nil { |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1104 | outputFile := c.linker.link(ctx, flags, deps, objs) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1105 | if ctx.Failed() { |
| 1106 | return |
| 1107 | } |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1108 | c.outputFile = android.OptionalPathForPath(outputFile) |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1109 | |
| 1110 | // If a lib is directly included in any of the APEXes, unhide the stubs |
| 1111 | // variant having the latest version gets visible to make. In addition, |
| 1112 | // the non-stubs variant is renamed to <libname>.bootstrap. This is to |
| 1113 | // force anything in the make world to link against the stubs library. |
| 1114 | // (unless it is explicitly referenced via .bootstrap suffix or the |
| 1115 | // module is marked with 'bootstrap: true'). |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 1116 | if c.HasStubsVariants() && |
| 1117 | android.DirectlyInAnyApex(ctx, ctx.baseModuleName()) && |
Pirama Arumuga Nainar | 1acd447 | 2018-12-10 15:12:40 -0800 | [diff] [blame] | 1118 | !c.inRecovery() && !c.useVndk() && !c.static() && !c.isCoverageVariant() && |
| 1119 | c.IsStubs() { |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1120 | c.Properties.HideFromMake = false // unhide |
| 1121 | // Note: this is still non-installable |
| 1122 | } |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1123 | } |
Colin Cross | 5049f02 | 2015-03-18 13:28:46 -0700 | [diff] [blame] | 1124 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 1125 | if c.installable() { |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1126 | c.installer.install(ctx, c.outputFile.Path()) |
| 1127 | if ctx.Failed() { |
| 1128 | return |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1129 | } |
Dan Albert | c403f7c | 2015-03-18 14:01:18 -0700 | [diff] [blame] | 1130 | } |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1131 | } |
| 1132 | |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1133 | func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1134 | if c.cachedToolchain == nil { |
Colin Cross | b98c8b0 | 2016-07-29 13:44:28 -0700 | [diff] [blame] | 1135 | c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch()) |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1136 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1137 | return c.cachedToolchain |
Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame] | 1138 | } |
| 1139 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1140 | func (c *Module) begin(ctx BaseModuleContext) { |
| 1141 | if c.compiler != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1142 | c.compiler.compilerInit(ctx) |
Colin Cross | 21b9a24 | 2015-03-24 14:15:58 -0700 | [diff] [blame] | 1143 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1144 | if c.linker != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1145 | c.linker.linkerInit(ctx) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1146 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1147 | if c.stl != nil { |
| 1148 | c.stl.begin(ctx) |
| 1149 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1150 | if c.sanitize != nil { |
| 1151 | c.sanitize.begin(ctx) |
| 1152 | } |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1153 | if c.coverage != nil { |
| 1154 | c.coverage.begin(ctx) |
| 1155 | } |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1156 | if c.sabi != nil { |
| 1157 | c.sabi.begin(ctx) |
| 1158 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1159 | if c.vndkdep != nil { |
| 1160 | c.vndkdep.begin(ctx) |
| 1161 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1162 | if c.lto != nil { |
| 1163 | c.lto.begin(ctx) |
| 1164 | } |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 1165 | if c.pgo != nil { |
| 1166 | c.pgo.begin(ctx) |
| 1167 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1168 | for _, feature := range c.features { |
| 1169 | feature.begin(ctx) |
| 1170 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1171 | if ctx.useSdk() { |
Dan Albert | f5415d7 | 2017-08-17 16:19:59 -0700 | [diff] [blame] | 1172 | version, err := normalizeNdkApiLevel(ctx, ctx.sdkVersion(), ctx.Arch()) |
Dan Albert | 7fa7b2e | 2016-08-05 16:37:52 -0700 | [diff] [blame] | 1173 | if err != nil { |
| 1174 | ctx.PropertyErrorf("sdk_version", err.Error()) |
| 1175 | } |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 1176 | c.Properties.Sdk_version = StringPtr(version) |
Dan Albert | 7fa7b2e | 2016-08-05 16:37:52 -0700 | [diff] [blame] | 1177 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1178 | } |
| 1179 | |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 1180 | func (c *Module) deps(ctx DepsContext) Deps { |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1181 | deps := Deps{} |
| 1182 | |
| 1183 | if c.compiler != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1184 | deps = c.compiler.compilerDeps(ctx, deps) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1185 | } |
Pirama Arumuga Nainar | 0b882f0 | 2018-04-23 22:44:39 +0000 | [diff] [blame] | 1186 | // Add the PGO dependency (the clang_rt.profile runtime library), which |
| 1187 | // sometimes depends on symbols from libgcc, before libgcc gets added |
| 1188 | // in linkerDeps(). |
Pirama Arumuga Nainar | 49b53d5 | 2017-10-04 16:47:29 -0700 | [diff] [blame] | 1189 | if c.pgo != nil { |
| 1190 | deps = c.pgo.deps(ctx, deps) |
| 1191 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1192 | if c.linker != nil { |
Colin Cross | 42742b8 | 2016-08-01 13:20:05 -0700 | [diff] [blame] | 1193 | deps = c.linker.linkerDeps(ctx, deps) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1194 | } |
Colin Cross | a8e07cc | 2016-04-04 15:07:06 -0700 | [diff] [blame] | 1195 | if c.stl != nil { |
| 1196 | deps = c.stl.deps(ctx, deps) |
| 1197 | } |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 1198 | if c.sanitize != nil { |
| 1199 | deps = c.sanitize.deps(ctx, deps) |
| 1200 | } |
Pirama Arumuga Nainar | 0b882f0 | 2018-04-23 22:44:39 +0000 | [diff] [blame] | 1201 | if c.coverage != nil { |
| 1202 | deps = c.coverage.deps(ctx, deps) |
| 1203 | } |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1204 | if c.sabi != nil { |
| 1205 | deps = c.sabi.deps(ctx, deps) |
| 1206 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 1207 | if c.vndkdep != nil { |
| 1208 | deps = c.vndkdep.deps(ctx, deps) |
| 1209 | } |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 1210 | if c.lto != nil { |
| 1211 | deps = c.lto.deps(ctx, deps) |
| 1212 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1213 | for _, feature := range c.features { |
| 1214 | deps = feature.deps(ctx, deps) |
| 1215 | } |
| 1216 | |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 1217 | deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs) |
| 1218 | deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs) |
| 1219 | deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs) |
| 1220 | deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs) |
| 1221 | deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs) |
| 1222 | deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1223 | deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1224 | |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1225 | for _, lib := range deps.ReexportSharedLibHeaders { |
| 1226 | if !inList(lib, deps.SharedLibs) { |
| 1227 | ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib) |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | for _, lib := range deps.ReexportStaticLibHeaders { |
| 1232 | if !inList(lib, deps.StaticLibs) { |
| 1233 | ctx.PropertyErrorf("export_static_lib_headers", "Static library not in static_libs: '%s'", lib) |
| 1234 | } |
| 1235 | } |
| 1236 | |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 1237 | for _, lib := range deps.ReexportHeaderLibHeaders { |
| 1238 | if !inList(lib, deps.HeaderLibs) { |
| 1239 | ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib) |
| 1240 | } |
| 1241 | } |
| 1242 | |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 1243 | for _, gen := range deps.ReexportGeneratedHeaders { |
| 1244 | if !inList(gen, deps.GeneratedHeaders) { |
| 1245 | ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen) |
| 1246 | } |
| 1247 | } |
| 1248 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1249 | return deps |
| 1250 | } |
| 1251 | |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1252 | func (c *Module) beginMutator(actx android.BottomUpMutatorContext) { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1253 | ctx := &baseModuleContext{ |
Colin Cross | 0ea8ba8 | 2019-06-06 14:33:29 -0700 | [diff] [blame] | 1254 | BaseModuleContext: actx, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1255 | moduleContextImpl: moduleContextImpl{ |
| 1256 | mod: c, |
| 1257 | }, |
| 1258 | } |
| 1259 | ctx.ctx = ctx |
| 1260 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1261 | c.begin(ctx) |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1262 | } |
| 1263 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1264 | // Split name#version into name and version |
| 1265 | func stubsLibNameAndVersion(name string) (string, string) { |
| 1266 | if sharp := strings.LastIndex(name, "#"); sharp != -1 && sharp != len(name)-1 { |
| 1267 | version := name[sharp+1:] |
| 1268 | libname := name[:sharp] |
| 1269 | return libname, version |
| 1270 | } |
| 1271 | return name, "" |
| 1272 | } |
| 1273 | |
Colin Cross | 1e676be | 2016-10-12 14:38:15 -0700 | [diff] [blame] | 1274 | func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 1275 | ctx := &depsContext{ |
| 1276 | BottomUpMutatorContext: actx, |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1277 | moduleContextImpl: moduleContextImpl{ |
| 1278 | mod: c, |
| 1279 | }, |
| 1280 | } |
| 1281 | ctx.ctx = ctx |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1282 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1283 | deps := c.deps(ctx) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1284 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1285 | variantNdkLibs := []string{} |
| 1286 | variantLateNdkLibs := []string{} |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 1287 | if ctx.Os() == android.Android { |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1288 | version := ctx.sdkVersion() |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1289 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1290 | // rewriteNdkLibs takes a list of names of shared libraries and scans it for three types |
| 1291 | // of names: |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1292 | // |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1293 | // 1. Name of an NDK library that refers to a prebuilt module. |
| 1294 | // For each of these, it adds the name of the prebuilt module (which will be in |
| 1295 | // prebuilts/ndk) to the list of nonvariant libs. |
| 1296 | // 2. Name of an NDK library that refers to an ndk_library module. |
| 1297 | // For each of these, it adds the name of the ndk_library module to the list of |
| 1298 | // variant libs. |
| 1299 | // 3. Anything else (so anything that isn't an NDK library). |
| 1300 | // It adds these to the nonvariantLibs list. |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1301 | // |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1302 | // The caller can then know to add the variantLibs dependencies differently from the |
| 1303 | // nonvariantLibs |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1304 | |
| 1305 | llndkLibraries := llndkLibraries(actx.Config()) |
| 1306 | vendorPublicLibraries := vendorPublicLibraries(actx.Config()) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1307 | rewriteNdkLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) { |
| 1308 | variantLibs = []string{} |
| 1309 | nonvariantLibs = []string{} |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1310 | for _, entry := range list { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1311 | // strip #version suffix out |
| 1312 | name, _ := stubsLibNameAndVersion(entry) |
| 1313 | if ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) { |
| 1314 | if !inList(name, ndkMigratedLibs) { |
| 1315 | nonvariantLibs = append(nonvariantLibs, name+".ndk."+version) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1316 | } else { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1317 | variantLibs = append(variantLibs, name+ndkLibrarySuffix) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1318 | } |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1319 | } else if ctx.useVndk() && inList(name, *llndkLibraries) { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1320 | nonvariantLibs = append(nonvariantLibs, name+llndkLibrarySuffix) |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1321 | } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1322 | vendorPublicLib := name + vendorPublicLibrarySuffix |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 1323 | if actx.OtherModuleExists(vendorPublicLib) { |
| 1324 | nonvariantLibs = append(nonvariantLibs, vendorPublicLib) |
| 1325 | } else { |
| 1326 | // This can happen if vendor_public_library module is defined in a |
| 1327 | // namespace that isn't visible to the current module. In that case, |
| 1328 | // link to the original library. |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1329 | nonvariantLibs = append(nonvariantLibs, name) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 1330 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1331 | } else { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1332 | // put name#version back |
Dan Willemsen | 7cbf5f8 | 2017-03-28 00:08:30 -0700 | [diff] [blame] | 1333 | nonvariantLibs = append(nonvariantLibs, entry) |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1334 | } |
| 1335 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1336 | return nonvariantLibs, variantLibs |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1337 | } |
| 1338 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1339 | deps.SharedLibs, variantNdkLibs = rewriteNdkLibs(deps.SharedLibs) |
| 1340 | deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs) |
Jiyong Park | 4c35af0 | 2017-07-05 13:41:55 +0900 | [diff] [blame] | 1341 | deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders) |
Dan Willemsen | 72d3993 | 2016-07-08 23:23:48 -0700 | [diff] [blame] | 1342 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1343 | |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1344 | buildStubs := false |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1345 | if c.linker != nil { |
| 1346 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 1347 | if library.buildStubs() { |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1348 | buildStubs = true |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1349 | } |
| 1350 | } |
| 1351 | } |
| 1352 | |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 1353 | for _, lib := range deps.HeaderLibs { |
| 1354 | depTag := headerDepTag |
| 1355 | if inList(lib, deps.ReexportHeaderLibHeaders) { |
| 1356 | depTag = headerExportDepTag |
| 1357 | } |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1358 | if buildStubs { |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1359 | actx.AddFarVariationDependencies([]blueprint.Variation{ |
| 1360 | {Mutator: "arch", Variation: ctx.Target().String()}, |
Jiyong Park | 3b1746a | 2019-01-29 11:15:04 +0900 | [diff] [blame] | 1361 | {Mutator: "image", Variation: c.imageVariation()}, |
Jiyong Park | 7e636d0 | 2019-01-28 16:16:54 +0900 | [diff] [blame] | 1362 | }, depTag, lib) |
| 1363 | } else { |
| 1364 | actx.AddVariationDependencies(nil, depTag, lib) |
| 1365 | } |
| 1366 | } |
| 1367 | |
| 1368 | if buildStubs { |
| 1369 | // Stubs lib does not have dependency to other static/shared libraries. |
| 1370 | // Don't proceed. |
| 1371 | return |
Colin Cross | 32ec36c | 2016-12-15 07:39:51 -0800 | [diff] [blame] | 1372 | } |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 1373 | |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1374 | syspropImplLibraries := syspropImplLibraries(actx.Config()) |
| 1375 | |
Jiyong Park | 5d1598f | 2019-02-25 22:14:17 +0900 | [diff] [blame] | 1376 | for _, lib := range deps.WholeStaticLibs { |
| 1377 | depTag := wholeStaticDepTag |
| 1378 | if impl, ok := syspropImplLibraries[lib]; ok { |
| 1379 | lib = impl |
| 1380 | } |
| 1381 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1382 | {Mutator: "link", Variation: "static"}, |
| 1383 | }, depTag, lib) |
| 1384 | } |
| 1385 | |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1386 | for _, lib := range deps.StaticLibs { |
| 1387 | depTag := staticDepTag |
| 1388 | if inList(lib, deps.ReexportStaticLibHeaders) { |
| 1389 | depTag = staticExportDepTag |
| 1390 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1391 | |
| 1392 | if impl, ok := syspropImplLibraries[lib]; ok { |
| 1393 | lib = impl |
| 1394 | } |
| 1395 | |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1396 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1397 | {Mutator: "link", Variation: "static"}, |
| 1398 | }, depTag, lib) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1399 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1400 | |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1401 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1402 | {Mutator: "link", Variation: "static"}, |
| 1403 | }, lateStaticDepTag, deps.LateStaticLibs...) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1404 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1405 | addSharedLibDependencies := func(depTag dependencyTag, name string, version string) { |
| 1406 | var variations []blueprint.Variation |
| 1407 | variations = append(variations, blueprint.Variation{Mutator: "link", Variation: "shared"}) |
Jiyong Park | 0fefdea | 2018-12-13 12:01:31 +0900 | [diff] [blame] | 1408 | versionVariantAvail := !ctx.useVndk() && !c.inRecovery() |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1409 | if version != "" && versionVariantAvail { |
| 1410 | // Version is explicitly specified. i.e. libFoo#30 |
| 1411 | variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version}) |
| 1412 | depTag.explicitlyVersioned = true |
| 1413 | } |
| 1414 | actx.AddVariationDependencies(variations, depTag, name) |
| 1415 | |
| 1416 | // If the version is not specified, add dependency to the latest stubs library. |
| 1417 | // The stubs library will be used when the depending module is built for APEX and |
| 1418 | // the dependent module is not in the same APEX. |
| 1419 | latestVersion := latestStubsVersionFor(actx.Config(), name) |
| 1420 | if version == "" && latestVersion != "" && versionVariantAvail { |
| 1421 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1422 | {Mutator: "link", Variation: "shared"}, |
| 1423 | {Mutator: "version", Variation: latestVersion}, |
| 1424 | }, depTag, name) |
| 1425 | // Note that depTag.explicitlyVersioned is false in this case. |
| 1426 | } |
| 1427 | } |
| 1428 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1429 | // shared lib names without the #version suffix |
| 1430 | var sharedLibNames []string |
| 1431 | |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1432 | for _, lib := range deps.SharedLibs { |
| 1433 | depTag := sharedDepTag |
| 1434 | if inList(lib, deps.ReexportSharedLibHeaders) { |
| 1435 | depTag = sharedExportDepTag |
| 1436 | } |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 1437 | |
| 1438 | if impl, ok := syspropImplLibraries[lib]; ok { |
| 1439 | lib = impl |
| 1440 | } |
| 1441 | |
| 1442 | name, version := stubsLibNameAndVersion(lib) |
| 1443 | sharedLibNames = append(sharedLibNames, name) |
| 1444 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1445 | addSharedLibDependencies(depTag, name, version) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1446 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1447 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1448 | for _, lib := range deps.LateSharedLibs { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1449 | if inList(lib, sharedLibNames) { |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1450 | // This is to handle the case that some of the late shared libs (libc, libdl, libm, ...) |
| 1451 | // are added also to SharedLibs with version (e.g., libc#10). If not skipped, we will be |
| 1452 | // linking against both the stubs lib and the non-stubs lib at the same time. |
| 1453 | continue |
| 1454 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1455 | addSharedLibDependencies(lateSharedDepTag, lib, "") |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 1456 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1457 | |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1458 | actx.AddVariationDependencies([]blueprint.Variation{ |
| 1459 | {Mutator: "link", Variation: "shared"}, |
| 1460 | }, runtimeDepTag, deps.RuntimeLibs...) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1461 | |
Colin Cross | 6886183 | 2016-07-08 10:41:41 -0700 | [diff] [blame] | 1462 | actx.AddDependency(c, genSourceDepTag, deps.GeneratedSources...) |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 1463 | |
| 1464 | for _, gen := range deps.GeneratedHeaders { |
| 1465 | depTag := genHeaderDepTag |
| 1466 | if inList(gen, deps.ReexportGeneratedHeaders) { |
| 1467 | depTag = genHeaderExportDepTag |
| 1468 | } |
| 1469 | actx.AddDependency(c, depTag, gen) |
| 1470 | } |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1471 | |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 1472 | actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1473 | |
| 1474 | if deps.CrtBegin != "" { |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 1475 | actx.AddVariationDependencies(nil, crtBeginDepTag, deps.CrtBegin) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1476 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1477 | if deps.CrtEnd != "" { |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 1478 | actx.AddVariationDependencies(nil, crtEndDepTag, deps.CrtEnd) |
Colin Cross | 21b9a24 | 2015-03-24 14:15:58 -0700 | [diff] [blame] | 1479 | } |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 1480 | if deps.LinkerFlagsFile != "" { |
| 1481 | actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile) |
| 1482 | } |
| 1483 | if deps.DynamicLinker != "" { |
| 1484 | actx.AddDependency(c, dynamicLinkerDepTag, deps.DynamicLinker) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 1485 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1486 | |
| 1487 | version := ctx.sdkVersion() |
| 1488 | actx.AddVariationDependencies([]blueprint.Variation{ |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1489 | {Mutator: "ndk_api", Variation: version}, |
| 1490 | {Mutator: "link", Variation: "shared"}, |
| 1491 | }, ndkStubDepTag, variantNdkLibs...) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1492 | actx.AddVariationDependencies([]blueprint.Variation{ |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1493 | {Mutator: "ndk_api", Variation: version}, |
| 1494 | {Mutator: "link", Variation: "shared"}, |
| 1495 | }, ndkLateStubDepTag, variantLateNdkLibs...) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1496 | |
| 1497 | if vndkdep := c.vndkdep; vndkdep != nil { |
| 1498 | if vndkdep.isVndkExt() { |
| 1499 | baseModuleMode := vendorMode |
| 1500 | if actx.DeviceConfig().VndkVersion() == "" { |
| 1501 | baseModuleMode = coreMode |
| 1502 | } |
| 1503 | actx.AddVariationDependencies([]blueprint.Variation{ |
Dan Willemsen | 59339a2 | 2018-07-22 21:18:45 -0700 | [diff] [blame] | 1504 | {Mutator: "image", Variation: baseModuleMode}, |
| 1505 | {Mutator: "link", Variation: "shared"}, |
| 1506 | }, vndkExtDepTag, vndkdep.getVndkExtendsModuleName()) |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1507 | } |
| 1508 | } |
Colin Cross | 6362e27 | 2015-10-29 15:25:03 -0700 | [diff] [blame] | 1509 | } |
Colin Cross | 21b9a24 | 2015-03-24 14:15:58 -0700 | [diff] [blame] | 1510 | |
Colin Cross | e40b4ea | 2018-10-02 22:25:58 -0700 | [diff] [blame] | 1511 | func BeginMutator(ctx android.BottomUpMutatorContext) { |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 1512 | if c, ok := ctx.Module().(*Module); ok && c.Enabled() { |
| 1513 | c.beginMutator(ctx) |
| 1514 | } |
| 1515 | } |
| 1516 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1517 | // Whether a module can link to another module, taking into |
| 1518 | // account NDK linking. |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1519 | func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag dependencyTag) { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1520 | if from.Target().Os != android.Android { |
| 1521 | // Host code is not restricted |
| 1522 | return |
| 1523 | } |
| 1524 | if from.Properties.UseVndk { |
| 1525 | // Though vendor code is limited by the vendor mutator, |
| 1526 | // each vendor-available module needs to check |
| 1527 | // link-type for VNDK. |
| 1528 | if from.vndkdep != nil { |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1529 | from.vndkdep.vndkCheckLinkType(ctx, to, tag) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1530 | } |
| 1531 | return |
| 1532 | } |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 1533 | if String(from.Properties.Sdk_version) == "" { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1534 | // Platform code can link to anything |
| 1535 | return |
| 1536 | } |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 1537 | if from.inRecovery() { |
| 1538 | // Recovery code is not NDK |
| 1539 | return |
| 1540 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1541 | if _, ok := to.linker.(*toolchainLibraryDecorator); ok { |
| 1542 | // These are always allowed |
| 1543 | return |
| 1544 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1545 | if _, ok := to.linker.(*ndkPrebuiltStlLinker); ok { |
| 1546 | // These are allowed, but they don't set sdk_version |
| 1547 | return |
| 1548 | } |
| 1549 | if _, ok := to.linker.(*stubDecorator); ok { |
| 1550 | // These aren't real libraries, but are the stub shared libraries that are included in |
| 1551 | // the NDK. |
| 1552 | return |
| 1553 | } |
Logan Chien | 834b9a6 | 2019-01-14 15:39:03 +0800 | [diff] [blame] | 1554 | |
| 1555 | if strings.HasPrefix(ctx.ModuleName(), "libclang_rt.") && to.Name() == "libc++" { |
| 1556 | // Bug: http://b/121358700 - Allow libclang_rt.* shared libraries (with sdk_version) |
| 1557 | // to link to libc++ (non-NDK and without sdk_version). |
| 1558 | return |
| 1559 | } |
| 1560 | |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 1561 | if String(to.Properties.Sdk_version) == "" { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1562 | // NDK code linking to platform code is never okay. |
| 1563 | ctx.ModuleErrorf("depends on non-NDK-built library %q", |
| 1564 | ctx.OtherModuleName(to)) |
Dan Willemsen | 155d17c | 2019-02-06 18:30:02 -0800 | [diff] [blame] | 1565 | return |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | // At this point we know we have two NDK libraries, but we need to |
| 1569 | // check that we're not linking against anything built against a higher |
| 1570 | // API level, as it is only valid to link against older or equivalent |
| 1571 | // APIs. |
| 1572 | |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 1573 | // Current can link against anything. |
| 1574 | if String(from.Properties.Sdk_version) != "current" { |
| 1575 | // Otherwise we need to check. |
| 1576 | if String(to.Properties.Sdk_version) == "current" { |
| 1577 | // Current can't be linked against by anything else. |
| 1578 | ctx.ModuleErrorf("links %q built against newer API version %q", |
| 1579 | ctx.OtherModuleName(to), "current") |
| 1580 | } else { |
| 1581 | fromApi, err := strconv.Atoi(String(from.Properties.Sdk_version)) |
| 1582 | if err != nil { |
| 1583 | ctx.PropertyErrorf("sdk_version", |
Inseob Kim | 34b2283 | 2018-04-11 10:13:16 +0900 | [diff] [blame] | 1584 | "Invalid sdk_version value (must be int or current): %q", |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 1585 | String(from.Properties.Sdk_version)) |
| 1586 | } |
| 1587 | toApi, err := strconv.Atoi(String(to.Properties.Sdk_version)) |
| 1588 | if err != nil { |
| 1589 | ctx.PropertyErrorf("sdk_version", |
Inseob Kim | 34b2283 | 2018-04-11 10:13:16 +0900 | [diff] [blame] | 1590 | "Invalid sdk_version value (must be int or current): %q", |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 1591 | String(to.Properties.Sdk_version)) |
| 1592 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1593 | |
Inseob Kim | 01a2872 | 2018-04-11 09:48:45 +0900 | [diff] [blame] | 1594 | if toApi > fromApi { |
| 1595 | ctx.ModuleErrorf("links %q built against newer API version %q", |
| 1596 | ctx.OtherModuleName(to), String(to.Properties.Sdk_version)) |
| 1597 | } |
| 1598 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1599 | } |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 1600 | |
| 1601 | // Also check that the two STL choices are compatible. |
| 1602 | fromStl := from.stl.Properties.SelectedStl |
| 1603 | toStl := to.stl.Properties.SelectedStl |
| 1604 | if fromStl == "" || toStl == "" { |
| 1605 | // Libraries that don't use the STL are unrestricted. |
Inseob Kim | da2171a | 2018-04-11 15:41:38 +0900 | [diff] [blame] | 1606 | } else if fromStl == "ndk_system" || toStl == "ndk_system" { |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 1607 | // We can be permissive with the system "STL" since it is only the C++ |
| 1608 | // ABI layer, but in the future we should make sure that everyone is |
| 1609 | // using either libc++ or nothing. |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 1610 | } else if getNdkStlFamily(from) != getNdkStlFamily(to) { |
Dan Albert | 202fe49 | 2017-12-15 13:56:59 -0800 | [diff] [blame] | 1611 | ctx.ModuleErrorf("uses %q and depends on %q which uses incompatible %q", |
| 1612 | from.stl.Properties.SelectedStl, ctx.OtherModuleName(to), |
| 1613 | to.stl.Properties.SelectedStl) |
| 1614 | } |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1615 | } |
| 1616 | |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 1617 | // 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] | 1618 | // If a library has a vendor variant and is a (transitive) dependency of an LLNDK library, |
| 1619 | // 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] | 1620 | // or as vndk-sp (vndk: { enabled: true, support_system_process: true}). |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1621 | func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) { |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1622 | llndkLibraries := llndkLibraries(ctx.Config()) |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1623 | check := func(child, parent android.Module) bool { |
| 1624 | to, ok := child.(*Module) |
| 1625 | if !ok { |
| 1626 | // follow thru cc.Defaults, etc. |
| 1627 | return true |
| 1628 | } |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 1629 | |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1630 | if lib, ok := to.linker.(*libraryDecorator); !ok || !lib.shared() { |
| 1631 | return false |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 1632 | } |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1633 | |
| 1634 | // if target lib has no vendor variant, keep checking dependency graph |
| 1635 | if !to.hasVendorVariant() { |
| 1636 | return true |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 1637 | } |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1638 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1639 | if to.isVndkSp() || inList(child.Name(), *llndkLibraries) || Bool(to.VendorProperties.Double_loadable) { |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1640 | return false |
| 1641 | } |
| 1642 | |
| 1643 | var stringPath []string |
| 1644 | for _, m := range ctx.GetWalkPath() { |
| 1645 | stringPath = append(stringPath, m.Name()) |
| 1646 | } |
| 1647 | ctx.ModuleErrorf("links a library %q which is not LL-NDK, "+ |
| 1648 | "VNDK-SP, or explicitly marked as 'double_loadable:true'. "+ |
| 1649 | "(dependency: %s)", ctx.OtherModuleName(to), strings.Join(stringPath, " -> ")) |
| 1650 | return false |
| 1651 | } |
| 1652 | if module, ok := ctx.Module().(*Module); ok { |
| 1653 | if lib, ok := module.linker.(*libraryDecorator); ok && lib.shared() { |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1654 | if inList(ctx.ModuleName(), *llndkLibraries) || Bool(module.VendorProperties.Double_loadable) { |
Jooyung Han | a70f067 | 2019-01-18 15:20:43 +0900 | [diff] [blame] | 1655 | ctx.WalkDeps(check) |
| 1656 | } |
Jiyong Park | 5fb8c10 | 2018-04-09 12:03:06 +0900 | [diff] [blame] | 1657 | } |
| 1658 | } |
| 1659 | } |
| 1660 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1661 | // Convert dependencies to paths. Returns a PathDeps containing paths |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1662 | func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1663 | var depPaths PathDeps |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1664 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1665 | directStaticDeps := []*Module{} |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1666 | directSharedDeps := []*Module{} |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1667 | |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1668 | llndkLibraries := llndkLibraries(ctx.Config()) |
| 1669 | vendorPublicLibraries := vendorPublicLibraries(ctx.Config()) |
| 1670 | |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1671 | reexportExporter := func(exporter exportedFlagsProducer) { |
| 1672 | depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.exportedDirs()...) |
| 1673 | depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.exportedSystemDirs()...) |
| 1674 | depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.exportedFlags()...) |
| 1675 | depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.exportedDeps()...) |
| 1676 | } |
| 1677 | |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 1678 | ctx.VisitDirectDeps(func(dep android.Module) { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1679 | depName := ctx.OtherModuleName(dep) |
| 1680 | depTag := ctx.OtherModuleDependencyTag(dep) |
Dan Albert | 9e10cd4 | 2016-08-03 14:12:14 -0700 | [diff] [blame] | 1681 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1682 | ccDep, _ := dep.(*Module) |
| 1683 | if ccDep == nil { |
| 1684 | // handling for a few module types that aren't cc Module but that are also supported |
| 1685 | switch depTag { |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1686 | case genSourceDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1687 | if genRule, ok := dep.(genrule.SourceFileGenerator); ok { |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1688 | depPaths.GeneratedSources = append(depPaths.GeneratedSources, |
| 1689 | genRule.GeneratedSourceFiles()...) |
| 1690 | } else { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1691 | ctx.ModuleErrorf("module %q is not a gensrcs or genrule", depName) |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1692 | } |
Colin Cross | e90bfd1 | 2017-04-26 16:59:26 -0700 | [diff] [blame] | 1693 | // Support exported headers from a generated_sources dependency |
| 1694 | fallthrough |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 1695 | case genHeaderDepTag, genHeaderExportDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1696 | if genRule, ok := dep.(genrule.SourceFileGenerator); ok { |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1697 | depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, |
Dan Willemsen | 9da9d49 | 2018-02-21 18:28:18 -0800 | [diff] [blame] | 1698 | genRule.GeneratedDeps()...) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1699 | dirs := genRule.GeneratedHeaderDirs().Strings() |
| 1700 | depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1701 | if depTag == genHeaderExportDepTag { |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1702 | depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...) |
| 1703 | depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...) |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 1704 | // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1705 | c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs...) |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 1706 | |
Dan Willemsen | b3454ab | 2016-09-28 17:34:58 -0700 | [diff] [blame] | 1707 | } |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1708 | } else { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1709 | ctx.ModuleErrorf("module %q is not a genrule", depName) |
Dan Willemsen | b40aab6 | 2016-04-20 14:21:14 -0700 | [diff] [blame] | 1710 | } |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 1711 | case linkerFlagsDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1712 | if genRule, ok := dep.(genrule.SourceFileGenerator); ok { |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 1713 | files := genRule.GeneratedSourceFiles() |
| 1714 | if len(files) == 1 { |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 1715 | depPaths.LinkerFlagsFile = android.OptionalPathForPath(files[0]) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 1716 | } else if len(files) > 1 { |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 1717 | 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] | 1718 | } |
| 1719 | } else { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1720 | ctx.ModuleErrorf("module %q is not a genrule", depName) |
Dan Willemsen | c77a0b3 | 2017-09-18 23:19:12 -0700 | [diff] [blame] | 1721 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1722 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1723 | return |
| 1724 | } |
| 1725 | |
Colin Cross | fe17f6f | 2019-03-28 19:30:56 -0700 | [diff] [blame] | 1726 | if depTag == android.ProtoPluginDepTag { |
| 1727 | return |
| 1728 | } |
| 1729 | |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 1730 | if dep.Target().Os != ctx.Os() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1731 | ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName) |
| 1732 | return |
| 1733 | } |
Colin Cross | d11fcda | 2017-10-23 17:59:01 -0700 | [diff] [blame] | 1734 | if dep.Target().Arch.ArchType != ctx.Arch().ArchType { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1735 | ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName) |
Colin Cross | a1ad8d1 | 2016-06-01 17:09:44 -0700 | [diff] [blame] | 1736 | return |
| 1737 | } |
| 1738 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1739 | // re-exporting flags |
| 1740 | if depTag == reuseObjTag { |
| 1741 | if l, ok := ccDep.compiler.(libraryInterface); ok { |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1742 | c.staticVariant = ccDep |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1743 | objs, exporter := l.reuseObjs() |
Colin Cross | 10d2231 | 2017-05-03 11:01:58 -0700 | [diff] [blame] | 1744 | depPaths.Objs = depPaths.Objs.Append(objs) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1745 | reexportExporter(exporter) |
Colin Cross | bba9904 | 2016-11-23 15:45:05 -0800 | [diff] [blame] | 1746 | return |
| 1747 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1748 | } |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1749 | |
Jiyong Park | e4bb986 | 2019-02-01 00:31:10 +0900 | [diff] [blame] | 1750 | if depTag == staticVariantTag { |
| 1751 | if _, ok := ccDep.compiler.(libraryInterface); ok { |
| 1752 | c.staticVariant = ccDep |
| 1753 | return |
| 1754 | } |
| 1755 | } |
| 1756 | |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1757 | // Extract explicitlyVersioned field from the depTag and reset it inside the struct. |
| 1758 | // Otherwise, sharedDepTag and lateSharedDepTag with explicitlyVersioned set to true |
| 1759 | // won't be matched to sharedDepTag and lateSharedDepTag. |
| 1760 | explicitlyVersioned := false |
| 1761 | if t, ok := depTag.(dependencyTag); ok { |
| 1762 | explicitlyVersioned = t.explicitlyVersioned |
| 1763 | t.explicitlyVersioned = false |
| 1764 | depTag = t |
| 1765 | } |
| 1766 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1767 | if t, ok := depTag.(dependencyTag); ok && t.library { |
Jiyong Park | 16e91a0 | 2018-12-20 18:18:08 +0900 | [diff] [blame] | 1768 | depIsStatic := false |
| 1769 | switch depTag { |
| 1770 | case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag: |
| 1771 | depIsStatic = true |
| 1772 | } |
| 1773 | if dependentLibrary, ok := ccDep.linker.(*libraryDecorator); ok && !depIsStatic { |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1774 | depIsStubs := dependentLibrary.buildStubs() |
| 1775 | depHasStubs := ccDep.HasStubsVariants() |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 1776 | depInSameApex := android.DirectlyInApex(c.ApexName(), depName) |
Nicolas Geoffray | c22c1bf | 2019-01-15 19:53:23 +0000 | [diff] [blame] | 1777 | depInPlatform := !android.DirectlyInAnyApex(ctx, depName) |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1778 | |
| 1779 | var useThisDep bool |
| 1780 | if depIsStubs && explicitlyVersioned { |
| 1781 | // Always respect dependency to the versioned stubs (i.e. libX#10) |
| 1782 | useThisDep = true |
| 1783 | } else if !depHasStubs { |
| 1784 | // Use non-stub variant if that is the only choice |
| 1785 | // (i.e. depending on a lib without stubs.version property) |
| 1786 | useThisDep = true |
| 1787 | } else if c.IsForPlatform() { |
| 1788 | // If not building for APEX, use stubs only when it is from |
| 1789 | // an APEX (and not from platform) |
| 1790 | useThisDep = (depInPlatform != depIsStubs) |
Jiyong Park | a4b9dd0 | 2019-01-16 22:53:13 +0900 | [diff] [blame] | 1791 | if c.inRecovery() || c.bootstrap() { |
Jiyong Park | b078857 | 2018-12-20 22:10:17 +0900 | [diff] [blame] | 1792 | // However, for recovery or bootstrap modules, |
Jiyong Park | 25fc6a9 | 2018-11-18 18:02:45 +0900 | [diff] [blame] | 1793 | // always link to non-stub variant |
| 1794 | useThisDep = !depIsStubs |
| 1795 | } |
| 1796 | } else { |
| 1797 | // If building for APEX, use stubs only when it is not from |
| 1798 | // the same APEX |
| 1799 | useThisDep = (depInSameApex != depIsStubs) |
| 1800 | } |
| 1801 | |
| 1802 | if !useThisDep { |
| 1803 | return // stop processing this dep |
| 1804 | } |
| 1805 | } |
| 1806 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1807 | if i, ok := ccDep.linker.(exportedFlagsProducer); ok { |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1808 | depPaths.IncludeDirs = append(depPaths.IncludeDirs, i.exportedDirs()...) |
| 1809 | depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...) |
| 1810 | depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, i.exportedDeps()...) |
| 1811 | depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1812 | |
| 1813 | if t.reexportFlags { |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1814 | reexportExporter(i) |
Jayant Chowdhary | 715cac3 | 2017-04-20 06:53:59 -0700 | [diff] [blame] | 1815 | // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. |
Jayant Chowdhary | af6eb71 | 2017-08-23 16:08:29 -0700 | [diff] [blame] | 1816 | // Re-exported shared library headers must be included as well since they can help us with type information |
| 1817 | // about template instantiations (instantiated from their headers). |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1818 | // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version |
| 1819 | // scripts. |
| 1820 | c.sabi.Properties.ReexportedIncludes = append( |
| 1821 | c.sabi.Properties.ReexportedIncludes, i.exportedDirs()...) |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1822 | } |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1823 | } |
Dan Willemsen | a96ff64 | 2016-06-07 12:34:45 -0700 | [diff] [blame] | 1824 | |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 1825 | checkLinkType(ctx, c, ccDep, t) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1826 | } |
| 1827 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1828 | var ptr *android.Paths |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 1829 | var depPtr *android.Paths |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1830 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1831 | linkFile := ccDep.outputFile |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1832 | depFile := android.OptionalPath{} |
| 1833 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1834 | switch depTag { |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1835 | case ndkStubDepTag, sharedDepTag, sharedExportDepTag: |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1836 | ptr = &depPaths.SharedLibs |
| 1837 | depPtr = &depPaths.SharedLibsDeps |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1838 | depFile = ccDep.linker.(libraryInterface).toc() |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1839 | directSharedDeps = append(directSharedDeps, ccDep) |
Jiyong Park | 64a44f2 | 2019-01-18 14:37:08 +0900 | [diff] [blame] | 1840 | case earlySharedDepTag: |
| 1841 | ptr = &depPaths.EarlySharedLibs |
| 1842 | depPtr = &depPaths.EarlySharedLibsDeps |
| 1843 | depFile = ccDep.linker.(libraryInterface).toc() |
| 1844 | directSharedDeps = append(directSharedDeps, ccDep) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1845 | case lateSharedDepTag, ndkLateStubDepTag: |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1846 | ptr = &depPaths.LateSharedLibs |
| 1847 | depPtr = &depPaths.LateSharedLibsDeps |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1848 | depFile = ccDep.linker.(libraryInterface).toc() |
Dan Willemsen | 490a8dc | 2016-06-06 18:22:19 -0700 | [diff] [blame] | 1849 | case staticDepTag, staticExportDepTag: |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1850 | ptr = nil |
| 1851 | directStaticDeps = append(directStaticDeps, ccDep) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1852 | case lateStaticDepTag: |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1853 | ptr = &depPaths.LateStaticLibs |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1854 | case wholeStaticDepTag: |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1855 | ptr = &depPaths.WholeStaticLibs |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1856 | staticLib, ok := ccDep.linker.(libraryInterface) |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 1857 | if !ok || !staticLib.static() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1858 | ctx.ModuleErrorf("module %q not a static library", depName) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1859 | return |
| 1860 | } |
| 1861 | |
| 1862 | if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1863 | postfix := " (required by " + ctx.OtherModuleName(dep) + ")" |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1864 | for i := range missingDeps { |
| 1865 | missingDeps[i] += postfix |
| 1866 | } |
| 1867 | ctx.AddMissingDependencies(missingDeps) |
| 1868 | } |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1869 | depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs()) |
Colin Cross | 5950f38 | 2016-12-13 12:50:57 -0800 | [diff] [blame] | 1870 | case headerDepTag: |
| 1871 | // Nothing |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1872 | case objDepTag: |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 1873 | depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path()) |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1874 | case crtBeginDepTag: |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1875 | depPaths.CrtBegin = linkFile |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1876 | case crtEndDepTag: |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1877 | depPaths.CrtEnd = linkFile |
Dan Willemsen | a0790e3 | 2018-10-12 00:24:23 -0700 | [diff] [blame] | 1878 | case dynamicLinkerDepTag: |
| 1879 | depPaths.DynamicLinker = linkFile |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1880 | } |
| 1881 | |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1882 | switch depTag { |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1883 | case staticDepTag, staticExportDepTag, lateStaticDepTag: |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1884 | staticLib, ok := ccDep.linker.(libraryInterface) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1885 | if !ok || !staticLib.static() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1886 | ctx.ModuleErrorf("module %q not a static library", depName) |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1887 | return |
| 1888 | } |
| 1889 | |
| 1890 | // When combining coverage files for shared libraries and executables, coverage files |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1891 | // in static libraries act as if they were whole static libraries. The same goes for |
| 1892 | // source based Abi dump files. |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1893 | depPaths.StaticLibObjs.coverageFiles = append(depPaths.StaticLibObjs.coverageFiles, |
| 1894 | staticLib.objs().coverageFiles...) |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 1895 | depPaths.StaticLibObjs.sAbiDumpFiles = append(depPaths.StaticLibObjs.sAbiDumpFiles, |
| 1896 | staticLib.objs().sAbiDumpFiles...) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1897 | |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 1898 | } |
| 1899 | |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1900 | if ptr != nil { |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1901 | if !linkFile.Valid() { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1902 | ctx.ModuleErrorf("module %q missing output file", depName) |
Colin Cross | ce75d2c | 2016-10-06 16:12:58 -0700 | [diff] [blame] | 1903 | return |
| 1904 | } |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1905 | *ptr = append(*ptr, linkFile.Path()) |
| 1906 | } |
| 1907 | |
Colin Cross | c99deeb | 2016-04-11 15:06:20 -0700 | [diff] [blame] | 1908 | if depPtr != nil { |
Colin Cross | 26c34ed | 2016-09-30 17:10:16 -0700 | [diff] [blame] | 1909 | dep := depFile |
| 1910 | if !dep.Valid() { |
| 1911 | dep = linkFile |
| 1912 | } |
| 1913 | *depPtr = append(*depPtr, dep.Path()) |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1914 | } |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 1915 | |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1916 | makeLibName := func(depName string) string { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1917 | libName := strings.TrimSuffix(depName, llndkLibrarySuffix) |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 1918 | libName = strings.TrimSuffix(libName, vendorPublicLibrarySuffix) |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 1919 | libName = strings.TrimPrefix(libName, "prebuilt_") |
Inseob Kim | 9516ee9 | 2019-05-09 10:56:13 +0900 | [diff] [blame] | 1920 | isLLndk := inList(libName, *llndkLibraries) |
| 1921 | isVendorPublicLib := inList(libName, *vendorPublicLibraries) |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1922 | bothVendorAndCoreVariantsExist := ccDep.hasVendorVariant() || isLLndk |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 1923 | |
yidong.zhang | d06ecc8 | 2019-08-02 15:49:24 +0800 | [diff] [blame] | 1924 | if ctx.DeviceConfig().VndkUseCoreVariant() && ccDep.isVndk() && !ccDep.mustUseVendorVariant() && !c.inRecovery() { |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 1925 | // The vendor module is a no-vendor-variant VNDK library. Depend on the |
| 1926 | // core module instead. |
| 1927 | return libName |
| 1928 | } else if c.useVndk() && bothVendorAndCoreVariantsExist { |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1929 | // The vendor module in Make will have been renamed to not conflict with the core |
| 1930 | // module, so update the dependency name here accordingly. |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1931 | return libName + vendorSuffix |
Jiyong Park | 374510b | 2018-03-19 18:23:01 +0900 | [diff] [blame] | 1932 | } else if (ctx.Platform() || ctx.ProductSpecific()) && isVendorPublicLib { |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1933 | return libName + vendorPublicLibrarySuffix |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 1934 | } else if ccDep.inRecovery() && !ccDep.onlyInRecovery() { |
| 1935 | return libName + recoverySuffix |
dimitry | 1f33e40 | 2019-03-26 12:39:31 +0100 | [diff] [blame] | 1936 | } else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled { |
dimitry | 4320449 | 2019-05-23 13:24:38 +0200 | [diff] [blame] | 1937 | return libName + nativeBridgeSuffix |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1938 | } else { |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1939 | return libName |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 1940 | } |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1941 | } |
| 1942 | |
| 1943 | // Export the shared libs to Make. |
| 1944 | switch depTag { |
Jiyong Park | 64a44f2 | 2019-01-18 14:37:08 +0900 | [diff] [blame] | 1945 | case sharedDepTag, sharedExportDepTag, lateSharedDepTag, earlySharedDepTag: |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 1946 | if dependentLibrary, ok := ccDep.linker.(*libraryDecorator); ok { |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 1947 | if dependentLibrary.buildStubs() && android.InAnyApex(depName) { |
Logan Chien | 09106e1 | 2019-01-18 14:57:48 +0800 | [diff] [blame] | 1948 | // Add the dependency to the APEX(es) providing the library so that |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 1949 | // m <module> can trigger building the APEXes as well. |
Jiyong Park | 0ddfcd1 | 2018-12-11 01:35:25 +0900 | [diff] [blame] | 1950 | for _, an := range android.GetApexesForModule(depName) { |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 1951 | c.Properties.ApexesProvidingSharedLibs = append( |
| 1952 | c.Properties.ApexesProvidingSharedLibs, an) |
| 1953 | } |
Jiyong Park | de866cb | 2018-12-07 23:08:36 +0900 | [diff] [blame] | 1954 | } |
| 1955 | } |
| 1956 | |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 1957 | // Note: the order of libs in this list is not important because |
Jeff Gaston | af3cc2d | 2017-09-27 17:01:44 -0700 | [diff] [blame] | 1958 | // they merely serve as Make dependencies and do not affect this lib itself. |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1959 | c.Properties.AndroidMkSharedLibs = append( |
| 1960 | c.Properties.AndroidMkSharedLibs, makeLibName(depName)) |
Logan Chien | c7f797e | 2019-01-14 15:35:08 +0800 | [diff] [blame] | 1961 | case ndkStubDepTag, ndkLateStubDepTag: |
| 1962 | ndkStub := ccDep.linker.(*stubDecorator) |
| 1963 | c.Properties.AndroidMkSharedLibs = append( |
| 1964 | c.Properties.AndroidMkSharedLibs, |
| 1965 | depName+"."+ndkStub.properties.ApiLevel) |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 1966 | case staticDepTag, staticExportDepTag, lateStaticDepTag: |
| 1967 | c.Properties.AndroidMkStaticLibs = append( |
| 1968 | c.Properties.AndroidMkStaticLibs, makeLibName(depName)) |
Logan Chien | 43d34c3 | 2017-12-20 01:17:32 +0800 | [diff] [blame] | 1969 | case runtimeDepTag: |
| 1970 | c.Properties.AndroidMkRuntimeLibs = append( |
| 1971 | c.Properties.AndroidMkRuntimeLibs, makeLibName(depName)) |
Jaewoong Jung | 16c7d3d | 2018-11-16 01:19:56 +0000 | [diff] [blame] | 1972 | case wholeStaticDepTag: |
| 1973 | c.Properties.AndroidMkWholeStaticLibs = append( |
| 1974 | c.Properties.AndroidMkWholeStaticLibs, makeLibName(depName)) |
Jiyong Park | 27b188b | 2017-07-18 13:23:39 +0900 | [diff] [blame] | 1975 | } |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1976 | }) |
| 1977 | |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1978 | // use the ordered dependencies as this module's dependencies |
Jeff Gaston | f5b6e8f | 2017-11-27 15:48:57 -0800 | [diff] [blame] | 1979 | depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps, directSharedDeps)...) |
Jeff Gaston | 294356f | 2017-09-27 17:05:30 -0700 | [diff] [blame] | 1980 | |
Colin Cross | dd84e05 | 2017-05-17 13:44:16 -0700 | [diff] [blame] | 1981 | // Dedup exported flags from dependencies |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 1982 | depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1983 | depPaths.IncludeDirs = android.FirstUniqueStrings(depPaths.IncludeDirs) |
| 1984 | depPaths.SystemIncludeDirs = android.FirstUniqueStrings(depPaths.SystemIncludeDirs) |
Dan Willemsen | fe92c96 | 2017-08-29 12:28:37 -0700 | [diff] [blame] | 1985 | depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1986 | depPaths.ReexportedDirs = android.FirstUniqueStrings(depPaths.ReexportedDirs) |
| 1987 | depPaths.ReexportedSystemDirs = android.FirstUniqueStrings(depPaths.ReexportedSystemDirs) |
Colin Cross | b671544 | 2017-10-24 11:13:31 -0700 | [diff] [blame] | 1988 | depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags) |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1989 | depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps) |
Dan Willemsen | fe92c96 | 2017-08-29 12:28:37 -0700 | [diff] [blame] | 1990 | |
| 1991 | if c.sabi != nil { |
Inseob Kim | 6937844 | 2019-06-03 19:10:47 +0900 | [diff] [blame] | 1992 | c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes) |
Dan Willemsen | fe92c96 | 2017-08-29 12:28:37 -0700 | [diff] [blame] | 1993 | } |
Colin Cross | dd84e05 | 2017-05-17 13:44:16 -0700 | [diff] [blame] | 1994 | |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 1995 | return depPaths |
| 1996 | } |
| 1997 | |
| 1998 | func (c *Module) InstallInData() bool { |
| 1999 | if c.installer == nil { |
| 2000 | return false |
| 2001 | } |
Vishwath Mohan | 1dd8839 | 2017-03-29 22:00:18 -0700 | [diff] [blame] | 2002 | return c.installer.inData() |
| 2003 | } |
| 2004 | |
| 2005 | func (c *Module) InstallInSanitizerDir() bool { |
| 2006 | if c.installer == nil { |
| 2007 | return false |
| 2008 | } |
| 2009 | if c.sanitize != nil && c.sanitize.inSanitizerDir() { |
Colin Cross | 9461040 | 2016-08-29 13:41:32 -0700 | [diff] [blame] | 2010 | return true |
| 2011 | } |
Vishwath Mohan | 1dd8839 | 2017-03-29 22:00:18 -0700 | [diff] [blame] | 2012 | return c.installer.inSanitizerDir() |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2013 | } |
| 2014 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2015 | func (c *Module) InstallInRecovery() bool { |
| 2016 | return c.inRecovery() |
| 2017 | } |
| 2018 | |
Dan Willemsen | 4aa75ca | 2016-09-28 16:18:03 -0700 | [diff] [blame] | 2019 | func (c *Module) HostToolPath() android.OptionalPath { |
| 2020 | if c.installer == nil { |
| 2021 | return android.OptionalPath{} |
| 2022 | } |
| 2023 | return c.installer.hostToolPath() |
| 2024 | } |
| 2025 | |
Nan Zhang | d4e641b | 2017-07-12 12:55:28 -0700 | [diff] [blame] | 2026 | func (c *Module) IntermPathForModuleOut() android.OptionalPath { |
| 2027 | return c.outputFile |
| 2028 | } |
| 2029 | |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 2030 | func (c *Module) OutputFiles(tag string) (android.Paths, error) { |
| 2031 | switch tag { |
| 2032 | case "": |
| 2033 | if c.outputFile.Valid() { |
| 2034 | return android.Paths{c.outputFile.Path()}, nil |
| 2035 | } |
| 2036 | return android.Paths{}, nil |
| 2037 | default: |
| 2038 | return nil, fmt.Errorf("unsupported module reference tag %q", tag) |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2039 | } |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2040 | } |
| 2041 | |
Vishwath Mohan | b743e9c | 2017-11-01 09:20:21 +0000 | [diff] [blame] | 2042 | func (c *Module) static() bool { |
| 2043 | if static, ok := c.linker.(interface { |
| 2044 | static() bool |
| 2045 | }); ok { |
| 2046 | return static.static() |
| 2047 | } |
| 2048 | return false |
| 2049 | } |
| 2050 | |
Jiyong Park | 379de2f | 2018-12-19 02:47:14 +0900 | [diff] [blame] | 2051 | func (c *Module) staticBinary() bool { |
| 2052 | if static, ok := c.linker.(interface { |
| 2053 | staticBinary() bool |
| 2054 | }); ok { |
| 2055 | return static.staticBinary() |
| 2056 | } |
| 2057 | return false |
| 2058 | } |
| 2059 | |
Jiyong Park | 1d1119f | 2019-07-29 21:27:18 +0900 | [diff] [blame] | 2060 | func (c *Module) header() bool { |
| 2061 | if h, ok := c.linker.(interface { |
| 2062 | header() bool |
| 2063 | }); ok { |
| 2064 | return h.header() |
| 2065 | } |
| 2066 | return false |
| 2067 | } |
| 2068 | |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2069 | func (c *Module) getMakeLinkType(actx android.ModuleContext) string { |
| 2070 | name := actx.ModuleName() |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2071 | if c.useVndk() { |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2072 | if lib, ok := c.linker.(*llndkStubDecorator); ok { |
| 2073 | if Bool(lib.Properties.Vendor_available) { |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2074 | return "native:vndk" |
| 2075 | } |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2076 | return "native:vndk_private" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2077 | } |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2078 | if c.isVndk() && !c.isVndkExt() { |
| 2079 | if Bool(c.VendorProperties.Vendor_available) { |
| 2080 | return "native:vndk" |
| 2081 | } |
| 2082 | return "native:vndk_private" |
| 2083 | } |
| 2084 | return "native:vendor" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2085 | } else if c.inRecovery() { |
| 2086 | return "native:recovery" |
| 2087 | } else if c.Target().Os == android.Android && String(c.Properties.Sdk_version) != "" { |
| 2088 | return "native:ndk:none:none" |
| 2089 | // TODO(b/114741097): use the correct ndk stl once build errors have been fixed |
| 2090 | //family, link := getNdkStlFamilyAndLinkType(c) |
| 2091 | //return fmt.Sprintf("native:ndk:%s:%s", family, link) |
Jooyung Han | 3800291 | 2019-05-16 04:01:54 +0900 | [diff] [blame] | 2092 | } else if inList(name, *vndkUsingCoreVariantLibraries(actx.Config())) { |
Vic Yang | efd249e | 2018-11-12 20:19:56 -0800 | [diff] [blame] | 2093 | return "native:platform_vndk" |
Colin Cross | b60190a | 2018-09-04 16:28:17 -0700 | [diff] [blame] | 2094 | } else { |
| 2095 | return "native:platform" |
| 2096 | } |
| 2097 | } |
| 2098 | |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2099 | // Overrides ApexModule.IsInstallabeToApex() |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2100 | // 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] | 2101 | func (c *Module) IsInstallableToApex() bool { |
| 2102 | if shared, ok := c.linker.(interface { |
| 2103 | shared() bool |
| 2104 | }); ok { |
| 2105 | return shared.shared() |
Roland Levillain | f89cd09 | 2019-07-29 16:22:59 +0100 | [diff] [blame] | 2106 | } else if _, ok := c.linker.(testPerSrc); ok { |
| 2107 | return true |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2108 | } |
| 2109 | return false |
| 2110 | } |
| 2111 | |
Inseob Kim | 1f086e2 | 2019-05-09 13:29:15 +0900 | [diff] [blame] | 2112 | func (c *Module) installable() bool { |
| 2113 | return c.installer != nil && !c.Properties.PreventInstall && c.IsForPlatform() && c.outputFile.Valid() |
| 2114 | } |
| 2115 | |
Jiyong Park | 3b1746a | 2019-01-29 11:15:04 +0900 | [diff] [blame] | 2116 | func (c *Module) imageVariation() string { |
| 2117 | variation := "core" |
| 2118 | if c.useVndk() { |
| 2119 | variation = "vendor" |
| 2120 | } else if c.inRecovery() { |
| 2121 | variation = "recovery" |
| 2122 | } |
| 2123 | return variation |
| 2124 | } |
| 2125 | |
bralee | 3f49f4d | 2019-03-04 06:58:15 +0800 | [diff] [blame] | 2126 | func (c *Module) IDEInfo(dpInfo *android.IdeInfo) { |
Colin Cross | 41955e8 | 2019-05-29 14:40:35 -0700 | [diff] [blame] | 2127 | outputFiles, err := c.OutputFiles("") |
| 2128 | if err != nil { |
| 2129 | panic(err) |
| 2130 | } |
| 2131 | dpInfo.Srcs = append(dpInfo.Srcs, outputFiles.Strings()...) |
bralee | 3f49f4d | 2019-03-04 06:58:15 +0800 | [diff] [blame] | 2132 | } |
| 2133 | |
Logan Chien | 41eabe6 | 2019-04-10 13:33:58 +0800 | [diff] [blame] | 2134 | func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) { |
| 2135 | if c.linker != nil { |
| 2136 | if library, ok := c.linker.(*libraryDecorator); ok { |
| 2137 | library.androidMkWriteAdditionalDependenciesForSourceAbiDiff(w) |
| 2138 | } |
| 2139 | } |
| 2140 | } |
| 2141 | |
Colin Cross | 2ba19d9 | 2015-05-07 15:44:20 -0700 | [diff] [blame] | 2142 | // |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 2143 | // Defaults |
| 2144 | // |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2145 | type Defaults struct { |
Colin Cross | 635c3b0 | 2016-05-18 15:37:25 -0700 | [diff] [blame] | 2146 | android.ModuleBase |
Colin Cross | 1f44a3a | 2017-07-07 14:33:33 -0700 | [diff] [blame] | 2147 | android.DefaultsModuleBase |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2148 | android.ApexModuleBase |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 2149 | } |
| 2150 | |
Patrice Arruda | c249c71 | 2019-03-19 17:00:29 -0700 | [diff] [blame] | 2151 | // cc_defaults provides a set of properties that can be inherited by other cc |
| 2152 | // modules. A module can use the properties from a cc_defaults using |
| 2153 | // `defaults: ["<:default_module_name>"]`. Properties of both modules are |
| 2154 | // merged (when possible) by prepending the default module's values to the |
| 2155 | // depending module's values. |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 2156 | func defaultsFactory() android.Module { |
Colin Cross | e1d764e | 2016-08-18 14:18:32 -0700 | [diff] [blame] | 2157 | return DefaultsFactory() |
| 2158 | } |
| 2159 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 2160 | func DefaultsFactory(props ...interface{}) android.Module { |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2161 | module := &Defaults{} |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 2162 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 2163 | module.AddProperties(props...) |
| 2164 | module.AddProperties( |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2165 | &BaseProperties{}, |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2166 | &VendorProperties{}, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2167 | &BaseCompilerProperties{}, |
| 2168 | &BaseLinkerProperties{}, |
Paul Duffin | a37832a | 2019-07-18 12:31:26 +0100 | [diff] [blame] | 2169 | &ObjectLinkerProperties{}, |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 2170 | &LibraryProperties{}, |
Colin Cross | 919281a | 2016-04-05 16:42:05 -0700 | [diff] [blame] | 2171 | &FlagExporterProperties{}, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2172 | &BinaryLinkerProperties{}, |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 2173 | &TestProperties{}, |
| 2174 | &TestBinaryProperties{}, |
Mitch Phillips | 4e4ab8a | 2019-09-13 17:32:50 -0700 | [diff] [blame^] | 2175 | &FuzzProperties{}, |
Colin Cross | ca860ac | 2016-01-04 14:34:37 -0800 | [diff] [blame] | 2176 | &StlProperties{}, |
Colin Cross | 16b2349 | 2016-01-06 14:41:07 -0800 | [diff] [blame] | 2177 | &SanitizeProperties{}, |
Colin Cross | 665dce9 | 2016-04-28 14:50:03 -0700 | [diff] [blame] | 2178 | &StripProperties{}, |
Dan Willemsen | 7424d61 | 2016-09-01 13:45:39 -0700 | [diff] [blame] | 2179 | &InstallerProperties{}, |
Dan Willemsen | a03cf6d | 2016-09-26 15:45:04 -0700 | [diff] [blame] | 2180 | &TidyProperties{}, |
Dan Willemsen | 581341d | 2017-02-09 16:16:31 -0800 | [diff] [blame] | 2181 | &CoverageProperties{}, |
Jayant Chowdhary | 3e231fd | 2017-02-08 13:45:53 -0800 | [diff] [blame] | 2182 | &SAbiProperties{}, |
Justin Yun | 4b2382f | 2017-07-26 14:22:10 +0900 | [diff] [blame] | 2183 | &VndkProperties{}, |
Stephen Crane | ba090d1 | 2017-05-09 15:44:35 -0700 | [diff] [blame] | 2184 | <OProperties{}, |
Pirama Arumuga Nainar | ada83ec | 2017-08-31 23:38:27 -0700 | [diff] [blame] | 2185 | &PgoProperties{}, |
Ivan Lozano | 074ec48 | 2018-11-21 08:59:37 -0800 | [diff] [blame] | 2186 | &XomProperties{}, |
Dan Willemsen | 6424d17 | 2018-03-08 13:27:59 -0800 | [diff] [blame] | 2187 | &android.ProtoProperties{}, |
Colin Cross | e1d764e | 2016-08-18 14:18:32 -0700 | [diff] [blame] | 2188 | ) |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 2189 | |
Colin Cross | 1f44a3a | 2017-07-07 14:33:33 -0700 | [diff] [blame] | 2190 | android.InitDefaultsModule(module) |
Jiyong Park | 9d45299 | 2018-10-03 00:38:19 +0900 | [diff] [blame] | 2191 | android.InitApexModule(module) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 2192 | |
| 2193 | return module |
Colin Cross | cfad119 | 2015-11-02 16:43:11 -0800 | [diff] [blame] | 2194 | } |
| 2195 | |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2196 | const ( |
| 2197 | // coreMode is the variant used for framework-private libraries, or |
| 2198 | // SDK libraries. (which framework-private libraries can use) |
| 2199 | coreMode = "core" |
| 2200 | |
| 2201 | // vendorMode is the variant used for /vendor code that compiles |
| 2202 | // against the VNDK. |
| 2203 | vendorMode = "vendor" |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2204 | |
| 2205 | recoveryMode = "recovery" |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2206 | ) |
| 2207 | |
Jiyong Park | 6a43f04 | 2017-10-12 23:05:00 +0900 | [diff] [blame] | 2208 | func squashVendorSrcs(m *Module) { |
| 2209 | if lib, ok := m.compiler.(*libraryDecorator); ok { |
| 2210 | lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, |
| 2211 | lib.baseCompiler.Properties.Target.Vendor.Srcs...) |
| 2212 | |
| 2213 | lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, |
| 2214 | lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...) |
| 2215 | } |
| 2216 | } |
| 2217 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2218 | func squashRecoverySrcs(m *Module) { |
| 2219 | if lib, ok := m.compiler.(*libraryDecorator); ok { |
| 2220 | lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, |
| 2221 | lib.baseCompiler.Properties.Target.Recovery.Srcs...) |
| 2222 | |
| 2223 | lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, |
| 2224 | lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...) |
| 2225 | } |
| 2226 | } |
| 2227 | |
Jiyong Park | da6eb59 | 2018-12-19 17:12:36 +0900 | [diff] [blame] | 2228 | func ImageMutator(mctx android.BottomUpMutatorContext) { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2229 | if mctx.Os() != android.Android { |
| 2230 | return |
| 2231 | } |
| 2232 | |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2233 | if g, ok := mctx.Module().(*genrule.Module); ok { |
| 2234 | if props, ok := g.Extra.(*GenruleExtraProperties); ok { |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2235 | var coreVariantNeeded bool = false |
| 2236 | var vendorVariantNeeded bool = false |
| 2237 | var recoveryVariantNeeded bool = false |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 2238 | if mctx.DeviceConfig().VndkVersion() == "" { |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2239 | coreVariantNeeded = true |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2240 | } else if Bool(props.Vendor_available) { |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2241 | coreVariantNeeded = true |
| 2242 | vendorVariantNeeded = true |
Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 2243 | } else if mctx.SocSpecific() || mctx.DeviceSpecific() { |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2244 | vendorVariantNeeded = true |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2245 | } else { |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2246 | coreVariantNeeded = true |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2247 | } |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2248 | if Bool(props.Recovery_available) { |
| 2249 | recoveryVariantNeeded = true |
| 2250 | } |
| 2251 | |
Jiyong Park | 413cc74 | 2018-06-19 01:46:06 +0900 | [diff] [blame] | 2252 | if recoveryVariantNeeded { |
Jiyong Park | 8d52f86 | 2018-07-07 18:02:07 +0900 | [diff] [blame] | 2253 | primaryArch := mctx.Config().DevicePrimaryArchType() |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2254 | moduleArch := g.Target().Arch.ArchType |
Jiyong Park | 8d52f86 | 2018-07-07 18:02:07 +0900 | [diff] [blame] | 2255 | if moduleArch != primaryArch { |
Jiyong Park | 413cc74 | 2018-06-19 01:46:06 +0900 | [diff] [blame] | 2256 | recoveryVariantNeeded = false |
| 2257 | } |
| 2258 | } |
| 2259 | |
Jiyong Park | 3f736c9 | 2018-05-24 13:36:56 +0900 | [diff] [blame] | 2260 | var variants []string |
| 2261 | if coreVariantNeeded { |
| 2262 | variants = append(variants, coreMode) |
| 2263 | } |
| 2264 | if vendorVariantNeeded { |
| 2265 | variants = append(variants, vendorMode) |
| 2266 | } |
| 2267 | if recoveryVariantNeeded { |
| 2268 | variants = append(variants, recoveryMode) |
| 2269 | } |
Jiyong Park | 7ed9de3 | 2018-10-15 22:25:07 +0900 | [diff] [blame] | 2270 | mod := mctx.CreateVariations(variants...) |
| 2271 | for i, v := range variants { |
| 2272 | if v == recoveryMode { |
| 2273 | m := mod[i].(*genrule.Module) |
| 2274 | m.Extra.(*GenruleExtraProperties).InRecovery = true |
| 2275 | } |
| 2276 | } |
Dan Willemsen | 3e5bdf2 | 2017-09-13 18:37:08 -0700 | [diff] [blame] | 2277 | } |
| 2278 | } |
| 2279 | |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2280 | m, ok := mctx.Module().(*Module) |
| 2281 | if !ok { |
| 2282 | return |
| 2283 | } |
| 2284 | |
| 2285 | // Sanity check |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2286 | vendorSpecific := mctx.SocSpecific() || mctx.DeviceSpecific() |
Justin Yun | 9357f4a | 2018-11-28 15:14:47 +0900 | [diff] [blame] | 2287 | productSpecific := mctx.ProductSpecific() |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2288 | |
| 2289 | if m.VendorProperties.Vendor_available != nil && vendorSpecific { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2290 | mctx.PropertyErrorf("vendor_available", |
Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 2291 | "doesn't make sense at the same time as `vendor: true`, `proprietary: true`, or `device_specific:true`") |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2292 | return |
| 2293 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2294 | |
| 2295 | if vndkdep := m.vndkdep; vndkdep != nil { |
| 2296 | if vndkdep.isVndk() { |
Justin Yun | 9357f4a | 2018-11-28 15:14:47 +0900 | [diff] [blame] | 2297 | if productSpecific { |
| 2298 | mctx.PropertyErrorf("product_specific", |
| 2299 | "product_specific must not be true when `vndk: {enabled: true}`") |
| 2300 | return |
| 2301 | } |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2302 | if vendorSpecific { |
| 2303 | if !vndkdep.isVndkExt() { |
| 2304 | mctx.PropertyErrorf("vndk", |
| 2305 | "must set `extends: \"...\"` to vndk extension") |
| 2306 | return |
| 2307 | } |
| 2308 | } else { |
| 2309 | if vndkdep.isVndkExt() { |
| 2310 | mctx.PropertyErrorf("vndk", |
| 2311 | "must set `vendor: true` to set `extends: %q`", |
| 2312 | m.getVndkExtendsModuleName()) |
| 2313 | return |
| 2314 | } |
| 2315 | if m.VendorProperties.Vendor_available == nil { |
| 2316 | mctx.PropertyErrorf("vndk", |
| 2317 | "vendor_available must be set to either true or false when `vndk: {enabled: true}`") |
| 2318 | return |
| 2319 | } |
| 2320 | } |
| 2321 | } else { |
| 2322 | if vndkdep.isVndkSp() { |
| 2323 | mctx.PropertyErrorf("vndk", |
| 2324 | "must set `enabled: true` to set `support_system_process: true`") |
| 2325 | return |
| 2326 | } |
| 2327 | if vndkdep.isVndkExt() { |
| 2328 | mctx.PropertyErrorf("vndk", |
| 2329 | "must set `enabled: true` to set `extends: %q`", |
| 2330 | m.getVndkExtendsModuleName()) |
| 2331 | return |
| 2332 | } |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 2333 | } |
| 2334 | } |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2335 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2336 | var coreVariantNeeded bool = false |
| 2337 | var vendorVariantNeeded bool = false |
| 2338 | var recoveryVariantNeeded bool = false |
| 2339 | |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 2340 | if mctx.DeviceConfig().VndkVersion() == "" { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2341 | // If the device isn't compiling against the VNDK, we always |
| 2342 | // use the core mode. |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2343 | coreVariantNeeded = true |
Justin Yun | 1282f42 | 2019-09-09 14:42:44 +0900 | [diff] [blame] | 2344 | } else if m.Target().NativeBridge == android.NativeBridgeEnabled { |
| 2345 | // Skip creating vendor variants for natvie bridge modules |
| 2346 | coreVariantNeeded = true |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2347 | } else if _, ok := m.linker.(*llndkStubDecorator); ok { |
| 2348 | // LL-NDK stubs only exist in the vendor variant, since the |
| 2349 | // real libraries will be used in the core variant. |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2350 | vendorVariantNeeded = true |
Jiyong Park | 2a45412 | 2017-10-19 15:59:33 +0900 | [diff] [blame] | 2351 | } else if _, ok := m.linker.(*llndkHeadersDecorator); ok { |
| 2352 | // ... and LL-NDK headers as well |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2353 | vendorVariantNeeded = true |
Justin Yun | 312ccb9 | 2018-01-23 12:07:46 +0900 | [diff] [blame] | 2354 | } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok { |
Justin Yun | 7154928 | 2017-11-17 12:10:28 +0900 | [diff] [blame] | 2355 | // Make vendor variants only for the versions in BOARD_VNDK_VERSION and |
| 2356 | // PRODUCT_EXTRA_VNDK_VERSIONS. |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2357 | vendorVariantNeeded = true |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2358 | } else if m.hasVendorVariant() && !vendorSpecific { |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2359 | // This will be available in both /system and /vendor |
Justin Yun | 8effde4 | 2017-06-23 19:24:43 +0900 | [diff] [blame] | 2360 | // or a /system directory that is available to vendor. |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2361 | coreVariantNeeded = true |
| 2362 | vendorVariantNeeded = true |
Logan Chien | f351174 | 2017-10-31 18:04:35 +0800 | [diff] [blame] | 2363 | } else if vendorSpecific && String(m.Properties.Sdk_version) == "" { |
Jiyong Park | 2db7692 | 2017-11-08 16:03:48 +0900 | [diff] [blame] | 2364 | // This will be available in /vendor (or /odm) only |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2365 | vendorVariantNeeded = true |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2366 | } else { |
| 2367 | // This is either in /system (or similar: /data), or is a |
| 2368 | // modules built with the NDK. Modules built with the NDK |
| 2369 | // will be restricted using the existing link type checks. |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2370 | coreVariantNeeded = true |
| 2371 | } |
| 2372 | |
| 2373 | if Bool(m.Properties.Recovery_available) { |
| 2374 | recoveryVariantNeeded = true |
| 2375 | } |
| 2376 | |
| 2377 | if m.ModuleBase.InstallInRecovery() { |
| 2378 | recoveryVariantNeeded = true |
| 2379 | coreVariantNeeded = false |
| 2380 | } |
| 2381 | |
Jiyong Park | 413cc74 | 2018-06-19 01:46:06 +0900 | [diff] [blame] | 2382 | if recoveryVariantNeeded { |
Jiyong Park | 8d52f86 | 2018-07-07 18:02:07 +0900 | [diff] [blame] | 2383 | primaryArch := mctx.Config().DevicePrimaryArchType() |
| 2384 | moduleArch := m.Target().Arch.ArchType |
| 2385 | if moduleArch != primaryArch { |
Jiyong Park | 413cc74 | 2018-06-19 01:46:06 +0900 | [diff] [blame] | 2386 | recoveryVariantNeeded = false |
| 2387 | } |
| 2388 | } |
| 2389 | |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2390 | var variants []string |
| 2391 | if coreVariantNeeded { |
| 2392 | variants = append(variants, coreMode) |
| 2393 | } |
| 2394 | if vendorVariantNeeded { |
| 2395 | variants = append(variants, vendorMode) |
| 2396 | } |
| 2397 | if recoveryVariantNeeded { |
| 2398 | variants = append(variants, recoveryMode) |
| 2399 | } |
| 2400 | mod := mctx.CreateVariations(variants...) |
| 2401 | for i, v := range variants { |
| 2402 | if v == vendorMode { |
| 2403 | m := mod[i].(*Module) |
| 2404 | m.Properties.UseVndk = true |
| 2405 | squashVendorSrcs(m) |
| 2406 | } else if v == recoveryMode { |
| 2407 | m := mod[i].(*Module) |
| 2408 | m.Properties.InRecovery = true |
Jiyong Park | 5baac54 | 2018-08-28 09:55:37 +0900 | [diff] [blame] | 2409 | m.MakeAsPlatform() |
Jiyong Park | f9332f1 | 2018-02-01 00:54:12 +0900 | [diff] [blame] | 2410 | squashRecoverySrcs(m) |
| 2411 | } |
Dan Willemsen | 4416e5d | 2017-04-06 12:43:22 -0700 | [diff] [blame] | 2412 | } |
| 2413 | } |
| 2414 | |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 2415 | func getCurrentNdkPrebuiltVersion(ctx DepsContext) string { |
Colin Cross | 6510f91 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 2416 | if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt { |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 2417 | return strconv.Itoa(config.NdkMaxPrebuiltVersionInt) |
| 2418 | } |
Colin Cross | 6510f91 | 2017-11-29 00:27:14 -0800 | [diff] [blame] | 2419 | return ctx.Config().PlatformSdkVersion() |
Jayant Chowdhary | 6e8115a | 2017-05-09 10:21:52 -0700 | [diff] [blame] | 2420 | } |
| 2421 | |
Sasha Smundak | 2a4549e | 2018-11-05 16:49:08 -0800 | [diff] [blame] | 2422 | func kytheExtractAllFactory() android.Singleton { |
| 2423 | return &kytheExtractAllSingleton{} |
| 2424 | } |
| 2425 | |
| 2426 | type kytheExtractAllSingleton struct { |
| 2427 | } |
| 2428 | |
| 2429 | func (ks *kytheExtractAllSingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 2430 | var xrefTargets android.Paths |
| 2431 | ctx.VisitAllModules(func(module android.Module) { |
| 2432 | if ccModule, ok := module.(xref); ok { |
| 2433 | xrefTargets = append(xrefTargets, ccModule.XrefCcFiles()...) |
| 2434 | } |
| 2435 | }) |
| 2436 | // TODO(asmundak): Perhaps emit a rule to output a warning if there were no xrefTargets |
| 2437 | if len(xrefTargets) > 0 { |
| 2438 | ctx.Build(pctx, android.BuildParams{ |
| 2439 | Rule: blueprint.Phony, |
| 2440 | Output: android.PathForPhony(ctx, "xref_cxx"), |
| 2441 | Inputs: xrefTargets, |
| 2442 | //Default: true, |
| 2443 | }) |
| 2444 | } |
| 2445 | } |
| 2446 | |
Colin Cross | 06a931b | 2015-10-28 17:23:31 -0700 | [diff] [blame] | 2447 | var Bool = proptools.Bool |
Colin Cross | 38b40df | 2018-04-10 16:14:46 -0700 | [diff] [blame] | 2448 | var BoolDefault = proptools.BoolDefault |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 2449 | var BoolPtr = proptools.BoolPtr |
| 2450 | var String = proptools.String |
| 2451 | var StringPtr = proptools.StringPtr |