ART: Move simulator to art/

Move the simulator library out of the runtime directory. Let's not
pollute the runtime library.

Test: m
Change-Id: I351a0061ae628c3af0462b72d4de727db296ec23
diff --git a/Android.bp b/Android.bp
index d0e22fb..0ce86d8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -35,6 +35,7 @@
     "profman",
     "runtime",
     "sigchainlib",
+    "simulator",
     "test",
     "tools/cpp-define-generator",
     "tools/dmtracedump",
diff --git a/compiler/Android.bp b/compiler/Android.bp
index b721d21..f11d256 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -423,8 +423,11 @@
         },
     },
 
+    header_libs: ["libart_simulator_headers"],
+
     shared_libs: [
         "libartd-compiler",
+        "libartd-simulator-container",
         "libvixld-arm",
         "libvixld-arm64",
 
diff --git a/compiler/optimizing/codegen_test_utils.h b/compiler/optimizing/codegen_test_utils.h
index 1b38acd..cada2e6 100644
--- a/compiler/optimizing/codegen_test_utils.h
+++ b/compiler/optimizing/codegen_test_utils.h
@@ -28,6 +28,7 @@
 #include "arch/x86/instruction_set_features_x86.h"
 #include "arch/x86/registers_x86.h"
 #include "arch/x86_64/instruction_set_features_x86_64.h"
+#include "code_simulator.h"
 #include "code_simulator_container.h"
 #include "common_compiler_test.h"
 #include "graph_checker.h"
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 8d15c34..18a4c8c 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -50,7 +50,6 @@
         "class_linker.cc",
         "class_loader_context.cc",
         "class_table.cc",
-        "code_simulator_container.cc",
         "common_throws.cc",
         "compiler_filter.cc",
         "debugger.cc",
@@ -629,5 +628,4 @@
 subdirs = [
     "openjdkjvm",
     "openjdkjvmti",
-    "simulator",
 ]
diff --git a/runtime/simulator/Android.bp b/simulator/Android.bp
similarity index 60%
rename from runtime/simulator/Android.bp
rename to simulator/Android.bp
index 03e3f15..a399289 100644
--- a/runtime/simulator/Android.bp
+++ b/simulator/Android.bp
@@ -14,6 +14,12 @@
 // limitations under the License.
 //
 
+cc_library_headers {
+    name: "libart_simulator_headers",
+    host_supported: true,
+    export_include_dirs: ["include"],
+}
+
 cc_defaults {
     name: "libart_simulator_defaults",
     host_supported: true,
@@ -29,8 +35,8 @@
         "liblog",
     ],
     cflags: ["-DVIXL_INCLUDE_SIMULATOR_AARCH64"],
-    export_include_dirs: ["."],
-    include_dirs: ["art/runtime"],
+
+    header_libs: ["libart_simulator_headers"],
 }
 
 art_cc_library {
@@ -53,3 +59,38 @@
         "libvixld-arm64",
     ],
 }
+
+cc_defaults {
+    name: "libart_simulator_container_defaults",
+    host_supported: true,
+
+    defaults: ["art_defaults"],
+    srcs: [
+        "code_simulator_container.cc",
+    ],
+    shared_libs: [
+        "libbase",
+    ],
+
+    header_libs: ["libart_simulator_headers"],
+    export_include_dirs: ["."],  // TODO: Consider a proper separation.
+}
+
+art_cc_library {
+    name: "libart-simulator-container",
+    defaults: ["libart_simulator_container_defaults"],
+    shared_libs: [
+        "libart",
+    ],
+}
+
+art_cc_library {
+    name: "libartd-simulator-container",
+    defaults: [
+        "art_debug_defaults",
+        "libart_simulator_container_defaults",
+    ],
+    shared_libs: [
+        "libartd",
+    ],
+}
diff --git a/runtime/simulator/code_simulator.cc b/simulator/code_simulator.cc
similarity index 92%
rename from runtime/simulator/code_simulator.cc
rename to simulator/code_simulator.cc
index 1a11160..e653dfc 100644
--- a/runtime/simulator/code_simulator.cc
+++ b/simulator/code_simulator.cc
@@ -14,8 +14,9 @@
  * limitations under the License.
  */
 
