blob: 94e9c6c57996d60501b3c65a5420c30d9bd5eaa2 [file] [log] [blame]
Jiyong Park58c518b2018-05-12 22:29:12 +09001// 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
15package java
16
17import (
Anton Hansson20ce41d2021-01-22 15:05:32 +000018 "fmt"
Anton Hansson377318b2022-02-15 12:55:11 +000019 "path"
Anton Hansson370fd0b2021-01-22 15:05:04 +000020 "strconv"
Jiyong Park58c518b2018-05-12 22:29:12 +090021 "strings"
22
23 "github.com/google/blueprint/proptools"
Colin Cross17dec172020-05-14 18:05:32 -070024
25 "android/soong/android"
Anton Hansson20ce41d2021-01-22 15:05:32 +000026 "android/soong/genrule"
Jiyong Park58c518b2018-05-12 22:29:12 +090027)
28
Jiyong Park58c518b2018-05-12 22:29:12 +090029func init() {
Paul Duffina48f7582019-12-19 11:25:19 +000030 RegisterPrebuiltApisBuildComponents(android.InitRegistrationContext)
31}
Jiyong Park58c518b2018-05-12 22:29:12 +090032
Paul Duffina48f7582019-12-19 11:25:19 +000033func RegisterPrebuiltApisBuildComponents(ctx android.RegistrationContext) {
34 ctx.RegisterModuleType("prebuilt_apis", PrebuiltApisFactory)
Jiyong Park58c518b2018-05-12 22:29:12 +090035}
36
Sundong Ahn27eecb92018-06-21 13:47:17 +090037type prebuiltApisProperties struct {
38 // list of api version directories
39 Api_dirs []string
Liz Kammer2d2fd852020-08-12 14:42:30 -070040
Anton Hansson3a3f1692022-02-15 12:55:11 +000041 // Directory containing finalized api txt files for extension versions.
42 // Extension versions higher than the base sdk extension version will
43 // be assumed to be finalized later than all Api_dirs.
44 Extensions_dir *string
45
Anton Hansson20ce41d2021-01-22 15:05:32 +000046 // The next API directory can optionally point to a directory where
47 // files incompatibility-tracking files are stored for the current
48 // "in progress" API. Each module present in one of the api_dirs will have
49 // a <module>-incompatibilities.api.<scope>.latest module created.
50 Next_api_dir *string
51
Liz Kammer2d2fd852020-08-12 14:42:30 -070052 // The sdk_version of java_import modules generated based on jar files.
53 // Defaults to "current"
54 Imports_sdk_version *string
Liz Kammer4e7f2602020-09-02 08:37:49 -070055
56 // If set to true, compile dex for java_import modules. Defaults to false.
57 Imports_compile_dex *bool
Todd Lee2ec7e1c2023-08-25 18:02:13 +000058
59 // If set to true, allow incremental platform API of the form MM.m where MM is the major release
60 // version corresponding to the API level/SDK_INT and m is an incremental release version
61 // (e.g. API changes associated with QPR). Defaults to false.
62 Allow_incremental_platform_api *bool
Sundong Ahn27eecb92018-06-21 13:47:17 +090063}
64
Jiyong Park58c518b2018-05-12 22:29:12 +090065type prebuiltApis struct {
66 android.ModuleBase
Sundong Ahn27eecb92018-06-21 13:47:17 +090067 properties prebuiltApisProperties
Jiyong Park58c518b2018-05-12 22:29:12 +090068}
69
Jiyong Park58c518b2018-05-12 22:29:12 +090070func (module *prebuiltApis) GenerateAndroidBuildActions(ctx android.ModuleContext) {
71 // no need to implement
72}
73
Anton Hansson377318b2022-02-15 12:55:11 +000074// parsePrebuiltPath parses the relevant variables out of a variety of paths, e.g.
75// <version>/<scope>/<module>.jar
76// <version>/<scope>/api/<module>.txt
Todd Lee2ec7e1c2023-08-25 18:02:13 +000077// *Note when using incremental platform API, <version> may be of the form MM.m where MM is the
78// API level and m is an incremental release, otherwise <version> is a single integer corresponding to the API level only.
Anton Hansson377318b2022-02-15 12:55:11 +000079// extensions/<version>/<scope>/<module>.jar
80// extensions/<version>/<scope>/api/<module>.txt
81func parsePrebuiltPath(ctx android.LoadHookContext, p string) (module string, version string, scope string) {
82 elements := strings.Split(p, "/")
Sundong Ahna01c2a52018-06-07 21:42:16 +090083
Anton Hansson377318b2022-02-15 12:55:11 +000084 scopeIdx := len(elements) - 2
85 if elements[scopeIdx] == "api" {
86 scopeIdx--
87 }
88 scope = elements[scopeIdx]
89 if scope != "core" && scope != "public" && scope != "system" && scope != "test" && scope != "module-lib" && scope != "system-server" {
90 ctx.ModuleErrorf("invalid scope %q found in path: %q", scope, p)
Jiyong Park58c518b2018-05-12 22:29:12 +090091 return
92 }
Anton Hansson377318b2022-02-15 12:55:11 +000093 version = elements[scopeIdx-1]
Jiyong Park58c518b2018-05-12 22:29:12 +090094
Anton Hansson377318b2022-02-15 12:55:11 +000095 module = strings.TrimSuffix(path.Base(p), path.Ext(p))
Jiyong Park58c518b2018-05-12 22:29:12 +090096 return
97}
98
Anton Hansson377318b2022-02-15 12:55:11 +000099// parseFinalizedPrebuiltPath is like parsePrebuiltPath, but verifies the version is numeric (a finalized version).
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000100func parseFinalizedPrebuiltPath(ctx android.LoadHookContext, p string, allowIncremental bool) (module string, version int, release int, scope string) {
Anton Hansson377318b2022-02-15 12:55:11 +0000101 module, v, scope := parsePrebuiltPath(ctx, p)
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000102 if allowIncremental {
103 parts := strings.Split(v, ".")
104 if len(parts) != 2 {
105 ctx.ModuleErrorf("Found unexpected version '%v' for incremental prebuilts - expect MM.m format for incremental API with both major (MM) an minor (m) revision.", v)
106 return
107 }
108 sdk, sdk_err := strconv.Atoi(parts[0])
109 qpr, qpr_err := strconv.Atoi(parts[1])
110 if sdk_err != nil || qpr_err != nil {
111 ctx.ModuleErrorf("Unable to read version number for incremental prebuilt api '%v'", v)
112 return
113 }
114 version = sdk
115 release = qpr
116 return
117 }
118 release = 0
Anton Hansson377318b2022-02-15 12:55:11 +0000119 version, err := strconv.Atoi(v)
120 if err != nil {
121 ctx.ModuleErrorf("Found finalized API files in non-numeric dir '%v'", v)
122 return
123 }
124 return
Colin Cross17dec172020-05-14 18:05:32 -0700125}
126
Anton Hansson377318b2022-02-15 12:55:11 +0000127func prebuiltApiModuleName(mctx android.LoadHookContext, module, scope, version string) string {
128 return fmt.Sprintf("%s_%s_%s_%s", mctx.ModuleName(), scope, version, module)
129}
Anton Hansson377318b2022-02-15 12:55:11 +0000130func createImport(mctx android.LoadHookContext, module, scope, version, path, sdkVersion string, compileDex bool) {
Sundong Ahna01c2a52018-06-07 21:42:16 +0900131 props := struct {
Colin Cross8ff10582023-12-07 13:10:56 -0800132 Name *string
133 Jars []string
134 Sdk_version *string
135 Installable *bool
136 Compile_dex *bool
Romain Jobredeaux8242b432023-05-04 10:16:26 -0400137 }{
138 Name: proptools.StringPtr(prebuiltApiModuleName(mctx, module, scope, version)),
139 Jars: []string{path},
140 Sdk_version: proptools.StringPtr(sdkVersion),
141 Installable: proptools.BoolPtr(false),
142 Compile_dex: proptools.BoolPtr(compileDex),
143 }
Colin Cross84dfc3d2019-09-25 11:33:01 -0700144 mctx.CreateModule(ImportFactory, &props)
Sundong Ahna01c2a52018-06-07 21:42:16 +0900145}
146
Anton Hanssonc79d4122021-02-17 14:21:33 +0000147func createApiModule(mctx android.LoadHookContext, name string, path string) {
148 genruleProps := struct {
Jiyong Park58c518b2018-05-12 22:29:12 +0900149 Name *string
150 Srcs []string
Anton Hanssonc79d4122021-02-17 14:21:33 +0000151 Out []string
152 Cmd *string
Jiyong Park58c518b2018-05-12 22:29:12 +0900153 }{}
Anton Hanssonc79d4122021-02-17 14:21:33 +0000154 genruleProps.Name = proptools.StringPtr(name)
155 genruleProps.Srcs = []string{path}
156 genruleProps.Out = []string{name}
157 genruleProps.Cmd = proptools.StringPtr("cp $(in) $(out)")
158 mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
Jiyong Park58c518b2018-05-12 22:29:12 +0900159}
160
Gurpreet Singhdaa314a2023-04-21 16:30:03 +0000161func createLatestApiModuleExtensionVersionFile(mctx android.LoadHookContext, name string, version string) {
162 genruleProps := struct {
163 Name *string
164 Srcs []string
165 Out []string
166 Cmd *string
167 }{}
168 genruleProps.Name = proptools.StringPtr(name)
169 genruleProps.Out = []string{name}
170 genruleProps.Cmd = proptools.StringPtr("echo " + version + " > $(out)")
171 mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
172}
173
Anton Hansson20ce41d2021-01-22 15:05:32 +0000174func createEmptyFile(mctx android.LoadHookContext, name string) {
175 props := struct {
176 Name *string
177 Cmd *string
178 Out []string
179 }{}
180 props.Name = proptools.StringPtr(name)
181 props.Out = []string{name}
182 props.Cmd = proptools.StringPtr("touch $(genDir)/" + name)
183 mctx.CreateModule(genrule.GenRuleFactory, &props)
184}
185
Anton Hansson377318b2022-02-15 12:55:11 +0000186// globApiDirs collects all the files in all api_dirs and all scopes that match the given glob, e.g. '*.jar' or 'api/*.txt'.
187// <api-dir>/<scope>/<glob> for all api-dir and scope.
188func globApiDirs(mctx android.LoadHookContext, p *prebuiltApis, api_dir_glob string) []string {
Sundong Ahn27eecb92018-06-21 13:47:17 +0900189 var files []string
Liz Kammer2d2fd852020-08-12 14:42:30 -0700190 for _, apiver := range p.properties.Api_dirs {
Anton Hansson377318b2022-02-15 12:55:11 +0000191 files = append(files, globScopeDir(mctx, apiver, api_dir_glob)...)
Anton Hansson20ce41d2021-01-22 15:05:32 +0000192 }
193 return files
194}
195
Anton Hansson3a3f1692022-02-15 12:55:11 +0000196// globExtensionDirs collects all the files under the extension dir (for all versions and scopes) that match the given glob
197// <extension-dir>/<version>/<scope>/<glob> for all version and scope.
198func globExtensionDirs(mctx android.LoadHookContext, p *prebuiltApis, extension_dir_glob string) []string {
199 // <extensions-dir>/<num>/<extension-dir-glob>
200 return globScopeDir(mctx, *p.properties.Extensions_dir+"/*", extension_dir_glob)
201}
202
Anton Hansson377318b2022-02-15 12:55:11 +0000203// globScopeDir collects all the files in the given subdir across all scopes that match the given glob, e.g. '*.jar' or 'api/*.txt'.
204// <subdir>/<scope>/<glob> for all scope.
205func globScopeDir(mctx android.LoadHookContext, subdir string, subdir_glob string) []string {
Anton Hansson20ce41d2021-01-22 15:05:32 +0000206 var files []string
207 dir := mctx.ModuleDir() + "/" + subdir
208 for _, scope := range []string{"public", "system", "test", "core", "module-lib", "system-server"} {
Anton Hansson377318b2022-02-15 12:55:11 +0000209 glob := fmt.Sprintf("%s/%s/%s", dir, scope, subdir_glob)
Anton Hansson20ce41d2021-01-22 15:05:32 +0000210 vfiles, err := mctx.GlobWithDeps(glob, nil)
211 if err != nil {
Anton Hansson377318b2022-02-15 12:55:11 +0000212 mctx.ModuleErrorf("failed to glob %s files under %q: %s", subdir_glob, dir+"/"+scope, err)
Sundong Ahn27eecb92018-06-21 13:47:17 +0900213 }
Anton Hansson20ce41d2021-01-22 15:05:32 +0000214 files = append(files, vfiles...)
Sundong Ahna01c2a52018-06-07 21:42:16 +0900215 }
Anton Hansson377318b2022-02-15 12:55:11 +0000216 for i, f := range files {
217 files[i] = strings.TrimPrefix(f, mctx.ModuleDir()+"/")
218 }
Sundong Ahn8faab8a2019-02-14 11:49:24 +0900219 return files
220}
221
Liz Kammer2d2fd852020-08-12 14:42:30 -0700222func prebuiltSdkStubs(mctx android.LoadHookContext, p *prebuiltApis) {
Sundong Ahn8faab8a2019-02-14 11:49:24 +0900223 // <apiver>/<scope>/<module>.jar
Anton Hansson377318b2022-02-15 12:55:11 +0000224 files := globApiDirs(mctx, p, "*.jar")
Liz Kammer2d2fd852020-08-12 14:42:30 -0700225
Liz Kammer4e7f2602020-09-02 08:37:49 -0700226 sdkVersion := proptools.StringDefault(p.properties.Imports_sdk_version, "current")
227 compileDex := proptools.BoolDefault(p.properties.Imports_compile_dex, false)
Sundong Ahna01c2a52018-06-07 21:42:16 +0900228
229 for _, f := range files {
230 // create a Import module for each jar file
Anton Hansson377318b2022-02-15 12:55:11 +0000231 module, version, scope := parsePrebuiltPath(mctx, f)
232 createImport(mctx, module, scope, version, f, sdkVersion, compileDex)
Paul Duffinb077bcc2021-10-28 13:27:37 +0100233
234 if module == "core-for-system-modules" {
Anton Hansson377318b2022-02-15 12:55:11 +0000235 createSystemModules(mctx, version, scope)
Paul Duffinb077bcc2021-10-28 13:27:37 +0100236 }
Sundong Ahna01c2a52018-06-07 21:42:16 +0900237 }
238}
239
Anton Hansson377318b2022-02-15 12:55:11 +0000240func createSystemModules(mctx android.LoadHookContext, version, scope string) {
Colin Cross17dec172020-05-14 18:05:32 -0700241 props := struct {
242 Name *string
243 Libs []string
244 }{}
Anton Hansson377318b2022-02-15 12:55:11 +0000245 props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, "system_modules", scope, version))
246 props.Libs = append(props.Libs, prebuiltApiModuleName(mctx, "core-for-system-modules", scope, version))
Colin Cross17dec172020-05-14 18:05:32 -0700247
Paul Duffind6c2a652021-03-11 07:56:22 +0000248 mctx.CreateModule(systemModulesImportFactory, &props)
Colin Cross17dec172020-05-14 18:05:32 -0700249}
250
Paul Duffin958806b2022-05-16 13:10:47 +0000251func PrebuiltApiModuleName(module, scope, version string) string {
252 return module + ".api." + scope + "." + version
253}
254
Liz Kammer2d2fd852020-08-12 14:42:30 -0700255func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
Sundong Ahna01c2a52018-06-07 21:42:16 +0900256 // <apiver>/<scope>/api/<module>.txt
Anton Hansson377318b2022-02-15 12:55:11 +0000257 apiLevelFiles := globApiDirs(mctx, p, "api/*.txt")
258 if len(apiLevelFiles) == 0 {
259 mctx.ModuleErrorf("no api file found under %q", mctx.ModuleDir())
Sundong Ahna01c2a52018-06-07 21:42:16 +0900260 }
Sundong Ahna01c2a52018-06-07 21:42:16 +0900261
Anton Hanssonc79d4122021-02-17 14:21:33 +0000262 // Create modules for all (<module>, <scope, <version>) triplets,
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000263 allowIncremental := proptools.BoolDefault(p.properties.Allow_incremental_platform_api, false)
Anton Hansson377318b2022-02-15 12:55:11 +0000264 for _, f := range apiLevelFiles {
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000265 module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f, allowIncremental)
266 if allowIncremental {
267 incrementalVersion := strconv.Itoa(version) + "." + strconv.Itoa(release)
268 createApiModule(mctx, PrebuiltApiModuleName(module, scope, incrementalVersion), f)
269 } else {
270 createApiModule(mctx, PrebuiltApiModuleName(module, scope, strconv.Itoa(version)), f)
271 }
Anton Hansson377318b2022-02-15 12:55:11 +0000272 }
Sundong Ahna01c2a52018-06-07 21:42:16 +0900273
Anton Hansson377318b2022-02-15 12:55:11 +0000274 // Figure out the latest version of each module/scope
275 type latestApiInfo struct {
276 module, scope, path string
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000277 version, release int
Gurpreet Singhdaa314a2023-04-21 16:30:03 +0000278 isExtensionApiFile bool
Anton Hansson377318b2022-02-15 12:55:11 +0000279 }
280
Gurpreet Singhdaa314a2023-04-21 16:30:03 +0000281 getLatest := func(files []string, isExtensionApiFile bool) map[string]latestApiInfo {
Anton Hansson3a3f1692022-02-15 12:55:11 +0000282 m := make(map[string]latestApiInfo)
283 for _, f := range files {
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000284 module, version, release, scope := parseFinalizedPrebuiltPath(mctx, f, allowIncremental)
Anton Hansson3a3f1692022-02-15 12:55:11 +0000285 if strings.HasSuffix(module, "incompatibilities") {
286 continue
287 }
288 key := module + "." + scope
289 info, exists := m[key]
Todd Lee2ec7e1c2023-08-25 18:02:13 +0000290 if !exists || version > info.version || (version == info.version && release > info.release) {
291 m[key] = latestApiInfo{module, scope, f, version, release, isExtensionApiFile}
Anton Hansson3a3f1692022-02-15 12:55:11 +0000292 }
Anton Hansson370fd0b2021-01-22 15:05:04 +0000293 }
Anton Hansson3a3f1692022-02-15 12:55:11 +0000294 return m
295 }
Anton Hansson370fd0b2021-01-22 15:05:04 +0000296
Gurpreet Singhdaa314a2023-04-21 16:30:03 +0000297 latest := getLatest(apiLevelFiles, false)
Anton Hansson3a3f1692022-02-15 12:55:11 +0000298 if p.properties.Extensions_dir != nil {
299 extensionApiFiles := globExtensionDirs(mctx, p, "api/*.txt")
Gurpreet Singhdaa314a2023-04-21 16:30:03 +0000300 for k, v := range getLatest(extensionApiFiles, true) {
Anton Hansson7212dbe2022-09-20 17:08:49 +0000301 if _, exists := latest[k]; !exists {
302 mctx.ModuleErrorf("Module %v finalized for extension %d but never during an API level; likely error", v.module, v.version)
Anton Hansson3a3f1692022-02-15 12:55:11 +0000303 }
Anton Hansson7212dbe2022-09-20 17:08:49 +0000304 // The extension version is always at least as new as the last sdk int version (potentially identical)
305 latest[k] = v
Sundong Ahna01c2a52018-06-07 21:42:16 +0900306 }
307 }
Anton Hansson20ce41d2021-01-22 15:05:32 +0000308
Anton Hansson370fd0b2021-01-22 15:05:04 +0000309 // Sort the keys in order to make build.ninja stable
Cole Faust18994c72023-02-28 16:02:16 -0800310 for _, k := range android.SortedKeys(latest) {
Anton Hansson377318b2022-02-15 12:55:11 +0000311 info := latest[k]
Paul Duffin958806b2022-05-16 13:10:47 +0000312 name := PrebuiltApiModuleName(info.module, info.scope, "latest")
Gurpreet Singhdaa314a2023-04-21 16:30:03 +0000313 latestExtensionVersionModuleName := PrebuiltApiModuleName(info.module, info.scope, "latest.extension_version")
314 if info.isExtensionApiFile {
315 createLatestApiModuleExtensionVersionFile(mctx, latestExtensionVersionModuleName, strconv.Itoa(info.version))
316 } else {
317 createLatestApiModuleExtensionVersionFile(mctx, latestExtensionVersionModuleName, "-1")
318 }
Anton Hanssonc79d4122021-02-17 14:21:33 +0000319 createApiModule(mctx, name, info.path)
Anton Hansson20ce41d2021-01-22 15:05:32 +0000320 }
321
322 // Create incompatibilities tracking files for all modules, if we have a "next" api.
Jaewoong Jung1a97ee02021-03-09 13:25:02 -0800323 incompatibilities := make(map[string]bool)
Anton Hansson20ce41d2021-01-22 15:05:32 +0000324 if nextApiDir := String(p.properties.Next_api_dir); nextApiDir != "" {
Anton Hansson377318b2022-02-15 12:55:11 +0000325 files := globScopeDir(mctx, nextApiDir, "api/*incompatibilities.txt")
Anton Hansson20ce41d2021-01-22 15:05:32 +0000326 for _, f := range files {
Anton Hansson377318b2022-02-15 12:55:11 +0000327 filename, _, scope := parsePrebuiltPath(mctx, f)
Anton Hanssonfa5e6b52021-04-13 19:09:48 +0100328 referencedModule := strings.TrimSuffix(filename, "-incompatibilities")
Anton Hansson20ce41d2021-01-22 15:05:32 +0000329
Paul Duffin958806b2022-05-16 13:10:47 +0000330 createApiModule(mctx, PrebuiltApiModuleName(referencedModule+"-incompatibilities", scope, "latest"), f)
Anton Hansson20ce41d2021-01-22 15:05:32 +0000331
332 incompatibilities[referencedModule+"."+scope] = true
333 }
Jaewoong Jung1a97ee02021-03-09 13:25:02 -0800334 }
335 // Create empty incompatibilities files for remaining modules
Cole Faust18994c72023-02-28 16:02:16 -0800336 for _, k := range android.SortedKeys(latest) {
Jaewoong Jung1a97ee02021-03-09 13:25:02 -0800337 if _, ok := incompatibilities[k]; !ok {
Paul Duffin958806b2022-05-16 13:10:47 +0000338 createEmptyFile(mctx, PrebuiltApiModuleName(latest[k].module+"-incompatibilities", latest[k].scope, "latest"))
Anton Hansson20ce41d2021-01-22 15:05:32 +0000339 }
Sundong Ahna01c2a52018-06-07 21:42:16 +0900340 }
341}
342
Paul Duffind4c03562020-04-09 17:15:44 +0100343func createPrebuiltApiModules(mctx android.LoadHookContext) {
Liz Kammer2d2fd852020-08-12 14:42:30 -0700344 if p, ok := mctx.Module().(*prebuiltApis); ok {
345 prebuiltApiFiles(mctx, p)
346 prebuiltSdkStubs(mctx, p)
Jiyong Park58c518b2018-05-12 22:29:12 +0900347 }
348}
349
Anton Hanssonc79d4122021-02-17 14:21:33 +0000350// prebuilt_apis is a meta-module that generates modules for all API txt files
351// found under the directory where the Android.bp is located.
Jaewoong Jung5fb5b2a2019-03-21 10:48:25 -0700352// Specifically, an API file located at ./<ver>/<scope>/api/<module>.txt
Anton Hanssonc79d4122021-02-17 14:21:33 +0000353// generates a module named <module>-api.<scope>.<ver>.
Jaewoong Jung5fb5b2a2019-03-21 10:48:25 -0700354//
355// It also creates <module>-api.<scope>.latest for the latest <ver>.
Paul Duffind4c03562020-04-09 17:15:44 +0100356//
357// Similarly, it generates a java_import for all API .jar files found under the
358// directory where the Android.bp is located. Specifically, an API file located
359// at ./<ver>/<scope>/api/<module>.jar generates a java_import module named
Colin Cross17dec172020-05-14 18:05:32 -0700360// <prebuilt-api-module>_<scope>_<ver>_<module>, and for SDK versions >= 30
361// a java_system_modules module named
362// <prebuilt-api-module>_public_<ver>_system_modules
Inseob Kimc0907f12019-02-08 21:00:45 +0900363func PrebuiltApisFactory() android.Module {
Jiyong Park58c518b2018-05-12 22:29:12 +0900364 module := &prebuiltApis{}
Sundong Ahn27eecb92018-06-21 13:47:17 +0900365 module.AddProperties(&module.properties)
Jiyong Park58c518b2018-05-12 22:29:12 +0900366 android.InitAndroidModule(module)
Paul Duffind4c03562020-04-09 17:15:44 +0100367 android.AddLoadHook(module, createPrebuiltApiModules)
Jiyong Park58c518b2018-05-12 22:29:12 +0900368 return module
369}