$OpenBSD: patch-tools_gn_bootstrap_bootstrap_py,v 1.10 2017/09/09 19:16:43 robert Exp $

Index: tools/gn/bootstrap/bootstrap.py
--- tools/gn/bootstrap/bootstrap.py.orig
+++ tools/gn/bootstrap/bootstrap.py
@@ -33,7 +33,8 @@ is_win = sys.platform.startswith('win')
 is_linux = sys.platform.startswith('linux')
 is_mac = sys.platform.startswith('darwin')
 is_aix = sys.platform.startswith('aix')
-is_posix = is_linux or is_mac or is_aix
+is_openbsd = sys.platform.startswith('openbsd')
+is_posix = is_linux or is_mac or is_aix or is_openbsd
 
 def check_call(cmd, **kwargs):
   logging.debug('Running: %s', ' '.join(cmd))
@@ -534,7 +535,7 @@ def write_gn_ninja(path, root_gen_dir, options):
       'base/trace_event/heap_profiler_allocation_context_tracker.cc',
       'base/trace_event/heap_profiler_allocation_register.cc',
       'base/trace_event/heap_profiler_event_filter.cc',
-      'base/trace_event/heap_profiler_event_writer.cc',
+      'base/trace_event/heap_profiler_heap_dump_writer.cc',
       'base/trace_event/heap_profiler_serialization_state.cc',
       'base/trace_event/heap_profiler_stack_frame_deduplicator.cc',
       'base/trace_event/heap_profiler_type_name_deduplicator.cc',
@@ -652,6 +653,38 @@ def write_gn_ninja(path, root_gen_dir, options):
         'base/sys_info_linux.cc',
         'base/threading/platform_thread_linux.cc',
     ])
+
+  if is_openbsd:
+    ldflags.extend(['-lpthread', '-lexecinfo'])
+    include_dirs += ["/usr/local/include"]
+
+    static_libraries['xdg_user_dirs'] = {
+        'sources': [
+            'base/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
+        ],
+        'tool': 'cxx',
+    }
+    static_libraries['base']['sources'].extend([
+        'base/memory/shared_memory_handle_posix.cc',
+        'base/memory/shared_memory_posix.cc',
+        'base/memory/shared_memory_tracker.cc',
+        'base/process/memory_stubs.cc',
+        'base/process/process_info_linux.cc',
+        'base/nix/xdg_util.cc',
+        'base/process/internal_linux.cc',
+        'base/process/process_handle_openbsd.cc',
+        'base/process/process_metrics_openbsd.cc',
+        'base/strings/sys_string_conversions_posix.cc',
+        'base/sys_info_openbsd.cc',
+        'base/threading/platform_thread_linux.cc',
+    ])
+    static_libraries['libevent']['include_dirs'].extend([
+        os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'openbsd')
+    ])
+    static_libraries['libevent']['sources'].extend([
+        'base/third_party/libevent/kqueue.c',
+    ])
+
     if is_linux:
       static_libraries['base']['sources'].extend([
         'base/allocator/allocator_shim.cc',
@@ -663,17 +696,6 @@ def write_gn_ninja(path, root_gen_dir, options):
       ])
       static_libraries['libevent']['sources'].extend([
          'base/third_party/libevent/epoll.c',
-      ])
-    else:
-      libs.extend(['-lrt'])
-      static_libraries['base']['sources'].extend([
-          'base/process/internal_aix.cc'
-      ])
-      static_libraries['libevent']['include_dirs'].extend([
-          os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'aix')
-      ])
-      static_libraries['libevent']['include_dirs'].extend([
-          os.path.join(SRC_ROOT, 'base', 'third_party', 'libevent', 'compat')
       ])
 
   if is_mac:
