Add a rule about platform_apis
As sdk_check.mk checks, soong starts to check every app.
If sdk_version is empty, platform_apis must be true.
If sdk_version is not empty, platform_apis must be false.
Test: soong test
Test: m
Bug: 132780927
Change-Id: I7ba702d616404d155f8ac40cd008828663ad1488
diff --git a/java/java.go b/java/java.go
index 5f4a090..ecafa1e 100644
--- a/java/java.go
+++ b/java/java.go
@@ -52,6 +52,20 @@
android.RegisterSingletonType("logtags", LogtagsSingleton)
}
+func (j *Module) checkPlatformAPI(ctx android.ModuleContext) {
+ if sc, ok := ctx.Module().(sdkContext); ok {
+ usePlatformAPI := proptools.Bool(j.deviceProperties.Platform_apis)
+ if usePlatformAPI != (sc.sdkVersion() == "") {
+ if usePlatformAPI {
+ ctx.PropertyErrorf("platform_apis", "platform_apis must be false when sdk_version is not empty.")
+ } else {
+ ctx.PropertyErrorf("platform_apis", "platform_apis must be true when sdk_version is empty.")
+ }
+ }
+
+ }
+}
+
// TODO:
// Autogenerated files:
// Renderscript
@@ -178,8 +192,8 @@
// list of module-specific flags that will be used for dex compiles
Dxflags []string `android:"arch_variant"`
- // if not blank, set to the version of the sdk to compile against. Defaults to compiling against the current
- // sdk if platform_apis is not set.
+ // if not blank, set to the version of the sdk to compile against.
+ // Defaults to compiling against the current platform.
Sdk_version *string
// if not blank, set the minimum version of the sdk that the compiled artifacts will run against.
@@ -190,7 +204,8 @@
// Defaults to sdk_version if not set.
Target_sdk_version *string
- // if true, compile against the platform APIs instead of an SDK.
+ // It must be true only if sdk_version is empty.
+ // This field works in only android_app, otherwise nothing happens.
Platform_apis *bool
Aidl struct {