Obtain the Fuchsia SDK from the correct (updated) location

Since a mac-amd64 SDK is now published in addition to linux-amd64, use
it on macOS instead of repurposing linux-amd64.

Many thanks to Scott Graham <scottmg@chromium.org> for helping out at
https://chromium-review.googlesource.com/c/1506419.

Bug: crashpad:279
Change-Id: I4f108222ec2e75dea93fe32053ab470ac7ce48b9
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1503688
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
diff --git a/DEPS b/DEPS
index 5b07de5..b66addd 100644
--- a/DEPS
+++ b/DEPS
@@ -89,22 +89,24 @@
     'condition': 'checkout_fuchsia and host_os == "linux"',
     'dep_type': 'cipd'
   },
-  'crashpad/third_party/fuchsia/sdk/linux-amd64': {
-    # The SDK is keyed to the host system because it contains build tools.
-    # Currently, linux-amd64 is the only SDK published (see
-    # https://chrome-infra-packages.appspot.com/#/?path=fuchsia/sdk).
-    # As long as this is the case, use that SDK package
-    # even on other build hosts.
-    # The sysroot (containing headers and libraries) and other components are
-    # related to the target and should be functional with an appropriate
-    # toolchain that runs on the build host (fuchsia_clang, above).
+  'crashpad/third_party/fuchsia/sdk/mac-amd64': {
     'packages': [
       {
-        'package': 'fuchsia/sdk/linux-amd64',
+        'package': 'fuchsia/sdk/core/mac-amd64',
         'version': 'latest'
       },
     ],
-    'condition': 'checkout_fuchsia',
+    'condition': 'checkout_fuchsia and host_os == "mac"',
+    'dep_type': 'cipd'
+  },
+  'crashpad/third_party/fuchsia/sdk/linux-amd64': {
+    'packages': [
+      {
+        'package': 'fuchsia/sdk/core/linux-amd64',
+        'version': 'latest'
+      },
+    ],
+    'condition': 'checkout_fuchsia and host_os == "linux"',
     'dep_type': 'cipd'
   },
   'crashpad/third_party/win/toolchain': {
diff --git a/third_party/fuchsia/BUILD.gn b/third_party/fuchsia/BUILD.gn
index 1e6d94d..6965dfe 100644
--- a/third_party/fuchsia/BUILD.gn
+++ b/third_party/fuchsia/BUILD.gn
@@ -26,12 +26,12 @@
   group("zx") {
     public_deps = [
       "//third_party/fuchsia-sdk/sdk:fdio",
-      "//third_party/fuchsia-sdk/sdk:zx",
       "//third_party/fuchsia-sdk/sdk:sysinfo",
+      "//third_party/fuchsia-sdk/sdk:zx",
     ]
   }
 } else {
-  sdk_path = "sdk/linux-amd64"
+  sdk_path = "sdk/$host_os-amd64"
   sdk_pkg_path = "$sdk_path/pkg"
   sdk_fidl_path = "$sdk_path/fidl"
 
@@ -40,6 +40,7 @@
     include_dirs = [
       "$root_gen_dir/fidl/include",
       "$sdk_pkg_path/fidl/include",
+      "$sdk_pkg_path/fidl_base/include",
       "$sdk_pkg_path/zx/include",
     ]
   }
@@ -70,17 +71,20 @@
       script = "runner.py"
 
       args = [
-        rebase_path("$sdk_path/tools/fidlc", root_build_dir),
-        "--c-header",
-        rebase_path(c_header, root_build_dir),
-        "--c-client",
-        rebase_path(c_client, root_build_dir),
-        "--tables",
-        rebase_path(coding_tables, root_build_dir),
-        "--files",
-      ] + [ rebase_path(fidl_source.fidl, root_build_dir) ]
+               rebase_path("$sdk_path/tools/fidlc", root_build_dir),
+               "--c-header",
+               rebase_path(c_header, root_build_dir),
+               "--c-client",
+               rebase_path(c_client, root_build_dir),
+               "--tables",
+               rebase_path(coding_tables, root_build_dir),
+               "--files",
+             ] + [ rebase_path(fidl_source.fidl, root_build_dir) ]
 
