Disable check_cfi and ArtServiceTests when built from prebuilts.

These two target depends on disabled modules, thus it is required to be disable for device to build.

Bug: 301527192
Test: m (build from prebuilts)
Change-Id: Ibfd747302deb073ab7c518f57416afec0a22311c
diff --git a/libartservice/service/Android.bp b/libartservice/service/Android.bp
index ebfe936..f5e5d6b 100644
--- a/libartservice/service/Android.bp
+++ b/libartservice/service/Android.bp
@@ -125,6 +125,11 @@
         "javatests/**/*.java",
     ],
 
+    // disable the target when prebuilt modules are used
+    defaults: [
+        "art_module_source_build_java_defaults",
+    ],
+
     static_libs: [
         "androidx.test.ext.junit",
         "androidx.test.ext.truth",
diff --git a/tools/Android.bp b/tools/Android.bp
index ef0cadf..5cc579c 100644
--- a/tools/Android.bp
+++ b/tools/Android.bp
@@ -23,6 +23,13 @@
     default_applicable_licenses: ["art_license"],
 }
 
+soong_config_module_type_import {
+    from: "art/build/SoongConfig.bp",
+    module_types: [
+        "art_module_cc_genrule",
+    ],
+}
+
 python_binary_host {
     name: "generate_operator_out",
     srcs: [
@@ -109,8 +116,16 @@
     },
 }
 
-cc_genrule {
+art_module_cc_genrule {
     name: "check_cfi",
+
+    // disable the target when prebuilt modules are used
+    enabled: false,
+    soong_config_variables: {
+        source_build: {
+            enabled: true,
+        },
+    },
     tool_files: [
         "check_cfi.py",
     ],
@@ -128,4 +143,14 @@
         "--dwarfdump $(location llvm-dwarfdump) " +
         "--objdump $(location llvm-objdump) " +
         "--out $(out) $(in)",
+
+    target: {
+        windows: {
+            // When the module is enabled globally in the soong_config_variables
+            // stanza above, it gets enabled on windows too. Hence we need to
+            // disable it explicitly.
+            // TODO(b/172480617): Clean up with that.
+            enabled: false,
+        },
+    },
 }