[archivist] Create a new component for Archivist.

This component does not do much yet, see follow-ups for implementation.

Change-Id: I301ed9389c31914b0ef9c3341945942a5daa2a23
diff --git a/garnet/bin/archivist/BUILD.gn b/garnet/bin/archivist/BUILD.gn
new file mode 100644
index 0000000..f3c20ba
--- /dev/null
+++ b/garnet/bin/archivist/BUILD.gn
@@ -0,0 +1,69 @@
+# Copyright 2019 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/package.gni")
+import("//build/rust/rustc_binary.gni")
+import("//build/test/test_package.gni")
+import("//build/testing/environments.gni")
+
+rustc_binary("bin") {
+  name = "archivist"
+  with_unit_tests = true
+  edition = "2018"
+
+  deps = [
+    "//garnet/lib/rust/never",
+    "//garnet/public/lib/fidl/rust/fidl",
+    "//garnet/public/rust/fdio",
+    "//garnet/public/rust/fuchsia-async",
+    "//garnet/public/rust/fuchsia-component",
+    "//garnet/public/rust/fuchsia-syslog",
+    "//garnet/public/rust/fuchsia-zircon",
+    "//third_party/rust_crates:chrono",
+    "//third_party/rust_crates:failure",
+    "//third_party/rust_crates:futures-preview",
+    "//third_party/rust_crates:itertools",
+    "//third_party/rust_crates:lazy_static",
+    "//third_party/rust_crates:regex",
+    "//third_party/rust_crates:serde",
+    "//third_party/rust_crates:serde_derive",
+    "//third_party/rust_crates:serde_json",
+    "//third_party/rust_crates:tempfile",
+    "//zircon/public/fidl/fuchsia-io:fuchsia-io-rustc",
+  ]
+}
+
+package("archivist") {
+  deps = [
+    ":bin",
+  ]
+
+  binaries = [
+    {
+      name = "rust_crates/archivist"
+      dest = "archivist"
+    },
+  ]
+
+  meta = [
+    {
+      path = rebase_path("meta/archivist.cmx")
+      dest = "archivist.cmx"
+    },
+  ]
+}
+
+test_package("archivist_tests") {
+  deps = [
+    ":bin",
+  ]
+
+  tests = [
+    {
+      name = "archivist_bin_test"
+      dest = "archivist_tests"
+      environments = basic_envs
+    },
+  ]
+}
diff --git a/garnet/bin/archivist/meta/archivist.cmx b/garnet/bin/archivist/meta/archivist.cmx
new file mode 100644
index 0000000..ac1f37b
--- /dev/null
+++ b/garnet/bin/archivist/meta/archivist.cmx
@@ -0,0 +1,14 @@
+{
+    "program": {
+        "binary": "bin/archivist"
+    },
+    "sandbox": {
+        "features": [
+            "isolated-persistent-storage",
+            "shell"
+        ],
+        "services": [
+            "fuchsia.logger.LogSink"
+        ]
+    }
+}
diff --git a/garnet/bin/archivist/meta/archivist_tests.cmx b/garnet/bin/archivist/meta/archivist_tests.cmx
new file mode 100644
index 0000000..77e3b7f
--- /dev/null
+++ b/garnet/bin/archivist/meta/archivist_tests.cmx
@@ -0,0 +1,10 @@
+{
+    "program": {
+        "binary": "test/archivist_tests"
+    },
+    "sandbox": {
+        "features": [
+            "system-temp"
+        ]
+    }
+}
diff --git a/garnet/bin/archivist/src/main.rs b/garnet/bin/archivist/src/main.rs
new file mode 100644
index 0000000..67e38fd
--- /dev/null
+++ b/garnet/bin/archivist/src/main.rs
@@ -0,0 +1,37 @@
+// Copyright 2019 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#![feature(async_await, await_macro)]
+#![deny(warnings)]
+#![allow(dead_code)]
+
+use {
+    failure::Error,
+    fuchsia_async as fasync,
+    fuchsia_component::server::ServiceFs,
+    fuchsia_syslog::{self, macros::*},
+    futures::StreamExt,
+};
+
+#[fasync::run_singlethreaded]
+async fn main() -> Result<(), Error> {
+    fuchsia_syslog::init_with_tags(&["archivist"]).expect("can't init logger");
+    fx_log_info!("Archivist is starting up...");
+
+    // Serve no services, but create an outgoing "test" directory to see if hub is working.
+    let mut fs = ServiceFs::new();
+    fs.dir("test");
+    fs.take_and_serve_directory_handle()?;
+
+    await!(startup())?;
+
+    await!(fs.collect::<()>());
+    Ok(())
+}
+
+// TODO: Create an archive on startup, then start ticking (for garbage collection and rollover) and
+// install directory watches in the correct places.
+async fn startup() -> Result<(), Error> {
+    Ok(())
+}
diff --git a/garnet/packages/prod/BUILD.gn b/garnet/packages/prod/BUILD.gn
index aed91ae..ab91a1e 100644
--- a/garnet/packages/prod/BUILD.gn
+++ b/garnet/packages/prod/BUILD.gn
@@ -5,6 +5,12 @@
 # WARNING: This file was machine-generated from previous json files and
 # will eventually be deleted.
 
+group("archivist") {
+  testonly = true
+  public_deps = [
+    "//garnet/bin/archivist",
+  ]
+}
 group("rolldice") {
   testonly = true
   public_deps = [
@@ -193,6 +199,7 @@
     "//garnet/go/src/amber:pkgfs",
     "//garnet/packages/prod:amber",
     "//garnet/packages/prod:appmgr",
+    "//garnet/packages/prod:archivist",
     "//garnet/packages/prod:atheros",
     "//garnet/packages/prod:auth",
     "//garnet/packages/prod:banjo",
diff --git a/garnet/packages/tests/BUILD.gn b/garnet/packages/tests/BUILD.gn
index 8799b1b..c84f5f0 100644
--- a/garnet/packages/tests/BUILD.gn
+++ b/garnet/packages/tests/BUILD.gn
@@ -8,6 +8,13 @@
 # WARNING: This file was machine-generated from previous json files and
 # will eventually be deleted.
 
+group("archivist_tests") {
+  testonly = true
+  public_deps = [
+    "//garnet/bin/archivist:archivist_tests",
+  ]
+}
+
 group("svc") {
   testonly = true
   public_deps = [
@@ -301,6 +308,7 @@
   public_deps = [
     ":acts_tests",
     ":amber",
+    ":archivist_tests",
     ":asio",
     ":async_promise",
     ":ath10k",