Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 1 | // Copyright 2018 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 java |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 19 | "fmt" |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 20 | "strings" |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 21 | |
| 22 | "github.com/google/blueprint" |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 23 | "github.com/google/blueprint/proptools" |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 24 | ) |
| 25 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 26 | type AndroidLibraryDependency interface { |
| 27 | Dependency |
| 28 | ExportPackage() android.Path |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 29 | ExportedProguardFlagFiles() android.Paths |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 30 | ExportedRRODirs() android.Paths |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 31 | ExportedStaticPackages() android.Paths |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 32 | ExportedManifest() android.Path |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | func init() { |
| 36 | android.RegisterModuleType("android_library_import", AARImportFactory) |
| 37 | android.RegisterModuleType("android_library", AndroidLibraryFactory) |
| 38 | } |
| 39 | |
| 40 | // |
| 41 | // AAR (android library) |
| 42 | // |
| 43 | |
| 44 | type androidLibraryProperties struct { |
| 45 | BuildAAR bool `blueprint:"mutated"` |
| 46 | } |
| 47 | |
| 48 | type aaptProperties struct { |
| 49 | // flags passed to aapt when creating the apk |
| 50 | Aaptflags []string |
| 51 | |
Dan Willemsen | 72be590 | 2018-10-24 20:24:57 -0700 | [diff] [blame] | 52 | // include all resource configurations, not just the product-configured |
| 53 | // ones. |
| 54 | Aapt_include_all_resources *bool |
| 55 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 56 | // list of directories relative to the Blueprints file containing assets. |
Colin Cross | 0ddae7f | 2019-02-07 15:30:01 -0800 | [diff] [blame] | 57 | // Defaults to ["assets"] if a directory called assets exists. Set to [] |
| 58 | // to disable the default. |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 59 | Asset_dirs []string |
| 60 | |
| 61 | // list of directories relative to the Blueprints file containing |
Colin Cross | 0ddae7f | 2019-02-07 15:30:01 -0800 | [diff] [blame] | 62 | // Android resources. Defaults to ["res"] if a directory called res exists. |
| 63 | // Set to [] to disable the default. |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 64 | Resource_dirs []string |
| 65 | |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 66 | // list of zip files containing Android resources. |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 67 | Resource_zips []string `android:"path"` |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 68 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 69 | // path to AndroidManifest.xml. If unset, defaults to "AndroidManifest.xml". |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 70 | Manifest *string `android:"path"` |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | type aapt struct { |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 74 | aaptSrcJar android.Path |
| 75 | exportPackage android.Path |
| 76 | manifestPath android.Path |
| 77 | proguardOptionsFile android.Path |
| 78 | rroDirs android.Paths |
| 79 | rTxt android.Path |
| 80 | extraAaptPackagesFile android.Path |
Colin Cross | 1b6a3cf | 2018-07-24 14:51:30 -0700 | [diff] [blame] | 81 | isLibrary bool |
Colin Cross | e4246ab | 2019-02-05 21:55:21 -0800 | [diff] [blame] | 82 | uncompressedJNI bool |
Colin Cross | 46abdad | 2019-02-07 13:07:08 -0800 | [diff] [blame] | 83 | useEmbeddedDex bool |
David Brazdil | d25060a | 2019-02-18 18:24:16 +0000 | [diff] [blame] | 84 | usesNonSdkApis bool |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 85 | |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 86 | splitNames []string |
| 87 | splits []split |
| 88 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 89 | aaptProperties aaptProperties |
| 90 | } |
| 91 | |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 92 | type split struct { |
| 93 | name string |
| 94 | suffix string |
| 95 | path android.Path |
| 96 | } |
| 97 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 98 | func (a *aapt) ExportPackage() android.Path { |
| 99 | return a.exportPackage |
| 100 | } |
| 101 | |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 102 | func (a *aapt) ExportedRRODirs() android.Paths { |
| 103 | return a.rroDirs |
| 104 | } |
| 105 | |
| 106 | func (a *aapt) ExportedManifest() android.Path { |
| 107 | return a.manifestPath |
| 108 | } |
| 109 | |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 110 | func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, manifestPath android.Path) (flags []string, |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 111 | deps android.Paths, resDirs, overlayDirs []globbedResourceDir, rroDirs, resZips android.Paths) { |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 112 | |
| 113 | hasVersionCode := false |
| 114 | hasVersionName := false |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 115 | for _, f := range a.aaptProperties.Aaptflags { |
| 116 | if strings.HasPrefix(f, "--version-code") { |
| 117 | hasVersionCode = true |
| 118 | } else if strings.HasPrefix(f, "--version-name") { |
| 119 | hasVersionName = true |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | |
| 123 | var linkFlags []string |
| 124 | |
| 125 | // Flags specified in Android.bp |
| 126 | linkFlags = append(linkFlags, a.aaptProperties.Aaptflags...) |
| 127 | |
| 128 | linkFlags = append(linkFlags, "--no-static-lib-packages") |
| 129 | |
| 130 | // Find implicit or explicit asset and resource dirs |
| 131 | assetDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Asset_dirs, "assets") |
| 132 | resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res") |
Colin Cross | 8a49795 | 2019-03-05 22:25:09 -0800 | [diff] [blame] | 133 | resourceZips := android.PathsForModuleSrc(ctx, a.aaptProperties.Resource_zips) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 134 | |
| 135 | var linkDeps android.Paths |
| 136 | |
| 137 | // Glob directories into lists of paths |
| 138 | for _, dir := range resourceDirs { |
| 139 | resDirs = append(resDirs, globbedResourceDir{ |
| 140 | dir: dir, |
| 141 | files: androidResourceGlob(ctx, dir), |
| 142 | }) |
| 143 | resOverlayDirs, resRRODirs := overlayResourceGlob(ctx, dir) |
| 144 | overlayDirs = append(overlayDirs, resOverlayDirs...) |
| 145 | rroDirs = append(rroDirs, resRRODirs...) |
| 146 | } |
| 147 | |
| 148 | var assetFiles android.Paths |
| 149 | for _, dir := range assetDirs { |
| 150 | assetFiles = append(assetFiles, androidResourceGlob(ctx, dir)...) |
| 151 | } |
| 152 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 153 | linkFlags = append(linkFlags, "--manifest "+manifestPath.String()) |
| 154 | linkDeps = append(linkDeps, manifestPath) |
| 155 | |
| 156 | linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A ")) |
| 157 | linkDeps = append(linkDeps, assetFiles...) |
| 158 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 159 | // SDK version flags |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 160 | minSdkVersion := sdkVersionOrDefault(ctx, sdkContext.minSdkVersion()) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 161 | |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 162 | linkFlags = append(linkFlags, "--min-sdk-version "+minSdkVersion) |
| 163 | linkFlags = append(linkFlags, "--target-sdk-version "+minSdkVersion) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 164 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 165 | // Version code |
| 166 | if !hasVersionCode { |
| 167 | linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion()) |
| 168 | } |
| 169 | |
| 170 | if !hasVersionName { |
Colin Cross | 402d5e0 | 2018-04-25 14:54:06 -0700 | [diff] [blame] | 171 | var versionName string |
| 172 | if ctx.ModuleName() == "framework-res" { |
| 173 | // Some builds set AppsDefaultVersionName() to include the build number ("O-123456"). aapt2 copies the |
| 174 | // version name of framework-res into app manifests as compileSdkVersionCodename, which confuses things |
Colin Cross | bfd347d | 2018-05-09 11:11:35 -0700 | [diff] [blame] | 175 | // if it contains the build number. Use the PlatformVersionName instead. |
| 176 | versionName = ctx.Config().PlatformVersionName() |
Colin Cross | 402d5e0 | 2018-04-25 14:54:06 -0700 | [diff] [blame] | 177 | } else { |
| 178 | versionName = ctx.Config().AppsDefaultVersionName() |
| 179 | } |
Colin Cross | 0b9f31f | 2019-02-28 11:00:01 -0800 | [diff] [blame] | 180 | versionName = proptools.NinjaEscape(versionName) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 181 | linkFlags = append(linkFlags, "--version-name ", versionName) |
| 182 | } |
| 183 | |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 184 | return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resourceZips |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 187 | func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkContext sdkContext) { |
Colin Cross | 42308aa | 2018-11-14 21:44:17 -0800 | [diff] [blame] | 188 | sdkDep := decodeSdkDep(ctx, sdkContext) |
| 189 | if sdkDep.frameworkResModule != "" { |
| 190 | ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 194 | func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, extraLinkFlags ...string) { |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 195 | transitiveStaticLibs, staticLibManifests, staticRRODirs, libDeps, libFlags := aaptLibs(ctx, sdkContext) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 196 | |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 197 | // App manifest file |
| 198 | manifestFile := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml") |
| 199 | manifestSrcPath := android.PathForModuleSrc(ctx, manifestFile) |
| 200 | |
Colin Cross | 46abdad | 2019-02-07 13:07:08 -0800 | [diff] [blame] | 201 | manifestPath := manifestMerger(ctx, manifestSrcPath, sdkContext, staticLibManifests, a.isLibrary, |
David Brazdil | d25060a | 2019-02-18 18:24:16 +0000 | [diff] [blame] | 202 | a.uncompressedJNI, a.useEmbeddedDex, a.usesNonSdkApis) |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 203 | |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 204 | linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, sdkContext, manifestPath) |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 205 | |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 206 | rroDirs = append(rroDirs, staticRRODirs...) |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 207 | linkFlags = append(linkFlags, libFlags...) |
| 208 | linkDeps = append(linkDeps, libDeps...) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 209 | linkFlags = append(linkFlags, extraLinkFlags...) |
Colin Cross | 1b6a3cf | 2018-07-24 14:51:30 -0700 | [diff] [blame] | 210 | if a.isLibrary { |
| 211 | linkFlags = append(linkFlags, "--static-lib") |
| 212 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 213 | |
| 214 | packageRes := android.PathForModuleOut(ctx, "package-res.apk") |
| 215 | srcJar := android.PathForModuleGen(ctx, "R.jar") |
| 216 | proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options") |
| 217 | rTxt := android.PathForModuleOut(ctx, "R.txt") |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 218 | // This file isn't used by Soong, but is generated for exporting |
| 219 | extraPackages := android.PathForModuleOut(ctx, "extra_packages") |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 220 | |
Colin Cross | 4aaa84a | 2018-08-21 15:14:37 -0700 | [diff] [blame] | 221 | var compiledResDirs []android.Paths |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 222 | for _, dir := range resDirs { |
Colin Cross | 4aaa84a | 2018-08-21 15:14:37 -0700 | [diff] [blame] | 223 | compiledResDirs = append(compiledResDirs, aapt2Compile(ctx, dir.dir, dir.files).Paths()) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 224 | } |
Colin Cross | 4aaa84a | 2018-08-21 15:14:37 -0700 | [diff] [blame] | 225 | |
Colin Cross | a592e3e | 2019-02-19 16:59:53 -0800 | [diff] [blame] | 226 | for i, zip := range resZips { |
| 227 | flata := android.PathForModuleOut(ctx, fmt.Sprintf("reszip.%d.flata", i)) |
| 228 | aapt2CompileZip(ctx, flata, zip) |
| 229 | compiledResDirs = append(compiledResDirs, android.Paths{flata}) |
| 230 | } |
| 231 | |
Colin Cross | 4aaa84a | 2018-08-21 15:14:37 -0700 | [diff] [blame] | 232 | var compiledRes, compiledOverlay android.Paths |
| 233 | |
| 234 | compiledOverlay = append(compiledOverlay, transitiveStaticLibs...) |
| 235 | |
Colin Cross | bec8530 | 2019-02-13 13:15:46 -0800 | [diff] [blame] | 236 | if len(transitiveStaticLibs) > 0 { |
Colin Cross | 4aaa84a | 2018-08-21 15:14:37 -0700 | [diff] [blame] | 237 | // If we are using static android libraries, every source file becomes an overlay. |
| 238 | // This is to emulate old AAPT behavior which simulated library support. |
| 239 | for _, compiledResDir := range compiledResDirs { |
| 240 | compiledOverlay = append(compiledOverlay, compiledResDir...) |
| 241 | } |
Colin Cross | bec8530 | 2019-02-13 13:15:46 -0800 | [diff] [blame] | 242 | } else if a.isLibrary { |
| 243 | // Otherwise, for a static library we treat all the resources equally with no overlay. |
| 244 | for _, compiledResDir := range compiledResDirs { |
| 245 | compiledRes = append(compiledRes, compiledResDir...) |
| 246 | } |
Colin Cross | 4aaa84a | 2018-08-21 15:14:37 -0700 | [diff] [blame] | 247 | } else if len(compiledResDirs) > 0 { |
| 248 | // Without static libraries, the first directory is our directory, which can then be |
| 249 | // overlaid by the rest. |
| 250 | compiledRes = append(compiledRes, compiledResDirs[0]...) |
| 251 | for _, compiledResDir := range compiledResDirs[1:] { |
| 252 | compiledOverlay = append(compiledOverlay, compiledResDir...) |
| 253 | } |
| 254 | } |
| 255 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 256 | for _, dir := range overlayDirs { |
| 257 | compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files).Paths()...) |
| 258 | } |
| 259 | |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 260 | var splitPackages android.WritablePaths |
| 261 | var splits []split |
| 262 | |
| 263 | for _, s := range a.splitNames { |
| 264 | suffix := strings.Replace(s, ",", "_", -1) |
| 265 | path := android.PathForModuleOut(ctx, "package_"+suffix+".apk") |
| 266 | linkFlags = append(linkFlags, "--split", path.String()+":"+s) |
| 267 | splitPackages = append(splitPackages, path) |
| 268 | splits = append(splits, split{ |
| 269 | name: s, |
| 270 | suffix: suffix, |
| 271 | path: path, |
| 272 | }) |
| 273 | } |
| 274 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 275 | aapt2Link(ctx, packageRes, srcJar, proguardOptionsFile, rTxt, extraPackages, |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 276 | linkFlags, linkDeps, compiledRes, compiledOverlay, splitPackages) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 277 | |
| 278 | a.aaptSrcJar = srcJar |
| 279 | a.exportPackage = packageRes |
| 280 | a.manifestPath = manifestPath |
| 281 | a.proguardOptionsFile = proguardOptionsFile |
| 282 | a.rroDirs = rroDirs |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 283 | a.extraAaptPackagesFile = extraPackages |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 284 | a.rTxt = rTxt |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 285 | a.splits = splits |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | // aaptLibs collects libraries from dependencies and sdk_version and converts them into paths |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 289 | func aaptLibs(ctx android.ModuleContext, sdkContext sdkContext) (transitiveStaticLibs, staticLibManifests, |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 290 | staticRRODirs, deps android.Paths, flags []string) { |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 291 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 292 | var sharedLibs android.Paths |
| 293 | |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 294 | sdkDep := decodeSdkDep(ctx, sdkContext) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 295 | if sdkDep.useFiles { |
Colin Cross | 86a60ae | 2018-05-29 14:44:55 -0700 | [diff] [blame] | 296 | sharedLibs = append(sharedLibs, sdkDep.jars...) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | ctx.VisitDirectDeps(func(module android.Module) { |
| 300 | var exportPackage android.Path |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 301 | aarDep, _ := module.(AndroidLibraryDependency) |
| 302 | if aarDep != nil { |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 303 | exportPackage = aarDep.ExportPackage() |
| 304 | } |
| 305 | |
| 306 | switch ctx.OtherModuleDependencyTag(module) { |
Colin Cross | 4b964c0 | 2018-10-15 16:18:06 -0700 | [diff] [blame] | 307 | case instrumentationForTag: |
| 308 | // Nothing, instrumentationForTag is treated as libTag for javac but not for aapt2. |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 309 | case libTag, frameworkResTag: |
| 310 | if exportPackage != nil { |
| 311 | sharedLibs = append(sharedLibs, exportPackage) |
| 312 | } |
| 313 | case staticLibTag: |
| 314 | if exportPackage != nil { |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 315 | transitiveStaticLibs = append(transitiveStaticLibs, aarDep.ExportedStaticPackages()...) |
Colin Cross | bec8530 | 2019-02-13 13:15:46 -0800 | [diff] [blame] | 316 | transitiveStaticLibs = append(transitiveStaticLibs, exportPackage) |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 317 | staticLibManifests = append(staticLibManifests, aarDep.ExportedManifest()) |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 318 | staticRRODirs = append(staticRRODirs, aarDep.ExportedRRODirs()...) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | }) |
| 322 | |
| 323 | deps = append(deps, sharedLibs...) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 324 | deps = append(deps, transitiveStaticLibs...) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 325 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 326 | if len(transitiveStaticLibs) > 0 { |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 327 | flags = append(flags, "--auto-add-overlay") |
| 328 | } |
| 329 | |
| 330 | for _, sharedLib := range sharedLibs { |
| 331 | flags = append(flags, "-I "+sharedLib.String()) |
| 332 | } |
| 333 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 334 | transitiveStaticLibs = android.FirstUniquePaths(transitiveStaticLibs) |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 335 | staticRRODirs = android.FirstUniquePaths(staticRRODirs) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 336 | |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 337 | return transitiveStaticLibs, staticLibManifests, staticRRODirs, deps, flags |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | type AndroidLibrary struct { |
| 341 | Library |
| 342 | aapt |
| 343 | |
| 344 | androidLibraryProperties androidLibraryProperties |
| 345 | |
| 346 | aarFile android.WritablePath |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 347 | |
| 348 | exportedProguardFlagFiles android.Paths |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 349 | exportedStaticPackages android.Paths |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | func (a *AndroidLibrary) ExportedProguardFlagFiles() android.Paths { |
| 353 | return a.exportedProguardFlagFiles |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 354 | } |
| 355 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 356 | func (a *AndroidLibrary) ExportedStaticPackages() android.Paths { |
| 357 | return a.exportedStaticPackages |
| 358 | } |
| 359 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 360 | var _ AndroidLibraryDependency = (*AndroidLibrary)(nil) |
| 361 | |
| 362 | func (a *AndroidLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { |
| 363 | a.Module.deps(ctx) |
| 364 | if !Bool(a.properties.No_framework_libs) && !Bool(a.properties.No_standard_libs) { |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 365 | a.aapt.deps(ctx, sdkContext(a)) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 366 | } |
| 367 | } |
| 368 | |
| 369 | func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
Colin Cross | e4246ab | 2019-02-05 21:55:21 -0800 | [diff] [blame] | 370 | a.aapt.isLibrary = true |
Colin Cross | 1b6a3cf | 2018-07-24 14:51:30 -0700 | [diff] [blame] | 371 | a.aapt.buildActions(ctx, sdkContext(a)) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 372 | |
| 373 | ctx.CheckbuildFile(a.proguardOptionsFile) |
| 374 | ctx.CheckbuildFile(a.exportPackage) |
| 375 | ctx.CheckbuildFile(a.aaptSrcJar) |
| 376 | |
| 377 | // apps manifests are handled by aapt, don't let Module see them |
| 378 | a.properties.Manifest = nil |
| 379 | |
| 380 | a.Module.extraProguardFlagFiles = append(a.Module.extraProguardFlagFiles, |
| 381 | a.proguardOptionsFile) |
| 382 | |
| 383 | a.Module.compile(ctx, a.aaptSrcJar) |
| 384 | |
Colin Cross | f57c578 | 2019-01-25 13:20:38 -0800 | [diff] [blame] | 385 | a.aarFile = android.PathForModuleOut(ctx, ctx.ModuleName()+".aar") |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 386 | var res android.Paths |
| 387 | if a.androidLibraryProperties.BuildAAR { |
| 388 | BuildAAR(ctx, a.aarFile, a.outputFile, a.manifestPath, a.rTxt, res) |
| 389 | ctx.CheckbuildFile(a.aarFile) |
| 390 | } |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 391 | |
| 392 | ctx.VisitDirectDeps(func(m android.Module) { |
| 393 | if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag { |
| 394 | a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 395 | a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportPackage()) |
| 396 | a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportedStaticPackages()...) |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 397 | } |
| 398 | }) |
| 399 | |
| 400 | a.exportedProguardFlagFiles = android.FirstUniquePaths(a.exportedProguardFlagFiles) |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 401 | a.exportedStaticPackages = android.FirstUniquePaths(a.exportedStaticPackages) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 404 | // android_library builds and links sources into a `.jar` file for the device along with Android resources. |
| 405 | // |
| 406 | // An android_library has a single variant that produces a `.jar` file containing `.class` files that were |
| 407 | // compiled against the device bootclasspath, along with a `package-res.apk` file containing Android resources compiled |
| 408 | // with aapt2. This module is not suitable for installing on a device, but can be used as a `static_libs` dependency of |
| 409 | // an android_app module. |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 410 | func AndroidLibraryFactory() android.Module { |
| 411 | module := &AndroidLibrary{} |
| 412 | |
| 413 | module.AddProperties( |
| 414 | &module.Module.properties, |
| 415 | &module.Module.deviceProperties, |
Colin Cross | 43f08db | 2018-11-12 10:13:39 -0800 | [diff] [blame] | 416 | &module.Module.dexpreoptProperties, |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 417 | &module.Module.protoProperties, |
| 418 | &module.aaptProperties, |
| 419 | &module.androidLibraryProperties) |
| 420 | |
| 421 | module.androidLibraryProperties.BuildAAR = true |
| 422 | |
Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 423 | InitJavaModule(module, android.DeviceSupported) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 424 | return module |
| 425 | } |
| 426 | |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 427 | // |
| 428 | // AAR (android library) prebuilts |
| 429 | // |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 430 | |
| 431 | type AARImportProperties struct { |
Colin Cross | 27b922f | 2019-03-04 22:35:41 -0800 | [diff] [blame] | 432 | Aars []string `android:"path"` |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 433 | |
Colin Cross | 479884c | 2018-07-10 13:39:30 -0700 | [diff] [blame] | 434 | Sdk_version *string |
| 435 | Min_sdk_version *string |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 436 | |
| 437 | Static_libs []string |
| 438 | Libs []string |
Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 439 | |
| 440 | // if set to true, run Jetifier against .aar file. Defaults to false. |
| 441 | Jetifier_enabled *bool |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | type AARImport struct { |
| 445 | android.ModuleBase |
Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 446 | android.DefaultableModuleBase |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 447 | prebuilt android.Prebuilt |
| 448 | |
| 449 | properties AARImportProperties |
| 450 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 451 | classpathFile android.WritablePath |
| 452 | proguardFlags android.WritablePath |
| 453 | exportPackage android.WritablePath |
| 454 | extraAaptPackagesFile android.WritablePath |
Colin Cross | 10f7c4a | 2018-05-23 10:59:28 -0700 | [diff] [blame] | 455 | manifest android.WritablePath |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 456 | |
| 457 | exportedStaticPackages android.Paths |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 458 | } |
| 459 | |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 460 | func (a *AARImport) sdkVersion() string { |
| 461 | return String(a.properties.Sdk_version) |
| 462 | } |
| 463 | |
| 464 | func (a *AARImport) minSdkVersion() string { |
Colin Cross | 479884c | 2018-07-10 13:39:30 -0700 | [diff] [blame] | 465 | if a.properties.Min_sdk_version != nil { |
| 466 | return *a.properties.Min_sdk_version |
| 467 | } |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 468 | return a.sdkVersion() |
| 469 | } |
| 470 | |
Dan Willemsen | 419290a | 2018-10-31 15:28:47 -0700 | [diff] [blame] | 471 | func (a *AARImport) targetSdkVersion() string { |
| 472 | return a.sdkVersion() |
| 473 | } |
| 474 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 475 | var _ AndroidLibraryDependency = (*AARImport)(nil) |
| 476 | |
| 477 | func (a *AARImport) ExportPackage() android.Path { |
| 478 | return a.exportPackage |
| 479 | } |
| 480 | |
Colin Cross | 89c3158 | 2018-04-30 15:55:11 -0700 | [diff] [blame] | 481 | func (a *AARImport) ExportedProguardFlagFiles() android.Paths { |
| 482 | return android.Paths{a.proguardFlags} |
| 483 | } |
| 484 | |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 485 | func (a *AARImport) ExportedRRODirs() android.Paths { |
| 486 | return nil |
| 487 | } |
| 488 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 489 | func (a *AARImport) ExportedStaticPackages() android.Paths { |
| 490 | return a.exportedStaticPackages |
| 491 | } |
| 492 | |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 493 | func (a *AARImport) ExportedManifest() android.Path { |
| 494 | return a.manifest |
| 495 | } |
| 496 | |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 497 | func (a *AARImport) Prebuilt() *android.Prebuilt { |
| 498 | return &a.prebuilt |
| 499 | } |
| 500 | |
| 501 | func (a *AARImport) Name() string { |
| 502 | return a.prebuilt.Name(a.ModuleBase.Name()) |
| 503 | } |
| 504 | |
| 505 | func (a *AARImport) DepsMutator(ctx android.BottomUpMutatorContext) { |
Colin Cross | 1f367bf | 2018-12-18 22:46:24 -0800 | [diff] [blame] | 506 | if !ctx.Config().UnbundledBuildPrebuiltSdks() { |
Colin Cross | 83bb316 | 2018-06-25 15:48:06 -0700 | [diff] [blame] | 507 | sdkDep := decodeSdkDep(ctx, sdkContext(a)) |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 508 | if sdkDep.useModule && sdkDep.frameworkResModule != "" { |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 509 | ctx.AddVariationDependencies(nil, frameworkResTag, sdkDep.frameworkResModule) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 510 | } |
| 511 | } |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 512 | |
Colin Cross | 42d48b7 | 2018-08-29 14:10:52 -0700 | [diff] [blame] | 513 | ctx.AddVariationDependencies(nil, libTag, a.properties.Libs...) |
| 514 | ctx.AddVariationDependencies(nil, staticLibTag, a.properties.Static_libs...) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 515 | } |
| 516 | |
| 517 | // Unzip an AAR into its constituent files and directories. Any files in Outputs that don't exist in the AAR will be |
| 518 | // touched to create an empty file, and any directories in $expectedDirs will be created. |
| 519 | var unzipAAR = pctx.AndroidStaticRule("unzipAAR", |
| 520 | blueprint.RuleParams{ |
| 521 | Command: `rm -rf $outDir && mkdir -p $outDir $expectedDirs && ` + |
| 522 | `unzip -qo -d $outDir $in && touch $out`, |
| 523 | }, |
| 524 | "expectedDirs", "outDir") |
| 525 | |
| 526 | func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 527 | if len(a.properties.Aars) != 1 { |
| 528 | ctx.PropertyErrorf("aars", "exactly one aar is required") |
| 529 | return |
| 530 | } |
| 531 | |
Nan Zhang | 4c819fb | 2018-08-27 18:31:46 -0700 | [diff] [blame] | 532 | aarName := ctx.ModuleName() + ".aar" |
| 533 | var aar android.Path |
| 534 | aar = android.PathForModuleSrc(ctx, a.properties.Aars[0]) |
| 535 | if Bool(a.properties.Jetifier_enabled) { |
| 536 | inputFile := aar |
| 537 | aar = android.PathForModuleOut(ctx, "jetifier", aarName) |
| 538 | TransformJetifier(ctx, aar.(android.WritablePath), inputFile) |
| 539 | } |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 540 | |
| 541 | extractedAARDir := android.PathForModuleOut(ctx, "aar") |
| 542 | extractedResDir := extractedAARDir.Join(ctx, "res") |
| 543 | a.classpathFile = extractedAARDir.Join(ctx, "classes.jar") |
| 544 | a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt") |
Colin Cross | 10f7c4a | 2018-05-23 10:59:28 -0700 | [diff] [blame] | 545 | a.manifest = extractedAARDir.Join(ctx, "AndroidManifest.xml") |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 546 | |
| 547 | ctx.Build(pctx, android.BuildParams{ |
| 548 | Rule: unzipAAR, |
| 549 | Input: aar, |
Colin Cross | 10f7c4a | 2018-05-23 10:59:28 -0700 | [diff] [blame] | 550 | Outputs: android.WritablePaths{a.classpathFile, a.proguardFlags, a.manifest}, |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 551 | Description: "unzip AAR", |
| 552 | Args: map[string]string{ |
| 553 | "expectedDirs": extractedResDir.String(), |
| 554 | "outDir": extractedAARDir.String(), |
| 555 | }, |
| 556 | }) |
| 557 | |
| 558 | compiledResDir := android.PathForModuleOut(ctx, "flat-res") |
| 559 | aaptCompileDeps := android.Paths{a.classpathFile} |
| 560 | aaptCompileDirs := android.Paths{extractedResDir} |
| 561 | flata := compiledResDir.Join(ctx, "gen_res.flata") |
| 562 | aapt2CompileDirs(ctx, flata, aaptCompileDirs, aaptCompileDeps) |
| 563 | |
| 564 | a.exportPackage = android.PathForModuleOut(ctx, "package-res.apk") |
| 565 | srcJar := android.PathForModuleGen(ctx, "R.jar") |
| 566 | proguardOptionsFile := android.PathForModuleGen(ctx, "proguard.options") |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 567 | rTxt := android.PathForModuleOut(ctx, "R.txt") |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 568 | a.extraAaptPackagesFile = android.PathForModuleOut(ctx, "extra_packages") |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 569 | |
| 570 | var linkDeps android.Paths |
| 571 | |
| 572 | linkFlags := []string{ |
| 573 | "--static-lib", |
| 574 | "--no-static-lib-packages", |
| 575 | "--auto-add-overlay", |
| 576 | } |
| 577 | |
Colin Cross | 10f7c4a | 2018-05-23 10:59:28 -0700 | [diff] [blame] | 578 | linkFlags = append(linkFlags, "--manifest "+a.manifest.String()) |
| 579 | linkDeps = append(linkDeps, a.manifest) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 580 | |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 581 | transitiveStaticLibs, staticLibManifests, staticRRODirs, libDeps, libFlags := aaptLibs(ctx, sdkContext(a)) |
Colin Cross | 3165695 | 2018-05-24 16:11:20 -0700 | [diff] [blame] | 582 | |
| 583 | _ = staticLibManifests |
Colin Cross | c1c3755 | 2019-01-31 11:42:41 -0800 | [diff] [blame] | 584 | _ = staticRRODirs |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 585 | |
Colin Cross | a97c5d3 | 2018-03-28 14:58:31 -0700 | [diff] [blame] | 586 | linkDeps = append(linkDeps, libDeps...) |
| 587 | linkFlags = append(linkFlags, libFlags...) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 588 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 589 | overlayRes := append(android.Paths{flata}, transitiveStaticLibs...) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 590 | |
Colin Cross | 66f7882 | 2018-05-02 12:58:28 -0700 | [diff] [blame] | 591 | aapt2Link(ctx, a.exportPackage, srcJar, proguardOptionsFile, rTxt, a.extraAaptPackagesFile, |
Colin Cross | e560c4a | 2019-03-19 16:03:11 -0700 | [diff] [blame] | 592 | linkFlags, linkDeps, nil, overlayRes, nil) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | var _ Dependency = (*AARImport)(nil) |
| 596 | |
| 597 | func (a *AARImport) HeaderJars() android.Paths { |
| 598 | return android.Paths{a.classpathFile} |
| 599 | } |
| 600 | |
| 601 | func (a *AARImport) ImplementationJars() android.Paths { |
| 602 | return android.Paths{a.classpathFile} |
| 603 | } |
| 604 | |
Colin Cross | 331a121 | 2018-08-15 20:40:52 -0700 | [diff] [blame] | 605 | func (a *AARImport) ResourceJars() android.Paths { |
| 606 | return nil |
| 607 | } |
| 608 | |
| 609 | func (a *AARImport) ImplementationAndResourcesJars() android.Paths { |
| 610 | return android.Paths{a.classpathFile} |
| 611 | } |
| 612 | |
Colin Cross | f24a22a | 2019-01-31 14:12:44 -0800 | [diff] [blame] | 613 | func (a *AARImport) DexJar() android.Path { |
| 614 | return nil |
| 615 | } |
| 616 | |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 617 | func (a *AARImport) AidlIncludeDirs() android.Paths { |
| 618 | return nil |
| 619 | } |
| 620 | |
Jiyong Park | 1be9691 | 2018-05-28 18:02:19 +0900 | [diff] [blame] | 621 | func (a *AARImport) ExportedSdkLibs() []string { |
| 622 | return nil |
| 623 | } |
| 624 | |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 625 | var _ android.PrebuiltInterface = (*Import)(nil) |
| 626 | |
Colin Cross | 1b16b0e | 2019-02-12 14:41:32 -0800 | [diff] [blame] | 627 | // android_library_import imports an `.aar` file into the build graph as if it was built with android_library. |
| 628 | // |
| 629 | // This module is not suitable for installing on a device, but can be used as a `static_libs` dependency of |
| 630 | // an android_app module. |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 631 | func AARImportFactory() android.Module { |
| 632 | module := &AARImport{} |
| 633 | |
| 634 | module.AddProperties(&module.properties) |
| 635 | |
| 636 | android.InitPrebuiltModule(module, &module.properties.Aars) |
Colin Cross | 48de9a4 | 2018-10-02 13:53:33 -0700 | [diff] [blame] | 637 | InitJavaModule(module, android.DeviceSupported) |
Colin Cross | fabb608 | 2018-02-20 17:22:23 -0800 | [diff] [blame] | 638 | return module |
| 639 | } |