blob: 30fd1c4e2aa0f651c20da755ede63b212c62c19c [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 {
Jiyong Parkbaaf9dd2018-05-02 01:35:27 +090082 // list of optional source files that are part of API but not part of runtime library.
83 Api_srcs []string `android:"arch_variant"`
84
Sundong Ahnf043cf62018-06-25 16:04:37 +090085 // List of Java libraries that will be in the classpath when building stubs
86 Stub_only_libs []string `android:"arch_variant"`
87
Jiyong Parkc678ad32018-04-10 13:07:10 +090088 // list of package names that will be documented and publicized as API
89 Api_packages []string
90
Jiyong Park5a2c9d72018-05-01 22:25:41 +090091 // list of package names that must be hidden from the API
92 Hidden_api_packages []string
93
Paul Duffin11512472019-02-11 15:55:17 +000094 // local files that are used within user customized droiddoc options.
95 Droiddoc_option_files []string
96
97 // additional droiddoc options
98 // Available variables for substitution:
99 //
100 // $(location <label>): the path to the droiddoc_option_files with name <label>
Sundong Ahndd567f92018-07-31 17:19:11 +0900101 Droiddoc_options []string
102
Sundong Ahn054b19a2018-10-19 13:46:09 +0900103 // a list of top-level directories containing files to merge qualifier annotations
104 // (i.e. those intended to be included in the stubs written) from.
105 Merge_annotations_dirs []string
106
107 // a list of top-level directories containing Java stub files to merge show/hide annotations from.
108 Merge_inclusion_annotations_dirs []string
109
110 // If set to true, the path of dist files is apistubs/core. Defaults to false.
111 Core_lib *bool
112
Sundong Ahn80a87b32019-05-13 15:02:50 +0900113 // don't create dist rules.
114 No_dist *bool `blueprint:"mutated"`
115
Jiyong Parkc678ad32018-04-10 13:07:10 +0900116 // TODO: determines whether to create HTML doc or not
117 //Html_doc *bool
118}
119
Inseob Kimc0907f12019-02-08 21:00:45 +0900120type SdkLibrary struct {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900121 Library
Jiyong Parkc678ad32018-04-10 13:07:10 +0900122
Sundong Ahn054b19a2018-10-19 13:46:09 +0900123 sdkLibraryProperties sdkLibraryProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900124
125 publicApiStubsPath android.Paths
126 systemApiStubsPath android.Paths
Jiyong Parkdf130542018-04-27 16:29:21 +0900127 testApiStubsPath android.Paths
Sundong Ahn241cd372018-07-13 16:16:44 +0900128
129 publicApiStubsImplPath android.Paths
130 systemApiStubsImplPath android.Paths
131 testApiStubsImplPath android.Paths
Sundong Ahn20e998b2018-07-24 11:19:26 +0900132
133 publicApiFilePath android.Path
134 systemApiFilePath android.Path
135 testApiFilePath android.Path
Jiyong Parkc678ad32018-04-10 13:07:10 +0900136}
137
Inseob Kimc0907f12019-02-08 21:00:45 +0900138var _ Dependency = (*SdkLibrary)(nil)
139var _ SdkLibraryDependency = (*SdkLibrary)(nil)
Colin Cross897d2ed2019-02-11 14:03:51 -0800140
Inseob Kimc0907f12019-02-08 21:00:45 +0900141func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
Jiyong Parke3ef3c82019-07-15 15:31:16 +0900142 useBuiltStubs := !ctx.Config().UnbundledBuildUsePrebuiltSdks()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900143 // Add dependencies to the stubs library
Jiyong Parke3ef3c82019-07-15 15:31:16 +0900144 if useBuiltStubs {
145 ctx.AddVariationDependencies(nil, publicApiStubsTag, module.stubsName(apiScopePublic))
146 }
Colin Cross42d48b72018-08-29 14:10:52 -0700147 ctx.AddVariationDependencies(nil, publicApiFileTag, module.docsName(apiScopePublic))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900148
Paul Duffin250e6192019-06-07 10:44:37 +0100149 sdkDep := decodeSdkDep(ctx, sdkContext(&module.Library))
150 if sdkDep.hasStandardLibs() {
Jiyong Parke3ef3c82019-07-15 15:31:16 +0900151 if useBuiltStubs {
152 ctx.AddVariationDependencies(nil, systemApiStubsTag, module.stubsName(apiScopeSystem))
153 ctx.AddVariationDependencies(nil, testApiStubsTag, module.stubsName(apiScopeTest))
154 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900155 ctx.AddVariationDependencies(nil, systemApiFileTag, module.docsName(apiScopeSystem))
156 ctx.AddVariationDependencies(nil, testApiFileTag, module.docsName(apiScopeTest))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900157 }
158
159 module.Library.deps(ctx)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900160}
161
Inseob Kimc0907f12019-02-08 21:00:45 +0900162func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900163 module.Library.GenerateAndroidBuildActions(ctx)
164
Sundong Ahn57368eb2018-07-06 11:20:23 +0900165 // Record the paths to the header jars of the library (stubs and impl).
Jiyong Parkc678ad32018-04-10 13:07:10 +0900166 // When this java_sdk_library is dependened from others via "libs" property,
167 // the recorded paths will be returned depending on the link type of the caller.
168 ctx.VisitDirectDeps(func(to android.Module) {
169 otherName := ctx.OtherModuleName(to)
170 tag := ctx.OtherModuleDependencyTag(to)
171
Sundong Ahn57368eb2018-07-06 11:20:23 +0900172 if lib, ok := to.(Dependency); ok {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900173 switch tag {
174 case publicApiStubsTag:
Sundong Ahn57368eb2018-07-06 11:20:23 +0900175 module.publicApiStubsPath = lib.HeaderJars()
Sundong Ahn241cd372018-07-13 16:16:44 +0900176 module.publicApiStubsImplPath = lib.ImplementationJars()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900177 case systemApiStubsTag:
Sundong Ahn57368eb2018-07-06 11:20:23 +0900178 module.systemApiStubsPath = lib.HeaderJars()
Sundong Ahn241cd372018-07-13 16:16:44 +0900179 module.systemApiStubsImplPath = lib.ImplementationJars()
Jiyong Parkdf130542018-04-27 16:29:21 +0900180 case testApiStubsTag:
Sundong Ahn57368eb2018-07-06 11:20:23 +0900181 module.testApiStubsPath = lib.HeaderJars()
Sundong Ahn241cd372018-07-13 16:16:44 +0900182 module.testApiStubsImplPath = lib.ImplementationJars()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900183 }
184 }
Sundong Ahn20e998b2018-07-24 11:19:26 +0900185 if doc, ok := to.(ApiFilePath); ok {
186 switch tag {
187 case publicApiFileTag:
188 module.publicApiFilePath = doc.ApiFilePath()
189 case systemApiFileTag:
190 module.systemApiFilePath = doc.ApiFilePath()
191 case testApiFileTag:
192 module.testApiFilePath = doc.ApiFilePath()
193 default:
194 ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
195 }
196 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900197 })
198}
199
Inseob Kimc0907f12019-02-08 21:00:45 +0900200func (module *SdkLibrary) AndroidMk() android.AndroidMkData {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900201 data := module.Library.AndroidMk()
202 data.Required = append(data.Required, module.xmlFileName())
203
204 data.Custom = func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
205 android.WriteAndroidMkData(w, data)
206
207 module.Library.AndroidMkHostDex(w, name, data)
Sundong Ahn80a87b32019-05-13 15:02:50 +0900208 if !Bool(module.sdkLibraryProperties.No_dist) {
209 // Create a phony module that installs the impl library, for the case when this lib is
210 // in PRODUCT_PACKAGES.
211 owner := module.ModuleBase.Owner()
212 if owner == "" {
213 if Bool(module.sdkLibraryProperties.Core_lib) {
214 owner = "core"
215 } else {
216 owner = "android"
217 }
Sundong Ahn4fd04bb2018-08-31 18:01:37 +0900218 }
Sundong Ahn80a87b32019-05-13 15:02:50 +0900219 // Create dist rules to install the stubs libs to the dist dir
220 if len(module.publicApiStubsPath) == 1 {
221 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
222 module.publicApiStubsImplPath.Strings()[0]+
223 ":"+path.Join("apistubs", owner, "public",
224 module.BaseModuleName()+".jar")+")")
225 }
226 if len(module.systemApiStubsPath) == 1 {
227 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
228 module.systemApiStubsImplPath.Strings()[0]+
229 ":"+path.Join("apistubs", owner, "system",
230 module.BaseModuleName()+".jar")+")")
231 }
232 if len(module.testApiStubsPath) == 1 {
233 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
234 module.testApiStubsImplPath.Strings()[0]+
235 ":"+path.Join("apistubs", owner, "test",
236 module.BaseModuleName()+".jar")+")")
237 }
238 if module.publicApiFilePath != nil {
239 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
240 module.publicApiFilePath.String()+
241 ":"+path.Join("apistubs", owner, "public", "api",
242 module.BaseModuleName()+".txt")+")")
243 }
244 if module.systemApiFilePath != nil {
245 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
246 module.systemApiFilePath.String()+
247 ":"+path.Join("apistubs", owner, "system", "api",
248 module.BaseModuleName()+".txt")+")")
249 }
250 if module.testApiFilePath != nil {
251 fmt.Fprintln(w, "$(call dist-for-goals,sdk win_sdk,"+
252 module.testApiFilePath.String()+
253 ":"+path.Join("apistubs", owner, "test", "api",
254 module.BaseModuleName()+".txt")+")")
255 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900256 }
Jiyong Park82484c02018-04-23 21:41:26 +0900257 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900258 return data
Jiyong Park82484c02018-04-23 21:41:26 +0900259}
260
Jiyong Parkc678ad32018-04-10 13:07:10 +0900261// Module name of the stubs library
Inseob Kimc0907f12019-02-08 21:00:45 +0900262func (module *SdkLibrary) stubsName(apiScope apiScope) string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900263 stubsName := module.BaseModuleName() + sdkStubsLibrarySuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900264 switch apiScope {
265 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900266 stubsName = stubsName + sdkSystemApiSuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900267 case apiScopeTest:
268 stubsName = stubsName + sdkTestApiSuffix
Jiyong Parkc678ad32018-04-10 13:07:10 +0900269 }
270 return stubsName
271}
272
273// Module name of the docs
Inseob Kimc0907f12019-02-08 21:00:45 +0900274func (module *SdkLibrary) docsName(apiScope apiScope) string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900275 docsName := module.BaseModuleName() + sdkDocsSuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900276 switch apiScope {
277 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900278 docsName = docsName + sdkSystemApiSuffix
Jiyong Parkdf130542018-04-27 16:29:21 +0900279 case apiScopeTest:
280 docsName = docsName + sdkTestApiSuffix
Jiyong Parkc678ad32018-04-10 13:07:10 +0900281 }
282 return docsName
283}
284
285// Module name of the runtime implementation library
Inseob Kimc0907f12019-02-08 21:00:45 +0900286func (module *SdkLibrary) implName() string {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900287 return module.BaseModuleName()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900288}
289
290// File path to the runtime implementation library
Inseob Kimc0907f12019-02-08 21:00:45 +0900291func (module *SdkLibrary) implPath() string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900292 partition := "system"
293 if module.SocSpecific() {
294 partition = "vendor"
295 } else if module.DeviceSpecific() {
296 partition = "odm"
297 } else if module.ProductSpecific() {
298 partition = "product"
299 }
300 return "/" + partition + "/framework/" + module.implName() + ".jar"
301}
302
303// Module name of the XML file for the lib
Inseob Kimc0907f12019-02-08 21:00:45 +0900304func (module *SdkLibrary) xmlFileName() string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900305 return module.BaseModuleName() + sdkXmlFileSuffix
306}
307
308// SDK version that the stubs library is built against. Note that this is always
309// *current. Older stubs library built with a numberd SDK version is created from
310// the prebuilt jar.
Inseob Kimc0907f12019-02-08 21:00:45 +0900311func (module *SdkLibrary) sdkVersion(apiScope apiScope) string {
Jiyong Parkdf130542018-04-27 16:29:21 +0900312 switch apiScope {
313 case apiScopePublic:
314 return "current"
315 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900316 return "system_current"
Jiyong Parkdf130542018-04-27 16:29:21 +0900317 case apiScopeTest:
318 return "test_current"
319 default:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900320 return "current"
321 }
322}
323
324// $(INTERNAL_PLATFORM_<apiTagName>_API_FILE) points to the generated
325// api file for the current source
326// TODO: remove this when apicheck is done in soong
Inseob Kimc0907f12019-02-08 21:00:45 +0900327func (module *SdkLibrary) apiTagName(apiScope apiScope) string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900328 apiTagName := strings.Replace(strings.ToUpper(module.BaseModuleName()), ".", "_", -1)
Jiyong Parkdf130542018-04-27 16:29:21 +0900329 switch apiScope {
330 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900331 apiTagName = apiTagName + "_SYSTEM"
Jiyong Parkdf130542018-04-27 16:29:21 +0900332 case apiScopeTest:
333 apiTagName = apiTagName + "_TEST"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900334 }
335 return apiTagName
336}
337
Inseob Kimc0907f12019-02-08 21:00:45 +0900338func (module *SdkLibrary) latestApiFilegroupName(apiScope apiScope) string {
Jiyong Park58c518b2018-05-12 22:29:12 +0900339 name := ":" + module.BaseModuleName() + ".api."
Jiyong Parkdf130542018-04-27 16:29:21 +0900340 switch apiScope {
Jiyong Park58c518b2018-05-12 22:29:12 +0900341 case apiScopePublic:
342 name = name + "public"
Jiyong Parkdf130542018-04-27 16:29:21 +0900343 case apiScopeSystem:
Jiyong Park58c518b2018-05-12 22:29:12 +0900344 name = name + "system"
Jiyong Parkdf130542018-04-27 16:29:21 +0900345 case apiScopeTest:
Jiyong Park58c518b2018-05-12 22:29:12 +0900346 name = name + "test"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900347 }
Jiyong Park58c518b2018-05-12 22:29:12 +0900348 name = name + ".latest"
349 return name
350}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900351
Inseob Kimc0907f12019-02-08 21:00:45 +0900352func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope apiScope) string {
Jiyong Park58c518b2018-05-12 22:29:12 +0900353 name := ":" + module.BaseModuleName() + "-removed.api."
354 switch apiScope {
355 case apiScopePublic:
356 name = name + "public"
357 case apiScopeSystem:
358 name = name + "system"
359 case apiScopeTest:
360 name = name + "test"
361 }
362 name = name + ".latest"
363 return name
Jiyong Parkc678ad32018-04-10 13:07:10 +0900364}
365
366// Creates a static java library that has API stubs
Colin Crossf8b860a2019-04-16 14:43:28 -0700367func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiScope apiScope) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900368 props := struct {
369 Name *string
370 Srcs []string
371 Sdk_version *string
Sundong Ahnf043cf62018-06-25 16:04:37 +0900372 Libs []string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900373 Soc_specific *bool
374 Device_specific *bool
375 Product_specific *bool
Sundong Ahndd567f92018-07-31 17:19:11 +0900376 Compile_dex *bool
Sundong Ahn054b19a2018-10-19 13:46:09 +0900377 System_modules *string
378 Java_version *string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900379 Product_variables struct {
380 Unbundled_build struct {
381 Enabled *bool
382 }
Jiyong Park82484c02018-04-23 21:41:26 +0900383 Pdk struct {
384 Enabled *bool
385 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900386 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900387 Openjdk9 struct {
388 Srcs []string
389 Javacflags []string
390 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900391 }{}
392
Paul Duffin52d398a2019-06-11 12:31:14 +0100393 sdkVersion := module.sdkVersion(apiScope)
Paul Duffin250e6192019-06-07 10:44:37 +0100394 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
Paul Duffin52d398a2019-06-11 12:31:14 +0100395 if !sdkDep.hasStandardLibs() {
396 sdkVersion = "none"
397 }
Paul Duffin250e6192019-06-07 10:44:37 +0100398
Jiyong Parkdf130542018-04-27 16:29:21 +0900399 props.Name = proptools.StringPtr(module.stubsName(apiScope))
Jiyong Parkc678ad32018-04-10 13:07:10 +0900400 // sources are generated from the droiddoc
Jiyong Parkdf130542018-04-27 16:29:21 +0900401 props.Srcs = []string{":" + module.docsName(apiScope)}
Paul Duffin52d398a2019-06-11 12:31:14 +0100402 props.Sdk_version = proptools.StringPtr(sdkVersion)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900403 props.Libs = module.sdkLibraryProperties.Stub_only_libs
Jiyong Parkc678ad32018-04-10 13:07:10 +0900404 // Unbundled apps will use the prebult one from /prebuilts/sdk
Colin Cross10932872019-04-18 14:27:12 -0700405 if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
Colin Cross2c77ceb2019-01-21 11:56:21 -0800406 props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false)
407 }
Jiyong Park82484c02018-04-23 21:41:26 +0900408 props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900409 props.System_modules = module.Library.Module.deviceProperties.System_modules
410 props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs
411 props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags
412 props.Java_version = module.Library.Module.properties.Java_version
413 if module.Library.Module.deviceProperties.Compile_dex != nil {
414 props.Compile_dex = module.Library.Module.deviceProperties.Compile_dex
Sundong Ahndd567f92018-07-31 17:19:11 +0900415 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900416
417 if module.SocSpecific() {
418 props.Soc_specific = proptools.BoolPtr(true)
419 } else if module.DeviceSpecific() {
420 props.Device_specific = proptools.BoolPtr(true)
421 } else if module.ProductSpecific() {
422 props.Product_specific = proptools.BoolPtr(true)
423 }
424
Colin Cross9ae1b922018-06-26 17:59:05 -0700425 mctx.CreateModule(android.ModuleFactoryAdaptor(LibraryFactory), &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900426}
427
428// Creates a droiddoc module that creates stubs source files from the given full source
429// files
Colin Crossf8b860a2019-04-16 14:43:28 -0700430func (module *SdkLibrary) createDocs(mctx android.LoadHookContext, apiScope apiScope) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900431 props := struct {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900432 Name *string
433 Srcs []string
434 Installable *bool
Paul Duffin52d398a2019-06-11 12:31:14 +0100435 Sdk_version *string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900436 Libs []string
Paul Duffin11512472019-02-11 15:55:17 +0000437 Arg_files []string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900438 Args *string
439 Api_tag_name *string
440 Api_filename *string
441 Removed_api_filename *string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900442 Java_version *string
443 Merge_annotations_dirs []string
444 Merge_inclusion_annotations_dirs []string
445 Check_api struct {
Inseob Kim38449af2019-02-28 14:24:05 +0900446 Current ApiToCheck
447 Last_released ApiToCheck
448 Ignore_missing_latest_api *bool
Jiyong Park58c518b2018-05-12 22:29:12 +0900449 }
Sundong Ahn1b92c822018-05-29 11:35:17 +0900450 Aidl struct {
451 Include_dirs []string
452 Local_include_dirs []string
453 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900454 }{}
455
Paul Duffin250e6192019-06-07 10:44:37 +0100456 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
Paul Duffin52d398a2019-06-11 12:31:14 +0100457 sdkVersion := ""
458 if !sdkDep.hasStandardLibs() {
459 sdkVersion = "none"
460 }
Paul Duffin250e6192019-06-07 10:44:37 +0100461
Jiyong Parkdf130542018-04-27 16:29:21 +0900462 props.Name = proptools.StringPtr(module.docsName(apiScope))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900463 props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
464 props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...)
Paul Duffin52d398a2019-06-11 12:31:14 +0100465 props.Sdk_version = proptools.StringPtr(sdkVersion)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900466 props.Installable = proptools.BoolPtr(false)
Sundong Ahne6f0b052018-06-05 16:46:14 +0900467 // A droiddoc module has only one Libs property and doesn't distinguish between
468 // shared libs and static libs. So we need to add both of these libs to Libs property.
Sundong Ahn054b19a2018-10-19 13:46:09 +0900469 props.Libs = module.Library.Module.properties.Libs
470 props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...)
471 props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs
472 props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs
Sundong Ahn054b19a2018-10-19 13:46:09 +0900473 props.Java_version = module.Library.Module.properties.Java_version
Jiyong Parkc678ad32018-04-10 13:07:10 +0900474
Sundong Ahn054b19a2018-10-19 13:46:09 +0900475 props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
476 props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
477
478 droiddocArgs := " --stub-packages " + strings.Join(module.sdkLibraryProperties.Api_packages, ":") +
479 " " + android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package ") +
480 " " + android.JoinWithPrefix(module.sdkLibraryProperties.Droiddoc_options, " ") +
Sundong Ahn04ef8a32019-01-14 11:36:50 +0900481 " --hide MissingPermission --hide BroadcastBehavior " +
482 "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " +
483 "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo"
Sundong Ahnfb2721f2018-09-17 13:23:09 +0900484
Jiyong Parkdf130542018-04-27 16:29:21 +0900485 switch apiScope {
486 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900487 droiddocArgs = droiddocArgs + " -showAnnotation android.annotation.SystemApi"
Jiyong Parkdf130542018-04-27 16:29:21 +0900488 case apiScopeTest:
489 droiddocArgs = droiddocArgs + " -showAnnotation android.annotation.TestApi"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900490 }
Paul Duffin11512472019-02-11 15:55:17 +0000491 props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files
Jiyong Parkc678ad32018-04-10 13:07:10 +0900492 props.Args = proptools.StringPtr(droiddocArgs)
493
494 // List of APIs identified from the provided source files are created. They are later
495 // compared against to the not-yet-released (a.k.a current) list of APIs and to the
496 // last-released (a.k.a numbered) list of API.
Jiyong Parkc678ad32018-04-10 13:07:10 +0900497 currentApiFileName := "current.txt"
498 removedApiFileName := "removed.txt"
Jiyong Parkdf130542018-04-27 16:29:21 +0900499 switch apiScope {
500 case apiScopeSystem:
Jiyong Parkc678ad32018-04-10 13:07:10 +0900501 currentApiFileName = "system-" + currentApiFileName
502 removedApiFileName = "system-" + removedApiFileName
Jiyong Parkdf130542018-04-27 16:29:21 +0900503 case apiScopeTest:
504 currentApiFileName = "test-" + currentApiFileName
505 removedApiFileName = "test-" + removedApiFileName
Jiyong Parkc678ad32018-04-10 13:07:10 +0900506 }
507 currentApiFileName = path.Join("api", currentApiFileName)
508 removedApiFileName = path.Join("api", removedApiFileName)
Jiyong Park58c518b2018-05-12 22:29:12 +0900509 // TODO(jiyong): remove these three props
Jiyong Parkdf130542018-04-27 16:29:21 +0900510 props.Api_tag_name = proptools.StringPtr(module.apiTagName(apiScope))
Jiyong Parkc678ad32018-04-10 13:07:10 +0900511 props.Api_filename = proptools.StringPtr(currentApiFileName)
512 props.Removed_api_filename = proptools.StringPtr(removedApiFileName)
513
Jiyong Park58c518b2018-05-12 22:29:12 +0900514 // check against the not-yet-release API
515 props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName)
516 props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName)
Jiyong Park58c518b2018-05-12 22:29:12 +0900517
518 // check against the latest released API
519 props.Check_api.Last_released.Api_file = proptools.StringPtr(
520 module.latestApiFilegroupName(apiScope))
521 props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
522 module.latestRemovedApiFilegroupName(apiScope))
Inseob Kim38449af2019-02-28 14:24:05 +0900523 props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
Jiyong Park58c518b2018-05-12 22:29:12 +0900524
Sundong Ahn04ef8a32019-01-14 11:36:50 +0900525 mctx.CreateModule(android.ModuleFactoryAdaptor(DroidstubsFactory), &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900526}
527
Jiyong Parkc678ad32018-04-10 13:07:10 +0900528// Creates the xml file that publicizes the runtime library
Colin Crossf8b860a2019-04-16 14:43:28 -0700529func (module *SdkLibrary) createXmlFile(mctx android.LoadHookContext) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900530 template := `
531<?xml version="1.0" encoding="utf-8"?>
532<!-- Copyright (C) 2018 The Android Open Source Project
533
534 Licensed under the Apache License, Version 2.0 (the "License");
535 you may not use this file except in compliance with the License.
536 You may obtain a copy of the License at
Jiyong Park1112c4c2019-08-16 21:12:10 +0900537
Jiyong Parkc678ad32018-04-10 13:07:10 +0900538 http://www.apache.org/licenses/LICENSE-2.0
Jiyong Park1112c4c2019-08-16 21:12:10 +0900539
Jiyong Parkc678ad32018-04-10 13:07:10 +0900540 Unless required by applicable law or agreed to in writing, software
541 distributed under the License is distributed on an "AS IS" BASIS,
542 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
543 See the License for the specific language governing permissions and
544 limitations under the License.
545-->
546
547<permissions>
548 <library name="%s" file="%s"/>
549</permissions>
550`
551 // genrule to generate the xml file content from the template above
552 // TODO: preserve newlines in the generate xml file. Newlines are being squashed
553 // in the ninja file. Do we need to have an external tool for this?
554 xmlContent := fmt.Sprintf(template, module.BaseModuleName(), module.implPath())
555 genruleProps := struct {
556 Name *string
557 Cmd *string
558 Out []string
559 }{}
560 genruleProps.Name = proptools.StringPtr(module.xmlFileName() + "-gen")
561 genruleProps.Cmd = proptools.StringPtr("echo '" + xmlContent + "' > $(out)")
562 genruleProps.Out = []string{module.xmlFileName()}
563 mctx.CreateModule(android.ModuleFactoryAdaptor(genrule.GenRuleFactory), &genruleProps)
564
565 // creates a prebuilt_etc module to actually place the xml file under
566 // <partition>/etc/permissions
567 etcProps := struct {
568 Name *string
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900569 Src *string
Jiyong Parkc678ad32018-04-10 13:07:10 +0900570 Sub_dir *string
571 Soc_specific *bool
572 Device_specific *bool
573 Product_specific *bool
574 }{}
575 etcProps.Name = proptools.StringPtr(module.xmlFileName())
Jiyong Park5a8d1be2018-04-25 22:57:34 +0900576 etcProps.Src = proptools.StringPtr(":" + module.xmlFileName() + "-gen")
Jiyong Parkc678ad32018-04-10 13:07:10 +0900577 etcProps.Sub_dir = proptools.StringPtr("permissions")
578 if module.SocSpecific() {
579 etcProps.Soc_specific = proptools.BoolPtr(true)
580 } else if module.DeviceSpecific() {
581 etcProps.Device_specific = proptools.BoolPtr(true)
582 } else if module.ProductSpecific() {
583 etcProps.Product_specific = proptools.BoolPtr(true)
584 }
585 mctx.CreateModule(android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory), &etcProps)
586}
587
Colin Cross0ea8ba82019-06-06 14:33:29 -0700588func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900589 var api, v string
Paul Duffin52d398a2019-06-11 12:31:14 +0100590 if sdkVersion == "" || sdkVersion == "none" {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900591 api = "system"
592 v = "current"
593 } else if strings.Contains(sdkVersion, "_") {
594 t := strings.Split(sdkVersion, "_")
595 api = t[0]
596 v = t[1]
Jiyong Parkc678ad32018-04-10 13:07:10 +0900597 } else {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900598 api = "public"
599 v = sdkVersion
600 }
601 dir := filepath.Join("prebuilts", "sdk", v, api)
602 jar := filepath.Join(dir, module.BaseModuleName()+".jar")
603 jarPath := android.ExistentPathForSource(ctx, jar)
Sundong Ahnae418ac2019-02-28 15:01:28 +0900604 if !jarPath.Valid() {
605 ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", v, jar)
606 return nil
607 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900608 return android.Paths{jarPath.Path()}
609}
610
611// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700612func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900613 // This module is just a wrapper for the stubs.
Colin Cross10932872019-04-18 14:27:12 -0700614 if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900615 return module.PrebuiltJars(ctx, sdkVersion)
616 } else {
617 if strings.HasPrefix(sdkVersion, "system_") {
618 return module.systemApiStubsPath
619 } else if sdkVersion == "" {
620 return module.Library.HeaderJars()
621 } else {
622 return module.publicApiStubsPath
623 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900624 }
625}
626
Sundong Ahn241cd372018-07-13 16:16:44 +0900627// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700628func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Sundong Ahn241cd372018-07-13 16:16:44 +0900629 // This module is just a wrapper for the stubs.
Colin Cross10932872019-04-18 14:27:12 -0700630 if ctx.Config().UnbundledBuildUsePrebuiltSdks() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900631 return module.PrebuiltJars(ctx, sdkVersion)
Sundong Ahn241cd372018-07-13 16:16:44 +0900632 } else {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900633 if strings.HasPrefix(sdkVersion, "system_") {
634 return module.systemApiStubsImplPath
635 } else if sdkVersion == "" {
636 return module.Library.ImplementationJars()
637 } else {
638 return module.publicApiStubsImplPath
639 }
Sundong Ahn241cd372018-07-13 16:16:44 +0900640 }
641}
642
Sundong Ahn80a87b32019-05-13 15:02:50 +0900643func (module *SdkLibrary) SetNoDist() {
644 module.sdkLibraryProperties.No_dist = proptools.BoolPtr(true)
645}
646
Colin Cross571cccf2019-02-04 11:22:08 -0800647var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
648
Jiyong Park82484c02018-04-23 21:41:26 +0900649func javaSdkLibraries(config android.Config) *[]string {
Colin Cross571cccf2019-02-04 11:22:08 -0800650 return config.Once(javaSdkLibrariesKey, func() interface{} {
Jiyong Park82484c02018-04-23 21:41:26 +0900651 return &[]string{}
652 }).(*[]string)
653}
654
Jiyong Parkc678ad32018-04-10 13:07:10 +0900655// For a java_sdk_library module, create internal modules for stubs, docs,
656// runtime libs and xml file. If requested, the stubs and docs are created twice
657// once for public API level and once for system API level
Colin Crossf8b860a2019-04-16 14:43:28 -0700658func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) {
Inseob Kim6e93ac92019-03-21 17:43:49 +0900659 if len(module.Library.Module.properties.Srcs) == 0 {
Inseob Kimc0907f12019-02-08 21:00:45 +0900660 mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
661 }
662
Inseob Kim6e93ac92019-03-21 17:43:49 +0900663 if len(module.sdkLibraryProperties.Api_packages) == 0 {
Inseob Kimc0907f12019-02-08 21:00:45 +0900664 mctx.PropertyErrorf("api_packages", "java_sdk_library must specify api_packages")
665 }
Inseob Kim8098faa2019-03-18 10:19:51 +0900666
667 missing_current_api := false
668
669 for _, scope := range []string{"", "system-", "test-"} {
670 for _, api := range []string{"current.txt", "removed.txt"} {
671 path := path.Join(mctx.ModuleDir(), "api", scope+api)
672 p := android.ExistentPathForSource(mctx, path)
673 if !p.Valid() {
674 mctx.ModuleErrorf("Current api file %#v doesn't exist", path)
675 missing_current_api = true
676 }
677 }
678 }
679
680 if missing_current_api {
681 script := "build/soong/scripts/gen-java-current-api-files.sh"
682 p := android.ExistentPathForSource(mctx, script)
683
684 if !p.Valid() {
685 panic(fmt.Sprintf("script file %s doesn't exist", script))
686 }
687
688 mctx.ModuleErrorf("One or more current api files are missing. "+
689 "You can update them by:\n"+
690 "%s %q && m update-api", script, mctx.ModuleDir())
691 return
692 }
693
Inseob Kimc0907f12019-02-08 21:00:45 +0900694 // for public API stubs
695 module.createStubsLibrary(mctx, apiScopePublic)
696 module.createDocs(mctx, apiScopePublic)
697
Paul Duffin250e6192019-06-07 10:44:37 +0100698 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
699 if sdkDep.hasStandardLibs() {
Inseob Kimc0907f12019-02-08 21:00:45 +0900700 // for system API stubs
701 module.createStubsLibrary(mctx, apiScopeSystem)
702 module.createDocs(mctx, apiScopeSystem)
703
704 // for test API stubs
705 module.createStubsLibrary(mctx, apiScopeTest)
706 module.createDocs(mctx, apiScopeTest)
707
708 // for runtime
709 module.createXmlFile(mctx)
710 }
711
712 // record java_sdk_library modules so that they are exported to make
713 javaSdkLibraries := javaSdkLibraries(mctx.Config())
714 javaSdkLibrariesLock.Lock()
715 defer javaSdkLibrariesLock.Unlock()
716 *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
717}
718
719func (module *SdkLibrary) InitSdkLibraryProperties() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900720 module.AddProperties(
721 &module.sdkLibraryProperties,
722 &module.Library.Module.properties,
723 &module.Library.Module.dexpreoptProperties,
724 &module.Library.Module.deviceProperties,
725 &module.Library.Module.protoProperties,
726 )
727
728 module.Library.Module.properties.Installable = proptools.BoolPtr(true)
729 module.Library.Module.deviceProperties.IsSDKLibrary = true
Inseob Kimc0907f12019-02-08 21:00:45 +0900730}
Sundong Ahn054b19a2018-10-19 13:46:09 +0900731
Jaewoong Jung4f158ee2019-07-11 10:05:35 -0700732// java_sdk_library is a special Java library that provides optional platform APIs to apps.
733// In practice, it can be viewed as a combination of several modules: 1) stubs library that clients
734// are linked against to, 2) droiddoc module that internally generates API stubs source files,
735// 3) the real runtime shared library that implements the APIs, and 4) XML file for adding
736// the runtime lib to the classpath at runtime if requested via <uses-library>.
Inseob Kimc0907f12019-02-08 21:00:45 +0900737func SdkLibraryFactory() android.Module {
738 module := &SdkLibrary{}
739 module.InitSdkLibraryProperties()
Sundong Ahn054b19a2018-10-19 13:46:09 +0900740 InitJavaModule(module, android.HostAndDeviceSupported)
Colin Crossf8b860a2019-04-16 14:43:28 -0700741 android.AddLoadHook(module, func(ctx android.LoadHookContext) { module.CreateInternalModules(ctx) })
Jiyong Parkc678ad32018-04-10 13:07:10 +0900742 return module
743}
Colin Cross79c7c262019-04-17 11:11:46 -0700744
745//
746// SDK library prebuilts
747//
748
749type sdkLibraryImportProperties struct {
750 Jars []string `android:"path"`
751
752 Sdk_version *string
753
754 Installable *bool
755
756 // List of shared java libs that this module has dependencies to
757 Libs []string
758
759 // List of files to remove from the jar file(s)
760 Exclude_files []string
761
762 // List of directories to remove from the jar file(s)
763 Exclude_dirs []string
764}
765
766type sdkLibraryImport struct {
767 android.ModuleBase
768 android.DefaultableModuleBase
769 prebuilt android.Prebuilt
770
771 properties sdkLibraryImportProperties
772
773 stubsPath android.Paths
774}
775
776var _ SdkLibraryDependency = (*sdkLibraryImport)(nil)
777
Jaewoong Jung4f158ee2019-07-11 10:05:35 -0700778// java_sdk_library_import imports a prebuilt java_sdk_library.
Colin Cross79c7c262019-04-17 11:11:46 -0700779func sdkLibraryImportFactory() android.Module {
780 module := &sdkLibraryImport{}
781
782 module.AddProperties(&module.properties)
783
784 android.InitPrebuiltModule(module, &module.properties.Jars)
785 InitJavaModule(module, android.HostAndDeviceSupported)
786
787 android.AddLoadHook(module, func(mctx android.LoadHookContext) { module.createInternalModules(mctx) })
788 return module
789}
790
791func (module *sdkLibraryImport) Prebuilt() *android.Prebuilt {
792 return &module.prebuilt
793}
794
795func (module *sdkLibraryImport) Name() string {
796 return module.prebuilt.Name(module.ModuleBase.Name())
797}
798
799func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) {
800 // Creates a java import for the jar with ".stubs" suffix
801 props := struct {
802 Name *string
803 Soc_specific *bool
804 Device_specific *bool
805 Product_specific *bool
806 }{}
807
808 props.Name = proptools.StringPtr(module.BaseModuleName() + sdkStubsLibrarySuffix)
809
810 if module.SocSpecific() {
811 props.Soc_specific = proptools.BoolPtr(true)
812 } else if module.DeviceSpecific() {
813 props.Device_specific = proptools.BoolPtr(true)
814 } else if module.ProductSpecific() {
815 props.Product_specific = proptools.BoolPtr(true)
816 }
817
818 mctx.CreateModule(android.ModuleFactoryAdaptor(ImportFactory), &props, &module.properties)
819
820 javaSdkLibraries := javaSdkLibraries(mctx.Config())
821 javaSdkLibrariesLock.Lock()
822 defer javaSdkLibrariesLock.Unlock()
823 *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
824}
825
826func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
827 // Add dependencies to the prebuilt stubs library
828 ctx.AddVariationDependencies(nil, publicApiStubsTag, module.BaseModuleName()+sdkStubsLibrarySuffix)
829}
830
831func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
832 // Record the paths to the prebuilt stubs library.
833 ctx.VisitDirectDeps(func(to android.Module) {
834 tag := ctx.OtherModuleDependencyTag(to)
835
836 switch tag {
837 case publicApiStubsTag:
838 module.stubsPath = to.(Dependency).HeaderJars()
839 }
840 })
841}
842
843// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700844func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Colin Cross79c7c262019-04-17 11:11:46 -0700845 // This module is just a wrapper for the prebuilt stubs.
846 return module.stubsPath
847}
848
849// to satisfy SdkLibraryDependency interface
Colin Cross0ea8ba82019-06-06 14:33:29 -0700850func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion string) android.Paths {
Colin Cross79c7c262019-04-17 11:11:46 -0700851 // This module is just a wrapper for the stubs.
852 return module.stubsPath
853}