Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [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 ( |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 18 | "fmt" |
Anton Hansson | 370fd0b | 2021-01-22 15:05:04 +0000 | [diff] [blame] | 19 | "strconv" |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 20 | "strings" |
| 21 | |
| 22 | "github.com/google/blueprint/proptools" |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 23 | |
| 24 | "android/soong/android" |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 25 | "android/soong/genrule" |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 26 | ) |
| 27 | |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 28 | func init() { |
Paul Duffin | a48f758 | 2019-12-19 11:25:19 +0000 | [diff] [blame] | 29 | RegisterPrebuiltApisBuildComponents(android.InitRegistrationContext) |
| 30 | } |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 31 | |
Paul Duffin | a48f758 | 2019-12-19 11:25:19 +0000 | [diff] [blame] | 32 | func RegisterPrebuiltApisBuildComponents(ctx android.RegistrationContext) { |
| 33 | ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 34 | } |
| 35 | |
Sundong Ahn | 27eecb9 | 2018-06-21 13:47:17 +0900 | [diff] [blame] | 36 | type prebuiltApisProperties struct { |
| 37 | // list of api version directories |
| 38 | Api_dirs []string |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 39 | |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 40 | // The next API directory can optionally point to a directory where |
| 41 | // files incompatibility-tracking files are stored for the current |
| 42 | // "in progress" API. Each module present in one of the api_dirs will have |
| 43 | // a <module>-incompatibilities.api.<scope>.latest module created. |
| 44 | Next_api_dir *string |
| 45 | |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 46 | // The sdk_version of java_import modules generated based on jar files. |
| 47 | // Defaults to "current" |
| 48 | Imports_sdk_version *string |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 49 | |
| 50 | // If set to true, compile dex for java_import modules. Defaults to false. |
| 51 | Imports_compile_dex *bool |
Sundong Ahn | 27eecb9 | 2018-06-21 13:47:17 +0900 | [diff] [blame] | 52 | } |
| 53 | |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 54 | type prebuiltApis struct { |
| 55 | android.ModuleBase |
Sundong Ahn | 27eecb9 | 2018-06-21 13:47:17 +0900 | [diff] [blame] | 56 | properties prebuiltApisProperties |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 57 | } |
| 58 | |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 59 | func (module *prebuiltApis) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 60 | // no need to implement |
| 61 | } |
| 62 | |
Paul Duffin | d4c0356 | 2020-04-09 17:15:44 +0100 | [diff] [blame] | 63 | func parseJarPath(path string) (module string, apiver string, scope string) { |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 64 | elements := strings.Split(path, "/") |
| 65 | |
| 66 | apiver = elements[0] |
| 67 | scope = elements[1] |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 68 | |
| 69 | module = strings.TrimSuffix(elements[2], ".jar") |
| 70 | return |
| 71 | } |
| 72 | |
Paul Duffin | d4c0356 | 2020-04-09 17:15:44 +0100 | [diff] [blame] | 73 | func parseApiFilePath(ctx android.LoadHookContext, path string) (module string, apiver string, scope string) { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 74 | elements := strings.Split(path, "/") |
Sundong Ahn | 054b19a | 2018-10-19 13:46:09 +0900 | [diff] [blame] | 75 | apiver = elements[0] |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 76 | |
| 77 | scope = elements[1] |
Anton Hansson | 8d23969 | 2020-05-01 18:37:15 +0100 | [diff] [blame] | 78 | if scope != "public" && scope != "system" && scope != "test" && scope != "module-lib" && scope != "system-server" { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 79 | ctx.ModuleErrorf("invalid scope %q found in path: %q", scope, path) |
| 80 | return |
| 81 | } |
| 82 | |
| 83 | // elements[2] is string literal "api". skipping. |
| 84 | module = strings.TrimSuffix(elements[3], ".txt") |
| 85 | return |
| 86 | } |
| 87 | |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 88 | func prebuiltApiModuleName(mctx android.LoadHookContext, module string, scope string, apiver string) string { |
| 89 | return mctx.ModuleName() + "_" + scope + "_" + apiver + "_" + module |
| 90 | } |
| 91 | |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 92 | func createImport(mctx android.LoadHookContext, module, scope, apiver, path, sdkVersion string, compileDex bool) { |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 93 | props := struct { |
| 94 | Name *string |
| 95 | Jars []string |
| 96 | Sdk_version *string |
| 97 | Installable *bool |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 98 | Compile_dex *bool |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 99 | }{} |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 100 | props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, module, scope, apiver)) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 101 | props.Jars = append(props.Jars, path) |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 102 | props.Sdk_version = proptools.StringPtr(sdkVersion) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 103 | props.Installable = proptools.BoolPtr(false) |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 104 | props.Compile_dex = proptools.BoolPtr(compileDex) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 105 | |
Colin Cross | 84dfc3d | 2019-09-25 11:33:01 -0700 | [diff] [blame] | 106 | mctx.CreateModule(ImportFactory, &props) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 107 | } |
| 108 | |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 109 | func createApiModule(mctx android.LoadHookContext, name string, path string) { |
| 110 | genruleProps := struct { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 111 | Name *string |
| 112 | Srcs []string |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 113 | Out []string |
| 114 | Cmd *string |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 115 | }{} |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 116 | genruleProps.Name = proptools.StringPtr(name) |
| 117 | genruleProps.Srcs = []string{path} |
| 118 | genruleProps.Out = []string{name} |
| 119 | genruleProps.Cmd = proptools.StringPtr("cp $(in) $(out)") |
| 120 | mctx.CreateModule(genrule.GenRuleFactory, &genruleProps) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 121 | } |
| 122 | |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 123 | func createEmptyFile(mctx android.LoadHookContext, name string) { |
| 124 | props := struct { |
| 125 | Name *string |
| 126 | Cmd *string |
| 127 | Out []string |
| 128 | }{} |
| 129 | props.Name = proptools.StringPtr(name) |
| 130 | props.Out = []string{name} |
| 131 | props.Cmd = proptools.StringPtr("touch $(genDir)/" + name) |
| 132 | mctx.CreateModule(genrule.GenRuleFactory, &props) |
| 133 | } |
| 134 | |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 135 | func getPrebuiltFiles(mctx android.LoadHookContext, p *prebuiltApis, name string) []string { |
Sundong Ahn | 27eecb9 | 2018-06-21 13:47:17 +0900 | [diff] [blame] | 136 | var files []string |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 137 | for _, apiver := range p.properties.Api_dirs { |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 138 | files = append(files, getPrebuiltFilesInSubdir(mctx, apiver, name)...) |
| 139 | } |
| 140 | return files |
| 141 | } |
| 142 | |
| 143 | func getPrebuiltFilesInSubdir(mctx android.LoadHookContext, subdir string, name string) []string { |
| 144 | var files []string |
| 145 | dir := mctx.ModuleDir() + "/" + subdir |
| 146 | for _, scope := range []string{"public", "system", "test", "core", "module-lib", "system-server"} { |
| 147 | glob := fmt.Sprintf("%s/%s/%s", dir, scope, name) |
| 148 | vfiles, err := mctx.GlobWithDeps(glob, nil) |
| 149 | if err != nil { |
| 150 | mctx.ModuleErrorf("failed to glob %s files under %q: %s", name, dir+"/"+scope, err) |
Sundong Ahn | 27eecb9 | 2018-06-21 13:47:17 +0900 | [diff] [blame] | 151 | } |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 152 | files = append(files, vfiles...) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 153 | } |
Sundong Ahn | 8faab8a | 2019-02-14 11:49:24 +0900 | [diff] [blame] | 154 | return files |
| 155 | } |
| 156 | |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 157 | func prebuiltSdkStubs(mctx android.LoadHookContext, p *prebuiltApis) { |
Sundong Ahn | 8faab8a | 2019-02-14 11:49:24 +0900 | [diff] [blame] | 158 | mydir := mctx.ModuleDir() + "/" |
| 159 | // <apiver>/<scope>/<module>.jar |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 160 | files := getPrebuiltFiles(mctx, p, "*.jar") |
| 161 | |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 162 | sdkVersion := proptools.StringDefault(p.properties.Imports_sdk_version, "current") |
| 163 | compileDex := proptools.BoolDefault(p.properties.Imports_compile_dex, false) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 164 | |
| 165 | for _, f := range files { |
| 166 | // create a Import module for each jar file |
| 167 | localPath := strings.TrimPrefix(f, mydir) |
Paul Duffin | d4c0356 | 2020-04-09 17:15:44 +0100 | [diff] [blame] | 168 | module, apiver, scope := parseJarPath(localPath) |
Liz Kammer | 4e7f260 | 2020-09-02 08:37:49 -0700 | [diff] [blame] | 169 | createImport(mctx, module, scope, apiver, localPath, sdkVersion, compileDex) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 173 | func createSystemModules(mctx android.LoadHookContext, apiver string) { |
| 174 | props := struct { |
| 175 | Name *string |
| 176 | Libs []string |
| 177 | }{} |
| 178 | props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, "system_modules", "public", apiver)) |
| 179 | props.Libs = append(props.Libs, prebuiltApiModuleName(mctx, "core-for-system-modules", "public", apiver)) |
| 180 | |
| 181 | mctx.CreateModule(SystemModulesFactory, &props) |
| 182 | } |
| 183 | |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 184 | func prebuiltSdkSystemModules(mctx android.LoadHookContext, p *prebuiltApis) { |
| 185 | for _, apiver := range p.properties.Api_dirs { |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 186 | jar := android.ExistentPathForSource(mctx, |
| 187 | mctx.ModuleDir(), apiver, "public", "core-for-system-modules.jar") |
| 188 | if jar.Valid() { |
| 189 | createSystemModules(mctx, apiver) |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 194 | func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) { |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 195 | mydir := mctx.ModuleDir() + "/" |
| 196 | // <apiver>/<scope>/api/<module>.txt |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 197 | files := getPrebuiltFiles(mctx, p, "api/*.txt") |
Sundong Ahn | 8faab8a | 2019-02-14 11:49:24 +0900 | [diff] [blame] | 198 | |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 199 | if len(files) == 0 { |
| 200 | mctx.ModuleErrorf("no api file found under %q", mydir) |
| 201 | } |
| 202 | |
| 203 | // construct a map to find out the latest api file path |
| 204 | // for each (<module>, <scope>) pair. |
| 205 | type latestApiInfo struct { |
Anton Hansson | 370fd0b | 2021-01-22 15:05:04 +0000 | [diff] [blame] | 206 | module string |
| 207 | scope string |
| 208 | version int |
| 209 | path string |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 210 | } |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 211 | |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 212 | // Create modules for all (<module>, <scope, <version>) triplets, |
| 213 | // and a "latest" module variant for each (<module>, <scope>) pair |
| 214 | apiModuleName := func(module, scope, version string) string { |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 215 | return module + ".api." + scope + "." + version |
| 216 | } |
Anton Hansson | 370fd0b | 2021-01-22 15:05:04 +0000 | [diff] [blame] | 217 | m := make(map[string]latestApiInfo) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 218 | for _, f := range files { |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 219 | localPath := strings.TrimPrefix(f, mydir) |
| 220 | module, apiver, scope := parseApiFilePath(mctx, localPath) |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 221 | createApiModule(mctx, apiModuleName(module, scope, apiver), localPath) |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 222 | |
Anton Hansson | 370fd0b | 2021-01-22 15:05:04 +0000 | [diff] [blame] | 223 | version, err := strconv.Atoi(apiver) |
| 224 | if err != nil { |
| 225 | mctx.ModuleErrorf("Found finalized API files in non-numeric dir %v", apiver) |
| 226 | return |
| 227 | } |
| 228 | |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 229 | // Track latest version of each module/scope, except for incompatibilities |
| 230 | if !strings.HasSuffix(module, "incompatibilities") { |
| 231 | key := module + "." + scope |
| 232 | info, ok := m[key] |
| 233 | if !ok { |
| 234 | m[key] = latestApiInfo{module, scope, version, localPath} |
| 235 | } else if version > info.version { |
| 236 | info.version = version |
| 237 | info.path = localPath |
| 238 | m[key] = info |
| 239 | } |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 240 | } |
| 241 | } |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 242 | |
Anton Hansson | 370fd0b | 2021-01-22 15:05:04 +0000 | [diff] [blame] | 243 | // Sort the keys in order to make build.ninja stable |
| 244 | for _, k := range android.SortedStringKeys(m) { |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 245 | info := m[k] |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 246 | name := apiModuleName(info.module, info.scope, "latest") |
| 247 | createApiModule(mctx, name, info.path) |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | // Create incompatibilities tracking files for all modules, if we have a "next" api. |
| 251 | if nextApiDir := String(p.properties.Next_api_dir); nextApiDir != "" { |
| 252 | files := getPrebuiltFilesInSubdir(mctx, nextApiDir, "api/*incompatibilities.txt") |
| 253 | incompatibilities := make(map[string]bool) |
| 254 | for _, f := range files { |
| 255 | localPath := strings.TrimPrefix(f, mydir) |
| 256 | module, _, scope := parseApiFilePath(mctx, localPath) |
| 257 | |
| 258 | // Figure out which module is referenced by this file. Special case for "android". |
| 259 | referencedModule := strings.TrimSuffix(module, "incompatibilities") |
| 260 | referencedModule = strings.TrimSuffix(referencedModule, "-") |
| 261 | if referencedModule == "" { |
| 262 | referencedModule = "android" |
| 263 | } |
| 264 | |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 265 | createApiModule(mctx, apiModuleName(referencedModule+"-incompatibilities", scope, "latest"), localPath) |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 266 | |
| 267 | incompatibilities[referencedModule+"."+scope] = true |
| 268 | } |
| 269 | // Create empty incompatibilities files for remaining modules |
| 270 | for _, k := range android.SortedStringKeys(m) { |
| 271 | if _, ok := incompatibilities[k]; !ok { |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 272 | createEmptyFile(mctx, apiModuleName(m[k].module+"-incompatibilities", m[k].scope, "latest")) |
Anton Hansson | 20ce41d | 2021-01-22 15:05:32 +0000 | [diff] [blame] | 273 | } |
| 274 | } |
Sundong Ahn | a01c2a5 | 2018-06-07 21:42:16 +0900 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | |
Paul Duffin | d4c0356 | 2020-04-09 17:15:44 +0100 | [diff] [blame] | 278 | func createPrebuiltApiModules(mctx android.LoadHookContext) { |
Liz Kammer | 2d2fd85 | 2020-08-12 14:42:30 -0700 | [diff] [blame] | 279 | if p, ok := mctx.Module().(*prebuiltApis); ok { |
| 280 | prebuiltApiFiles(mctx, p) |
| 281 | prebuiltSdkStubs(mctx, p) |
| 282 | prebuiltSdkSystemModules(mctx, p) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 286 | // prebuilt_apis is a meta-module that generates modules for all API txt files |
| 287 | // found under the directory where the Android.bp is located. |
Jaewoong Jung | 5fb5b2a | 2019-03-21 10:48:25 -0700 | [diff] [blame] | 288 | // Specifically, an API file located at ./<ver>/<scope>/api/<module>.txt |
Anton Hansson | c79d412 | 2021-02-17 14:21:33 +0000 | [diff] [blame] | 289 | // generates a module named <module>-api.<scope>.<ver>. |
Jaewoong Jung | 5fb5b2a | 2019-03-21 10:48:25 -0700 | [diff] [blame] | 290 | // |
| 291 | // It also creates <module>-api.<scope>.latest for the latest <ver>. |
Paul Duffin | d4c0356 | 2020-04-09 17:15:44 +0100 | [diff] [blame] | 292 | // |
| 293 | // Similarly, it generates a java_import for all API .jar files found under the |
| 294 | // directory where the Android.bp is located. Specifically, an API file located |
| 295 | // at ./<ver>/<scope>/api/<module>.jar generates a java_import module named |
Colin Cross | 17dec17 | 2020-05-14 18:05:32 -0700 | [diff] [blame] | 296 | // <prebuilt-api-module>_<scope>_<ver>_<module>, and for SDK versions >= 30 |
| 297 | // a java_system_modules module named |
| 298 | // <prebuilt-api-module>_public_<ver>_system_modules |
Inseob Kim | c0907f1 | 2019-02-08 21:00:45 +0900 | [diff] [blame] | 299 | func PrebuiltApisFactory() android.Module { |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 300 | module := &prebuiltApis{} |
Sundong Ahn | 27eecb9 | 2018-06-21 13:47:17 +0900 | [diff] [blame] | 301 | module.AddProperties(&module.properties) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 302 | android.InitAndroidModule(module) |
Paul Duffin | d4c0356 | 2020-04-09 17:15:44 +0100 | [diff] [blame] | 303 | android.AddLoadHook(module, createPrebuiltApiModules) |
Jiyong Park | 58c518b | 2018-05-12 22:29:12 +0900 | [diff] [blame] | 304 | return module |
| 305 | } |