Merge "Add support for SOONG_SDK_SNAPSHOT_USE_SRCJAR" am: 820397deb2
am: 66f9ac0d33
am: c0de64161c
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1706107 Change-Id: I69d8f0ed2459d8722c620d3a9984363318fd5ec2
This commit is contained in:
commit
648d0fab59
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue