Add support for SOONG_SDK_SNAPSHOT_USE_SRCJAR
Test: m SOONG_SDK_SNAPSHOT_USE_SRCJAR=true ipsec-module-sdk - check generated snapshot.zip file. Change-Id: I02991e2a60d7784984b308cff2c47ee809d61f01
This commit is contained in:
@@ -2482,11 +2482,18 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo
|
|||||||
}
|
}
|
||||||
scopeSet.AddProperty("jars", jars)
|
scopeSet.AddProperty("jars", jars)
|
||||||
|
|
||||||
// Merge the stubs source jar into the snapshot zip so that when it is unpacked
|
if ctx.SdkModuleContext().Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_USE_SRCJAR") {
|
||||||
// the source files are also unpacked.
|
// Copy the stubs source jar into the snapshot zip as is.
|
||||||
snapshotRelativeDir := filepath.Join(scopeDir, ctx.Name()+"_stub_sources")
|
srcJarSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".srcjar")
|
||||||
ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir)
|
ctx.SnapshotBuilder().CopyToSnapshot(properties.StubsSrcJar, srcJarSnapshotPath)
|
||||||
scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir})
|
scopeSet.AddProperty("stub_srcs", []string{srcJarSnapshotPath})
|
||||||
|
} else {
|
||||||
|
// Merge the stubs source jar into the snapshot zip so that when it is unpacked
|
||||||
|
// the source files are also unpacked.
|
||||||
|
snapshotRelativeDir := filepath.Join(scopeDir, ctx.Name()+"_stub_sources")
|
||||||
|
ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir)
|
||||||
|
scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir})
|
||||||
|
}
|
||||||
|
|
||||||
if properties.CurrentApiFile != nil {
|
if properties.CurrentApiFile != nil {
|
||||||
currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt")
|
currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt")
|
||||||
|
@@ -1089,6 +1089,57 @@ sdk_snapshot {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) {
|
||||||
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForSdkTestWithJavaSdkLibrary,
|
||||||
|
android.FixtureMergeEnv(map[string]string{
|
||||||
|
"SOONG_SDK_SNAPSHOT_USE_SRCJAR": "true",
|
||||||
|
}),
|
||||||
|
).RunTestWithBp(t, `
|
||||||
|
sdk {
|
||||||
|
name: "mysdk",
|
||||||
|
java_sdk_libs: ["myjavalib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_sdk_library {
|
||||||
|
name: "myjavalib",
|
||||||
|
srcs: ["Test.java"],
|
||||||
|
sdk_version: "current",
|
||||||
|
shared_library: false,
|
||||||
|
public: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
CheckSnapshot(t, result, "mysdk", "",
|
||||||
|
checkUnversionedAndroidBpContents(`
|
||||||
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
|
java_sdk_library_import {
|
||||||
|
name: "myjavalib",
|
||||||
|
prefer: false,
|
||||||
|
visibility: ["//visibility:public"],
|
||||||
|
apex_available: ["//apex_available:platform"],
|
||||||
|
shared_library: false,
|
||||||
|
public: {
|
||||||
|
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||||
|
stub_srcs: ["sdk_library/public/myjavalib.srcjar"],
|
||||||
|
current_api: "sdk_library/public/myjavalib.txt",
|
||||||
|
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||||
|
sdk_version: "current",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`),
|
||||||
|
checkAllCopyRules(`
|
||||||
|
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
|
||||||
|
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar
|
||||||
|
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
|
||||||
|
.intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
|
||||||
|
`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
|
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
|
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
|
||||||
sdk {
|
sdk {
|
||||||
|
Reference in New Issue
Block a user