blob: 68b1b7e9323d8246aa7124782fcf02cab145dc70 [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 (
Jiyong Parkc678ad32018-04-10 13:07:10 +090018 "fmt"
19 "path"
Sundong Ahn054b19a2018-10-19 13:46:09 +090020 "path/filepath"
Paul Duffin46a26a82020-04-07 19:27:04 +010021 "reflect"
Jiyong Park82484c02018-04-23 21:41:26 +090022 "sort"
Jiyong Parkc678ad32018-04-10 13:07:10 +090023 "strings"
Jiyong Park82484c02018-04-23 21:41:26 +090024 "sync"
Jiyong Parkc678ad32018-04-10 13:07:10 +090025
Paul Duffind1b3a922020-01-22 11:57:20 +000026 "github.com/google/blueprint"
Jiyong Parkc678ad32018-04-10 13:07:10 +090027 "github.com/google/blueprint/proptools"
Paul Duffin46a26a82020-04-07 19:27:04 +010028
29 "android/soong/android"
Jiyong Parkc678ad32018-04-10 13:07:10 +090030)
31
Jooyung Han58f26ab2019-12-18 15:34:32 +090032const (
Jiyong Parkc678ad32018-04-10 13:07:10 +090033 sdkStubsLibrarySuffix = ".stubs"
34 sdkSystemApiSuffix = ".system"
Jiyong Parkdf130542018-04-27 16:29:21 +090035 sdkTestApiSuffix = ".test"
Paul Duffin91b883d2020-02-11 13:05:28 +000036 sdkStubsSourceSuffix = ".stubs.source"
Jiyong Parkc678ad32018-04-10 13:07:10 +090037 sdkXmlFileSuffix = ".xml"
Jiyong Parke3833882020-02-17 17:28:10 +090038 permissionsTemplate = `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n` +
Jooyung Han624058e2019-12-24 18:38:06 +090039 `<!-- Copyright (C) 2018 The Android Open Source Project\n` +
40 `\n` +
Jiyong Parke3833882020-02-17 17:28:10 +090041 ` Licensed under the Apache License, Version 2.0 (the \"License\");\n` +
Jooyung Han624058e2019-12-24 18:38:06 +090042 ` you may not use this file except in compliance with the License.\n` +
43 ` You may obtain a copy of the License at\n` +
44 `\n` +
45 ` http://www.apache.org/licenses/LICENSE-2.0\n` +
46 `\n` +
47 ` Unless required by applicable law or agreed to in writing, software\n` +
Jiyong Parke3833882020-02-17 17:28:10 +090048 ` distributed under the License is distributed on an \"AS IS\" BASIS,\n` +
Jooyung Han624058e2019-12-24 18:38:06 +090049 ` WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n` +
50 ` See the License for the specific language governing permissions and\n` +
51 ` limitations under the License.\n` +
52 `-->\n` +
53 `<permissions>\n` +
Jiyong Parke3833882020-02-17 17:28:10 +090054 ` <library name=\"%s\" file=\"%s\"/>\n` +
Jooyung Han624058e2019-12-24 18:38:06 +090055 `</permissions>\n`
Jiyong Parkc678ad32018-04-10 13:07:10 +090056)
57
Paul Duffind1b3a922020-01-22 11:57:20 +000058// A tag to associated a dependency with a specific api scope.
59type scopeDependencyTag struct {
60 blueprint.BaseDependencyTag
61 name string
62 apiScope *apiScope
63}
64
65// Provides information about an api scope, e.g. public, system, test.
66type apiScope struct {
67 // The name of the api scope, e.g. public, system, test
68 name string
69
Paul Duffin97b53b82020-05-05 14:40:52 +010070 // The api scope that this scope extends.
71 extends *apiScope
72
Paul Duffin46a26a82020-04-07 19:27:04 +010073 // The name of the field in the dynamically created structure.
74 fieldName string
75
Paul Duffind1b3a922020-01-22 11:57:20 +000076 // The tag to use to depend on the stubs library module.
77 stubsTag scopeDependencyTag
78
79 // The tag to use to depend on the stubs
80 apiFileTag scopeDependencyTag
81
82 // The scope specific prefix to add to the api file base of "current.txt" or "removed.txt".
83 apiFilePrefix string
84
85 // The scope specific prefix to add to the sdk library module name to construct a scope specific
86 // module name.
87 moduleSuffix string
88
Paul Duffind1b3a922020-01-22 11:57:20 +000089 // SDK version that the stubs library is built against. Note that this is always
90 // *current. Older stubs library built with a numbered SDK version is created from
91 // the prebuilt jar.
92 sdkVersion string
Paul Duffin1fb487d2020-04-07 18:50:10 +010093
94 // Extra arguments to pass to droidstubs for this scope.
95 droidstubsArgs []string
Anton Hansson6478ac12020-05-02 11:19:36 +010096
97 // Whether the api scope can be treated as unstable, and should skip compat checks.
98 unstable bool
Paul Duffind1b3a922020-01-22 11:57:20 +000099}
100
101// Initialize a scope, creating and adding appropriate dependency tags
102func initApiScope(scope *apiScope) *apiScope {
Paul Duffin46a26a82020-04-07 19:27:04 +0100103 scope.fieldName = proptools.FieldNameForProperty(scope.name)
Paul Duffind1b3a922020-01-22 11:57:20 +0000104 scope.stubsTag = scopeDependencyTag{
105 name: scope.name + "-stubs",
106 apiScope: scope,
107 }
108 scope.apiFileTag = scopeDependencyTag{
109 name: scope.name + "-api",
110 apiScope: scope,
111 }
112 return scope
113}
114
115func (scope *apiScope) stubsModuleName(baseName string) string {
116 return baseName + sdkStubsLibrarySuffix + scope.moduleSuffix
117}
118
119func (scope *apiScope) docsModuleName(baseName string) string {
Paul Duffin91b883d2020-02-11 13:05:28 +0000120 return baseName + sdkStubsSourceSuffix + scope.moduleSuffix
Paul Duffind1b3a922020-01-22 11:57:20 +0000121}
122
123type apiScopes []*apiScope
124
125func (scopes apiScopes) Strings(accessor func(*apiScope) string) []string {
126 var list []string
127 for _, scope := range scopes {
128 list = append(list, accessor(scope))
129 }
130 return list
131}
132
Jiyong Parkc678ad32018-04-10 13:07:10 +0900133var (
Paul Duffind1b3a922020-01-22 11:57:20 +0000134 apiScopePublic = initApiScope(&apiScope{
135 name: "public",
136 sdkVersion: "current",
137 })
138 apiScopeSystem = initApiScope(&apiScope{
Anton Hansson6affb1f2020-04-28 16:47:41 +0100139 name: "system",
Paul Duffin97b53b82020-05-05 14:40:52 +0100140 extends: apiScopePublic,
Anton Hansson6affb1f2020-04-28 16:47:41 +0100141 apiFilePrefix: "system-",
142 moduleSuffix: sdkSystemApiSuffix,
143 sdkVersion: "system_current",
Paul Duffin0d543642020-04-29 22:18:41 +0100144 droidstubsArgs: []string{"-showAnnotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.PRIVILEGED_APPS\\)"},
Paul Duffind1b3a922020-01-22 11:57:20 +0000145 })
146 apiScopeTest = initApiScope(&apiScope{
Anton Hansson6affb1f2020-04-28 16:47:41 +0100147 name: "test",
Paul Duffin97b53b82020-05-05 14:40:52 +0100148 extends: apiScopePublic,
Anton Hansson6affb1f2020-04-28 16:47:41 +0100149 apiFilePrefix: "test-",
150 moduleSuffix: sdkTestApiSuffix,
151 sdkVersion: "test_current",
152 droidstubsArgs: []string{"-showAnnotation android.annotation.TestApi"},
Anton Hansson6478ac12020-05-02 11:19:36 +0100153 unstable: true,
Paul Duffind1b3a922020-01-22 11:57:20 +0000154 })
155 allApiScopes = apiScopes{
156 apiScopePublic,
157 apiScopeSystem,
158 apiScopeTest,
159 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900160)
161
Jiyong Park82484c02018-04-23 21:41:26 +0900162var (
163 javaSdkLibrariesLock sync.Mutex
164)
165
Jiyong Parkc678ad32018-04-10 13:07:10 +0900166// TODO: these are big features that are currently missing
Jiyong Park1be96912018-05-28 18:02:19 +0900167// 1) disallowing linking to the runtime shared lib
168// 2) HTML generation
Jiyong Parkc678ad32018-04-10 13:07:10 +0900169
170func init() {
Paul Duffin43dc1cc2019-12-19 11:18:54 +0000171 RegisterSdkLibraryBuildComponents(android.InitRegistrationContext)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900172
Jiyong Park82484c02018-04-23 21:41:26 +0900173 android.RegisterMakeVarsProvider(pctx, func(ctx android.MakeVarsContext) {
174 javaSdkLibraries := javaSdkLibraries(ctx.Config())
175 sort.Strings(*javaSdkLibraries)
176 ctx.Strict("JAVA_SDK_LIBRARIES", strings.Join(*javaSdkLibraries, " "))
177 })
Paul Duffindd46f712020-02-10 13:37:10 +0000178
179 // Register sdk member types.
180 android.RegisterSdkMemberType(&sdkLibrarySdkMemberType{
181 android.SdkMemberTypeBase{
182 PropertyName: "java_sdk_libs",
183 SupportsSdk: true,
184 },
185 })
Jiyong Parkc678ad32018-04-10 13:07:10 +0900186}
187
Paul Duffin43dc1cc2019-12-19 11:18:54 +0000188func RegisterSdkLibraryBuildComponents(ctx android.RegistrationContext) {
189 ctx.RegisterModuleType("java_sdk_library", SdkLibraryFactory)
190 ctx.RegisterModuleType("java_sdk_library_import", sdkLibraryImportFactory)
191}
192
Jiyong Parkc678ad32018-04-10 13:07:10 +0900193type sdkLibraryProperties struct {
Sundong Ahnf043cf62018-06-25 16:04:37 +0900194 // List of Java libraries that will be in the classpath when building stubs
195 Stub_only_libs []string `android:"arch_variant"`
196
Paul Duffin7a586d32019-12-30 17:09:34 +0000197 // list of package names that will be documented and publicized as API.
198 // This allows the API to be restricted to a subset of the source files provided.
199 // If this is unspecified then all the source files will be treated as being part
200 // of the API.
Jiyong Parkc678ad32018-04-10 13:07:10 +0900201 Api_packages []string
202
Jiyong Park5a2c9d72018-05-01 22:25:41 +0900203 // list of package names that must be hidden from the API
204 Hidden_api_packages []string
205
Paul Duffin749f98f2019-12-30 17:23:46 +0000206 // the relative path to the directory containing the api specification files.
207 // Defaults to "api".
208 Api_dir *string
209
Paul Duffin43db9be2019-12-30 17:35:49 +0000210 // If set to true there is no runtime library.
211 Api_only *bool
212
Paul Duffin11512472019-02-11 15:55:17 +0000213 // local files that are used within user customized droiddoc options.
214 Droiddoc_option_files []string
215
216 // additional droiddoc options
217 // Available variables for substitution:
218 //
219 // $(location <label>): the path to the droiddoc_option_files with name <label>
Sundong Ahndd567f92018-07-31 17:19:11 +0900220 Droiddoc_options []string
221
Sundong Ahn054b19a2018-10-19 13:46:09 +0900222 // a list of top-level directories containing files to merge qualifier annotations
223 // (i.e. those intended to be included in the stubs written) from.
224 Merge_annotations_dirs []string
225
226 // a list of top-level directories containing Java stub files to merge show/hide annotations from.
227 Merge_inclusion_annotations_dirs []string
228
229 // If set to true, the path of dist files is apistubs/core. Defaults to false.
230 Core_lib *bool
231
Sundong Ahn80a87b32019-05-13 15:02:50 +0900232 // don't create dist rules.
233 No_dist *bool `blueprint:"mutated"`
234
Paul Duffin37e0b772019-12-30 17:20:10 +0000235 // indicates whether system and test apis should be managed.
236 Has_system_and_test_apis bool `blueprint:"mutated"`
237
Jiyong Parkc678ad32018-04-10 13:07:10 +0900238 // TODO: determines whether to create HTML doc or not
239 //Html_doc *bool
240}
241
Paul Duffind1b3a922020-01-22 11:57:20 +0000242type scopePaths struct {
Paul Duffin1fd005d2020-04-09 01:08:11 +0100243 stubsHeaderPath android.Paths
244 stubsImplPath android.Paths
245 currentApiFilePath android.Path
246 removedApiFilePath android.Path
247 stubsSrcJar android.Path
Paul Duffind1b3a922020-01-22 11:57:20 +0000248}
249
Paul Duffin56d44902020-01-31 13:36:25 +0000250// Common code between sdk library and sdk library import
251type commonToSdkLibraryAndImport struct {
252 scopePaths map[*apiScope]*scopePaths
253}
254
255func (c *commonToSdkLibraryAndImport) getScopePaths(scope *apiScope) *scopePaths {
256 if c.scopePaths == nil {
257 c.scopePaths = make(map[*apiScope]*scopePaths)
258 }
259 paths := c.scopePaths[scope]
260 if paths == nil {
261 paths = &scopePaths{}
262 c.scopePaths[scope] = paths
263 }
264
265 return paths
266}
267
Inseob Kimc0907f12019-02-08 21:00:45 +0900268type SdkLibrary struct {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900269 Library
Jiyong Parkc678ad32018-04-10 13:07:10 +0900270
Sundong Ahn054b19a2018-10-19 13:46:09 +0900271 sdkLibraryProperties sdkLibraryProperties
Jiyong Parkc678ad32018-04-10 13:07:10 +0900272
Paul Duffin56d44902020-01-31 13:36:25 +0000273 commonToSdkLibraryAndImport
Jiyong Parkc678ad32018-04-10 13:07:10 +0900274}
275
Inseob Kimc0907f12019-02-08 21:00:45 +0900276var _ Dependency = (*SdkLibrary)(nil)
277var _ SdkLibraryDependency = (*SdkLibrary)(nil)
Colin Cross897d2ed2019-02-11 14:03:51 -0800278
Paul Duffind1b3a922020-01-22 11:57:20 +0000279func (module *SdkLibrary) getActiveApiScopes() apiScopes {
280 if module.sdkLibraryProperties.Has_system_and_test_apis {
281 return allApiScopes
282 } else {
283 return apiScopes{apiScopePublic}
284 }
285}
286
Paul Duffine74ac732020-02-06 13:51:46 +0000287var xmlPermissionsFileTag = dependencyTag{name: "xml-permissions-file"}
288
Jiyong Parke3833882020-02-17 17:28:10 +0900289func IsXmlPermissionsFileDepTag(depTag blueprint.DependencyTag) bool {
290 if dt, ok := depTag.(dependencyTag); ok {
291 return dt == xmlPermissionsFileTag
292 }
293 return false
294}
295
Inseob Kimc0907f12019-02-08 21:00:45 +0900296func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
Paul Duffind1b3a922020-01-22 11:57:20 +0000297 for _, apiScope := range module.getActiveApiScopes() {
298 // Add dependencies to the stubs library
Paul Duffin50061512020-01-21 16:31:05 +0000299 ctx.AddVariationDependencies(nil, apiScope.stubsTag, module.stubsName(apiScope))
Paul Duffind1b3a922020-01-22 11:57:20 +0000300
Paul Duffin50061512020-01-21 16:31:05 +0000301 // And the api file
Paul Duffind1b3a922020-01-22 11:57:20 +0000302 ctx.AddVariationDependencies(nil, apiScope.apiFileTag, module.docsName(apiScope))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900303 }
304
Paul Duffine74ac732020-02-06 13:51:46 +0000305 if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
306 // Add dependency to the rule for generating the xml permissions file
Jiyong Parke3833882020-02-17 17:28:10 +0900307 ctx.AddDependency(module, xmlPermissionsFileTag, module.xmlFileName())
Paul Duffine74ac732020-02-06 13:51:46 +0000308 }
309
Sundong Ahn054b19a2018-10-19 13:46:09 +0900310 module.Library.deps(ctx)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900311}
312
Inseob Kimc0907f12019-02-08 21:00:45 +0900313func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Paul Duffin43db9be2019-12-30 17:35:49 +0000314 // Don't build an implementation library if this is api only.
315 if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
316 module.Library.GenerateAndroidBuildActions(ctx)
317 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900318
Sundong Ahn57368eb2018-07-06 11:20:23 +0900319 // Record the paths to the header jars of the library (stubs and impl).
Paul Duffind1b3a922020-01-22 11:57:20 +0000320 // When this java_sdk_library is depended upon from others via "libs" property,
Jiyong Parkc678ad32018-04-10 13:07:10 +0900321 // the recorded paths will be returned depending on the link type of the caller.
322 ctx.VisitDirectDeps(func(to android.Module) {
323 otherName := ctx.OtherModuleName(to)
324 tag := ctx.OtherModuleDependencyTag(to)
325
Sundong Ahn57368eb2018-07-06 11:20:23 +0900326 if lib, ok := to.(Dependency); ok {
Paul Duffind1b3a922020-01-22 11:57:20 +0000327 if scopeTag, ok := tag.(scopeDependencyTag); ok {
328 apiScope := scopeTag.apiScope
329 scopePaths := module.getScopePaths(apiScope)
330 scopePaths.stubsHeaderPath = lib.HeaderJars()
331 scopePaths.stubsImplPath = lib.ImplementationJars()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900332 }
333 }
Paul Duffin3d1248c2020-04-09 00:10:17 +0100334 if doc, ok := to.(ApiStubsProvider); ok {
Paul Duffind1b3a922020-01-22 11:57:20 +0000335 if scopeTag, ok := tag.(scopeDependencyTag); ok {
336 apiScope := scopeTag.apiScope
337 scopePaths := module.getScopePaths(apiScope)
Paul Duffin1fd005d2020-04-09 01:08:11 +0100338 scopePaths.currentApiFilePath = doc.ApiFilePath()
339 scopePaths.removedApiFilePath = doc.RemovedApiFilePath()
Paul Duffin3d1248c2020-04-09 00:10:17 +0100340 scopePaths.stubsSrcJar = doc.StubsSrcJar()
Paul Duffind1b3a922020-01-22 11:57:20 +0000341 } else {
Sundong Ahn20e998b2018-07-24 11:19:26 +0900342 ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
343 }
344 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900345 })
346}
347
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900348func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
Paul Duffin43db9be2019-12-30 17:35:49 +0000349 if proptools.Bool(module.sdkLibraryProperties.Api_only) {
350 return nil
351 }
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900352 entriesList := module.Library.AndroidMkEntries()
353 entries := &entriesList[0]
Jaewoong Jungb0c127c2019-08-29 14:56:03 -0700354 entries.Required = append(entries.Required, module.xmlFileName())
Jiyong Park0b0e1b92019-12-03 13:24:29 +0900355 return entriesList
Jiyong Park82484c02018-04-23 21:41:26 +0900356}
357
Jiyong Parkc678ad32018-04-10 13:07:10 +0900358// Module name of the stubs library
Paul Duffind1b3a922020-01-22 11:57:20 +0000359func (module *SdkLibrary) stubsName(apiScope *apiScope) string {
360 return apiScope.stubsModuleName(module.BaseModuleName())
Jiyong Parkc678ad32018-04-10 13:07:10 +0900361}
362
363// Module name of the docs
Paul Duffind1b3a922020-01-22 11:57:20 +0000364func (module *SdkLibrary) docsName(apiScope *apiScope) string {
365 return apiScope.docsModuleName(module.BaseModuleName())
Jiyong Parkc678ad32018-04-10 13:07:10 +0900366}
367
368// Module name of the runtime implementation library
Inseob Kimc0907f12019-02-08 21:00:45 +0900369func (module *SdkLibrary) implName() string {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900370 return module.BaseModuleName()
Jiyong Parkc678ad32018-04-10 13:07:10 +0900371}
372
Jiyong Parkc678ad32018-04-10 13:07:10 +0900373// Module name of the XML file for the lib
Inseob Kimc0907f12019-02-08 21:00:45 +0900374func (module *SdkLibrary) xmlFileName() string {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900375 return module.BaseModuleName() + sdkXmlFileSuffix
376}
377
Anton Hansson5fd5d242020-03-27 19:43:19 +0000378// The dist path of the stub artifacts
379func (module *SdkLibrary) apiDistPath(apiScope *apiScope) string {
380 if module.ModuleBase.Owner() != "" {
381 return path.Join("apistubs", module.ModuleBase.Owner(), apiScope.name)
382 } else if Bool(module.sdkLibraryProperties.Core_lib) {
383 return path.Join("apistubs", "core", apiScope.name)
384 } else {
385 return path.Join("apistubs", "android", apiScope.name)
386 }
387}
388
Paul Duffin12ceb462019-12-24 20:31:31 +0000389// Get the sdk version for use when compiling the stubs library.
Paul Duffinf0229202020-04-29 16:47:28 +0100390func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) string {
Paul Duffin12ceb462019-12-24 20:31:31 +0000391 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
392 if sdkDep.hasStandardLibs() {
393 // If building against a standard sdk then use the sdk version appropriate for the scope.
Paul Duffind1b3a922020-01-22 11:57:20 +0000394 return apiScope.sdkVersion
Paul Duffin12ceb462019-12-24 20:31:31 +0000395 } else {
396 // Otherwise, use no system module.
397 return "none"
398 }
399}
400
Paul Duffind1b3a922020-01-22 11:57:20 +0000401func (module *SdkLibrary) latestApiFilegroupName(apiScope *apiScope) string {
402 return ":" + module.BaseModuleName() + ".api." + apiScope.name + ".latest"
Jiyong Park58c518b2018-05-12 22:29:12 +0900403}
Jiyong Parkc678ad32018-04-10 13:07:10 +0900404
Paul Duffind1b3a922020-01-22 11:57:20 +0000405func (module *SdkLibrary) latestRemovedApiFilegroupName(apiScope *apiScope) string {
406 return ":" + module.BaseModuleName() + "-removed.api." + apiScope.name + ".latest"
Jiyong Parkc678ad32018-04-10 13:07:10 +0900407}
408
409// Creates a static java library that has API stubs
Paul Duffinf0229202020-04-29 16:47:28 +0100410func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900411 props := struct {
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900412 Name *string
413 Srcs []string
Paul Duffin367ab912019-12-23 19:40:36 +0000414 Installable *bool
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900415 Sdk_version *string
Paul Duffin12ceb462019-12-24 20:31:31 +0000416 System_modules *string
Paul Duffinab8da5d2020-02-07 16:12:04 +0000417 Patch_module *string
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900418 Libs []string
419 Soc_specific *bool
420 Device_specific *bool
421 Product_specific *bool
422 System_ext_specific *bool
423 Compile_dex *bool
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900424 Java_version *string
425 Product_variables struct {
Jiyong Park82484c02018-04-23 21:41:26 +0900426 Pdk struct {
427 Enabled *bool
428 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900429 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900430 Openjdk9 struct {
431 Srcs []string
432 Javacflags []string
433 }
Anton Hansson5fd5d242020-03-27 19:43:19 +0000434 Dist struct {
435 Targets []string
436 Dest *string
437 Dir *string
438 Tag *string
439 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900440 }{}
441
Jiyong Parkdf130542018-04-27 16:29:21 +0900442 props.Name = proptools.StringPtr(module.stubsName(apiScope))
Jiyong Parkc678ad32018-04-10 13:07:10 +0900443 // sources are generated from the droiddoc
Jiyong Parkdf130542018-04-27 16:29:21 +0900444 props.Srcs = []string{":" + module.docsName(apiScope)}
Paul Duffin12ceb462019-12-24 20:31:31 +0000445 sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope)
Paul Duffin52d398a2019-06-11 12:31:14 +0100446 props.Sdk_version = proptools.StringPtr(sdkVersion)
Paul Duffin12ceb462019-12-24 20:31:31 +0000447 props.System_modules = module.Library.Module.deviceProperties.System_modules
Paul Duffinab8da5d2020-02-07 16:12:04 +0000448 props.Patch_module = module.Library.Module.properties.Patch_module
Paul Duffin367ab912019-12-23 19:40:36 +0000449 props.Installable = proptools.BoolPtr(false)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900450 props.Libs = module.sdkLibraryProperties.Stub_only_libs
Jiyong Park82484c02018-04-23 21:41:26 +0900451 props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900452 props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs
453 props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags
454 props.Java_version = module.Library.Module.properties.Java_version
455 if module.Library.Module.deviceProperties.Compile_dex != nil {
456 props.Compile_dex = module.Library.Module.deviceProperties.Compile_dex
Sundong Ahndd567f92018-07-31 17:19:11 +0900457 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900458
459 if module.SocSpecific() {
460 props.Soc_specific = proptools.BoolPtr(true)
461 } else if module.DeviceSpecific() {
462 props.Device_specific = proptools.BoolPtr(true)
463 } else if module.ProductSpecific() {
464 props.Product_specific = proptools.BoolPtr(true)
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900465 } else if module.SystemExtSpecific() {
466 props.System_ext_specific = proptools.BoolPtr(true)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900467 }
Anton Hansson5fd5d242020-03-27 19:43:19 +0000468 // Dist the class jar artifact for sdk builds.
469 if !Bool(module.sdkLibraryProperties.No_dist) {
470 props.Dist.Targets = []string{"sdk", "win_sdk"}
471 props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.jar", module.BaseModuleName()))
472 props.Dist.Dir = proptools.StringPtr(module.apiDistPath(apiScope))
473 props.Dist.Tag = proptools.StringPtr(".jar")
474 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900475
Colin Cross84dfc3d2019-09-25 11:33:01 -0700476 mctx.CreateModule(LibraryFactory, &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900477}
478
Paul Duffin6d0886e2020-04-07 18:49:53 +0100479// Creates a droidstubs module that creates stubs source files from the given full source
Jiyong Parkc678ad32018-04-10 13:07:10 +0900480// files
Paul Duffinf0229202020-04-29 16:47:28 +0100481func (module *SdkLibrary) createStubsSources(mctx android.DefaultableHookContext, apiScope *apiScope) {
Jiyong Parkc678ad32018-04-10 13:07:10 +0900482 props := struct {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900483 Name *string
484 Srcs []string
485 Installable *bool
Paul Duffin52d398a2019-06-11 12:31:14 +0100486 Sdk_version *string
Paul Duffin12ceb462019-12-24 20:31:31 +0000487 System_modules *string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900488 Libs []string
Paul Duffin11512472019-02-11 15:55:17 +0000489 Arg_files []string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900490 Args *string
Sundong Ahn054b19a2018-10-19 13:46:09 +0900491 Java_version *string
492 Merge_annotations_dirs []string
493 Merge_inclusion_annotations_dirs []string
494 Check_api struct {
Inseob Kim38449af2019-02-28 14:24:05 +0900495 Current ApiToCheck
496 Last_released ApiToCheck
497 Ignore_missing_latest_api *bool
Jiyong Park58c518b2018-05-12 22:29:12 +0900498 }
Sundong Ahn1b92c822018-05-29 11:35:17 +0900499 Aidl struct {
500 Include_dirs []string
501 Local_include_dirs []string
502 }
Anton Hansson5fd5d242020-03-27 19:43:19 +0000503 Dist struct {
504 Targets []string
505 Dest *string
506 Dir *string
507 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900508 }{}
509
Paul Duffin7b78b4d2020-04-28 14:08:32 +0100510 // The stubs source processing uses the same compile time classpath when extracting the
511 // API from the implementation library as it does when compiling it. i.e. the same
512 // * sdk version
513 // * system_modules
514 // * libs (static_libs/libs)
Paul Duffin250e6192019-06-07 10:44:37 +0100515
Jiyong Parkdf130542018-04-27 16:29:21 +0900516 props.Name = proptools.StringPtr(module.docsName(apiScope))
Sundong Ahn054b19a2018-10-19 13:46:09 +0900517 props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...)
Paul Duffin7b78b4d2020-04-28 14:08:32 +0100518 props.Sdk_version = module.Library.Module.deviceProperties.Sdk_version
Paul Duffin12ceb462019-12-24 20:31:31 +0000519 props.System_modules = module.Library.Module.deviceProperties.System_modules
Jiyong Parkc678ad32018-04-10 13:07:10 +0900520 props.Installable = proptools.BoolPtr(false)
Sundong Ahne6f0b052018-06-05 16:46:14 +0900521 // A droiddoc module has only one Libs property and doesn't distinguish between
522 // shared libs and static libs. So we need to add both of these libs to Libs property.
Sundong Ahn054b19a2018-10-19 13:46:09 +0900523 props.Libs = module.Library.Module.properties.Libs
524 props.Libs = append(props.Libs, module.Library.Module.properties.Static_libs...)
525 props.Aidl.Include_dirs = module.Library.Module.deviceProperties.Aidl.Include_dirs
526 props.Aidl.Local_include_dirs = module.Library.Module.deviceProperties.Aidl.Local_include_dirs
Sundong Ahn054b19a2018-10-19 13:46:09 +0900527 props.Java_version = module.Library.Module.properties.Java_version
Jiyong Parkc678ad32018-04-10 13:07:10 +0900528
Sundong Ahn054b19a2018-10-19 13:46:09 +0900529 props.Merge_annotations_dirs = module.sdkLibraryProperties.Merge_annotations_dirs
530 props.Merge_inclusion_annotations_dirs = module.sdkLibraryProperties.Merge_inclusion_annotations_dirs
531
Paul Duffin6d0886e2020-04-07 18:49:53 +0100532 droidstubsArgs := []string{}
Paul Duffin235ffff2019-12-24 10:41:30 +0000533 if len(module.sdkLibraryProperties.Api_packages) != 0 {
Paul Duffin6d0886e2020-04-07 18:49:53 +0100534 droidstubsArgs = append(droidstubsArgs, "--stub-packages "+strings.Join(module.sdkLibraryProperties.Api_packages, ":"))
Paul Duffin235ffff2019-12-24 10:41:30 +0000535 }
536 if len(module.sdkLibraryProperties.Hidden_api_packages) != 0 {
Paul Duffin6d0886e2020-04-07 18:49:53 +0100537 droidstubsArgs = append(droidstubsArgs,
Paul Duffin235ffff2019-12-24 10:41:30 +0000538 android.JoinWithPrefix(module.sdkLibraryProperties.Hidden_api_packages, " --hide-package "))
539 }
Paul Duffin6d0886e2020-04-07 18:49:53 +0100540 droidstubsArgs = append(droidstubsArgs, module.sdkLibraryProperties.Droiddoc_options...)
Paul Duffin235ffff2019-12-24 10:41:30 +0000541 disabledWarnings := []string{
542 "MissingPermission",
543 "BroadcastBehavior",
544 "HiddenSuperclass",
545 "DeprecationMismatch",
546 "UnavailableSymbol",
547 "SdkConstant",
548 "HiddenTypeParameter",
549 "Todo",
550 "Typo",
551 }
Paul Duffin6d0886e2020-04-07 18:49:53 +0100552 droidstubsArgs = append(droidstubsArgs, android.JoinWithPrefix(disabledWarnings, "--hide "))
Sundong Ahnfb2721f2018-09-17 13:23:09 +0900553
Paul Duffin1fb487d2020-04-07 18:50:10 +0100554 // Add in scope specific arguments.
555 droidstubsArgs = append(droidstubsArgs, apiScope.droidstubsArgs...)
Paul Duffin11512472019-02-11 15:55:17 +0000556 props.Arg_files = module.sdkLibraryProperties.Droiddoc_option_files
Paul Duffin6d0886e2020-04-07 18:49:53 +0100557 props.Args = proptools.StringPtr(strings.Join(droidstubsArgs, " "))
Jiyong Parkc678ad32018-04-10 13:07:10 +0900558
559 // List of APIs identified from the provided source files are created. They are later
560 // compared against to the not-yet-released (a.k.a current) list of APIs and to the
561 // last-released (a.k.a numbered) list of API.
Paul Duffind1b3a922020-01-22 11:57:20 +0000562 currentApiFileName := apiScope.apiFilePrefix + "current.txt"
563 removedApiFileName := apiScope.apiFilePrefix + "removed.txt"
Paul Duffin749f98f2019-12-30 17:23:46 +0000564 apiDir := module.getApiDir()
565 currentApiFileName = path.Join(apiDir, currentApiFileName)
566 removedApiFileName = path.Join(apiDir, removedApiFileName)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900567
Jiyong Park58c518b2018-05-12 22:29:12 +0900568 // check against the not-yet-release API
569 props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName)
570 props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName)
Jiyong Park58c518b2018-05-12 22:29:12 +0900571
Anton Hansson6478ac12020-05-02 11:19:36 +0100572 if !apiScope.unstable {
573 // check against the latest released API
574 props.Check_api.Last_released.Api_file = proptools.StringPtr(
575 module.latestApiFilegroupName(apiScope))
576 props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
577 module.latestRemovedApiFilegroupName(apiScope))
578 props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
579 }
Jiyong Park58c518b2018-05-12 22:29:12 +0900580
Anton Hansson5fd5d242020-03-27 19:43:19 +0000581 // Dist the api txt artifact for sdk builds.
582 if !Bool(module.sdkLibraryProperties.No_dist) {
583 props.Dist.Targets = []string{"sdk", "win_sdk"}
584 props.Dist.Dest = proptools.StringPtr(fmt.Sprintf("%v.txt", module.BaseModuleName()))
585 props.Dist.Dir = proptools.StringPtr(path.Join(module.apiDistPath(apiScope), "api"))
586 }
587
Colin Cross84dfc3d2019-09-25 11:33:01 -0700588 mctx.CreateModule(DroidstubsFactory, &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900589}
590
Jooyung Han5e9013b2020-03-10 06:23:13 +0900591func (module *SdkLibrary) DepIsInSameApex(mctx android.BaseModuleContext, dep android.Module) bool {
592 depTag := mctx.OtherModuleDependencyTag(dep)
593 if depTag == xmlPermissionsFileTag {
594 return true
595 }
596 return module.Library.DepIsInSameApex(mctx, dep)
597}
598
Jiyong Parkc678ad32018-04-10 13:07:10 +0900599// Creates the xml file that publicizes the runtime library
Paul Duffinf0229202020-04-29 16:47:28 +0100600func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) {
Jiyong Parke3833882020-02-17 17:28:10 +0900601 props := struct {
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900602 Name *string
Jiyong Parke3833882020-02-17 17:28:10 +0900603 Lib_name *string
Sundong Ahn0d7dff42019-12-04 12:53:44 +0900604 Soc_specific *bool
605 Device_specific *bool
606 Product_specific *bool
607 System_ext_specific *bool
Jooyung Han5e9013b2020-03-10 06:23:13 +0900608 Apex_available []string
Jiyong Parke3833882020-02-17 17:28:10 +0900609 }{
Jooyung Han5e9013b2020-03-10 06:23:13 +0900610 Name: proptools.StringPtr(module.xmlFileName()),
611 Lib_name: proptools.StringPtr(module.BaseModuleName()),
612 Apex_available: module.ApexProperties.Apex_available,
Jiyong Parkc678ad32018-04-10 13:07:10 +0900613 }
Jiyong Parke3833882020-02-17 17:28:10 +0900614
615 if module.SocSpecific() {
616 props.Soc_specific = proptools.BoolPtr(true)
617 } else if module.DeviceSpecific() {
618 props.Device_specific = proptools.BoolPtr(true)
619 } else if module.ProductSpecific() {
620 props.Product_specific = proptools.BoolPtr(true)
621 } else if module.SystemExtSpecific() {
622 props.System_ext_specific = proptools.BoolPtr(true)
623 }
624
625 mctx.CreateModule(sdkLibraryXmlFactory, &props)
Jiyong Parkc678ad32018-04-10 13:07:10 +0900626}
627
Paul Duffin50061512020-01-21 16:31:05 +0000628func PrebuiltJars(ctx android.BaseModuleContext, baseName string, s sdkSpec) android.Paths {
Jiyong Park6a927c42020-01-21 02:03:43 +0900629 var ver sdkVersion
630 var kind sdkKind
631 if s.usePrebuilt(ctx) {
632 ver = s.version
633 kind = s.kind
Jiyong Parkc678ad32018-04-10 13:07:10 +0900634 } else {
Jiyong Park6a927c42020-01-21 02:03:43 +0900635 // We don't have prebuilt SDK for the specific sdkVersion.
636 // Instead of breaking the build, fallback to use "system_current"
637 ver = sdkVersionCurrent
638 kind = sdkSystem
Sundong Ahn054b19a2018-10-19 13:46:09 +0900639 }
Jiyong Park6a927c42020-01-21 02:03:43 +0900640
641 dir := filepath.Join("prebuilts", "sdk", ver.String(), kind.String())
Paul Duffin50061512020-01-21 16:31:05 +0000642 jar := filepath.Join(dir, baseName+".jar")
Sundong Ahn054b19a2018-10-19 13:46:09 +0900643 jarPath := android.ExistentPathForSource(ctx, jar)
Sundong Ahnae418ac2019-02-28 15:01:28 +0900644 if !jarPath.Valid() {
Colin Cross07c88562020-01-07 09:34:44 -0800645 if ctx.Config().AllowMissingDependencies() {
646 return android.Paths{android.PathForSource(ctx, jar)}
647 } else {
Jiyong Park6a927c42020-01-21 02:03:43 +0900648 ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", s.raw, jar)
Colin Cross07c88562020-01-07 09:34:44 -0800649 }
Sundong Ahnae418ac2019-02-28 15:01:28 +0900650 return nil
651 }
Sundong Ahn054b19a2018-10-19 13:46:09 +0900652 return android.Paths{jarPath.Path()}
653}
654
Paul Duffind1b3a922020-01-22 11:57:20 +0000655func (module *SdkLibrary) sdkJars(
656 ctx android.BaseModuleContext,
657 sdkVersion sdkSpec,
658 headerJars bool) android.Paths {
659
Paul Duffin50061512020-01-21 16:31:05 +0000660 // If a specific numeric version has been requested then use prebuilt versions of the sdk.
661 if sdkVersion.version.isNumbered() {
662 return PrebuiltJars(ctx, module.BaseModuleName(), sdkVersion)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900663 } else {
Paul Duffind1b3a922020-01-22 11:57:20 +0000664 if !sdkVersion.specified() {
665 if headerJars {
666 return module.Library.HeaderJars()
667 } else {
668 return module.Library.ImplementationJars()
669 }
670 }
Paul Duffin726d23c2020-01-22 16:30:37 +0000671 var apiScope *apiScope
Jiyong Park6a927c42020-01-21 02:03:43 +0900672 switch sdkVersion.kind {
673 case sdkSystem:
Paul Duffin726d23c2020-01-22 16:30:37 +0000674 apiScope = apiScopeSystem
675 case sdkTest:
676 apiScope = apiScopeTest
Jiyong Park6a927c42020-01-21 02:03:43 +0900677 case sdkPrivate:
Sundong Ahn054b19a2018-10-19 13:46:09 +0900678 return module.Library.HeaderJars()
Jiyong Park6a927c42020-01-21 02:03:43 +0900679 default:
Paul Duffin726d23c2020-01-22 16:30:37 +0000680 apiScope = apiScopePublic
Paul Duffind1b3a922020-01-22 11:57:20 +0000681 }
682
Paul Duffin726d23c2020-01-22 16:30:37 +0000683 paths := module.getScopePaths(apiScope)
Paul Duffind1b3a922020-01-22 11:57:20 +0000684 if headerJars {
685 return paths.stubsHeaderPath
686 } else {
687 return paths.stubsImplPath
Sundong Ahn054b19a2018-10-19 13:46:09 +0900688 }
Jiyong Parkc678ad32018-04-10 13:07:10 +0900689 }
690}
691
Sundong Ahn241cd372018-07-13 16:16:44 +0900692// to satisfy SdkLibraryDependency interface
Paul Duffind1b3a922020-01-22 11:57:20 +0000693func (module *SdkLibrary) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
694 return module.sdkJars(ctx, sdkVersion, true /*headerJars*/)
695}
696
697// to satisfy SdkLibraryDependency interface
Jiyong Park6a927c42020-01-21 02:03:43 +0900698func (module *SdkLibrary) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
Paul Duffind1b3a922020-01-22 11:57:20 +0000699 return module.sdkJars(ctx, sdkVersion, false /*headerJars*/)
Sundong Ahn241cd372018-07-13 16:16:44 +0900700}
701
Sundong Ahn80a87b32019-05-13 15:02:50 +0900702func (module *SdkLibrary) SetNoDist() {
703 module.sdkLibraryProperties.No_dist = proptools.BoolPtr(true)
704}
705
Colin Cross571cccf2019-02-04 11:22:08 -0800706var javaSdkLibrariesKey = android.NewOnceKey("javaSdkLibraries")
707
Jiyong Park82484c02018-04-23 21:41:26 +0900708func javaSdkLibraries(config android.Config) *[]string {
Colin Cross571cccf2019-02-04 11:22:08 -0800709 return config.Once(javaSdkLibrariesKey, func() interface{} {
Jiyong Park82484c02018-04-23 21:41:26 +0900710 return &[]string{}
711 }).(*[]string)
712}
713
Paul Duffin749f98f2019-12-30 17:23:46 +0000714func (module *SdkLibrary) getApiDir() string {
715 return proptools.StringDefault(module.sdkLibraryProperties.Api_dir, "api")
716}
717
Jiyong Parkc678ad32018-04-10 13:07:10 +0900718// For a java_sdk_library module, create internal modules for stubs, docs,
719// runtime libs and xml file. If requested, the stubs and docs are created twice
720// once for public API level and once for system API level
Paul Duffinf0229202020-04-29 16:47:28 +0100721func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) {
722 // If the module has been disabled then don't create any child modules.
723 if !module.Enabled() {
724 return
725 }
726
Inseob Kim6e93ac92019-03-21 17:43:49 +0900727 if len(module.Library.Module.properties.Srcs) == 0 {
Inseob Kimc0907f12019-02-08 21:00:45 +0900728 mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs")
Jooyung Han58f26ab2019-12-18 15:34:32 +0900729 return
Inseob Kimc0907f12019-02-08 21:00:45 +0900730 }
731
Paul Duffin37e0b772019-12-30 17:20:10 +0000732 // If this builds against standard libraries (i.e. is not part of the core libraries)
733 // then assume it provides both system and test apis. Otherwise, assume it does not and
734 // also assume it does not contribute to the dist build.
735 sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library))
736 hasSystemAndTestApis := sdkDep.hasStandardLibs()
737 module.sdkLibraryProperties.Has_system_and_test_apis = hasSystemAndTestApis
738 module.sdkLibraryProperties.No_dist = proptools.BoolPtr(!hasSystemAndTestApis)
739
Inseob Kim8098faa2019-03-18 10:19:51 +0900740 missing_current_api := false
741
Paul Duffind1b3a922020-01-22 11:57:20 +0000742 activeScopes := module.getActiveApiScopes()
743
Paul Duffin749f98f2019-12-30 17:23:46 +0000744 apiDir := module.getApiDir()
Paul Duffind1b3a922020-01-22 11:57:20 +0000745 for _, scope := range activeScopes {
Inseob Kim8098faa2019-03-18 10:19:51 +0900746 for _, api := range []string{"current.txt", "removed.txt"} {
Paul Duffind1b3a922020-01-22 11:57:20 +0000747 path := path.Join(mctx.ModuleDir(), apiDir, scope.apiFilePrefix+api)
Inseob Kim8098faa2019-03-18 10:19:51 +0900748 p := android.ExistentPathForSource(mctx, path)
749 if !p.Valid() {
750 mctx.ModuleErrorf("Current api file %#v doesn't exist", path)
751 missing_current_api = true
752 }
753 }
754 }
755
756 if missing_current_api {
757 script := "build/soong/scripts/gen-java-current-api-files.sh"
758 p := android.ExistentPathForSource(mctx, script)
759
760 if !p.Valid() {
761 panic(fmt.Sprintf("script file %s doesn't exist", script))
762 }
763
764 mctx.ModuleErrorf("One or more current api files are missing. "+
765 "You can update them by:\n"+
Paul Duffin37e0b772019-12-30 17:20:10 +0000766 "%s %q %s && m update-api",
Paul Duffind1b3a922020-01-22 11:57:20 +0000767 script, filepath.Join(mctx.ModuleDir(), apiDir),
768 strings.Join(activeScopes.Strings(func(s *apiScope) string { return s.apiFilePrefix }), " "))
Inseob Kim8098faa2019-03-18 10:19:51 +0900769 return
770 }
771
Paul Duffind1b3a922020-01-22 11:57:20 +0000772 for _, scope := range activeScopes {
773 module.createStubsLibrary(mctx, scope)
774 module.createStubsSources(mctx, scope)
Inseob Kimc0907f12019-02-08 21:00:45 +0900775 }
776
Paul Duffin43db9be2019-12-30 17:35:49 +0000777 if !proptools.Bool(module.sdkLibraryProperties.Api_only) {
778 // for runtime
779 module.createXmlFile(mctx)
780
781 // record java_sdk_library modules so that they are exported to make
782 javaSdkLibraries := javaSdkLibraries(mctx.Config())
783 javaSdkLibrariesLock.Lock()
784 defer javaSdkLibrariesLock.Unlock()
785 *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
786 }
Inseob Kimc0907f12019-02-08 21:00:45 +0900787}
788
789func (module *SdkLibrary) InitSdkLibraryProperties() {
Sundong Ahn054b19a2018-10-19 13:46:09 +0900790 module.AddProperties(
791 &module.sdkLibraryProperties,
792 &module.Library.Module.properties,
793 &module.Library.Module.dexpreoptProperties,
794 &module.Library.Module.deviceProperties,
795 &module.Library.Module.protoProperties,
796 )
797
798 module.Library.Module.properties.Installable = proptools.BoolPtr(true)
799 module.Library.Module.deviceProperties.IsSDKLibrary = true
Inseob Kimc0907f12019-02-08 21:00:45 +0900800}
Sundong Ahn054b19a2018-10-19 13:46:09 +0900801
Jaewoong Jung4f158ee2019-07-11 10:05:35 -0700802// java_sdk_library is a special Java library that provides optional platform APIs to apps.
803// In practice, it can be viewed as a combination of several modules: 1) stubs library that clients
804// are linked against to, 2) droiddoc module that internally generates API stubs source files,
805// 3) the real runtime shared library that implements the APIs, and 4) XML file for adding
806// the runtime lib to the classpath at runtime if requested via <uses-library>.
Inseob Kimc0907f12019-02-08 21:00:45 +0900807func SdkLibraryFactory() android.Module {
808 module := &SdkLibrary{}
809 module.InitSdkLibraryProperties()
Jooyung Han58f26ab2019-12-18 15:34:32 +0900810 android.InitApexModule(module)
Sundong Ahn054b19a2018-10-19 13:46:09 +0900811 InitJavaModule(module, android.HostAndDeviceSupported)
Paul Duffinf0229202020-04-29 16:47:28 +0100812 module.SetDefaultableHook(func(ctx android.DefaultableHookContext) { module.CreateInternalModules(ctx) })
Jiyong Parkc678ad32018-04-10 13:07:10 +0900813 return module
814}
Colin Cross79c7c262019-04-17 11:11:46 -0700815
816//
817// SDK library prebuilts
818//
819
Paul Duffin56d44902020-01-31 13:36:25 +0000820// Properties associated with each api scope.
821type sdkLibraryScopeProperties struct {
Colin Cross79c7c262019-04-17 11:11:46 -0700822 Jars []string `android:"path"`
823
824 Sdk_version *string
825
Colin Cross79c7c262019-04-17 11:11:46 -0700826 // List of shared java libs that this module has dependencies to
827 Libs []string
Paul Duffin3d1248c2020-04-09 00:10:17 +0100828
829 // The stub sources.
830 Stub_srcs []string `android:"path"`
Paul Duffin1fd005d2020-04-09 01:08:11 +0100831
832 // The current.txt
833 Current_api string `android:"path"`
834
835 // The removed.txt
836 Removed_api string `android:"path"`
Colin Cross79c7c262019-04-17 11:11:46 -0700837}
838
Paul Duffin56d44902020-01-31 13:36:25 +0000839type sdkLibraryImportProperties struct {
Paul Duffinfcfd7912020-01-31 17:54:30 +0000840 // List of shared java libs, common to all scopes, that this module has
841 // dependencies to
842 Libs []string
Paul Duffin56d44902020-01-31 13:36:25 +0000843}
844
Colin Cross79c7c262019-04-17 11:11:46 -0700845type sdkLibraryImport struct {
846 android.ModuleBase
847 android.DefaultableModuleBase
848 prebuilt android.Prebuilt
Paul Duffindd46f712020-02-10 13:37:10 +0000849 android.ApexModuleBase
850 android.SdkBase
Colin Cross79c7c262019-04-17 11:11:46 -0700851
852 properties sdkLibraryImportProperties
853
Paul Duffin46a26a82020-04-07 19:27:04 +0100854 // Map from api scope to the scope specific property structure.
855 scopeProperties map[*apiScope]*sdkLibraryScopeProperties
856
Paul Duffin56d44902020-01-31 13:36:25 +0000857 commonToSdkLibraryAndImport
Colin Cross79c7c262019-04-17 11:11:46 -0700858}
859
860var _ SdkLibraryDependency = (*sdkLibraryImport)(nil)
861
Paul Duffin46a26a82020-04-07 19:27:04 +0100862// The type of a structure that contains a field of type sdkLibraryScopeProperties
863// for each apiscope in allApiScopes, e.g. something like:
864// struct {
865// Public sdkLibraryScopeProperties
866// System sdkLibraryScopeProperties
867// ...
868// }
869var allScopeStructType = createAllScopePropertiesStructType()
870
871// Dynamically create a structure type for each apiscope in allApiScopes.
872func createAllScopePropertiesStructType() reflect.Type {
873 var fields []reflect.StructField
874 for _, apiScope := range allApiScopes {
875 field := reflect.StructField{
876 Name: apiScope.fieldName,
877 Type: reflect.TypeOf(sdkLibraryScopeProperties{}),
878 }
879 fields = append(fields, field)
880 }
881
882 return reflect.StructOf(fields)
883}
884
885// Create an instance of the scope specific structure type and return a map
886// from apiscope to a pointer to each scope specific field.
887func createPropertiesInstance() (interface{}, map[*apiScope]*sdkLibraryScopeProperties) {
888 allScopePropertiesPtr := reflect.New(allScopeStructType)
889 allScopePropertiesStruct := allScopePropertiesPtr.Elem()
890 scopeProperties := make(map[*apiScope]*sdkLibraryScopeProperties)
891
892 for _, apiScope := range allApiScopes {
893 field := allScopePropertiesStruct.FieldByName(apiScope.fieldName)
894 scopeProperties[apiScope] = field.Addr().Interface().(*sdkLibraryScopeProperties)
895 }
896
897 return allScopePropertiesPtr.Interface(), scopeProperties
898}
899
Jaewoong Jung4f158ee2019-07-11 10:05:35 -0700900// java_sdk_library_import imports a prebuilt java_sdk_library.
Colin Cross79c7c262019-04-17 11:11:46 -0700901func sdkLibraryImportFactory() android.Module {
902 module := &sdkLibraryImport{}
903
Paul Duffin46a26a82020-04-07 19:27:04 +0100904 allScopeProperties, scopeToProperties := createPropertiesInstance()
905 module.scopeProperties = scopeToProperties
906 module.AddProperties(&module.properties, allScopeProperties)
Colin Cross79c7c262019-04-17 11:11:46 -0700907
Paul Duffin0bdcb272020-02-06 15:24:57 +0000908 android.InitPrebuiltModule(module, &[]string{""})
Paul Duffindd46f712020-02-10 13:37:10 +0000909 android.InitApexModule(module)
910 android.InitSdkAwareModule(module)
Colin Cross79c7c262019-04-17 11:11:46 -0700911 InitJavaModule(module, android.HostAndDeviceSupported)
912
913 android.AddLoadHook(module, func(mctx android.LoadHookContext) { module.createInternalModules(mctx) })
914 return module
915}
916
917func (module *sdkLibraryImport) Prebuilt() *android.Prebuilt {
918 return &module.prebuilt
919}
920
921func (module *sdkLibraryImport) Name() string {
922 return module.prebuilt.Name(module.ModuleBase.Name())
923}
924
925func (module *sdkLibraryImport) createInternalModules(mctx android.LoadHookContext) {
Colin Cross79c7c262019-04-17 11:11:46 -0700926
Paul Duffin50061512020-01-21 16:31:05 +0000927 // If the build is configured to use prebuilts then force this to be preferred.
928 if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
929 module.prebuilt.ForcePrefer()
930 }
931
Paul Duffin46a26a82020-04-07 19:27:04 +0100932 for apiScope, scopeProperties := range module.scopeProperties {
Paul Duffin56d44902020-01-31 13:36:25 +0000933 if len(scopeProperties.Jars) == 0 {
934 continue
935 }
936
Paul Duffinbbb546b2020-04-09 00:07:11 +0100937 module.createJavaImportForStubs(mctx, apiScope, scopeProperties)
Paul Duffin3d1248c2020-04-09 00:10:17 +0100938
939 module.createPrebuiltStubsSources(mctx, apiScope, scopeProperties)
Paul Duffin56d44902020-01-31 13:36:25 +0000940 }
Colin Cross79c7c262019-04-17 11:11:46 -0700941
942 javaSdkLibraries := javaSdkLibraries(mctx.Config())
943 javaSdkLibrariesLock.Lock()
944 defer javaSdkLibrariesLock.Unlock()
945 *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName())
946}
947
Paul Duffinbbb546b2020-04-09 00:07:11 +0100948func (module *sdkLibraryImport) createJavaImportForStubs(mctx android.LoadHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) {
949 // Creates a java import for the jar with ".stubs" suffix
950 props := struct {
951 Name *string
952 Soc_specific *bool
953 Device_specific *bool
954 Product_specific *bool
955 System_ext_specific *bool
956 Sdk_version *string
957 Libs []string
958 Jars []string
959 Prefer *bool
960 }{}
961 props.Name = proptools.StringPtr(apiScope.stubsModuleName(module.BaseModuleName()))
962 props.Sdk_version = scopeProperties.Sdk_version
963 // Prepend any of the libs from the legacy public properties to the libs for each of the
964 // scopes to avoid having to duplicate them in each scope.
965 props.Libs = append(module.properties.Libs, scopeProperties.Libs...)
966 props.Jars = scopeProperties.Jars
967 if module.SocSpecific() {
968 props.Soc_specific = proptools.BoolPtr(true)
969 } else if module.DeviceSpecific() {
970 props.Device_specific = proptools.BoolPtr(true)
971 } else if module.ProductSpecific() {
972 props.Product_specific = proptools.BoolPtr(true)
973 } else if module.SystemExtSpecific() {
974 props.System_ext_specific = proptools.BoolPtr(true)
975 }
976 // If the build should use prebuilt sdks then set prefer to true on the stubs library.
977 // That will cause the prebuilt version of the stubs to override the source version.
978 if mctx.Config().UnbundledBuildUsePrebuiltSdks() {
979 props.Prefer = proptools.BoolPtr(true)
980 }
981 mctx.CreateModule(ImportFactory, &props)
982}
983
Paul Duffin3d1248c2020-04-09 00:10:17 +0100984func (module *sdkLibraryImport) createPrebuiltStubsSources(mctx android.LoadHookContext, apiScope *apiScope, scopeProperties *sdkLibraryScopeProperties) {
985 props := struct {
986 Name *string
987 Srcs []string
988 }{}
989 props.Name = proptools.StringPtr(apiScope.docsModuleName(module.BaseModuleName()))
990 props.Srcs = scopeProperties.Stub_srcs
991 mctx.CreateModule(PrebuiltStubsSourcesFactory, &props)
992}
993
Colin Cross79c7c262019-04-17 11:11:46 -0700994func (module *sdkLibraryImport) DepsMutator(ctx android.BottomUpMutatorContext) {
Paul Duffin46a26a82020-04-07 19:27:04 +0100995 for apiScope, scopeProperties := range module.scopeProperties {
Paul Duffin56d44902020-01-31 13:36:25 +0000996 if len(scopeProperties.Jars) == 0 {
997 continue
998 }
999
1000 // Add dependencies to the prebuilt stubs library
1001 ctx.AddVariationDependencies(nil, apiScope.stubsTag, apiScope.stubsModuleName(module.BaseModuleName()))
1002 }
Colin Cross79c7c262019-04-17 11:11:46 -07001003}
1004
1005func (module *sdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1006 // Record the paths to the prebuilt stubs library.
1007 ctx.VisitDirectDeps(func(to android.Module) {
1008 tag := ctx.OtherModuleDependencyTag(to)
1009
Paul Duffin56d44902020-01-31 13:36:25 +00001010 if lib, ok := to.(Dependency); ok {
1011 if scopeTag, ok := tag.(scopeDependencyTag); ok {
1012 apiScope := scopeTag.apiScope
1013 scopePaths := module.getScopePaths(apiScope)
1014 scopePaths.stubsHeaderPath = lib.HeaderJars()
1015 }
Colin Cross79c7c262019-04-17 11:11:46 -07001016 }
1017 })
1018}
1019
Paul Duffin56d44902020-01-31 13:36:25 +00001020func (module *sdkLibraryImport) sdkJars(
1021 ctx android.BaseModuleContext,
1022 sdkVersion sdkSpec) android.Paths {
1023
Paul Duffin50061512020-01-21 16:31:05 +00001024 // If a specific numeric version has been requested then use prebuilt versions of the sdk.
1025 if sdkVersion.version.isNumbered() {
1026 return PrebuiltJars(ctx, module.BaseModuleName(), sdkVersion)
1027 }
1028
Paul Duffin56d44902020-01-31 13:36:25 +00001029 var apiScope *apiScope
1030 switch sdkVersion.kind {
1031 case sdkSystem:
1032 apiScope = apiScopeSystem
1033 case sdkTest:
1034 apiScope = apiScopeTest
1035 default:
1036 apiScope = apiScopePublic
1037 }
1038
1039 paths := module.getScopePaths(apiScope)
1040 return paths.stubsHeaderPath
1041}
1042
Colin Cross79c7c262019-04-17 11:11:46 -07001043// to satisfy SdkLibraryDependency interface
Jiyong Park6a927c42020-01-21 02:03:43 +09001044func (module *sdkLibraryImport) SdkHeaderJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
Colin Cross79c7c262019-04-17 11:11:46 -07001045 // This module is just a wrapper for the prebuilt stubs.
Paul Duffin56d44902020-01-31 13:36:25 +00001046 return module.sdkJars(ctx, sdkVersion)
Colin Cross79c7c262019-04-17 11:11:46 -07001047}
1048
1049// to satisfy SdkLibraryDependency interface
Jiyong Park6a927c42020-01-21 02:03:43 +09001050func (module *sdkLibraryImport) SdkImplementationJars(ctx android.BaseModuleContext, sdkVersion sdkSpec) android.Paths {
Colin Cross79c7c262019-04-17 11:11:46 -07001051 // This module is just a wrapper for the stubs.
Paul Duffin56d44902020-01-31 13:36:25 +00001052 return module.sdkJars(ctx, sdkVersion)
Colin Cross79c7c262019-04-17 11:11:46 -07001053}
Jiyong Parke3833882020-02-17 17:28:10 +09001054
1055//
1056// java_sdk_library_xml
1057//
1058type sdkLibraryXml struct {
1059 android.ModuleBase
1060 android.DefaultableModuleBase
1061 android.ApexModuleBase
1062
1063 properties sdkLibraryXmlProperties
1064
1065 outputFilePath android.OutputPath
1066 installDirPath android.InstallPath
1067}
1068
1069type sdkLibraryXmlProperties struct {
1070 // canonical name of the lib
1071 Lib_name *string
1072}
1073
1074// java_sdk_library_xml builds the permission xml file for a java_sdk_library.
1075// Not to be used directly by users. java_sdk_library internally uses this.
1076func sdkLibraryXmlFactory() android.Module {
1077 module := &sdkLibraryXml{}
1078
1079 module.AddProperties(&module.properties)
1080
1081 android.InitApexModule(module)
1082 android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
1083
1084 return module
1085}
1086
1087// from android.PrebuiltEtcModule
1088func (module *sdkLibraryXml) SubDir() string {
1089 return "permissions"
1090}
1091
1092// from android.PrebuiltEtcModule
1093func (module *sdkLibraryXml) OutputFile() android.OutputPath {
1094 return module.outputFilePath
1095}
1096
1097// from android.ApexModule
1098func (module *sdkLibraryXml) AvailableFor(what string) bool {
1099 return true
1100}
1101
1102func (module *sdkLibraryXml) DepsMutator(ctx android.BottomUpMutatorContext) {
1103 // do nothing
1104}
1105
1106// File path to the runtime implementation library
1107func (module *sdkLibraryXml) implPath() string {
1108 implName := proptools.String(module.properties.Lib_name)
1109 if apexName := module.ApexName(); apexName != "" {
1110 // TODO(b/146468504): ApexName() is only a soong module name, not apex name.
1111 // In most cases, this works fine. But when apex_name is set or override_apex is used
1112 // this can be wrong.
1113 return fmt.Sprintf("/apex/%s/javalib/%s.jar", apexName, implName)
1114 }
1115 partition := "system"
1116 if module.SocSpecific() {
1117 partition = "vendor"
1118 } else if module.DeviceSpecific() {
1119 partition = "odm"
1120 } else if module.ProductSpecific() {
1121 partition = "product"
1122 } else if module.SystemExtSpecific() {
1123 partition = "system_ext"
1124 }
1125 return "/" + partition + "/framework/" + implName + ".jar"
1126}
1127
1128func (module *sdkLibraryXml) GenerateAndroidBuildActions(ctx android.ModuleContext) {
1129 libName := proptools.String(module.properties.Lib_name)
1130 xmlContent := fmt.Sprintf(permissionsTemplate, libName, module.implPath())
1131
1132 module.outputFilePath = android.PathForModuleOut(ctx, libName+".xml").OutputPath
1133 rule := android.NewRuleBuilder()
1134 rule.Command().
1135 Text("/bin/bash -c \"echo -e '" + xmlContent + "'\" > ").
1136 Output(module.outputFilePath)
1137
1138 rule.Build(pctx, ctx, "java_sdk_xml", "Permission XML")
1139
1140 module.installDirPath = android.PathForModuleInstall(ctx, "etc", module.SubDir())
1141}
1142
1143func (module *sdkLibraryXml) AndroidMkEntries() []android.AndroidMkEntries {
1144 if !module.IsForPlatform() {
1145 return []android.AndroidMkEntries{android.AndroidMkEntries{
1146 Disabled: true,
1147 }}
1148 }
1149
1150 return []android.AndroidMkEntries{android.AndroidMkEntries{
1151 Class: "ETC",
1152 OutputFile: android.OptionalPathForPath(module.outputFilePath),
1153 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
1154 func(entries *android.AndroidMkEntries) {
1155 entries.SetString("LOCAL_MODULE_TAGS", "optional")
1156 entries.SetString("LOCAL_MODULE_PATH", module.installDirPath.ToMakePath().String())
1157 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", module.outputFilePath.Base())
1158 },
1159 },
1160 }}
1161}
Paul Duffindd46f712020-02-10 13:37:10 +00001162
1163type sdkLibrarySdkMemberType struct {
1164 android.SdkMemberTypeBase
1165}
1166
1167func (s *sdkLibrarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorContext, dependencyTag blueprint.DependencyTag, names []string) {
1168 mctx.AddVariationDependencies(nil, dependencyTag, names...)
1169}
1170
1171func (s *sdkLibrarySdkMemberType) IsInstance(module android.Module) bool {
1172 _, ok := module.(*SdkLibrary)
1173 return ok
1174}
1175
1176func (s *sdkLibrarySdkMemberType) AddPrebuiltModule(ctx android.SdkMemberContext, member android.SdkMember) android.BpModule {
1177 return ctx.SnapshotBuilder().AddPrebuiltModule(member, "java_sdk_library_import")
1178}
1179
1180func (s *sdkLibrarySdkMemberType) CreateVariantPropertiesStruct() android.SdkMemberProperties {
1181 return &sdkLibrarySdkMemberProperties{}
1182}
1183
1184type sdkLibrarySdkMemberProperties struct {
1185 android.SdkMemberPropertiesBase
1186
1187 // Scope to per scope properties.
1188 Scopes map[*apiScope]scopeProperties
1189
1190 // Additional libraries that the exported stubs libraries depend upon.
1191 Libs []string
Paul Duffin3d1248c2020-04-09 00:10:17 +01001192
1193 // The Java stubs source files.
1194 Stub_srcs []string
Paul Duffindd46f712020-02-10 13:37:10 +00001195}
1196
1197type scopeProperties struct {
Paul Duffin1fd005d2020-04-09 01:08:11 +01001198 Jars android.Paths
1199 StubsSrcJar android.Path
1200 CurrentApiFile android.Path
1201 RemovedApiFile android.Path
1202 SdkVersion string
Paul Duffindd46f712020-02-10 13:37:10 +00001203}
1204
1205func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
1206 sdk := variant.(*SdkLibrary)
1207
1208 s.Scopes = make(map[*apiScope]scopeProperties)
1209 for _, apiScope := range allApiScopes {
1210 paths := sdk.getScopePaths(apiScope)
1211 jars := paths.stubsImplPath
1212 if len(jars) > 0 {
1213 properties := scopeProperties{}
1214 properties.Jars = jars
1215 properties.SdkVersion = apiScope.sdkVersion
Paul Duffin3d1248c2020-04-09 00:10:17 +01001216 properties.StubsSrcJar = paths.stubsSrcJar
Paul Duffin1fd005d2020-04-09 01:08:11 +01001217 properties.CurrentApiFile = paths.currentApiFilePath
1218 properties.RemovedApiFile = paths.removedApiFilePath
Paul Duffindd46f712020-02-10 13:37:10 +00001219 s.Scopes[apiScope] = properties
1220 }
1221 }
1222
1223 s.Libs = sdk.properties.Libs
1224}
1225
1226func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
1227 for _, apiScope := range allApiScopes {
1228 if properties, ok := s.Scopes[apiScope]; ok {
1229 scopeSet := propertySet.AddPropertySet(apiScope.name)
1230
Paul Duffin3d1248c2020-04-09 00:10:17 +01001231 scopeDir := filepath.Join("sdk_library", s.OsPrefix(), apiScope.name)
1232
Paul Duffindd46f712020-02-10 13:37:10 +00001233 var jars []string
1234 for _, p := range properties.Jars {
Paul Duffin3d1248c2020-04-09 00:10:17 +01001235 dest := filepath.Join(scopeDir, ctx.Name()+"-stubs.jar")
Paul Duffindd46f712020-02-10 13:37:10 +00001236 ctx.SnapshotBuilder().CopyToSnapshot(p, dest)
1237 jars = append(jars, dest)
1238 }
1239 scopeSet.AddProperty("jars", jars)
1240
Paul Duffin3d1248c2020-04-09 00:10:17 +01001241 // Merge the stubs source jar into the snapshot zip so that when it is unpacked
1242 // the source files are also unpacked.
1243 snapshotRelativeDir := filepath.Join(scopeDir, ctx.Name()+"_stub_sources")
1244 ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir)
1245 scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir})
1246
Paul Duffin1fd005d2020-04-09 01:08:11 +01001247 if properties.CurrentApiFile != nil {
1248 currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt")
1249 ctx.SnapshotBuilder().CopyToSnapshot(properties.CurrentApiFile, currentApiSnapshotPath)
1250 scopeSet.AddProperty("current_api", currentApiSnapshotPath)
1251 }
1252
1253 if properties.RemovedApiFile != nil {
1254 removedApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+"-removed.txt")
1255 ctx.SnapshotBuilder().CopyToSnapshot(properties.CurrentApiFile, removedApiSnapshotPath)
1256 scopeSet.AddProperty("removed_api", removedApiSnapshotPath)
1257 }
1258
Paul Duffindd46f712020-02-10 13:37:10 +00001259 if properties.SdkVersion != "" {
1260 scopeSet.AddProperty("sdk_version", properties.SdkVersion)
1261 }
1262 }
1263 }
1264
1265 if len(s.Libs) > 0 {
1266 propertySet.AddPropertyWithTag("libs", s.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(false))
1267 }
1268}