Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 1 | // Copyright 2016 Google Inc. All rights reserved. |
| 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 | import ( |
| 18 | "fmt" |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 19 | "path/filepath" |
Dan Albert | ad66593 | 2021-06-07 13:19:49 -0700 | [diff] [blame] | 20 | "runtime" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 21 | "strings" |
Colin Cross | e8a67a7 | 2016-08-07 21:17:54 -0700 | [diff] [blame] | 22 | "sync" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 23 | |
| 24 | "github.com/google/blueprint" |
Jiyong Park | ee9b117 | 2021-04-06 17:40:32 +0900 | [diff] [blame] | 25 | "github.com/google/blueprint/proptools" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 26 | |
| 27 | "android/soong/android" |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 28 | "android/soong/bazel" |
Jingwen Chen | 341f735 | 2022-01-11 05:42:49 +0000 | [diff] [blame] | 29 | "android/soong/cc/config" |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 30 | ) |
| 31 | |
sophiez | 58cabb7 | 2020-05-29 13:37:12 -0700 | [diff] [blame] | 32 | func init() { |
Dan Albert | 06f58af | 2020-06-22 15:10:31 -0700 | [diff] [blame] | 33 | pctx.HostBinToolVariable("ndkStubGenerator", "ndkstubgen") |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 34 | pctx.HostBinToolVariable("abidiff", "abidiff") |
| 35 | pctx.HostBinToolVariable("abitidy", "abitidy") |
| 36 | pctx.HostBinToolVariable("abidw", "abidw") |
sophiez | 58cabb7 | 2020-05-29 13:37:12 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 39 | var ( |
Colin Cross | 9d45bb7 | 2016-08-29 16:14:13 -0700 | [diff] [blame] | 40 | genStubSrc = pctx.AndroidStaticRule("genStubSrc", |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 41 | blueprint.RuleParams{ |
Dan Albert | 06f58af | 2020-06-22 15:10:31 -0700 | [diff] [blame] | 42 | Command: "$ndkStubGenerator --arch $arch --api $apiLevel " + |
| 43 | "--api-map $apiMap $flags $in $out", |
| 44 | CommandDeps: []string{"$ndkStubGenerator"}, |
Jiyong Park | 3fd0baf | 2018-12-07 16:25:39 +0900 | [diff] [blame] | 45 | }, "arch", "apiLevel", "apiMap", "flags") |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 46 | |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 47 | abidw = pctx.AndroidStaticRule("abidw", |
| 48 | blueprint.RuleParams{ |
| 49 | Command: "$abidw --type-id-style hash --no-corpus-path " + |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 50 | "--no-show-locs --no-comp-dir-path -w $symbolList " + |
| 51 | "$in --out-file $out", |
| 52 | CommandDeps: []string{"$abidw"}, |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 53 | }, "symbolList") |
| 54 | |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 55 | abitidy = pctx.AndroidStaticRule("abitidy", |
| 56 | blueprint.RuleParams{ |
Dan Albert | 604086f | 2021-06-15 13:23:44 -0700 | [diff] [blame] | 57 | Command: "$abitidy --all $flags -i $in -o $out", |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 58 | CommandDeps: []string{"$abitidy"}, |
Dan Albert | 604086f | 2021-06-15 13:23:44 -0700 | [diff] [blame] | 59 | }, "flags") |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 60 | |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 61 | abidiff = pctx.AndroidStaticRule("abidiff", |
| 62 | blueprint.RuleParams{ |
| 63 | // Need to create *some* output for ninja. We don't want to use tee |
| 64 | // because we don't want to spam the build output with "nothing |
| 65 | // changed" messages, so redirect output message to $out, and if |
| 66 | // changes were detected print the output and fail. |
| 67 | Command: "$abidiff $args $in > $out || (cat $out && false)", |
| 68 | CommandDeps: []string{"$abidiff"}, |
| 69 | }, "args") |
| 70 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 71 | ndkLibrarySuffix = ".ndk" |
Colin Cross | 4d9c2d1 | 2016-07-29 12:48:20 -0700 | [diff] [blame] | 72 | |
Colin Cross | 95f1ca0 | 2020-10-29 20:47:22 -0700 | [diff] [blame] | 73 | ndkKnownLibsKey = android.NewOnceKey("ndkKnownLibsKey") |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 74 | // protects ndkKnownLibs writes during parallel BeginMutator. |
| 75 | ndkKnownLibsLock sync.Mutex |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 76 | |
| 77 | stubImplementation = dependencyTag{name: "stubImplementation"} |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 78 | ) |
| 79 | |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 80 | // The First_version and Unversioned_until properties of this struct should not |
| 81 | // be used directly, but rather through the ApiLevel returning methods |
| 82 | // firstVersion() and unversionedUntil(). |
| 83 | |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 84 | // Creates a stub shared library based on the provided version file. |
| 85 | // |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 86 | // Example: |
| 87 | // |
Spandan Das | 73bcafc | 2022-08-18 23:26:00 +0000 | [diff] [blame] | 88 | // ndk_library { |
| 89 | // |
| 90 | // name: "libfoo", |
| 91 | // symbol_file: "libfoo.map.txt", |
| 92 | // first_version: "9", |
| 93 | // |
| 94 | // } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 95 | type libraryProperties struct { |
| 96 | // Relative path to the symbol map. |
| 97 | // An example file can be seen here: TODO(danalbert): Make an example. |
Inseob Kim | 5eb7ee9 | 2022-04-27 10:30:34 +0900 | [diff] [blame] | 98 | Symbol_file *string `android:"path"` |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 99 | |
| 100 | // The first API level a library was available. A library will be generated |
| 101 | // for every API level beginning with this one. |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 102 | First_version *string |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 103 | |
Dan Albert | 98dbb3b | 2017-01-03 15:16:29 -0800 | [diff] [blame] | 104 | // The first API level that library should have the version script applied. |
| 105 | // This defaults to the value of first_version, and should almost never be |
| 106 | // used. This is only needed to work around platform bugs like |
| 107 | // https://github.com/android-ndk/ndk/issues/265. |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 108 | Unversioned_until *string |
Dan Albert | 604086f | 2021-06-15 13:23:44 -0700 | [diff] [blame] | 109 | |
| 110 | // If true, does not emit errors when APIs lacking type information are |
| 111 | // found. This is false by default and should not be enabled outside bionic, |
| 112 | // where it is enabled pending a fix for http://b/190554910 (no debug info |
| 113 | // for asm implemented symbols). |
| 114 | Allow_untyped_symbols *bool |
Spandan Das | 73bcafc | 2022-08-18 23:26:00 +0000 | [diff] [blame] | 115 | |
| 116 | // Headers presented by this library to the Public API Surface |
| 117 | Export_header_libs []string |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 118 | } |
| 119 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 120 | type stubDecorator struct { |
| 121 | *libraryDecorator |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 122 | |
| 123 | properties libraryProperties |
Dan Albert | 2bc91ba | 2016-07-28 17:40:28 -0700 | [diff] [blame] | 124 | |
sophiez | 58cabb7 | 2020-05-29 13:37:12 -0700 | [diff] [blame] | 125 | versionScriptPath android.ModuleGenPath |
| 126 | parsedCoverageXmlPath android.ModuleOutPath |
| 127 | installPath android.Path |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 128 | abiDumpPath android.OutputPath |
| 129 | abiDiffPaths android.Paths |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 130 | |
| 131 | apiLevel android.ApiLevel |
| 132 | firstVersion android.ApiLevel |
| 133 | unversionedUntil android.ApiLevel |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 134 | } |
| 135 | |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 136 | var _ versionedInterface = (*stubDecorator)(nil) |
| 137 | |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 138 | func shouldUseVersionScript(ctx BaseModuleContext, stub *stubDecorator) bool { |
| 139 | return stub.apiLevel.GreaterThanOrEqualTo(stub.unversionedUntil) |
Dan Albert | 98dbb3b | 2017-01-03 15:16:29 -0800 | [diff] [blame] | 140 | } |
| 141 | |
Colin Cross | 0477b42 | 2020-10-13 18:43:54 -0700 | [diff] [blame] | 142 | func (stub *stubDecorator) implementationModuleName(name string) string { |
| 143 | return strings.TrimSuffix(name, ndkLibrarySuffix) |
| 144 | } |
| 145 | |
Colin Cross | 3572cf7 | 2020-10-01 15:58:11 -0700 | [diff] [blame] | 146 | func ndkLibraryVersions(ctx android.BaseMutatorContext, from android.ApiLevel) []string { |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 147 | var versions []android.ApiLevel |
| 148 | versionStrs := []string{} |
| 149 | for _, version := range ctx.Config().AllSupportedApiLevels() { |
| 150 | if version.GreaterThanOrEqualTo(from) { |
| 151 | versions = append(versions, version) |
| 152 | versionStrs = append(versionStrs, version.String()) |
| 153 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 154 | } |
Dan Albert | 0b176c8 | 2020-07-23 16:43:25 -0700 | [diff] [blame] | 155 | versionStrs = append(versionStrs, android.FutureApiLevel.String()) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 156 | |
Colin Cross | 5ec407b | 2020-09-30 11:41:33 -0700 | [diff] [blame] | 157 | return versionStrs |
| 158 | } |
| 159 | |
Colin Cross | 3572cf7 | 2020-10-01 15:58:11 -0700 | [diff] [blame] | 160 | func (this *stubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string { |
| 161 | if !ctx.Module().Enabled() { |
| 162 | return nil |
| 163 | } |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 164 | if ctx.Target().NativeBridge == android.NativeBridgeEnabled { |
| 165 | ctx.Module().Disable() |
| 166 | return nil |
| 167 | } |
Colin Cross | 3572cf7 | 2020-10-01 15:58:11 -0700 | [diff] [blame] | 168 | firstVersion, err := nativeApiLevelFromUser(ctx, |
| 169 | String(this.properties.First_version)) |
| 170 | if err != nil { |
| 171 | ctx.PropertyErrorf("first_version", err.Error()) |
| 172 | return nil |
| 173 | } |
| 174 | return ndkLibraryVersions(ctx, firstVersion) |
| 175 | } |
| 176 | |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 177 | func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool { |
Colin Cross | 5ec407b | 2020-09-30 11:41:33 -0700 | [diff] [blame] | 178 | this.apiLevel = nativeApiLevelOrPanic(ctx, this.stubsVersion()) |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 179 | |
| 180 | var err error |
| 181 | this.firstVersion, err = nativeApiLevelFromUser(ctx, |
| 182 | String(this.properties.First_version)) |
| 183 | if err != nil { |
| 184 | ctx.PropertyErrorf("first_version", err.Error()) |
| 185 | return false |
| 186 | } |
| 187 | |
Jiyong Park | ee9b117 | 2021-04-06 17:40:32 +0900 | [diff] [blame] | 188 | str := proptools.StringDefault(this.properties.Unversioned_until, "minimum") |
| 189 | this.unversionedUntil, err = nativeApiLevelFromUser(ctx, str) |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 190 | if err != nil { |
| 191 | ctx.PropertyErrorf("unversioned_until", err.Error()) |
| 192 | return false |
| 193 | } |
| 194 | |
| 195 | return true |
| 196 | } |
| 197 | |
Colin Cross | 95f1ca0 | 2020-10-29 20:47:22 -0700 | [diff] [blame] | 198 | func getNDKKnownLibs(config android.Config) *[]string { |
| 199 | return config.Once(ndkKnownLibsKey, func() interface{} { |
| 200 | return &[]string{} |
| 201 | }).(*[]string) |
| 202 | } |
| 203 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 204 | func (c *stubDecorator) compilerInit(ctx BaseModuleContext) { |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 205 | c.baseCompiler.compilerInit(ctx) |
| 206 | |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 207 | name := ctx.baseModuleName() |
| 208 | if strings.HasSuffix(name, ndkLibrarySuffix) { |
| 209 | ctx.PropertyErrorf("name", "Do not append %q manually, just use the base name", ndkLibrarySuffix) |
| 210 | } |
| 211 | |
Dan Albert | de5aade | 2020-06-30 12:32:51 -0700 | [diff] [blame] | 212 | ndkKnownLibsLock.Lock() |
| 213 | defer ndkKnownLibsLock.Unlock() |
Colin Cross | 95f1ca0 | 2020-10-29 20:47:22 -0700 | [diff] [blame] | 214 | ndkKnownLibs := getNDKKnownLibs(ctx.Config()) |
| 215 | for _, lib := range *ndkKnownLibs { |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 216 | if lib == name { |
| 217 | return |
| 218 | } |
| 219 | } |
Colin Cross | 95f1ca0 | 2020-10-29 20:47:22 -0700 | [diff] [blame] | 220 | *ndkKnownLibs = append(*ndkKnownLibs, name) |
Dan Albert | 7e9d295 | 2016-08-04 13:02:36 -0700 | [diff] [blame] | 221 | } |
| 222 | |
Jingwen Chen | 341f735 | 2022-01-11 05:42:49 +0000 | [diff] [blame] | 223 | var stubLibraryCompilerFlags = []string{ |
| 224 | // We're knowingly doing some otherwise unsightly things with builtin |
| 225 | // functions here. We're just generating stub libraries, so ignore it. |
| 226 | "-Wno-incompatible-library-redeclaration", |
| 227 | "-Wno-incomplete-setjmp-declaration", |
| 228 | "-Wno-builtin-requires-header", |
| 229 | "-Wno-invalid-noreturn", |
| 230 | "-Wall", |
| 231 | "-Werror", |
| 232 | // These libraries aren't actually used. Don't worry about unwinding |
| 233 | // (avoids the need to link an unwinder into a fake library). |
| 234 | "-fno-unwind-tables", |
| 235 | } |
| 236 | |
| 237 | func init() { |
| 238 | config.ExportStringList("StubLibraryCompilerFlags", stubLibraryCompilerFlags) |
| 239 | } |
| 240 | |
George Burgess IV | f5310e3 | 2017-07-19 11:39:53 -0700 | [diff] [blame] | 241 | func addStubLibraryCompilerFlags(flags Flags) Flags { |
Jingwen Chen | 341f735 | 2022-01-11 05:42:49 +0000 | [diff] [blame] | 242 | flags.Global.CFlags = append(flags.Global.CFlags, stubLibraryCompilerFlags...) |
Jiyong Park | 48d75ef | 2019-11-21 15:11:49 +0900 | [diff] [blame] | 243 | // All symbols in the stubs library should be visible. |
| 244 | if inList("-fvisibility=hidden", flags.Local.CFlags) { |
| 245 | flags.Local.CFlags = append(flags.Local.CFlags, "-fvisibility=default") |
| 246 | } |
George Burgess IV | f5310e3 | 2017-07-19 11:39:53 -0700 | [diff] [blame] | 247 | return flags |
| 248 | } |
| 249 | |
Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 250 | func (stub *stubDecorator) compilerFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags { |
| 251 | flags = stub.baseCompiler.compilerFlags(ctx, flags, deps) |
George Burgess IV | f5310e3 | 2017-07-19 11:39:53 -0700 | [diff] [blame] | 252 | return addStubLibraryCompilerFlags(flags) |
| 253 | } |
| 254 | |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 255 | type ndkApiOutputs struct { |
| 256 | stubSrc android.ModuleGenPath |
| 257 | versionScript android.ModuleGenPath |
| 258 | symbolList android.ModuleGenPath |
| 259 | } |
| 260 | |
| 261 | func parseNativeAbiDefinition(ctx ModuleContext, symbolFile string, |
| 262 | apiLevel android.ApiLevel, genstubFlags string) ndkApiOutputs { |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 263 | |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 264 | stubSrcPath := android.PathForModuleGen(ctx, "stub.c") |
| 265 | versionScriptPath := android.PathForModuleGen(ctx, "stub.map") |
| 266 | symbolFilePath := android.PathForModuleSrc(ctx, symbolFile) |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 267 | symbolListPath := android.PathForModuleGen(ctx, "abi_symbol_list.txt") |
Dan Albert | 49927d2 | 2017-03-28 15:00:46 -0700 | [diff] [blame] | 268 | apiLevelsJson := android.GetApiLevelsJson(ctx) |
Colin Cross | ae88703 | 2017-10-23 17:16:14 -0700 | [diff] [blame] | 269 | ctx.Build(pctx, android.BuildParams{ |
Colin Cross | 67a5c13 | 2017-05-09 13:45:28 -0700 | [diff] [blame] | 270 | Rule: genStubSrc, |
| 271 | Description: "generate stubs " + symbolFilePath.Rel(), |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 272 | Outputs: []android.WritablePath{stubSrcPath, versionScriptPath, |
| 273 | symbolListPath}, |
| 274 | Input: symbolFilePath, |
| 275 | Implicits: []android.Path{apiLevelsJson}, |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 276 | Args: map[string]string{ |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 277 | "arch": ctx.Arch().ArchType.String(), |
| 278 | "apiLevel": apiLevel.String(), |
Dan Albert | 49927d2 | 2017-03-28 15:00:46 -0700 | [diff] [blame] | 279 | "apiMap": apiLevelsJson.String(), |
Jiyong Park | 3fd0baf | 2018-12-07 16:25:39 +0900 | [diff] [blame] | 280 | "flags": genstubFlags, |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 281 | }, |
| 282 | }) |
| 283 | |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 284 | return ndkApiOutputs{ |
| 285 | stubSrc: stubSrcPath, |
| 286 | versionScript: versionScriptPath, |
| 287 | symbolList: symbolListPath, |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | func compileStubLibrary(ctx ModuleContext, flags Flags, src android.Path) Objects { |
Mitch Phillips | 4e5f9a1 | 2022-04-29 13:12:28 -0700 | [diff] [blame] | 292 | // libc/libm stubs libraries end up mismatching with clang's internal definition of these |
| 293 | // functions (which have noreturn attributes and other things). Because we just want to create a |
| 294 | // stub with symbol definitions, and types aren't important in C, ignore the mismatch. |
| 295 | flags.Local.ConlyFlags = append(flags.Local.ConlyFlags, "-fno-builtin") |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 296 | return compileObjs(ctx, flagsToBuilderFlags(flags), "", |
Chih-Hung Hsieh | 9db8a0c | 2022-02-17 12:54:45 -0800 | [diff] [blame] | 297 | android.Paths{src}, nil, nil, nil, nil) |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 300 | func (this *stubDecorator) findImplementationLibrary(ctx ModuleContext) android.Path { |
| 301 | dep := ctx.GetDirectDepWithTag(strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix), |
| 302 | stubImplementation) |
| 303 | if dep == nil { |
| 304 | ctx.ModuleErrorf("Could not find implementation for stub") |
| 305 | return nil |
| 306 | } |
| 307 | impl, ok := dep.(*Module) |
| 308 | if !ok { |
| 309 | ctx.ModuleErrorf("Implementation for stub is not correct module type") |
Alan Stokes | 73d3245 | 2022-11-01 14:05:08 +0000 | [diff] [blame] | 310 | return nil |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 311 | } |
| 312 | output := impl.UnstrippedOutputFile() |
| 313 | if output == nil { |
| 314 | ctx.ModuleErrorf("implementation module (%s) has no output", impl) |
| 315 | return nil |
| 316 | } |
| 317 | |
| 318 | return output |
| 319 | } |
| 320 | |
| 321 | func (this *stubDecorator) libraryName(ctx ModuleContext) string { |
| 322 | return strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix) |
| 323 | } |
| 324 | |
| 325 | func (this *stubDecorator) findPrebuiltAbiDump(ctx ModuleContext, |
| 326 | apiLevel android.ApiLevel) android.OptionalPath { |
| 327 | |
| 328 | subpath := filepath.Join("prebuilts/abi-dumps/ndk", apiLevel.String(), |
| 329 | ctx.Arch().ArchType.String(), this.libraryName(ctx), "abi.xml") |
| 330 | return android.ExistentPathForSource(ctx, subpath) |
| 331 | } |
| 332 | |
| 333 | // Feature flag. |
Dan Albert | f71006a | 2022-04-14 23:08:51 +0000 | [diff] [blame] | 334 | func canDumpAbi(config android.Config) bool { |
| 335 | if runtime.GOOS == "darwin" { |
| 336 | return false |
| 337 | } |
| 338 | // abidw doesn't currently handle top-byte-ignore correctly. Disable ABI |
| 339 | // dumping for those configs while we wait for a fix. We'll still have ABI |
| 340 | // checking coverage from non-hwasan builds. |
| 341 | // http://b/190554910 |
| 342 | if android.InList("hwaddress", config.SanitizeDevice()) { |
| 343 | return false |
| 344 | } |
| 345 | return true |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | // Feature flag to disable diffing against prebuilts. |
Dan Albert | ad66593 | 2021-06-07 13:19:49 -0700 | [diff] [blame] | 349 | func canDiffAbi() bool { |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 350 | return false |
| 351 | } |
| 352 | |
| 353 | func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) { |
| 354 | implementationLibrary := this.findImplementationLibrary(ctx) |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 355 | abiRawPath := getNdkAbiDumpInstallBase(ctx).Join(ctx, |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 356 | this.apiLevel.String(), ctx.Arch().ArchType.String(), |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 357 | this.libraryName(ctx), "abi.raw.xml") |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 358 | ctx.Build(pctx, android.BuildParams{ |
| 359 | Rule: abidw, |
| 360 | Description: fmt.Sprintf("abidw %s", implementationLibrary), |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 361 | Input: implementationLibrary, |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 362 | Output: abiRawPath, |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 363 | Implicit: symbolList, |
| 364 | Args: map[string]string{ |
| 365 | "symbolList": symbolList.String(), |
| 366 | }, |
| 367 | }) |
Dan Albert | 604086f | 2021-06-15 13:23:44 -0700 | [diff] [blame] | 368 | |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 369 | this.abiDumpPath = getNdkAbiDumpInstallBase(ctx).Join(ctx, |
| 370 | this.apiLevel.String(), ctx.Arch().ArchType.String(), |
| 371 | this.libraryName(ctx), "abi.xml") |
Dan Albert | 604086f | 2021-06-15 13:23:44 -0700 | [diff] [blame] | 372 | untypedFlag := "--abort-on-untyped-symbols" |
| 373 | if proptools.BoolDefault(this.properties.Allow_untyped_symbols, false) { |
| 374 | untypedFlag = "" |
| 375 | } |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 376 | ctx.Build(pctx, android.BuildParams{ |
| 377 | Rule: abitidy, |
| 378 | Description: fmt.Sprintf("abitidy %s", implementationLibrary), |
| 379 | Input: abiRawPath, |
| 380 | Output: this.abiDumpPath, |
Dan Albert | 604086f | 2021-06-15 13:23:44 -0700 | [diff] [blame] | 381 | Args: map[string]string{ |
| 382 | "flags": untypedFlag, |
| 383 | }, |
Matthias Maennich | c2346f1 | 2021-09-02 20:45:33 +0100 | [diff] [blame] | 384 | }) |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | func findNextApiLevel(ctx ModuleContext, apiLevel android.ApiLevel) *android.ApiLevel { |
| 388 | apiLevels := append(ctx.Config().AllSupportedApiLevels(), |
| 389 | android.FutureApiLevel) |
| 390 | for _, api := range apiLevels { |
| 391 | if api.GreaterThan(apiLevel) { |
| 392 | return &api |
| 393 | } |
| 394 | } |
| 395 | return nil |
| 396 | } |
| 397 | |
| 398 | func (this *stubDecorator) diffAbi(ctx ModuleContext) { |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 399 | // Catch any ABI changes compared to the checked-in definition of this API |
| 400 | // level. |
| 401 | abiDiffPath := android.PathForModuleOut(ctx, "abidiff.timestamp") |
| 402 | prebuiltAbiDump := this.findPrebuiltAbiDump(ctx, this.apiLevel) |
Dan Albert | f7cb563 | 2022-11-29 17:20:16 +0000 | [diff] [blame^] | 403 | missingPrebuiltError := fmt.Sprintf( |
| 404 | "Did not find prebuilt ABI dump for %q (%q). Generate with "+ |
| 405 | "//development/tools/ndk/update_ndk_abi.sh.", this.libraryName(ctx), |
| 406 | prebuiltAbiDump.InvalidReason()) |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 407 | if !prebuiltAbiDump.Valid() { |
| 408 | ctx.Build(pctx, android.BuildParams{ |
| 409 | Rule: android.ErrorRule, |
| 410 | Output: abiDiffPath, |
| 411 | Args: map[string]string{ |
| 412 | "error": missingPrebuiltError, |
| 413 | }, |
| 414 | }) |
| 415 | } else { |
| 416 | ctx.Build(pctx, android.BuildParams{ |
| 417 | Rule: abidiff, |
| 418 | Description: fmt.Sprintf("abidiff %s %s", prebuiltAbiDump, |
| 419 | this.abiDumpPath), |
| 420 | Output: abiDiffPath, |
| 421 | Inputs: android.Paths{prebuiltAbiDump.Path(), this.abiDumpPath}, |
| 422 | }) |
| 423 | } |
| 424 | this.abiDiffPaths = append(this.abiDiffPaths, abiDiffPath) |
| 425 | |
| 426 | // Also ensure that the ABI of the next API level (if there is one) matches |
| 427 | // this API level. *New* ABI is allowed, but any changes to APIs that exist |
| 428 | // in this API level are disallowed. |
| 429 | if !this.apiLevel.IsCurrent() { |
| 430 | nextApiLevel := findNextApiLevel(ctx, this.apiLevel) |
| 431 | if nextApiLevel == nil { |
| 432 | panic(fmt.Errorf("could not determine which API level follows "+ |
| 433 | "non-current API level %s", this.apiLevel)) |
| 434 | } |
| 435 | nextAbiDiffPath := android.PathForModuleOut(ctx, |
| 436 | "abidiff_next.timestamp") |
| 437 | nextAbiDump := this.findPrebuiltAbiDump(ctx, *nextApiLevel) |
| 438 | if !nextAbiDump.Valid() { |
| 439 | ctx.Build(pctx, android.BuildParams{ |
| 440 | Rule: android.ErrorRule, |
| 441 | Output: nextAbiDiffPath, |
| 442 | Args: map[string]string{ |
| 443 | "error": missingPrebuiltError, |
| 444 | }, |
| 445 | }) |
| 446 | } else { |
| 447 | ctx.Build(pctx, android.BuildParams{ |
| 448 | Rule: abidiff, |
| 449 | Description: fmt.Sprintf("abidiff %s %s", this.abiDumpPath, |
| 450 | nextAbiDump), |
| 451 | Output: nextAbiDiffPath, |
| 452 | Inputs: android.Paths{this.abiDumpPath, nextAbiDump.Path()}, |
| 453 | Args: map[string]string{ |
| 454 | "args": "--no-added-syms", |
| 455 | }, |
| 456 | }) |
| 457 | } |
| 458 | this.abiDiffPaths = append(this.abiDiffPaths, nextAbiDiffPath) |
| 459 | } |
| 460 | } |
| 461 | |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 462 | func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { |
Nan Zhang | 0007d81 | 2017-11-07 10:57:05 -0800 | [diff] [blame] | 463 | if !strings.HasSuffix(String(c.properties.Symbol_file), ".map.txt") { |
Dan Albert | 15be0c6 | 2017-06-13 15:14:56 -0700 | [diff] [blame] | 464 | ctx.PropertyErrorf("symbol_file", "must end with .map.txt") |
| 465 | } |
| 466 | |
Colin Cross | 5ec407b | 2020-09-30 11:41:33 -0700 | [diff] [blame] | 467 | if !c.buildStubs() { |
| 468 | // NDK libraries have no implementation variant, nothing to do |
| 469 | return Objects{} |
| 470 | } |
| 471 | |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 472 | if !c.initializeProperties(ctx) { |
| 473 | // Emits its own errors, so we don't need to. |
| 474 | return Objects{} |
| 475 | } |
| 476 | |
sophiez | 58cabb7 | 2020-05-29 13:37:12 -0700 | [diff] [blame] | 477 | symbolFile := String(c.properties.Symbol_file) |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 478 | nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile, c.apiLevel, "") |
| 479 | objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc) |
| 480 | c.versionScriptPath = nativeAbiResult.versionScript |
Dan Albert | f71006a | 2022-04-14 23:08:51 +0000 | [diff] [blame] | 481 | if canDumpAbi(ctx.Config()) { |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 482 | c.dumpAbi(ctx, nativeAbiResult.symbolList) |
Dan Albert | ad66593 | 2021-06-07 13:19:49 -0700 | [diff] [blame] | 483 | if canDiffAbi() { |
Dan Albert | f1d14c7 | 2020-07-30 14:32:55 -0700 | [diff] [blame] | 484 | c.diffAbi(ctx) |
| 485 | } |
| 486 | } |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 487 | if c.apiLevel.IsCurrent() && ctx.PrimaryArch() { |
sophiez | 4c4f803 | 2021-08-16 22:54:00 -0700 | [diff] [blame] | 488 | c.parsedCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile) |
sophiez | 58cabb7 | 2020-05-29 13:37:12 -0700 | [diff] [blame] | 489 | } |
Dan Willemsen | b916b80 | 2017-03-19 13:44:32 -0700 | [diff] [blame] | 490 | return objs |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 491 | } |
| 492 | |
Spandan Das | 73bcafc | 2022-08-18 23:26:00 +0000 | [diff] [blame] | 493 | // Add a dependency on the header modules of this ndk_library |
Colin Cross | 37047f1 | 2016-12-13 17:06:13 -0800 | [diff] [blame] | 494 | func (linker *stubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { |
Spandan Das | 73bcafc | 2022-08-18 23:26:00 +0000 | [diff] [blame] | 495 | return Deps{ |
| 496 | HeaderLibs: linker.properties.Export_header_libs, |
| 497 | } |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 500 | func (linker *stubDecorator) Name(name string) string { |
| 501 | return name + ndkLibrarySuffix |
| 502 | } |
| 503 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 504 | func (stub *stubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { |
Dan Willemsen | 01a9059 | 2017-04-07 15:21:13 -0700 | [diff] [blame] | 505 | stub.libraryDecorator.libName = ctx.baseModuleName() |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 506 | return stub.libraryDecorator.linkerFlags(ctx, flags) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 507 | } |
| 508 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 509 | func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 510 | objs Objects) android.Path { |
Dan Albert | 2bc91ba | 2016-07-28 17:40:28 -0700 | [diff] [blame] | 511 | |
Colin Cross | 5ec407b | 2020-09-30 11:41:33 -0700 | [diff] [blame] | 512 | if !stub.buildStubs() { |
| 513 | // NDK libraries have no implementation variant, nothing to do |
| 514 | return nil |
| 515 | } |
| 516 | |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 517 | if shouldUseVersionScript(ctx, stub) { |
Dan Albert | 98dbb3b | 2017-01-03 15:16:29 -0800 | [diff] [blame] | 518 | linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() |
Colin Cross | 4af21ed | 2019-11-04 09:37:55 -0800 | [diff] [blame] | 519 | flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag) |
Dan Willemsen | 939408a | 2019-06-10 18:02:25 -0700 | [diff] [blame] | 520 | flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) |
Dan Albert | 98dbb3b | 2017-01-03 15:16:29 -0800 | [diff] [blame] | 521 | } |
| 522 | |
Colin Cross | 5ec407b | 2020-09-30 11:41:33 -0700 | [diff] [blame] | 523 | stub.libraryDecorator.skipAPIDefine = true |
Dan Willemsen | 5cb580f | 2016-09-26 17:33:01 -0700 | [diff] [blame] | 524 | return stub.libraryDecorator.link(ctx, flags, deps, objs) |
Dan Albert | 2bc91ba | 2016-07-28 17:40:28 -0700 | [diff] [blame] | 525 | } |
| 526 | |
Pirama Arumuga Nainar | 65c95ff | 2019-03-25 10:21:31 -0700 | [diff] [blame] | 527 | func (stub *stubDecorator) nativeCoverage() bool { |
| 528 | return false |
| 529 | } |
| 530 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 531 | func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) { |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 532 | arch := ctx.Target().Arch.ArchType.Name |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 533 | // arm64 isn't actually a multilib toolchain, so unlike the other LP64 |
| 534 | // architectures it's just installed to lib. |
| 535 | libDir := "lib" |
| 536 | if ctx.toolchain().Is64Bit() && arch != "arm64" { |
| 537 | libDir = "lib64" |
| 538 | } |
| 539 | |
| 540 | installDir := getNdkInstallBase(ctx).Join(ctx, fmt.Sprintf( |
Dan Albert | 1a24627 | 2020-07-06 14:49:35 -0700 | [diff] [blame] | 541 | "platforms/android-%s/arch-%s/usr/%s", stub.apiLevel, arch, libDir)) |
Colin Cross | 0875c52 | 2017-11-28 17:34:01 -0800 | [diff] [blame] | 542 | stub.installPath = ctx.InstallFile(installDir, path.Base(), path) |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 543 | } |
| 544 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 545 | func newStubLibrary() *Module { |
Colin Cross | ab3b732 | 2016-12-09 14:46:15 -0800 | [diff] [blame] | 546 | module, library := NewLibrary(android.DeviceSupported) |
| 547 | library.BuildOnlyShared() |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 548 | module.stl = nil |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 549 | module.sanitize = nil |
ThiƩbaud Weksteen | d458745 | 2020-08-19 14:53:01 +0200 | [diff] [blame] | 550 | library.disableStripping() |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 551 | |
Colin Cross | b916a38 | 2016-07-29 17:28:03 -0700 | [diff] [blame] | 552 | stub := &stubDecorator{ |
| 553 | libraryDecorator: library, |
| 554 | } |
| 555 | module.compiler = stub |
| 556 | module.linker = stub |
| 557 | module.installer = stub |
Colin Cross | 31076b3 | 2020-10-23 17:22:06 -0700 | [diff] [blame] | 558 | module.library = stub |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 559 | |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 560 | module.Properties.AlwaysSdk = true |
| 561 | module.Properties.Sdk_version = StringPtr("current") |
| 562 | |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 563 | module.AddProperties(&stub.properties, &library.MutatedProperties) |
| 564 | |
| 565 | return module |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 566 | } |
| 567 | |
Dan Albert | f740ed0 | 2020-07-24 14:19:06 -0700 | [diff] [blame] | 568 | // ndk_library creates a library that exposes a stub implementation of functions |
| 569 | // and variables for use at build time only. |
Jooyung Han | b90e491 | 2019-12-09 18:21:48 +0900 | [diff] [blame] | 570 | func NdkLibraryFactory() android.Module { |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 571 | module := newStubLibrary() |
| 572 | android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth) |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 573 | android.InitBazelModule(module) |
Colin Cross | 3624285 | 2017-06-23 15:06:31 -0700 | [diff] [blame] | 574 | return module |
Dan Albert | 914449f | 2016-06-17 16:45:24 -0700 | [diff] [blame] | 575 | } |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 576 | |
| 577 | type bazelCcApiContributionAttributes struct { |
| 578 | Api bazel.LabelAttribute |
| 579 | Api_surfaces bazel.StringListAttribute |
| 580 | Hdrs bazel.LabelListAttribute |
| 581 | Library_name string |
| 582 | } |
| 583 | |
| 584 | // Names of the cc_api_header targets in the bp2build workspace |
Spandan Das | 4238c65 | 2022-09-09 01:38:47 +0000 | [diff] [blame] | 585 | func apiHeaderLabels(ctx android.TopDownMutatorContext, hdrLibs []string) bazel.LabelList { |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 586 | addSuffix := func(ctx android.BazelConversionPathContext, module blueprint.Module) string { |
| 587 | label := android.BazelModuleLabel(ctx, module) |
| 588 | return android.ApiContributionTargetName(label) |
| 589 | } |
Spandan Das | 4238c65 | 2022-09-09 01:38:47 +0000 | [diff] [blame] | 590 | return android.BazelLabelForModuleDepsWithFn(ctx, hdrLibs, addSuffix) |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | func ndkLibraryBp2build(ctx android.TopDownMutatorContext, m *Module) { |
| 594 | props := bazel.BazelTargetModuleProperties{ |
| 595 | Rule_class: "cc_api_contribution", |
| 596 | Bzl_load_location: "//build/bazel/rules/apis:cc_api_contribution.bzl", |
| 597 | } |
| 598 | stubLibrary := m.compiler.(*stubDecorator) |
| 599 | attrs := &bazelCcApiContributionAttributes{ |
| 600 | Library_name: stubLibrary.implementationModuleName(m.Name()), |
| 601 | Api_surfaces: bazel.MakeStringListAttribute( |
| 602 | []string{android.PublicApi.String()}), |
| 603 | } |
| 604 | if symbolFile := stubLibrary.properties.Symbol_file; symbolFile != nil { |
| 605 | apiLabel := android.BazelLabelForModuleSrcSingle(ctx, proptools.String(symbolFile)).Label |
| 606 | attrs.Api = *bazel.MakeLabelAttribute(apiLabel) |
| 607 | } |
Spandan Das | 4238c65 | 2022-09-09 01:38:47 +0000 | [diff] [blame] | 608 | apiHeaders := apiHeaderLabels(ctx, stubLibrary.properties.Export_header_libs) |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 609 | attrs.Hdrs = bazel.MakeLabelListAttribute(apiHeaders) |
| 610 | apiContributionTargetName := android.ApiContributionTargetName(ctx.ModuleName()) |
| 611 | ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: apiContributionTargetName}, attrs) |
| 612 | } |