summaryrefslogtreecommitdiff
path: root/android/neverallow.go
diff options
context:
space:
mode:
author Luca Stefani <luca.stefani.ge1@gmail.com> 2024-10-12 17:55:31 +0200
committer Luca Stefani <luca.stefani.ge1@gmail.com> 2024-10-17 21:01:28 +0200
commit50098f775360a2b49ac981685dffb45366722b97 (patch)
treee9d86852f738baae570b1bdfbdcfa7b4c917b354 /android/neverallow.go
parent991d11df34cc11d0dd71c8e4334fc3fc9e28e054 (diff)
Add support for kotlin plugins
Use the already existing hooks used by the compose compiler plugin to support kotlin plugins bundled alongside the compiler such as kotlin-serialize-compiler Test: m, sample app with kotlin-serialize-compiler Change-Id: I4d5fa6cd42acfc90ef437222e9e07f61c259d565
Diffstat (limited to 'android/neverallow.go')
-rw-r--r--android/neverallow.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/android/neverallow.go b/android/neverallow.go
index 439fe2df8..57373d5b9 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -62,6 +62,7 @@ func init() {
AddNeverAllowRules(createLimitNdkExportRule()...)
AddNeverAllowRules(createLimitDirgroupRule()...)
AddNeverAllowRules(createFilesystemIsAutoGeneratedRule())
+ AddNeverAllowRules(createKotlinPluginRule()...)
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -302,6 +303,22 @@ func createFilesystemIsAutoGeneratedRule() Rule {
Because("is_auto_generated property is only allowed for filesystem modules in build/soong/fsgen directory")
}
+func createKotlinPluginRule() []Rule {
+ kotlinPluginProjectsAllowedList := []string{
+ // TODO: Migrate compose plugin to the bundled compiler plugin
+ // Actual path prebuilts/sdk/current/androidx/m2repository/androidx/compose/compiler/compiler-hosted
+ "prebuilts/sdk/current/androidx",
+ "external/kotlinc",
+ }
+
+ return []Rule{
+ NeverAllow().
+ NotIn(kotlinPluginProjectsAllowedList...).
+ ModuleType("kotlin_plugin").
+ Because("kotlin_plugin can only be used in allowed projects"),
+ }
+}
+
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {