[Open Screen] BUILD.gn reorganization

- Moves hello world code to samples/
- Ensures all targets are compiled by gn_all
- Consolidates tests into one unittests executable

Change-Id: I93b85516974be8e7e28c80e3b8d538830602cccb
Reviewed-on: https://chromium-review.googlesource.com/1144451
Reviewed-by: Brandon Tolsch <btolsch@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index a4ec72a..c163bab 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2,49 +2,20 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+# All compilable non-test targets in the repository (both executables and
+# source_sets).
 group("gn_all") {
-  testonly = true
+  deps = [
+    "//base",
+    "//platform",
+    "//sample:hello",
+  ]
+}
 
+executable("unittests") {
+  testonly = true
   deps = [
     "//base:base_unittests",
-    "//platform",
-  ]
-}
-
-executable("hello") {
-  sources = [
-    "hello.cc",
-  ]
-
-  deps = [
-    ":hello_shared",
-    ":hello_static",
-  ]
-}
-
-executable("hello_tests") {
-  testonly = true
-  sources = [ "hello_unittest.cc" ]
-
-  deps = [
-    "third_party/googletest:gmock",
-    "third_party/googletest:gtest",
-    "third_party/googletest:gtest_main",
-  ]
-}
-
-shared_library("hello_shared") {
-  sources = [
-    "hello_shared.cc",
-    "hello_shared.h",
-  ]
-
-  defines = [ "OPENSCREEN_SHARED_IMPLEMENTATION" ]
-}
-
-static_library("hello_static") {
-  sources = [
-    "hello_static.cc",
-    "hello_static.h",
+    "//sample:hello_unittests",
   ]
 }
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 4416780..77b195b 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -10,7 +10,7 @@
   ]
 }
 
-executable("base_unittests") {
+source_set("base_unittests") {
   testonly = true
 
   sources = [ "ip_address_unittest.cc" ]
diff --git a/platform/api/BUILD.gn b/platform/api/BUILD.gn
index 1a3a737..8872753 100644
--- a/platform/api/BUILD.gn
+++ b/platform/api/BUILD.gn
@@ -6,5 +6,6 @@
   sources = [
     "logging.cc",
     "logging.h",
+    "time.h",
   ]
 }
diff --git a/platform/api/time.h b/platform/api/time.h
new file mode 100644
index 0000000..cce93b4
--- /dev/null
+++ b/platform/api/time.h
@@ -0,0 +1,20 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PLATFORM_API_TIME_H_
+#define PLATFORM_API_TIME_H_
+
+#include <cstdint>
+
+namespace openscreen {
+namespace platform {
+
+typedef uint64_t Microseconds;
+
+Microseconds GetMonotonicTimeNow();
+
+}  // namespace platform
+}  // namespace openscreen
+
+#endif
diff --git a/platform/base/BUILD.gn b/platform/base/BUILD.gn
index aca386f..a92873c 100644
--- a/platform/base/BUILD.gn
+++ b/platform/base/BUILD.gn
@@ -3,7 +3,10 @@
 # found in the LICENSE file.
 
 source_set("base") {
-  sources = [ "logging.cc" ]
+  sources = [
+    "logging.cc",
+    "time.cc"
+  ]
 
   deps = [ "../api" ]
 }
diff --git a/sample/BUILD.gn b/sample/BUILD.gn
new file mode 100644
index 0000000..4c5afe8
--- /dev/null
+++ b/sample/BUILD.gn
@@ -0,0 +1,41 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+executable("hello") {
+  sources = [
+    "hello.cc",
+  ]
+
+  deps = [
+    ":hello_shared",
+    ":hello_static",
+  ]
+}
+
+source_set("hello_unittests") {
+  testonly = true
+  sources = [ "hello_unittest.cc" ]
+
+  deps = [
+    "//third_party/googletest:gmock",
+    "//third_party/googletest:gtest",
+    "//third_party/googletest:gtest_main",
+  ]
+}
+
+shared_library("hello_shared") {
+  sources = [
+    "hello_shared.cc",
+    "hello_shared.h",
+  ]
+
+  defines = [ "OPENSCREEN_SHARED_IMPLEMENTATION" ]
+}
+
+static_library("hello_static") {
+  sources = [
+    "hello_static.cc",
+    "hello_static.h",
+  ]
+}
diff --git a/hello.cc b/sample/hello.cc
similarity index 100%
rename from hello.cc
rename to sample/hello.cc
diff --git a/hello_shared.cc b/sample/hello_shared.cc
similarity index 100%
rename from hello_shared.cc
rename to sample/hello_shared.cc
diff --git a/hello_shared.h b/sample/hello_shared.h
similarity index 100%
rename from hello_shared.h
rename to sample/hello_shared.h
diff --git a/hello_static.cc b/sample/hello_static.cc
similarity index 100%
rename from hello_static.cc
rename to sample/hello_static.cc
diff --git a/hello_static.h b/sample/hello_static.h
similarity index 100%
rename from hello_static.h
rename to sample/hello_static.h
diff --git a/hello_unittest.cc b/sample/hello_unittest.cc
similarity index 100%
rename from hello_unittest.cc
rename to sample/hello_unittest.cc