summaryrefslogtreecommitdiff
path: root/android/sdk_version.go
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2023-03-20 18:52:50 +0000
committer Spandan Das <spandandas@google.com> 2023-03-20 20:50:03 +0000
commit626a8ad9348066fdca52aefe25ce004d8ae56e44 (patch)
tree1ef9dd45be6ab9d173d7c21f8e0083473a83e034 /android/sdk_version.go
parent44ac6dad279f320f6c5cae445b5aded0ae5dd847 (diff)
Cleanup hardcoded references to android_*stubs_current
These hardcoded refs will need to be updated when we start using .txt stub equivalent (single-tree/multi-tree). Instead of strewing this logic all over the codebase, create a helper function that contains the replacement logic. All other places should call this helper function instead of calculating the name of .txt equivalent soong module by itself. (Will do a similar cleanup in build/make) Test: no change in ninja file Change-Id: I6bf999eb4aeaba6ac2a44b9016bae4ec8c79ce19
Diffstat (limited to 'android/sdk_version.go')
-rw-r--r--android/sdk_version.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/android/sdk_version.go b/android/sdk_version.go
index a7e03dcd8..cace88a01 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -84,6 +84,40 @@ func (k SdkKind) String() string {
}
}
+// JavaLibraryName returns the soong module containing the Java APIs of that API surface.
+func (k SdkKind) JavaLibraryName(c Config) string {
+ name := k.defaultJavaLibraryName()
+ return JavaLibraryNameFromText(c, name)
+}
+
+// JavaLibraryNameFromText returns the name of .txt equivalent of a java_library, but does
+// not check if either module exists.
+// TODO: Return .txt (single-tree or multi-tree equivalents) based on config
+func JavaLibraryNameFromText(c Config, name string) string {
+ // This returns the default for now.
+ // TODO: Implement this
+ return name
+}
+
+func (k SdkKind) defaultJavaLibraryName() string {
+ switch k {
+ case SdkPublic:
+ return "android_stubs_current"
+ case SdkSystem:
+ return "android_system_stubs_current"
+ case SdkTest:
+ return "android_test_stubs_current"
+ case SdkCore:
+ return "core.current.stubs"
+ case SdkModule:
+ return "android_module_lib_stubs_current"
+ case SdkSystemServer:
+ return "android_system_server_stubs_current"
+ default:
+ panic(fmt.Errorf("APIs of API surface %v cannot be provided by a single Soong module\n", k))
+ }
+}
+
// SdkSpec represents the kind and the version of an SDK for a module to build against
type SdkSpec struct {
Kind SdkKind