Fix amalgamated build on windows

The amalgamated build generator copies all the used perfetto header into
the output. Including a header only on one platform doesn't work with
the amalgamator, because the output files need to be usable on all
platforms.

src/base/vm_sockets.h was designed to only be included on linux, but it
was included in the amalgamated build for all platforms, breaking
compilation on windows.

Fix the problem by guarding most of the content of the header with
preprocessor conditionals and including the header on all platforms in
the build system.

Reported-at: https://github.com/google/perfetto/issues/547
Change-Id: Iba2c780f8fc958349edc9b39a89ccd08be90089b
diff --git a/src/base/BUILD.gn b/src/base/BUILD.gn
index 89ca409..f9ecc20 100644
--- a/src/base/BUILD.gn
+++ b/src/base/BUILD.gn
@@ -140,13 +140,13 @@
       "../../gn:default_deps",
       "../../include/perfetto/ext/base",
     ]
-    sources = [ "unix_socket.cc" ]
+    sources = [
+      "unix_socket.cc",
+      "vm_sockets.h",
+    ]
     if (is_win && perfetto_build_standalone) {
       libs = [ "Ws2_32.lib" ]
     }
-    if (is_linux || is_android) {
-      sources += [ "vm_sockets.h" ]
-    }
   }
 }
 
diff --git a/src/base/vm_sockets.h b/src/base/vm_sockets.h
index af5b917..53b4e9e 100644
--- a/src/base/vm_sockets.h
+++ b/src/base/vm_sockets.h
@@ -17,12 +17,17 @@
 #ifndef SRC_BASE_VM_SOCKETS_H_
 #define SRC_BASE_VM_SOCKETS_H_
 
+#include "perfetto/base/build_config.h"
+
+#if PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) || \
+    PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
+
 #include <sys/socket.h>
 
 #ifdef AF_VSOCK
 // Use system vm_socket.h if avaialbe.
 #include <linux/vm_sockets.h>
-#else
+#else  // defined(AF_SOCK)
 // Fallback and use the stripped copy from the UAPI vm_sockets.h.
 
 #include <stdint.h>  // For uint8_t.
@@ -40,6 +45,9 @@
                          sizeof(unsigned int) - sizeof(uint8_t)];
 };
 
-#endif
+#endif  // defined(AF_SOCK)
+
+#endif  // PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) ||
+        // PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
 
 #endif  // SRC_BASE_VM_SOCKETS_H_