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