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