-#include "simulator/code_simulator.h"
-#include "simulator/code_simulator_arm64.h"
+#include "code_simulator.h"
+
+#include "code_simulator_arm64.h"
 
 namespace art {
 
diff --git a/runtime/simulator/code_simulator_arm64.cc b/simulator/code_simulator_arm64.cc
similarity index 97%
rename from runtime/simulator/code_simulator_arm64.cc
rename to simulator/code_simulator_arm64.cc
index c7ad1fd..939d2e2 100644
--- a/runtime/simulator/code_simulator_arm64.cc
+++ b/simulator/code_simulator_arm64.cc
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "simulator/code_simulator_arm64.h"
+#include "code_simulator_arm64.h"
 
 #include "base/logging.h"
 
diff --git a/runtime/simulator/code_simulator_arm64.h b/simulator/code_simulator_arm64.h
similarity index 88%
rename from runtime/simulator/code_simulator_arm64.h
rename to simulator/code_simulator_arm64.h
index 59ea34f..0542593 100644
--- a/runtime/simulator/code_simulator_arm64.h
+++ b/simulator/code_simulator_arm64.h
@@ -14,11 +14,10 @@
  * limitations under the License.
  */
 
-#ifndef ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_ARM64_H_
-#define ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_ARM64_H_
+#ifndef ART_SIMULATOR_CODE_SIMULATOR_ARM64_H_
+#define ART_SIMULATOR_CODE_SIMULATOR_ARM64_H_
 
 #include "memory"
-#include "simulator/code_simulator.h"
 
 // TODO(VIXL): Make VIXL compile with -Wshadow.
 #pragma GCC diagnostic push
@@ -26,6 +25,8 @@
 #include "aarch64/simulator-aarch64.h"
 #pragma GCC diagnostic pop
 
+#include "code_simulator.h"
+
 namespace art {
 namespace arm64 {
 
@@ -55,4 +56,4 @@
 }  // namespace arm64
 }  // namespace art
 
-#endif  // ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_ARM64_H_
+#endif  // ART_SIMULATOR_CODE_SIMULATOR_ARM64_H_
diff --git a/runtime/code_simulator_container.cc b/simulator/code_simulator_container.cc
similarity index 98%
rename from runtime/code_simulator_container.cc
rename to simulator/code_simulator_container.cc
index d884c58..a5f05dc 100644
--- a/runtime/code_simulator_container.cc
+++ b/simulator/code_simulator_container.cc
@@ -17,6 +17,8 @@
 #include <dlfcn.h>
 
 #include "code_simulator_container.h"
+
+#include "code_simulator.h"
 #include "globals.h"
 
 namespace art {
diff --git a/runtime/code_simulator_container.h b/simulator/code_simulator_container.h
similarity index 87%
rename from runtime/code_simulator_container.h
rename to simulator/code_simulator_container.h
index 10178ba..31a915e 100644
--- a/runtime/code_simulator_container.h
+++ b/simulator/code_simulator_container.h
@@ -14,15 +14,16 @@
  * limitations under the License.
  */
 
-#ifndef ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_
-#define ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_
+#ifndef ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
+#define ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
 
 #include "arch/instruction_set.h"
 #include "base/logging.h"
-#include "simulator/code_simulator.h"
 
 namespace art {
 
+class CodeSimulator;
+
 // This container dynamically opens and closes libart-simulator.
 class CodeSimulatorContainer {
  public:
@@ -52,4 +53,4 @@
 
 }  // namespace art
 
-#endif  // ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_
+#endif  // ART_SIMULATOR_CODE_SIMULATOR_CONTAINER_H_
diff --git a/runtime/simulator/code_simulator.h b/simulator/include/code_simulator.h
similarity index 89%
rename from runtime/simulator/code_simulator.h
rename to simulator/include/code_simulator.h
index bd48909..256ab23 100644
--- a/runtime/simulator/code_simulator.h
+++ b/simulator/include/code_simulator.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_H_
-#define ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_H_
+#ifndef ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_
+#define ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_
 
 #include "arch/instruction_set.h"
 
@@ -43,4 +43,4 @@
 
 }  // namespace art
 
-#endif  // ART_RUNTIME_SIMULATOR_CODE_SIMULATOR_H_
+#endif  // ART_SIMULATOR_INCLUDE_CODE_SIMULATOR_H_