igt-gpu-tools: Extract common code into a library

igt-gpu-tools is basically a library for making tests.  To simplify
writing individual tests, extracted all the common code into a static
library and allowed tests to reuse a common set of defaults.

Bug: 142890405
Test: built gem_blt successfully
Change-Id: Ia435530ae02d782d70a574276ad9e4d426decde2
diff --git a/Android.bp b/Android.bp
index 3cbbf14..4b03563 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,17 +1,5 @@
-cc_test {
-    name: "gem_blt",
-    srcs: [
-        "benchmarks/gem_blt.c",
-        "lib/drmtest.c",
-        "lib/igt_aux.c",
-        "lib/igt_core.c",
-        "lib/igt_debugfs.c",
-        "lib/igt_dummyload.c",
-        "lib/igt_kmod.c",
-        "lib/igt_sysfs.c",
-        "lib/ioctl_wrappers.c",
-        "lib/i915/gem_mman.c",
-    ],
+cc_defaults {
+    name: "igt-gpu-tools-defaults",
     cflags: [
         "-Wall",
         "-Werror",
@@ -22,12 +10,39 @@
         "-DHAVE_LIBGEN_H",
         "-DHAVE_MEMFD_CREATE",
     ],
-    local_include_dirs: [
+    static_libs: ["libelf", "libkmod"],
+    shared_libs: ["libdrm", "libunwind"],
+}
+
+cc_library_static {
+    name: "igt-gpu-tools",
+    defaults: ["igt-gpu-tools-defaults"],
+    srcs: [
+        "lib/drmtest.c",
+        "lib/igt_aux.c",
+        "lib/igt_core.c",
+        "lib/igt_debugfs.c",
+        "lib/igt_dummyload.c",
+        "lib/igt_kmod.c",
+        "lib/igt_sysfs.c",
+        "lib/ioctl_wrappers.c",
+        "lib/i915/gem_mman.c",
+    ],
+    export_include_dirs: [
         "lib",
         "lib/stubs/drm",
         "prebuilt-intermediates",
     ],
-    static_libs: ["libelf", "libkmod"],
-    shared_libs: ["libdrm", "libunwind"],
-    stl: "none",
+}
+
+cc_defaults {
+    name: "igt-gpu-tools-test-defaults",
+    defaults: ["igt-gpu-tools-defaults"],
+    static_libs: ["igt-gpu-tools"],
+}
+
+cc_test {
+    name: "gem_blt",
+    defaults: ["igt-gpu-tools-test-defaults"],
+    srcs: ["benchmarks/gem_blt.c"],
 }