Improve consistency of handling java snapshot properties
Previously, java snapshot properties (java_library and java_test)
relied on the properties not being optimized when there was a single os
type and instead being added directly to the common os type properties.
However, that means that the behavior is inconsistent for other member
types depending on whether there was one os type or not.
This change updates the java sdk member handling to support
optimization. This involved:
1) Adding AidlIncludeDirs field to librarySdkMemberProperties to
specify the aidl include dirs instead of extracting that from the
library field.
2) Renaming jarToExport to JarToExport (in both
library/testSdkMemberProperties)to allow it to be optimized.
3) Adding MemberType() and Name() methods to SdkMemberPropertiesContext
to avoid having to store the former in the properties struct and
retrieve the latter from the library/test fields.
4) Removing the now unused library/test fields from the properties
structures.
5) Separating the processing of the jar/test config in
AddToPropertySet(...) as they may be optimized separately.
6) Ditto for the jar/aidl include dirs.
7) While doing this work I noticed that although the contents of the
aidl include dirs are copied into the snapshot the java_import does
not make use of them. Raised bug 151933053 and added TODO to track
that work.
Bug: 142935992
Test: m nothing
Change-Id: Iba9799e111ca5672b2133568163d8c49837ba9cd
diff --git a/android/sdk.go b/android/sdk.go
index 0a4d346..7f292b4 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -466,14 +466,29 @@
// Contains common properties that apply across many different member types. These
// are not affected by the optimization to extract common values.
type SdkMemberPropertiesBase struct {
- // The setting to use for the compile_multilib property.
- Compile_multilib string `sdk:"keep"`
-
// The number of unique os types supported by the member variants.
+ //
+ // If a member has a variant with more than one os type then it will need to differentiate
+ // the locations of any of their prebuilt files in the snapshot by os type to prevent them
+ // from colliding. See OsPrefix().
+ //
+ // This property is the same for all variants of a member and so would be optimized away
+ // if it was not explicitly kept.
Os_count int `sdk:"keep"`
// The os type for which these properties refer.
+ //
+ // Provided to allow a member to differentiate between os types in the locations of their
+ // prebuilt files when it supports more than one os type.
+ //
+ // This property is the same for all os type specific variants of a member and so would be
+ // optimized away if it was not explicitly kept.
Os OsType `sdk:"keep"`
+
+ // The setting to use for the compile_multilib property.
+ //
+ // This property is set after optimization so there is no point in trying to optimize it.
+ Compile_multilib string `sdk:"keep"`
}
// The os prefix to use for any file paths in the sdk.
@@ -516,4 +531,13 @@
// The builder of the snapshot.
SnapshotBuilder() SnapshotBuilder
+
+ // The type of the member.
+ MemberType() SdkMemberType
+
+ // The name of the member.
+ //
+ // Provided for use by sdk members to create a member specific location within the snapshot
+ // into which to copy the prebuilt files.
+ Name() string
}