ios: Extract common targets to be shared for iOS.

Move some common files out of client and handler for iOS usage.

Bug: crashpad: 31
Change-Id: Ic8acfa5ba5b3cd43b4ce3dc6e4bbdd4c7bf64ca8
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2851059
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Justin Cohen <justincohen@chromium.org>
GitOrigin-RevId: b10f07e52e56cc7463fbdd57940607ecb8118e8e
diff --git a/client/BUILD.gn b/client/BUILD.gn
index e26b965..a53ac46 100644
--- a/client/BUILD.gn
+++ b/client/BUILD.gn
@@ -16,27 +16,14 @@
 
 crashpad_static_library("client") {
   sources = [
-    "annotation.cc",
-    "annotation.h",
-    "annotation_list.cc",
-    "annotation_list.h",
-    "crash_report_database.cc",
-    "crash_report_database.h",
     "crashpad_client.h",
-    "crashpad_info.cc",
-    "crashpad_info.h",
     "prune_crash_reports.cc",
     "prune_crash_reports.h",
-    "settings.cc",
-    "settings.h",
-    "simple_address_range_bag.h",
-    "simple_string_dictionary.h",
     "simulate_crash.h",
   ]
 
   if (crashpad_is_mac) {
     sources += [
-      "crash_report_database_mac.mm",
       "crashpad_client_mac.cc",
       "simulate_crash_mac.cc",
       "simulate_crash_mac.h",
@@ -45,7 +32,6 @@
 
   if (crashpad_is_ios) {
     sources += [
-      "crash_report_database_mac.mm",
       "crashpad_client_ios.cc",
       "simulate_crash_ios.h",
     ]
@@ -62,13 +48,11 @@
     sources += [
       "client_argv_handling.cc",
       "client_argv_handling.h",
-      "crashpad_info_note.S",
     ]
   }
 
   if (crashpad_is_win) {
     sources += [
-      "crash_report_database_win.cc",
       "crashpad_client_win.cc",
       "simulate_crash_win.h",
     ]
@@ -78,18 +62,18 @@
     sources += [ "crashpad_client_fuchsia.cc" ]
   }
 
-  if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) {
-    sources += [ "crash_report_database_generic.cc" ]
-  }
-
   public_configs = [ "..:crashpad_config" ]
 
   public_deps = [
+    ":common",
     "../third_party/mini_chromium:base",
     "../util",
   ]
 
-  deps = [ "../third_party/mini_chromium:chromeos_buildflags" ]
+  deps = [
+    ":common",
+    "../third_party/mini_chromium:chromeos_buildflags",
+  ]
 
   if (crashpad_is_win) {
     libs = [ "rpcrt4.lib" ]
@@ -99,6 +83,7 @@
   # TODO(justincohen): Temporary dependency to bring up the iOS client.
   if (crashpad_is_ios) {
     deps += [
+      "../handler:common",
       "../minidump",
       "../snapshot",
     ]
@@ -116,6 +101,43 @@
   }
 }
 
+static_library("common") {
+  sources = [
+    "annotation.cc",
+    "annotation.h",
+    "annotation_list.cc",
+    "annotation_list.h",
+    "crash_report_database.cc",
+    "crash_report_database.h",
+    "crashpad_info.cc",
+    "crashpad_info.h",
+    "settings.cc",
+    "settings.h",
+    "simple_address_range_bag.h",
+    "simple_string_dictionary.h",
+  ]
+
+  if (crashpad_is_mac || crashpad_is_ios) {
+    sources += [ "crash_report_database_mac.mm" ]
+  }
+  if (crashpad_is_win) {
+    sources += [ "crash_report_database_win.cc" ]
+  }
+  if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) {
+    sources += [
+      "crash_report_database_generic.cc",
+      "crashpad_info_note.S",
+    ]
+  }
+
+  public_configs = [ "..:crashpad_config" ]
+  public_deps = [
+    "../third_party/mini_chromium:base",
+    "../util",
+  ]
+  deps = [ "../util" ]
+}
+
 source_set("client_test") {
   testonly = true
 
diff --git a/handler/BUILD.gn b/handler/BUILD.gn
index 1d5951e..a697b33 100644
--- a/handler/BUILD.gn
+++ b/handler/BUILD.gn
@@ -16,12 +16,8 @@
 
 static_library("handler") {
   sources = [
-    "crash_report_upload_thread.cc",
-    "crash_report_upload_thread.h",
     "handler_main.cc",
     "handler_main.h",
-    "minidump_to_upload_parameters.cc",
-    "minidump_to_upload_parameters.h",
     "prune_crash_reports_thread.cc",
     "prune_crash_reports_thread.h",
     "user_stream_data_source.cc",
@@ -34,8 +30,6 @@
       "mac/crash_report_exception_handler.h",
       "mac/exception_handler_server.cc",
       "mac/exception_handler_server.h",
-      "mac/file_limit_annotation.cc",
-      "mac/file_limit_annotation.h",
     ]
   }
 
@@ -67,12 +61,14 @@
   public_configs = [ "..:crashpad_config" ]
 
   public_deps = [
+    ":common",
     "../client",
     "../third_party/mini_chromium:base",
     "../util",
   ]
 
   deps = [
+    ":common",
     "../minidump",
     "../snapshot",
     "../third_party/mini_chromium:chromeos_buildflags",
@@ -94,6 +90,34 @@
   }
 }
 
+static_library("common") {
+  sources = [
+    "crash_report_upload_thread.cc",
+    "crash_report_upload_thread.h",
+    "minidump_to_upload_parameters.cc",
+    "minidump_to_upload_parameters.h",
+  ]
+  if (crashpad_is_mac || crashpad_is_ios) {
+    sources += [
+      "mac/file_limit_annotation.cc",
+      "mac/file_limit_annotation.h",
+    ]
+  }
+  public_configs = [ "..:crashpad_config" ]
+  public_deps = [
+    "../third_party/mini_chromium:base",
+    "../util",
+  ]
+  deps = [
+    "../client:common",
+    "../snapshot",
+    "../util",
+  ]
+  if (crashpad_is_win) {
+    cflags = [ "/wd4201" ]  # nonstandard extension used : nameless struct/union
+  }
+}
+
 source_set("handler_test") {
   testonly = true
 
diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn
index e387e3c..b9ee959 100644
--- a/snapshot/BUILD.gn
+++ b/snapshot/BUILD.gn
@@ -242,18 +242,15 @@
   public_deps = [ ":context" ]
 
   deps = [
-    "../client",
+    "../client:common",
     "../compat",
     "../minidump:format",
     "../third_party/mini_chromium:base",
     "../util",
   ]
 
-  if (crashpad_is_ios) {
-    deps -= [ "../client" ]
-  }
-
   if (crashpad_is_win) {
+    deps += [ "../client" ]
     cflags = [ "/wd4201" ]  # nonstandard extension used : nameless struct/union
     libs = [ "powrprof.lib" ]
   }
@@ -423,7 +420,7 @@
 
   deps = [
     ":test_support",
-    "../client",
+    "../client:common",
     "../compat",
     "../minidump:format",
     "../test",
@@ -432,6 +429,10 @@
     "../util",
   ]
 
+  if (crashpad_is_win) {
+    deps += [ "../client" ]
+  }
+
   data_deps = [
     ":crashpad_snapshot_test_module",
     ":crashpad_snapshot_test_module_large",