ART: Move cmdline parser to header library

Express the cmdline parser as a header library.

TODO: Express the libart dependency correctly.

Test: m
Change-Id: I9e90029d047ab0d75a455a2361d5213a8fa6f361
diff --git a/cmdline/Android.bp b/cmdline/Android.bp
index c811cbd..b46e987 100644
--- a/cmdline/Android.bp
+++ b/cmdline/Android.bp
@@ -14,6 +14,13 @@
 // limitations under the License.
 //
 
+// TODO: this header library depends on libart. Find a way to express that.
+cc_library_headers {
+    name: "art_cmdlineparser_headers",
+    host_supported: true,
+    export_include_dirs: ["."],
+}
+
 art_cc_test {
     name: "art_cmdline_tests",
     defaults: [
diff --git a/cmdline/cmdline_parser.h b/cmdline/cmdline_parser.h
index 804727b..fef39ad 100644
--- a/cmdline/cmdline_parser.h
+++ b/cmdline/cmdline_parser.h
@@ -19,9 +19,9 @@
 
 #define CMDLINE_NDEBUG 1  // Do not output any debugging information for parsing.
 
-#include "cmdline/detail/cmdline_debug_detail.h"
-#include "cmdline/detail/cmdline_parse_argument_detail.h"
-#include "cmdline/detail/cmdline_parser_detail.h"
+#include "detail/cmdline_debug_detail.h"
+#include "detail/cmdline_parse_argument_detail.h"
+#include "detail/cmdline_parser_detail.h"
 
 #include "cmdline_parse_result.h"
 #include "cmdline_result.h"
@@ -29,7 +29,7 @@
 #include "cmdline_types.h"
 #include "token_range.h"
 
-#include "runtime/base/variant_map.h"
+#include "base/variant_map.h"
 
 #include <memory>
 #include <vector>
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index 0d453ef..f13f01c 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -33,11 +33,10 @@
         },
     },
 
-
-    include_dirs: [
-        "art/cmdline",
+    header_libs: [
+        "dex2oat_headers",
+        "art_cmdlineparser_headers",
     ],
-    header_libs: ["dex2oat_headers"],
 }
 
 art_cc_binary {
diff --git a/dexoptanalyzer/Android.bp b/dexoptanalyzer/Android.bp
index da6663d..715c209 100644
--- a/dexoptanalyzer/Android.bp
+++ b/dexoptanalyzer/Android.bp
@@ -28,10 +28,6 @@
         },
     },
 
-    include_dirs: [
-        "art/cmdline",
-    ],
-
     shared_libs: [
         "libbase",
     ],
diff --git a/imgdiag/Android.bp b/imgdiag/Android.bp
index 9459bb5..2b89497 100644
--- a/imgdiag/Android.bp
+++ b/imgdiag/Android.bp
@@ -38,8 +38,8 @@
             shared_libs: ["libziparchive"],
         },
     },
-    include_dirs: [
-        "art/cmdline",
+    header_libs: [
+        "art_cmdlineparser_headers",
     ],
     multilib: {
         lib32: {
diff --git a/oatdump/Android.bp b/oatdump/Android.bp
index 1cd97c2..4851722 100644
--- a/oatdump/Android.bp
+++ b/oatdump/Android.bp
@@ -24,7 +24,9 @@
             shared_libs: ["libcutils"],
         },
     },
-    include_dirs: ["art/cmdline"],
+    header_libs: [
+        "art_cmdlineparser_headers",
+    ],
 }
 
 art_cc_binary {
diff --git a/profman/Android.bp b/profman/Android.bp
index 2a45c46..ea682b4 100644
--- a/profman/Android.bp
+++ b/profman/Android.bp
@@ -30,10 +30,6 @@
         },
     },
 
-    include_dirs: [
-        "art/cmdline",
-    ],
-
     shared_libs: [
         "libbase",
     ],
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 0f5a1a8..71b803d 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -400,10 +400,12 @@
     export_generated_headers: ["cpp-define-generator-asm-support"],
     clang: true,
     include_dirs: [
-        "art/cmdline",
         "art/sigchainlib",
         "art",
     ],
+    header_libs: [
+        "art_cmdlineparser_headers",
+    ],
     shared_libs: [
         "libnativehelper",
         "libnativebridge",
@@ -424,6 +426,8 @@
     },
     export_include_dirs: ["."],
     // ART's macros.h depends on libbase's macros.h.
+    // Note: runtime_options.h depends on cmdline. But we don't really want to export this
+    //       generically. dex2oat takes care of it itself.
     export_shared_lib_headers: ["libbase"],
 }
 
@@ -609,6 +613,9 @@
     shared_libs: [
         "libbacktrace",
     ],
+    header_libs: [
+        "art_cmdlineparser_headers",  // For parsed_options_test.
+    ],
 }
 
 art_cc_test {
diff --git a/test/Android.bp b/test/Android.bp
index fcb8788..26b9b84 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -73,7 +73,6 @@
     ],
     include_dirs: [
         "art",
-        "art/cmdline",
     ],
 
     target: {