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