$OpenBSD: patch-base_BUILD_gn,v 1.19 2021/10/29 14:49:39 robert Exp $

Index: base/BUILD.gn
--- base/BUILD.gn.orig
+++ base/BUILD.gn
@@ -947,7 +947,7 @@ component("base") {
       "timer/hi_res_timer_manager_posix.cc",
     ]
 
-    if (!is_nacl && !is_apple) {
+    if (!is_nacl && !is_apple && !is_openbsd) {
       sources += [
         "cpu_affinity_posix.cc",
         "cpu_affinity_posix.h",
@@ -958,6 +958,12 @@ component("base") {
         "profiler/thread_delegate_posix.h",
       ]
     }
+
+    if (is_openbsd) {
+      sources += [
+        "profiler/stack_sampler_posix.cc",
+      ]
+    }
   }
 
   if (is_win) {
@@ -1381,11 +1387,16 @@ component("base") {
   # building inside the cros_sdk environment - use host_toolchain as a
   # more robust check for this.
   if (!use_sysroot &&
-      (is_android || ((is_linux || is_chromeos) && !is_chromecast)) &&
+      (is_android || ((is_linux || is_chromeos) && !is_chromecast && !is_openbsd)) &&
       host_toolchain != "//build/toolchain/cros:host") {
     libs += [ "atomic" ]
   }
 
+  # OpenBSD needs libkvm
+  if (is_openbsd) {
+    libs += [ "kvm" ]
+  }
+
   if (use_allocator_shim) {
     sources += [
       "allocator/allocator_shim.cc",
@@ -1407,7 +1418,7 @@ component("base") {
         "allocator/allocator_shim_override_mac_symbols.h",
       ]
     }
-    if (is_chromeos || is_linux) {
+    if (is_chromeos || (is_linux && !is_openbsd)) {
       sources += [
         "allocator/allocator_shim_override_cpp_symbols.h",
         "allocator/allocator_shim_override_glibc_weak_symbols.h",
@@ -2118,6 +2129,30 @@ component("base") {
         "linux_util.h",
       ]
     }
+  }
+
+  if (is_openbsd) {
+    sources -= [
+      "files/file_path_watcher_linux.cc",
+      "files/file_util_linux.cc",
+      "files/scoped_file_linux.cc",
+      "process/memory_linux.cc",
+      "process/process_linux.cc",
+      "system/sys_info_linux.cc",
+      "process/process_iterator_linux.cc",
+      "process/process_metrics_linux.cc",
+      "process/process_handle_linux.cc"
+    ]
+    sources += [
+      "process/memory_stubs.cc",
+      "process/process_handle_openbsd.cc",
+      "process/process_iterator_openbsd.cc",
+      "process/process_metrics_openbsd.cc",
+      "system/sys_info_openbsd.cc",
+      "files/file_path_watcher_kqueue.cc",
+      "files/file_path_watcher_kqueue.h",
+      "files/file_path_watcher_bsd.cc",
+    ]
   }
 
   # iOS
