blob: b7efcff354bb44c06eb717bef73fc001df7111a9 [file] [log] [blame]
Jiyong Parkc678ad32018-04-10 13:07:10 +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 (
18 "android/soong/android"
19 "android/soong/genrule"
20 "fmt"
Jiyong Park82484c02018-04-23 21:41:26 +090021 "io"
Jiyong Parkc678ad32018-04-10 13:07:10 +090022 "path"
Sundong Ahn054b19a2018-10-19 13:46:09 +090023 "path/filepath"
Jiyong Park82484c02018-04-23 21:41:26 +090024 "sort"
Jiyong Parkc678ad32018-04-10 13:07:10 +090025 "strings"
Jiyong Park82484c02018-04-23 21:41:26 +090026 "sync"
Jiyong Parkc678ad32018-04-10 13:07:10 +090027
28 "github.com/google/blueprint"
29 "github.com/google/blueprint/proptools"
30)
31
32var (
33 sdkStubsLibrarySuffix = ".stubs"
34 sdkSystemApiSuffix = ".system"
Jiyong Parkdf130542018-04-27 16:29:21 +090035 sdkTestApiSuffix = ".test"
Jiyong Parkc678ad32018-04-10 13:07:10 +090036 sdkDocsSuffix = ".docs"
Jiyong Parkc678ad32018-04-10 13:07:10 +090037 sdkXmlFileSuffix = ".xml"
38)
39
40type stubsLibraryDependencyTag struct {
41 blueprint.BaseDependencyTag
42 name string
43}
44
45var (
46 publicApiStubsTag = dependencyTag{name: "public"}
47 systemApiStubsTag = dependencyTag{name: "system"}
Jiyong Parkdf130542018-04-27 16:29:21 +090048 testApiStubsTag = dependencyTag{name: "test"}
Sundong Ahn20e998b2018-07-24 11:19:26 +090049 publicApiFileTag = dependencyTag{name: "publicApi"}
50 systemApiFileTag = dependencyTag{name: "systemApi"}
51 testApiFileTag = dependencyTag{name: "testApi"}
Jiyong Parkdf130542018-04-27 16:29:21 +090052)
53
54type apiScope int
55
56const (
57 apiScopePublic apiScope = iota
58 apiScopeSystem
59 apiScopeTest
Jiyong Parkc678ad32018-04-10 13:07:10 +090060)
61
Jiyong Park82484c02018-04-23 21:41:26 +090062var (
63 javaSdkLibrariesLock sync.Mutex
64)
65
Jiyong Parkc678ad32018-04-10 13:07:10 +090066// TODO: these are big features that are currently missing
Jiyong Park1be96912018-05-28 18:02:19 +090067// 1) disallowing linking to the runtime shared lib
68// 2) HTML generation
Jiyong Parkc678ad32018-04-10 13:07:10 +090069
70func init() {
Inseob Kimc0907f12019-02-08 21:00:45 +090071 android.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
Colin Cross79c7c262019-04-17 11:11:46 -070072 android.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
Jiyong Parkc678ad32018-04-10 13:07:10 +090073
Jiyong Park82484c02018-04-23 21:41:26 +090074 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
75 javaSdkLibraries := javaSdkLibraries(ctx.Config())
76 sort.Strings(*javaSdkLibraries)
77 ctx.Strict("JAVA_SDK_LIBRARIES", strings.Join(*javaSdkLibraries, " "))
78 })
Jiyong Parkc678ad32018-04-10 13:07:10 +090079}
80
81type sdkLibraryProperties struct {
Sundong Ahnf043cf62018-06-25 16:04:37 +090082 // List of Java libraries that will be in the classpath when building stubs
83 Stub_only_libs []string `android:"arch_variant"`
84
Jiyong Parkc678ad32018-04-10 13:07:10 +090085 // list of package names that will be documented and publicized as API
86 Api_packages []string
87
Jiyong Park5a2c9d72018-05-01 22:25:41 +090088 // list of package names that must be hidden from the API
89 Hidden_api_packages []string
90
Paul Duffin11512472019-02-11 15:55:17 +000091 // local files that are used within user customized droiddoc options.
92 Droiddoc_option_files []string
93
94 // additional droiddoc options
95 // Available variables for substitution:
96 //
97 // $(location <label>): the path to the droiddoc_option_files with name <label>
Sundong Ahndd567f92018-07-31 17:19:11 +090098 Droiddoc_options []string
99
Sundong Ahn054b19a2018-10-19 13:46:09 +0900100 // a list of top-level directories containing files to merge qualifier annotations
101 // (i.e. those intended to be included in the stubs written) from.
102 Merge_annotations_dirs []string
103
104 // a list of top-level directories containing Java stub files to merge show/hide annotations from.
105 Merge_inclusion_annotations_dirs []string
106
107 // If set to true, the path of dist files is apistubs/core. Defaults to false.
108 Core_lib *bool
109
Sundong Ahn80a87b32019-05-13 15:02:50 +0900110 // don't create dist rules.
111 No_dist *bool `blueprint:"mutated"`
112
Jiyong Parkc678ad32018-04-10 13:07:10 +0900113 // TODO: determines whether to create HTML doc or not
114 //Html_doc *bool
115}
116
Inseob Kimc0907f12019-02-08 21:00:45 +0900117type SdkLibrary struct {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900118 Library
Jiyong Parkc678ad32018-04-10 13:07:10 +0900119
Sundong Ahn054b19a2018-10-19 13:46:09 +0900120 sdkLibraryProperties sdkLibraryProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900121
122 publicApiStubsPath android.Paths
123 systemApiStubsPath android.Paths
Jiyong Parkdf130542018-04-27 16:29:21 +0900124 testApiStubsPath android.Paths
Sundong Ahn241cd372018-07-13 16:16:44 +0900125
126 publicApiStubsImplPath android.Paths
127 systemApiStubsImplPath android.Paths
128 testApiStubsImplPath android.Paths
Sundong Ahn20e998b2018-07-24 11:19:26 +0900129
130 publicApiFilePath android.Path
131 systemApiFilePath android.Path
132 testApiFilePath android.Path
Jiyong Parkc678ad32018-04-10 13:07:10 +0900133}
134
Inseob Kimc0907f12019-02-08 21:00:45 +0900135var _ Dependency = (*SdkLibrary)(nil)
136var _ SdkLibraryDependency = (*SdkLibrary)(nil)
Colin Cross897d2ed2019-02-11 14:03:51 -0800137
Inseob Kimc0907f12019-02-08 21:00:45 +0900138func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
Jiyong Parke3ef3c82019-07-15 15:31:16 +0900139 useBuiltStubs := !ctx.Config().UnbundledBuildUsePrebuiltSdks()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900140 // Add dependencies to the stubs library
Jiyong Parke3ef3c82019-07-15 15:31:16 +0900141 if useBuiltStubs {
142 ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
143 }
Colin Cross42d48b72018-08-29 14:10:52 -0700144 ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900145
Paul Duffin250e6192019-06-07 10:44:37 +0100146 sdkDep := decodeSdkDep(ctx, sdkContext(&module.Library))
147 if sdkDep.hasStandardLibs() {
Jiyong Parke3ef3c82019-07-15 15:31:16 +0900148 if useBuiltStubs {
149 ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
150 ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
151 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900152 ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem))
153 ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900154 }
155
156 module.Library.deps(ctx)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900157}
158
Inseob Kimc0907f12019-02-08 21:00:45 +0900159func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900160 module.Library.GenerateAndroidBuildActions(ctx)
161
Sundong Ahn57368eb2018-07-06 11:20:23 +0900162 // Record the paths to the header jars of the library (stubs and impl).
Jiyong Parkc678ad32018-04-10 13:07:10 +0900163 // When this java_sdk_library is dependened from others via "libs" property,
164 // the recorded paths will be returned depending on the link type of the caller.
165 ctx.VisitDirectDeps(func(to android.Module) {
166 otherName := ctx.OtherModuleName(to)
167 tag := ctx.OtherModuleDependencyTag(to)
168
Sundong Ahn57368eb2018-07-06 11:20:23 +0900169 if lib, ok := to.(Dependency); ok {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900170 switch tag {
171 case publicApiStubsTag:
Sundong Ahn57368eb2018-07-06 11:20:23 +0900172 module.publicApiStubsPath = lib.HeaderJars()
Sundong Ahn241cd372018-07-13 16:16:44 +0900173 module.publicApiStubsImplPath = lib.ImplementationJars()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900174 case systemApiStubsTag:
Sundong Ahn57368eb2018-07-06 11:20:23 +0900175 module.systemApiStubsPath = lib.HeaderJars()
Sundong Ahn241cd372018-07-13 16:16:44 +0900176 module.systemApiStubsImplPath = lib.ImplementationJars()
Jiyong Parkdf130542018-04-27 16:29:21 +0900177 case testApiStubsTag:
Sundong Ahn57368eb2018-07-06 11:20:23 +0900178 module.testApiStubsPath = lib.HeaderJars()
Sundong Ahn241cd372018-07-13 16:16:44 +0900179 module.testApiStubsImplPath = lib.ImplementationJars()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900180 }
181 }
Sundong Ahn20e998b2018-07-24 11:19:26 +0900182 if doc, ok := to.(ApiFilePath); ok {
183 switch tag {
184 case publicApiFileTag:
185 module.publicApiFilePath = doc.ApiFilePath()
186 case systemApiFileTag:
187 module.systemApiFilePath = doc.ApiFilePath()
188 case testApiFileTag:
189 module.testApiFilePath = doc.ApiFilePath()
190 default:
191 ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
192 }
193 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900194 })
195}
196
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700197func (module *SdkLibrary) AndroidMkEntries() android.AndroidMkEntries {
198 entries := module.Library.AndroidMkEntries()
199 entries.Required = append(entries.Required, module.xmlFileName())
Sundong Ahn054b19a2018-10-19 13:46:09 +0900200
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700201 entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
202 func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
203 module.Library.AndroidMkHostDex(w, name, entries)
204 if !Bool(module.sdkLibraryProperties.No_dist) {
205 // Create a phony module that installs the impl library, for the case when this lib is
206 // in PRODUCT_PACKAGES.
207 owner := module.ModuleBase.Owner()
208 if owner == "" {
209 if Bool(module.sdkLibraryProperties.Core_lib) {
210 owner = "core"
211 } else {
212 owner = "android"
213 }
214 }
215 // Create dist rules to install the stubs libs to the dist dir
216 if len(module.publicApiStubsPath) == 1 {
217 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
218 module.publicApiStubsImplPath.Strings()[0]+
219 ":"+path.Join("apistubs", owner, "public",
220 module.BaseModuleName()+".jar")+")")
221 }
222 if len(module.systemApiStubsPath) == 1 {
223 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
224 module.systemApiStubsImplPath.Strings()[0]+
225 ":"+path.Join("apistubs", owner, "system",
226 module.BaseModuleName()+".jar")+")")
227 }
228 if len(module.testApiStubsPath) == 1 {
229 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
230 module.testApiStubsImplPath.Strings()[0]+
231 ":"+path.Join("apistubs", owner, "test",
232 module.BaseModuleName()+".jar")+")")
233 }
234 if module.publicApiFilePath != nil {
235 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
236 module.publicApiFilePath.String()+
237 ":"+path.Join("apistubs", owner, "public", "api",
238 module.BaseModuleName()+".txt")+")")
239 }
240 if module.systemApiFilePath != nil {
241 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
242 module.systemApiFilePath.String()+
243 ":"+path.Join("apistubs", owner, "system", "api",
244 module.BaseModuleName()+".txt")+")")
245 }
246 if module.testApiFilePath != nil {
247 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
248 module.testApiFilePath.String()+
249 ":"+path.Join("apistubs", owner, "test", "api",
250 module.BaseModuleName()+".txt")+")")
Sundong Ahn80a87b32019-05-13 15:02:50 +0900251 }
Sundong Ahn4fd04bb2018-08-31 18:01:37 +0900252 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700253 },
Jiyong Park82484c02018-04-23 21:41:26 +0900254 }
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700255 return entries
Jiyong Park82484c02018-04-23 21:41:26 +0900256}
257
Jiyong Parkc678ad32018-04-10 13:07:10 +0900258// Module name of the stubs library
Inseob Kimc0907f12019-02-08 21:00:45 +0900259func (module *SdkLibrary) stubsName(apiScope apiScope) string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900260 stubsName := module.BaseModuleName() + sdkStubsLibrarySuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900261 switch apiScope {
262 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900263 stubsName = stubsName + sdkSystemApiSuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900264 case apiScopeTest:
265 stubsName = stubsName + sdkTestApiSuffix
Jiyong Parkc678ad32018-04-10 13:07:10 +0900266 }
267 return stubsName
268}
269
270// Module name of the docs
Inseob Kimc0907f12019-02-08 21:00:45 +0900271func (module *SdkLibrary) docsName(apiScope apiScope) string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900272 docsName := module.BaseModuleName() + sdkDocsSuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900273 switch apiScope {
274 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900275 docsName = docsName + sdkSystemApiSuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900276 case apiScopeTest:
277 docsName = docsName + sdkTestApiSuffix
Jiyong Parkc678ad32018-04-10 13:07:10 +0900278 }
279 return docsName
280}
281
282// Module name of the runtime implementation library
Inseob Kimc0907f12019-02-08 21:00:45 +0900283func (module *SdkLibrary) implName() string {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900284 return module.BaseModuleName()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900285}
286
287// File path to the runtime implementation library
Inseob Kimc0907f12019-02-08 21:00:45 +0900288func (module *SdkLibrary) implPath() string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900289 partition := "system"
290 if module.SocSpecific() {
291 partition = "vendor"
292 } else if module.DeviceSpecific() {
293 partition = "odm"
294 } else if module.ProductSpecific() {
295 partition = "product"
296 }
297 return "/" + partition + "/framework/" + module.implName() + ".jar"
298}
299
300// Module name of the XML file for the lib
Inseob Kimc0907f12019-02-08 21:00:45 +0900301func (module *SdkLibrary) xmlFileName() string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900302 return module.BaseModuleName() + sdkXmlFileSuffix
303}
304
305// SDK version that the stubs library is built against. Note that this is always
306// *current. Older stubs library built with a numberd SDK version is created from
307// the prebuilt jar.
Inseob Kimc0907f12019-02-08 21:00:45 +0900308func (module *SdkLibrary) sdkVersion(apiScope apiScope) string {
Jiyong Parkdf130542018-04-27 16:29:21 +0900309 switch apiScope {
310 case apiScopePublic:
311 return "current"
312 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900313 return "system_current"
Jiyong Parkdf130542018-04-27 16:29:21 +0900314 case apiScopeTest:
315 return "test_current"
316 default:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900317 return "current"
318 }
319}
320
321// $(INTERNAL_PLATFORM_<apiTagName>_API_FILE) points to the generated
322// api file for the current source
323// TODO: remove this when apicheck is done in soong
Inseob Kimc0907f12019-02-08 21:00:45 +0900324func (module *SdkLibrary) apiTagName(apiScope apiScope) string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900325 apiTagName := strings.Replace(strings.ToUpper(module.BaseModuleName()), ".", "_", -1)
Jiyong Parkdf130542018-04-27 16:29:21 +0900326 switch apiScope {
327 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900328 apiTagName = apiTagName + "_SYSTEM"
Jiyong Parkdf130542018-04-27 16:29:21 +0900329 case apiScopeTest:
330 apiTagName = apiTagName + "_TEST"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900331 }
332 return apiTagName
333}
334
Inseob Kimc0907f12019-02-08 21:00:45 +0900335func (module *SdkLibrary) latestApiFilegroupName(apiScope apiScope) string {
Jiyong Park58c518b2018-05-12 22:29:12 +0900336 name := ":" + module.BaseModuleName() + ".api."
Jiyong Parkdf130542018-04-27 16:29:21 +0900337 switch apiScope {
Jiyong Park58c518b2018-05-12 22:29:12 +0900338 case apiScopePublic:
339 name = name + "public"
Jiyong Parkdf130542018-04-27 16:29:21 +0900340 case apiScopeSystem:
Jiyong Park58c518b2018-05-12 22:29:12 +0900341 name = name + "system"
Jiyong Parkdf130542018-04-27 16:29:21 +0900342 case apiScopeTest:
Jiyong Park58c518b2018-05-12 22:29:12 +0900343 name = name + "test"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900344 }
Jiyong Park58c518b2018-05-12 22:29:12 +0900345 name = name + ".latest"
346 return name
347}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900348
Inseob Kimc0907f12019-02-08 21:00:45 +0900349func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope apiScope) string {
Jiyong Park58c518b2018-05-12 22:29:12 +0900350 name := ":" + module.BaseModuleName() + "-removed.api."
351 switch apiScope {
352 case apiScopePublic:
353 name = name + "public"
354 case apiScopeSystem:
355 name = name + "system"
356 case apiScopeTest:
357 name = name + "test"
358 }
359 name = name + ".latest"
360 return name
Jiyong Parkc678ad32018-04-10 13:07:10 +0900361}
362
363// Creates a static java library that has API stubs
Colin Crossf8b860a2019-04-16 14:43:28 -0700364func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiScope apiScope) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900365 props := struct {
366 Name *string
367 Srcs []string
368 Sdk_version *string
Sundong Ahnf043cf62018-06-25 16:04:37 +0900369 Libs []string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900370 Soc_specific *bool
371 Device_specific *bool
372 Product_specific *bool
Sundong Ahndd567f92018-07-31 17:19:11 +0900373 Compile_dex *bool
Sundong Ahn054b19a2018-10-19 13:46:09 +0900374 System_modules *string
375 Java_version *string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900376 Product_variables struct {
377 Unbundled_build struct {
378 Enabled *bool
379 }
Jiyong Park82484c02018-04-23 21:41:26 +0900380 Pdk struct {
381 Enabled *bool
382 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900383 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900384 Openjdk9 struct {
385 Srcs []string
386 Javacflags []string
387 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900388 }{}
389
Paul Duffin52d398a2019-06-11 12:31:14 +0100390 sdkVersion := module.sdkVersion(apiScope)
Paul Duffin250e6192019-06-07 10:44:37 +0100391 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
Paul Duffin52d398a2019-06-11 12:31:14 +0100392 if !sdkDep.hasStandardLibs() {
393 sdkVersion = "none"
394 }
Paul Duffin250e6192019-06-07 10:44:37 +0100395
Jiyong Parkdf130542018-04-27 16:29:21 +0900396 props.Name = proptools.StringPtr(module.stubsName(apiScope))
Jiyong Parkc678ad32018-04-10 13:07:10 +0900397 // sources are generated from the droiddoc
Jiyong Parkdf130542018-04-27 16:29:21 +0900398 props.Srcs = []string{":" + module.docsName(apiScope)}
Paul Duffin52d398a2019-06-11 12:31:14 +0100399 props.Sdk_version = proptools.StringPtr(sdkVersion)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900400 props.Libs = module.sdkLibraryProperties.Stub_only_libs
Jiyong Parkc678ad32018-04-10 13:07:10 +0900401 // Unbundled apps will use the prebult one from /prebuilts/sdk
Colin Cross10932872019-04-18 14:27:12 -0700402 if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
Colin Cross2c77ceb2019-01-21 11:56:21 -0800403 props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false)
404 }
Jiyong Park82484c02018-04-23 21:41:26 +0900405 props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900406 props.System_modules = module.Library.Module.deviceProperties.System_modules
407 props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs
408 props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags
409 props.Java_version = module.Library.Module.properties.Java_version
410 if module.Library.Module.deviceProperties.Compile_dex != nil {
411 props.Compile_dex = module.Library.Module.deviceProperties.Compile_dex
Sundong Ahndd567f92018-07-31 17:19:11 +0900412 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900413
414 if module.SocSpecific() {
415 props.Soc_specific = proptools.BoolPtr(true)
416 } else if module.DeviceSpecific() {
417 props.Device_specific = proptools.BoolPtr(true)
418 } else if module.ProductSpecific() {
419 props.Product_specific = proptools.BoolPtr(true)
420 }
421
Colin Cross84dfc3d2019-09-25 11:33:01 -0700422 mctx.CreateModule(LibraryFactory, &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900423}
424
425// Creates a droiddoc module that creates stubs source files from the given full source
426// files
Colin Crossf8b860a2019-04-16 14:43:28 -0700427func (module *SdkLibrary) createDocs(mctx android.LoadHookContext, apiScope apiScope) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900428 props := struct {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900429 Name *string
430 Srcs []string
431 Installable *bool
Paul Duffin52d398a2019-06-11 12:31:14 +0100432 Sdk_version *string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900433 Libs []string
Paul Duffin11512472019-02-11 15:55:17 +0000434 Arg_files []string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900435 Args *string
436 Api_tag_name *string
437 Api_filename *string
438 Removed_api_filename *string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900439 Java_version *string
440 Merge_annotations_dirs []string
441 Merge_inclusion_annotations_dirs []string
442 Check_api struct {
Inseob Kim38449af2019-02-28 14:24:05 +0900443 Current ApiToCheck
444 Last_released ApiToCheck
445 Ignore_missing_latest_api *bool
Jiyong Park58c518b2018-05-12 22:29:12 +0900446 }
Sundong Ahn1b92c822018-05-29 11:35:17 +0900447 Aidl struct {
448 Include_dirs []string
449 Local_include_dirs []string
450 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900451 }{}
452
Paul Duffin250e6192019-06-07 10:44:37 +0100453 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
Paul Duffin52d398a2019-06-11 12:31:14 +0100454 sdkVersion := ""
455 if !sdkDep.hasStandardLibs() {
456 sdkVersion = "none"
457 }
Paul Duffin250e6192019-06-07 10:44:37 +0100458
Jiyong Parkdf130542018-04-27 16:29:21 +0900459 props.Name = proptools.StringPtr(module.docsName(apiScope))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900460 props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
Paul Duffin52d398a2019-06-11 12:31:14 +0100461 props.Sdk_version = proptools.StringPtr(sdkVersion)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900462 props.Installable = proptools.BoolPtr(false)
Sundong Ahne6f0b052018-06-05 16:46:14 +0900463 // A droiddoc module has only one Libs property and doesn't distinguish between
464 // shared libs and static libs. So we need to add both of these libs to Libs property.
Sundong Ahn054b19a2018-10-19 13:46:09 +0900465 props.Libs = module.Library.Module.properties.Libs
466 props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...)
467 props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs
468 props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs
Sundong Ahn054b19a2018-10-19 13:46:09 +0900469 props.Java_version = module.Library.Module.properties.Java_version
Jiyong Parkc678ad32018-04-10 13:07:10 +0900470
Sundong Ahn054b19a2018-10-19 13:46:09 +0900471 props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
472 props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
473
474 droiddocArgs := " --stub-packages " + strings.Join(module.sdkLibraryProperties.Api_packages, ":") +
475 " " + android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package ") +
476 " " + android.JoinWithPrefix(module.sdkLibraryProperties.Droiddoc_options, " ") +
Sundong Ahn04ef8a32019-01-14 11:36:50 +0900477 " --hide MissingPermission --hide BroadcastBehavior " +
478 "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " +
479 "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo"
Sundong Ahnfb2721f2018-09-17 13:23:09 +0900480
Jiyong Parkdf130542018-04-27 16:29:21 +0900481 switch apiScope {
482 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900483 droiddocArgs = droiddocArgs + " -showAnnotation android.annotation.SystemApi"
Jiyong Parkdf130542018-04-27 16:29:21 +0900484 case apiScopeTest:
485 droiddocArgs = droiddocArgs + " -showAnnotation android.annotation.TestApi"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900486 }
Paul Duffin11512472019-02-11 15:55:17 +0000487 props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files
Jiyong Parkc678ad32018-04-10 13:07:10 +0900488 props.Args = proptools.StringPtr(droiddocArgs)
489
490 // List of APIs identified from the provided source files are created. They are later
491 // compared against to the not-yet-released (a.k.a current) list of APIs and to the
492 // last-released (a.k.a numbered) list of API.
Jiyong Parkc678ad32018-04-10 13:07:10 +0900493 currentApiFileName := "current.txt"
494 removedApiFileName := "removed.txt"
Jiyong Parkdf130542018-04-27 16:29:21 +0900495 switch apiScope {
496 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900497 currentApiFileName = "system-" + currentApiFileName
498 removedApiFileName = "system-" + removedApiFileName
Jiyong Parkdf130542018-04-27 16:29:21 +0900499 case apiScopeTest:
500 currentApiFileName = "test-" + currentApiFileName
501 removedApiFileName = "test-" + removedApiFileName
Jiyong Parkc678ad32018-04-10 13:07:10 +0900502 }
503 currentApiFileName = path.Join("api", currentApiFileName)
504 removedApiFileName = path.Join("api", removedApiFileName)
Jiyong Park58c518b2018-05-12 22:29:12 +0900505 // TODO(jiyong): remove these three props
Jiyong Parkdf130542018-04-27 16:29:21 +0900506 props.Api_tag_name = proptools.StringPtr(module.apiTagName(apiScope))
Jiyong Parkc678ad32018-04-10 13:07:10 +0900507 props.Api_filename = proptools.StringPtr(currentApiFileName)
508 props.Removed_api_filename = proptools.StringPtr(removedApiFileName)
509
Jiyong Park58c518b2018-05-12 22:29:12 +0900510 // check against the not-yet-release API
511 props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName)
512 props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName)
Jiyong Park58c518b2018-05-12 22:29:12 +0900513
514 // check against the latest released API
515 props.Check_api.Last_released.Api_file = proptools.StringPtr(
516 module.latestApiFilegroupName(apiScope))
517 props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
518 module.latestRemovedApiFilegroupName(apiScope))
Inseob Kim38449af2019-02-28 14:24:05 +0900519 props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
Jiyong Park58c518b2018-05-12 22:29:12 +0900520
Colin Cross84dfc3d2019-09-25 11:33:01 -0700521 mctx.CreateModule(DroidstubsFactory, &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900522}
523
Jiyong Parkc678ad32018-04-10 13:07:10 +0900524// Creates the xml file that publicizes the runtime library
Colin Crossf8b860a2019-04-16 14:43:28 -0700525func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900526 template := `
527<?xml version="1.0" encoding="utf-8"?>
528<!-- Copyright (C) 2018 The Android Open Source Project
529
530 Licensed under the Apache License, Version 2.0 (the "License");
531 you may not use this file except in compliance with the License.
532 You may obtain a copy of the License at
Jiyong Park1112c4c2019-08-16 21:12:10 +0900533
Jiyong Parkc678ad32018-04-10 13:07:10 +0900534 http://www.apache.org/licenses/LICENSE-2.0
Jiyong Park1112c4c2019-08-16 21:12:10 +0900535
Jiyong Parkc678ad32018-04-10 13:07:10 +0900536 Unless required by applicable law or agreed to in writing, software
537 distributed under the License is distributed on an "AS IS" BASIS,
538 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539 See the License for the specific language governing permissions and
540 limitations under the License.
541-->
542
543<permissions>
544 <library name="%s" file="%s"/>
545</permissions>
546`
547 // genrule to generate the xml file content from the template above
548 // TODO: preserve newlines in the generate xml file. Newlines are being squashed
549 // in the ninja file. Do we need to have an external tool for this?
550 xmlContent := fmt.Sprintf(template, module.BaseModuleName(), module.implPath())
551 genruleProps := struct {
552 Name *string
553 Cmd *string
554 Out []string
555 }{}
556 genruleProps.Name = proptools.StringPtr(module.xmlFileName() + "-gen")
557 genruleProps.Cmd = proptools.StringPtr("echo '" + xmlContent + "' > $(out)")
558 genruleProps.Out = []string{module.xmlFileName()}
Colin Cross84dfc3d2019-09-25 11:33:01 -0700559 mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900560
561 // creates a prebuilt_etc module to actually place the xml file under
562 // <partition>/etc/permissions
563 etcProps := struct {
564 Name *string
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900565 Src *string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900566 Sub_dir *string
567 Soc_specific *bool
568 Device_specific *bool
569 Product_specific *bool
570 }{}
571 etcProps.Name = proptools.StringPtr(module.xmlFileName())
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900572 etcProps.Src = proptools.StringPtr(":" + module.xmlFileName() + "-gen")
Jiyong Parkc678ad32018-04-10 13:07:10 +0900573 etcProps.Sub_dir = proptools.StringPtr("permissions")
574 if module.SocSpecific() {
575 etcProps.Soc_specific = proptools.BoolPtr(true)
576 } else if module.DeviceSpecific() {
577 etcProps.Device_specific = proptools.BoolPtr(true)
578 } else if module.ProductSpecific() {
579 etcProps.Product_specific = proptools.BoolPtr(true)
580 }
Colin Cross84dfc3d2019-09-25 11:33:01 -0700581 mctx.CreateModule(android.PrebuiltEtcFactory, &etcProps)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900582}
583
Colin Cross0ea8ba82019-06-06 14:33:29 -0700584func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900585 var api, v string
Paul Duffin52d398a2019-06-11 12:31:14 +0100586 if sdkVersion == "" || sdkVersion == "none" {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900587 api = "system"
588 v = "current"
589 } else if strings.Contains(sdkVersion, "_") {
590 t := strings.Split(sdkVersion, "_")
591 api = t[0]
592 v = t[1]
Jiyong Parkc678ad32018-04-10 13:07:10 +0900593 } else {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900594 api = "public"
595 v = sdkVersion
596 }
597 dir := filepath.Join("prebuilts", "sdk", v, api)
598 jar := filepath.Join(dir, module.BaseModuleName()+".jar")
599 jarPath := android.ExistentPathForSource(ctx, jar)
Sundong Ahnae418ac2019-02-28 15:01:28 +0900600 if !jarPath.Valid() {
601 ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", v, jar)
602 return nil
603 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900604 return android.Paths{jarPath.Path()}
605}
606
607// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700608func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900609 // This module is just a wrapper for the stubs.
Colin Cross10932872019-04-18 14:27:12 -0700610 if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900611 return module.PrebuiltJars(ctx, sdkVersion)
612 } else {
613 if strings.HasPrefix(sdkVersion, "system_") {
614 return module.systemApiStubsPath
615 } else if sdkVersion == "" {
616 return module.Library.HeaderJars()
617 } else {
618 return module.publicApiStubsPath
619 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900620 }
621}
622
Sundong Ahn241cd372018-07-13 16:16:44 +0900623// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700624func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Sundong Ahn241cd372018-07-13 16:16:44 +0900625 // This module is just a wrapper for the stubs.
Colin Cross10932872019-04-18 14:27:12 -0700626 if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900627 return module.PrebuiltJars(ctx, sdkVersion)
Sundong Ahn241cd372018-07-13 16:16:44 +0900628 } else {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900629 if strings.HasPrefix(sdkVersion, "system_") {
630 return module.systemApiStubsImplPath
631 } else if sdkVersion == "" {
632 return module.Library.ImplementationJars()
633 } else {
634 return module.publicApiStubsImplPath
635 }
Sundong Ahn241cd372018-07-13 16:16:44 +0900636 }
637}
638
Sundong Ahn80a87b32019-05-13 15:02:50 +0900639func (module *SdkLibrary) SetNoDist() {
640 module.sdkLibraryProperties.No_dist = proptools.BoolPtr(true)
641}
642
Colin Cross571cccf2019-02-04 11:22:08 -0800643var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
644
Jiyong Park82484c02018-04-23 21:41:26 +0900645func javaSdkLibraries(config android.Config) *[]string {
Colin Cross571cccf2019-02-04 11:22:08 -0800646 return config.Once(javaSdkLibrariesKey, func() interface{} {
Jiyong Park82484c02018-04-23 21:41:26 +0900647 return &[]string{}
648 }).(*[]string)
649}
650
Jiyong Parkc678ad32018-04-10 13:07:10 +0900651// For a java_sdk_library module, create internal modules for stubs, docs,
652// runtime libs and xml file. If requested, the stubs and docs are created twice
653// once for public API level and once for system API level
Colin Crossf8b860a2019-04-16 14:43:28 -0700654func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
Inseob Kim6e93ac92019-03-21 17:43:49 +0900655 if len(module.Library.Module.properties.Srcs) == 0 {
Inseob Kimc0907f12019-02-08 21:00:45 +0900656 mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
657 }
658
Inseob Kim6e93ac92019-03-21 17:43:49 +0900659 if len(module.sdkLibraryProperties.Api_packages) == 0 {
Inseob Kimc0907f12019-02-08 21:00:45 +0900660 mctx.PropertyErrorf("api_packages", "java_sdk_library must specify api_packages")
661 }
Inseob Kim8098faa2019-03-18 10:19:51 +0900662
663 missing_current_api := false
664
665 for _, scope := range []string{"", "system-", "test-"} {
666 for _, api := range []string{"current.txt", "removed.txt"} {
667 path := path.Join(mctx.ModuleDir(), "api", scope+api)
668 p := android.ExistentPathForSource(mctx, path)
669 if !p.Valid() {
670 mctx.ModuleErrorf("Current api file %#v doesn't exist", path)
671 missing_current_api = true
672 }
673 }
674 }
675
676 if missing_current_api {
677 script := "build/soong/scripts/gen-java-current-api-files.sh"
678 p := android.ExistentPathForSource(mctx, script)
679
680 if !p.Valid() {
681 panic(fmt.Sprintf("script file %s doesn't exist", script))
682 }
683
684 mctx.ModuleErrorf("One or more current api files are missing. "+
685 "You can update them by:\n"+
686 "%s %q && m update-api", script, mctx.ModuleDir())
687 return
688 }
689
Inseob Kimc0907f12019-02-08 21:00:45 +0900690 // for public API stubs
691 module.createStubsLibrary(mctx, apiScopePublic)
692 module.createDocs(mctx, apiScopePublic)
693
Paul Duffin250e6192019-06-07 10:44:37 +0100694 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
695 if sdkDep.hasStandardLibs() {
Inseob Kimc0907f12019-02-08 21:00:45 +0900696 // for system API stubs
697 module.createStubsLibrary(mctx, apiScopeSystem)
698 module.createDocs(mctx, apiScopeSystem)
699
700 // for test API stubs
701 module.createStubsLibrary(mctx, apiScopeTest)
702 module.createDocs(mctx, apiScopeTest)
703
704 // for runtime
705 module.createXmlFile(mctx)
706 }
707
708 // record java_sdk_library modules so that they are exported to make
709 javaSdkLibraries := javaSdkLibraries(mctx.Config())
710 javaSdkLibrariesLock.Lock()
711 defer javaSdkLibrariesLock.Unlock()
712 *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
713}
714
715func (module *SdkLibrary) InitSdkLibraryProperties() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900716 module.AddProperties(
717 &module.sdkLibraryProperties,
718 &module.Library.Module.properties,
719 &module.Library.Module.dexpreoptProperties,
720 &module.Library.Module.deviceProperties,
721 &module.Library.Module.protoProperties,
722 )
723
724 module.Library.Module.properties.Installable = proptools.BoolPtr(true)
725 module.Library.Module.deviceProperties.IsSDKLibrary = true
Inseob Kimc0907f12019-02-08 21:00:45 +0900726}
Sundong Ahn054b19a2018-10-19 13:46:09 +0900727
Jaewoong Jung4f158ee2019-07-11 10:05:35 -0700728// java_sdk_library is a special Java library that provides optional platform APIs to apps.
729// In practice, it can be viewed as a combination of several modules: 1) stubs library that clients
730// are linked against to, 2) droiddoc module that internally generates API stubs source files,
731// 3) the real runtime shared library that implements the APIs, and 4) XML file for adding
732// the runtime lib to the classpath at runtime if requested via <uses-library>.
Inseob Kimc0907f12019-02-08 21:00:45 +0900733func SdkLibraryFactory() android.Module {
734 module := &SdkLibrary{}
735 module.InitSdkLibraryProperties()
Sundong Ahn054b19a2018-10-19 13:46:09 +0900736 InitJavaModule(module, android.HostAndDeviceSupported)
Colin Crossf8b860a2019-04-16 14:43:28 -0700737 android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.CreateInternalModules(ctx) })
Jiyong Parkc678ad32018-04-10 13:07:10 +0900738 return module
739}
Colin Cross79c7c262019-04-17 11:11:46 -0700740
741//
742// SDK library prebuilts
743//
744
745type sdkLibraryImportProperties struct {
746 Jars []string `android:"path"`
747
748 Sdk_version *string
749
750 Installable *bool
751
752 // List of shared java libs that this module has dependencies to
753 Libs []string
754
755 // List of files to remove from the jar file(s)
756 Exclude_files []string
757
758 // List of directories to remove from the jar file(s)
759 Exclude_dirs []string
760}
761
762type sdkLibraryImport struct {
763 android.ModuleBase
764 android.DefaultableModuleBase
765 prebuilt android.Prebuilt
766
767 properties sdkLibraryImportProperties
768
769 stubsPath android.Paths
770}
771
772var _ SdkLibraryDependency = (*sdkLibraryImport)(nil)
773
Jaewoong Jung4f158ee2019-07-11 10:05:35 -0700774// java_sdk_library_import imports a prebuilt java_sdk_library.
Colin Cross79c7c262019-04-17 11:11:46 -0700775func sdkLibraryImportFactory() android.Module {
776 module := &sdkLibraryImport{}
777
778 module.AddProperties(&module.properties)
779
780 android.InitPrebuiltModule(module, &module.properties.Jars)
781 InitJavaModule(module, android.HostAndDeviceSupported)
782
783 android.AddLoadHook(module, func(mctx android.LoadHookContext) { module.createInternalModules(mctx) })
784 return module
785}
786
787func (module *sdkLibraryImport) Prebuilt() *android.Prebuilt {
788 return &module.prebuilt
789}
790
791func (module *sdkLibraryImport) Name() string {
792 return module.prebuilt.Name(module.ModuleBase.Name())
793}
794
795func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) {
796 // Creates a java import for the jar with ".stubs" suffix
797 props := struct {
798 Name *string
799 Soc_specific *bool
800 Device_specific *bool
801 Product_specific *bool
802 }{}
803
804 props.Name = proptools.StringPtr(module.BaseModuleName() + sdkStubsLibrarySuffix)
805
806 if module.SocSpecific() {
807 props.Soc_specific = proptools.BoolPtr(true)
808 } else if module.DeviceSpecific() {
809 props.Device_specific = proptools.BoolPtr(true)
810 } else if module.ProductSpecific() {
811 props.Product_specific = proptools.BoolPtr(true)
812 }
813
Colin Cross84dfc3d2019-09-25 11:33:01 -0700814 mctx.CreateModule(ImportFactory, &props, &module.properties)
Colin Cross79c7c262019-04-17 11:11:46 -0700815
816 javaSdkLibraries := javaSdkLibraries(mctx.Config())
817 javaSdkLibrariesLock.Lock()
818 defer javaSdkLibrariesLock.Unlock()
819 *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
820}
821
822func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
823 // Add dependencies to the prebuilt stubs library
824 ctx.AddVariationDependencies(nil, publicApiStubsTag, module.BaseModuleName()+sdkStubsLibrarySuffix)
825}
826
827func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
828 // Record the paths to the prebuilt stubs library.
829 ctx.VisitDirectDeps(func(to android.Module) {
830 tag := ctx.OtherModuleDependencyTag(to)
831
832 switch tag {
833 case publicApiStubsTag:
834 module.stubsPath = to.(Dependency).HeaderJars()
835 }
836 })
837}
838
839// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700840func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Colin Cross79c7c262019-04-17 11:11:46 -0700841 // This module is just a wrapper for the prebuilt stubs.
842 return module.stubsPath
843}
844
845// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700846func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Colin Cross79c7c262019-04-17 11:11:46 -0700847 // This module is just a wrapper for the stubs.
848 return module.stubsPath
849}