Allow sdk members to vary by os type
Adds support for specifying separate members to an sdk/module_exports for different os types, e.g. separate ones for android and host. Adds 'android:"arch_variant"' tag to the dynamically generated fields for the sdk member types. Merges the exported members from all variants together. Determines the device/host_supported flags of the member snapshots by whether the OsClasses used by their variants rather than the sdk's host/device supported properties as they may be different. Bug: 150451422 Test: m nothing Change-Id: I41fbbcd8723aafd54826aad9b78eced9f66ef51c
This commit is contained in:
@@ -816,3 +816,126 @@ sdk_snapshot {
|
||||
checkAllCopyRules(".intermediates/system-module/linux_glibc_common/javac/system-module.jar -> java/system-module.jar"),
|
||||
)
|
||||
}
|
||||
|
||||
func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
|
||||
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
|
||||
SkipIfNotLinux(t)
|
||||
|
||||
result := testSdkWithJava(t, `
|
||||
module_exports {
|
||||
name: "myexports",
|
||||
host_supported: true,
|
||||
java_libs: ["myjavalib"],
|
||||
target: {
|
||||
android: {
|
||||
java_header_libs: ["androidjavalib"],
|
||||
},
|
||||
host: {
|
||||
java_header_libs: ["hostjavalib"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "myjavalib",
|
||||
host_supported: true,
|
||||
srcs: ["Test.java"],
|
||||
system_modules: "none",
|
||||
sdk_version: "none",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "androidjavalib",
|
||||
srcs: ["Test.java"],
|
||||
system_modules: "none",
|
||||
sdk_version: "none",
|
||||
}
|
||||
|
||||
java_library_host {
|
||||
name: "hostjavalib",
|
||||
srcs: ["Test.java"],
|
||||
}
|
||||
`)
|
||||
|
||||
result.CheckSnapshot("myexports", "",
|
||||
checkAndroidBpContents(`
|
||||
// This is auto-generated. DO NOT EDIT.
|
||||
|
||||
java_import {
|
||||
name: "myexports_hostjavalib@current",
|
||||
sdk_member_name: "hostjavalib",
|
||||
device_supported: false,
|
||||
host_supported: true,
|
||||
jars: ["java/hostjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "hostjavalib",
|
||||
prefer: false,
|
||||
device_supported: false,
|
||||
host_supported: true,
|
||||
jars: ["java/hostjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "myexports_androidjavalib@current",
|
||||
sdk_member_name: "androidjavalib",
|
||||
jars: ["java/androidjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "androidjavalib",
|
||||
prefer: false,
|
||||
jars: ["java/androidjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "myexports_myjavalib@current",
|
||||
sdk_member_name: "myjavalib",
|
||||
host_supported: true,
|
||||
target: {
|
||||
android: {
|
||||
jars: ["java/android/myjavalib.jar"],
|
||||
},
|
||||
linux_glibc: {
|
||||
jars: ["java/linux_glibc/myjavalib.jar"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
host_supported: true,
|
||||
target: {
|
||||
android: {
|
||||
jars: ["java/android/myjavalib.jar"],
|
||||
},
|
||||
linux_glibc: {
|
||||
jars: ["java/linux_glibc/myjavalib.jar"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
module_exports_snapshot {
|
||||
name: "myexports@current",
|
||||
host_supported: true,
|
||||
target: {
|
||||
android: {
|
||||
java_header_libs: ["myexports_androidjavalib@current"],
|
||||
},
|
||||
linux_glibc: {
|
||||
java_header_libs: ["myexports_hostjavalib@current"],
|
||||
},
|
||||
},
|
||||
java_libs: ["myexports_myjavalib@current"],
|
||||
}
|
||||
`),
|
||||
checkAllCopyRules(`
|
||||
.intermediates/hostjavalib/linux_glibc_common/javac/hostjavalib.jar -> java/hostjavalib.jar
|
||||
.intermediates/androidjavalib/android_common/turbine-combined/androidjavalib.jar -> java/androidjavalib.jar
|
||||
.intermediates/myjavalib/android_common/javac/myjavalib.jar -> java/android/myjavalib.jar
|
||||
.intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/linux_glibc/myjavalib.jar
|
||||
`),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user