Add min_sdk_version to Rust modules.
Add the min_sdk_version property to Rust modules so they can declare a minimum SDK version they support for use with APEX modules. Test: New Soong test passes. Bug: 174862583 Change-Id: I2829053a320f50c218783dee5adbeff9cef81e8e
This commit is contained in:
parent
110d13bef3
commit
3e9f9e47cf
|
@ -1782,6 +1782,31 @@ func TestApexMinSdkVersion_ErrorIfIncompatibleVersion(t *testing.T) {
|
||||||
min_sdk_version: "30",
|
min_sdk_version: "30",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
testApexError(t, `module "libfoo.ffi".*: should support min_sdk_version\(29\)`, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["libfoo.ffi"],
|
||||||
|
min_sdk_version: "29",
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
rust_ffi_shared {
|
||||||
|
name: "libfoo.ffi",
|
||||||
|
srcs: ["foo.rs"],
|
||||||
|
crate_name: "foo",
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
min_sdk_version: "30",
|
||||||
|
}
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexMinSdkVersion_Okay(t *testing.T) {
|
func TestApexMinSdkVersion_Okay(t *testing.T) {
|
||||||
|
|
|
@ -334,7 +334,7 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
||||||
},
|
},
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
"//apex_available:platform",
|
||||||
"myapex"
|
"//apex_available:anyapex",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
cc_library {
|
cc_library {
|
||||||
|
|
25
rust/rust.go
25
rust/rust.go
|
@ -67,6 +67,9 @@ type BaseProperties struct {
|
||||||
|
|
||||||
SubName string `blueprint:"mutated"`
|
SubName string `blueprint:"mutated"`
|
||||||
|
|
||||||
|
// Minimum sdk version that the artifact should support when it runs as part of mainline modules(APEX).
|
||||||
|
Min_sdk_version *string
|
||||||
|
|
||||||
PreventInstall bool
|
PreventInstall bool
|
||||||
HideFromMake bool
|
HideFromMake bool
|
||||||
}
|
}
|
||||||
|
@ -1076,7 +1079,29 @@ func (mod *Module) HostToolPath() android.OptionalPath {
|
||||||
|
|
||||||
var _ android.ApexModule = (*Module)(nil)
|
var _ android.ApexModule = (*Module)(nil)
|
||||||
|
|
||||||
|
func (mod *Module) minSdkVersion() string {
|
||||||
|
return String(mod.Properties.Min_sdk_version)
|
||||||
|
}
|
||||||
|
|
||||||
func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
func (mod *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error {
|
||||||
|
minSdkVersion := mod.minSdkVersion()
|
||||||
|
if minSdkVersion == "apex_inherit" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if minSdkVersion == "" {
|
||||||
|
return fmt.Errorf("min_sdk_version is not specificed")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not using nativeApiLevelFromUser because the context here is not
|
||||||
|
// necessarily a native context.
|
||||||
|
ver, err := android.ApiLevelFromUser(ctx, minSdkVersion)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ver.GreaterThan(sdkVersion) {
|
||||||
|
return fmt.Errorf("newer SDK(%v)", ver)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ func GatherRequiredDepsForTest() string {
|
||||||
nocrt: true,
|
nocrt: true,
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
||||||
|
min_sdk_version: "29",
|
||||||
}
|
}
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "libprotobuf-cpp-full",
|
name: "libprotobuf-cpp-full",
|
||||||
|
@ -95,6 +96,7 @@ func GatherRequiredDepsForTest() string {
|
||||||
native_coverage: false,
|
native_coverage: false,
|
||||||
sysroot: true,
|
sysroot: true,
|
||||||
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
||||||
|
min_sdk_version: "29",
|
||||||
}
|
}
|
||||||
rust_library {
|
rust_library {
|
||||||
name: "libtest",
|
name: "libtest",
|
||||||
|
@ -105,6 +107,7 @@ func GatherRequiredDepsForTest() string {
|
||||||
native_coverage: false,
|
native_coverage: false,
|
||||||
sysroot: true,
|
sysroot: true,
|
||||||
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
apex_available: ["//apex_available:platform", "//apex_available:anyapex"],
|
||||||
|
min_sdk_version: "29",
|
||||||
}
|
}
|
||||||
rust_library {
|
rust_library {
|
||||||
name: "libprotobuf",
|
name: "libprotobuf",
|
||||||
|
|
Loading…
Reference in New Issue