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