-      inputs = [ fidl_source.fidl, "$sdk_path/tools/fidlc" ]
+      inputs = [
+        fidl_source.fidl,
+        "$sdk_path/tools/fidlc",
+      ]
 
       outputs = [
         c_client,
@@ -91,47 +95,76 @@
   }
 
   static_library("zx") {
-    sources = [
-      "$sdk_pkg_path/zx/channel.cpp",
-      "$sdk_pkg_path/zx/event.cpp",
-      "$sdk_pkg_path/zx/eventpair.cpp",
-      "$sdk_pkg_path/zx/fifo.cpp",
-      "$sdk_pkg_path/zx/guest.cpp",
-      "$sdk_pkg_path/zx/include/lib/zx/bti.h",
-      "$sdk_pkg_path/zx/include/lib/zx/channel.h",
-      "$sdk_pkg_path/zx/include/lib/zx/event.h",
-      "$sdk_pkg_path/zx/include/lib/zx/eventpair.h",
-      "$sdk_pkg_path/zx/include/lib/zx/fifo.h",
-      "$sdk_pkg_path/zx/include/lib/zx/guest.h",
-      "$sdk_pkg_path/zx/include/lib/zx/handle.h",
-      "$sdk_pkg_path/zx/include/lib/zx/interrupt.h",
-      "$sdk_pkg_path/zx/include/lib/zx/job.h",
-      "$sdk_pkg_path/zx/include/lib/zx/object.h",
-      "$sdk_pkg_path/zx/include/lib/zx/object_traits.h",
-      "$sdk_pkg_path/zx/include/lib/zx/pmt.h",
-      "$sdk_pkg_path/zx/include/lib/zx/port.h",
-      "$sdk_pkg_path/zx/include/lib/zx/process.h",
-      "$sdk_pkg_path/zx/include/lib/zx/resource.h",
-      "$sdk_pkg_path/zx/include/lib/zx/socket.h",
-      "$sdk_pkg_path/zx/include/lib/zx/task.h",
-      "$sdk_pkg_path/zx/include/lib/zx/thread.h",
-      "$sdk_pkg_path/zx/include/lib/zx/time.h",
-      "$sdk_pkg_path/zx/include/lib/zx/timer.h",
-      "$sdk_pkg_path/zx/include/lib/zx/vmar.h",
-      "$sdk_pkg_path/zx/include/lib/zx/vmo.h",
-      "$sdk_pkg_path/zx/interrupt.cpp",
-      "$sdk_pkg_path/zx/job.cpp",
-      "$sdk_pkg_path/zx/port.cpp",
-      "$sdk_pkg_path/zx/process.cpp",
-      "$sdk_pkg_path/zx/resource.cpp",
-      "$sdk_pkg_path/zx/socket.cpp",
-      "$sdk_pkg_path/zx/thread.cpp",
-      "$sdk_pkg_path/zx/timer.cpp",
-      "$sdk_pkg_path/zx/vmar.cpp",
-      "$sdk_pkg_path/zx/vmo.cpp",
-    ] + fidl_gen_sources
+    sources =
+        [
+          # This is the zx library.
+          "$sdk_pkg_path/zx/channel.cpp",
+          "$sdk_pkg_path/zx/event.cpp",
+          "$sdk_pkg_path/zx/eventpair.cpp",
+          "$sdk_pkg_path/zx/fifo.cpp",
+          "$sdk_pkg_path/zx/guest.cpp",
+          "$sdk_pkg_path/zx/include/lib/zx/bti.h",
+          "$sdk_pkg_path/zx/include/lib/zx/channel.h",
+          "$sdk_pkg_path/zx/include/lib/zx/event.h",
+          "$sdk_pkg_path/zx/include/lib/zx/eventpair.h",
+          "$sdk_pkg_path/zx/include/lib/zx/fifo.h",
+          "$sdk_pkg_path/zx/include/lib/zx/guest.h",
+          "$sdk_pkg_path/zx/include/lib/zx/handle.h",
+          "$sdk_pkg_path/zx/include/lib/zx/interrupt.h",
+          "$sdk_pkg_path/zx/include/lib/zx/job.h",
+          "$sdk_pkg_path/zx/include/lib/zx/object.h",
+          "$sdk_pkg_path/zx/include/lib/zx/object_traits.h",
+          "$sdk_pkg_path/zx/include/lib/zx/pmt.h",
+          "$sdk_pkg_path/zx/include/lib/zx/port.h",
+          "$sdk_pkg_path/zx/include/lib/zx/process.h",
+          "$sdk_pkg_path/zx/include/lib/zx/resource.h",
+          "$sdk_pkg_path/zx/include/lib/zx/socket.h",
+          "$sdk_pkg_path/zx/include/lib/zx/task.h",
+          "$sdk_pkg_path/zx/include/lib/zx/thread.h",
+          "$sdk_pkg_path/zx/include/lib/zx/time.h",
+          "$sdk_pkg_path/zx/include/lib/zx/timer.h",
+          "$sdk_pkg_path/zx/include/lib/zx/vmar.h",
+          "$sdk_pkg_path/zx/include/lib/zx/vmo.h",
+          "$sdk_pkg_path/zx/interrupt.cpp",
+          "$sdk_pkg_path/zx/job.cpp",
+          "$sdk_pkg_path/zx/port.cpp",
+          "$sdk_pkg_path/zx/process.cpp",
+          "$sdk_pkg_path/zx/resource.cpp",
+          "$sdk_pkg_path/zx/socket.cpp",
+          "$sdk_pkg_path/zx/thread.cpp",
+          "$sdk_pkg_path/zx/timer.cpp",
+          "$sdk_pkg_path/zx/vmar.cpp",
+          "$sdk_pkg_path/zx/vmo.cpp",
 
-    deps = [ ":fuchsia.sysinfo" ]
+          # This is the fidl_base library.
+          "$sdk_pkg_path/fidl_base/builder.cpp",
+          "$sdk_pkg_path/fidl_base/decoding.cpp",
+          "$sdk_pkg_path/fidl_base/encoding.cpp",
+          "$sdk_pkg_path/fidl_base/envelope_frames.h",
+          "$sdk_pkg_path/fidl_base/formatting.cpp",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/coding.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/builder.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/message.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/message_buffer.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/message_builder.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/message_part.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/string_view.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/cpp/vector_view.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/internal.h",
+          "$sdk_pkg_path/fidl_base/include/lib/fidl/internal_callable_traits.h",
+          "$sdk_pkg_path/fidl_base/linearizing.cpp",
+          "$sdk_pkg_path/fidl_base/message.cpp",
+          "$sdk_pkg_path/fidl_base/message_buffer.cpp",
+          "$sdk_pkg_path/fidl_base/message_builder.cpp",
+          "$sdk_pkg_path/fidl_base/validating.cpp",
+          "$sdk_pkg_path/fidl_base/visitor.h",
+          "$sdk_pkg_path/fidl_base/walker.cpp",
+          "$sdk_pkg_path/fidl_base/walker.h",
+        ] + fidl_gen_sources
+
+    deps = [
+      ":fuchsia.sysinfo",
+    ]
 
     public_configs = [ ":zx_config" ]
   }