gn as single commit

Change-Id: I951583f2b51c26bae58cb203cb9818723412840a
diff --git a/BUILD.gn b/BUILD.gn
index f9af0d6..6327468 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2,18 +2,25 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("$zx/public/gn/build_api.gni")
 import("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/host_tool_action.gni")
+import("$zx/public/gn/pkg.gni")
+import("$zx/public/gn/toolchain/c_utils.gni")
 import("$zx/public/gn/toolchain/select_toolchain.gni")
+import("$zx/public/gn/zbi.gni")
 
 # Build the native host tools intended for developer use.
-select_toolchain("tools-${host_os}-${host_cpu}") {
-  testonly = true
-  environment_label = "$zx/public/gn/toolchain:host"
-  cpu = host_cpu
-  os = host_os
-  deps = [
-    "$zx/system/host:tools",
-  ]
+foreach(host, standard_build_hosts) {
+  select_toolchain("tools-${host.os}-${host.cpu}") {
+    testonly = true
+    environment_label = "$zx/public/gn/toolchain:host"
+    cpu = host.cpu
+    os = host.os
+    deps = [
+      "$zx/system/host:tools",
+    ]
+  }
 }
 
 if (current_toolchain == default_toolchain) {
@@ -52,11 +59,265 @@
       rebase_path(tools_rspfile, root_build_dir),
     ]
   }
+
+  # TODO(mcgrathr): Temporary hacks for integrating with the legacy Fuchsia
+  # GN build.
+  host_tests_rspfile = "$target_gen_dir/host_tests.rsp"
+  generated_file("host_tests._rsp") {
+    visibility = [ ":legacy-host_tests" ]
+    testonly = true
+    outputs = [
+      host_tests_rspfile,
+    ]
+    deps = [
+      "system/utest:host"
+    ]
+    output_conversion = "list lines"
+    data_keys = [ "link_output" ]
+    walk_keys = [ "link_barrier" ]
+  }
+
+  action("legacy-host_tests") {
+    testonly = true
+    deps = [
+      ":host_tests._rsp",
+    ]
+    script = "$zx/scripts/copy-files"
+    depfile = "$target_out_dir/$target_name.d"
+    outputs = [
+      depfile,
+    ]
+    sources = [
+      host_tests_rspfile,
+    ]
+    args = [
+      "host_tests",
+      rebase_path(depfile, root_build_dir),
+      rebase_path(host_tests_rspfile, root_build_dir),
+    ]
+  }
+}
+
+public_targets = [
+  "bootloader",
+  "kernel",
+  "core",
+]
+
+testonly_public_targets = [
+  "bin",
+  "drivers",
+]
+
+# Each cpu is a target name for all the public targets for that CPU.
+foreach(cpu, standard_fuchsia_cpus) {
+  bootimage(cpu) {
+    testonly = true
+    cpu = cpu
+    deps = []
+    foreach(target, public_targets + testonly_public_targets) {
+      deps += [ "$zx/public/$target:$cpu" ]
+    }
+  }
+
+  # TODO(mcgrathr): Temporary hacks for integrating with the legacy Fuchsia
+  # GN build.
+  if (current_toolchain == default_toolchain) {
+    # This functions as the top-level target for integrating into the
+    # legacy Fuchsia GN build (what //scritps/build-zircon.sh builds)
+    # and also as the build API module used by the Fuchsia GN build's
+    # integration support (zircon_legacy in //build/config/fuchsia/zircon.gni).
+    build_api_module("legacy-$cpu") {
+      testonly = true
+      deps = [
+        ":ids-$cpu",
+        ":legacy-deps-$cpu",
+        ":manifest-$cpu",
+      ]
+      data_keys = [ "images" ]
+    }
+
+    group("legacy-deps-$cpu") {
+      testonly = true
+      deps = [
+        ":$cpu",
+        ":boards-$cpu",
+        "$zx/system/ulib:asan-manifest-$cpu",
+      ]
+    }
+
+    pkg_export("manifest-$cpu") {
+      testonly = true
+      data_keys = [ "pkg_export_manifest" ]
+      deps = [
+        ":$cpu",
+        ":tools",
+        ":ulib-$cpu",
+
+        # Separately listed because they're reached by dependencies only on x64.
+        "$zx/system/banjo/ddk-protocol-acpi",
+        "$zx/system/banjo/ddk-protocol-intelgpucore",
+        "$zx/system/banjo/ddk-protocol-intelhda-codec",
+        "$zx/system/banjo/ddk-protocol-intelhda-dsp",
+      ]
+    }
+
+    generated_file("boards-$cpu") {
+      testonly = true
+      outputs = [
+        "$root_build_dir/export/$target_name.list",
+      ]
+      output_conversion = "list lines"
+      data_keys = [ "sdk_board_list" ]
+      deps = [
+        ":$cpu",
+      ]
+    }
+  }
+
+  select_toolchain("ulib-$cpu") {
+    testonly = true
+    cpu = cpu
+    environment_label = "$zx/public/gn/toolchain:user"
+    deps = [
+      "$zx/system/ulib",
+    ]
+  }
+}
+
+# TODO(TC-303): ids.txt is deprecated and will be removed.
+if (current_toolchain == default_toolchain) {
+  action("ids.txt") {
+    testonly = true
+    outputs = [
+      "$root_build_dir/ids.txt",
+    ]
+    deps = []
+    sources = []
+    foreach(cpu, standard_fuchsia_cpus) {
+      deps += [ ":ids-$cpu" ]
+      sources += [ "$root_build_dir/ids-$cpu.txt" ]
+    }
+    script = "/usr/bin/sort"
+    args = [
+             "-u",
+             "-o",
+           ] + rebase_path(outputs + sources, root_build_dir)
+  }
+
+  foreach(cpu, standard_fuchsia_cpus) {
+    select_toolchain("ids-$cpu") {
+      testonly = true
+      cpu = cpu
+      environment_label = "$zx/public/gn/toolchain:user"
+      deps = [
+        ":ids-$cpu.txt",
+      ]
+    }
+  }
+} else if (toolchain.environment == "user") {
+  generated_file("elf-$current_cpu.list") {
+    testonly = true
+    outputs = [
+      "$root_build_dir/elf-$current_cpu.list",
+    ]
+    deps = [
+      ":legacy-deps-$current_cpu($default_toolchain)",
+    ]
+    data_keys = [ "elf_link_output" ]
+  }
+
+  toolchain_utils_action("ids-$current_cpu.txt") {
+    testonly = true
+    deps = [
+      ":elf-$current_cpu.list",
+    ]
+    outputs = [
+      "$root_build_dir/$target_name",
+    ]
+    sources = [
+      "$root_build_dir/elf-$current_cpu.list",
+    ]
+    depfile = "${outputs[0]}.d"
+    script = "scripts/gen-ids-file"
+    utils = [ "readelf" ]
+    args = rebase_path(outputs + [ depfile ] + sources, root_build_dir)
+  }
+}
+
+# Each public target is a target name for all the CPUs for that target.
+foreach(target, public_targets + testonly_public_targets) {
+  group(target) {
+    testonly = public_targets + [ target ] - [ target ] == public_targets
+    deps = []
+    foreach(cpu, standard_fuchsia_cpus) {
+      deps += [ "$zx/public/$target:$cpu" ]
+    }
+  }
+}
+
+group("all-cpu") {
+  testonly = true
+  deps = []
+  foreach(cpu, standard_fuchsia_cpus) {
+    deps += [ ":$cpu" ]
+  }
 }
 
 group("default") {
   testonly = true
   deps = [
+    ":all-cpu",
     ":tools",
   ]
 }
+
+# TODO: example
+
+foreach(cpu, standard_fuchsia_cpus) {
+  bootimage("core-tests-$cpu") {
+    testonly = true
+    cpu = cpu
+    deps = [
+      "$zx/public/kernel",
+      "$zx/system/utest:core-tests",
+    ]
+  }
+}
+
+bootimage("sherlock-zedboot") {
+  cpu = "arm64"
+  deps = [
+    ":zedboot",
+    "$zx/system/dev/board/sherlock",
+  ]
+}
+
+if (current_cpu != "") {
+  group("zedboot") {
+    deps = [
+      "$zx/public/core",
+      # TODO: some group() of useful diag/debug tools
+    ]
+    metadata = {
+      devmgr_config = [ "netsvc.netboot=true" ]
+    }
+  }
+
+  group("recovery") {
+    deps = [
+      "$zx/public/core",
+      # TODO: some group() of useful diag/recovery tools
+    ]
+  }
+}
+
+if (current_toolchain == default_toolchain) {
+  build_api_module("api") {
+    testonly = true
+    deps = [
+      "system/utest:host_tests",
+    ]
+    data_keys = [ "build_api_modules" ]
+  }
+}
diff --git a/bootloader/BUILD.gn b/bootloader/BUILD.gn
new file mode 100644
index 0000000..4e856f9
--- /dev/null
+++ b/bootloader/BUILD.gn
@@ -0,0 +1,82 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/public/gn/toolchain/environment.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# Gigaboot gets its own toolchains to build EFI code.
+if (current_toolchain == default_toolchain) {
+  define_environment("efi") {
+    cpu = "x64"
+    os = "win"
+    globals = {
+      is_kernel = true
+    }
+    configs += standard_fuchsia_configs + [ ":efi_config" ]
+
+    # TODO: harmless, but just to match build.mk
+    configs -= [ "$zx/public/gn/config:default_frame_pointers" ]
+
+    # TODO: strip = true
+
+    # There isn't a GCC toolchain that supports the Windows target directly
+    # the way we use it.
+    exclude_variant_tags = [ "gcc" ]
+  }
+} else if (toolchain.environment == "efi") {
+  # This is the top config for all code in the efi_toolchain.
+  config("efi_config") {
+    public_deps = [
+      "$zx/kernel:standalone",
+      "$zx/public/gn/config:no_sanitizers",
+
+      # TODO: "$zx/kernel:warnings",
+    ]
+    include_dirs = [ "include" ]
+    cflags = [
+      "-std=c99",
+      "-fshort-wchar",
+    ]
+    if (current_cpu == "x64") {
+      cflags += [ "-mno-red-zone" ]
+    }
+  }
+
+  executable("bootloader") {
+    output_dir = root_out_dir
+    output_name = "boot${current_cpu}"
+    output_extension = "efi"
+    deps = [
+      "lib",
+      "src",
+    ]
+    ldflags = [
+      "-nostdlib",
+      "-Wl,/subsystem:efi_application",
+      "-Wl,/entry:efi_main",
+    ]
+
+    # TODO(mcgrathr): Temporary kludge for legacy Fuchsia GN build integration.
+    metadata = {
+      images = [
+        {
+          name = "bootloader"
+          type = "efi"
+          path = rebase_path("$root_out_dir/$output_name.$output_extension",
+                             root_build_dir)
+        },
+      ]
+    }
+  }
+} else {
+  # In any other toolchain, just redirect to the proper toolchain.
+  select_toolchain("bootloader") {
+    environment_label = ":efi"
+    deps = [
+      ":bootloader",
+    ]
+  }
+}
diff --git a/bootloader/include/inttypes.h b/bootloader/include/inttypes.h
index 36ae92d..081e0b7 100644
--- a/bootloader/include/inttypes.h
+++ b/bootloader/include/inttypes.h
@@ -20,6 +20,8 @@
 
 #ifdef __clang__
 #define PRIx64 "llx"
+#define PRIu64 "llu"
 #else
 #define PRIx64 "lx"
+#define PRIu64 "lu"
 #endif
diff --git a/bootloader/lib/BUILD.gn b/bootloader/lib/BUILD.gn
new file mode 100644
index 0000000..b58aac0
--- /dev/null
+++ b/bootloader/lib/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+assert(toolchain.environment == "efi")
+
+source_set("lib") {
+  sources = [
+    "console-printf.c",
+    "ctype.c",
+    "efi/guids.c",
+    "inet.c",
+    "loadfile.c",
+    "printf.c",
+    "stdlib.c",
+    "string.c",
+    "strings.c",
+    "xefi.c",
+  ]
+}
diff --git a/bootloader/src/BUILD.gn b/bootloader/src/BUILD.gn
new file mode 100644
index 0000000..4633cad
--- /dev/null
+++ b/bootloader/src/BUILD.gn
@@ -0,0 +1,27 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+assert(toolchain.environment == "efi")
+
+source_set("src") {
+  sources = [
+    "cmdline.c",
+    "device_id.c",
+    "diskio.c",
+    "framebuffer.c",
+    "inet6.c",
+    "misc.c",
+    "netboot.c",
+    "netifc.c",
+    "osboot.c",
+    "pci.c",
+    "zircon.c",
+  ]
+  include_dirs = [ "." ]
+  deps = [
+    "$zx/system/ulib/tftp",
+  ]
+}
diff --git a/kernel/BUILD.gn b/kernel/BUILD.gn
new file mode 100644
index 0000000..a703fa1
--- /dev/null
+++ b/kernel/BUILD.gn
@@ -0,0 +1,288 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/c_utils.gni")
+import("$zx/public/gn/toolchain/environment.gni")
+import("params.gni")
+
+if (current_toolchain == default_toolchain) {
+  # In the default toolchain, just define the kernel toolchains.
+  foreach(cpu, standard_fuchsia_cpus) {
+    define_environment("kernel") {
+      globals = {
+        is_kernel = true
+      }
+      configs += standard_fuchsia_configs
+      configs += [
+        ":kernel_config",
+        "lib/libc:headers",
+
+        # <kernel/spinlock.h> has #include <lockdep/lock_policy.h>.
+        "$zx/system/ulib/lockdep:headers",
+
+        # <kernel/thread.h> has #include <vm/kstack.h>.
+        "vm:headers",
+
+        # <lib/ktrace.h> has #include <lib/zircon-internal/ktrace.h>.
+        "$zx/system/ulib/zircon-internal:headers",
+      ]
+    }
+  }
+} else {
+  assert(is_kernel)
+
+  # These are needed both in kernel sources (pervasively) and in the linker
+  # scripts.
+  kernel_defines = [
+    # TODO: should not be needed in C, but is in one place now.
+    "KERNEL_BASE=$kernel_base",
+
+    "SMP_MAX_CPUS=$smp_max_cpus",
+  ]
+
+  # This is the top config for all kernel code.
+  config("kernel_config") {
+    public_deps = [
+      ":headers",
+      ":lock_dep",
+      ":standalone",
+      ":warnings",
+      "arch/$zircon_cpu:kernel",
+
+      # include/lib/counters.h and kernel.ld depend on -fdata-sections.
+      "$zx/public/gn/config:data_sections",
+    ]
+
+    defines = kernel_defines + kernel_extra_defines
+    defines += [
+      "_KERNEL",
+      "LK",
+      "ENABLE_PANIC_SHELL",
+      "WITH_DEBUG_LINEBUFFER",
+      "ZIRCON_TOOLCHAIN",
+    ]
+
+    if (!enable_user_pci) {
+      defines += [ "WITH_KERNEL_PCIE" ]
+    }
+
+    cflags = [ "-fpie" ]
+  }
+
+  config("headers") {
+    include_dirs = [ "include" ]
+  }
+
+  # For any standalone static binary.
+  config("standalone") {
+    ldflags = [ "-nostdlib" ]
+
+    cflags = [
+      "-ffreestanding",
+      "-include",
+      rebase_path("include/hidden.h", root_build_dir),
+
+      # We want `.debug_frame` for the kernel (ZX-62).  And we still want
+      # asynchronous unwind tables.  Alas there's (currently) no way to
+      # achieve this with our GCC.  At the moment we compile with
+      # `-fno-omit-frame-pointer`, which is good because we link with
+      # `--gc-sections`, which means `.eh_frame` gets discarded so GCC-built
+      # kernels don't have any unwind info (except for assembly)!  Assembler
+      # code has its own way of requesting `.debug_frame` vs `.eh_frame` with
+      # the `.cfi_sections` directive.
+      "-fno-unwind-tables",
+    ]
+
+    if (!is_gcc && current_os == "fuchsia") {
+      # In the Fuchsia-target toolchains there's no way to prevent the
+      # compiler driver from passing -pie, so negate it.  BFD ld doesn't
+      # have --no-pie, but arm64-elf-gcc doesn't pass -pie either.
+      ldflags += [ "-Wl,--no-pie" ]
+    }
+
+    public_deps = [
+      "$zx/public/gn/config:no_exceptions",
+    ]
+  }
+
+  config("warnings") {
+    cflags = [
+      "-Wformat=2",
+      "-Wvla",
+    ]
+
+    # GCC supports `-Wformat-signedness` but Clang currently does not.
+    if (is_gcc) {
+      cflags += [ "-Wformat-signedness" ]
+    }
+
+    cflags_c = [ "-Wmissing-prototypes" ]
+  }
+
+  config("lock_dep") {
+    visibility = [ ":*" ]
+    defines = []
+    if (enable_lock_dep) {
+      defines += [
+        "WITH_LOCK_DEP=1",
+        "LOCK_DEP_ENABLE_VALIDATION=1",
+      ]
+    }
+    if (enable_lock_dep_tests) {
+      defines += [ "WITH_LOCK_DEP_TESTS=1" ]
+    }
+  }
+
+  # This is the kernel proper, an ELF executable with full symbols.
+  # It's the file to use with a debugger, for example.
+  executable("zircon") {
+    visibility = [ ":*" ]
+
+    # $zx/scripts/zircon.elf-gdb.py expects kernel symbols in "zircon.elf".
+    output_extension = "elf"
+
+    ldflags = [
+      "-Wl,-T," + rebase_path("kernel.ld", root_build_dir),
+      "-Wl,--emit-relocs",
+    ]
+    inputs = [
+      "kernel.ld",
+    ]
+    configs += [ ":kernel_defsym" ]
+
+    deps = [
+      ":test",  # TODO: make optional, add testonly taint
+      "top",
+    ]
+    if (current_cpu == "arm64") {
+      deps += [ "platform/generic-arm" ]
+    } else if (current_cpu == "x64") {
+      deps += [ "target/pc" ]
+    }
+  }
+
+  # Output file of that target.
+  zircon_elf = "$target_out_dir/zircon.elf"
+
+  # These are needed only in image.S and in the linker scripts.
+  image_defines = [ "BOOT_HEADER_SIZE=0x50" ]
+
+  # This supplies those variables for use in linker scripts.
+  config("kernel_defsym") {
+    visibility = [ ":*" ]
+    ldflags = []
+    foreach(assignment, kernel_defines + image_defines) {
+      ldflags += [ "-Wl,-defsym,$assignment" ]
+    }
+  }
+
+  # TODO: From project/virtual/test.mk
+  group("test") {
+    #TODO: testonly = true
+    visibility = [ ":*" ]
+    deps = [
+      "lib/debugcommands",
+      "tests",
+    ]
+  }
+
+  zircon_raw = "$target_out_dir/zircon.bin"
+  image_binary("raw") {
+    visibility = [ ":*" ]
+    deps = [
+      ":zircon",
+    ]
+    sources = [
+      zircon_elf,
+    ]
+    outputs = [
+      zircon_raw,
+    ]
+  }
+
+  # Use the --emit-relocs records to extract the fixups needed to relocate
+  # the kernel at boot.  This generates the "kernel-fixups.inc" file that's
+  # #include'd by "arch/$zircon_cpu/image.S".
+  toolchain_utils_action("fixups") {
+    visibility = [ ":*" ]
+    deps = [
+      ":zircon",
+    ]
+    sources = [
+      zircon_elf,
+    ]
+    outputs = [
+      "$target_gen_dir/kernel-fixups.inc",
+    ]
+
+    # TODO(mcgrathr): Move the script to this dir as it's private to this use.
+    script = "$zx/scripts/gen-kaslr-fixups.sh"
+    utils = [
+      "readelf",
+      "objdump",
+    ]
+    args = [
+      rebase_path(sources[0], root_build_dir),
+      rebase_path(outputs[0], root_build_dir),
+    ]
+  }
+
+  executable("image") {
+    visibility = [ ":*" ]
+    configs += [ ":kernel_defsym" ]
+    deps = [
+      ":fixups",
+      ":raw",
+      ":zircon",
+    ]
+    include_dirs = [ target_gen_dir ]
+    raw_path = rebase_path(zircon_raw, root_build_dir)
+    defines = image_defines + [ "KERNEL_IMAGE=\"${raw_path}\"" ]
+    sources = [
+      "arch/$zircon_cpu/image.S",
+    ]
+    ldflags = [
+      "-Wl,--build-id=none",
+      "-Wl,-T," + rebase_path("image.ld", root_build_dir),
+      "-Wl,--just-symbols," + rebase_path(zircon_elf, root_build_dir),
+    ]
+    inputs = [
+      "image.ld",
+      zircon_elf,
+      zircon_raw,
+    ]
+  }
+
+  image_binary("kernel") {
+    deps = [
+      ":image",
+    ]
+    outputs = [
+      "$root_out_dir/kernel.zbi",
+    ]
+    sources = [
+      "$target_out_dir/image",
+    ]
+
+    metadata = {
+      images = [
+        {
+          type = "zbi"
+          name = "kernel"
+          path = rebase_path(outputs[0], root_build_dir)
+        },
+      ]
+
+      # This metadata makes the kernel act as a zbi_input() target so it can
+      # be a dependency of a zbi() target to get into the image.
+      zbi_input_args = [
+        "--type=container",
+        rebase_path(outputs[0], root_build_dir),
+      ]
+    }
+  }
+}
diff --git a/kernel/arch/arm64/BUILD.gn b/kernel/arch/arm64/BUILD.gn
new file mode 100644
index 0000000..274ffbd
--- /dev/null
+++ b/kernel/arch/arm64/BUILD.gn
@@ -0,0 +1,110 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/params.gni")
+import("$zx/public/gn/toolchain/environment.gni")
+
+if (current_toolchain == default_toolchain) {
+  # Define a special environment for building code that runs in physical
+  # memory with the MMU disabled, at early boot.
+  define_environment("physmem") {
+    cpu = "arm64"
+    globals = {
+      is_kernel = true
+    }
+    configs += standard_fuchsia_configs + [ ":physmem_config" ]
+  }
+} else {
+  # This is the top config for the physmem environment.
+  config("physmem_config") {
+    public_deps = [
+      ":headers",
+      "$zx/kernel:headers",
+      "$zx/kernel:standalone",
+      "$zx/kernel:warnings",
+      "$zx/kernel/lib/libc:headers",
+      "$zx/public/gn/config:no_sanitizers",
+    ]
+
+    cflags = [
+      "-fpie",
+
+      "-mgeneral-regs-only",
+
+      # With the MMU disabled, alignment checking is always enabled.  So make
+      # sure the compiler doesn't use any unaligned memory accesses.
+      "-mstrict-align",
+    ]
+
+    if (!is_gcc) {
+      # TODO(TC-237): cflags += [ "-mcmodel=tiny" ]
+    }
+  }
+
+  # This is used pervasively throughout the kernel on arm64.
+  config("kernel") {
+    # The kernel does not use FP or vector registers.
+    cflags = [ "-mgeneral-regs-only" ]
+
+    if (!is_gcc) {
+      # Clang needs -mcmodel=kernel to tell it to use the right safe-stack
+      # ABI for the kernel.
+      cflags += [ "-mcmodel=kernel" ]
+    }
+
+    defines = [
+      "ARCH_ARM64",
+      "KERNEL_ASPACE_BASE=$kernel_aspace_base",
+      "KERNEL_ASPACE_SIZE=0x0001000000000000",
+      "USER_ASPACE_BASE=0x0000000001000000",
+      "USER_ASPACE_SIZE=0x0000fffffe000000",
+    ]
+
+    # For #include <arch/foo.h>.
+    include_dirs = [ "include" ]
+  }
+
+  library("arm64") {
+    kernel = true
+    defines = [
+      "SMP_CPU_MAX_CLUSTER_CPUS=$smp_max_cpus",
+      "SMP_CPU_MAX_CLUSTERS=$smp_max_clusters",
+    ]
+    sources = [
+      "arch.cpp",
+      "asm.S",
+      "boot-mmu.cpp",
+      "cache-ops.S",
+      "debugger.cpp",
+      "exceptions.S",
+      "exceptions_c.cpp",
+      "feature.cpp",
+      "fpu.cpp",
+      "mexec.S",
+      "mmu.cpp",
+      "mp.cpp",
+      "periphmap.cpp",
+      "registers.cpp",
+      "smccc.S",
+      "spinlock.cpp",
+      "start.S",
+      "sysreg.cpp",
+      "thread.cpp",
+      "user_copy.S",
+      "user_copy_c.cpp",
+      "uspace_entry.S",
+    ]
+    deps = [
+      "$zx/kernel/dev/iommu/dummy",
+      "$zx/kernel/lib/console",
+      "$zx/kernel/lib/counters",
+      "$zx/kernel/lib/crashlog",
+      "$zx/kernel/object",
+      "$zx/kernel/syscalls:syscall-abi",
+      "$zx/system/ulib/bitmap",
+    ]
+  }
+}
diff --git a/kernel/arch/arm64/hypervisor/BUILD.gn b/kernel/arch/arm64/hypervisor/BUILD.gn
new file mode 100644
index 0000000..4c42b13
--- /dev/null
+++ b/kernel/arch/arm64/hypervisor/BUILD.gn
@@ -0,0 +1,26 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("hypervisor") {
+  sources = [
+    "el2.S",
+    "el2_cpu_state.cpp",
+    "gic/el2.S",
+    "gic/gicv2.cpp",
+    "gic/gicv3.cpp",
+    "guest.cpp",
+    "vcpu.cpp",
+    "vmexit.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt/arm_gic/common",
+    "$zx/kernel/dev/interrupt/arm_gic/v2",
+    "$zx/kernel/dev/interrupt/arm_gic/v3",
+    "$zx/kernel/dev/psci",
+    "$zx/kernel/dev/timer/arm_generic",
+    "$zx/kernel/lib/hypervisor:headers",
+  ]
+}
diff --git a/kernel/arch/x86/BUILD.gn b/kernel/arch/x86/BUILD.gn
new file mode 100644
index 0000000..0ae2ca6
--- /dev/null
+++ b/kernel/arch/x86/BUILD.gn
@@ -0,0 +1,155 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/params.gni")
+
+# This is used pervasively throughout the kernel on x86.
+config("kernel") {
+  cflags = [
+    "-mno-red-zone",
+
+    # Hard disable floating point in the kernel.
+    "-msoft-float",
+    "-mno-mmx",
+    "-mno-sse",
+    "-mno-sse2",
+    "-mno-3dnow",
+    "-mno-avx",
+    "-mno-avx2",
+  ]
+
+  if (is_gcc) {
+    cflags += [
+      "-falign-jumps=1",
+      "-falign-loops=1",
+      "-falign-functions=4",
+
+      # Optimization: Since FPU is disabled, do not pass flag in %rax to
+      # varargs routines that floating point args are in use.
+      "-mskip-rax-setup",
+    ]
+  } else {
+    # Clang needs -mcmodel=kernel to tell it to use the right safe-stack
+    # ABI for the kernel.
+    cflags += [ "-mcmodel=kernel" ]
+  }
+
+  defines = [
+    "ARCH_X86",
+    "KERNEL_ASPACE_BASE=$kernel_aspace_base",
+    "KERNEL_ASPACE_SIZE=0x0000008000000000UL",
+
+    "USER_ASPACE_BASE=0x0000000001000000UL",  # 16MB
+
+    # We set the top of user address space to be (1 << 47) - 4k.  See
+    # docs/sysret_problem.md for why we subtract 4k here.  Subtracting
+    # USER_ASPACE_BASE from that value gives the value for USER_ASPACE_SIZE
+    # below.
+    "USER_ASPACE_SIZE=0x00007ffffefff000UL",
+
+    "KERNEL_LOAD_OFFSET=0x00100000",  # 1MB
+  ]
+
+  # For #include <arch/foo.h>.
+  include_dirs = [ "include" ]
+
+  public_deps = [
+    # <arch/aspace.h> has #include <arch/x86/ioport.h>.
+    ":headers",
+  ]
+}
+
+library("x86") {
+  kernel = true
+  sources = [
+    "acpi.S",
+    "arch.cpp",
+    "asm.S",
+    "bootstrap16.cpp",
+    "cache.cpp",
+    "cpu_topology.cpp",
+    "debugger.cpp",
+    "descriptor.cpp",
+    "exceptions.S",
+    "faults.cpp",
+    "feature.cpp",
+    "gdt.S",
+    "hwp.cpp",
+    "idt.cpp",
+    "ioapic.cpp",
+    "ioport.cpp",
+    "lapic.cpp",
+    "mexec.S",
+    "mmu.cpp",
+    "mmu_mem_types.cpp",
+    "mp.cpp",
+    "ops.S",
+    "perf_mon.cpp",
+    "proc_trace.cpp",
+    "pvclock.cpp",
+    "registers.cpp",
+    "smp.cpp",
+    "start.S",
+    "start16.S",
+    "thread.cpp",
+    "timer_freq.cpp",
+    "tsc.cpp",
+    "user_copy.S",
+    "user_copy.cpp",
+    "uspace_entry.S",
+  ]
+  deps = [
+    ":syscall",
+    ":tests",
+    "$zx/kernel/dev/hw_rng",
+    "$zx/kernel/dev/iommu/dummy",
+    "$zx/kernel/dev/iommu/intel",
+    "$zx/kernel/lib/code_patching",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/counters",
+    "$zx/kernel/lib/crashlog",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/pci",
+    "$zx/kernel/object",
+    "$zx/system/ulib/bitmap",
+  ]
+  public_deps = [
+    "page_tables:headers",
+
+    # arch/x86/apic.h has #include <dev/interrupt.h>.
+    "$zx/kernel/dev/interrupt:headers",
+
+    # arch/x86/hypervisor.h has #include <hypervisor/guest_physical_address_space.h>.
+    "$zx/kernel/lib/hypervisor:headers",
+
+    # <arch/aspace.h> has #include <bitmap/rle-bitmap.h>.
+    "$zx/system/ulib/bitmap:headers",
+
+    # <arch/aspace.h> has #include <fbl/unique_ptr.h>.
+    "$zx/system/ulib/fbl:headers",
+
+    # <arch/x86/acpi.h> has #include <acpica/acpi.h>.
+    "$zx/third_party/lib/acpica:headers",
+  ]
+}
+
+source_set("syscall") {
+  sources = [
+    "syscall.S",
+  ]
+  deps = [
+    "$zx/kernel/syscalls:syscall-abi",
+  ]
+}
+
+source_set("tests") {
+  sources = [
+    "mmu_tests.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/arch/x86/hypervisor/BUILD.gn b/kernel/arch/x86/hypervisor/BUILD.gn
new file mode 100644
index 0000000..c754483
--- /dev/null
+++ b/kernel/arch/x86/hypervisor/BUILD.gn
@@ -0,0 +1,20 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("hypervisor") {
+  sources = [
+    "guest.cpp",
+    "pvclock.cpp",
+    "vcpu.cpp",
+    "vmexit.cpp",
+    "vmx.S",
+    "vmx_cpu_state.cpp",
+  ]
+  deps = [
+    "$zx/kernel/platform/pc",
+    "$zx/system/ulib/explicit-memory",
+  ]
+}
diff --git a/kernel/arch/x86/page_tables/BUILD.gn b/kernel/arch/x86/page_tables/BUILD.gn
new file mode 100644
index 0000000..b28195f
--- /dev/null
+++ b/kernel/arch/x86/page_tables/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("page_tables") {
+  kernel = true
+  sources = [
+    "page_tables.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/fbl",
+  ]
+  public_deps = [
+    # <arch/x86/page_tables/page_tables.h> has #include <hwreg/bitfields.h>.
+    "$zx/system/ulib/hwreg:headers",
+  ]
+}
diff --git a/kernel/dev/hdcp/amlogic_s912/BUILD.gn b/kernel/dev/hdcp/amlogic_s912/BUILD.gn
new file mode 100644
index 0000000..ff0ff9b
--- /dev/null
+++ b/kernel/dev/hdcp/amlogic_s912/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("amlogic_s912") {
+  sources = [
+    "hdcp.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/lib/cbuf",
+  ]
+}
diff --git a/kernel/dev/hw_rng/BUILD.gn b/kernel/dev/hw_rng/BUILD.gn
new file mode 100644
index 0000000..806f17c
--- /dev/null
+++ b/kernel/dev/hw_rng/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("hw_rng") {
+  kernel = true
+  sources = [
+    "debug.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+  ]
+}
diff --git a/kernel/dev/intel_rng/BUILD.gn b/kernel/dev/intel_rng/BUILD.gn
new file mode 100644
index 0000000..770088e
--- /dev/null
+++ b/kernel/dev/intel_rng/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("intel_rng") {
+  sources = [
+    "intel-rng.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/hw_rng",
+  ]
+}
diff --git a/kernel/dev/interrupt/BUILD.gn b/kernel/dev/interrupt/BUILD.gn
new file mode 100644
index 0000000..fc6cb64
--- /dev/null
+++ b/kernel/dev/interrupt/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("interrupt") {
+  kernel = true
+  sources = [
+    "msi.cpp",
+  ]
+}
diff --git a/kernel/dev/interrupt/arm_gic/common/BUILD.gn b/kernel/dev/interrupt/arm_gic/common/BUILD.gn
new file mode 100644
index 0000000..9ec2e27
--- /dev/null
+++ b/kernel/dev/interrupt/arm_gic/common/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("common") {
+  kernel = true
+  sources = [
+    "arm_gic_hw_interface.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+  ]
+}
diff --git a/kernel/dev/interrupt/arm_gic/v2/BUILD.gn b/kernel/dev/interrupt/arm_gic/v2/BUILD.gn
new file mode 100644
index 0000000..1ab1604
--- /dev/null
+++ b/kernel/dev/interrupt/arm_gic/v2/BUILD.gn
@@ -0,0 +1,23 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("v2") {
+  kernel = true
+  sources = [
+    "arm_gicv2.cpp",
+    "arm_gicv2m.cpp",
+    "arm_gicv2m_msi.cpp",
+    "arm_gicv2m_pcie.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/interrupt/arm_gic/common",
+    "$zx/kernel/dev/pcie",
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/interrupt",
+    "$zx/kernel/lib/pow2_range_allocator",
+  ]
+}
diff --git a/kernel/dev/interrupt/arm_gic/v3/BUILD.gn b/kernel/dev/interrupt/arm_gic/v3/BUILD.gn
new file mode 100644
index 0000000..ee31a57
--- /dev/null
+++ b/kernel/dev/interrupt/arm_gic/v3/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("v3") {
+  kernel = true
+  sources = [
+    "arm_gicv3.cpp",
+    "arm_gicv3_pcie.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/interrupt/arm_gic/common",
+    "$zx/kernel/dev/interrupt/arm_gic/v2:headers",
+    "$zx/kernel/dev/pcie",
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/interrupt",
+  ]
+}
diff --git a/kernel/dev/iommu/dummy/BUILD.gn b/kernel/dev/iommu/dummy/BUILD.gn
new file mode 100644
index 0000000..93feb59
--- /dev/null
+++ b/kernel/dev/iommu/dummy/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("dummy") {
+  kernel = true
+  sources = [
+    "dummy_iommu.cpp",
+  ]
+}
diff --git a/kernel/dev/iommu/intel/BUILD.gn b/kernel/dev/iommu/intel/BUILD.gn
new file mode 100644
index 0000000..84cfb3a
--- /dev/null
+++ b/kernel/dev/iommu/intel/BUILD.gn
@@ -0,0 +1,33 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("intel") {
+  kernel = true
+  sources = [
+    "context_table_state.cpp",
+    "device_context.cpp",
+    "domain_allocator.cpp",
+    "intel_iommu.cpp",
+    "iommu_impl.cpp",
+    "iommu_page.cpp",
+    "second_level_pt.cpp",
+  ]
+  deps = [
+    "$zx/kernel/arch/x86/page_tables",
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/pcie",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/user_copy",
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/region-alloc",
+    "$zx/system/ulib/zxcpp",
+  ]
+  public_deps = [
+    # dev/iommu/intel.h has #include <fbl/ref_ptr.h>.
+    "$zx/kernel/lib/fbl:headers",
+  ]
+}
diff --git a/kernel/dev/pcie/BUILD.gn b/kernel/dev/pcie/BUILD.gn
new file mode 100644
index 0000000..0a244f9
--- /dev/null
+++ b/kernel/dev/pcie/BUILD.gn
@@ -0,0 +1,42 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("pcie") {
+  kernel = true
+  sources = [
+    "address_provider/designware.cpp",
+    "address_provider/ecam_region.cpp",
+    "address_provider/mmio.cpp",
+    "address_provider/pio.cpp",
+    "debug.cpp",
+    "pci_config.cpp",
+    "pcie_bridge.cpp",
+    "pcie_bus_driver.cpp",
+    "pcie_caps.cpp",
+    "pcie_device.cpp",
+    "pcie_irqs.cpp",
+    "pcie_quirks.cpp",
+    "pcie_root.cpp",
+    "pcie_upstream_node.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/pci",
+    "$zx/system/ulib/region-alloc",
+    "$zx/system/ulib/zxcpp",
+  ]
+  public_deps = [
+    # <dev/pcie_platform.h> has #include <dev/interrupt.h>.
+    "$zx/kernel/dev/interrupt:headers",
+
+    # <dev/pcie_bus_driver.h> has #include <region-alloc/region-alloc.h>.
+    "$zx/system/ulib/region-alloc:headers",
+  ]
+
+  # TODO(mcgrathr): Say why this is needed.
+  cflags_cc = [ "-Wno-invalid-offsetof" ]
+}
diff --git a/kernel/dev/pdev/BUILD.gn b/kernel/dev/pdev/BUILD.gn
new file mode 100644
index 0000000..f863b4f
--- /dev/null
+++ b/kernel/dev/pdev/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("pdev") {
+  kernel = true
+  sources = [
+    "pdev.cpp",
+  ]
+  public_deps = [
+    # <pdev/interrupt.h> has #include <dev/interrupt.h>.
+    "$zx/kernel/dev/interrupt",
+  ]
+}
diff --git a/kernel/dev/pdev/interrupt/BUILD.gn b/kernel/dev/pdev/interrupt/BUILD.gn
new file mode 100644
index 0000000..e194de6
--- /dev/null
+++ b/kernel/dev/pdev/interrupt/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("interrupt") {
+  sources = [
+    "interrupt.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+  ]
+}
diff --git a/kernel/dev/pdev/power/BUILD.gn b/kernel/dev/pdev/power/BUILD.gn
new file mode 100644
index 0000000..9bf8d3c
--- /dev/null
+++ b/kernel/dev/pdev/power/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("power") {
+  sources = [
+    "power.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/psci",
+  ]
+}
diff --git a/kernel/dev/pdev/uart/BUILD.gn b/kernel/dev/pdev/uart/BUILD.gn
new file mode 100644
index 0000000..0b29521
--- /dev/null
+++ b/kernel/dev/pdev/uart/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("uart") {
+  sources = [
+    "uart.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+  ]
+}
diff --git a/kernel/dev/power/hisi/BUILD.gn b/kernel/dev/power/hisi/BUILD.gn
new file mode 100644
index 0000000..b45220e
--- /dev/null
+++ b/kernel/dev/power/hisi/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("hisi") {
+  sources = [
+    "power.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/power",
+    "$zx/kernel/dev/psci",
+  ]
+}
diff --git a/kernel/dev/psci/BUILD.gn b/kernel/dev/psci/BUILD.gn
new file mode 100644
index 0000000..7a787d6
--- /dev/null
+++ b/kernel/dev/psci/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("psci") {
+  kernel = true
+  sources = [
+    "psci.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/lib/console",
+  ]
+}
diff --git a/kernel/dev/timer/arm_generic/BUILD.gn b/kernel/dev/timer/arm_generic/BUILD.gn
new file mode 100644
index 0000000..f46a18d
--- /dev/null
+++ b/kernel/dev/timer/arm_generic/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("arm_generic") {
+  kernel = true
+  sources = [
+    "arm_generic_timer.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/lib/fixed_point",
+  ]
+}
diff --git a/kernel/dev/uart/amlogic_s905/BUILD.gn b/kernel/dev/uart/amlogic_s905/BUILD.gn
new file mode 100644
index 0000000..aef8713
--- /dev/null
+++ b/kernel/dev/uart/amlogic_s905/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("amlogic_s905") {
+  sources = [
+    "uart.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/uart",
+    "$zx/kernel/lib/cbuf",
+    "$zx/kernel/lib/debuglog",
+  ]
+}
diff --git a/kernel/dev/uart/nxp-imx/BUILD.gn b/kernel/dev/uart/nxp-imx/BUILD.gn
new file mode 100644
index 0000000..64ea1ad
--- /dev/null
+++ b/kernel/dev/uart/nxp-imx/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("nxp-imx") {
+  sources = [
+    "uart.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/uart",
+    "$zx/kernel/lib/cbuf",
+    "$zx/kernel/lib/debuglog",
+  ]
+}
diff --git a/kernel/dev/uart/pl011/BUILD.gn b/kernel/dev/uart/pl011/BUILD.gn
new file mode 100644
index 0000000..ae47cc7
--- /dev/null
+++ b/kernel/dev/uart/pl011/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("pl011") {
+  sources = [
+    "uart.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/uart",
+    "$zx/kernel/lib/cbuf",
+    "$zx/kernel/lib/debuglog",
+  ]
+}
diff --git a/kernel/dev/udisplay/BUILD.gn b/kernel/dev/udisplay/BUILD.gn
new file mode 100644
index 0000000..c921c2b
--- /dev/null
+++ b/kernel/dev/udisplay/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("udisplay") {
+  kernel = true
+  sources = [
+    "udisplay.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/crashlog",
+    "$zx/kernel/lib/debuglog",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/gfx",
+    "$zx/kernel/lib/gfxconsole",
+  ]
+}
diff --git a/kernel/kernel/BUILD.gn b/kernel/kernel/BUILD.gn
new file mode 100644
index 0000000..3abb7dc
--- /dev/null
+++ b/kernel/kernel/BUILD.gn
@@ -0,0 +1,36 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("kernel") {
+  sources = [
+    "cmdline.cpp",
+    "deadline.cpp",
+    "debug.cpp",
+    "dpc.cpp",
+    "event.cpp",
+    "init.cpp",
+    "mp.cpp",
+    "mutex.cpp",
+    "percpu.cpp",
+    "sched.cpp",
+    "thread.cpp",
+    "timer.cpp",
+    "wait.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/counters",
+    "$zx/kernel/lib/debug",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/heap",
+    "$zx/kernel/lib/libc",
+    "$zx/kernel/object",
+    "$zx/kernel/vm",
+    "$zx/system/ulib/explicit-memory",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/kernel/lib/cbuf/BUILD.gn b/kernel/lib/cbuf/BUILD.gn
new file mode 100644
index 0000000..4ff9d09
--- /dev/null
+++ b/kernel/lib/cbuf/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("cbuf") {
+  kernel = true
+  sources = [
+    "cbuf.cpp",
+  ]
+}
diff --git a/kernel/lib/code_patching/BUILD.gn b/kernel/lib/code_patching/BUILD.gn
new file mode 100644
index 0000000..0c5ab1c
--- /dev/null
+++ b/kernel/lib/code_patching/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("code_patching") {
+  kernel = true
+  sources = [
+    "code_patching.cpp",
+  ]
+}
diff --git a/kernel/lib/console/BUILD.gn b/kernel/lib/console/BUILD.gn
new file mode 100644
index 0000000..fe01f36
--- /dev/null
+++ b/kernel/lib/console/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("console") {
+  kernel = true
+  sources = [
+    "console.cpp",
+  ]
+}
diff --git a/kernel/lib/counters/BUILD.gn b/kernel/lib/counters/BUILD.gn
new file mode 100644
index 0000000..df25662
--- /dev/null
+++ b/kernel/lib/counters/BUILD.gn
@@ -0,0 +1,26 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("counters") {
+  kernel = true
+  sources = [
+    "counters.cpp",
+  ]
+  deps = [
+    ":tests",  # TODO: testonly
+    "$zx/kernel/lib/console",
+  ]
+}
+
+source_set("tests") {
+  # TODO: testonly = true
+  sources = [
+    "counters_tests.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/lib/crashlog/BUILD.gn b/kernel/lib/crashlog/BUILD.gn
new file mode 100644
index 0000000..91e47f5
--- /dev/null
+++ b/kernel/lib/crashlog/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("crashlog") {
+  kernel = true
+  sources = [
+    "crashlog.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/version",
+  ]
+}
diff --git a/kernel/lib/crypto/BUILD.gn b/kernel/lib/crypto/BUILD.gn
new file mode 100644
index 0000000..271542e
--- /dev/null
+++ b/kernel/lib/crypto/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("crypto") {
+  kernel = true
+  sources = [
+    "global_prng.cpp",
+    "global_prng_unittest.cpp",
+    "prng.cpp",
+    "prng_unittest.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/unittest",
+    "$zx/system/ulib/explicit-memory",
+    "$zx/third_party/ulib/cryptolib",
+    "$zx/third_party/ulib/uboringssl",
+    "entropy",
+  ]
+  public_deps = [
+    # lib/crypto/prng.h has #include <openssl/sha.h>.
+    "$zx/third_party/ulib/uboringssl:headers",
+
+    # <lib/crypto/entropy/jitterentropy_collector.h> has #include <lib/jitterentropy/jitterentropy.h>.
+    "$zx/third_party/lib/jitterentropy:headers",
+  ]
+}
diff --git a/kernel/lib/crypto/entropy/BUILD.gn b/kernel/lib/crypto/entropy/BUILD.gn
new file mode 100644
index 0000000..a181cd2
--- /dev/null
+++ b/kernel/lib/crypto/entropy/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("entropy") {
+  sources = [
+    "collector.cpp",
+    "collector_unittest.cpp",
+    "hw_rng_collector.cpp",
+    "jitterentropy_collector.cpp",
+    "quality_test.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/hw_rng",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/unittest",
+    "$zx/third_party/lib/jitterentropy",
+  ]
+}
diff --git a/kernel/lib/debug/BUILD.gn b/kernel/lib/debug/BUILD.gn
new file mode 100644
index 0000000..57745e9
--- /dev/null
+++ b/kernel/lib/debug/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("debug") {
+  sources = [
+    "debug.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/hw_rng",
+  ]
+}
diff --git a/kernel/lib/debugcommands/BUILD.gn b/kernel/lib/debugcommands/BUILD.gn
new file mode 100644
index 0000000..6dc3d9e
--- /dev/null
+++ b/kernel/lib/debugcommands/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("debugcommands") {
+  sources = [
+    "debugcommands.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/debug",
+  ]
+}
diff --git a/kernel/lib/debuglog/BUILD.gn b/kernel/lib/debuglog/BUILD.gn
new file mode 100644
index 0000000..e2e70df
--- /dev/null
+++ b/kernel/lib/debuglog/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("debuglog") {
+  kernel = true
+  sources = [
+    "debuglog.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/udisplay:headers",
+    "$zx/kernel/lib/crashlog",
+    "$zx/kernel/lib/version",
+  ]
+}
diff --git a/kernel/lib/fbl/BUILD.gn b/kernel/lib/fbl/BUILD.gn
new file mode 100644
index 0000000..9e3082a
--- /dev/null
+++ b/kernel/lib/fbl/BUILD.gn
@@ -0,0 +1,36 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("fbl") {
+  kernel = true
+  sources = [
+    "arena.cpp",
+  ]
+  deps = [
+    ":tests",
+  ]
+  public_deps = [
+    "$zx/system/ulib/fbl",
+
+    # <fbl/arena.h> has #include <zxcpp/new.h>.
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+source_set("tests") {
+  #TODO: testonly = true
+  visibility = [ ":*" ]
+  sources = [
+    "arena_tests.cpp",
+    "inline_array_tests.cpp",
+    "name_tests.cpp",
+  ]
+
+  deps = [
+    ":headers",
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/lib/fixed_point/BUILD.gn b/kernel/lib/fixed_point/BUILD.gn
new file mode 100644
index 0000000..81d25b5
--- /dev/null
+++ b/kernel/lib/fixed_point/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("fixed_point") {
+  kernel = true
+  sources = [
+    "fixed_point.cpp",
+  ]
+}
diff --git a/kernel/lib/gfx/BUILD.gn b/kernel/lib/gfx/BUILD.gn
new file mode 100644
index 0000000..579be20
--- /dev/null
+++ b/kernel/lib/gfx/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("gfx") {
+  kernel = true
+  sources = [
+    "gfx.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+  ]
+}
diff --git a/kernel/lib/gfxconsole/BUILD.gn b/kernel/lib/gfxconsole/BUILD.gn
new file mode 100644
index 0000000..a995aa4
--- /dev/null
+++ b/kernel/lib/gfxconsole/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("gfxconsole") {
+  kernel = true
+  sources = [
+    "gfxconsole.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/gfx",
+  ]
+  public_deps = [
+    # <lib/gfxconsole.h> has #include <lib/gfx.h>.
+    "$zx/kernel/lib/gfx",
+  ]
+}
diff --git a/kernel/lib/header_tests/BUILD.gn b/kernel/lib/header_tests/BUILD.gn
new file mode 100644
index 0000000..5e188e4
--- /dev/null
+++ b/kernel/lib/header_tests/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("header_tests") {
+  sources = [
+    "pow2_tests.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/lib/heap/BUILD.gn b/kernel/lib/heap/BUILD.gn
new file mode 100644
index 0000000..38952a6
--- /dev/null
+++ b/kernel/lib/heap/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("heap") {
+  kernel = true
+  sources = [
+    "heap_wrapper.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "cmpctmalloc",
+  ]
+}
diff --git a/kernel/lib/heap/cmpctmalloc/BUILD.gn b/kernel/lib/heap/cmpctmalloc/BUILD.gn
new file mode 100644
index 0000000..fdc941d
--- /dev/null
+++ b/kernel/lib/heap/cmpctmalloc/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("cmpctmalloc") {
+  kernel = true
+  sources = [
+    "cmpctmalloc.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/counters",
+  ]
+}
diff --git a/kernel/lib/hypervisor/BUILD.gn b/kernel/lib/hypervisor/BUILD.gn
new file mode 100644
index 0000000..7c63d31
--- /dev/null
+++ b/kernel/lib/hypervisor/BUILD.gn
@@ -0,0 +1,29 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("hypervisor") {
+  kernel = true
+  sources = [
+    "cpu.cpp",
+    "guest_physical_address_space.cpp",
+    "hypervisor_unittest.cpp",
+    "ktrace.cpp",
+    "trap_map.cpp",
+  ]
+  deps = [
+    "$zx/kernel/arch/$zircon_cpu/hypervisor",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/unittest",
+    "$zx/system/ulib/bitmap",
+  ]
+  public_deps = [
+    # <hypervisor/trap_map.h> has #include <object/port_dispatcher.h>.
+    "$zx/kernel/object:headers",
+
+    # <hypervisor/id_allocator.h> has #include <bitmap/raw-bitmap.h>.
+    "$zx/system/ulib/bitmap:headers",
+  ]
+}
diff --git a/kernel/lib/io/BUILD.gn b/kernel/lib/io/BUILD.gn
new file mode 100644
index 0000000..650423b
--- /dev/null
+++ b/kernel/lib/io/BUILD.gn
@@ -0,0 +1,15 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("io") {
+  kernel = true
+  sources = [
+    "console.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/debuglog",
+  ]
+}
diff --git a/kernel/lib/ktrace/BUILD.gn b/kernel/lib/ktrace/BUILD.gn
new file mode 100644
index 0000000..2f74751
--- /dev/null
+++ b/kernel/lib/ktrace/BUILD.gn
@@ -0,0 +1,31 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/syscalls/abigen.gni")
+
+source_set("ktrace") {
+  sources = [
+    "ktrace.cpp",
+  ]
+  include_dirs = [ target_gen_dir ]
+  deps = [
+    ":ktrace-info",
+    "$zx/kernel/lib/hypervisor",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
+
+abigen("ktrace-info") {
+  visibility = [ ":*" ]
+  gen = [
+    {
+      args = [ "-trace" ]
+      outputs = [
+        "$target_gen_dir/zircon/syscall-ktrace-info.inc",
+      ]
+    },
+  ]
+}
diff --git a/kernel/lib/libc/BUILD.gn b/kernel/lib/libc/BUILD.gn
new file mode 100644
index 0000000..6968937
--- /dev/null
+++ b/kernel/lib/libc/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("libc") {
+  kernel = true
+  sources = [
+    "atexit.c",
+    "atoi.c",
+    "bsearch.c",
+    "cxa_atexit.cpp",
+    "eabi.c",
+    "errno.c",
+    "printf.c",
+    "qsort.c",
+    "rand.c",
+    "stdio.c",
+    "strtol.c",
+    "strtoll.c",
+  ]
+  deps = [
+    ":ctype",
+    "$zx/kernel/lib/heap",
+    "$zx/kernel/lib/io",
+    "string",
+  ]
+  public_deps = [
+    # stdio.h has #include <lib/io.h>.
+    "$zx/kernel/lib/io:headers",
+
+    # malloc.h has #include <lib/heap.h>.
+    "$zx/kernel/lib/heap:headers",
+  ]
+
+  if (toolchain.environment == "kernel") {
+    # Avoid circularity.
+    configs -= [ get_label_info(":headers", "label_no_toolchain") ]
+  }
+}
+
+source_set("ctype") {
+  sources = [
+    "ctype.c",
+  ]
+}
diff --git a/kernel/lib/libc/string/BUILD.gn b/kernel/lib/libc/string/BUILD.gn
new file mode 100644
index 0000000..b8badb1
--- /dev/null
+++ b/kernel/lib/libc/string/BUILD.gn
@@ -0,0 +1,36 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("string") {
+  sources = [
+    "memchr.c",
+    "memcmp.c",
+    "memmove.c",
+    "strcat.c",
+    "strchr.c",
+    "strcmp.c",
+    "strcoll.c",
+    "strcpy.c",
+    "strlcat.c",
+    "strlcpy.c",
+    "strlen.c",
+    "strncat.c",
+    "strncmp.c",
+    "strncpy.c",
+    "strnicmp.c",
+    "strnlen.c",
+    "strpbrk.c",
+    "strrchr.c",
+    "strspn.c",
+    "strstr.c",
+    "strtok.c",
+    "strxfrm.c",
+  ]
+  deps = [
+    "$zx/kernel/lib/libc:ctype",
+    "arch/$zircon_cpu",
+  ]
+}
diff --git a/kernel/lib/libc/string/arch/arm64/BUILD.gn b/kernel/lib/libc/string/arch/arm64/BUILD.gn
new file mode 100644
index 0000000..0dd1d27
--- /dev/null
+++ b/kernel/lib/libc/string/arch/arm64/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("arm64") {
+  sources = [
+    "$zx/third_party/lib/cortex-strings/src/aarch64/memcpy.S",
+    "$zx/third_party/lib/cortex-strings/no-neon/src/aarch64/memset.S",
+  ]
+}
diff --git a/kernel/lib/libc/string/arch/x86/BUILD.gn b/kernel/lib/libc/string/arch/x86/BUILD.gn
new file mode 100644
index 0000000..697d795
--- /dev/null
+++ b/kernel/lib/libc/string/arch/x86/BUILD.gn
@@ -0,0 +1,28 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("x86") {
+  sources = [
+    "memcpy.S",
+    "memset.S",
+    "selector.cpp",
+  ]
+  deps = [
+    ":tests",
+    "$zx/kernel/lib/code_patching",
+  ]
+}
+
+source_set("tests") {
+  # TODO(mcgrathr): Make this optional somehow and enable testonly taint.
+  #testonly = true
+  sources = [
+    "tests.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/lib/lockdep/BUILD.gn b/kernel/lib/lockdep/BUILD.gn
new file mode 100644
index 0000000..ee68179
--- /dev/null
+++ b/kernel/lib/lockdep/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("lockdep") {
+  sources = [
+    "lock_dep.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/version",
+  ]
+  public_deps = [
+    "$zx/system/ulib/lockdep",
+  ]
+}
diff --git a/kernel/lib/memory_limit/BUILD.gn b/kernel/lib/memory_limit/BUILD.gn
new file mode 100644
index 0000000..3739c88
--- /dev/null
+++ b/kernel/lib/memory_limit/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("memory_limit") {
+  kernel = true
+  sources = [
+    "memory_limit.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/fbl",
+    "$zx/system/ulib/pretty",
+  ]
+}
diff --git a/kernel/lib/mtrace/BUILD.gn b/kernel/lib/mtrace/BUILD.gn
new file mode 100644
index 0000000..388a8a4
--- /dev/null
+++ b/kernel/lib/mtrace/BUILD.gn
@@ -0,0 +1,13 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("mtrace") {
+  sources = [
+    "mtrace-ipt.cpp",
+    "mtrace-pmu.cpp",
+    "mtrace.cpp",
+  ]
+}
diff --git a/kernel/lib/oom/BUILD.gn b/kernel/lib/oom/BUILD.gn
new file mode 100644
index 0000000..4225408
--- /dev/null
+++ b/kernel/lib/oom/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("oom") {
+  kernel = true
+  sources = [
+    "oom.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/system/ulib/pretty",
+  ]
+}
diff --git a/kernel/lib/pci/BUILD.gn b/kernel/lib/pci/BUILD.gn
new file mode 100644
index 0000000..23454c3
--- /dev/null
+++ b/kernel/lib/pci/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("pci") {
+  kernel = true
+  sources = [
+    "pio.cpp",
+  ]
+}
diff --git a/kernel/lib/pow2_range_allocator/BUILD.gn b/kernel/lib/pow2_range_allocator/BUILD.gn
new file mode 100644
index 0000000..87115f0
--- /dev/null
+++ b/kernel/lib/pow2_range_allocator/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("pow2_range_allocator") {
+  kernel = true
+  sources = [
+    "pow2_range_allocator.cpp",
+  ]
+}
diff --git a/kernel/lib/topology/BUILD.gn b/kernel/lib/topology/BUILD.gn
new file mode 100644
index 0000000..fbbd945
--- /dev/null
+++ b/kernel/lib/topology/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+library("topology") {
+  host = true
+  kernel = true
+  sources = [
+    "system-topology.cpp",
+  ]
+  deps = [
+    ":test",
+    "$zx/system/ulib/fbl",
+  ]
+}
+
+source_set("test") {
+  # TODO: testonly = true
+  sources = [
+    "system-topology_test.cpp",
+  ]
+  include_dirs = [ "include" ]
+  deps = [
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/lib/unittest/BUILD.gn b/kernel/lib/unittest/BUILD.gn
new file mode 100644
index 0000000..ac6d031
--- /dev/null
+++ b/kernel/lib/unittest/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("unittest") {
+  kernel = true
+  sources = [
+    "unittest.cpp",
+    "user_memory.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+  ]
+}
diff --git a/kernel/lib/user_copy/BUILD.gn b/kernel/lib/user_copy/BUILD.gn
new file mode 100644
index 0000000..36d4321
--- /dev/null
+++ b/kernel/lib/user_copy/BUILD.gn
@@ -0,0 +1,9 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+config("user_copy") {
+  include_dirs = [ "include" ]
+}
diff --git a/kernel/lib/userboot/BUILD.gn b/kernel/lib/userboot/BUILD.gn
new file mode 100644
index 0000000..de0a6eb
--- /dev/null
+++ b/kernel/lib/userboot/BUILD.gn
@@ -0,0 +1,56 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/lib/vdso/rodso.gni")
+
+source_set("userboot") {
+  sources = [
+    "userboot.cpp",
+  ]
+  include_dirs = [ target_gen_dir ]
+  deps = [
+    ":gen-userboot-code-header",
+    ":image",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/vdso",
+  ]
+}
+
+# The userboot-code.h generated header file tells the userboot.cpp code
+# where the segment boundaries and entry points are.
+rodso_code_header("gen-userboot-code-header") {
+  visibility = [ ":*" ]
+  name = "USERBOOT"
+  outputs = [
+    "$target_gen_dir/userboot-code.h",
+  ]
+  deps = [
+    # TODO(mcgrathr): mv //system/core/userboot ./user
+    "$zx/system/core/userboot",
+  ]
+}
+
+# The generated header is also needed to tell .incbin how much of the
+# image file to embed (see $zx/kernel/lib/vdso/include/lib/rodso-asm.h).
+source_set("image") {
+  visibility = [ ":*" ]
+  sources = [
+    "userboot-image.S",
+  ]
+  include_dirs = [ target_gen_dir ]
+  deps = [
+    ":gen-userboot-code-header",
+    "$zx/kernel/lib/vdso",
+  ]
+
+  # userboot-image.S includes the userboot contents and so must be
+  # reassembled when that changes.  We can't express that in $inputs
+  # here because we don't know the exact name of the file since that
+  # depends on the toolchain selected.  Fortunately, we already depend
+  # on the generated userboot-code.h header, which is always
+  # regenerated whenever the userboot binary itself changes.  So this
+  # indirect dependency is sufficient.
+}
diff --git a/kernel/lib/vdso/BUILD.gn b/kernel/lib/vdso/BUILD.gn
new file mode 100644
index 0000000..c118f55
--- /dev/null
+++ b/kernel/lib/vdso/BUILD.gn
@@ -0,0 +1,115 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/syscalls/abigen.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+import("rodso.gni")
+
+library("vdso") {
+  kernel = true
+  sources = [
+    "vdso-image.S",
+    "vdso.cpp",
+  ]
+
+  # vdso-image.S includes the vDSO (aka libzircon.so) contents and so must
+  # be reassembled when that changes.  But listing $zx/system/ulib/zircon
+  # in deps here will make GN try to link libzircon.so into the kernel.
+  # Fortunately, vdso-image.S also includes the "vdso-code.h" header file
+  # and normal depfile magic will discover that.  This header file is
+  # generated (below) from libzircon.so itself, so it will always be
+  # touched when libzircon.so has been touched and thus ensure vdso-image.S
+  # is reassembled with the new vDSO contents.
+  if (is_kernel) {
+    deps = [
+      ":gen-categories",
+      ":rodso",
+      ":vdso-code-header",
+      "$zx/kernel/lib/version:config-buildid-header",
+      "$zx/kernel/syscalls",
+      "$zx/system/ulib/fbl",
+    ]
+    public_deps = [
+      ":vdso-valid-sysret",
+
+      # <lib/rodso.h> has #include <object/handle.h>.
+      "$zx/kernel/object",
+    ]
+  }
+}
+
+source_set("rodso") {
+  sources = [
+    "rodso.cpp",
+  ]
+  deps = [
+    ":headers",
+  ]
+}
+
+config("vdso-valid-sysret") {
+  include_dirs = [ target_gen_dir ]
+  deps = [
+    ":gen-vdso-valid-sysret",
+  ]
+}
+
+action("gen-vdso-valid-sysret") {
+  visibility = [ ":*" ]
+
+  # TODO(mcgrathr): Move the script to this dir.
+  script = "$zx/scripts/gen-vdso-valid-sysret.sh"
+  sources = [
+    "$target_gen_dir/vdso-code.h",
+  ]
+  outputs = [
+    "$target_gen_dir/vdso-valid-sysret.h",
+  ]
+  args = rebase_path(sources + outputs)
+  deps = [
+    ":gen-vdso-code-header",
+  ]
+}
+
+# Redirect to the userland vDSO shared library target.
+select_toolchain("userland") {
+  environment_label = "$zx/public/gn/toolchain:user"
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+config("vdso-code-header") {
+  include_dirs = [ target_gen_dir ]
+  deps = [
+    ":gen-vdso-code-header",
+  ]
+}
+
+# This generated header file tells the vdso.cpp code
+# where the segment boundaries and entry points are.
+rodso_code_header("gen-vdso-code-header") {
+  visibility = [ ":*" ]
+  name = "VDSO"
+  outputs = [
+    "$target_gen_dir/vdso-code.h",
+  ]
+  deps = [
+    ":userland",
+  ]
+}
+
+abigen("gen-categories") {
+  visibility = [ ":*" ]
+  gen = [
+    {
+      args = [ "-category" ]
+      outputs = [
+        "$target_gen_dir/zircon/syscall-category.inc",
+      ]
+    },
+  ]
+}
diff --git a/kernel/lib/vdso/rodso.gni b/kernel/lib/vdso/rodso.gni
new file mode 100644
index 0000000..3477fe7
--- /dev/null
+++ b/kernel/lib/vdso/rodso.gni
@@ -0,0 +1,73 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/public/gn/toolchain/c_utils.gni")
+
+template("link_output_rspfile") {
+  generated_file(target_name) {
+    forward_variables_from(invoker,
+                           [
+                             "deps",
+                             "outputs",
+                             "testonly",
+                             "visibility",
+                           ])
+    data_keys = [ "link_output" ]
+    walk_keys = [ "link_barrier" ]
+    output_conversion = "list lines"
+  }
+}
+
+template("rodso_code_header") {
+  main_target_name = target_name
+  rspfile_target_name = "$main_target_name._rsp"
+  rspfile = "$target_gen_dir/$target_name.rsp"
+
+  link_output_rspfile(rspfile_target_name) {
+    forward_variables_from(invoker,
+                           [
+                             "deps",
+                             "testonly",
+                           ])
+    outputs = [
+      rspfile,
+    ]
+    visibility = [ ":$main_target_name" ]
+  }
+
+  toolchain_utils_action(main_target_name) {
+    forward_variables_from(invoker,
+                           [
+                             "testonly",
+                             "visibility",
+                           ])
+
+    deps = [
+      ":$rspfile_target_name",
+    ]
+    outputs = invoker.outputs
+    assert(outputs == [ outputs[0] ],
+           "rodso_code_header() outputs must have exactly one element")
+    depfile = "${outputs[0]}.d"
+
+    # TODO(mcgrathr): Move the script to this dir.
+    script = "$zx/scripts/gen-rodso-code.sh"
+    utils = [
+      "nm",
+      "readelf",
+    ]
+    sources = [
+      rspfile,
+    ]
+    args = [
+      "--depfile",
+      rebase_path(depfile, root_build_dir),
+      rebase_path(outputs[0], root_build_dir),
+      invoker.name,
+      "@" + rebase_path(rspfile, root_build_dir),
+    ]
+  }
+}
diff --git a/kernel/lib/version/BUILD.gn b/kernel/lib/version/BUILD.gn
new file mode 100644
index 0000000..27311cf
--- /dev/null
+++ b/kernel/lib/version/BUILD.gn
@@ -0,0 +1,61 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+declare_args() {
+  # Version string embedded in the kernel for `zx_system_get_version`.
+  # If set to the default "", a string is generated based on the
+  # Zircon git revision of the checkout.
+  kernel_version_string = ""
+}
+
+# The version string depends solely on the source and doesn't vary across
+# machines or toolchains, so generate it only once.
+if (current_toolchain == default_toolchain) {
+  action("gen-config-buildid-header") {
+    visibility = [ ":*" ]
+    outputs = [
+      "$target_gen_dir/config-buildid.h",
+    ]
+    if (kernel_version_string != "") {
+      script = "/usr/bin/touch"
+    } else {
+      sources = [
+        "$zx/.git/HEAD",
+        "$zx/.git/index",
+      ]
+      script = "buildid.sh"
+    }
+    args = rebase_path(outputs, root_build_dir)
+  }
+} else {
+  library("version") {
+    kernel = true
+    sources = [
+      "version.cpp",
+    ]
+    defines = [
+      "ARCH=\"$zircon_cpu\"",
+      "PROJECT=\"$current_cpu\"",
+      "PLATFORM=\"XXX\"",
+      "TARGET=\"XXX\"",
+    ]
+    deps = [
+      ":config-buildid-header",
+      "$zx/kernel/lib/console",
+    ]
+  }
+
+  config("config-buildid-header") {
+    if (kernel_version_string != "") {
+      defines = [ "BUILDID='\"$kernel_version_string\"'" ]
+    } else {
+      deps = [
+        ":gen-config-buildid-header($default_toolchain)",
+      ]
+      include_dirs = [ get_label_info(deps[0], "target_gen_dir") ]
+    }
+  }
+}
diff --git a/kernel/lib/version/buildid.sh b/kernel/lib/version/buildid.sh
index be143e0..4b384bc 100755
--- a/kernel/lib/version/buildid.sh
+++ b/kernel/lib/version/buildid.sh
@@ -18,12 +18,18 @@
 fi
 
 if [ $# -eq 1 ]; then
-  cat > "$1" <<END
+  cat > "$1.new" <<END
 #ifndef __BUILDID_H
 #define __BUILDID_H
-#define ${GIT_REV}
+#define BUILDID "${GIT_REV}"
 #endif
 END
+  # Update the existing file only if it's changed.
+  if [ -r "$1" ] && cmp -s "$1.new" "$1"; then
+    rm -f "$1.new"
+  else
+    mv -f "$1.new" "$1"
+  fi
 else
     echo "${GIT_REV}"
 fi
diff --git a/kernel/lib/watchdog/BUILD.gn b/kernel/lib/watchdog/BUILD.gn
new file mode 100644
index 0000000..a8c5776
--- /dev/null
+++ b/kernel/lib/watchdog/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("watchdog") {
+  kernel = true
+  sources = [
+    "watchdog.c",
+  ]
+}
diff --git a/kernel/object/BUILD.gn b/kernel/object/BUILD.gn
new file mode 100644
index 0000000..577479d
--- /dev/null
+++ b/kernel/object/BUILD.gn
@@ -0,0 +1,99 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("object") {
+  kernel = true
+  sources = [
+    "buffer_chain.cpp",
+    "bus_transaction_initiator_dispatcher.cpp",
+    "channel_dispatcher.cpp",
+    "diagnostics.cpp",
+    "dispatcher.cpp",
+    "event_dispatcher.cpp",
+    "event_pair_dispatcher.cpp",
+    "exception.cpp",
+    "excp_port.cpp",
+    "fifo_dispatcher.cpp",
+    "futex_context.cpp",
+    "futex_node.cpp",
+    "glue.cpp",
+    "guest_dispatcher.cpp",
+    "handle.cpp",
+    "interrupt_dispatcher.cpp",
+    "interrupt_event_dispatcher.cpp",
+    "iommu_dispatcher.cpp",
+    "job_dispatcher.cpp",
+    "job_policy.cpp",
+    "log_dispatcher.cpp",
+    "mbuf.cpp",
+    "message_packet.cpp",
+    "pager_dispatcher.cpp",
+    "pci_device_dispatcher.cpp",
+    "pci_interrupt_dispatcher.cpp",
+    "pinned_memory_token_dispatcher.cpp",
+    "port_dispatcher.cpp",
+    "process_dispatcher.cpp",
+    "profile_dispatcher.cpp",
+    "resource.cpp",
+    "resource_dispatcher.cpp",
+    "semaphore.cpp",
+    "socket_dispatcher.cpp",
+    "suspend_token_dispatcher.cpp",
+    "thread_dispatcher.cpp",
+    "timer_dispatcher.cpp",
+    "vcpu_dispatcher.cpp",
+    "virtual_interrupt_dispatcher.cpp",
+    "vm_address_region_dispatcher.cpp",
+    "vm_object_dispatcher.cpp",
+    "wait_state_observer.cpp",
+  ]
+  deps = [
+    ":tests",
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/iommu/dummy",
+    "$zx/kernel/dev/pcie",
+    "$zx/kernel/dev/udisplay",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/counters",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/hypervisor",
+    "$zx/kernel/lib/oom",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/region-alloc",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "$zx/kernel/dev/iommu/intel" ]
+  }
+  public_deps = [
+    # <object/pci_device_dispatcher.h> has #include <dev/pci_common.h>
+    "$zx/kernel/dev/pcie:headers",
+
+    # <object/log_dispatcher.h> has #include <lib/debuglog.h>.
+    "$zx/kernel/lib/debuglog:headers",
+
+    # <object/resource_dispatcher.h> has #include <region-alloc/region-alloc.h>.
+    "$zx/system/ulib/region-alloc:headers",
+
+    # <object/vcpu_dispatcher.h> has #include <hypervisor/interrupt_tracker.h>.
+    #"$zx/kernel/lib/hypervisor:headers",
+  ]
+}
+
+source_set("tests") {
+  # TODO: testonly = true
+  sources = [
+    "buffer_chain_tests.cpp",
+    "job_policy_tests.cpp",
+    "mbuf_tests.cpp",
+    "message_packet_tests.cpp",
+    "state_tracker_tests.cpp",
+  ]
+  deps = [
+    ":headers",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/kernel/params.gni b/kernel/params.gni
new file mode 100644
index 0000000..5dcedfd
--- /dev/null
+++ b/kernel/params.gni
@@ -0,0 +1,46 @@
+declare_args() {
+  # Maximum number of CPUs the kernel will run on (others will be ignored).
+  smp_max_cpus = 16
+
+  if (current_cpu == "arm64") {
+    # Maximum number of CPU clusters the kernel will support.
+    # The kernel will panic at boot on hardware with more clusters.
+    smp_max_clusters = 2
+  }
+
+  # Virtual address where the kernel is mapped statically.  This is the
+  # base of addresses that appear in the kernel symbol table.  At runtime
+  # KASLR relocation processing adjusts addresses in memory from this base
+  # to the actual runtime virtual address.
+  if (current_cpu == "arm64") {
+    kernel_base = "0xffffffff00000000"
+  } else if (current_cpu == "x64") {
+    kernel_base = "0xffffffff80100000"  # Has KERNEL_LOAD_OFFSET baked into it.
+  }
+
+  # Virtual address where the kernel address space begins.
+  # Below this is the user address space.
+  if (current_cpu == "arm64") {
+    kernel_aspace_base = "0xffff000000000000"
+  } else if (current_cpu == "x64") {
+    kernel_aspace_base = "0xffffff8000000000UL"  # -512GB
+  }
+
+  # Enable kernel lock dependency tracking.
+  enable_lock_dep = false
+
+  # Enable userspace PCI and disable kernel PCI.
+  enable_user_pci = false
+
+  # Extra macro definitions for kernel code, e.g. "DISABLE_KASLR",
+  # "ENABLE_KERNEL_LL_DEBUG".
+  kernel_extra_defines = []
+}
+
+declare_args() {
+  # Enable kernel lock dependency tracking tests.  By default this is
+  # enabled when tracking is enabled, but can also be eanbled independently
+  # to assess whether the tests build and *fail correctly* when lockdep is
+  # disabled.
+  enable_lock_dep_tests = enable_lock_dep
+}
diff --git a/kernel/platform/BUILD.gn b/kernel/platform/BUILD.gn
new file mode 100644
index 0000000..2025755
--- /dev/null
+++ b/kernel/platform/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("platform") {
+  sources = [
+    "debug.cpp",
+    "init.cpp",
+    "power.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/kernel/platform/generic-arm/BUILD.gn b/kernel/platform/generic-arm/BUILD.gn
new file mode 100644
index 0000000..e72dbef
--- /dev/null
+++ b/kernel/platform/generic-arm/BUILD.gn
@@ -0,0 +1,38 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/params.gni")
+
+source_set("generic-arm") {
+  sources = [
+    "platform.cpp",
+  ]
+  defines = [ "SMP_CPU_MAX_CLUSTERS=$smp_max_clusters" ]
+  deps = [
+    "$zx/kernel/dev/hdcp/amlogic_s912",
+    "$zx/kernel/dev/hw_rng",
+    "$zx/kernel/dev/interrupt/arm_gic/common",
+    "$zx/kernel/dev/interrupt/arm_gic/v2",
+    "$zx/kernel/dev/interrupt/arm_gic/v3",
+    "$zx/kernel/dev/pcie",
+    "$zx/kernel/dev/pdev",
+    "$zx/kernel/dev/pdev/power",
+    "$zx/kernel/dev/power/hisi",
+    "$zx/kernel/dev/psci",
+    "$zx/kernel/dev/timer/arm_generic",
+    "$zx/kernel/dev/uart/amlogic_s905",
+    "$zx/kernel/dev/uart/nxp-imx",
+    "$zx/kernel/dev/uart/pl011",
+    "$zx/kernel/lib/cbuf",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/lockdep",
+    "$zx/kernel/lib/memory_limit",
+    "$zx/kernel/lib/topology",
+    "$zx/kernel/object",
+    "$zx/system/ulib/libzbi",
+  ]
+}
diff --git a/kernel/platform/pc/BUILD.gn b/kernel/platform/pc/BUILD.gn
new file mode 100644
index 0000000..1e5df4f
--- /dev/null
+++ b/kernel/platform/pc/BUILD.gn
@@ -0,0 +1,46 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("pc") {
+  kernel = true
+  sources = [
+    "acpi.cpp",
+    "console.cpp",
+    "debug.cpp",
+    "hpet.cpp",
+    "interrupts.cpp",
+    "keyboard.cpp",
+    "memory.cpp",
+    "pcie_quirks.cpp",
+    "pic.cpp",
+    "platform.cpp",
+    "platform_pcie.cpp",
+    "power.cpp",
+    "smbios.cpp",
+    "timer.cpp",
+  ]
+  deps = [
+    "$zx/kernel/dev/interrupt",
+    "$zx/kernel/dev/pcie",
+    "$zx/kernel/lib/cbuf",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/fixed_point",
+    "$zx/kernel/lib/gfxconsole",
+    "$zx/kernel/lib/lockdep",
+    "$zx/kernel/lib/memory_limit",
+    "$zx/kernel/lib/pow2_range_allocator",
+    "$zx/kernel/lib/version",
+    "$zx/system/ulib/libzbi",
+    "$zx/system/ulib/smbios",
+    "$zx/third_party/lib/acpica",
+    "$zx/third_party/ulib/cksum",
+  ]
+  public_deps = [
+    # <platform/pc/acpi.h> has #include <acpica/acpi.h>.
+    "$zx/third_party/lib/acpica:headers",
+  ]
+}
diff --git a/kernel/syscalls/BUILD.gn b/kernel/syscalls/BUILD.gn
new file mode 100644
index 0000000..87e8065
--- /dev/null
+++ b/kernel/syscalls/BUILD.gn
@@ -0,0 +1,114 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("abigen.gni")
+
+source_set("syscalls") {
+  sources = [
+    "channel.cpp",
+    "ddk.cpp",
+    "ddk_${zircon_cpu}.cpp",
+    "ddk_pci.cpp",
+    "debug.cpp",
+    "exceptions.cpp",
+    "fifo.cpp",
+    "futex.cpp",
+    "handle_ops.cpp",
+    "hypervisor.cpp",
+    "object.cpp",
+    "object_wait.cpp",
+    "pager.cpp",
+    "port.cpp",
+    "profile.cpp",
+    "resource.cpp",
+    "socket.cpp",
+    "system.cpp",
+    "system_${zircon_cpu}.cpp",
+    "task.cpp",
+    "test.cpp",
+    "timer.cpp",
+    "vmar.cpp",
+    "vmo.cpp",
+    "zircon.cpp",
+  ]
+  deps = [
+    ":dispatch",
+    ":syscall-abi",
+    "$zx/kernel/dev/udisplay",
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/counters",
+    "$zx/kernel/lib/crypto",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/gfxconsole",
+    "$zx/kernel/lib/ktrace",
+    "$zx/kernel/lib/mtrace",
+    "$zx/kernel/lib/pci",
+    "$zx/kernel/lib/user_copy",
+    "$zx/kernel/object",
+    "$zx/system/ulib/explicit-memory",
+    "$zx/system/ulib/libzbi",
+    "$zx/system/ulib/region-alloc",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "$zx/kernel/platform/pc" ]
+  }
+}
+
+# Only this file depends on vdso-valid-sysret.h.
+source_set("dispatch") {
+  sources = [
+    "syscalls.cpp",
+  ]
+  deps = [
+    ":syscall-abi",
+    "$zx/kernel/lib/vdso:headers",
+  ]
+}
+
+config("syscall-abi") {
+  visibility = [
+    ":*",
+    "$zx/kernel/arch/$zircon_cpu:*",
+    "$zx/system/ulib/zircon:*",
+    "$zx/system/utest/core/bad-syscall:*",
+  ]
+
+  include_dirs = [ target_gen_dir ]
+
+  deps = [
+    ":generate-syscall-abi",
+  ]
+}
+
+abigen("generate-syscall-abi") {
+  visibility = [ ":syscall-abi" ]
+  gen = [
+    {
+      args = [ "-numbers" ]
+      outputs = [
+        "$target_gen_dir/zircon/zx-syscall-numbers.h",
+      ]
+    },
+    {
+      args = [ "-kernel-header" ]
+      outputs = [
+        "$target_gen_dir/zircon/syscall-definitions.h",
+      ]
+    },
+    {
+      args = [ "-kernel-wrappers" ]
+      outputs = [
+        "$target_gen_dir/zircon/syscall-kernel-wrappers.inc",
+      ]
+    },
+    {
+      args = [ "-kernel-branch" ]
+      outputs = [
+        "$target_gen_dir/zircon/syscall-kernel-branches.S",
+      ]
+    },
+  ]
+}
diff --git a/kernel/syscalls/abigen.gni b/kernel/syscalls/abigen.gni
new file mode 100644
index 0000000..df789c8
--- /dev/null
+++ b/kernel/syscalls/abigen.gni
@@ -0,0 +1,31 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/public/gn/host_tool_action.gni")
+
+template("abigen") {
+  host_tool_action(target_name) {
+    forward_variables_from(invoker,
+                           [
+                             "testonly",
+                             "visibility",
+                           ])
+
+    tool = "$zx/system/host/abigen"
+
+    outputs = []
+    args = []
+    foreach(gen, invoker.gen) {
+      outputs += gen.outputs
+      args += gen.args + rebase_path(gen.outputs, root_build_dir)
+    }
+
+    sources = [
+      "$zx/system/public/zircon/syscalls.abigen",
+    ]
+    args += rebase_path(sources, root_build_dir)
+  }
+}
diff --git a/kernel/target/BUILD.gn b/kernel/target/BUILD.gn
new file mode 100644
index 0000000..29b5b41
--- /dev/null
+++ b/kernel/target/BUILD.gn
@@ -0,0 +1,11 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("target") {
+  sources = [
+    "init.cpp",
+  ]
+}
diff --git a/kernel/target/arm64/boot-shim/BUILD.gn b/kernel/target/arm64/boot-shim/BUILD.gn
new file mode 100644
index 0000000..dff70c3
--- /dev/null
+++ b/kernel/target/arm64/boot-shim/BUILD.gn
@@ -0,0 +1,139 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/public/gn/toolchain/c_utils.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+assert(current_cpu == "arm64")
+
+# The boot shims need to be compiled in the special environment for running
+# in physical memory with the MMU disabled.
+if (toolchain.environment == "physmem") {
+  source_set("common") {
+    visibility = [ ":*" ]
+    sources = [
+      "boot-shim.S",
+      "debug.c",
+      "devicetree.c",
+      "util.c",
+    ]
+    deps = [
+      "$zx/kernel/lib/libc/string",
+    ]
+    public_deps = [
+      "$zx/system/ulib/ddk:headers",
+      "$zx/system/ulib/libzbi",
+    ]
+  }
+}
+
+template("boot_shim") {
+  board = target_name
+
+  if (toolchain.environment == "physmem") {
+    executable("${board}-boot-shim") {
+      output_extension = "elf"
+
+      deps = [
+        ":common",
+      ]
+      sources = [
+        "${board}-uart.c",
+        "boot-shim.c",
+      ]
+      defines = [ "KERNEL_ALIGN=0x10000" ]
+
+      # TODO(mcgrathr): Move these to ./$board-config.h and use a -D.
+      include_dirs = [ "$zx/kernel/target/arm64/board/$board" ]
+      inputs = [
+        "boot-shim.ld",
+      ]
+      ldflags = [
+        "-Wl,-T," + rebase_path("boot-shim.ld", root_build_dir),
+        "-Wl,-defsym," + defines[0],
+      ]
+    }
+    image_binary(board) {
+      forward_variables_from(invoker,
+                             [
+                               "testonly",
+                               "visibility",
+                             ])
+      deps = [
+        ":${board}-boot-shim",
+      ]
+      outputs = [
+        "$root_out_dir/${board}-boot-shim.bin",
+      ]
+      sources = [
+        "$target_out_dir/${board}-boot-shim.elf",
+      ]
+      metadata = {
+        images = [
+          {
+            name = "${board}-boot-shim"
+            path = rebase_path(outputs[0], root_build_dir)
+            type = "bin"  # TODO(mcgrathr): ???
+          },
+        ]
+        if (board == "qemu") {
+          images += [
+            {
+              name = "qemu-kernel"
+              type = "kernel"
+              path = rebase_path(outputs[0], root_build_dir)
+            },
+          ]
+        }
+
+        # TODO: later
+        bootimage_inputs = outputs
+        bootimage_script = [ invoker.script ]
+        bootimage_args = invoker.args + rebase_path(outputs, root_build_dir)
+      }
+    }
+  } else {
+    select_toolchain(board) {
+      environment_label = "$zx/kernel/arch/arm64:physmem"
+      deps = [
+        ":$board",
+      ]
+    }
+    not_needed(invoker, "*")
+  }
+}
+
+boot_shim("hikey960") {
+  script = "..."  # TODO: cat $1 $2 | gzip -9n > $3
+  args = []
+}
+
+boot_shim("imx8mevk") {
+  script = "..."  # TODO: avb, mkbootimg
+  args = []
+}
+
+boot_shim("imx8mmevk") {
+  script = "..."  # TODO: avb, mkbootimg
+  args = []
+}
+
+boot_shim("mt8167s_ref") {
+  script = "..."  # TODO: avb, append
+  args = []
+}
+
+boot_shim("qemu") {
+  # The "image" for the QEMU "board" is just a response file pointing to
+  # the shim, which acts as QEMU's kernel, with the ZBI as initrd.
+  script = "..."  # TODO: echo "-kernel $1 -initrd $2" > $3
+  args = []
+}
+
+boot_shim("sherlock") {
+  script = "..."  # TODO: kdtb
+  args = []
+}
diff --git a/kernel/target/pc/BUILD.gn b/kernel/target/pc/BUILD.gn
new file mode 100644
index 0000000..c3149fd
--- /dev/null
+++ b/kernel/target/pc/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+group("pc") {
+  deps = [
+    "$zx/kernel/dev/intel_rng",
+    "$zx/kernel/platform/pc",
+  ]
+
+  # Also build the Multiboot trampoline to support legacy boot loaders.
+  data_deps = [
+    "multiboot",
+  ]
+
+  metadata = {
+    sdk_board_list = [ "pc" ]
+  }
+}
diff --git a/kernel/target/pc/multiboot/BUILD.gn b/kernel/target/pc/multiboot/BUILD.gn
new file mode 100644
index 0000000..5245b7c
--- /dev/null
+++ b/kernel/target/pc/multiboot/BUILD.gn
@@ -0,0 +1,93 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/public/gn/toolchain/environment.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# The Multiboot trampoline gets its own toolchain to build x86-32 code.
+if (current_toolchain == default_toolchain) {
+  # Define the special toolchain itself only in the default toolchain.
+  define_environment("multiboot") {
+    cpu = "x64"
+    configs += standard_fuchsia_configs + [ ":multiboot_config" ]
+    globals = {
+      is_kernel = true
+    }
+    strip = "--strip-sections"
+  }
+} else if (toolchain.environment == "multiboot") {
+  # This is the top config for all code in the multiboot_toolchain.
+  config("multiboot_config") {
+    public_deps = [
+      "$zx/kernel:headers",
+      "$zx/kernel:standalone",
+      "$zx/kernel:warnings",
+      "$zx/kernel/arch/x86:kernel",
+      "$zx/kernel/lib/libc:headers",
+      "$zx/public/gn/config:no_sanitizers",
+    ]
+    cflags = [
+      "-m32",
+      "-mregparm=3",
+      "-fno-pic",
+    ]
+    asmflags = cflags
+    ldflags = cflags + [ "-Wl,--no-pie" ]
+  }
+
+  # We could make a Multiboot image meant to be loaded without ELF headers
+  # and do `objcopy -O binary` here.  But there's no reason to, and having
+  # an ELF binary to look at is nicer.  To remove the ELF headers instead,
+  # the linker script would need to remove `+ SIZEOF_HEADERS` and then the
+  # multiboot header would be first thing in the raw binary.  The toolchain
+  # implicitly strips executables, so `multiboot.bin` is a lean, fully
+  # stripped ELF/Multiboot image.
+  executable("multiboot") {
+    output_extension = "bin"
+    output_path = rebase_path("$target_out_dir/$target_name.$output_extension",
+                              root_build_dir)
+    metadata = {
+      images = []
+      foreach(name,
+              [
+                "multiboot-kernel",
+                "qemu-kernel",
+              ]) {
+        images += [
+          {
+            name = name
+            type = "kernel"
+            path = output_path
+          },
+        ]
+      }
+    }
+    sources = [
+      "multiboot-main.c",
+      "multiboot-start.S",
+      "paging.c",
+      "trampoline.c",
+      "util.c",
+    ]
+    deps = [
+      "$zx/kernel/arch/x86/page_tables:headers",
+      "$zx/kernel/platform/pc:headers",
+      "$zx/system/ulib/libzbi",
+    ]
+    ldflags = [ "-Wl,-T," + rebase_path("multiboot.ld", root_build_dir) ]
+    inputs = [
+      "multiboot.ld",
+    ]
+  }
+} else {
+  # In any other toolchain, just redirect to the proper toolchain.
+  select_toolchain("multiboot") {
+    environment_label = ":multiboot"
+    deps = [
+      ":multiboot",
+    ]
+  }
+}
diff --git a/kernel/tests/BUILD.gn b/kernel/tests/BUILD.gn
new file mode 100644
index 0000000..5dc2799
--- /dev/null
+++ b/kernel/tests/BUILD.gn
@@ -0,0 +1,38 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("tests") {
+  cflags = [ "-fno-builtin" ]
+  sources = [
+    "alloc_checker_tests.cpp",
+    "benchmarks.cpp",
+    "cache_tests.cpp",
+    "clock_tests.cpp",
+    "fibo.cpp",
+    "lock_dep_tests.cpp",
+    "mem_tests.cpp",
+    "mp_hotplug_tests.cpp",
+    "preempt_disable_tests.cpp",
+    "printf_tests.cpp",
+    "resource_tests.cpp",
+    "sleep_tests.cpp",
+    "string_tests.cpp",
+    "sync_ipi_tests.cpp",
+    "tests.cpp",
+    "thread_tests.cpp",
+    "timer_tests.cpp",
+    "uart_tests.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/crypto",
+    "$zx/kernel/lib/debuglog",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/header_tests",
+    "$zx/kernel/lib/unittest",
+    "$zx/kernel/object",
+  ]
+}
diff --git a/kernel/top/BUILD.gn b/kernel/top/BUILD.gn
new file mode 100644
index 0000000..df80fa0
--- /dev/null
+++ b/kernel/top/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+source_set("top") {
+  sources = [
+    "init.cpp",
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/kernel/arch/$zircon_cpu",
+    "$zx/kernel/kernel",
+    "$zx/kernel/lib/debuglog",
+    "$zx/kernel/lib/userboot",
+    "$zx/kernel/lib/version",
+    "$zx/kernel/platform",
+    "$zx/kernel/target",
+  ]
+}
diff --git a/kernel/vm/BUILD.gn b/kernel/vm/BUILD.gn
new file mode 100644
index 0000000..d9d10c8
--- /dev/null
+++ b/kernel/vm/BUILD.gn
@@ -0,0 +1,57 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("vm") {
+  kernel = true
+  sources = [
+    "bootalloc.cpp",
+    "bootreserve.cpp",
+    "kstack.cpp",
+    "page.cpp",
+    "page_source.cpp",
+    "pinned_vm_object.cpp",
+    "pmm.cpp",
+    "pmm_arena.cpp",
+    "pmm_node.cpp",
+    "vm.cpp",
+    "vm_address_region.cpp",
+    "vm_address_region_or_mapping.cpp",
+    "vm_aspace.cpp",
+    "vm_mapping.cpp",
+    "vm_object.cpp",
+    "vm_object_paged.cpp",
+    "vm_object_physical.cpp",
+    "vm_page_list.cpp",
+    "vmm.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/console",
+    "$zx/kernel/lib/fbl",
+    "$zx/kernel/lib/user_copy",
+    "$zx/kernel/lib/vdso",
+    "$zx/system/ulib/pretty",
+    "$zx/third_party/ulib/cryptolib",
+  ]
+  public_deps = [
+    # <vm/vm_object.h> has #include <fbl/name.h>.
+    "$zx/kernel/lib/fbl:headers",
+
+    # <vm/vm_object.h> has #include <lib/user_copy/user_ptr.h>.
+    "$zx/kernel/lib/user_copy",
+
+    # <vm/vm_aspace.h> has #include <lib/crypto/prng.h>
+    "$zx/kernel/lib/crypto:headers",
+  ]
+}
+
+source_set("tests") {
+  sources = [
+    "vm_unittest.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/unittest",
+  ]
+}
diff --git a/munge-manifest.sh b/munge-manifest.sh
new file mode 100755
index 0000000..2a58741
--- /dev/null
+++ b/munge-manifest.sh
@@ -0,0 +1,37 @@
+#!/bin/bash -e
+
+# oy
+
+[ $# -eq 4 ] || exit 2
+readonly OUTPUT="$1"
+readonly INPUT="$2"
+readonly DEPFILE="$3"
+readonly PREFIX="$4"
+
+manifest_files=()
+input_files=()
+
+read_file_list() {
+  while read file; do
+    if [ "${file%%/*}" = "$PREFIX" ]; then
+      case "${file##*.}" in
+        manifest)
+          manifest_files+=("$file")
+          ;;
+        d)
+          input_files+=($(<"$file"))
+          ;;
+        *)
+          echo >&2 "unexpected runtime_deps file $file"
+          exit 1
+          ;;
+      esac
+    fi
+  done
+}
+
+read_file_list < "$INPUT"
+
+echo "$OUTPUT: ${manifest_files[*]} ${input_files[*]}" > "$DEPFILE"
+
+LC_ALL=C sort "${manifest_files[@]}" > "$OUTPUT"
diff --git a/public/bin/BUILD.gn b/public/bin/BUILD.gn
new file mode 100644
index 0000000..be13266
--- /dev/null
+++ b/public/bin/BUILD.gn
@@ -0,0 +1,22 @@
+# 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("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# $zx/public/bin:$cpu is a target to build all user app binaries for $cpu.
+foreach(cpu, standard_fuchsia_cpus) {
+  select_toolchain(cpu) {
+    testonly = true
+    cpu = target_name
+    environment_label = "$zx/public/gn/toolchain:user"
+    deps = [
+      "$zx/system/uapp",
+      "$zx/third_party/uapp",
+
+      # TODO: top-level $zx/test?
+      "$zx/system/utest",
+    ]
+  }
+}
diff --git a/public/bootloader/BUILD.gn b/public/bootloader/BUILD.gn
new file mode 100644
index 0000000..448e8cf
--- /dev/null
+++ b/public/bootloader/BUILD.gn
@@ -0,0 +1,24 @@
+# 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("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# $zx/public/kernel:$cpu is a target to build the standard bootloader for $cpu.
+# Build configuration will select the variant to use for the bootloader.
+foreach(cpu, standard_fuchsia_cpus) {
+  if (cpu == "x64") {
+    select_toolchain(cpu) {
+      cpu = target_name
+      environment_label = "$zx/bootloader:efi"
+      deps = [
+        "$zx/bootloader",
+      ]
+    }
+  } else {
+    # We don't have our own bootloader for other machines.
+    group(cpu) {
+    }
+  }
+}
diff --git a/public/core/BUILD.gn b/public/core/BUILD.gn
new file mode 100644
index 0000000..aef132a
--- /dev/null
+++ b/public/core/BUILD.gn
@@ -0,0 +1,30 @@
+# 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("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# $zx/public/core:$cpu is a target to build the standard core services for $cpu.
+foreach(cpu, standard_fuchsia_cpus) {
+  select_toolchain(cpu) {
+    cpu = target_name
+    environment_label = "$zx/public/gn/toolchain:user"
+    deps = [
+      ":core",
+    ]
+  }
+}
+
+if (current_cpu != "") {
+  group("core") {
+    deps = [
+      "$zx/system/core",
+    ]
+
+    # Core services need a kernel!
+    data_deps = [
+      "$zx/public/kernel",
+    ]
+  }
+}
diff --git a/public/drivers/BUILD.gn b/public/drivers/BUILD.gn
new file mode 100644
index 0000000..e8d0e54
--- /dev/null
+++ b/public/drivers/BUILD.gn
@@ -0,0 +1,30 @@
+# 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("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# $zx/public/drivers:$cpu is a target to build all drivers for $cpu.
+foreach(cpu, standard_fuchsia_cpus) {
+  select_toolchain(cpu) {
+    testonly = true
+    cpu = target_name
+    environment_label = "$zx/public/gn/toolchain:user"
+    deps = [
+      ":drivers",
+    ]
+  }
+}
+
+if (current_cpu != "") {
+  group("drivers") {
+    testonly = true
+    deps = [
+      "$zx/system/dev",
+    ]
+    if (current_cpu == "x64") {
+      deps += [ "$zx/third_party/dev/ethernet/e1000" ]
+    }
+  }
+}
diff --git a/public/gn/BUILDCONFIG.gn b/public/gn/BUILDCONFIG.gn
index d555321..1fc45cc 100644
--- a/public/gn/BUILDCONFIG.gn
+++ b/public/gn/BUILDCONFIG.gn
@@ -39,9 +39,22 @@
 # The toolchain can specify pervasive globals.
 forward_variables_from(toolchain.globals, "*")
 
+# This is the name for $current_cpu that's used in Zircon file names.
+if (current_cpu == "x64") {
+  zircon_cpu = "x86"
+} else if (current_cpu != "") {
+  zircon_cpu = current_cpu
+}
+
 # Shorthand for `current_os == "fuchsia"`.
 is_fuchsia = current_os == "fuchsia"
 
+# Shorthand for `current_os == "linux"`.
+is_linux = current_os == "linux"
+
+# Shorthand for `current_os == "mac"`.
+is_mac = current_os == "mac"
+
 if (!defined(is_gcc)) {
   # True iff $current_toolchain builds with GCC rather than Clang.
   is_gcc = false
@@ -229,6 +242,129 @@
   }
 }
 
+# This is for doing the actual shared_library() or loadable_module()
+# target in a toolchain that supports them directly.  That is, either
+# ${toolchain.label} == ${toolchain.shlib} or this is a toolchain that
+# was defined with `solink = true` so there is no ${toolchain.shlib}.
+template("_shlib_toolchain_target") {
+  assert_no_legacy_configs(target_name) {
+    type = invoker.target_type
+  }
+  assert(!is_kernel,
+         "${invoker.target_type}() targets don't work in kernel toolchains")
+
+  target(invoker.target_type, target_name) {
+    # visibility and data_deps get special treatment in ${toolchain.shlib}.
+    if (defined(toolchain.shlib)) {
+      if (defined(invoker.visibility)) {
+        # Make sure we're visible to the redirector groups defined below.
+        visibility = invoker.visibility + [ ":$target_name" ]
+      }
+      if (defined(invoker.data_deps)) {
+        # Redirect data_deps to the non-shlib toolchain.
+        data_deps = []
+        foreach(label, invoker.data_deps) {
+          if (get_label_info(label, "toolchain") == current_toolchain) {
+            label += "(${toolchain.label})"
+          }
+          data_deps += [ label ]
+        }
+      }
+    } else {
+      forward_variables_from(invoker,
+                             [
+                               "data_deps",
+                               "visibility",
+                             ])
+    }
+
+    # Everything else is passed through (everything in solink toolchains).
+    # But also apply configs->deps.
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "configs",
+                             "deps",
+                             "data_deps",
+                             "target_type",
+                             "visibility",
+                           ])
+    deps = invoker.configs
+    if (defined(invoker.deps)) {
+      deps += invoker.deps
+    }
+  }
+}
+
+template("shared_library") {
+  if (!defined(toolchain.shlib) || current_toolchain == toolchain.shlib) {
+    # This is the toolchain that actually builds the libraries.
+    _shlib_toolchain_target(target_name) {
+      target_type = "shared_library"
+      forward_variables_from(invoker,
+                             "*",
+                             [
+                               "metadata",
+                               "target_type",
+                               "visibility",
+                             ])
+      forward_variables_from(invoker, [ "visibility" ])
+
+      # Elaborate the toolchain's defaults to compute the output file name.
+      if (!defined(output_name)) {
+        output_name = target_name
+      }
+      output_name += toolchain.output_name_suffix
+      if (!defined(output_extension)) {
+        output_extension = "so"
+      }
+      output_file = "$target_out_dir/lib$output_name"
+      if (output_extension != "") {
+        output_file += ".$output_extension"
+      }
+
+      metadata = {
+        if (defined(invoker.metadata)) {
+          forward_variables_from(invoker.metadata, "*")
+        }
+
+        # Every terminal target provides these metadata keys.  The first is
+        # used the data key for the output of the link, as a file name
+        # relative to $root_build_dir appropriate for command-line
+        # contexts.  The second is used as a walk key to provide a
+        # dependency barrier against e.g. shared_library() deps or other
+        # executable() data_deps.
+        link_output = [ rebase_path(output_file + toolchain.link_output_suffix,
+                                    root_build_dir) ]
+        link_barrier = []
+        if (current_os != "mac" && current_os != "win") {
+          elf_link_output = link_output
+        }
+
+        # Each shared_library() that's not on the whitelist gets a poison
+        # pill to flag it if it appears in the dependency graph from a
+        # driver() target.
+        if (!defined(driver_blacklist)) {
+          driver_blacklist = [ true ]
+        }
+      }
+    }
+  } else {
+    # In the main toolchain, just redirect to the shlib toolchain.
+    group(target_name) {
+      forward_variables_from(invoker,
+                             [
+                               "testonly",
+                               "visibility",
+                             ])
+      not_needed(invoker, "*")
+      public_deps = [
+        ":$target_name(${toolchain.shlib})",
+      ]
+    }
+  }
+}
+
 template("library") {
   _library_name = target_name
   host = defined(invoker.host) && invoker.host
@@ -240,16 +376,17 @@
     static = !kernel
   }
   if (defined(invoker.sdk)) {
-    # TODO: later
-    not_needed(invoker,
-               [
-                 "sdk",
-                 "sdk_headers",
-               ])
+    sdk = invoker.sdk
+    sdk_headers = invoker.sdk_headers
+  } else {
+    sdk = false
+    sdk_headers = []
   }
   _library_params = [
     "kernel",
     "host",
+    "sdk",
+    "sdk_headers",
     "shared",
     "static",
   ]
@@ -273,7 +410,23 @@
   not_needed([ "static_library" ])
 
   targets = false
-  if (is_host) {
+  if (is_kernel) {
+    if (kernel) {
+      targets = true
+      source_set(_library_name) {
+        forward_variables_from(invoker, "*", _library_params)
+        if (!defined(public_deps)) {
+          public_deps = []
+        }
+        public_deps += [ ":${_library_name}.headers" ]
+      }
+    }
+    if (sdk != false && !static && !shared && toolchain.tags == []) {
+      data_deps = [
+        ":$_library_name-$current_cpu.pkg(${toolchain.label})",
+      ]
+    }
+  } else if (is_host) {
     if (host) {
       targets = true
       target(static_library, _library_name) {
@@ -287,6 +440,137 @@
         public_deps += [ ":${_library_name}.headers" ]
       }
     }
+  } else if (static || shared) {
+    targets = true
+    source_set("${_library_name}._sources") {
+      visibility = [
+        ":${_library_name}.static",
+        ":${_library_name}.shared",
+      ]
+      forward_variables_from(invoker,
+                             "*",
+                             _library_params + [
+                                   "data_deps",
+                                   "install_path",
+                                   "public_deps",
+                                   "visibility",
+                                 ])
+      if (!defined(deps)) {
+        deps = []
+      }
+      deps += [ ":${_library_name}.headers" ]
+      if (defined(invoker.data_deps)) {
+        # Redirect data_deps to the non-shlib toolchain.
+        data_deps = []
+        foreach(label, invoker.data_deps) {
+          if (get_label_info(label, "toolchain") == current_toolchain) {
+            label += "(${toolchain.label})"
+          }
+          data_deps += [ label ]
+        }
+      }
+    }
+    if (static) {
+      target(static_library, "${_library_name}.static") {
+        if (static_library == "static_library") {
+          complete_static_lib = true
+        }
+        output_name = _library_name
+        forward_variables_from(invoker,
+                               [
+                                 "configs",
+                                 "data_deps",
+                                 "public_deps",
+                                 "testonly",
+                                 "visibility",
+                               ])
+        if (!defined(public_deps)) {
+          public_deps = []
+        }
+        public_deps += [ ":${_library_name}.headers" ]
+        deps = [
+          ":${_library_name}._sources",
+        ]
+      }
+    }
+    if (shared) {
+      if (defined(invoker.install_path)) {
+        install_path = invoker.install_path
+      } else {
+        install_path = "lib/${toolchain.libprefix}lib${_library_name}.so"
+      }
+      shared_library("${_library_name}.shared") {
+        output_name = _library_name
+        forward_variables_from(invoker,
+                               [
+                                 "configs",
+                                 "ldflags",
+                                 "libs",
+                                 "lib_dirs",
+                                 "testonly",
+                                 "visibility",
+                               ])
+
+        # Everything that depends on the library gets the headers.
+        # It also gets the explicit `public_deps`, which includes
+        # any header dependencies or public config()s.
+        public_deps = [
+          ":${_library_name}.headers",
+        ]
+        if (defined(invoker.public_deps)) {
+          public_deps += invoker.public_deps
+        }
+
+        # The library depends on the source_set().  It also depends on the
+        # `deps` from the source_set() so as to get any config()
+        # dependencies that affect linking rather than just compilation.
+        # Other dependencies are redundant since the source_set() already
+        # has them, but they don't hurt.
+        deps = [
+          ":${_library_name}._sources",
+        ]
+        if (defined(invoker.deps)) {
+          deps += invoker.deps
+        }
+
+        # An explicit `install_path = false` means this DSO is not installed.
+        if (install_path != false) {
+          metadata = {
+            manifest_inputs = [ "$target_out_dir/lib${output_name}.so" ]
+            manifest_lines = [ "${install_path}=" +
+                               rebase_path(manifest_inputs[0], root_build_dir) ]
+          }
+        }
+      }
+    }
+    group(_library_name) {
+      forward_variables_from(invoker,
+                             [
+                               "testonly",
+                               "visibility",
+                             ])
+      if (shared) {
+        public_deps = [
+          ":${_library_name}.shared",
+        ]
+      } else {
+        public_deps = [
+          ":${_library_name}.static",
+        ]
+      }
+      if (sdk != false && toolchain.environment == "user" &&
+          toolchain.tags == []) {
+        if (sdk == "shared") {
+          data_deps = [
+            ":$_library_name-$current_cpu.pkg(${toolchain.shlib})",
+          ]
+        } else {
+          data_deps = [
+            ":$_library_name-$current_cpu.pkg(${toolchain.label})",
+          ]
+        }
+      }
+    }
   }
 
   if (!targets) {
@@ -340,11 +624,164 @@
         ":${_library_name}.headers",
       ]
     }
+    if (!is_kernel && !is_host) {
+      if (static) {
+        group("static") {
+          forward_variables_from(invoker,
+                                 [
+                                   "testonly",
+                                   "visibility",
+                                 ])
+          public_deps = [
+            ":${_library_name}.static",
+          ]
+        }
+      }
+      if (shared) {
+        group("shared") {
+          forward_variables_from(invoker,
+                                 [
+                                   "testonly",
+                                   "visibility",
+                                 ])
+          public_deps = [
+            ":${_library_name}.shared",
+          ]
+        }
+      }
+    }
+  }
+
+  if (sdk != false &&
+      (toolchain.environment == "user" || (!shared && !static))) {
+    if (sdk == "static") {
+      assert(static,
+             "$target_name must have static=true to have sdk=\"static\"")
+    } else if (sdk == "shared") {
+      assert(shared || !defined(toolchain.shlib),
+             "$target_name must have shared=true to have sdk=\"shared\"")
+    } else {
+      assert(sdk == "source",
+             "$target_name sdk=\"$sdk\" not static, shared, or source")
+    }
+    if (toolchain.tags != [] ||
+        (defined(toolchain.shlib) &&
+         ((sdk == "shared" && current_toolchain != toolchain.shlib) ||
+          (sdk != "shared" && current_toolchain == toolchain.shlib)))) {
+      sdk = false
+    }
+    if (sdk != false) {
+      import("$zx/public/gn/pkg.gni")
+      pkg_export("$target_name-$current_cpu.pkg") {
+        contents = [
+          "[package]",
+          "name=$_library_name",
+          "type=lib",
+        ]
+        if (sdk == "source") {
+          contents += [
+            "arch=src",
+            "[src]",
+          ]
+          foreach(file, invoker.sources) {
+            contents += [ rebase_path(file, ".") + "=SOURCE/" +
+                          rebase_path(file, "//") ]
+          }
+        } else {
+          contents += [
+            "arch=$zircon_cpu",
+            "[lib]",
+          ]
+          if (sdk == "static") {
+            if (defined(invoker.output_prefix_override) &&
+                invoker.output_prefix_override) {
+              contents += [ "lib/${_library_name}.a=BUILD/" +
+                            rebase_path("$target_out_dir/${_library_name}.a",
+                                        root_build_dir) ]
+            } else {
+              contents += [ "lib/lib${_library_name}.a=BUILD/" +
+                            rebase_path("$target_out_dir/lib${_library_name}.a",
+                                        root_build_dir) ]
+            }
+          } else {
+            soname = "lib${_library_name}.so"
+            contents += [
+              "debug/$soname=BUILD/" +
+                  rebase_path("$target_out_dir/$soname.debug", root_build_dir),
+              "lib/$soname=BUILD/" +
+                  rebase_path("$target_out_dir/$soname.debug", root_build_dir),
+            ]
+            if (defined(invoker.install_path)) {
+              install_path = invoker.install_path
+            } else {
+              install_path = "lib/${toolchain.libprefix}lib${_library_name}.so"
+            }
+            if (install_path != false) {
+              contents +=
+                  [ "dist/$install_path=BUILD/" +
+                    rebase_path("$target_out_dir/$soname", root_build_dir) ]
+            }
+          }
+        }
+        contents += [ "[includes]" ]
+        foreach(file, invoker.sdk_headers) {
+          contents += [ rebase_path(file, ".") + "=SOURCE/" +
+                        rebase_path(file, "//", "include") ]
+        }
+        sdk_deps = []
+        if (defined(invoker.public_deps)) {
+          sdk_deps += invoker.public_deps
+        }
+        if (sdk == "source" && defined(invoker.deps)) {
+          sdk_deps += invoker.deps
+        }
+        if (sdk_deps != []) {
+          banjo_deps = []
+          fidl_deps = []
+          lib_deps = []
+          foreach(label, sdk_deps) {
+            if (get_path_info(get_label_info(label, "dir"), "dir") ==
+                "$zx/system/banjo") {
+              banjo_deps += [ get_label_info(label, "name") ]
+            } else if (get_label_info(label, "name") == "c.headers" ||
+                       (get_label_info(label, "name") == "c" &&
+                        get_path_info(get_label_info(label, "dir"), "dir") ==
+                        "$zx/system/fidl")) {
+              assert(get_path_info(get_label_info(label, "dir"), "dir") ==
+                     "$zx/system/fidl")
+              fidl_deps +=
+                  [ get_path_info(get_label_info(label, "dir"), "name") ]
+            } else if (get_label_info(label, "name") !=
+                       "enable_driver_tracing" &&
+                       get_label_info(label, "name") !=
+                       "generated-public-headers") {
+              assert(true || get_label_info(label, "name") == "headers" ||
+                         get_path_info(get_label_info(label, "name"),
+                                       "extension") == "headers",
+                     "$label is not a library() headers target")
+              lib_deps +=
+                  [ get_path_info(get_label_info(label, "dir"), "name") ]
+            }
+          }
+          lib_deps += [ "zxcpp" ]
+          lib_deps -= [ "zxcpp" ]
+          if (lib_deps != []) {
+            contents += [ "[deps]" ] + lib_deps
+          }
+          if (banjo_deps != []) {
+            contents += [ "[banjo-deps]" ] + banjo_deps
+          }
+          if (fidl_deps != []) {
+            contents += [ "[fidl-deps]" ] + fidl_deps
+          }
+        }
+      }
+    }
   }
 }
 
 ###
-### "Terminal" (executable) target types.
+### "Terminal" (executable and loadable_module) target types.
 ### These are the targets that do variant selection.
 ###
 
@@ -754,6 +1191,143 @@
   }
 }
 
+template("loadable_module") {
+  assert(!is_kernel)
+  assert(!is_host)
+  _variant_target(target_name) {
+    # This is for _variant_target().
+    target = {
+      shlib = true
+      match = "loadable_module"
+      type = "_shlib_toolchain_target"
+    }
+
+    # This is for _shlib_toolchain_target().
+    target_type = "loadable_module"
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "metadata",
+                             "target_type",
+                             "visibility",
+                           ])
+    forward_variables_from(invoker, [ "visibility" ])
+
+    # Elaborate the toolchain's defaults to compute the output file name.
+    if (!defined(output_name)) {
+      output_name = target_name
+    }
+    output_name += toolchain.output_name_suffix
+    if (!defined(output_extension)) {
+      output_extension = "so"
+    }
+    output_file = "$target_out_dir/$output_name"
+    if (output_extension != "") {
+      output_file += ".$output_extension"
+    }
+
+    metadata = {
+      if (defined(invoker.metadata)) {
+        forward_variables_from(invoker.metadata, "*")
+      }
+
+      # Every terminal target provides these metadata keys.  The first is
+      # used the data key for the output of the link, as a file name
+      # relative to $root_build_dir appropriate for command-line
+      # contexts.  The second is used as a walk key to provide a
+      # dependency barrier against e.g. shared_library() deps or other
+      # executable() data_deps.
+      link_output = [ rebase_path(output_file + toolchain.link_output_suffix,
+                                  root_build_dir) ]
+      link_barrier = []
+      if (current_os != "mac" && current_os != "win") {
+        elf_link_output = link_output
+      }
+    }
+
+    if (defined(invoker.install_path)) {
+      target.main_metadata = {
+        manifest_inputs = [ output_file ]
+        manifest_lines =
+            [ "${install_path}=" + rebase_path(output_file, root_build_dir) ]
+      }
+
+      # Also define an alias with the variant suffix.  _variant_target will
+      # make this redirect to the specific variant toolchain chosen for
+      # this target.  In only that toolchain, the metadata will give the
+      # binary a second install path with the variant suffix.
+      extension = get_path_info(invoker.install_path, "extension")
+      if (extension != "") {
+        extension = ".$extension"
+      }
+      target.variant_metadata = {
+        manifest_inputs = [ output_file ]
+        manifest_lines = [ get_path_info(invoker.install_path, "dir") + "/" +
+                           get_path_info(invoker.install_path, "name") +
+                           toolchain.variant_suffix + extension + "=" +
+                           rebase_path(output_file, root_build_dir) ]
+      }
+    }
+  }
+}
+
+template("driver") {
+  loadable_module(target_name) {
+    data_deps = []
+    deps = []
+    forward_variables_from(invoker, "*", [ "visibility" ])
+    forward_variables_from(invoker, [ "visibility" ])
+
+    # All drivers implicitly get the driver ABI.
+    deps += [ "$zx/system/ulib/driver" ]
+
+    # Drivers that use C++ library facilities cannot use the libc++
+    # shared library (it's not in the whitelist).  So always use the
+    # hermetic static library.  This has no effect if no C++ library
+    # symbols are used.
+    configs += [ "$zx/public/gn/config:static-libc++" ]
+
+    # It's an error to link against any shared library that's not on the
+    # whitelist.  Those libraries set `driver_blackist=[]` while others (by
+    # default, see shared_library() above) set `driver_blacklist=[true]`.
+    if (false) {  # TODO(get_metadata): add assert_no_metadata feature
+      assert_no_metadata([ "" ],
+                         [ "driver_blacklist" ],
+                         [ "driver_blacklist_barrier" ],
+                         "driver() targets cannot depend on shared libraries")
+    }
+
+    # Elaborate the defaults to compute the output file name.
+    if (!defined(output_name)) {
+      output_name = target_name
+    }
+
+    # Set the standard install_path.
+    if (!defined(install_path)) {
+      install_path = "driver/${output_name}.so"
+    }
+  }
+}
+
+template("test_driver") {
+  driver(target_name) {
+    testonly = true
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "install_path",
+                             "visibility",
+                           ])
+    forward_variables_from(invoker, [ "visibility" ])
+
+    # Elaborate the defaults to compute the output file name.
+    if (!defined(output_name)) {
+      output_name = target_name
+    }
+    install_path = "driver/test/${output_name}.so"
+  }
+}
+
 template("executable") {
   _basic_executable(target_name) {
     target_type = "executable"
@@ -785,6 +1359,26 @@
                              ])
       forward_variables_from(invoker, [ "visibility" ])
 
+      if (!defined(output_name)) {
+        output_name = "${target_name}-test"
+      }
+      output_name += toolchain.output_name_suffix
+      if (!defined(output_extension)) {
+        output_extension = toolchain.executable_extension
+      }
+
+      if (!is_host && !defined(install_path)) {
+        if (defined(invoker.test_group)) {
+          test_group = invoker.test_group
+        } else {
+          test_group = "sys"
+        }
+        install_path = "test/$test_group/$output_name"
+        if (output_extension != "") {
+          install_path += ".$output_extension"
+        }
+      }
+
       if (is_host) {
         metadata = {  # TODO: host test metadata
         }
@@ -838,6 +1432,31 @@
         tool_executables = variant_suffix_outputs
       }
     }
+    if (is_host && current_os == host_os && current_cpu == host_cpu) {
+      if (!defined(data_deps)) {
+        data_deps = []
+      }
+      data_deps += [ ":$target_name.pkg" ]
+    }
+  }
+
+  # TODO(mcgrathr): Temporary hacks for integrating with the legacy
+  # Fuchsia GN build.
+  if (is_host && current_os == host_os && current_cpu == host_cpu) {
+    import("$zx/public/gn/pkg.gni")
+    assert(!defined(invoker.output_name))
+    tool_name = target_name
+    pkg_export("$target_name.pkg") {
+      contents = [
+        "[package]",
+        "name=$tool_name",
+        "type=tool",
+        "arch=host",
+        "[bin]",
+        "$tool_name=BUILD/" +
+            rebase_path("$target_out_dir/$tool_name", root_build_dir),
+      ]
+    }
   }
 }
 
@@ -848,10 +1467,18 @@
   "executable",
   "host_tool",
   "library",
+  "loadable_module",
+  "shared_library",
   "source_set",
   "static_library",
   "test",
 ]
+if (toolchain.environment == "user") {
+  _compile_target_types += [
+    "driver",
+    "test_driver",
+  ]
+}
 
 # ${toolchain.configs} gives the initial `configs` set for every compile
 # target in this toolchain.  Targets use `+=` rather than `=` unless they
diff --git a/public/gn/banjo.gni b/public/gn/banjo.gni
new file mode 100644
index 0000000..a09bbf4
--- /dev/null
+++ b/public/gn/banjo.gni
@@ -0,0 +1,201 @@
+# 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("$zx/public/gn/host_tool_action.gni")
+import("$zx/public/gn/pkg.gni")  # TODO: temporary hack
+
+template("banjo_library") {
+  assert(defined(invoker.sources),
+         "banjo_library(\"$target_name\") must set `sources`")
+
+  # The main target is an action that generates the headers.
+  # Its public_deps includes a config() target that makes them visible.
+  # banjo_library() targets use public_deps for dependencies between headers.
+  banjo_target = target_name
+  config_target = "${banjo_target}._config"
+
+  # The generated headers are the same in every toolchain, so generate only
+  # once, in $default_toolchain.
+  gen_dir = get_label_info(":$banjo_target($default_toolchain)",
+                           "target_gen_dir") + "/$banjo_target"
+
+  config(config_target) {
+    visibility = [ ":$banjo_target" ]
+    forward_variables_from(invoker, [ "testonly" ])
+    deps = [
+      ":$banjo_target._cflags.rsp($default_toolchain)",
+    ]
+    cflags = [ "@" + rebase_path("$gen_dir._cflags.rsp", root_build_dir) ]
+  }
+
+  if (current_toolchain == default_toolchain) {
+    # TODO(mcgrathr): temporary until everything is renamed with . names
+    banjo_library_name = string_replace(banjo_target, "-", ".")
+
+    banjo_path = string_replace(banjo_library_name, ".", "/")
+    banjo_name = string_replace(banjo_path, "ddk/protocol/", "")
+
+    pkg_export("${banjo_target}.pkg") {  # TODO: temporary hack
+      contents = [
+        "[package]",
+        "name=$banjo_target",
+        "library=$banjo_library_name",
+        "arch=banjo",
+        "type=banjo",
+        "[banjo]",
+      ]
+      foreach(file, invoker.sources) {
+        contents += [ "$file=SOURCE/" + rebase_path(file, "//") ]
+      }
+      if (defined(invoker.deps)) {
+        contents += [ "[banjo-deps]" ]
+        foreach(label, invoker.deps) {
+          contents += [ get_label_info(label, "name") + "=SOURCE/" +
+                        rebase_path(get_label_info(label, "dir"), "//") ]
+        }
+      }
+    }
+
+    gen_files = [
+      {
+        switch = "--ddk-header"
+        file = "$gen_dir/include/ddk/protocol/${banjo_name}.h"
+      },
+      {
+        switch = "--ddktl-header"
+        file = "$gen_dir/include/ddktl/protocol/${banjo_name}.h"
+      },
+      {
+        file = "$gen_dir/include/ddktl/protocol/${banjo_name}-internal.h"
+      },
+    ]
+    gen_args = [
+      "--name",
+      banjo_library_name,
+    ]
+    gen_outputs = []
+    foreach(gen, gen_files) {
+      gen_outputs += [ gen.file ]
+      if (defined(gen.switch)) {
+        gen_args += [
+          gen.switch,
+          rebase_path(gen.file, root_build_dir),
+        ]
+      }
+    }
+
+    # This just groups the dependencies together with the metadata listing
+    # the input files.
+    group("$banjo_target._files") {
+      visibility = [
+        ":$banjo_target._files.rsp",
+        ":$banjo_target._cflags.rsp",
+      ]
+      forward_variables_from(invoker,
+                             [
+                               "deps",
+                               "public_deps",
+                               "testonly",
+                             ])
+
+      # These inputs are needed both here and in every dependency
+      # banjo_library() action.
+      metadata = {
+        banjo_rspfile =
+            [ "--files" ] + rebase_path(invoker.sources, root_build_dir)
+        banjo_cflags =
+            [ "-I" + rebase_path("$gen_dir/include", root_build_dir) ]
+      }
+    }
+
+    # First produce a metadata response file from all the banjo_rspfile lists.
+    # TODO(get_metadata): banjo needs this to collect metadata in
+    # topological order, but it's a pruned pre-order instead
+    files_rspfile = "$target_gen_dir/$banjo_target._files.rsp"
+    generated_file("$banjo_target._files.rsp") {
+      forward_variables_from(invoker, [ "testonly" ])
+      visibility = [ ":$banjo_target._rsp" ]
+      deps = [
+        ":$banjo_target._files",
+      ]
+      outputs = [
+        files_rspfile,
+      ]
+      output_conversion = "list lines"
+      data_keys = [ "banjo_rspfile" ]
+    }
+
+    # Next, combine that into a response file for the whole command.
+    # At the same time, produce a depfile listing all the input files.
+    gen_rspfile = "$target_out_dir/$banjo_target.rsp"
+    gen_depfile = "$target_out_dir/$banjo_target.d"
+    action("$banjo_target._rsp") {
+      forward_variables_from(invoker, [ "testonly" ])
+      visibility = [ ":$banjo_target" ]
+      deps = [
+        ":$banjo_target._files.rsp",
+      ]
+      sources = [
+        files_rspfile,
+      ]
+      outputs = [
+        gen_rspfile,
+        gen_depfile,
+      ]
+      script = "$zx/public/gn/gen-fidlc-rsp.sh"
+      args = rebase_path(outputs + [ gen_outputs[0] ] + sources,
+                         root_build_dir) + gen_args
+    }
+
+    # Finally, the real action runs banjoc with that response file.
+    host_tool_action(banjo_target) {
+      forward_variables_from(invoker,
+                             [
+                               "public_deps",
+                               "testonly",
+                               "visibility",
+                             ])
+      if (!defined(public_deps)) {
+        public_deps = []
+      }
+      public_deps += [ ":$config_target" ]
+      deps = [
+        ":$banjo_target._rsp",
+      ]
+
+      tool = "$zx/system/host/banjo/compiler"
+      outputs = gen_outputs
+      sources = [
+        gen_rspfile,
+      ]
+      depfile = gen_depfile
+      args = [ "@" + rebase_path(gen_rspfile, root_build_dir) ]
+    }
+
+    # The config also needs this metadata response file containing -I switches.
+    generated_file("$banjo_target._cflags.rsp") {
+      visibility = [ ":$config_target" ]
+      deps = [
+        ":$banjo_target._files",
+      ]
+      outputs = [
+        "$gen_dir._cflags.rsp",
+      ]
+      output_conversion = "list lines"
+      data_keys = [ "banjo_cflags" ]
+    }
+  } else {
+    group(banjo_target) {
+      forward_variables_from(invoker,
+                             [
+                               "testonly",
+                               "visibility",
+                             ])
+      public_deps = [
+        ":$banjo_target($default_toolchain)",
+      ]
+      not_needed(invoker, "*")
+    }
+  }
+}
diff --git a/public/gn/build_api.gni b/public/gn/build_api.gni
new file mode 100644
index 0000000..5c18b18
--- /dev/null
+++ b/public/gn/build_api.gni
@@ -0,0 +1,43 @@
+# 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.
+
+# Write a JSON file for the $target_name "build API module".  The file goes
+# at `$root_build_dir/$target_name.json`.  The contents are in JSON format.
+#
+# The $target_name is the name of the build API module.  It's up to each
+# module to define the JSON schema that constitutes the API contract with
+# users of this build API module.  Usually somewhere in the JSON structure
+# will be strings naming Ninja targets (i.e. output files to produce, or
+# actions to take for side-effect such as running tests).
+#
+# Parameters
+#
+#   contents (optional)
+#     Fixed contents of the file, any GN type, serialized as JSON.
+#     This must be present if $data_keys et al are not.
+#
+#   deps, data_keys, walk_keys (optional)
+#     Specifies a metadata query to produce the contents of the file.
+#     In this case, the file always contains a JSON list.  If $contents
+#     is omitted then $data_keys is required.
+#
+template("build_api_module") {
+  generated_file(target_name) {
+    outputs = [
+      "$root_build_dir/$target_name.json",
+    ]
+    forward_variables_from(invoker,
+                           [
+                             "contents",
+                             "deps",
+                             "data_keys",
+                             "walk_keys",
+                             "testonly",
+                           ])
+    output_conversion = "json"
+    metadata = {
+      build_api_modules = [ target_name ]
+    }
+  }
+}
diff --git a/public/gn/config/BUILD.gn b/public/gn/config/BUILD.gn
index 37fa7e6..a7ef9c6 100644
--- a/public/gn/config/BUILD.gn
+++ b/public/gn/config/BUILD.gn
@@ -93,6 +93,27 @@
     if (current_os != "win" && current_os != "mac") {
       ldflags += [ "-Wl,--build-id" ]
     }
+  } else if (is_gcc) {
+    # This is predefined by Clang --target=*-fuchsia.
+    # But the GCC toolchain is the generic --target=*-elf one.
+    defines += [ "__Fuchsia__" ]
+
+    # This is done by default in the Clang toolchain.
+    ldflags += [ "-Wl,--build-id" ]
+  }
+
+  if (current_os == "linux") {
+    public_deps += [ ":static-libc++" ]
+  }
+
+  if (current_cpu == "arm64") {
+    # Generate code for the fairly generic cortex-a53.
+    compiler_flags += [ "-mcpu=cortex-a53" ]
+
+    # x18 is reserved in the Fuchsia userland ABI so it can be used
+    # for things like -fsanitize=shadow-call-stack.  In the kernel,
+    # it's reserved so we can use it to point at the per-CPU structure.
+    compiler_flags += [ "-ffixed-x18" ]
   }
 
   if (current_os == "linux") {
@@ -152,6 +173,19 @@
   }
 }
 
+config("nostdlib") {
+  # Don't actually use -nostdlib, because the builtins and -lc++ are what
+  # we want and are otherwise annoying to find and specify.  It's just the
+  # -lc that we really want to defeat, and that's handled by giving a -L
+  # that will find exactly nothing but a dummy libc.so.
+  ldflags = [ "-nostartfiles" ]
+  lib_dirs = [ "libc-dummy" ]
+  if (is_gcc) {
+    # Include this in every link.
+    libs = [ "$zx/scripts/dso_handle.ld" ]
+  }
+}
+
 config("data_sections") {
   cflags = [ "-fdata-sections" ]
 }
@@ -174,6 +208,9 @@
 config("assert_level") {
   assert(assert_level >= 0)
   defines = [ "ZX_DEBUGLEVEL=$assert_level" ]
+  if (is_kernel) {
+    defines += [ "LK_DEBUGLEVEL=$assert_level" ]
+  }
   if (assert_level == 0) {
     defines += [ "NDEBUG" ]
   }
@@ -239,6 +276,23 @@
   }
 }
 
+config("werror") {
+  cflags = [
+    "-Werror",
+
+    # Declarations marked as deprecated should not cause build failures.
+    # Rather they should emit warnings to notify developers about the use
+    # of deprecated interfaces.
+    "-Wno-error=deprecated-declarations",
+
+    # Do not add additional `-Wno-error=...` switches to this config!
+  ]
+
+  if (current_os == "win") {
+    ldflags = [ "-Wl,/WX" ]
+  }
+}
+
 config("default_warnings") {
   cflags = [
     "-Wall",
@@ -342,10 +396,77 @@
   }
 }
 
+config("no_stack_protector") {
+  cflags = [ "-fno-stack-protector" ]
+}
+
+config("no_safestack") {
+  cflags = [ "-fno-sanitize=safe-stack" ]
+  public_deps = [
+    ":no_stack_protector",
+  ]
+}
+
+config("no_sanitizers") {
+  cflags = [ "-fno-sanitize=all" ]
+  public_deps = [
+    ":no_stack_protector",
+  ]
+}
+
+# Compile code appropriately to be linked into a shared library.
+config("shared_library_config") {
+  if (current_os != "mac") {
+    # Assembly code can use `#ifdef __PIC__`.
+    compiler_flags = [ "-fPIC" ]
+  }
+}
+
+# Don't allow dangling undefined references in shared libraries.
+# All references should be satisfied by link-time library dependencies.
+config("no_undefined_symbols") {
+  if (current_os == "mac") {
+    ldflags = [ "-Wl,-undefined,error" ]
+  } else {
+    ldflags = [ "-Wl,-z,defs" ]
+  }
+}
+
 config("visibility_hidden") {
   cflags = [ "-fvisibility=hidden" ]
 }
 
+config("machine") {
+  ldflags = []
+  if (current_cpu == "arm64") {
+    # The linker rewrites instructions to work around a CPU bug.
+    ldflags += [ "-Wl,--fix-cortex-a53-843419" ]
+  }
+  if (is_fuchsia) {
+    ldflags += [ "-Wl,-z,max-page-size=4096" ]
+  }
+}
+
+config("user") {
+  defines = [
+    "_ALL_SOURCE",
+    "ZIRCON_TOOLCHAIN",
+  ]
+  public_deps = [
+    "$zx/system/ulib/c",
+  ]
+  if (toolchain.environment == "user" && current_toolchain != toolchain.shlib) {
+    public_deps += [ "$zx/system/ulib/c:crt1" ]
+  }
+}
+
+config("integer-paranoia") {
+  cflags = [
+    "-fsanitize=integer-divide-by-zero,signed-integer-overflow",
+    "-fsanitize-undefined-trap-on-error",
+  ]
+}
+
 config("static-libc++") {
   ldflags = [ "-static-libstdc++" ]
   if (current_os == "linux") {
diff --git a/public/gn/config/instrumentation/BUILD.gn b/public/gn/config/instrumentation/BUILD.gn
new file mode 100644
index 0000000..3300357
--- /dev/null
+++ b/public/gn/config/instrumentation/BUILD.gn
@@ -0,0 +1,77 @@
+# 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.
+
+declare_args() {
+  # Default [AddressSanitizer](https://llvm.org/docs/AddressSanitizer.html)
+  # options (before the `ASAN_OPTIONS` environment variable is read at
+  # runtime).  This can be set as a build argument to affect most "asan"
+  # variants in $variants (which see), or overridden in $toolchain_args in
+  # one of those variants.  Note that setting this nonempty may conflict
+  # with programs that define their own `__asan_default_options` C
+  # function.
+  asan_default_options = ""
+}
+
+config("asan") {
+  compiler_flags = [ "-fsanitize=address" ]
+
+  # ASan wants frame pointers because it captures stack traces
+  # on allocations and such, not just on errors.
+  public_deps = [
+    "$zx/public/gn/config:frame_pointers",
+  ]
+
+  metadata = {
+    # TODO: runtime shlib deps
+  }
+}
+
+source_set("asan_default_options") {
+  if (asan_default_options != "") {
+    sources = [
+      "asan_default_options.c",
+    ]
+    defines = [ "ASAN_DEFAULT_OPTIONS=\"${asan_default_options}\"" ]
+
+    # On Fuchsia, the ASan runtime is dynamically linked and needs to have
+    # the __asan_default_options symbol exported.  On systems where the
+    # ASan runtime is statically linked, it doesn't matter either way.
+    # TODO: configs -= [ "$zx/public/gn/config:visibility_hidden" ]
+  }
+}
+
+config("ubsan") {
+  compiler_flags = [ "-fsanitize=undefined" ]
+
+  metadata = {
+    # TODO: runtime shlib deps
+  }
+}
+
+config("sancov") {
+  compiler_flags = [ "-fsanitize-coverage=trace-pc-guard" ]
+}
+
+config("profile") {
+  compiler_flags = [
+    "-fprofile-instr-generate",
+    "-fcoverage-mapping",
+  ]
+  if (is_fuchsia) {
+    # The statically-linked profiling runtime depends on libzircon.
+    deps = [
+      "$zx/system/ulib/zircon",
+    ]
+  }
+}
+
+config("fuzzer") {
+  compiler_flags = [ "-fsanitize=fuzzer" ]
+  if (is_fuchsia) {
+    # The statically-linked libFuzzer runtime depends on libzircon.
+    deps = [
+      "$zx/system/ulib/zircon",
+    ]
+  }
+}
diff --git a/public/gn/config/instrumentation/asan_default_options.c b/public/gn/config/instrumentation/asan_default_options.c
new file mode 100644
index 0000000..14b1de2
--- /dev/null
+++ b/public/gn/config/instrumentation/asan_default_options.c
@@ -0,0 +1,13 @@
+// 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.
+
+#include <sanitizer/asan_interface.h>
+
+// ASan applies the options here before looking at the ASAN_OPTIONS
+// environment variable.
+const char* __asan_default_options(void) {
+  // This macro is defined by BUILD.gn from the `asan_default_options` GN
+  // build argument.
+  return ASAN_DEFAULT_OPTIONS;
+}
diff --git a/public/gn/config/libc-dummy/libc.so b/public/gn/config/libc-dummy/libc.so
new file mode 100644
index 0000000..0d94572
--- /dev/null
+++ b/public/gn/config/libc-dummy/libc.so
@@ -0,0 +1,4 @@
+/*
+ * This is an empty input linker script just to be found as -lc.
+ * See $zx/public/gn/config/BUILD.gn:nostdlib.
+ */
diff --git a/public/gn/config/libc-dummy/libg.a b/public/gn/config/libc-dummy/libg.a
new file mode 100644
index 0000000..f17cf09
--- /dev/null
+++ b/public/gn/config/libc-dummy/libg.a
@@ -0,0 +1,4 @@
+/*
+ * This is an empty input linker script just to be found as -lg.
+ * See $zx/public/gn/config/BUILD.gn:nostdlib.
+ */
diff --git a/public/gn/config/libc-dummy/libm.so b/public/gn/config/libc-dummy/libm.so
new file mode 100644
index 0000000..00cccee
--- /dev/null
+++ b/public/gn/config/libc-dummy/libm.so
@@ -0,0 +1,4 @@
+/*
+ * This is an empty input linker script just to be found as -lm.
+ * See $zx/public/gn/config/BUILD.gn:nostdlib.
+ */
diff --git a/public/gn/config/libc-dummy/libstdc++.a b/public/gn/config/libc-dummy/libstdc++.a
new file mode 100644
index 0000000..66318f8
--- /dev/null
+++ b/public/gn/config/libc-dummy/libstdc++.a
@@ -0,0 +1,2 @@
+# GCC looks for -lstdc++ but we actually use -lc++.
+INPUT ( libc++.a )
diff --git a/public/gn/config/lto/BUILD.gn b/public/gn/config/lto/BUILD.gn
new file mode 100644
index 0000000..d883598
--- /dev/null
+++ b/public/gn/config/lto/BUILD.gn
@@ -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.
+
+config("lto") {
+  compiler_flags = [
+    "-flto",
+
+    # Enable whole-program devirtualization and virtual constant propagation.
+    "-fwhole-program-vtables",
+  ]
+}
+
+declare_args() {
+  # Number of parallel ThinLTO jobs.
+  thinlto_jobs = 8
+
+  # ThinLTO cache directory path.
+  thinlto_cache_dir = rebase_path("$root_out_dir/thinlto-cache", root_build_dir)
+}
+
+config("thinlto") {
+  compiler_flags = [ "-flto=thin" ]
+  ldflags = [
+    # The ThinLTO driver launches a number of threads in parallel whose
+    # number is by default equivalent to the number of cores.  We need
+    # to limit the parallelism to avoid aggressive competition between
+    # different linker jobs.
+    "-Wl,--thinlto-jobs=$thinlto_jobs",
+
+    # Set the ThinLTO cache directory which is used to cache native
+    # object files for ThinLTO incremental builds.  This directory is
+    # not managed by Ninja and has to be cleaned manually, but it is
+    # periodically garbage-collected by the ThinLTO driver.
+    "-Wl,--thinlto-cache-dir=$thinlto_cache_dir",
+  ]
+}
diff --git a/public/gn/config/standard.gni b/public/gn/config/standard.gni
index f8b2fa6..dd99d41 100644
--- a/public/gn/config/standard.gni
+++ b/public/gn/config/standard.gni
@@ -2,6 +2,12 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+# All the $current_cpu values that `current_os == "fuchsia"` supports.
+standard_fuchsia_cpus = [
+  "arm64",
+  "x64",
+]
+
 # All the {cpu, os} combinations supported as build or SDK hosts.  The
 # build will define toolchains for all of these.  Successful
 # cross-compilation may require that a sysroot be installed and configured.
@@ -34,6 +40,7 @@
 standard_configs = [
   "$zx/public/gn/config:compiler",
   "$zx/public/gn/config:language",
+  "$zx/public/gn/config:machine",
   "$zx/public/gn/config:relative_paths",
   "$zx/public/gn/config:assert_level",
   "$zx/public/gn/config:opt_level",
@@ -48,6 +55,68 @@
   "$zx/public/gn/config:thread_safety_annotations",
 
   # TODO: "$zx/public/gn/config:symbol_visibility_hidden",
+
+  {
+    # Additional configs apply only to code built into shared libraries.
+    # This means everything in a ${toolchain.shlib} toolchain, not just code
+    # directly in the `sources` of a shared_library() or library() target.
+    shlib = true
+    add = [
+      "$zx/public/gn/config:shared_library_config",
+      "$zx/public/gn/config:no_undefined_symbols",
+    ]
+  },
+]
+
+# Additional configs apply to code built for Fuchsia but not to host code.
+standard_fuchsia_configs = [
+  "$zx/public/gn/config:nostdlib",
+  "$zx/public/gn/config:werror",
+]
+
+# Additional configs apply to normal userland Fuchsia code.
+standard_fuchsia_user_configs = [
+  "$zx/public/gn/config:user",
+  {
+    types = [ "host_tool" ]
+    add = [ "$zx/system/ulib/fdio" ]
+  },
+  {
+    # The "driver_config" target represents the execution environment into
+    # which driver modules get loaded.  This represents the vanilla (or
+    # configured) environment.  Variants can remove this and add a
+    # different variant driver_config label that represents the execution
+    # environment those drivers should get.
+    types = [ "driver" ]
+    add = [ "$zx/system/core/devmgr:driver_config" ]
+  },
+]
+
+# See define_environment().  These are the environments that are
+# vanilla bases to make derived environments from.
+standard_environments = [
+  {
+    name = "host"
+    targets = standard_build_hosts
+    globals = {
+      is_host = true
+    }
+    strip = true
+  },
+  {
+    name = "user"
+    targets = []
+    foreach(cpu, standard_fuchsia_cpus) {
+      targets += [
+        {
+          cpu = cpu
+        },
+      ]
+    }
+    configs = standard_fuchsia_configs + standard_fuchsia_user_configs
+    shlib = true
+    strip = "--strip-sections"
+  },
 ]
 
 # This list has the same structure as $variants but it just supplies
@@ -69,6 +138,76 @@
       }
     }
   },
+  {
+    variant = {
+      name = "lto"
+      configs = [ "$zx/public/gn/config/lto" ]
+    }
+  },
+  {
+    variant = {
+      name = "thinlto"
+      configs = [ "$zx/public/gn/config/lto:thinlto" ]
+    }
+  },
+  {
+    variant = {
+      name = "profile"
+      configs = [ "$zx/public/gn/config/instrumentation:profile" ]
+      tags = [
+        "instrumented",
+        "useronly",
+      ]
+    }
+  },
+  {
+    variant = {
+      name = "asan"
+      configs = [
+        "$zx/public/gn/config/instrumentation:asan",
+        {
+          types = [
+            "executable",
+            "host_tool",
+            "test",
+          ]
+          add = [ "$zx/public/gn/config/instrumentation:asan_default_options" ]
+        },
+        {
+          # ASan drivers need to live in an ASan-compatible environment.
+          types = [ "driver" ]
+          remove = [ "$zx/system/core/devmgr:driver_config" ]
+          add = [ "$zx/system/core/devmgr:driver_config.$name" ]
+        },
+      ]
+      toolchain_vars = {
+        libprefix = "asan/"
+      }
+      tags = [
+        "instrumented",
+        "useronly",
+      ]
+    }
+  },
+  {
+    variant = {
+      name = "ubsan"
+      configs = [ "$zx/public/gn/config/instrumentation:ubsan" ]
+      tags = [
+        "instrumented",
+        "useronly",
+      ]
+    }
+  },
+  {
+    variant = {
+      name = "asan-ubsan"
+      bases = [
+        "asan",
+        "ubsan",
+      ]
+    }
+  },
 ]
 
 # This list is appended to the $variants list for the build.  It provides
@@ -76,8 +215,20 @@
 # selector must be compatible with all environments used in select_toolchain(),
 default_variants = [
   {
+    # The EFI toolchain is only supported using Clang.
+    # For host default to Clang.
+    environment = [
+      "efi",
+      "host",
+    ]
     variant = "clang"
   },
+  {
+    variant = "clang"
+  },
+  {
+    variant = "gcc"
+  },
 ]
 
 # TODO: doc
@@ -91,4 +242,22 @@
       },
     ]
   },
+  {
+    name = "host_asan"
+    selectors = [
+      {
+        variant = "asan"
+        host = true
+      },
+    ]
+  },
+  {
+    name = "asan_drivers"
+    selectors = [
+      {
+        variant = "asan"
+        target_type = [ "driver" ]
+      },
+    ]
+  },
 ]
diff --git a/public/gn/fidl-expand-rsp.sh b/public/gn/fidl-expand-rsp.sh
new file mode 100755
index 0000000..80cf419
--- /dev/null
+++ b/public/gn/fidl-expand-rsp.sh
@@ -0,0 +1,45 @@
+#!/bin/sh -e
+
+OUTPUT="$1"
+shift
+DEPFILE="$1"
+shift
+
+deps=()
+args=()
+
+while [ $# -gt 0 ]; do
+  arg="$1"
+  shift
+  case "$arg" in
+    @*)
+      file="${arg#@}"
+      # Weed out the duplicates.
+      new=true
+      for dep in "${deps[@]}"; do
+        if [ "$dep" = "$file" ]; then
+          new=false
+        fi
+      done
+      $new || continue
+      deps+=("$file")
+      set -- $(cat "$file") ${1+"$@"}
+      ;;
+    --files)
+      args+=("$arg")
+      ;;
+    --*)
+      args+=("$arg" "$1")
+      shift
+      ;;
+    *)
+      args+=("$arg")
+      deps+=("$arg")
+      ;;
+  esac
+done
+
+echo "$OUTPUT:" "${deps[@]}" > "$DEPFILE"
+for arg in "${args[@]}"; do
+  echo "$arg"
+done > "$OUTPUT"
diff --git a/public/gn/fidl.gni b/public/gn/fidl.gni
new file mode 100644
index 0000000..4f68e34
--- /dev/null
+++ b/public/gn/fidl.gni
@@ -0,0 +1,266 @@
+# 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("$zx/public/gn/host_tool_action.gni")
+import("$zx/public/gn/pkg.gni")  # TODO: temporary hack
+
+_fidl_generators = [
+  {
+    name = "c"
+    files = [
+      {
+        switch = "--c-header"
+        path_prefix = "include/"
+        path_suffix = "/c/fidl.h"
+      },
+      {
+        switch = "--c-client"
+        path = "client.c"
+      },
+      {
+        switch = "--c-server"
+        path = "server.c"
+      },
+      {
+        switch = "--tables"
+        path = "tables.cpp"
+      },
+    ]
+    target = "_fidl_c_library"
+    subtargets = [
+      "headers",
+      "static",
+    ]
+  },
+]
+
+template("fidl_library") {
+  assert(defined(invoker.sources),
+         "fidl_library(\"$target_name\") must set `sources`")
+
+  fidl_target = target_name
+
+  # TODO(mcgrathr): temporary until everything is renamed with . names
+  fidl_name = string_replace(fidl_target, "-", ".")
+  fidl_path = string_replace(fidl_name, ".", "/")
+  if (defined(invoker.deps)) {
+    fidl_deps = invoker.deps
+  } else {
+    fidl_deps = []
+  }
+
+  pkg_export("${fidl_target}.pkg") {  # TODO: temporary hack
+    contents = [
+      "[package]",
+      "name=$fidl_target",
+      "library=$fidl_name",
+      "arch=fidl",
+      "type=fidl",
+      "[fidl]",
+    ]
+    foreach(file, invoker.sources) {
+      contents += [ "$file=SOURCE/" + rebase_path(file, "//") ]
+    }
+    if (defined(invoker.deps)) {
+      contents += [ "[fidl-deps]" ]
+      foreach(label, invoker.deps) {
+        contents += [ get_label_info(label, "name") + "=SOURCE/" +
+                      rebase_path(get_label_info(label, "dir"), "//") ]
+      }
+    }
+  }
+
+  # The generated sources are the same in every toolchain, so generate only
+  # once, in $default_toolchain.  The same sources will be separately
+  # compiled in each toolchain that uses the bindings library.
+  _fidl_gen_dir = get_label_info(":$fidl_target($default_toolchain)",
+                                 "target_gen_dir") + "/$fidl_target"
+  group(fidl_target) {
+    forward_variables_from(invoker,
+                           [
+                             "deps",
+                             "testonly",
+                             "visibility",
+                           ])
+    metadata = {
+      fidl_inputs = invoker.sources
+      fidl_input_args =
+          [ "--files" ] + rebase_path(invoker.sources, root_build_dir)
+
+      fidl_c_include_dirs = [ "$_fidl_gen_dir/include" ]
+    }
+    data_deps = [
+      ":$fidl_target.pkg",
+    ]
+  }
+
+  template("_fidl_c_library") {
+    gen = invoker.gen
+    gen_target = "${invoker.fidl_target}._generate.${gen.name}"
+    library(target_name) {
+      forward_variables_from(invoker, "*", [ "deps" ])
+      deps = invoker.deps
+
+      # Users of the bindings library need the generated headers.
+      public_deps = [
+        ":${target_name}_config",
+      ]
+
+      # The generated headers of a dependent fidl_library() will #include the
+      # generated headers for its dependencies' bindings libraries.
+      #
+      # TODO(get_metadata): This presumes all deps are direct
+      # fidl_library() deps.  Instead, just include deps' bindings header
+      # dirs in include_dirs below via metadata.
+      foreach(dep, fidl_deps) {
+        public_deps += [ "$dep:c.headers" ]
+      }
+
+      # The generated code uses these.
+      deps += [
+        "$zx/system/ulib/fidl",
+        "$zx/system/ulib/zircon",
+      ]
+    }
+    config("${target_name}_config") {
+      forward_variables_from(invoker,
+                             [
+                               "testonly",
+                               "visibility",
+                             ])
+      include_dirs = [
+        "$_fidl_gen_dir/include",
+        # The generated headers of a dependent fidl_library() will #include the
+        # generated headers for its dependencies' bindings libraries.
+        # TODO(get_metadata): get_metadata("", [ "fidl_c_include_dirs" ]),
+      ]
+      deps = [
+        ":$gen_target($default_toolchain)",
+      ]
+    }
+  }
+
+  if (current_toolchain == default_toolchain) {
+    foreach(gen, _fidl_generators) {
+      gen_target = "${fidl_target}._generate.${gen.name}"
+      gen_outputs = []
+      gen_args = [
+        "--name",
+        fidl_name,
+      ]
+      foreach(file, gen.files) {
+        gen_args += [ file.switch ]
+        if (defined(file.path)) {
+          file = file.path
+        } else {
+          file = "${file.path_prefix}${fidl_path}${file.path_suffix}"
+        }
+        gen_outputs += [ "$_fidl_gen_dir/$file" ]
+        gen_args += [ rebase_path("$_fidl_gen_dir/$file", root_build_dir) ]
+      }
+
+      host_tool_action(gen_target) {
+        forward_variables_from(invoker, [ "testonly" ])
+        visibility = [ ":*" ]
+        deps = [
+          ":$fidl_target",
+        ]
+        tool = "$zx/system/host/fidl:fidlc"
+        outputs = gen_outputs
+        if (false) {  # TODO(get_metadata)
+          sources = [
+            # This is not "" so it doesn't get the host_tool_action() tool dep.
+            get_metadata(deps, [ "fidl_inputs" ]),
+          ]
+          args = gen_args + [ get_metadata(deps, [ "fidl_input_args" ]) ]
+        } else {
+          # TODO(get_metadata): horrible hack, uses action below
+          sources = [
+            "$_fidl_gen_dir/${gen_target}.rsp",
+          ]
+          deps += [ ":${gen_target}.rsp" ]
+          args = [ "@" + rebase_path(sources[0], root_build_dir) ]
+        }
+      }
+    }
+
+    # TODO(get_metadata): horrible hack, used above
+    _fidl_rsp = []
+    foreach(dep, fidl_deps) {
+      dep_name = get_label_info(dep, "name")
+      dep_gen_dir = get_label_info(dep, "target_gen_dir") + "/$dep_name"
+      _fidl_rsp += [ "@" + rebase_path("${dep_gen_dir}/${dep_name}.rsp",
+                                       root_build_dir) ]
+    }
+    _fidl_rsp += [ "--files" ] + rebase_path(invoker.sources, root_build_dir)
+    write_file("$_fidl_gen_dir/${fidl_target}.rsp", _fidl_rsp, "list lines")
+    action("${gen_target}.rsp") {
+      visibility = [ ":$gen_target" ]
+      sources = [
+        "$_fidl_gen_dir/${fidl_target}.rsp",
+      ]
+      outputs = [
+        "$_fidl_gen_dir/${gen_target}.rsp",
+      ]
+      depfile = "${outputs[0]}.d"
+      script = "$zx/public/gn/fidl-expand-rsp.sh"
+      args = rebase_path(outputs + [ depfile ], root_build_dir) + gen_args +
+             [ "@" + rebase_path(sources[0], root_build_dir) ]
+    }
+  } else {
+    foreach(gen, _fidl_generators) {
+      gen_target = "${fidl_target}._generate.${gen.name}"
+      target(gen.target, "${fidl_target}.${gen.name}") {
+        forward_variables_from(invoker,
+                               [
+                                 "testonly",
+                                 "visibility",
+                               ])
+        deps = [
+          ":$gen_target($default_toolchain)",
+        ]
+        sources = []
+        foreach(file, gen.files) {
+          if (defined(file.path)) {
+            file = file.path
+          } else {
+            file = "${file.path_prefix}${fidl_path}${file.path_suffix}"
+          }
+          sources += [ "$_fidl_gen_dir/$file" ]
+        }
+      }
+
+      # If this fidl_library() is the main target for the directory, then give
+      # its bindings targets `dir:dir.lang` aliases `dir:lang`.  For
+      # `dir:dir.c` that also means `dir:dir.c.headers` gets `dir:c.headers`.
+      if (get_label_info(":$fidl_target", "name") ==
+          get_path_info(get_label_info(":$fidl_target", "dir"), "file")) {
+        group(gen.name) {
+          forward_variables_from(invoker,
+                                 [
+                                   "testonly",
+                                   "visibility",
+                                 ])
+          public_deps = [
+            ":${fidl_target}.${gen.name}",
+          ]
+        }
+        if (defined(gen.subtargets)) {
+          foreach(subtarget, gen.subtargets) {
+            group("${gen.name}.${subtarget}") {
+              forward_variables_from(invoker,
+                                     [
+                                       "testonly",
+                                       "visibility",
+                                     ])
+              public_deps = [
+                ":${fidl_target}.${gen.name}.${subtarget}",
+              ]
+            }
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/public/gn/firmware.gni b/public/gn/firmware.gni
new file mode 100644
index 0000000..f39e22c
--- /dev/null
+++ b/public/gn/firmware.gni
@@ -0,0 +1,33 @@
+# 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("resource.gni")
+
+# TODO: comment
+firmware_dir = "$zx/prebuilt/downloads/firmware"
+
+# This is the same as resource(), but $outputs strings give exactly the strings
+# passed to the `load_firmware()` function by the driver code.  Giving a
+# driver() a $data_deps on the firmware() ensures that the firmware will be
+# stored somewhere and made available at runtime by `devmgr`, but the driver
+# has no knowledge of how the storage actually works.  If $outputs is omitted,
+# it defaults to `[ "{{source_file_part}}" ]` so the string matches the string
+# in `sources` after any slash.
+template("firmware") {
+  resource(target_name) {
+    forward_variables_from(invoker, "*", [ "outputs" ])
+    if (defined(invoker.outputs)) {
+      outputs = []
+      foreach(path, invoker.outputs) {
+        assert(rebase_path(path, "foo") != path,
+               "`outputs` in firmware() must be relative paths")
+        outputs += [ "lib/firmware/$path" ]
+      }
+    } else {
+      outputs = [
+        "lib/firmware/{{source_file_part}}",
+      ]
+    }
+  }
+}
diff --git a/public/gn/gen-fidlc-rsp.sh b/public/gn/gen-fidlc-rsp.sh
new file mode 100755
index 0000000..4766a3e
--- /dev/null
+++ b/public/gn/gen-fidlc-rsp.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# 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.
+
+set -e
+
+OUTFILE="$1"
+DEPFILE="$2"
+DEPOUTFILE="$3"
+RSPFILE="$4"
+shift 4
+
+ARGS=()
+FILES=()
+
+handle_args() {
+  ARGS+=("$@")
+  local arg in_files=false
+  for arg in "$@"; do
+    if [ "$arg" = --files ]; then
+      in_files=true
+    elif $in_files; then
+      FILES+=("$arg")
+    fi
+  done
+}
+
+read_rspfile() {
+  local arg
+  while read arg; do
+    handle_args "$arg"
+  done
+}
+
+write_output() {
+  local arg
+  for arg in "${ARGS[@]}"; do
+    echo "$arg"
+  done
+}
+
+handle_args "$@"
+read_rspfile < "$RSPFILE"
+echo "$DEPOUTFILE: ${FILES[*]}" > "$DEPFILE"
+write_output > "$OUTFILE"
diff --git a/public/gn/host_tool_action.gni b/public/gn/host_tool_action.gni
new file mode 100644
index 0000000..bef9ad7
--- /dev/null
+++ b/public/gn/host_tool_action.gni
@@ -0,0 +1,105 @@
+# 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("$zx/public/gn/toolchain/select_toolchain.gni")
+
+template("_host_tool_action_target") {
+  action_target = target_name
+
+  assert(defined(invoker.tool), "tool must be defined for $target_name")
+  assert(defined(invoker.outputs), "outputs must be defined for $target_name")
+  assert(defined(invoker.args), "args must be defined for $target_name")
+
+  # Dispatch to a host toolchain to get the tool built.
+  select_toolchain("_tool.$action_target") {
+    visibility = [
+      ":$action_target",
+      ":_rspfile.$action_target",
+    ]
+    environment_label = "$zx/public/gn/toolchain:host"
+    cpu = host_cpu
+    os = host_os
+    deps = [
+      invoker.tool,
+    ]
+  }
+
+  # The response file generated by host_tool() gives the files used (like
+  # the executable itself), then "--", then the arguments that make up the
+  # command line prefix to invoke the tool.  host_tool_action.sh consumes that.
+  rspfile = "$target_gen_dir/$target_name._host_tool_action.rsp"
+  generated_file("_rspfile.$action_target") {
+    deps = [
+      ":_tool.$action_target",
+    ]
+    outputs = [
+      rspfile,
+    ]
+    data_keys = [ "host_tool_rspfile" ]
+    walk_keys = [ "host_tool_barrier" ]
+  }
+
+  target(invoker._target_type, action_target) {
+    forward_variables_from(invoker,
+                           [
+                             "data_deps",
+                             "deps",
+                             "inputs",
+                             "outputs",
+                             "public_deps",
+                             "sources",
+                             "testonly",
+                             "visibility",
+                           ])
+    if (!defined(deps)) {
+      deps = []
+    }
+    if (!defined(inputs)) {
+      inputs = []
+    }
+    deps += [
+      ":_rspfile.$action_target",
+      ":_tool.$action_target",
+    ]
+    inputs += [ rspfile ]
+
+    depfile = "$target_out_dir/$target_name._host_tool_action.d"
+    if (defined(invoker.depfile)) {
+      orig_depfile = rebase_path(invoker.depfile, root_build_dir)
+    } else {
+      orig_depfile = "-"
+    }
+
+    script = "$zx/public/gn/host_tool_action.sh"
+    args = rebase_path([
+                         rspfile,
+                         outputs[0],
+                         depfile,
+                       ],
+                       root_build_dir) + [ orig_depfile ] + invoker.args
+
+    metadata = {
+      # Never follow the deps to find link outputs from invoker.tool.
+      # TODO: Maybe should still follow invoker.deps?
+      link_barrier = []
+      if (defined(invoker.metadata)) {
+        forward_variables_from(invoker.metadata, "*")
+      }
+    }
+  }
+}
+
+template("host_tool_action") {
+  _host_tool_action_target(target_name) {
+    _target_type = "action"
+    forward_variables_from(invoker, "*")
+  }
+}
+
+template("host_tool_action_foreach") {
+  _host_tool_action_target(target_name) {
+    _target_type = "action_foreach"
+    forward_variables_from(invoker, "*")
+  }
+}
diff --git a/public/gn/host_tool_action.sh b/public/gn/host_tool_action.sh
new file mode 100755
index 0000000..9d05d63
--- /dev/null
+++ b/public/gn/host_tool_action.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# 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.
+
+set -e
+
+RSPFILE="$1"
+OUTPUT="$2"
+DEPFILE="$3"
+ORIG_DEPFILE="$4"
+shift 4
+
+CMD=()
+FILES=()
+
+read_rspfile() {
+  local word
+  while read word; do
+    if [ "$word" = -- ]; then
+      break
+    else
+      FILES+=("$word")
+    fi
+  done
+  while read word; do
+    CMD+=("$word")
+  done
+}
+
+process_args() {
+  local arg rspfile
+  while [ $# -gt 0 ]; do
+    arg="$1"
+    shift
+    if [[ "$arg" == @* ]]; then
+      rspfile="${arg#@}"
+      FILES+=("$rspfile")
+      while read arg; do
+        CMD+=("$arg")
+      done < "$rspfile"
+    else
+      CMD+=("$arg")
+    fi
+  done
+}
+
+read_rspfile < "$RSPFILE"
+process_args "$@"
+
+"${CMD[@]}"
+
+if [ "$ORIG_DEPFILE" = - ]; then
+  # The host_tool_action() has no user-specified depfile, so just generate
+  # one that lists the files from the metadata rspfile.
+  echo "$OUTPUT: ${FILES[*]}" > "$DEPFILE"
+else
+  # Append the file list to the user-generated depfile.
+  echo "$(< "$ORIG_DEPFILE") ${FILES[*]}" > "$DEPFILE"
+fi
diff --git a/public/gn/pkg.gni b/public/gn/pkg.gni
new file mode 100644
index 0000000..30243b0
--- /dev/null
+++ b/public/gn/pkg.gni
@@ -0,0 +1,26 @@
+# 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.
+
+# TODO(mcgrathr): This is all temporary stuff to maintain rough compatibility
+# with the old makefile build as used by the higher-layer Fuchsia GN build.
+
+template("pkg_export") {
+  generated_file(target_name) {
+    outputs = [
+      "$root_build_dir/export/$target_name",
+    ]
+    output_conversion = "list lines"
+    forward_variables_from(invoker,
+                           [
+                             "contents",
+                             "data_keys",
+                             "deps",
+                             "walk_keys",
+                             "testonly",
+                           ])
+    metadata = {
+      pkg_export_manifest = [ target_name ]
+    }
+  }
+}
diff --git a/public/gn/resource.gni b/public/gn/resource.gni
new file mode 100644
index 0000000..60fa440
--- /dev/null
+++ b/public/gn/resource.gni
@@ -0,0 +1,64 @@
+# 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.
+
+# Looks just like a copy() target but $outputs are relative target paths.
+# Using $data_deps to this resource() target in each target whose code uses
+# $outputs at runtime ensures that the files will be present on the system.
+template("resource") {
+  group(target_name) {
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "metadata",
+                             "outputs",
+                             "sources",
+                           ])
+    metadata = {
+      manifest_lines = []
+      if (defined(invoker.metadata)) {
+        forward_variables_from(invoker.metadata, "*")
+      }
+      foreach(source, invoker.sources) {
+        foreach(target, process_file_template([ source ], invoker.outputs)) {
+          assert(rebase_path(target, "foo") != target,
+                 "`outputs` in resource() cannot start with /")
+          manifest_lines +=
+              [ target + "=" + rebase_path(source, root_build_dir) ]
+        }
+      }
+    }
+  }
+}
+
+# Looks just like a generated_file() target but $outputs is like resource().
+template("generated_resource") {
+  generated_file(target_name) {
+    forward_variables_from(invoker, "*", [ "metadata" ])
+    assert(outputs == [ outputs[0] ],
+           "generated_resource() requires a single element in `outputs")
+
+    # Select a place to generate the contents at `gn gen` time.
+    file = "$target_gen_dir/$target_name"
+    if (defined(output_conversion) && output_conversion == "json") {
+      file += ".json"
+    } else {
+      file += ".txt"
+    }
+
+    # Add metadata to add that file to a filesystem image.
+    metadata = {
+      manifest_lines = []
+      if (defined(invoker.metadata)) {
+        forward_variables_from(invoker.metadata, "*")
+      }
+      manifest_lines += [ "${outputs[0]}=" + rebase_path(file, root_build_dir) ]
+    }
+
+    # That static file is the actual output of this target.
+    outputs = []
+    outputs = [
+      file,
+    ]
+  }
+}
diff --git a/public/gn/toolchain/BUILD.gn b/public/gn/toolchain/BUILD.gn
index 0f016b5..e7694c9 100644
--- a/public/gn/toolchain/BUILD.gn
+++ b/public/gn/toolchain/BUILD.gn
@@ -19,14 +19,8 @@
   propagates_configs = true
 }
 
-define_environment("host") {
-  cpu = host_cpu
-  os = host_os
-
-  globals = {
-    is_host = true
-  }
-  strip = true
+# This defines user and host toolchains.
+define_standard_environments("") {
 }
 
 standard_host = false
diff --git a/public/gn/toolchain/c_utils.gni b/public/gn/toolchain/c_utils.gni
new file mode 100644
index 0000000..7a1580d
--- /dev/null
+++ b/public/gn/toolchain/c_utils.gni
@@ -0,0 +1,122 @@
+# 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.
+
+# Like action() but using utility binaries from the C/C++ toolchain.
+# This is the way to use `nm`, `objcopy`, etc.
+#
+# Parameters
+#
+#   utils (required)
+#     [list of strings] Utilities to use, e.g. "nm", "objcopy", "objdump".
+#
+#   script (optional)
+#     [string] Same as for action().  The script receives an implicit
+#     argument for each element in $utils giving the command to run.
+#     If omitted, then $utils must have only one element and that command
+#     itself will be run with $args just as given.
+#
+#   args (required)
+#     [list of strings] Same as for action().  If there is a $script,
+#     the implicit $utils arguments precede $args.
+#
+#   deps, inputs, outputs, sources, testonly, visibility
+#      Same as for action().
+#
+template("toolchain_utils_action") {
+  assert(defined(invoker.utils),
+         "toolchain_utils_action(\"$target_name\") requires `utils`")
+  forward_variables_from(invoker, [ "script" ])
+
+  utils_inputs = []
+  utils_paths = []
+  if (toolchain.tool_dir != "") {
+    # The toolchain binaries are in a specified location (e.g. a prebuilt).
+    foreach(util, invoker.utils) {
+      if (util == "cc") {
+        util = toolchain.cc
+      } else {
+        util = "${toolchain.tool_prefix}${util}"
+      }
+      util = "${toolchain.tool_dir}/${util}"
+      utils_inputs += [ util ]
+      utils_paths += [ rebase_path(util, root_build_dir) ]
+    }
+  } else {
+    # The toolchain binaries are just found in the system PATH.
+    # They won't be used as dependencies.
+    if (!defined(script)) {
+      # If there's no script, utils_paths[0] will become the script.
+      # But the script has to be a known location that's a dependency.
+      # So use a dummy wrapper as the script.
+      script = "/usr/bin/env"
+    }
+    foreach(util, invoker.utils) {
+      if (util == "cc") {
+        util = toolchain.cc
+      } else {
+        util = "${toolchain.tool_prefix}${util}"
+      }
+      utils_paths += [ util ]
+    }
+  }
+
+  action(target_name) {
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "args",
+                             "script",
+                             "utils",
+                           ])
+    if (!defined(inputs)) {
+      inputs = []
+    }
+    inputs += utils_inputs
+    if (defined(script)) {
+      args = utils_paths + invoker.args
+    } else {
+      script = rebase_path(utils_paths[0], "", root_build_dir)
+      assert(
+          utils_paths == [ utils_paths[0] ],
+          "toolchain_utils_action(\"$target_name\") without `script` must have exactly one element in `utils`")
+      args = invoker.args
+    }
+  }
+}
+
+# Define an action to convert an ELF file to a raw binary image file.
+#
+# Parameters
+#
+#   sources (required)
+#     [list of one string] Input file.
+#
+#   outputs (required)
+#     [list of one string] Output file.
+#
+#   deps, testonly, visibility
+#     Same as for action().
+#
+template("image_binary") {
+  toolchain_utils_action(target_name) {
+    forward_variables_from(invoker,
+                           [
+                             "deps",
+                             "metadata",
+                             "outputs",
+                             "sources",
+                             "testonly",
+                             "visibility",
+                           ])
+    assert(sources == [ sources[0] ], "sources must have exactly one element")
+    assert(outputs == [ outputs[0] ], "outputs must have exactly one element")
+    utils = [ "objcopy" ]
+    args = [
+      "-O",
+      "binary",
+      rebase_path(sources[0], root_build_dir),
+      rebase_path(outputs[0], root_build_dir),
+    ]
+  }
+}
diff --git a/public/gn/toolchain/environment.gni b/public/gn/toolchain/environment.gni
index f15d99a..e676994 100644
--- a/public/gn/toolchain/environment.gni
+++ b/public/gn/toolchain/environment.gni
@@ -612,3 +612,48 @@
 set_defaults("define_environment") {
   configs = standard_configs
 }
+
+# Define environments based on $standard_environments.
+#
+# $target_name is a suffix on the `name` fields in $standard_environments
+# elements and must start with ".".  Parameters are generally as for
+# define_environment() except $cpu and $os cannot be set and $configs has
+# $standard_configs (and others) prepended rather than being preset.
+#
+template("define_standard_environments") {
+  assert(target_name == "" || get_path_info(target_name, "extension") != "",
+         "define_standard_environments() name must start with `.`")
+  foreach(env, standard_environments) {
+    foreach(target, env.targets) {
+      define_environment("${env.name}${target_name}") {
+        forward_variables_from(target, "*")
+        forward_variables_from(env,
+                               "*",
+                               [
+                                 "configs",
+                                 "name",
+                                 "targets",
+                               ])
+
+        # Let the invoker clobber most settings.
+        forward_variables_from(invoker,
+                               "*",
+                               [
+                                 "configs",
+                                 "cpu",
+                                 "os",
+                               ])
+
+        # The invoker can have used `configs -=` to remove some of the
+        # default configs set above.  Now append the base environment's
+        # configs and the invoker's.
+        if (defined(env.configs)) {
+          configs += env.configs
+        }
+        if (defined(invoker.configs)) {
+          configs += invoker.configs
+        }
+      }
+    }
+  }
+}
diff --git a/public/gn/zbi.gni b/public/gn/zbi.gni
new file mode 100644
index 0000000..ed6e4ce
--- /dev/null
+++ b/public/gn/zbi.gni
@@ -0,0 +1,366 @@
+# 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("$zx/public/gn/host_tool_action.gni")
+import("$zx/public/gn/resource.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# The target generates a manifest that collects any manifest_lines from its
+# dependencies' metadata, e.g. contributed by resource() targets.  It
+# contributes metadata that will drive zbi() to use this manifest, as well
+# as any non-BOOTFS inputs given via $sources and $args.
+template("zbi_input") {
+  input_target = target_name
+  manifest_target = "$target_name._manifest"
+  manifest_file = "$target_gen_dir/${target_name}.manifest"
+
+  generated_file(manifest_target) {
+    visibility = [ ":$input_target" ]
+    forward_variables_from(invoker,
+                           [
+                             "data_deps",
+                             "deps",
+                             "testonly",
+                           ])
+    outputs = [
+      manifest_file,
+    ]
+    output_conversion = "list lines"
+    data_keys = [ "manifest_lines" ]
+    walk_keys = [ "manifest_barrier" ]
+
+    # An embedded manifest contributes to metadata.manifest_lines directly.
+    if (defined(invoker.manifest)) {
+      entries = []
+      foreach(entry, invoker.manifest) {
+        if (entry == "$entry") {
+          # It's a literal manifest entry string.
+          # Note this doesn't express any dependency on its source file!
+          entries += [ entry ]
+        } else {
+          # It's a manifest entry in the style of a copy() target.
+          foreach(source, entry.sources) {
+            inputs += [ source ]
+            source_path = rebase_path(source, root_build_dir)
+            foreach(target, process_file_template([ source ], entry.outputs)) {
+              entries += [ "${target}=${source_path}" ]
+            }
+          }
+        }
+      }
+      metadata = {
+        manifest_lines = entries
+      }
+    }
+  }
+
+  # This is separate from the manifest target just because the metadata
+  # contributed here must not be included in the manifest metadata query.
+  group(input_target) {
+    forward_variables_from(invoker,
+                           [
+                             "visibility",
+                             "testonly",
+                           ])
+    deps = [
+      ":$manifest_target",
+    ]
+
+    metadata = {
+      zbi_input_args = []
+
+      # An explicit type applies only to $sources and $args.
+      if (defined(invoker.type) && invoker.type != "") {
+        zbi_input_args += [ "--type=${invoker.type}" ]
+      }
+
+      # Explicit $args come first, for e.g. "-u" or "-g" to affect inputs.
+      # $args may also contain "--entry=..." payloads directly.
+      if (defined(invoker.args)) {
+        zbi_input_args += invoker.args
+      }
+
+      if (defined(invoker.sources)) {
+        zbi_input_args += rebase_path(invoker.sources, root_build_dir)
+      }
+
+      # Always include the manifest generated from the deps here.  The
+      # barrier will prevent zbi() from collecting manifest_lines that are
+      # redundant with this manifest.
+      zbi_input_args += [
+        "--files",
+        rebase_path(manifest_file, root_build_dir),
+      ]
+      manifest_barrier = []
+
+      if (defined(invoker.metadata)) {
+        forward_variables_from(invoker.metadata,
+                               "*",
+                               [
+                                 "manifest_barrier",
+                                 "manifest_lines",
+                                 "zbi_input_args",
+                               ])
+      }
+    }
+  }
+}
+
+template("zbi") {
+  zbi_target = target_name
+  input_target = "$target_name._zbi.input"
+  rspfile_target = "$target_name._zbi.rsp"
+  rspfile = "$target_gen_dir/$target_name._zbi.rsp"
+
+  if (defined(invoker.output_name)) {
+    output_file = invoker.output_name
+  } else {
+    output_file = target_name
+  }
+
+  if (defined(invoker.output_extension)) {
+    if (invoker.output_extension != "") {
+      output_file += ".${invoker.output_extension}"
+    }
+  } else {
+    output_file += ".zbi"
+  }
+
+  output_file = "$target_out_dir/$output_file"
+
+  zbi_input(input_target) {
+    visibility = [ ":$rspfile_target" ]
+    forward_variables_from(invoker,
+                           [
+                             "deps",
+                             "testonly",
+                           ])
+    assert(defined(deps), "zbi(\"$zbi_target\") must have `deps`")
+  }
+
+  # Generate a response file of input arguments collected from metadata.
+  generated_file(rspfile_target) {
+    visibility = [ ":$zbi_target" ]
+    forward_variables_from(invoker, [ "testonly" ])
+    deps = [
+      ":$input_target",
+    ]
+    outputs = [
+      rspfile,
+    ]
+    data_keys = [ "zbi_input_args" ]
+    output_conversion = "list lines"
+  }
+
+  host_tool_action(zbi_target) {
+    forward_variables_from(invoker,
+                           [
+                             "data_deps",
+                             "visibility",
+                             "testonly",
+                           ])
+    deps = [
+      ":$rspfile_target",
+    ]
+    outputs = [
+      output_file,
+    ]
+    depfile = "${output_file}.d"
+    sources = [
+      rspfile,
+    ]
+
+    tool = "$zx/system/host/zbi"
+    args = [
+      "--output=" + rebase_path(output_file, root_build_dir),
+      "--depfile=" + rebase_path(depfile, root_build_dir),
+      "@" + rebase_path(rspfile, root_build_dir),
+    ]
+
+    # Require a complete ZBI for the specified $cpu (or $current_cpu).
+    # A value of "" means it need not be a complete ZBI.
+    if (defined(invoker.cpu)) {
+      cpu = invoker.cpu
+    } else {
+      cpu = current_cpu
+    }
+    if (cpu != "") {
+      args += [ "--complete=$cpu" ]
+    }
+
+    # This comes last to affect the output despite any earlier
+    # "-c" or "-u" from metadata.zbi_input_args meant to affect
+    # a particular input (e.g. for "--type=ramdisk").
+    if (defined(invoker.compress) && !invoker.compress) {
+      args += [ "--uncompressed" ]
+    } else {
+      args += [ "--compressed" ]
+    }
+
+    metadata = {
+      images = [
+        {
+          type = "manifest"
+          name = zbi_target
+          path = rebase_path("$target_gen_dir/$input_target.manifest",
+                             root_build_dir)
+        },
+        {
+          type = "zbi"
+          name = zbi_target
+          path = rebase_path(output_file, root_build_dir)
+        },
+      ]
+
+      # Provide metadata so that a zbi() target can also act as if it were a
+      # zbi_input() with `type = "zbi"` and `sources` of this target's $outputs.
+      # Thus a zbi() target can be a dependency of another zbi() target to
+      # combine them without requiring an intervening zbi_input() target.
+      zbi_input_args =
+          [ "--type=container" ] + rebase_path(outputs, root_build_dir)
+
+      if (defined(invoker.metadata)) {
+        forward_variables_from(invoker.metadata,
+                               "*",
+                               [
+                                 "images",
+                                 "zbi_input_args",
+                               ])
+      }
+    }
+  }
+}
+
+template("devmgr_config") {
+  main_target = target_name
+  contents_target = "$target_name._devmgr_config"
+
+  generated_resource(contents_target) {
+    visibility = [ ":$main_target" ]
+    forward_variables_from(invoker,
+                           [
+                             "data_deps",
+                             "deps",
+                             "metadata",
+                             "testonly",
+                           ])
+    outputs = [
+      "config/devmgr",
+    ]
+    output_conversion = "list lines"
+    data_keys = [ "devmgr_config" ]
+    walk_keys = [ "devmgr_config_barrier" ]
+  }
+
+  # This is separate just so that it can add the metadata barrier and not
+  # have it affect this metadata collection walk itself.
+  group(main_target) {
+    forward_variables_from(invoker,
+                           [
+                             "visibility",
+                             "testonly",
+                           ])
+    deps = [
+      ":$contents_target",
+    ]
+    metadata = {
+      devmgr_config_barrier = []
+    }
+  }
+}
+
+template("bootimage") {
+  if (defined(invoker.cpu)) {
+    cpu = invoker.cpu
+  } else {
+    cpu = current_cpu
+  }
+  assert(cpu != "", "bootimage() requires `cpu`")
+  if (cpu != current_cpu) {
+    # Redirect to a CPU-specific toolchain.
+    select_toolchain(target_name) {
+      forward_variables_from(invoker,
+                             [
+                               "testonly",
+                               "visibility",
+                             ])
+      cpu = cpu
+      environment_label = "$zx/public/gn/toolchain:user"
+      deps = [
+        ":$target_name",
+      ]
+    }
+    not_needed(invoker, "*")
+  } else {
+    zbi_target = target_name
+    devmgr_config_target = "${target_name}.devmgr_config"
+
+    # Always generate a /boot/config/devmgr file that rolls up
+    # the metadata.devmgr_config lists from deps.
+    devmgr_config(devmgr_config_target) {
+      visibility = [ ":$zbi_target._zbi.input._manifest" ]
+      forward_variables_from(invoker,
+                             [
+                               "deps",
+                               "testonly",
+                             ])
+    }
+
+    # The main target is a bootable zbi() that rolls up every zbi_input() and
+    # metadata.devmgr_config list from deps.
+    zbi(zbi_target) {
+      cpu = cpu
+      forward_variables_from(invoker,
+                             [
+                               "deps",
+                               "metadata",
+                               "output_name",
+                               "testonly",
+                               "visibility",
+                             ])
+      if (defined(visibility)) {
+        visibility += [
+          ":$target_name",
+          ":$img_target",
+        ]
+      }
+      if (!defined(deps)) {
+        deps = []
+      }
+      deps += [ ":$devmgr_config_target" ]
+    }
+
+    if (false) {  # TODO(get_metadata): later
+      img_target = "${target_name}.img"
+
+      # The secondary target is a board-specific wrapping of the ZBI made
+      # above.  The metadata flowing up from $zx/system/dev/board/$board
+      # supplies the details of how this is made.
+      action(img_target) {
+        visibility = [ ":$zbi_target" ]
+        deps = [
+          ":$zbi_target",
+        ]
+        forward_variables_from(invoker,
+                               [
+                                 "output_name",
+                                 "testonly",
+                               ])
+        if (!defined(output_name)) {
+          output_name = target_name
+        }
+        outputs = [
+          "$root_build_dir/$output_name",
+        ]
+
+        # TODO(get_metadata): get_metadata([ "" ], [ "bootimage_script" ])
+        script = "/bin/echo"
+        sources = get_metadata([ "" ], [ "bootimage_inputs" ])
+        args = get_metadata([ ":$zbi_target" ], [ "bootimage_args" ]) +
+               rebase_path(get_target_outputs(":$zbi_target") + outputs,
+                           root_build_dir)
+      }
+    }
+  }
+}
diff --git a/public/kernel/BUILD.gn b/public/kernel/BUILD.gn
new file mode 100644
index 0000000..e54d8cd
--- /dev/null
+++ b/public/kernel/BUILD.gn
@@ -0,0 +1,27 @@
+# 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("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# $zx/public/kernel:$cpu is a target to build the standard kernel for $cpu.
+# Build configuration will select the variant to use for the kernel.
+foreach(cpu, standard_fuchsia_cpus) {
+  select_toolchain(cpu) {
+    cpu = target_name
+    environment_label = "$zx/kernel"
+    deps = [
+      "$zx/kernel",
+    ]
+  }
+}
+
+if (current_cpu != "") {
+  select_toolchain("kernel") {
+    environment_label = "$zx/kernel"
+    deps = [
+      "$zx/kernel",
+    ]
+  }
+}
diff --git a/scripts/gen-ids-file b/scripts/gen-ids-file
new file mode 100755
index 0000000..45c1c73
--- /dev/null
+++ b/scripts/gen-ids-file
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+# 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.
+
+set -e
+
+readonly READELF="$1"
+readonly OUTFILE="$2"
+readonly DEPFILE="$3"
+readonly LISTFILE="$4"
+
+FILES=()
+
+gen_id_line() {
+  FILES+=("$1")
+  LC_ALL=C "$READELF" -n "$1" | sed -n '/Build ID:/{s/.*: //;s@$@ '"$1"'@p;}'
+}
+
+gen_id_lines_from_list() {
+  local file
+  while read file; do
+    gen_id_line "$file"
+  done
+}
+
+trap 'rm -f "$OUTFILE"' ERR HUP INT TERM
+
+gen_id_lines_from_list < "$LISTFILE" > "$OUTFILE"
+
+echo "$OUTFILE: ${FILES[*]}" > "$DEPFILE"
diff --git a/scripts/gen-kaslr-fixups.sh b/scripts/gen-kaslr-fixups.sh
index 9493b972..d7b0683 100755
--- a/scripts/gen-kaslr-fixups.sh
+++ b/scripts/gen-kaslr-fixups.sh
@@ -25,25 +25,32 @@
 # each run of adjustments, and then #include's the output of this script.
 
 usage() {
-  echo >&2 "Usage: $0 [--pure] KERNEL READELF OBJDUMP OUTFILE"
+  echo >&2 "Usage: $0 READELF OBJDUMP [--pure] KERNEL OUTFILE"
   exit 2
 }
 
+if [ $# -lt 2 ]; then
+  usage
+fi
+
+READELF="$1"
+shift
+OBJDUMP="$1"
+shift
+
 PURE=0
-if [ $# -eq 5 -a "$1" = --pure ]; then
+if [ $# -gt 1 -a "$1" = --pure ]; then
   PURE=1
   shift
 fi
 
-if [ $# -ne 4 ]; then
+if [ $# -ne 2 ]; then
   usage
 fi
 
 AWK=awk
 KERNEL="$1"
-READELF="$2"
-OBJDUMP="$3"
-OUTFILE="$4"
+OUTFILE="$2"
 
 grok_fixups() {
   "$AWK" -v kernel="$KERNEL" -v objdump="$OBJDUMP" -v pure=$PURE '
@@ -87,6 +94,7 @@
     next
 }
 NF == 0 || $1 == "Offset" { next }
+!secname { exit(1); }
 # Ignore standard non-allocated sections.
 secname ~ /^\.debug/ || secname == ".comment" { next }
 # .text.boot contains code that runs before fixups.
@@ -201,6 +209,6 @@
   set -o pipefail
 fi
 
-trap 'rm -f "$OUTFILE"' ERR
+trap 'rm -f "$OUTFILE"' ERR INT HUP TERM
 
 LC_ALL=C "$READELF" -W -r "$KERNEL" | grok_fixups > "$OUTFILE"
diff --git a/scripts/gen-rodso-code.sh b/scripts/gen-rodso-code.sh
index e53e057..94736d5 100755
--- a/scripts/gen-rodso-code.sh
+++ b/scripts/gen-rodso-code.sh
@@ -17,7 +17,7 @@
 # of entries in the table.
 
 usage() {
-  echo >&2 "Usage: $0 NM READELF OUTFILE {NAME DSO}..."
+  echo >&2 "Usage: $0 NM READELF [--depfile DEPFILE] OUTFILE {NAME DSO}..."
   exit 2
 }
 
@@ -29,6 +29,14 @@
 shift
 READELF="$1"
 shift
+
+DEPFILE=
+if [ $# -gt 2 -a "$1" = "--depfile" ]; then
+  DEPFILE="$2"
+  shift 2
+fi
+USED_FILES=()
+
 OUTFILE="$1"
 shift
 
@@ -135,15 +143,33 @@
   }; then : ; fi
 }
 
+trap 'rm -f "$OUTFILE" ${DEPFILE:+"$DEPFILE"}' ERR HUP INT TERM
+
 while [ $# -gt 0 ]; do
   if [ $# -lt 2 ]; then
     usage
   fi
-  echo "#define ${1}_FILENAME \"${2}\"" > $OUTFILE
-  find_segments "$1" "$2"
-  find_code_symbols "$1" "$2"
-  if [ $have_dynsym = yes ]; then
-    find_dynsym_slots "$1" "$2"
-  fi
+  name="$1"
+  dso="$2"
   shift 2
+
+  # This argument might be a response file.
+  if [[ "$dso" == @* ]]; then
+    rspfile="${dso#@}"
+    dso="$(< "$rspfile")"
+    USED_FILES+=("$rspfile" "$dso")
+  else
+    USED_FILES+=("$dso")
+  fi
+
+  echo "#define ${name}_FILENAME \"${dso}\"" > $OUTFILE
+  find_segments "$name" "$dso"
+  find_code_symbols "$name" "$dso"
+  if [ $have_dynsym = yes ]; then
+    find_dynsym_slots "$name" "$dso"
+  fi
 done
+
+if [ -n "$DEPFILE" ]; then
+  echo "$OUTFILE: ${USED_FILES[*]}" > "$DEPFILE"
+fi
diff --git a/scripts/gen-vdso-valid-sysret.sh b/scripts/gen-vdso-valid-sysret.sh
index db56bd7..ae7a11b 100755
--- a/scripts/gen-vdso-valid-sysret.sh
+++ b/scripts/gen-vdso-valid-sysret.sh
@@ -63,6 +63,17 @@
 }
 
 set -e
+
+case $# in
+1)
+  exec < "$1"
+  ;;
+2) 
+  trap "rm -f '$2'" ERR HUP INT TERM
+  exec < "$1" > "$2"
+  ;;
+esac
+
 header
 scan < "$1"
 footer
diff --git a/scripts/shlib-symbols b/scripts/shlib-symbols
index 9fcf4d2..da1ce64 100755
--- a/scripts/shlib-symbols
+++ b/scripts/shlib-symbols
@@ -35,6 +35,18 @@
   set -o pipefail -e
 fi
 
+usage() {
+  echo >&2 "Usage: $0 NM [-a] [-z] DSO OUTPUT [DEPFILE]"
+  exit 2
+}
+
+if [ $# -lt 3 ]; then
+  usage
+fi
+
+NM="$1"
+shift
+
 show_address=false
 zero_function_size=false
 while [ $# -gt 0 ]; do
@@ -46,13 +58,26 @@
   shift
 done
 
-if [ $# -ne 2 ]; then
-  echo >&2 "Usage: $0 [-a] [-z] NM DSO"
-  exit 2
+if [ $# -ne 2 -a $# -ne 3 ]; then
+  usage
 fi
 
-NM="$1"
-DSO="$2"
+DSO="$1"
+OUTPUT="$2"
+DEPFILE="$3"
+
+USED_FILES=()
+if [[ "$DSO" == @* ]]; then
+  rspfile="${DSO#@}"
+  DSO="$(< "$rspfile")"
+  USED_FILES+=("$rspfile" "$DSO")
+else
+  USED_FILES+=("$DSO")
+fi
+
+if [ -n "$DEPFILE" ]; then
+  echo "$OUTPUT: ${USED_FILES[*]}" > "$DEPFILE"
+fi
 
 dump_names() {
   "$NM" -P -g -D -S "$DSO"
@@ -113,4 +138,5 @@
   done
 }
 
-dump_names | massage
+trap 'rm -f "$OUTPUT" ${DEPFILE:+$"DEPFILE"}' ERR HUP INT TERM
+dump_names | massage > "$OUTPUT"
diff --git a/system/banjo/ddk-driver/BUILD.gn b/system/banjo/ddk-driver/BUILD.gn
new file mode 100644
index 0000000..e2a9c0f
--- /dev/null
+++ b/system/banjo/ddk-driver/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-driver") {
+  sources = [
+    "driver.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-physiter/BUILD.gn b/system/banjo/ddk-physiter/BUILD.gn
new file mode 100644
index 0000000..5a805c5
--- /dev/null
+++ b/system/banjo/ddk-physiter/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-physiter") {
+  sources = [
+    "phys-iter.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-acpi/BUILD.gn b/system/banjo/ddk-protocol-acpi/BUILD.gn
new file mode 100644
index 0000000..13912f2
--- /dev/null
+++ b/system/banjo/ddk-protocol-acpi/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-acpi") {
+  sources = [
+    "acpi.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-amlogiccanvas/BUILD.gn b/system/banjo/ddk-protocol-amlogiccanvas/BUILD.gn
new file mode 100644
index 0000000..df4494b
--- /dev/null
+++ b/system/banjo/ddk-protocol-amlogiccanvas/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-amlogiccanvas") {
+  sources = [
+    "amlogic-canvas.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-badblock/BUILD.gn b/system/banjo/ddk-protocol-badblock/BUILD.gn
new file mode 100644
index 0000000..a79eed4
--- /dev/null
+++ b/system/banjo/ddk-protocol-badblock/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-badblock") {
+  sources = [
+    "bad-block.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-block-partition/BUILD.gn b/system/banjo/ddk-protocol-block-partition/BUILD.gn
new file mode 100644
index 0000000..81df34e
--- /dev/null
+++ b/system/banjo/ddk-protocol-block-partition/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-block-partition") {
+  sources = [
+    "partition.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-device-block",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-block-volume/BUILD.gn b/system/banjo/ddk-protocol-block-volume/BUILD.gn
new file mode 100644
index 0000000..1e97001
--- /dev/null
+++ b/system/banjo/ddk-protocol-block-volume/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-block-volume") {
+  sources = [
+    "volume.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-device-block",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-block/BUILD.gn b/system/banjo/ddk-protocol-block/BUILD.gn
new file mode 100644
index 0000000..b222243
--- /dev/null
+++ b/system/banjo/ddk-protocol-block/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-block") {
+  sources = [
+    "block.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-device-block",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-bt-gattsvc/BUILD.gn b/system/banjo/ddk-protocol-bt-gattsvc/BUILD.gn
new file mode 100644
index 0000000..42a3190
--- /dev/null
+++ b/system/banjo/ddk-protocol-bt-gattsvc/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-bt-gattsvc") {
+  sources = [
+    "bt-gatt-svc.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-bt-hci/BUILD.gn b/system/banjo/ddk-protocol-bt-hci/BUILD.gn
new file mode 100644
index 0000000..988eba4
--- /dev/null
+++ b/system/banjo/ddk-protocol-bt-hci/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-bt-hci") {
+  sources = [
+    "bt-hci.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-clk/BUILD.gn b/system/banjo/ddk-protocol-clk/BUILD.gn
new file mode 100644
index 0000000..e50aa4e
--- /dev/null
+++ b/system/banjo/ddk-protocol-clk/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-clk") {
+  sources = [
+    "clk.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-display-controller/BUILD.gn b/system/banjo/ddk-protocol-display-controller/BUILD.gn
new file mode 100644
index 0000000..cc57020
--- /dev/null
+++ b/system/banjo/ddk-protocol-display-controller/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-display-controller") {
+  sources = [
+    "display-controller.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-device-audio",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-ethernet-board/BUILD.gn b/system/banjo/ddk-protocol-ethernet-board/BUILD.gn
new file mode 100644
index 0000000..238cacd
--- /dev/null
+++ b/system/banjo/ddk-protocol-ethernet-board/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-ethernet-board") {
+  sources = [
+    "ethernet-board.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-ethernet-mac/BUILD.gn b/system/banjo/ddk-protocol-ethernet-mac/BUILD.gn
new file mode 100644
index 0000000..f12a191
--- /dev/null
+++ b/system/banjo/ddk-protocol-ethernet-mac/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-ethernet-mac") {
+  sources = [
+    "ethernet-mac.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-ethernet/BUILD.gn b/system/banjo/ddk-protocol-ethernet/BUILD.gn
new file mode 100644
index 0000000..560b58c
--- /dev/null
+++ b/system/banjo/ddk-protocol-ethernet/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-ethernet") {
+  sources = [
+    "ethernet.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-gpio/BUILD.gn b/system/banjo/ddk-protocol-gpio/BUILD.gn
new file mode 100644
index 0000000..c2199ae
--- /dev/null
+++ b/system/banjo/ddk-protocol-gpio/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-gpio") {
+  sources = [
+    "gpio.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-gpioimpl/BUILD.gn b/system/banjo/ddk-protocol-gpioimpl/BUILD.gn
new file mode 100644
index 0000000..8397220
--- /dev/null
+++ b/system/banjo/ddk-protocol-gpioimpl/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-gpioimpl") {
+  sources = [
+    "gpio-impl.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-hidbus/BUILD.gn b/system/banjo/ddk-protocol-hidbus/BUILD.gn
new file mode 100644
index 0000000..55bb89e
--- /dev/null
+++ b/system/banjo/ddk-protocol-hidbus/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-hidbus") {
+  sources = [
+    "hidbus.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-i2c/BUILD.gn b/system/banjo/ddk-protocol-i2c/BUILD.gn
new file mode 100644
index 0000000..cdc9b0f
--- /dev/null
+++ b/system/banjo/ddk-protocol-i2c/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-i2c") {
+  sources = [
+    "i2c.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-i2cimpl/BUILD.gn b/system/banjo/ddk-protocol-i2cimpl/BUILD.gn
new file mode 100644
index 0000000..15df57f
--- /dev/null
+++ b/system/banjo/ddk-protocol-i2cimpl/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-i2cimpl") {
+  sources = [
+    "i2c-impl.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-intelgpucore/BUILD.gn b/system/banjo/ddk-protocol-intelgpucore/BUILD.gn
new file mode 100644
index 0000000..d4ff6ff
--- /dev/null
+++ b/system/banjo/ddk-protocol-intelgpucore/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-intelgpucore") {
+  sources = [
+    "intel-gpu-core.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-intelhda-codec/BUILD.gn b/system/banjo/ddk-protocol-intelhda-codec/BUILD.gn
new file mode 100644
index 0000000..5e9abdf
--- /dev/null
+++ b/system/banjo/ddk-protocol-intelhda-codec/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-intelhda-codec") {
+  sources = [
+    "intel-hda-codec.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-intelhda-dsp/BUILD.gn b/system/banjo/ddk-protocol-intelhda-dsp/BUILD.gn
new file mode 100644
index 0000000..306c740
--- /dev/null
+++ b/system/banjo/ddk-protocol-intelhda-dsp/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-intelhda-dsp") {
+  sources = [
+    "intel-hda-dsp.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-iommu/BUILD.gn b/system/banjo/ddk-protocol-iommu/BUILD.gn
new file mode 100644
index 0000000..d5a93fc
--- /dev/null
+++ b/system/banjo/ddk-protocol-iommu/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-iommu") {
+  sources = [
+    "iommu.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-mailbox/BUILD.gn b/system/banjo/ddk-protocol-mailbox/BUILD.gn
new file mode 100644
index 0000000..460bc62
--- /dev/null
+++ b/system/banjo/ddk-protocol-mailbox/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-mailbox") {
+  sources = [
+    "mailbox.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-mipicsi/BUILD.gn b/system/banjo/ddk-protocol-mipicsi/BUILD.gn
new file mode 100644
index 0000000..cc77a9d
--- /dev/null
+++ b/system/banjo/ddk-protocol-mipicsi/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-mipicsi") {
+  sources = [
+    "mipicsi.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-nand/BUILD.gn b/system/banjo/ddk-protocol-nand/BUILD.gn
new file mode 100644
index 0000000..61ce551
--- /dev/null
+++ b/system/banjo/ddk-protocol-nand/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-nand") {
+  sources = [
+    "nand.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-device-nand",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-pci/BUILD.gn b/system/banjo/ddk-protocol-pci/BUILD.gn
new file mode 100644
index 0000000..0dd0e0a
--- /dev/null
+++ b/system/banjo/ddk-protocol-pci/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-pci") {
+  sources = [
+    "pci.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-syscalls-pci",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-pciroot/BUILD.gn b/system/banjo/ddk-protocol-pciroot/BUILD.gn
new file mode 100644
index 0000000..d6bdae0
--- /dev/null
+++ b/system/banjo/ddk-protocol-pciroot/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-pciroot") {
+  sources = [
+    "pciroot.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-hw-pci",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-platform-bus/BUILD.gn b/system/banjo/ddk-protocol-platform-bus/BUILD.gn
new file mode 100644
index 0000000..78daeb5
--- /dev/null
+++ b/system/banjo/ddk-protocol-platform-bus/BUILD.gn
@@ -0,0 +1,15 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-platform-bus") {
+  sources = [
+    "platform-bus.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-driver",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-platform-device/BUILD.gn b/system/banjo/ddk-protocol-platform-device/BUILD.gn
new file mode 100644
index 0000000..3518a78
--- /dev/null
+++ b/system/banjo/ddk-protocol-platform-device/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-platform-device") {
+  sources = [
+    "platform-device.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-driver",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-platform-proxy/BUILD.gn b/system/banjo/ddk-protocol-platform-proxy/BUILD.gn
new file mode 100644
index 0000000..fe72aa3
--- /dev/null
+++ b/system/banjo/ddk-protocol-platform-proxy/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-platform-proxy") {
+  sources = [
+    "platform-proxy.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-rawnand/BUILD.gn b/system/banjo/ddk-protocol-rawnand/BUILD.gn
new file mode 100644
index 0000000..bdc1199
--- /dev/null
+++ b/system/banjo/ddk-protocol-rawnand/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-rawnand") {
+  sources = [
+    "rawnand.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-device-nand",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-scpi/BUILD.gn b/system/banjo/ddk-protocol-scpi/BUILD.gn
new file mode 100644
index 0000000..a666218
--- /dev/null
+++ b/system/banjo/ddk-protocol-scpi/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-scpi") {
+  sources = [
+    "scpi.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-sdhci/BUILD.gn b/system/banjo/ddk-protocol-sdhci/BUILD.gn
new file mode 100644
index 0000000..04f2920
--- /dev/null
+++ b/system/banjo/ddk-protocol-sdhci/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-sdhci") {
+  sources = [
+    "sdhci.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-sdio/BUILD.gn b/system/banjo/ddk-protocol-sdio/BUILD.gn
new file mode 100644
index 0000000..4923cdd
--- /dev/null
+++ b/system/banjo/ddk-protocol-sdio/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-sdio") {
+  sources = [
+    "sdio.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-sdmmc/BUILD.gn b/system/banjo/ddk-protocol-sdmmc/BUILD.gn
new file mode 100644
index 0000000..0957cc4
--- /dev/null
+++ b/system/banjo/ddk-protocol-sdmmc/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-sdmmc") {
+  sources = [
+    "sdmmc.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-serial/BUILD.gn b/system/banjo/ddk-protocol-serial/BUILD.gn
new file mode 100644
index 0000000..1b6ecd4
--- /dev/null
+++ b/system/banjo/ddk-protocol-serial/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-serial") {
+  sources = [
+    "serial.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-serialimpl/BUILD.gn b/system/banjo/ddk-protocol-serialimpl/BUILD.gn
new file mode 100644
index 0000000..223ffc2
--- /dev/null
+++ b/system/banjo/ddk-protocol-serialimpl/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-serialimpl") {
+  sources = [
+    "serial-impl.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-serial",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-test/BUILD.gn b/system/banjo/ddk-protocol-test/BUILD.gn
new file mode 100644
index 0000000..36f9785
--- /dev/null
+++ b/system/banjo/ddk-protocol-test/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-test") {
+  sources = [
+    "test.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-bus/BUILD.gn b/system/banjo/ddk-protocol-usb-bus/BUILD.gn
new file mode 100644
index 0000000..1449aa6
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-bus/BUILD.gn
@@ -0,0 +1,17 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-bus") {
+  sources = [
+    "usb-bus.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-driver",
+    "$zx/system/banjo/ddk-protocol-usb-hub",
+    "$zx/system/banjo/zircon-hw-usb",
+    "$zx/system/banjo/zircon-hw-usb-hub",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-composite/BUILD.gn b/system/banjo/ddk-protocol-usb-composite/BUILD.gn
new file mode 100644
index 0000000..b77b71a
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-composite/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-composite") {
+  sources = [
+    "usb-composite.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/zircon-hw-usb",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-dci/BUILD.gn b/system/banjo/ddk-protocol-usb-dci/BUILD.gn
new file mode 100644
index 0000000..1c2721d
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-dci/BUILD.gn
@@ -0,0 +1,16 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-dci") {
+  sources = [
+    "usb-dci.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-physiter",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/banjo/zircon-hw-usb",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-function/BUILD.gn b/system/banjo/ddk-protocol-usb-function/BUILD.gn
new file mode 100644
index 0000000..cc7659c
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-function/BUILD.gn
@@ -0,0 +1,16 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-function") {
+  sources = [
+    "usb-function.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-physiter",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/banjo/zircon-hw-usb",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-hci/BUILD.gn b/system/banjo/ddk-protocol-usb-hci/BUILD.gn
new file mode 100644
index 0000000..89514f5
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-hci/BUILD.gn
@@ -0,0 +1,19 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-hci") {
+  sources = [
+    "usb-hci.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-physiter",
+    "$zx/system/banjo/ddk-protocol-usb-bus",
+    "$zx/system/banjo/ddk-protocol-usb-hub",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/banjo/zircon-hw-usb",
+    "$zx/system/banjo/zircon-hw-usb-hub",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-hub/BUILD.gn b/system/banjo/ddk-protocol-usb-hub/BUILD.gn
new file mode 100644
index 0000000..d162379
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-hub/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-hub") {
+  sources = [
+    "usb-hub.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-modeswitch/BUILD.gn b/system/banjo/ddk-protocol-usb-modeswitch/BUILD.gn
new file mode 100644
index 0000000..e35706d
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-modeswitch/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-modeswitch") {
+  sources = [
+    "usb-mode-switch.banjo",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb-request/BUILD.gn b/system/banjo/ddk-protocol-usb-request/BUILD.gn
new file mode 100644
index 0000000..daa4313
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb-request/BUILD.gn
@@ -0,0 +1,15 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb-request") {
+  sources = [
+    "usb-request.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-physiter",
+    "$zx/system/banjo/zircon-hw-usb",
+  ]
+}
diff --git a/system/banjo/ddk-protocol-usb/BUILD.gn b/system/banjo/ddk-protocol-usb/BUILD.gn
new file mode 100644
index 0000000..efd47bf
--- /dev/null
+++ b/system/banjo/ddk-protocol-usb/BUILD.gn
@@ -0,0 +1,16 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("ddk-protocol-usb") {
+  sources = [
+    "usb.banjo",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-physiter",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/banjo/zircon-hw-usb",
+  ]
+}
diff --git a/system/banjo/zircon-device-audio/BUILD.gn b/system/banjo/zircon-device-audio/BUILD.gn
new file mode 100644
index 0000000..4a8e590
--- /dev/null
+++ b/system/banjo/zircon-device-audio/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-device-audio") {
+  sources = [
+    "audio.banjo",
+  ]
+}
diff --git a/system/banjo/zircon-device-block/BUILD.gn b/system/banjo/zircon-device-block/BUILD.gn
new file mode 100644
index 0000000..458befc
--- /dev/null
+++ b/system/banjo/zircon-device-block/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-device-block") {
+  sources = [
+    "block.banjo",
+  ]
+}
diff --git a/system/banjo/zircon-device-nand/BUILD.gn b/system/banjo/zircon-device-nand/BUILD.gn
new file mode 100644
index 0000000..9fe2b8c
--- /dev/null
+++ b/system/banjo/zircon-device-nand/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-device-nand") {
+  sources = [
+    "nand.banjo",
+  ]
+}
diff --git a/system/banjo/zircon-hw-pci/BUILD.gn b/system/banjo/zircon-hw-pci/BUILD.gn
new file mode 100644
index 0000000..526b507
--- /dev/null
+++ b/system/banjo/zircon-hw-pci/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-hw-pci") {
+  sources = [
+    "hwpci.banjo",
+  ]
+}
diff --git a/system/banjo/zircon-hw-usb-hub/BUILD.gn b/system/banjo/zircon-hw-usb-hub/BUILD.gn
new file mode 100644
index 0000000..59cc515
--- /dev/null
+++ b/system/banjo/zircon-hw-usb-hub/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-hw-usb-hub") {
+  sources = [
+    "usb-hub.banjo",
+  ]
+}
diff --git a/system/banjo/zircon-hw-usb/BUILD.gn b/system/banjo/zircon-hw-usb/BUILD.gn
new file mode 100644
index 0000000..73e78e4
--- /dev/null
+++ b/system/banjo/zircon-hw-usb/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-hw-usb") {
+  sources = [
+    "usb.banjo",
+  ]
+}
diff --git a/system/banjo/zircon-syscalls-pci/BUILD.gn b/system/banjo/zircon-syscalls-pci/BUILD.gn
new file mode 100644
index 0000000..b576bf7
--- /dev/null
+++ b/system/banjo/zircon-syscalls-pci/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/banjo.gni")
+
+banjo_library("zircon-syscalls-pci") {
+  sources = [
+    "pci.banjo",
+  ]
+}
diff --git a/system/core/BUILD.gn b/system/core/BUILD.gn
new file mode 100644
index 0000000..cdaffd9
--- /dev/null
+++ b/system/core/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+group("core") {
+  # bootsvc is the first real user process, and it launches everything else.
+  # So it's the only "core" direct dependency and it has data_deps for the
+  # other binaries it launches.
+  deps = [
+    "bootsvc",
+  ]
+}
diff --git a/system/core/bootsvc/BUILD.gn b/system/core/bootsvc/BUILD.gn
new file mode 100644
index 0000000..acdc786
--- /dev/null
+++ b/system/core/bootsvc/BUILD.gn
@@ -0,0 +1,55 @@
+# 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.
+
+executable("bootsvc") {
+  sources = [
+    "bootfs-loader-service.cpp",
+    "bootfs-service.cpp",
+    "main.cpp",
+    "util.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/bootdata",
+    "$zx/system/ulib/bootfs",
+    "$zx/system/ulib/bootsvc-protocol",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/loader-service",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/lz4",
+  ]
+  data_deps = [
+    "$zx/system/core/devmgr/devmgr",
+  ]
+}
+
+test("bootsvc-tests") {
+  sources = [
+    "integration-test.cpp",
+    "util.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/bootsvc-protocol",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/core/devmgr/BUILD.gn b/system/core/devmgr/BUILD.gn
new file mode 100644
index 0000000..4f9e2cd
--- /dev/null
+++ b/system/core/devmgr/BUILD.gn
@@ -0,0 +1,35 @@
+# 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.
+
+group("devmgr") {
+  # Everything else is in data_deps of devmgr.
+  # TODO: consider moving devmgr/* back to this dir
+  deps = [
+    "devmgr",
+  ]
+}
+
+# Drivers depend on this (see $standard_fuchsia_user_configs).
+# It just gets the standard devhost binary into the BOOTFS image.
+group("driver_config") {
+  data_deps = [
+    "devhost",
+  ]
+}
+
+# Variants can remove that standard "driver_config" from $configs and
+# instead add a specific "driver_config.variant" defined below.
+
+variant_suffixes = [ toolchain.variant_suffix ]
+foreach(other, toolchain.other_variants) {
+  variant_suffixes += [ other.suffix ]
+}
+
+foreach(variant, variant_suffixes) {
+  group("driver_config$variant") {
+    data_deps = [
+      "devhost:devhost$variant(${toolchain.label})",
+    ]
+  }
+}
diff --git a/system/core/devmgr/devhost/BUILD.gn b/system/core/devmgr/devhost/BUILD.gn
new file mode 100644
index 0000000..b4b434b
--- /dev/null
+++ b/system/core/devmgr/devhost/BUILD.gn
@@ -0,0 +1,84 @@
+# 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.
+
+declare_args() {
+  # Allow driver tracing to be completely disabled (as if it didn't exist).
+  enable_driver_tracing = false
+}
+
+config("enable_driver_tracing") {
+  if (enable_driver_tracing) {
+    defines = [ "ENABLE_DRIVER_TRACING" ]
+  }
+}
+
+executable("devhost") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    ":driver",
+  ]
+}
+
+# "$zx/system/ulib/driver" is an alias for this.
+library("driver") {
+  sdk = "shared"
+  sdk_headers = []
+  shared = true
+  static = false
+  sources = [
+    "api.cpp",
+    "core.cpp",
+    "devhost.cpp",
+    "rpc-server.cpp",
+    "zx-device.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    ":enable_driver_tracing",
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async:async-cpp.static",
+    "$zx/system/ulib/async-loop:async-loop-cpp.static",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxio",
+    "../shared:env",
+  ]
+
+  if (enable_driver_tracing) {
+    sources += [ "tracing.cpp" ]
+    deps += [
+      "$zx/system/ulib/async:async-default.static",
+      "$zx/system/ulib/async:static",
+      "$zx/system/ulib/trace:static",
+      "$zx/system/ulib/trace-engine:static",
+      "$zx/system/ulib/trace-provider:static",
+    ]
+
+    # Since the tracing support is brought in via an archive, we need explicit
+    # references to ensure everything is present.
+    libs = [ "$zx/system/ulib/trace-engine/ddk-exports.ld" ]
+  } else {
+    # Some symbols still need to be present even if tracing is disabled.
+    # See the linker script for details.
+    libs = [ "$zx/system/ulib/trace-engine/ddk-disabled-exports.ld" ]
+  }
+
+  # This library is on the whitelist for driver() shared library deps.
+  # It doesn't trigger the assert_no_metadata() check, and it prunes the
+  # metadata walk here so our own deps are not subject to the check.
+  metadata = {
+    driver_blacklist = []
+    driver_blacklist_barrier = []
+  }
+}
diff --git a/system/core/devmgr/devmgr/BUILD.gn b/system/core/devmgr/devmgr/BUILD.gn
new file mode 100644
index 0000000..6d4c4fd
--- /dev/null
+++ b/system/core/devmgr/devmgr/BUILD.gn
@@ -0,0 +1,53 @@
+# 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.
+
+executable("devmgr") {
+  sources = [
+    "binding.cpp",
+    "coordinator.cpp",
+    "devfs.cpp",
+    "drivers.cpp",
+    "fidl.cpp",
+    "main.cpp",
+  ]
+
+  deps = [
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/bootdata",
+    "$zx/system/ulib/bootsvc-protocol",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/driver-info",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/libzbi",
+    "$zx/system/ulib/loader-service",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/lz4",
+    "../shared",
+  ]
+
+  # Bring the auxiliaries into the build and the image.  devhost isn't
+  # listed here because it's implicitly in data_deps of every driver().
+  data_deps = [
+    "../dmctl",
+    "../fshost",
+    "$zx/system/core/netsvc",
+    "$zx/system/core/svchost",
+    "$zx/system/core/virtcon:virtual-console",
+    "$zx/system/core/pwrbtn-monitor",
+  ]
+}
diff --git a/system/core/devmgr/dmctl/BUILD.gn b/system/core/devmgr/dmctl/BUILD.gn
new file mode 100644
index 0000000..d702904
--- /dev/null
+++ b/system/core/devmgr/dmctl/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("dmctl") {
+  sources = [
+    "dmctl.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/core/devmgr/fshost/BUILD.gn b/system/core/devmgr/fshost/BUILD.gn
new file mode 100644
index 0000000..e43c2c7
--- /dev/null
+++ b/system/core/devmgr/fshost/BUILD.gn
@@ -0,0 +1,35 @@
+# 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.
+
+executable("fshost") {
+  sources = [
+    "block-watcher.cpp",
+    "main.cpp",
+    "vfs-rpc.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/bootdata",
+    "$zx/system/ulib/bootfs",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/loader-service",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/cksum",
+    "$zx/third_party/ulib/lz4",
+    "../shared",
+  ]
+}
diff --git a/system/core/devmgr/shared/BUILD.gn b/system/core/devmgr/shared/BUILD.gn
new file mode 100644
index 0000000..145bb1c
--- /dev/null
+++ b/system/core/devmgr/shared/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+source_set("shared") {
+  visibility = [ "$zx/system/core/devmgr/*" ]
+  sources = [
+    "fdio.cpp",
+  ]
+  deps = [
+    ":env",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
+
+source_set("env") {
+  visibility = [ "$zx/system/core/devmgr/*" ]
+  sources = [
+    "env.cpp",
+  ]
+}
diff --git a/system/core/netsvc/BUILD.gn b/system/core/netsvc/BUILD.gn
new file mode 100644
index 0000000..9918f7c
--- /dev/null
+++ b/system/core/netsvc/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+executable("netsvc") {
+  sources = [
+    "debuglog.c",
+    "device_id.c",
+    "netboot.c",
+    "netfile.c",
+    "netsvc.c",
+    "tftp.c",
+    "zbi.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/fidl/fuchsia-hardware-ethernet:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/inet6",
+    "$zx/system/ulib/libzbi",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/tftp",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+  data_deps = [
+    # netsvc launches /boot/bin/install-disk-image under --netboot.
+    "$zx/system/uapp/disk-pave",
+
+    # netsvc launches /boot/bin/sh for netruncmd.
+    "$zx/third_party/uapp/dash",
+  ]
+}
diff --git a/system/core/pwrbtn-monitor/BUILD.gn b/system/core/pwrbtn-monitor/BUILD.gn
new file mode 100644
index 0000000..81ed9e7
--- /dev/null
+++ b/system/core/pwrbtn-monitor/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+executable("pwrbtn-monitor") {
+  sources = [
+    "pwrbtn-monitor.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/hid-parser",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/core/svchost/BUILD.gn b/system/core/svchost/BUILD.gn
new file mode 100644
index 0000000..af1eb98
--- /dev/null
+++ b/system/core/svchost/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+executable("svchost") {
+  sources = [
+    "crashsvc.cpp",
+    "svchost.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-crash:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-logger:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/fidl/fuchsia-process:c",
+    "$zx/system/fidl/fuchsia-sysmem:c",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/inspector",
+    "$zx/system/ulib/logger",
+    "$zx/system/ulib/process-launcher",
+    "$zx/system/ulib/svc",
+    "$zx/system/ulib/sysmem",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/core/userboot/BUILD.gn b/system/core/userboot/BUILD.gn
new file mode 100644
index 0000000..4cc3651
--- /dev/null
+++ b/system/core/userboot/BUILD.gn
@@ -0,0 +1,152 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/lib/vdso/rodso.gni")
+import("$zx/public/gn/config/levels.gni")
+import("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/c_utils.gni")
+import("$zx/public/gn/toolchain/environment.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# userboot gets its own toolchain for its special build requirements.
+if (current_toolchain == default_toolchain) {
+  # Define the special toolchain itself only in the default toolchain.
+  foreach(cpu, standard_fuchsia_cpus) {
+    define_environment("userboot") {
+      cpu = cpu
+      configs += standard_fuchsia_configs + [ ":userboot_config" ]
+
+      # This doesn't get a separate shlib sub-toolchain, but the main one
+      # can do loadable_module().
+      solink = true
+
+      if (opt_level < 2) {
+        # userboot doesn't stay sufficiently pure without optimization.
+        toolchain_args = {
+          opt_level = 2
+        }
+      }
+
+      # userboot can't use any instrumentation runtimes.
+      exclude_variant_tags = [ "instrumented" ]
+    }
+  }
+} else if (toolchain.environment == "userboot") {
+  # Everything in userboot gets compiled this way.
+  config("userboot_config") {
+    public_deps = [
+      "$zx/public/gn/config:no_sanitizers",
+      "$zx/system/ulib/c:headers",
+    ]
+
+    # Everything is statically linked together with no PLT or GOT.
+    cflags = [
+      "-include",
+      rebase_path("$zx/kernel/include/hidden.h", root_build_dir),
+    ]
+    defines = [
+      "HIDDEN",
+      "WITH_LZ4_NOALLOC",
+    ]
+  }
+
+  vdso_syms_ld = "$target_gen_dir/vdso-syms.ld"
+  vdso_syms_rspfile = "$target_gen_dir/vdso-syms.h.rsp"
+
+  loadable_module("userboot") {
+    sources = [
+      "bootdata.c",
+      "bootfs.c",
+      "loader-service.c",
+      "option.c",
+      "start.c",
+      "userboot-elf.c",
+      "util.c",
+    ]
+    libs = [ vdso_syms_ld ]
+    deps = [
+      ":gen-vdso-syms-ld",
+      "$zx/system/ulib/bootdata",
+      "$zx/system/ulib/elfload",
+      "$zx/system/ulib/ldmsg",
+      "$zx/system/ulib/runtime",
+      "$zx/system/ulib/zircon:headers",
+      "$zx/third_party/ulib/lz4",
+      "$zx/third_party/ulib/musl/src/string:minimal_str",
+      "$zx/third_party/ulib/musl/src/string:stdmem",
+    ]
+  }
+
+  # This generated header lists all the ABI symbols in the vDSO with their
+  # addresses.  It's used to generate vdso-syms.ld, below.
+  toolchain_utils_action("gen-vdso-syms-header") {
+    visibility = [ ":gen-vdso-syms-ld" ]
+    sources = [
+      vdso_syms_rspfile,
+    ]
+    deps = [
+      ":gen-vdso-syms-header-rspfile",
+    ]
+    outputs = [
+      "$target_gen_dir/vdso-syms.h",
+    ]
+    depfile = "${outputs[0]}.d"
+    utils = [ "nm" ]
+    script = "$zx/scripts/shlib-symbols"
+    args = [
+      "-a",
+      "@" + rebase_path(vdso_syms_rspfile, root_build_dir),
+      rebase_path(outputs[0], root_build_dir),
+      rebase_path(depfile, root_build_dir),
+    ]
+  }
+
+  link_output_rspfile("gen-vdso-syms-header-rspfile") {
+    visibility = [ ":gen-vdso-syms-header" ]
+    deps = [
+      "$zx/system/ulib/zircon",
+    ]
+    outputs = [
+      vdso_syms_rspfile,
+    ]
+  }
+
+  # This generated linker script defines symbols for each vDSO entry point
+  # giving the relative address where it will be found at runtime.  With
+  # this hack, the userboot code doesn't need to do any special work to
+  # find the vDSO and its entry points, keeping the code far simpler.
+  toolchain_utils_action("gen-vdso-syms-ld") {
+    visibility = [ ":*" ]
+    outputs = [
+      vdso_syms_ld,
+    ]
+    deps = [
+      ":gen-vdso-syms-header",
+    ]
+    sources = get_target_outputs(deps[0])
+    inputs = [
+      "vdso-syms.ld.h",
+    ]
+    utils = [ "cc" ]
+    args = [
+      "-o",
+      rebase_path(outputs[0], root_build_dir),
+      "-E",
+      "-P",
+      "-include",
+      rebase_path(inputs[0], root_build_dir),
+      rebase_path(sources[0], root_build_dir),
+    ]
+  }
+} else {
+  # In any other toolchain, just redirect to the proper toolchain.
+  select_toolchain("userboot") {
+    environment_label = ":userboot"
+    deps = [
+      ":userboot",
+    ]
+  }
+}
diff --git a/system/core/virtcon/BUILD.gn b/system/core/virtcon/BUILD.gn
new file mode 100644
index 0000000..d2e7deb
--- /dev/null
+++ b/system/core/virtcon/BUILD.gn
@@ -0,0 +1,57 @@
+# 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.
+
+group("virtcon") {
+  testonly = true
+  deps = [
+    ":virtual-console",
+    ":virtual-console-test",
+  ]
+}
+
+common_sources = [
+  "keyboard-vt100.cpp",
+  "keyboard.cpp",
+  "textcon.cpp",
+  "vc-device.cpp",
+  "vc-gfx.cpp",
+  "vc-input.cpp",
+]
+
+common_deps = [
+  "$zx/system/fidl/fuchsia-hardware-display:c",
+  "$zx/system/fidl/fuchsia-io:c",
+  "$zx/system/fidl/fuchsia-hardware-input:c",
+  "$zx/system/ulib/fbl",
+  "$zx/system/ulib/fdio",
+  "$zx/system/ulib/fidl",
+  "$zx/system/ulib/fzl",
+  "$zx/system/ulib/gfx",
+  "$zx/system/ulib/hid",
+  "$zx/system/ulib/port",
+  "$zx/system/ulib/zircon",
+  "$zx/system/ulib/zx",
+  "$zx/system/ulib/zxcpp",
+]
+
+executable("virtual-console") {
+  sources = common_sources + [
+              "main.cpp",
+              "vc-display.cpp",
+            ]
+  deps = common_deps
+}
+
+test("virtual-console-test") {
+  output_name = "virtual-console-test"
+  defines = [ "BUILD_FOR_TEST" ]
+  sources = common_sources + [
+              "keyboard-test.cpp",
+              "textcon-test.cpp",
+            ]
+  deps = common_deps + [
+           "$zx/system/ulib/unittest",
+           "$zx/system/utest/core:unittest_main",
+         ]
+}
diff --git a/system/core/virtcon/textcon-test.cpp b/system/core/virtcon/textcon-test.cpp
index 93a30dc..db76ba9 100644
--- a/system/core/virtcon/textcon-test.cpp
+++ b/system/core/virtcon/textcon-test.cpp
@@ -747,9 +747,3 @@
 END_TEST_CASE(gfxconsole_textbuf_tests)
 
 }
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/dev/BUILD.gn b/system/dev/BUILD.gn
new file mode 100644
index 0000000..934ab5e
--- /dev/null
+++ b/system/dev/BUILD.gn
@@ -0,0 +1,36 @@
+# 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.
+
+group("dev") {
+  testonly = true
+  deps = [
+    "$zx/system/ulib/ddktl:ddktl-test",
+    "audio",
+    "block",
+    "bluetooth",
+    "board",
+    "bus",
+    "camera",
+    "clk",
+    "codec",
+    "display",
+    "ethernet",
+    "gpio",
+    "gpu",
+    "i2c",
+    "input",
+    "light",
+    "misc",
+    "nand",
+    "pci",
+    "rtc",
+    "sample",
+    "scpi",
+    "serial",
+    "tee",
+    "test",
+    "thermal",
+    "usb",
+  ]
+}
diff --git a/system/dev/audio/BUILD.gn b/system/dev/audio/BUILD.gn
new file mode 100644
index 0000000..a72f2d6
--- /dev/null
+++ b/system/dev/audio/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+group("audio") {
+  deps = [
+    "astro-pdm-input",
+    "astro-tdm-output",
+    "gauss-pdm-input",
+    "gauss-tdm",
+    "intel-hda",
+    "usb-audio",
+  ]
+}
diff --git a/system/dev/audio/astro-pdm-input/BUILD.gn b/system/dev/audio/astro-pdm-input/BUILD.gn
new file mode 100644
index 0000000..432cfe7
--- /dev/null
+++ b/system/dev/audio/astro-pdm-input/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+driver("astro-pdm-input") {
+  sources = [
+    "audio-stream-in.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/audio/lib/simple-audio-stream",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/astro-tdm-output/BUILD.gn b/system/dev/audio/astro-tdm-output/BUILD.gn
new file mode 100644
index 0000000..dec27fa
--- /dev/null
+++ b/system/dev/audio/astro-tdm-output/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+driver("astro-tdm-output") {
+  sources = [
+    "audio-stream-out.cpp",
+    "binding.c",
+    "tas27xx.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/audio/lib/simple-audio-stream",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/gauss-pdm-input/BUILD.gn b/system/dev/audio/gauss-pdm-input/BUILD.gn
new file mode 100644
index 0000000..c3bc1932
--- /dev/null
+++ b/system/dev/audio/gauss-pdm-input/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+driver("gauss-pdm-input") {
+  sources = [
+    "a113-audio-device.c",
+    "a113-ddr.c",
+    "a113-pdm.c",
+    "gauss-pdm-input-stream.cpp",
+    "gauss-pdm-input.c",
+    "vmo_helper.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/gauss-tdm/BUILD.gn b/system/dev/audio/gauss-tdm/BUILD.gn
new file mode 100644
index 0000000..814d32f
--- /dev/null
+++ b/system/dev/audio/gauss-tdm/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("gauss-tdm") {
+  sources = [
+    "gauss-tdm-out.c",
+    "gauss-tdm-stream.cpp",
+    "tas57xx.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/intel-hda/BUILD.gn b/system/dev/audio/intel-hda/BUILD.gn
new file mode 100644
index 0000000..52a1c8d
--- /dev/null
+++ b/system/dev/audio/intel-hda/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+group("intel-hda") {
+  deps = [
+    "codecs/qemu",
+    "codecs/realtek",
+    "controller",
+    "dsp",
+  ]
+}
diff --git a/system/dev/audio/intel-hda/codecs/qemu/BUILD.gn b/system/dev/audio/intel-hda/codecs/qemu/BUILD.gn
new file mode 100644
index 0000000..78250ff
--- /dev/null
+++ b/system/dev/audio/intel-hda/codecs/qemu/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+group("qemu") {
+  deps = [
+    ":qemu-audio",
+  ]
+}
+
+driver("qemu-audio") {
+  sources = [
+    "binding.c",
+    "qemu-codec.cpp",
+    "qemu-stream.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-intelhda-codec",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/intel-hda",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/intel-hda/codecs/realtek/BUILD.gn b/system/dev/audio/intel-hda/codecs/realtek/BUILD.gn
new file mode 100644
index 0000000..c6550e3
--- /dev/null
+++ b/system/dev/audio/intel-hda/codecs/realtek/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+driver("realtek") {
+  sources = [
+    "binding.c",
+    "realtek-codec.cpp",
+    "realtek-stream.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/intel-hda",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/intel-hda/controller/BUILD.gn b/system/dev/audio/intel-hda/controller/BUILD.gn
new file mode 100644
index 0000000..942389b
--- /dev/null
+++ b/system/dev/audio/intel-hda/controller/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+driver("controller") {
+  sources = [
+    "binding.c",
+    "codec-cmd-job.cpp",
+    "debug.cpp",
+    "intel-hda-codec.cpp",
+    "intel-hda-controller-init.cpp",
+    "intel-hda-controller.cpp",
+    "intel-hda-dsp.cpp",
+    "intel-hda-irq.cpp",
+    "intel-hda-stream.cpp",
+    "utils.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-intelhda-codec",
+    "$zx/system/banjo/ddk-protocol-intelhda-dsp",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/intel-hda",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/intel-hda/dsp/BUILD.gn b/system/dev/audio/intel-hda/dsp/BUILD.gn
new file mode 100644
index 0000000..c701f6e
--- /dev/null
+++ b/system/dev/audio/intel-hda/dsp/BUILD.gn
@@ -0,0 +1,43 @@
+# 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("$zx/public/gn/firmware.gni")
+
+driver("dsp") {
+  sources = [
+    "binding.c",
+    "debug.cpp",
+    "intel-audio-dsp.cpp",
+    "intel-dsp-code-loader.cpp",
+    "intel-dsp-ipc.cpp",
+    "intel-dsp-stream.cpp",
+    "intel-dsp-topology.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-intelhda-codec",
+    "$zx/system/banjo/ddk-protocol-intelhda-dsp",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/intel-hda",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+  data_deps = [
+    ":firmware",
+  ]
+}
+
+firmware("firmware") {
+  sources = [
+    "$firmware_dir/intel-adsp-sst/dsp_fw_kbl_v3266.bin",
+  ]
+}
diff --git a/system/dev/audio/lib/simple-audio-stream/BUILD.gn b/system/dev/audio/lib/simple-audio-stream/BUILD.gn
new file mode 100644
index 0000000..7bbbbee
--- /dev/null
+++ b/system/dev/audio/lib/simple-audio-stream/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+library("simple-audio-stream") {
+  sdk = "source"
+  sdk_headers = [ "lib/simple-audio-stream/simple-audio-stream.h" ]
+  sources = [
+    "simple-audio-stream.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/dev/audio/sherlock-pdm-input/BUILD.gn b/system/dev/audio/sherlock-pdm-input/BUILD.gn
new file mode 100644
index 0000000..c73ad9d
--- /dev/null
+++ b/system/dev/audio/sherlock-pdm-input/BUILD.gn
@@ -0,0 +1,29 @@
+# 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.
+
+driver("sherlock-pdm-input") {
+  sources = [
+    "audio-stream-in.cpp",
+    "binding.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/audio/lib/simple-audio-stream",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/sherlock-tdm-output/BUILD.gn b/system/dev/audio/sherlock-tdm-output/BUILD.gn
new file mode 100644
index 0000000..dcad374
--- /dev/null
+++ b/system/dev/audio/sherlock-tdm-output/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+driver("sherlock-tdm-output") {
+  sources = [
+    "audio-stream-out.cpp",
+    "binding.c",
+    "tas5720.cpp",
+    "tas5760.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/audio/lib/simple-audio-stream",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/audio/usb-audio/BUILD.gn b/system/dev/audio/usb-audio/BUILD.gn
new file mode 100644
index 0000000..35d0cbc
--- /dev/null
+++ b/system/dev/audio/usb-audio/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+driver("usb-audio") {
+  sources = [
+    "binding.c",
+    "midi.c",
+    "usb-audio-control-interface.cpp",
+    "usb-audio-descriptors.cpp",
+    "usb-audio-device.cpp",
+    "usb-audio-path.cpp",
+    "usb-audio-stream-interface.cpp",
+    "usb-audio-stream.cpp",
+    "usb-audio-units.cpp",
+    "usb-audio.cpp",
+    "usb-midi-sink.c",
+    "usb-midi-source.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/dev/backlight/ti-lp8556/BUILD.gn b/system/dev/backlight/ti-lp8556/BUILD.gn
new file mode 100644
index 0000000..b855728
--- /dev/null
+++ b/system/dev/backlight/ti-lp8556/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+driver("ti-lp8556") {
+  sources = [
+    "ti-lp8556.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/fidl/fuchsia-hardware-backlight:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/block/BUILD.gn b/system/dev/block/BUILD.gn
new file mode 100644
index 0000000..c39a6ce
--- /dev/null
+++ b/system/dev/block/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+group("block") {
+  deps = [
+    "ahci",
+    "aml-sd-emmc",
+    "block",
+    "bootpart",
+    "fvm",
+    "gpt",
+    "imx-sdhci",
+    "mbr",
+    "mtk-sdmmc",
+    "nvme",
+    "pci-sdhci",
+    "ramdisk",
+    "sdhci",
+    "sdmmc",
+    "ums-function",
+    "usb-mass-storage",
+    "zxcrypt",
+  ]
+}
diff --git a/system/dev/block/ahci/BUILD.gn b/system/dev/block/ahci/BUILD.gn
new file mode 100644
index 0000000..9d5bcfc
--- /dev/null
+++ b/system/dev/block/ahci/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("ahci") {
+  sources = [
+    "ahci.c",
+    "sata.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/aml-sd-emmc/BUILD.gn b/system/dev/block/aml-sd-emmc/BUILD.gn
new file mode 100644
index 0000000..b7be95a
--- /dev/null
+++ b/system/dev/block/aml-sd-emmc/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("aml-sd-emmc") {
+  sources = [
+    "aml-sd-emmc.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-sdmmc",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/block/BUILD.gn b/system/dev/block/block/BUILD.gn
new file mode 100644
index 0000000..5f40926
--- /dev/null
+++ b/system/dev/block/block/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("block") {
+  sources = [
+    "block.cpp",
+    "server-manager.cpp",
+    "server.cpp",
+    "txn-group.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/banjo/ddk-protocol-block-volume",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/block/bootpart/BUILD.gn b/system/dev/block/bootpart/BUILD.gn
new file mode 100644
index 0000000..e783429
--- /dev/null
+++ b/system/dev/block/bootpart/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("bootpart") {
+  sources = [
+    "bootpart.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/dev/block/ftl/BUILD.gn b/system/dev/block/ftl/BUILD.gn
new file mode 100644
index 0000000..6e1e03c
--- /dev/null
+++ b/system/dev/block/ftl/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+driver("ftl") {
+  sources = [
+    "bind.cpp",
+  ]
+  deps = [
+    ":common",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+  ]
+}
+
+# Also used by ftl-test.
+source_set("common") {
+  visibility = [ "./*" ]
+  sources = [
+    "block_device.cpp",
+    "nand_driver.cpp",
+    "nand_operation.cpp",
+    "oob_doubler.cpp",
+  ]
+  public_deps = [
+    "$zx/system/banjo/ddk-protocol-badblock",
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-block:c",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/ftl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/block/ftl/test/BUILD.gn b/system/dev/block/ftl/test/BUILD.gn
new file mode 100644
index 0000000..1d8cefa
--- /dev/null
+++ b/system/dev/block/ftl/test/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+group("test") {
+  testonly = true
+  deps = [
+    ":ftl",
+  ]
+}
+
+test("ftl") {
+  sources = [
+    "block_device_test.cpp",
+    "driver-test.cpp",
+    "ftl-shell.cpp",
+    "ftl-test.cpp",
+    "main.cpp",
+    "nand_driver_test.cpp",
+    "nand_operation_test.cpp",
+    "ndm-ram-driver.cpp",
+    "oob_doubler_test.cpp",
+  ]
+  include_dirs = [ ".." ]
+  deps = [
+    "$zx/system/dev/lib/fake_ddk",
+    "$zx/system/ulib/unittest",
+    "..:common",
+  ]
+}
diff --git a/system/dev/block/fvm/BUILD.gn b/system/dev/block/fvm/BUILD.gn
new file mode 100644
index 0000000..f9c0803
--- /dev/null
+++ b/system/dev/block/fvm/BUILD.gn
@@ -0,0 +1,38 @@
+# 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.
+
+driver("fvm") {
+  deps = [
+    ":shared",
+  ]
+}
+
+# Also used by test/.
+source_set("shared") {
+  visibility = [ "./*" ]
+  sources = [
+    "fvm.c",
+    "fvm.cpp",
+    "slice-extent.cpp",
+    "vpartition.cpp",
+  ]
+  public_deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/banjo/ddk-protocol-block-volume",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/dev/block/fvm/test/BUILD.gn b/system/dev/block/fvm/test/BUILD.gn
new file mode 100644
index 0000000..5a720fa
--- /dev/null
+++ b/system/dev/block/fvm/test/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+group("test") {
+  testonly = true
+  deps = [
+    ":fvm-driver-unittests",
+  ]
+}
+
+test("fvm-driver-unittests") {
+  sources = [
+    "main.cpp",
+    "slice-extent-test.cpp",
+  ]
+  include_dirs = [ ".." ]
+  deps = [
+    "$zx/system/ulib/unittest",
+    "..:shared",
+  ]
+}
diff --git a/system/dev/block/gpt/BUILD.gn b/system/dev/block/gpt/BUILD.gn
new file mode 100644
index 0000000..6f4026c
--- /dev/null
+++ b/system/dev/block/gpt/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("gpt") {
+  sources = [
+    "gpt.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/dev/block/imx-sdhci/BUILD.gn b/system/dev/block/imx-sdhci/BUILD.gn
new file mode 100644
index 0000000..ddeb31b
--- /dev/null
+++ b/system/dev/block/imx-sdhci/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("imx-sdhci") {
+  sources = [
+    "imx-sdhci.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-sdhci",
+    "$zx/system/banjo/ddk-protocol-sdmmc",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/mbr/BUILD.gn b/system/dev/block/mbr/BUILD.gn
new file mode 100644
index 0000000..5bc3b7c
--- /dev/null
+++ b/system/dev/block/mbr/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("mbr") {
+  sources = [
+    "mbr.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/mtk-sdmmc/BUILD.gn b/system/dev/block/mtk-sdmmc/BUILD.gn
new file mode 100644
index 0000000..3dae088
--- /dev/null
+++ b/system/dev/block/mtk-sdmmc/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+driver("mtk-sdmmc") {
+  sources = [
+    "binding.c",
+    "mtk-sdmmc.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-sdmmc",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/block/nvme/BUILD.gn b/system/dev/block/nvme/BUILD.gn
new file mode 100644
index 0000000..55a069f
--- /dev/null
+++ b/system/dev/block/nvme/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+driver("nvme") {
+  sources = [
+    "nvme.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/pci-sdhci/BUILD.gn b/system/dev/block/pci-sdhci/BUILD.gn
new file mode 100644
index 0000000..89442cf
--- /dev/null
+++ b/system/dev/block/pci-sdhci/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("pci-sdhci") {
+  sources = [
+    "pci-sdhci.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/banjo/ddk-protocol-sdhci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/ramdisk/BUILD.gn b/system/dev/block/ramdisk/BUILD.gn
new file mode 100644
index 0000000..50c1bd4
--- /dev/null
+++ b/system/dev/block/ramdisk/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("ramdisk") {
+  sources = [
+    "ramdisk.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/block/sdhci/BUILD.gn b/system/dev/block/sdhci/BUILD.gn
new file mode 100644
index 0000000..29a2638
--- /dev/null
+++ b/system/dev/block/sdhci/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("sdhci") {
+  sources = [
+    "sdhci.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-sdhci",
+    "$zx/system/banjo/ddk-protocol-sdmmc",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/sdmmc/BUILD.gn b/system/dev/block/sdmmc/BUILD.gn
new file mode 100644
index 0000000..a23c520
--- /dev/null
+++ b/system/dev/block/sdmmc/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("sdmmc") {
+  sources = [
+    "mmc.c",
+    "ops.c",
+    "sd.c",
+    "sdio-interrupts.c",
+    "sdio.c",
+    "sdmmc.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-sdio",
+    "$zx/system/banjo/ddk-protocol-sdmmc",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/ums-function/BUILD.gn b/system/dev/block/ums-function/BUILD.gn
new file mode 100644
index 0000000..51cea3b
--- /dev/null
+++ b/system/dev/block/ums-function/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("ums-function") {
+  sources = [
+    "ums-function.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-function",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/usb-mass-storage/BUILD.gn b/system/dev/block/usb-mass-storage/BUILD.gn
new file mode 100644
index 0000000..db1f410
--- /dev/null
+++ b/system/dev/block/usb-mass-storage/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+driver("usb-mass-storage") {
+  sources = [
+    "block.cpp",
+    "usb-mass-storage.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/block/zxcrypt/BUILD.gn b/system/dev/block/zxcrypt/BUILD.gn
new file mode 100644
index 0000000..287cc0f
--- /dev/null
+++ b/system/dev/block/zxcrypt/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+driver("zxcrypt") {
+  sources = [
+    "binding.c",
+    "device.cpp",
+    "extra.cpp",
+    "worker.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:integer-paranoia" ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-block-partition",
+    "$zx/system/banjo/ddk-protocol-block-volume",
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/crypto",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxcrypt",
+  ]
+}
diff --git a/system/dev/bluetooth/BUILD.gn b/system/dev/bluetooth/BUILD.gn
new file mode 100644
index 0000000..d7bad72
--- /dev/null
+++ b/system/dev/bluetooth/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+group("bluetooth") {
+  deps = [
+    "bt-hci-broadcom",
+    "bt-transport-uart",
+    "bt-transport-usb",
+  ]
+}
diff --git a/system/dev/bluetooth/bt-hci-broadcom/BUILD.gn b/system/dev/bluetooth/bt-hci-broadcom/BUILD.gn
new file mode 100644
index 0000000..95b1e79
--- /dev/null
+++ b/system/dev/bluetooth/bt-hci-broadcom/BUILD.gn
@@ -0,0 +1,27 @@
+# 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("$zx/public/gn/firmware.gni")
+
+driver("bt-hci-broadcom") {
+  sources = [
+    "bt-hci-broadcom.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-bt-hci",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    ":firmware",
+  ]
+}
+
+firmware("firmware") {
+  sources = [
+    "$firmware_dir/bluetooth/bcm4345c4/BCM4345C5.hcd",
+  ]
+}
diff --git a/system/dev/bluetooth/bt-transport-uart/BUILD.gn b/system/dev/bluetooth/bt-transport-uart/BUILD.gn
new file mode 100644
index 0000000..63c4906
--- /dev/null
+++ b/system/dev/bluetooth/bt-transport-uart/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+driver("bt-transport-uart") {
+  sources = [
+    "bt-transport-uart.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-bt-hci",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/bluetooth/bt-transport-usb/BUILD.gn b/system/dev/bluetooth/bt-transport-usb/BUILD.gn
new file mode 100644
index 0000000..74f77e7
--- /dev/null
+++ b/system/dev/bluetooth/bt-transport-usb/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("bt-transport-usb") {
+  sources = [
+    "bt-transport-usb.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-bt-hci",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/board/BUILD.gn b/system/dev/board/BUILD.gn
new file mode 100644
index 0000000..3cdc0ab
--- /dev/null
+++ b/system/dev/board/BUILD.gn
@@ -0,0 +1,32 @@
+# 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.
+
+group("board") {
+  deps = [
+    "machina",
+    "qemu",
+    "test",
+  ]
+  if (current_cpu == "arm64") {
+    deps += [
+      "astro",
+      "gauss",
+      "hikey960",
+      "imx8mevk",
+      "imx8mmevk",
+      "mt8167s_ref",
+      "sherlock",
+      "vim",
+    ]
+    metadata = {
+      sdk_board_list = [
+        "gauss",
+        "hikey960",
+        "qemu",
+        "vim2",
+        "imx8mevk",
+      ]
+    }
+  }
+}
diff --git a/system/dev/board/astro/BUILD.gn b/system/dev/board/astro/BUILD.gn
new file mode 100644
index 0000000..eb24b79
--- /dev/null
+++ b/system/dev/board/astro/BUILD.gn
@@ -0,0 +1,41 @@
+# 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.
+
+driver("astro") {
+  sources = [
+    "astro-audio.c",
+    "astro-backlight.c",
+    "astro-bluetooth.c",
+    "astro-buttons.c",
+    "astro-canvas.c",
+    "astro-clk.c",
+    "astro-display.c",
+    "astro-gpio.c",
+    "astro-i2c.c",
+    "astro-light.c",
+    "astro-rawnand.c",
+    "astro-sdio.c",
+    "astro-tee.c",
+    "astro-thermal.c",
+    "astro-touch.c",
+    "astro-usb.c",
+    "astro-video.c",
+    "astro.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/dev/lib/broadcom",
+    "$zx/system/dev/lib/focaltech",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/board/gauss/BUILD.gn b/system/dev/board/gauss/BUILD.gn
new file mode 100644
index 0000000..cc1c15e
--- /dev/null
+++ b/system/dev/board/gauss/BUILD.gn
@@ -0,0 +1,57 @@
+# 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.
+
+driver("gauss") {
+  sources = [
+    "gauss-audio.c",
+    "gauss-clk.c",
+    "gauss-gpio.c",
+    "gauss-i2c.c",
+    "gauss-pcie.c",
+    "gauss-rawnand.c",
+    "gauss-usb.c",
+    "gauss.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/dev/pci/designware",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    ":gauss-i2c-test",
+  ]
+}
+
+driver("gauss-i2c-test") {
+  sources = [
+    "gauss-i2c-test.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+if (false) {  # TODO: ifeq (PLEASE_DISCUSS_WITH_SWETLAND,)
+  driver("gauss-led") {
+    sources = [
+      "gauss-led.c",
+    ]
+    deps = [
+      "$zx/system/ulib/ddk",
+      "$zx/system/ulib/sync",
+      "$zx/system/ulib/zircon",
+    ]
+  }
+}
diff --git a/system/dev/board/hikey960/BUILD.gn b/system/dev/board/hikey960/BUILD.gn
new file mode 100644
index 0000000..c901917
--- /dev/null
+++ b/system/dev/board/hikey960/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+driver("hikey960") {
+  sources = [
+    "hikey960-devices.c",
+    "hikey960-i2c.c",
+    "hikey960-usb.c",
+    "hikey960.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/dev/gpio/pl061",
+    "$zx/system/dev/lib/hi3660",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    "$zx/kernel/target/arm64/boot-shim:hikey960",
+    ":hi3660-i2c-test",  # TODO: only for test configs
+  ]
+}
+
+driver("hi3660-i2c-test") {
+  # TODO: testonly = true
+  sources = [
+    "hikey960-i2c-test.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/board/imx8mevk/BUILD.gn b/system/dev/board/imx8mevk/BUILD.gn
new file mode 100644
index 0000000..aca67e1
--- /dev/null
+++ b/system/dev/board/imx8mevk/BUILD.gn
@@ -0,0 +1,29 @@
+# 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.
+
+driver("imx8mevk") {
+  sources = [
+    "imx8mevk-gpio.c",
+    "imx8mevk-gpu.c",
+    "imx8mevk-i2c.c",
+    "imx8mevk-sdhci.c",
+    "imx8mevk-usb.c",
+    "imx8mevk.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/dev/lib/imx8m",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    "$zx/kernel/target/arm64/boot-shim:imx8mevk",
+  ]
+}
diff --git a/system/dev/board/imx8mmevk/BUILD.gn b/system/dev/board/imx8mmevk/BUILD.gn
new file mode 100644
index 0000000..2e0642c
--- /dev/null
+++ b/system/dev/board/imx8mmevk/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+driver("imx8mmevk") {
+  sources = [
+    "binding.c",
+    "imx8mmevk-gpio.cpp",
+    "imx8mmevk.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/imx8m",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+  data_deps = [
+    "$zx/kernel/target/arm64/boot-shim:imx8mmevk",
+  ]
+}
diff --git a/system/dev/board/machina/BUILD.gn b/system/dev/board/machina/BUILD.gn
new file mode 100644
index 0000000..852ed01
--- /dev/null
+++ b/system/dev/board/machina/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+driver("machina") {
+  sources = [
+    "machina.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/board/mt8167s_ref/BUILD.gn b/system/dev/board/mt8167s_ref/BUILD.gn
new file mode 100644
index 0000000..3f9a74c
--- /dev/null
+++ b/system/dev/board/mt8167s_ref/BUILD.gn
@@ -0,0 +1,41 @@
+# 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.
+
+driver("mt8167s_ref") {
+  sources = [
+    "mt8167-buttons.cpp",
+    "mt8167-clk.cpp",
+    "mt8167-display.cpp",
+    "mt8167-emmc.cpp",
+    "mt8167-gpio.cpp",
+    "mt8167-gpu.cpp",
+    "mt8167-i2c.cpp",
+    "mt8167-sdio.cpp",
+    "mt8167-sensors.cpp",
+    "mt8167-soc.cpp",
+    "mt8167-thermal.cpp",
+    "mt8167-touch.cpp",
+    "mt8167-usb.cpp",
+    "mt8167.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/dev/lib/focaltech",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+  data_deps = [
+    "$zx/kernel/target/arm64/boot-shim:mt8167s_ref",
+  ]
+}
diff --git a/system/dev/board/qemu/BUILD.gn b/system/dev/board/qemu/BUILD.gn
new file mode 100644
index 0000000..2722827
--- /dev/null
+++ b/system/dev/board/qemu/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("qemu") {
+  sources = [
+    "qemu-bus.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+  if (current_cpu == "arm64") {
+    data_deps = [
+      "$zx/kernel/target/arm64/boot-shim:qemu",
+    ]
+  }
+}
diff --git a/system/dev/board/sherlock/BUILD.gn b/system/dev/board/sherlock/BUILD.gn
new file mode 100644
index 0000000..5ee8485
--- /dev/null
+++ b/system/dev/board/sherlock/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+driver("sherlock") {
+  sources = [
+    "bind.c",
+    "sherlock-audio.cpp",
+    "sherlock-backlight.cpp",
+    "sherlock-bluetooth.cpp",
+    "sherlock-buttons.cpp",
+    "sherlock-camera.cpp",
+    "sherlock-canvas.cpp",
+    "sherlock-clk.cpp",
+    "sherlock-display.cpp",
+    "sherlock-emmc.cpp",
+    "sherlock-gpio.cpp",
+    "sherlock-i2c.cpp",
+    "sherlock-mali.cpp",
+    "sherlock-sdio.cpp",
+    "sherlock-usb.cpp",
+    "sherlock-video.cpp",
+    "sherlock.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/dev/lib/broadcom",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+  data_deps = [
+    "$zx/kernel/target/arm64/boot-shim:sherlock",
+  ]
+}
diff --git a/system/dev/board/test/BUILD.gn b/system/dev/board/test/BUILD.gn
new file mode 100644
index 0000000..9bfcc93
--- /dev/null
+++ b/system/dev/board/test/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.
+
+simple_drivers = [
+  "child-1",
+  "child-2",
+  "child-3",
+  "parent",
+]
+
+group("test") {
+  deps = [
+    ":test-board",
+    ":test-gpio",
+  ]
+  foreach(driver, simple_drivers) {
+    deps += [ ":test-$driver" ]
+  }
+}
+
+driver("test-board") {
+  sources = [
+    "test-board.cpp",
+    "test-gpio.cpp",
+    "test.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+driver("test-gpio") {
+  sources = [
+    "test/gpio.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+foreach(driver, simple_drivers) {
+  driver("test-$driver") {
+    sources = [
+      "test/$driver.c",
+    ]
+    deps = [
+      "$zx/system/banjo/ddk-protocol-gpio",
+      "$zx/system/banjo/ddk-protocol-platform-device",
+      "$zx/system/ulib/ddk",
+      "$zx/system/ulib/zircon",
+    ]
+  }
+}
diff --git a/system/dev/board/vim/BUILD.gn b/system/dev/board/vim/BUILD.gn
new file mode 100644
index 0000000..e21cced
--- /dev/null
+++ b/system/dev/board/vim/BUILD.gn
@@ -0,0 +1,43 @@
+# 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.
+
+driver("vim") {
+  sources = [
+    "vim-canvas.c",
+    "vim-clk.c",
+    "vim-display.c",
+    "vim-eth.c",
+    "vim-gpio.c",
+    "vim-i2c.c",
+    "vim-led2472g.c",
+    "vim-mali.c",
+    "vim-rtc.c",
+    "vim-sd-emmc.c",
+    "vim-sdio.c",
+    "vim-thermal.c",
+    "vim-uart.c",
+    "vim-usb.c",
+    "vim-video.c",
+    "vim.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/dev/lib/broadcom",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+  metadata = {
+    # The VIM has native ZBI support, so no extra image-packing is required.
+    bootimage_script = [ "/bin/true" ]
+  }
+}
diff --git a/system/dev/bus/BUILD.gn b/system/dev/bus/BUILD.gn
new file mode 100644
index 0000000..aa769a2
--- /dev/null
+++ b/system/dev/bus/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+group("bus") {
+  deps = [
+    "pci",
+    "platform",
+    "virtio",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "acpi" ]
+  }
+}
diff --git a/system/dev/bus/acpi/BUILD.gn b/system/dev/bus/acpi/BUILD.gn
new file mode 100644
index 0000000..edcc1f8
--- /dev/null
+++ b/system/dev/bus/acpi/BUILD.gn
@@ -0,0 +1,81 @@
+# 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("$zx/kernel/params.gni")
+
+assert(current_cpu == "x64")
+
+group("acpi") {
+  deps = [
+    ":bus-acpi",
+  ]
+}
+
+config("config") {
+  visibility = [ ":*" ]
+
+  include_dirs = [ "include" ]
+
+  if (enable_user_pci) {
+    defines = [ "ENABLE_USER_PCI" ]
+  }
+
+  if (!is_gcc) {
+    cflags = [ "-Wno-null-pointer-arithmetic" ]
+  }
+  cflags_c = [ "-fno-strict-aliasing" ]
+}
+
+driver("bus-acpi") {
+  sources = [
+    "bus-acpi.c",
+    "cpu-trace.c",
+    "debug.c",
+    "dev/dev-battery.c",
+    "dev/dev-cros-ec/dev.cpp",
+    "dev/dev-cros-ec/motion.cpp",
+    "dev/dev-ec.c",
+    "dev/dev-pwrbtn.cpp",
+    "dev/dev-pwrsrc.c",
+    "dev/dev-tbmc.cpp",
+    "dev/dev-thermal.c",
+    "init.c",
+    "iommu.c",
+    "methods.cpp",
+    "nhlt.c",
+    "pciroot.cpp",
+    "power.c",
+    "resources.c",
+    "util.c",
+  ]
+
+  # Userspace PCI feature flag.  The scaffolding for the userspace pci bus
+  # driver is in pci.cpp.  If not enabled then the kernel pci bus driver
+  # initialization code in ACPI (kpci.c) will be built instead.
+  if (enable_user_pci) {
+    sources += [ "pci.cpp" ]
+  } else {
+    sources += [ "kpci.c" ]
+  }
+  configs += [ ":config" ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-acpi",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-intelhda-dsp",
+    "$zx/system/banjo/ddk-protocol-pciroot",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/fidl/fuchsia-hardware-power:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/pci",
+    "$zx/system/ulib/region-alloc",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/lib/acpica",
+    "$zx/third_party/ulib/chromiumos-platform-ec",
+  ]
+}
diff --git a/system/dev/bus/pci/BUILD.gn b/system/dev/bus/pci/BUILD.gn
new file mode 100644
index 0000000..bc2dee9
--- /dev/null
+++ b/system/dev/bus/pci/BUILD.gn
@@ -0,0 +1,54 @@
+# 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("$zx/kernel/params.gni")
+
+group("pci") {
+  deps = [
+    ":bus-pci",
+  ]
+  if (!enable_user_pci) {
+    deps += [ ":bus-pci.proxy" ]
+  }
+}
+
+driver("bus-pci") {
+  deps = [
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/banjo/ddk-protocol-pciroot",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+  if (enable_user_pci) {
+    sources = [
+      "binding.c",
+      "bus.cpp",
+      "config.cpp",
+    ]
+    deps += [
+      "$zx/system/ulib/ddktl",
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/pretty",
+      "$zx/system/ulib/zxcpp",
+    ]
+  } else {
+    sources = [
+      "kpci/kpci.c",
+    ]
+    deps += [ "$zx/system/banjo/ddk-protocol-platform-device" ]
+  }
+}
+
+driver("bus-pci.proxy") {
+  sources = [
+    "kpci/proxy.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/banjo/ddk-protocol-pciroot",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/bus/platform/BUILD.gn b/system/dev/bus/platform/BUILD.gn
new file mode 100644
index 0000000..f13729e
--- /dev/null
+++ b/system/dev/bus/platform/BUILD.gn
@@ -0,0 +1,65 @@
+# 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.
+
+group("platform") {
+  deps = [
+    ":platform-bus",
+    ":platform-bus.proxy",
+  ]
+}
+
+driver("platform-bus") {
+  sources = [
+    "device-resources.cpp",
+    "platform-bus.cpp",
+    "platform-device.cpp",
+    "platform-i2c.cpp",
+    "platform-protocol-device.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-platform-proxy",
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+driver("platform-bus.proxy") {
+  sources = [
+    "platform-proxy-bind.c",
+    "platform-proxy-client.cpp",
+    "platform-proxy-device.cpp",
+    "platform-proxy.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-platform-proxy",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/bus/virtio/BUILD.gn b/system/dev/bus/virtio/BUILD.gn
new file mode 100644
index 0000000..610254c
--- /dev/null
+++ b/system/dev/bus/virtio/BUILD.gn
@@ -0,0 +1,43 @@
+# 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.
+
+driver("virtio") {
+  sources = [
+    "backends/pci.cpp",
+    "backends/pci_legacy.cpp",
+    "backends/pci_modern.cpp",
+    "block.cpp",
+    "console.cpp",
+    "device.cpp",
+    "ethernet.cpp",
+    "gpu.cpp",
+    "input.cpp",
+    "ring.cpp",
+    "rng.cpp",
+    "socket.cpp",
+    "virtio_c.c",
+    "virtio_driver.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/fidl/fuchsia-hardware-vsock:c",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/virtio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/camera/BUILD.gn b/system/dev/camera/BUILD.gn
new file mode 100644
index 0000000..df83da3
--- /dev/null
+++ b/system/dev/camera/BUILD.gn
@@ -0,0 +1,10 @@
+# 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.
+
+group("camera") {
+  deps = [
+    "aml-mipicsi",
+    "imx227",
+  ]
+}
diff --git a/system/dev/camera/aml-mipicsi/BUILD.gn b/system/dev/camera/aml-mipicsi/BUILD.gn
new file mode 100644
index 0000000..958a1c6
--- /dev/null
+++ b/system/dev/camera/aml-mipicsi/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+driver("aml-mipicsi") {
+  sources = [
+    "aml-mipi-adap.cpp",
+    "aml-mipi-debug.cpp",
+    "aml-mipi.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-mipicsi",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/camera/imx227/BUILD.gn b/system/dev/camera/imx227/BUILD.gn
new file mode 100644
index 0000000..6ecf97b
--- /dev/null
+++ b/system/dev/camera/imx227/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("imx227") {
+  sources = [
+    "imx227.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-mipicsi",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/fidl/fuchsia-hardware-camera:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/clk/BUILD.gn b/system/dev/clk/BUILD.gn
new file mode 100644
index 0000000..2d94af8
--- /dev/null
+++ b/system/dev/clk/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+group("clk") {
+  deps = [
+    "amlogic-clk",
+    "hisi-lib",
+    "hisi3660",
+  ]
+}
diff --git a/system/dev/clk/amlogic-clk/BUILD.gn b/system/dev/clk/amlogic-clk/BUILD.gn
new file mode 100644
index 0000000..4e9bc63
--- /dev/null
+++ b/system/dev/clk/amlogic-clk/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+driver("amlogic-clk") {
+  sources = [
+    "aml-clk.c",
+    "aml-clk.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/clk/hisi-lib/BUILD.gn b/system/dev/clk/hisi-lib/BUILD.gn
new file mode 100644
index 0000000..5f87aae
--- /dev/null
+++ b/system/dev/clk/hisi-lib/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+library("hisi-lib") {
+  sdk = "static"
+  sdk_headers = [ "dev/clk/hisi-lib/hisi.h" ]
+  sources = [
+    "hisi-clk.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/clk/hisi3660/BUILD.gn b/system/dev/clk/hisi3660/BUILD.gn
new file mode 100644
index 0000000..616dab6
--- /dev/null
+++ b/system/dev/clk/hisi3660/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("hisi3660") {
+  sources = [
+    "hisi3660-clk.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/clk/hisi-lib",
+    "$zx/system/dev/lib/hi3660",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/clk/mtk-clk/BUILD.gn b/system/dev/clk/mtk-clk/BUILD.gn
new file mode 100644
index 0000000..fdd9d87
--- /dev/null
+++ b/system/dev/clk/mtk-clk/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("mtk-clk") {
+  sources = [
+    "binding.c",
+    "mtk-clk.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/codec/BUILD.gn b/system/dev/codec/BUILD.gn
new file mode 100644
index 0000000..ee02a84
--- /dev/null
+++ b/system/dev/codec/BUILD.gn
@@ -0,0 +1,10 @@
+# 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.
+
+group("codec") {
+  deps = [
+    "alc5514",
+    "max98927",
+  ]
+}
diff --git a/system/dev/codec/alc5514/BUILD.gn b/system/dev/codec/alc5514/BUILD.gn
new file mode 100644
index 0000000..281cd2b
--- /dev/null
+++ b/system/dev/codec/alc5514/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("alc5514") {
+  sources = [
+    "alc5514.cpp",
+    "binding.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/codec/max98927/BUILD.gn b/system/dev/codec/max98927/BUILD.gn
new file mode 100644
index 0000000..024cef4
--- /dev/null
+++ b/system/dev/codec/max98927/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("max98927") {
+  sources = [
+    "binding.c",
+    "max98927.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/BUILD.gn b/system/dev/display/BUILD.gn
new file mode 100644
index 0000000..c998ccc
--- /dev/null
+++ b/system/dev/display/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+group("display") {
+  deps = [
+    "aml-canvas",
+    "astro-display",
+    "display",
+    "dummy",
+    "hikey-display",
+    "imx8m-display",
+    "led2472g",
+    "mt8167s-display",
+    "simple",
+    "vim-display",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "intel-i915" ]
+  }
+}
diff --git a/system/dev/display/aml-canvas/BUILD.gn b/system/dev/display/aml-canvas/BUILD.gn
new file mode 100644
index 0000000..d6fbc97
--- /dev/null
+++ b/system/dev/display/aml-canvas/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+driver("aml-canvas") {
+  sources = [
+    "aml-canvas.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-amlogiccanvas",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-platform-proxy",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    ":aml-canvas.proxy",
+  ]
+}
+
+driver("aml-canvas.proxy") {
+  sources = [
+    "aml-canvas-proxy-client.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-amlogiccanvas",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-platform-proxy",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/display/astro-display/BUILD.gn b/system/dev/display/astro-display/BUILD.gn
new file mode 100644
index 0000000..6f31d4f
--- /dev/null
+++ b/system/dev/display/astro-display/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+driver("astro-display") {
+  sources = [
+    "aml-dsi-host.cpp",
+    "aml-mipi-phy.cpp",
+    "astro-clock.cpp",
+    "astro-display.cpp",
+    "bind.c",
+    "dw-mipi-dsi.cpp",
+    "lcd.cpp",
+    "osd.cpp",
+    "vpu.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-amlogiccanvas",
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/display/BUILD.gn b/system/dev/display/display/BUILD.gn
new file mode 100644
index 0000000..9500b9b
--- /dev/null
+++ b/system/dev/display/display/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+driver("display") {
+  sources = [
+    "bind.c",
+    "client.cpp",
+    "controller.cpp",
+    "fence.cpp",
+    "image.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/fidl/fuchsia-hardware-display:c",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/edid",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/dummy/BUILD.gn b/system/dev/display/dummy/BUILD.gn
new file mode 100644
index 0000000..bb29eb7
--- /dev/null
+++ b/system/dev/display/dummy/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("dummy") {
+  sources = [
+    "dummy-display.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/hikey-display/BUILD.gn b/system/dev/display/hikey-display/BUILD.gn
new file mode 100644
index 0000000..4253e84
--- /dev/null
+++ b/system/dev/display/hikey-display/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("hikey-display") {
+  sources = [
+    "adv7533.c",
+    "ddk-interface.cpp",
+    "edid.c",
+    "hi3660-dsi.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/imx8m-display/BUILD.gn b/system/dev/display/imx8m-display/BUILD.gn
new file mode 100644
index 0000000..f6245df
--- /dev/null
+++ b/system/dev/display/imx8m-display/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+driver("imx8m-display") {
+  sources = [
+    "imx8m-display.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/display/intel-i915/BUILD.gn b/system/dev/display/intel-i915/BUILD.gn
new file mode 100644
index 0000000..5c95f8b
--- /dev/null
+++ b/system/dev/display/intel-i915/BUILD.gn
@@ -0,0 +1,36 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("intel-i915") {
+  sources = [
+    "bind.c",
+    "display-device.cpp",
+    "dp-display.cpp",
+    "gtt.cpp",
+    "hdmi-display.cpp",
+    "igd.cpp",
+    "intel-i915.cpp",
+    "interrupts.cpp",
+    "pipe.cpp",
+    "power.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-intelgpucore",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/fidl/fuchsia-hardware-backlight:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/edid",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/region-alloc",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/led2472g/BUILD.gn b/system/dev/display/led2472g/BUILD.gn
new file mode 100644
index 0000000..9590413
--- /dev/null
+++ b/system/dev/display/led2472g/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+group("led2472g") {
+  deps = [
+    ":vim-led2472g",
+  ]
+}
+
+driver("vim-led2472g") {
+  sources = [
+    "led2472g.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/display/mt8167s-display/BUILD.gn b/system/dev/display/mt8167s-display/BUILD.gn
new file mode 100644
index 0000000..4df834e
--- /dev/null
+++ b/system/dev/display/mt8167s-display/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+driver("mt8167s-display") {
+  sources = [
+    "disp-rdma.cpp",
+    "mt8167s-display.cpp",
+    "ovl.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/display/simple/BUILD.gn b/system/dev/display/simple/BUILD.gn
new file mode 100644
index 0000000..9ce6a4c
--- /dev/null
+++ b/system/dev/display/simple/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+source_set("shared") {
+  visibility = [ ":*" ]
+  sources = [
+    "simple-display.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+  ]
+}
+
+simple_drivers = [
+  "bochs",
+  "amd-kaveri",
+  "nv",
+  "intel",
+]
+
+group("simple") {
+  deps = []
+  foreach(driver, simple_drivers) {
+    deps += [ ":simple.$driver" ]
+  }
+}
+
+foreach(driver, simple_drivers) {
+  driver("simple.$driver") {
+    sources = [
+      "simple-$driver.c",
+    ]
+    deps = [
+      ":shared",
+      "$zx/system/banjo/ddk-protocol-display-controller",
+      "$zx/system/banjo/ddk-protocol-pci",
+      "$zx/system/ulib/ddk",
+    ]
+  }
+}
diff --git a/system/dev/display/vim-display/BUILD.gn b/system/dev/display/vim-display/BUILD.gn
new file mode 100644
index 0000000..b4878bc
--- /dev/null
+++ b/system/dev/display/vim-display/BUILD.gn
@@ -0,0 +1,40 @@
+# 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.
+
+driver("vim-display") {
+  sources = [
+    "edid.cpp",
+    "hdmitx.cpp",
+    "hdmitx_clk.cpp",
+    "registers.cpp",
+    "vim-audio-utils.cpp",
+    "vim-audio.cpp",
+    "vim-display.cpp",
+    "vim-spdif-audio-stream.cpp",
+    "vpp.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-amlogiccanvas",
+    "$zx/system/banjo/ddk-protocol-display-controller",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/audio/lib/simple-audio-stream",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/dev/ethernet/BUILD.gn b/system/dev/ethernet/BUILD.gn
new file mode 100644
index 0000000..9cb5366
--- /dev/null
+++ b/system/dev/ethernet/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+group("ethernet") {
+  deps = [
+    "aml-ethernet-s912",
+    "asix-88179",
+    "asix-88772b",
+    "dwmac",
+    "ethernet",
+    "ethertap",
+    "realtek-8211f",
+    "rndis",
+    "usb-cdc-ecm",
+    "usb-cdc-function",
+  ]
+  if (current_cpu == "x64") {
+    deps += [
+      "intel-ethernet",
+      "realtek-8111",
+    ]
+  }
+}
diff --git a/system/dev/ethernet/aml-ethernet-s912/BUILD.gn b/system/dev/ethernet/aml-ethernet-s912/BUILD.gn
new file mode 100644
index 0000000..e15a72c
--- /dev/null
+++ b/system/dev/ethernet/aml-ethernet-s912/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("aml-ethernet-s912") {
+  sources = [
+    "aml-ethernet.cpp",
+    "binding.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-ethernet-board",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/ethernet/asix-88179/BUILD.gn b/system/dev/ethernet/asix-88179/BUILD.gn
new file mode 100644
index 0000000..77c0f77
--- /dev/null
+++ b/system/dev/ethernet/asix-88179/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("asix-88179") {
+  sources = [
+    "asix-88179.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/dev/ethernet/asix-88772b/BUILD.gn b/system/dev/ethernet/asix-88772b/BUILD.gn
new file mode 100644
index 0000000..a666082
--- /dev/null
+++ b/system/dev/ethernet/asix-88772b/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("asix-88772b") {
+  sources = [
+    "asix-88772b.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/ethernet/dwmac/BUILD.gn b/system/dev/ethernet/dwmac/BUILD.gn
new file mode 100644
index 0000000..e2ec518
--- /dev/null
+++ b/system/dev/ethernet/dwmac/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+driver("dwmac") {
+  sources = [
+    "binding.c",
+    "dwmac-debug.cpp",
+    "dwmac.cpp",
+    "pinned-buffer.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-ethernet-board",
+    "$zx/system/banjo/ddk-protocol-ethernet-mac",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/ethernet/ethernet/BUILD.gn b/system/dev/ethernet/ethernet/BUILD.gn
new file mode 100644
index 0000000..2f09c7e
--- /dev/null
+++ b/system/dev/ethernet/ethernet/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+driver("ethernet") {
+  sources = [
+    "ethernet.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/fidl/fuchsia-hardware-ethernet:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/ethernet/ethertap/BUILD.gn b/system/dev/ethernet/ethertap/BUILD.gn
new file mode 100644
index 0000000..3f695c5
--- /dev/null
+++ b/system/dev/ethernet/ethertap/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("ethertap") {
+  sources = [
+    "binding.c",
+    "ethertap.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/ethernet/intel-ethernet/BUILD.gn b/system/dev/ethernet/intel-ethernet/BUILD.gn
new file mode 100644
index 0000000..78baf15
--- /dev/null
+++ b/system/dev/ethernet/intel-ethernet/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("intel-ethernet") {
+  sources = [
+    "ethernet.c",
+    "ie.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/ethernet/realtek-8111/BUILD.gn b/system/dev/ethernet/realtek-8111/BUILD.gn
new file mode 100644
index 0000000..c1cb4ca
--- /dev/null
+++ b/system/dev/ethernet/realtek-8111/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("realtek-8111") {
+  sources = [
+    "rtl8111.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/ethernet/realtek-8211f/BUILD.gn b/system/dev/ethernet/realtek-8211f/BUILD.gn
new file mode 100644
index 0000000..df11fd5
--- /dev/null
+++ b/system/dev/ethernet/realtek-8211f/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("realtek-8211f") {
+  sources = [
+    "binding.c",
+    "rtl8211f.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet-mac",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/ethernet/rndis/BUILD.gn b/system/dev/ethernet/rndis/BUILD.gn
new file mode 100644
index 0000000..d915127
--- /dev/null
+++ b/system/dev/ethernet/rndis/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("rndis") {
+  sources = [
+    "rndishost.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/ethernet/usb-cdc-ecm/BUILD.gn b/system/dev/ethernet/usb-cdc-ecm/BUILD.gn
new file mode 100644
index 0000000..8ea8be3
--- /dev/null
+++ b/system/dev/ethernet/usb-cdc-ecm/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("usb-cdc-ecm") {
+  sources = [
+    "usb-cdc-ecm.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/ethernet/usb-cdc-function/BUILD.gn b/system/dev/ethernet/usb-cdc-function/BUILD.gn
new file mode 100644
index 0000000..e889f19
--- /dev/null
+++ b/system/dev/ethernet/usb-cdc-function/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("usb-cdc-function") {
+  sources = [
+    "cdc-eth-function.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-function",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/inet6",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/gpio/BUILD.gn b/system/dev/gpio/BUILD.gn
new file mode 100644
index 0000000..2a026d1
--- /dev/null
+++ b/system/dev/gpio/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+group("gpio") {
+  deps = [
+    "aml-axg-gpio",
+    "aml-gxl-gpio",
+    "gpio-test",
+    "imx8",
+    "mt-8167",
+    "pl061",
+  ]
+}
diff --git a/system/dev/gpio/aml-axg-gpio/BUILD.gn b/system/dev/gpio/aml-axg-gpio/BUILD.gn
new file mode 100644
index 0000000..b5f3f8b
--- /dev/null
+++ b/system/dev/gpio/aml-axg-gpio/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("aml-axg-gpio") {
+  sources = [
+    "aml-axg-gpio.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/gpio/aml-gxl-gpio/BUILD.gn b/system/dev/gpio/aml-gxl-gpio/BUILD.gn
new file mode 100644
index 0000000..0cddc4e
--- /dev/null
+++ b/system/dev/gpio/aml-gxl-gpio/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+driver("aml-gxl-gpio") {
+  sources = [
+    "aml-gxl-gpio.cpp",
+    "binding.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/gpio/gpio-test/BUILD.gn b/system/dev/gpio/gpio-test/BUILD.gn
new file mode 100644
index 0000000..ac9b702
--- /dev/null
+++ b/system/dev/gpio/gpio-test/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("gpio-test") {
+  sources = [
+    "gpio-test.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/gpio/imx8/BUILD.gn b/system/dev/gpio/imx8/BUILD.gn
new file mode 100644
index 0000000..92abfdb
--- /dev/null
+++ b/system/dev/gpio/imx8/BUILD.gn
@@ -0,0 +1,56 @@
+# 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.
+
+group("imx8") {
+  deps = [
+    ":imx8.m",
+    ":imx8.m-mini",
+  ]
+}
+
+driver("imx8.m") {
+  sources = [
+    "imx8m-gpio.c",
+  ]
+  deps = [
+    ":common",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/imx8m",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+driver("imx8.m-mini") {
+  sources = [
+    "imx8m-mini-gpio.c",
+  ]
+  deps = [
+    ":common",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/imx8m",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+source_set("common") {
+  visibility = [ ":*" ]
+  sources = [
+    "imx8-gpio.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/imx8m",
+    "$zx/system/ulib/ddk",
+  ]
+}
diff --git a/system/dev/gpio/mt-8167/BUILD.gn b/system/dev/gpio/mt-8167/BUILD.gn
new file mode 100644
index 0000000..53432cf
--- /dev/null
+++ b/system/dev/gpio/mt-8167/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+driver("mt-8167") {
+  sources = [
+    "mt8167-gpio.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/gpio/pl061/BUILD.gn b/system/dev/gpio/pl061/BUILD.gn
new file mode 100644
index 0000000..90708a3
--- /dev/null
+++ b/system/dev/gpio/pl061/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+library("pl061") {
+  sources = [
+    "pl061.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/gpu/BUILD.gn b/system/dev/gpu/BUILD.gn
new file mode 100644
index 0000000..e9ad155
--- /dev/null
+++ b/system/dev/gpu/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+group("gpu") {
+  deps = [
+    "aml-gpu",
+  ]
+}
diff --git a/system/dev/gpu/aml-gpu/BUILD.gn b/system/dev/gpu/aml-gpu/BUILD.gn
new file mode 100644
index 0000000..91b309d
--- /dev/null
+++ b/system/dev/gpu/aml-gpu/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+driver("aml-gpu") {
+  sources = [
+    "aml-gpu.c",
+    "aml-s905d2g.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-iommu",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/fidl/fuchsia-hardware-gpu-clock:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/i2c/BUILD.gn b/system/dev/i2c/BUILD.gn
new file mode 100644
index 0000000..ae85eae
--- /dev/null
+++ b/system/dev/i2c/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+group("i2c") {
+  deps = [
+    "aml-i2c",
+    "dw-i2c",
+    "imx-i2c",
+    "intel-i2c",
+    "mt8167-i2c",
+  ]
+}
diff --git a/system/dev/i2c/aml-i2c/BUILD.gn b/system/dev/i2c/aml-i2c/BUILD.gn
new file mode 100644
index 0000000..f1ef305
--- /dev/null
+++ b/system/dev/i2c/aml-i2c/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("aml-i2c") {
+  sources = [
+    "aml-i2c.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/i2c/dw-i2c/BUILD.gn b/system/dev/i2c/dw-i2c/BUILD.gn
new file mode 100644
index 0000000..e02842b
--- /dev/null
+++ b/system/dev/i2c/dw-i2c/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("dw-i2c") {
+  sources = [
+    "dw-i2c.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/i2c/imx-i2c/BUILD.gn b/system/dev/i2c/imx-i2c/BUILD.gn
new file mode 100644
index 0000000..beb4359
--- /dev/null
+++ b/system/dev/i2c/imx-i2c/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+driver("imx-i2c") {
+  sources = [
+    "imx-i2c.c",
+    "imx-i2c.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/i2c/intel-i2c/BUILD.gn b/system/dev/i2c/intel-i2c/BUILD.gn
new file mode 100644
index 0000000..ef01824
--- /dev/null
+++ b/system/dev/i2c/intel-i2c/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("intel-i2c") {
+  sources = [
+    "intel-i2c-controller.c",
+    "intel-i2c-slave.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/fidl/fuchsia-hardware-i2c:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/i2c/mt8167-i2c/BUILD.gn b/system/dev/i2c/mt8167-i2c/BUILD.gn
new file mode 100644
index 0000000..05838b9
--- /dev/null
+++ b/system/dev/i2c/mt8167-i2c/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("mt8167-i2c") {
+  sources = [
+    "bind.c",
+    "mt8167-i2c.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-i2cimpl",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/input/BUILD.gn b/system/dev/input/BUILD.gn
new file mode 100644
index 0000000..b2ae529
--- /dev/null
+++ b/system/dev/input/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+group("input") {
+  deps = [
+    "bma253",
+    "focaltech",
+    "goodix",
+    "hid",
+    "hid-buttons",
+    "hidctl",
+    "i2c-hid",
+    "usb-hid",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "pc-ps2" ]
+  }
+}
diff --git a/system/dev/input/bma253/BUILD.gn b/system/dev/input/bma253/BUILD.gn
new file mode 100644
index 0000000..146d63b
--- /dev/null
+++ b/system/dev/input/bma253/BUILD.gn
@@ -0,0 +1,49 @@
+# 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.
+
+driver("bma253") {
+  sources = [
+    "bma253.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/simplehid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+test("bma253-test") {
+  sources = [
+    "bma253-test.cpp",
+    "bma253.cpp",
+  ]
+  deps = [
+    "$zx/system/dev/lib/mock-hidbus-ifc",
+    "$zx/system/dev/lib/mock-i2c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/simplehid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/input/focaltech/BUILD.gn b/system/dev/input/focaltech/BUILD.gn
new file mode 100644
index 0000000..42c9e34
--- /dev/null
+++ b/system/dev/input/focaltech/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+driver("focaltech") {
+  sources = [
+    "focaltech.c",
+    "ft_device.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/dev/lib/focaltech",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/input/goodix/BUILD.gn b/system/dev/input/goodix/BUILD.gn
new file mode 100644
index 0000000..eace5dd
--- /dev/null
+++ b/system/dev/input/goodix/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("goodix") {
+  sources = [
+    "gt92xx.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/input/hid-buttons/BUILD.gn b/system/dev/input/hid-buttons/BUILD.gn
new file mode 100644
index 0000000..69ce5f1
--- /dev/null
+++ b/system/dev/input/hid-buttons/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+driver("hid-buttons") {
+  sources = [
+    "bind.c",
+    "hid-buttons.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/input/hid/BUILD.gn b/system/dev/input/hid/BUILD.gn
new file mode 100644
index 0000000..5879d07
--- /dev/null
+++ b/system/dev/input/hid/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("hid") {
+  sources = [
+    "hid-fifo.c",
+    "hid-parser-lib.cpp",
+    "hid.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid-parser",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/input/hidctl/BUILD.gn b/system/dev/input/hidctl/BUILD.gn
new file mode 100644
index 0000000..cbbe9d6
--- /dev/null
+++ b/system/dev/input/hidctl/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("hidctl") {
+  sources = [
+    "binding.c",
+    "hidctl.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/input/i2c-hid/BUILD.gn b/system/dev/input/i2c-hid/BUILD.gn
new file mode 100644
index 0000000..a470d48
--- /dev/null
+++ b/system/dev/input/i2c-hid/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("i2c-hid") {
+  sources = [
+    "i2c-hid.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/input/pc-ps2/BUILD.gn b/system/dev/input/pc-ps2/BUILD.gn
new file mode 100644
index 0000000..7356409
--- /dev/null
+++ b/system/dev/input/pc-ps2/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("pc-ps2") {
+  sources = [
+    "i8042.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/input/usb-hid/BUILD.gn b/system/dev/input/usb-hid/BUILD.gn
new file mode 100644
index 0000000..76906f6
--- /dev/null
+++ b/system/dev/input/usb-hid/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("usb-hid") {
+  sources = [
+    "usb-hid.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/lib/amlogic/BUILD.gn b/system/dev/lib/amlogic/BUILD.gn
new file mode 100644
index 0000000..fb09617
--- /dev/null
+++ b/system/dev/lib/amlogic/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+library("amlogic") {
+  sources = [
+    "a113-clocks.c",
+    "aml-pdm-audio.cpp",
+    "aml-tdm-audio.cpp",
+    "aml-usb-phy-v2.c",
+    "s905d2-hiu.c",
+    "s905d2-mali.c",
+    "s905d2-pll-rates.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/dev/lib/broadcom/BUILD.gn b/system/dev/lib/broadcom/BUILD.gn
new file mode 100644
index 0000000..4f42bff
--- /dev/null
+++ b/system/dev/lib/broadcom/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+library("broadcom") {
+  sdk = "source"
+  sdk_headers = [ "wifi/wifi-config.h" ]
+  sources = []
+}
diff --git a/system/dev/lib/fake-bti/BUILD.gn b/system/dev/lib/fake-bti/BUILD.gn
new file mode 100644
index 0000000..739e78f
--- /dev/null
+++ b/system/dev/lib/fake-bti/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+library("fake-bti") {
+  sdk = "shared"
+  sdk_headers = [ "lib/fake-bti/bti.h" ]
+  testonly = true
+  shared = true
+  sources = [
+    "fake-bti.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/lib/fake_ddk/BUILD.gn b/system/dev/lib/fake_ddk/BUILD.gn
new file mode 100644
index 0000000..530ac49
--- /dev/null
+++ b/system/dev/lib/fake_ddk/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+library("fake_ddk") {
+  testonly = true
+  sources = [
+    "fake_ddk.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/lib/focaltech/BUILD.gn b/system/dev/lib/focaltech/BUILD.gn
new file mode 100644
index 0000000..0c7f839
--- /dev/null
+++ b/system/dev/lib/focaltech/BUILD.gn
@@ -0,0 +1,7 @@
+# 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.
+
+library("focaltech") {
+  sources = []
+}
diff --git a/system/dev/lib/hi3660/BUILD.gn b/system/dev/lib/hi3660/BUILD.gn
new file mode 100644
index 0000000..f251561
--- /dev/null
+++ b/system/dev/lib/hi3660/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+library("hi3660") {
+  sources = [
+    "hi3660-dsi.c",
+    "hi3660-gpios.c",
+    "hi3660-i2c.c",
+    "hi3660-usb.c",
+    "hi3660.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-gpioimpl",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/gpio/pl061",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/lib/imx8m/BUILD.gn b/system/dev/lib/imx8m/BUILD.gn
new file mode 100644
index 0000000..01222e0
--- /dev/null
+++ b/system/dev/lib/imx8m/BUILD.gn
@@ -0,0 +1,7 @@
+# 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.
+
+library("imx8m") {
+  sources = []
+}
diff --git a/system/dev/lib/mock-hidbus-ifc/BUILD.gn b/system/dev/lib/mock-hidbus-ifc/BUILD.gn
new file mode 100644
index 0000000..8a64231
--- /dev/null
+++ b/system/dev/lib/mock-hidbus-ifc/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+library("mock-hidbus-ifc") {
+  testonly = true
+  sources = []
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/dev/lib/mock-i2c/BUILD.gn b/system/dev/lib/mock-i2c/BUILD.gn
new file mode 100644
index 0000000..06aa8da
--- /dev/null
+++ b/system/dev/lib/mock-i2c/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+library("mock-i2c") {
+  testonly = true
+  sources = [
+    "mock-i2c.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/dev/lib/mock_mmio_reg/BUILD.gn b/system/dev/lib/mock_mmio_reg/BUILD.gn
new file mode 100644
index 0000000..c843e62
--- /dev/null
+++ b/system/dev/lib/mock_mmio_reg/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+library("mock_mmio_reg") {
+  # TODO: testonly = true
+  sources = [
+    "mock_mmio_reg.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/dev/lib/mt8167/BUILD.gn b/system/dev/lib/mt8167/BUILD.gn
new file mode 100644
index 0000000..28147f6
--- /dev/null
+++ b/system/dev/lib/mt8167/BUILD.gn
@@ -0,0 +1,7 @@
+# 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.
+
+library("mt8167") {
+  sources = []
+}
diff --git a/system/dev/lib/usb/BUILD.gn b/system/dev/lib/usb/BUILD.gn
new file mode 100644
index 0000000..bdd4c53
--- /dev/null
+++ b/system/dev/lib/usb/BUILD.gn
@@ -0,0 +1,47 @@
+# 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.
+
+library("usb") {
+  sdk = "source"
+  sdk_headers = [
+    "usb/usb-request.h",
+    "usb/usb.h",
+  ]
+  sources = [
+    "usb-request.c",
+    "usb-wrapper.cpp",
+    "usb.c",
+  ]
+  public_deps = [
+    # <ddk/usb/usb.h> has #include <ddk/protocol/usb.h>.
+    "$zx/system/ulib/ddk:headers",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+  ]
+}
+
+test("usb-wrapper-test") {
+  sources = [
+    "tests/main.c",
+    "tests/usb-wrapper-tests.cpp",
+  ]
+  deps = [
+    ":usb",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/dev/lib/fake-bti",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/light/BUILD.gn b/system/dev/light/BUILD.gn
new file mode 100644
index 0000000..82d2ab9
--- /dev/null
+++ b/system/dev/light/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+group("light") {
+  deps = [
+    "ams-light",
+  ]
+}
diff --git a/system/dev/light/ams-light/BUILD.gn b/system/dev/light/ams-light/BUILD.gn
new file mode 100644
index 0000000..eca06bb
--- /dev/null
+++ b/system/dev/light/ams-light/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("ams-light") {
+  sources = [
+    "tcs3400.c",
+    "tcs3400.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/light/lite-on/BUILD.gn b/system/dev/light/lite-on/BUILD.gn
new file mode 100644
index 0000000..0377c8c
--- /dev/null
+++ b/system/dev/light/lite-on/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+driver("lite-on") {
+  sources = [
+    "binding.c",
+    "ltr-578als.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/simplehid",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/misc/BUILD.gn b/system/dev/misc/BUILD.gn
new file mode 100644
index 0000000..9f49444
--- /dev/null
+++ b/system/dev/misc/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+group("misc") {
+  deps = [
+    "builtin",
+    "console",
+    "ktrace",
+    "pty",
+    "sysinfo",
+    "test",
+  ]
+
+  if (current_cpu == "x64") {
+    deps += [
+      "tpm",
+
+      # TODO(dje): This can either be removed (we only support arm,x86)
+      # or even add arm to the filter-out list when arm supported is added.
+      "cpu-trace",
+    ]
+  }
+}
diff --git a/system/dev/misc/builtin/BUILD.gn b/system/dev/misc/builtin/BUILD.gn
new file mode 100644
index 0000000..73080ba
--- /dev/null
+++ b/system/dev/misc/builtin/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+driver("builtin") {
+  sources = [
+    "null.c",
+    "root.c",
+    "zero.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/misc/console/BUILD.gn b/system/dev/misc/console/BUILD.gn
new file mode 100644
index 0000000..8bf39bd
--- /dev/null
+++ b/system/dev/misc/console/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+driver("console") {
+  sources = [
+    "console.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/misc/cpu-trace/BUILD.gn b/system/dev/misc/cpu-trace/BUILD.gn
new file mode 100644
index 0000000..f1dbffb
--- /dev/null
+++ b/system/dev/misc/cpu-trace/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("cpu-trace") {
+  sources = [
+    "cpu-trace.c",
+    "intel-pm.c",
+    "intel-pt.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/system/dev/misc/ktrace/BUILD.gn b/system/dev/misc/ktrace/BUILD.gn
new file mode 100644
index 0000000..ea68dd0
--- /dev/null
+++ b/system/dev/misc/ktrace/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+driver("ktrace") {
+  sources = [
+    "ktrace.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/system/dev/misc/pty/BUILD.gn b/system/dev/misc/pty/BUILD.gn
new file mode 100644
index 0000000..20eecbc
--- /dev/null
+++ b/system/dev/misc/pty/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+driver("pty") {
+  sources = [
+    "pty-core.c",
+    "pty-driver.c",
+    "pty-fifo.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/misc/sysinfo/BUILD.gn b/system/dev/misc/sysinfo/BUILD.gn
new file mode 100644
index 0000000..ec87dc6
--- /dev/null
+++ b/system/dev/misc/sysinfo/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+driver("sysinfo") {
+  sources = [
+    "sysinfo.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/misc/test/BUILD.gn b/system/dev/misc/test/BUILD.gn
new file mode 100644
index 0000000..94c201c
--- /dev/null
+++ b/system/dev/misc/test/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+driver("test") {
+  sources = [
+    "test.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/fidl/fuchsia-device-test:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/misc/tpm/BUILD.gn b/system/dev/misc/tpm/BUILD.gn
new file mode 100644
index 0000000..94e723b
--- /dev/null
+++ b/system/dev/misc/tpm/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("tpm") {
+  sources = [
+    "bind.c",
+    "i2c-cr50.cpp",
+    "tpm-commands.cpp",
+    "tpm-proto.cpp",
+    "tpm.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/explicit-memory",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/nand/BUILD.gn b/system/dev/nand/BUILD.gn
new file mode 100644
index 0000000..64e55b4
--- /dev/null
+++ b/system/dev/nand/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+group("nand") {
+  testonly = true
+  deps = [
+    "aml-rawnand",
+    "broker",
+    "nand",
+    "nandpart",
+    "ram-nand",
+    "skip-block",
+  ]
+}
diff --git a/system/dev/nand/aml-rawnand/BUILD.gn b/system/dev/nand/aml-rawnand/BUILD.gn
new file mode 100644
index 0000000..e0f9d03
--- /dev/null
+++ b/system/dev/nand/aml-rawnand/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("aml-rawnand") {
+  sources = [
+    "aml-rawnand.c",
+    "onfi.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-rawnand",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/fidl/fuchsia-hardware-nand",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/nand/broker/BUILD.gn b/system/dev/nand/broker/BUILD.gn
new file mode 100644
index 0000000..133923f
--- /dev/null
+++ b/system/dev/nand/broker/BUILD.gn
@@ -0,0 +1,50 @@
+# 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.
+
+group("broker") {
+  deps = [
+    ":nand-broker",
+  ]
+}
+
+driver("nand-broker") {
+  sources = [
+    "bind.c",
+    "broker.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/fidl/fuchsia-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+test("nand") {
+  sources = [
+    "test/broker-test.cpp",
+    "test/main.cpp",
+    "test/parent.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/fidl/fuchsia-nand:c",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/nand/nand/BUILD.gn b/system/dev/nand/nand/BUILD.gn
new file mode 100644
index 0000000..521ced1
--- /dev/null
+++ b/system/dev/nand/nand/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+driver("nand") {
+  sources = [
+    "nand.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-rawnand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/nand/nandpart/BUILD.gn b/system/dev/nand/nandpart/BUILD.gn
new file mode 100644
index 0000000..4e44603
--- /dev/null
+++ b/system/dev/nand/nandpart/BUILD.gn
@@ -0,0 +1,52 @@
+# 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.
+
+driver("nandpart") {
+  sources = [
+    "aml-bad-block.cpp",
+    "bad-block.cpp",
+    "binding.c",
+    "nandpart-utils.cpp",
+    "nandpart.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-badblock",
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+test("nandpart-test") {
+  output_name = "nandpart-test"
+  sources = [
+    "aml-bad-block.cpp",
+    "bad-block.cpp",
+    "nandpart-utils.cpp",
+    "test/aml-bad-block-test.cpp",
+    "test/main.cpp",
+    "test/nandpart-utils-test.cpp",
+  ]
+  include_dirs = [ "." ]
+  defines = [ "TEST" ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/nand/ram-nand/BUILD.gn b/system/dev/nand/ram-nand/BUILD.gn
new file mode 100644
index 0000000..751918b
--- /dev/null
+++ b/system/dev/nand/ram-nand/BUILD.gn
@@ -0,0 +1,65 @@
+# 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.
+
+driver("ram-nand") {
+  sources = [
+    "ram-nand-ctl.cpp",
+    "ram-nand.c",
+  ]
+  deps = [
+    ":common",
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+source_set("common") {
+  visibility = [ ":*" ]
+  sources = [
+    "ram-nand.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/sync",
+  ]
+}
+
+test("ram-nand-test") {
+  output_name = "ram-nand-test"
+  sources = [
+    "test/main.cpp",
+    "test/ram-nand-ctl.cpp",
+    "test/ram-nand.cpp",
+  ]
+  include_dirs = [ "." ]
+  deps = [
+    ":common",
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/dev/lib/fake_ddk",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/nand/skip-block/BUILD.gn b/system/dev/nand/skip-block/BUILD.gn
new file mode 100644
index 0000000..d9e7ee7
--- /dev/null
+++ b/system/dev/nand/skip-block/BUILD.gn
@@ -0,0 +1,52 @@
+# 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.
+
+driver("skip-block") {
+  sources = [
+    "binding.c",
+    "skip-block.cpp",
+  ]
+  deps = [
+    ":common",
+    "$zx/system/banjo/ddk-protocol-badblock",
+    "$zx/system/banjo/ddk-protocol-nand",
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/fidl/fuchsia-hardware-skipblock:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+source_set("common") {
+  sources = [
+    "logical-to-physical-map.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+  ]
+}
+
+test("skip-block-test") {
+  output_name = "skip-block-test"
+  sources = [
+    "test/logical-to-physical-map-test.cpp",
+    "test/main.cpp",
+  ]
+  include_dirs = [ "." ]
+  deps = [
+    ":common",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/pci/BUILD.gn b/system/dev/pci/BUILD.gn
new file mode 100644
index 0000000..1e4057f
--- /dev/null
+++ b/system/dev/pci/BUILD.gn
@@ -0,0 +1,10 @@
+# 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.
+
+group("pci") {
+  deps = [
+    "amlogic-pcie",
+    "designware",
+  ]
+}
diff --git a/system/dev/pci/amlogic-pcie/BUILD.gn b/system/dev/pci/amlogic-pcie/BUILD.gn
new file mode 100644
index 0000000..a951664
--- /dev/null
+++ b/system/dev/pci/amlogic-pcie/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("amlogic-pcie") {
+  sources = [
+    "aml-pcie-clk.cpp",
+    "aml-pcie-device.cpp",
+    "aml-pcie.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/dev/pci/designware",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/pci/designware/BUILD.gn b/system/dev/pci/designware/BUILD.gn
new file mode 100644
index 0000000..36a9b9d
--- /dev/null
+++ b/system/dev/pci/designware/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+library("designware") {
+  sdk = "static"
+  sdk_headers = [
+    "dev/pci/designware/atu-cfg.h",
+    "dev/pci/designware/dw-pcie.h",
+  ]
+  sources = [
+    "dw-pcie.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/rtc/BUILD.gn b/system/dev/rtc/BUILD.gn
new file mode 100644
index 0000000..4e4bb51
--- /dev/null
+++ b/system/dev/rtc/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+group("rtc") {
+  deps = [
+    "fallback",
+    "nxp",
+    "pl031-rtc",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "intel-rtc" ]
+  }
+}
diff --git a/system/dev/rtc/fallback/BUILD.gn b/system/dev/rtc/fallback/BUILD.gn
new file mode 100644
index 0000000..ffbc028
--- /dev/null
+++ b/system/dev/rtc/fallback/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("fallback") {
+  sources = [
+    "fallback-rtc.c",
+    "rtc-impl.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/rtc",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/rtc/intel-rtc/BUILD.gn b/system/dev/rtc/intel-rtc/BUILD.gn
new file mode 100644
index 0000000..6f1b278
--- /dev/null
+++ b/system/dev/rtc/intel-rtc/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("intel-rtc") {
+  sources = [
+    "intel-rtc.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/rtc",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/rtc/nxp/BUILD.gn b/system/dev/rtc/nxp/BUILD.gn
new file mode 100644
index 0000000..3cabff5
--- /dev/null
+++ b/system/dev/rtc/nxp/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+driver("nxp") {
+  sources = [
+    "pcf8563-rtc.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/rtc",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/rtc/pl031-rtc/BUILD.gn b/system/dev/rtc/pl031-rtc/BUILD.gn
new file mode 100644
index 0000000..a043a86
--- /dev/null
+++ b/system/dev/rtc/pl031-rtc/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+driver("pl031-rtc") {
+  sources = [
+    "pl031-rtc.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/rtc",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/sample/BUILD.gn b/system/dev/sample/BUILD.gn
new file mode 100644
index 0000000..030ad11
--- /dev/null
+++ b/system/dev/sample/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+group("sample") {
+  deps = [
+    "fifo",
+  ]
+  if (false) {  # TODO: not to be included in most images
+    deps += [
+      "multi",
+      "null",
+      "number",
+      "ramdisk",
+      "zero",
+    ]
+  }
+}
diff --git a/system/dev/sample/fifo/BUILD.gn b/system/dev/sample/fifo/BUILD.gn
new file mode 100644
index 0000000..7424c92
--- /dev/null
+++ b/system/dev/sample/fifo/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+group("fifo") {
+  deps = [
+    ":demo-fifo",
+  ]
+}
+
+driver("demo-fifo") {
+  sources = [
+    "demo-fifo.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/sample/multi/BUILD.gn b/system/dev/sample/multi/BUILD.gn
new file mode 100644
index 0000000..b253519
--- /dev/null
+++ b/system/dev/sample/multi/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+driver("multi") {
+  sources = [
+    "demo-multi.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/sample/null/BUILD.gn b/system/dev/sample/null/BUILD.gn
new file mode 100644
index 0000000..6ba914b
--- /dev/null
+++ b/system/dev/sample/null/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+driver("null") {
+  sources = [
+    "demo-null.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/sample/number/BUILD.gn b/system/dev/sample/number/BUILD.gn
new file mode 100644
index 0000000..60db182
--- /dev/null
+++ b/system/dev/sample/number/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+driver("number") {
+  sources = [
+    "demo-number.c",
+  ]
+  deps = [
+    "$zx/system/fidl/zircon-sample:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/sample/ramdisk/BUILD.gn b/system/dev/sample/ramdisk/BUILD.gn
new file mode 100644
index 0000000..4b1cb6f
--- /dev/null
+++ b/system/dev/sample/ramdisk/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+driver("ramdisk") {
+  sources = [
+    "demo-ramdisk.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/sample/zero/BUILD.gn b/system/dev/sample/zero/BUILD.gn
new file mode 100644
index 0000000..9ff7c93
--- /dev/null
+++ b/system/dev/sample/zero/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+driver("zero") {
+  sources = [
+    "demo-zero.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/scpi/BUILD.gn b/system/dev/scpi/BUILD.gn
new file mode 100644
index 0000000..4568802
--- /dev/null
+++ b/system/dev/scpi/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+group("scpi") {
+  deps = [
+    "aml-scpi-s912",
+  ]
+}
diff --git a/system/dev/scpi/aml-scpi-s912/BUILD.gn b/system/dev/scpi/aml-scpi-s912/BUILD.gn
new file mode 100644
index 0000000..858a102
--- /dev/null
+++ b/system/dev/scpi/aml-scpi-s912/BUILD.gn
@@ -0,0 +1,50 @@
+# 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.
+
+group("aml-scpi-s912") {
+  deps = [
+    ":aml-scpi-s912.mailbox",
+    ":scpi",
+  ]
+}
+
+driver("aml-scpi-s912.mailbox") {
+  sources = [
+    "aml-mailbox.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-mailbox",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+driver("scpi") {
+  sources = [
+    "aml-scpi.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-mailbox",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/serial/BUILD.gn b/system/dev/serial/BUILD.gn
new file mode 100644
index 0000000..7b43529
--- /dev/null
+++ b/system/dev/serial/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+group("serial") {
+  deps = [
+    "aml-uart",
+    "ftdi",
+    "serial",
+  ]
+  if (current_cpu == "x64") {
+    deps += [ "intel-serialio" ]
+  }
+}
diff --git a/system/dev/serial/aml-uart/BUILD.gn b/system/dev/serial/aml-uart/BUILD.gn
new file mode 100644
index 0000000..6ceb7f3
--- /dev/null
+++ b/system/dev/serial/aml-uart/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("aml-uart") {
+  sources = [
+    "aml-uart.cpp",
+    "binding.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/banjo/ddk-protocol-serialimpl",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/serial/ftdi/BUILD.gn b/system/dev/serial/ftdi/BUILD.gn
new file mode 100644
index 0000000..2aafcc9
--- /dev/null
+++ b/system/dev/serial/ftdi/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("ftdi") {
+  sources = [
+    "ftdi.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/banjo/ddk-protocol-serialimpl",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/serial/intel-serialio/BUILD.gn b/system/dev/serial/intel-serialio/BUILD.gn
new file mode 100644
index 0000000..fba5c3d
--- /dev/null
+++ b/system/dev/serial/intel-serialio/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("intel-serialio") {
+  sources = [
+    "dma/dma.c",
+    "sdio/sdio.c",
+    "serialio.c",
+    "spi/spi.c",
+    "uart/uart.c",
+  ]
+  include_dirs = [ "intel-serialio-include" ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/serial/serial/BUILD.gn b/system/dev/serial/serial/BUILD.gn
new file mode 100644
index 0000000..ec48986
--- /dev/null
+++ b/system/dev/serial/serial/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+driver("serial") {
+  sources = [
+    "serial.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-serial",
+    "$zx/system/banjo/ddk-protocol-serialimpl",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/tee/BUILD.gn b/system/dev/tee/BUILD.gn
new file mode 100644
index 0000000..4ac1ab2
--- /dev/null
+++ b/system/dev/tee/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+group("tee") {
+  deps = [
+    "optee",
+  ]
+}
diff --git a/system/dev/tee/optee/BUILD.gn b/system/dev/tee/optee/BUILD.gn
new file mode 100644
index 0000000..6b0f3e1
--- /dev/null
+++ b/system/dev/tee/optee/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+driver("optee") {
+  sources = [
+    "binding.c",
+    "optee-client.cpp",
+    "optee-controller.cpp",
+    "optee-message.cpp",
+    "shared-memory.cpp",
+    "util.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/fidl/fuchsia-hardware-tee:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/region-alloc",
+    "$zx/system/ulib/tee-client-api",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/test/BUILD.gn b/system/dev/test/BUILD.gn
new file mode 100644
index 0000000..a2ad8d6
--- /dev/null
+++ b/system/dev/test/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+group("test") {
+  testonly = true
+  deps = [
+    "ddk-test",
+    "sysdev",
+  ]
+}
diff --git a/system/dev/test/ddk-test/BUILD.gn b/system/dev/test/ddk-test/BUILD.gn
new file mode 100644
index 0000000..d50402f
--- /dev/null
+++ b/system/dev/test/ddk-test/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+test_driver("ddk-test") {
+  sources = [
+    "ddk-test-binding.c",
+    "ddk-test.c",
+    "metadata-test.c",
+    "usb-request-test.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/fake-bti",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/test/mock-device/BUILD.gn b/system/dev/test/mock-device/BUILD.gn
new file mode 100644
index 0000000..2fe9dd8
--- /dev/null
+++ b/system/dev/test/mock-device/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+test_driver("mock-device") {
+  sources = [
+    "device.cpp",
+    "fidl.cpp",
+  ]
+  deps = [
+    ":fuchsia.device.mock:c",
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+fidl_library("fuchsia.device.mock") {
+  visibility = [ ":*" ]
+  testonly = true
+  sources = [
+    "mock-device.fidl",
+  ]
+}
diff --git a/system/dev/test/sysdev/BUILD.gn b/system/dev/test/sysdev/BUILD.gn
new file mode 100644
index 0000000..dc98a96
--- /dev/null
+++ b/system/dev/test/sysdev/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test_driver("sysdev") {
+  sources = [
+    "bind.c",
+    "sysdev.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/thermal/BUILD.gn b/system/dev/thermal/BUILD.gn
new file mode 100644
index 0000000..833cd41
--- /dev/null
+++ b/system/dev/thermal/BUILD.gn
@@ -0,0 +1,10 @@
+# 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.
+
+group("thermal") {
+  deps = [
+    "aml-thermal-s905d2g",
+    "aml-thermal-s912",
+  ]
+}
diff --git a/system/dev/thermal/aml-thermal-s905d2g/BUILD.gn b/system/dev/thermal/aml-thermal-s905d2g/BUILD.gn
new file mode 100644
index 0000000..725b0a0
--- /dev/null
+++ b/system/dev/thermal/aml-thermal-s905d2g/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+driver("aml-thermal-s905d2g") {
+  sources = [
+    "aml-cpufreq.cpp",
+    "aml-fclk-rates.c",
+    "aml-pwm.cpp",
+    "aml-thermal.c",
+    "aml-thermal.cpp",
+    "aml-tsensor.cpp",
+    "aml-voltage.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/thermal/aml-thermal-s912/BUILD.gn b/system/dev/thermal/aml-thermal-s912/BUILD.gn
new file mode 100644
index 0000000..bc8611f
--- /dev/null
+++ b/system/dev/thermal/aml-thermal-s912/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+driver("aml-thermal-s912") {
+  sources = [
+    "aml-thermal.c",
+    "aml-thermal.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-platform-bus",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/dev/lib/amlogic",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/thermal/mtk-thermal/BUILD.gn b/system/dev/thermal/mtk-thermal/BUILD.gn
new file mode 100644
index 0000000..5ee1c1f
--- /dev/null
+++ b/system/dev/thermal/mtk-thermal/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+driver("mtk-thermal") {
+  sources = [
+    "binding.c",
+    "mtk-thermal.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-scpi",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/BUILD.gn b/system/dev/usb/BUILD.gn
new file mode 100644
index 0000000..da05c65
--- /dev/null
+++ b/system/dev/usb/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+group("usb") {
+  testonly = true
+  deps = [
+    "dwc3",
+    "hikey-usb",
+    "usb-bus",
+    "usb-composite",
+    "usb-hub",
+    "usb-peripheral",
+    "usb-peripheral-test",
+    "usb-test",
+    "xhci",
+  ]
+}
diff --git a/system/dev/usb/dwc3/BUILD.gn b/system/dev/usb/dwc3/BUILD.gn
new file mode 100644
index 0000000..3ed5219
--- /dev/null
+++ b/system/dev/usb/dwc3/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+driver("dwc3") {
+  sources = [
+    "dwc3-commands.cpp",
+    "dwc3-endpoints.cpp",
+    "dwc3-ep0.cpp",
+    "dwc3-events.cpp",
+    "dwc3.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-dci",
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/hikey-usb/BUILD.gn b/system/dev/usb/hikey-usb/BUILD.gn
new file mode 100644
index 0000000..e1ddfb2
--- /dev/null
+++ b/system/dev/usb/hikey-usb/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("hikey-usb") {
+  sources = [
+    "hikey-usb.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/mt-musb-peripheral/BUILD.gn b/system/dev/usb/mt-musb-peripheral/BUILD.gn
new file mode 100644
index 0000000..77963bf
--- /dev/null
+++ b/system/dev/usb/mt-musb-peripheral/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+driver("mt-usb-peripheral") {
+  sources = [
+    "mt-usb.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-clk",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-dci",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/mt8167",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/usb-bus/BUILD.gn b/system/dev/usb/usb-bus/BUILD.gn
new file mode 100644
index 0000000..4c2d8d7
--- /dev/null
+++ b/system/dev/usb/usb-bus/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("usb-bus") {
+  sources = [
+    "usb-bus.c",
+    "usb-device.c",
+    "util.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-bus",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-hci",
+    "$zx/system/banjo/ddk-protocol-usb-hub",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-hardware-usb-device:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/utf_conversion",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/usb/usb-composite/BUILD.gn b/system/dev/usb/usb-composite/BUILD.gn
new file mode 100644
index 0000000..01375c8
--- /dev/null
+++ b/system/dev/usb/usb-composite/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+driver("usb-composite") {
+  sources = [
+    "usb-composite.c",
+    "usb-interface.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/usb/usb-dfu/BUILD.gn b/system/dev/usb/usb-dfu/BUILD.gn
new file mode 100644
index 0000000..2b0ec6e
--- /dev/null
+++ b/system/dev/usb/usb-dfu/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+driver("usb-dfu") {
+  sources = [
+    "usb-dfu.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-hardware-usb-test-fwloader:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/usb-hub/BUILD.gn b/system/dev/usb/usb-hub/BUILD.gn
new file mode 100644
index 0000000..23b83e8
--- /dev/null
+++ b/system/dev/usb/usb-hub/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+driver("usb-hub") {
+  sources = [
+    "usb-hub.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-bus",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-hub",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/dev/usb/usb-peripheral-test/BUILD.gn b/system/dev/usb/usb-peripheral-test/BUILD.gn
new file mode 100644
index 0000000..4c0dca8
--- /dev/null
+++ b/system/dev/usb/usb-peripheral-test/BUILD.gn
@@ -0,0 +1,32 @@
+# 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.
+
+test_driver("usb-peripheral-test") {
+  sources = [
+    "driver.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-function",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+if (current_os == "linux") {
+  test("usb-peripheral") {
+    sources = [
+      "test.cpp",
+    ]
+    deps = [
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/unittest",
+      "$zx/third_party/ulib/usbhost",
+    ]
+  }
+}
diff --git a/system/dev/usb/usb-peripheral/BUILD.gn b/system/dev/usb/usb-peripheral/BUILD.gn
new file mode 100644
index 0000000..88dff15
--- /dev/null
+++ b/system/dev/usb/usb-peripheral/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+driver("usb-peripheral") {
+  sources = [
+    "usb-peripheral.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-dci",
+    "$zx/system/banjo/ddk-protocol-usb-function",
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/fidl/fuchsia-hardware-usb-peripheral:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+
+  # Set default configuration here, rather than relying on usbctl to do it.
+  defines = [
+    "USB_DEVICE_VID=0x18D1",
+    "USB_DEVICE_PID=0xA020",
+    "USB_DEVICE_MANUFACTURER=\"Zircon\"",
+    "USB_DEVICE_PRODUCT=\"CDC-Ethernet\"",
+    "USB_DEVICE_SERIAL=\"0123456789ABCDEF\"",
+    "USB_DEVICE_FUNCTIONS=\"cdc\"",
+  ]
+}
diff --git a/system/dev/usb/usb-test/BUILD.gn b/system/dev/usb/usb-test/BUILD.gn
new file mode 100644
index 0000000..5004e07
--- /dev/null
+++ b/system/dev/usb/usb-test/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+group("usb-test") {
+  testonly = true
+  deps = [
+    "flash-programmer",
+    "fx3",
+    "usb-tester",
+  ]
+}
diff --git a/system/dev/usb/usb-test/flash-programmer/BUILD.gn b/system/dev/usb/usb-test/flash-programmer/BUILD.gn
new file mode 100644
index 0000000..1a1ce11
--- /dev/null
+++ b/system/dev/usb/usb-test/flash-programmer/BUILD.gn
@@ -0,0 +1,36 @@
+# 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("$zx/public/gn/firmware.gni")
+
+# TODO: test_driver?
+driver("flash-programmer") {
+  testonly = true
+  sources = [
+    "flash-programmer.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-hardware-usb-fwloader:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+  data_deps = [
+    ":fx3-firmware",
+  ]
+}
+
+firmware("fx3-firmware") {
+  sources = [
+    "$firmware_dir/fx3-boot/Fx3BootAppGcc.img",
+  ]
+}
diff --git a/system/dev/usb/usb-test/fx3/BUILD.gn b/system/dev/usb/usb-test/fx3/BUILD.gn
new file mode 100644
index 0000000..3445302
--- /dev/null
+++ b/system/dev/usb/usb-test/fx3/BUILD.gn
@@ -0,0 +1,32 @@
+# 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("$zx/public/gn/firmware.gni")
+
+driver("fx3") {  # TODO: test_driver?
+  testonly = true
+  sources = [
+    "fx3.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-hardware-usb-fwloader:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    ":firmware",
+  ]
+}
+
+firmware("firmware") {
+  sources = [
+    "$firmware_dir/fx3-flash/cyfxflashprog.img",
+    "$firmware_dir/usb-testing/fx3/fx3.img",
+  ]
+}
diff --git a/system/dev/usb/usb-test/usb-tester/BUILD.gn b/system/dev/usb/usb-test/usb-tester/BUILD.gn
new file mode 100644
index 0000000..e1d0a17
--- /dev/null
+++ b/system/dev/usb/usb-test/usb-tester/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+driver("usb-tester") {  # TODO: test_driver?
+  testonly = true
+  sources = [
+    "usb-tester.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-composite",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-hardware-usb-tester:c",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/usb-virtual-bus/BUILD.gn b/system/dev/usb/usb-virtual-bus/BUILD.gn
new file mode 100644
index 0000000..6ed40b7
--- /dev/null
+++ b/system/dev/usb/usb-virtual-bus/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+driver("usb-virtual-bus") {
+  sources = [
+    "usb-virtual-bus.cpp",
+    "usb-virtual-device.cpp",
+    "usb-virtual-host.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-bus",
+    "$zx/system/banjo/ddk-protocol-usb-dci",
+    "$zx/system/banjo/ddk-protocol-usb-function",
+    "$zx/system/banjo/ddk-protocol-usb-hci",
+    "$zx/system/banjo/ddk-protocol-usb-hub",
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-hardware-usb-virtual-bus:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/dev/usb/xhci/BUILD.gn b/system/dev/usb/xhci/BUILD.gn
new file mode 100644
index 0000000..2e5427d
--- /dev/null
+++ b/system/dev/usb/xhci/BUILD.gn
@@ -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.
+
+driver("xhci") {
+  sources = [
+    "usb-xhci.cpp",
+    "xdc-transfer.cpp",
+    "xdc.cpp",
+    "xhci-device-manager.cpp",
+    "xhci-root-hub.cpp",
+    "xhci-transfer-common.cpp",
+    "xhci-transfer.cpp",
+    "xhci-trb.cpp",
+    "xhci-util.cpp",
+    "xhci.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/banjo/ddk-protocol-usb",
+    "$zx/system/banjo/ddk-protocol-usb-bus",
+    "$zx/system/banjo/ddk-protocol-usb-hci",
+    "$zx/system/banjo/ddk-protocol-usb-hub",
+    "$zx/system/banjo/ddk-protocol-usb-request",
+    "$zx/system/dev/lib/usb",
+    "$zx/system/fidl/fuchsia-usb-debug:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/xdc-server-utils",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/fidl/fuchsia-cobalt/BUILD.gn b/system/fidl/fuchsia-cobalt/BUILD.gn
new file mode 100644
index 0000000..2f92eb3
--- /dev/null
+++ b/system/fidl/fuchsia-cobalt/BUILD.gn
@@ -0,0 +1,15 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-cobalt") {
+  sources = [
+    "cobalt.fidl",
+    "cobalt_controller.fidl",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-mem",
+  ]
+}
diff --git a/system/fidl/fuchsia-crash/BUILD.gn b/system/fidl/fuchsia-crash/BUILD.gn
new file mode 100644
index 0000000..84ea0cf
--- /dev/null
+++ b/system/fidl/fuchsia-crash/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-crash") {
+  sources = [
+    "crash.fidl",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-mem",
+  ]
+}
diff --git a/system/fidl/fuchsia-device-manager/BUILD.gn b/system/fidl/fuchsia-device-manager/BUILD.gn
new file mode 100644
index 0000000..bcc25d4
--- /dev/null
+++ b/system/fidl/fuchsia-device-manager/BUILD.gn
@@ -0,0 +1,12 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-device-manager") {
+  sources = [
+    "coordinator.fidl",
+    "dmctl.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-device-test/BUILD.gn b/system/fidl/fuchsia-device-test/BUILD.gn
new file mode 100644
index 0000000..ea5fd16
--- /dev/null
+++ b/system/fidl/fuchsia-device-test/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-device-test") {
+  sources = [
+    "test.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-device-vsock/BUILD.gn b/system/fidl/fuchsia-device-vsock/BUILD.gn
new file mode 100644
index 0000000..5d6c6fc
--- /dev/null
+++ b/system/fidl/fuchsia-device-vsock/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-device-vsock") {
+  sources = [
+    "vsock.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-backlight/BUILD.gn b/system/fidl/fuchsia-hardware-backlight/BUILD.gn
new file mode 100644
index 0000000..a807774
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-backlight/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-backlight") {
+  sources = [
+    "backlight.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-block/BUILD.gn b/system/fidl/fuchsia-hardware-block/BUILD.gn
new file mode 100644
index 0000000..5c947d6
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-block/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-block") {
+  sources = [
+    "ftl.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-camera/BUILD.gn b/system/fidl/fuchsia-hardware-camera/BUILD.gn
new file mode 100644
index 0000000..803d646
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-camera/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-camera") {
+  sources = [
+    "camera_sensor.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-display/BUILD.gn b/system/fidl/fuchsia-hardware-display/BUILD.gn
new file mode 100644
index 0000000..a5e7e0d
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-display/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-display") {
+  sources = [
+    "display-controller.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-ethernet/BUILD.gn b/system/fidl/fuchsia-hardware-ethernet/BUILD.gn
new file mode 100644
index 0000000..6fa4d4a
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-ethernet/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-ethernet") {
+  sources = [
+    "ethernet.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-gpu-clock/BUILD.gn b/system/fidl/fuchsia-hardware-gpu-clock/BUILD.gn
new file mode 100644
index 0000000..3d4ca07
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-gpu-clock/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-gpu-clock") {
+  sources = [
+    "clock.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-i2c/BUILD.gn b/system/fidl/fuchsia-hardware-i2c/BUILD.gn
new file mode 100644
index 0000000..68bf8e7
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-i2c/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-i2c") {
+  sources = [
+    "i2c.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-input/BUILD.gn b/system/fidl/fuchsia-hardware-input/BUILD.gn
new file mode 100644
index 0000000..3327302
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-input/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-input") {
+  sources = [
+    "input.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-nand/BUILD.gn b/system/fidl/fuchsia-hardware-nand/BUILD.gn
new file mode 100644
index 0000000..8785709
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-nand/BUILD.gn
@@ -0,0 +1,12 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-nand") {
+  sources = [
+    "nand.fidl",
+    "ram-nand.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-power/BUILD.gn b/system/fidl/fuchsia-hardware-power/BUILD.gn
new file mode 100644
index 0000000..ccf1084
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-power/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-power") {
+  sources = [
+    "power.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-rtc/BUILD.gn b/system/fidl/fuchsia-hardware-rtc/BUILD.gn
new file mode 100644
index 0000000..8325aac
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-rtc/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-rtc") {
+  sources = [
+    "rtc.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-skipblock/BUILD.gn b/system/fidl/fuchsia-hardware-skipblock/BUILD.gn
new file mode 100644
index 0000000..b2ab15d
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-skipblock/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-skipblock") {
+  sources = [
+    "skip-block.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-tee/BUILD.gn b/system/fidl/fuchsia-hardware-tee/BUILD.gn
new file mode 100644
index 0000000..ef55a90
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-tee/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-tee") {
+  sources = [
+    "tee.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-usb-device/BUILD.gn b/system/fidl/fuchsia-hardware-usb-device/BUILD.gn
new file mode 100644
index 0000000..e2c9b14
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-usb-device/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-usb-device") {
+  sources = [
+    "usb-device.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-usb-fwloader/BUILD.gn b/system/fidl/fuchsia-hardware-usb-fwloader/BUILD.gn
new file mode 100644
index 0000000..6d0c70f
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-usb-fwloader/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-usb-fwloader") {
+  sources = [
+    "usb-test-fwloader.fidl",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-mem",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-usb-peripheral/BUILD.gn b/system/fidl/fuchsia-hardware-usb-peripheral/BUILD.gn
new file mode 100644
index 0000000..9f68fe3
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-usb-peripheral/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-usb-peripheral") {
+  sources = [
+    "usb-peripheral.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-usb-tester/BUILD.gn b/system/fidl/fuchsia-hardware-usb-tester/BUILD.gn
new file mode 100644
index 0000000..bd5c700
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-usb-tester/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-usb-tester") {
+  sources = [
+    "usb-tester.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-usb-virtual-bus/BUILD.gn b/system/fidl/fuchsia-hardware-usb-virtual-bus/BUILD.gn
new file mode 100644
index 0000000..f1819e6
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-usb-virtual-bus/BUILD.gn
@@ -0,0 +1,20 @@
+# 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("$zx/public/gn/fidl.gni")
+
+# TODO: rename the dir
+if (current_toolchain != default_toolchain) {
+  group("c") {
+    public_deps = [
+      ":fuchsia.usb.virtualbus.c",
+    ]
+  }
+}
+
+fidl_library("fuchsia.usb.virtualbus") {
+  sources = [
+    "usb-virtual-bus.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-hardware-vsock/BUILD.gn b/system/fidl/fuchsia-hardware-vsock/BUILD.gn
new file mode 100644
index 0000000..04ff89c
--- /dev/null
+++ b/system/fidl/fuchsia-hardware-vsock/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-hardware-vsock") {
+  sources = [
+    "vsock.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-i2c/BUILD.gn b/system/fidl/fuchsia-i2c/BUILD.gn
new file mode 100644
index 0000000..99d4f3f
--- /dev/null
+++ b/system/fidl/fuchsia-i2c/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-i2c") {
+  sources = [
+    "i2c.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-inspect/BUILD.gn b/system/fidl/fuchsia-inspect/BUILD.gn
new file mode 100644
index 0000000..7cd06fd
--- /dev/null
+++ b/system/fidl/fuchsia-inspect/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-inspect") {
+  sources = [
+    "inspect.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-io/BUILD.gn b/system/fidl/fuchsia-io/BUILD.gn
new file mode 100644
index 0000000..a93a454
--- /dev/null
+++ b/system/fidl/fuchsia-io/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-io") {
+  sources = [
+    "io.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-ldsvc/BUILD.gn b/system/fidl/fuchsia-ldsvc/BUILD.gn
new file mode 100644
index 0000000..0542554
--- /dev/null
+++ b/system/fidl/fuchsia-ldsvc/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-ldsvc") {
+  sources = [
+    "ldsvc.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-logger/BUILD.gn b/system/fidl/fuchsia-logger/BUILD.gn
new file mode 100644
index 0000000..d5a45fe
--- /dev/null
+++ b/system/fidl/fuchsia-logger/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-logger") {
+  sources = [
+    "logger.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-mem/BUILD.gn b/system/fidl/fuchsia-mem/BUILD.gn
new file mode 100644
index 0000000..f0b210f
--- /dev/null
+++ b/system/fidl/fuchsia-mem/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-mem") {
+  sources = [
+    "buffer.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-minfs/BUILD.gn b/system/fidl/fuchsia-minfs/BUILD.gn
new file mode 100644
index 0000000..309ed60
--- /dev/null
+++ b/system/fidl/fuchsia-minfs/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-minfs") {
+  sources = [
+    "minfs.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-nand/BUILD.gn b/system/fidl/fuchsia-nand/BUILD.gn
new file mode 100644
index 0000000..0a53aab
--- /dev/null
+++ b/system/fidl/fuchsia-nand/BUILD.gn
@@ -0,0 +1,14 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-nand") {
+  sources = [
+    "broker.fidl",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-nand",
+  ]
+}
diff --git a/system/fidl/fuchsia-net-stack/BUILD.gn b/system/fidl/fuchsia-net-stack/BUILD.gn
new file mode 100644
index 0000000..ca6f3c0
--- /dev/null
+++ b/system/fidl/fuchsia-net-stack/BUILD.gn
@@ -0,0 +1,15 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-net-stack") {
+  sources = [
+    "stack.fidl",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-ethernet",
+    "$zx/system/fidl/fuchsia-net",
+  ]
+}
diff --git a/system/fidl/fuchsia-net/BUILD.gn b/system/fidl/fuchsia-net/BUILD.gn
new file mode 100644
index 0000000..03f1d2c
--- /dev/null
+++ b/system/fidl/fuchsia-net/BUILD.gn
@@ -0,0 +1,13 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-net") {
+  sources = [
+    "connectivity.fidl",
+    "net.fidl",
+    "socket.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-power/BUILD.gn b/system/fidl/fuchsia-power/BUILD.gn
new file mode 100644
index 0000000..5087d0d
--- /dev/null
+++ b/system/fidl/fuchsia-power/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-power") {
+  sources = [
+    "power.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-process/BUILD.gn b/system/fidl/fuchsia-process/BUILD.gn
new file mode 100644
index 0000000..3b4ff11
--- /dev/null
+++ b/system/fidl/fuchsia-process/BUILD.gn
@@ -0,0 +1,16 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-process") {
+  sources = [
+    "launcher.fidl",
+    "resolver.fidl",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io",
+    "$zx/system/fidl/fuchsia-ldsvc",
+  ]
+}
diff --git a/system/fidl/fuchsia-sysinfo/BUILD.gn b/system/fidl/fuchsia-sysinfo/BUILD.gn
new file mode 100644
index 0000000..aa35ffc
--- /dev/null
+++ b/system/fidl/fuchsia-sysinfo/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-sysinfo") {
+  sources = [
+    "sysinfo.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-sysmem/BUILD.gn b/system/fidl/fuchsia-sysmem/BUILD.gn
new file mode 100644
index 0000000..116d432
--- /dev/null
+++ b/system/fidl/fuchsia-sysmem/BUILD.gn
@@ -0,0 +1,15 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-sysmem") {
+  sources = [
+    "allocator.fidl",
+    "collections.fidl",
+    "formats.fidl",
+    "image_formats.fidl",
+    "usages.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-tracelink/BUILD.gn b/system/fidl/fuchsia-tracelink/BUILD.gn
new file mode 100644
index 0000000..5f2cbb7
--- /dev/null
+++ b/system/fidl/fuchsia-tracelink/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-tracelink") {
+  sources = [
+    "tracelink.fidl",
+  ]
+}
diff --git a/system/fidl/fuchsia-usb-debug/BUILD.gn b/system/fidl/fuchsia-usb-debug/BUILD.gn
new file mode 100644
index 0000000..2910a37
--- /dev/null
+++ b/system/fidl/fuchsia-usb-debug/BUILD.gn
@@ -0,0 +1,11 @@
+# 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("$zx/public/gn/fidl.gni")
+
+fidl_library("fuchsia-usb-debug") {
+  sources = [
+    "usb-debug.fidl",
+  ]
+}
diff --git a/system/host/BUILD.gn b/system/host/BUILD.gn
index bdcb7f7..db5ea18 100644
--- a/system/host/BUILD.gn
+++ b/system/host/BUILD.gn
@@ -10,11 +10,14 @@
   deps = [
     "$zx/third_party/uapp/mkfs-msdosfs",
     "banjo",
+    "blobfs",
     "bootserver",
     "fidl:tools",
+    "fvm",
     "kernel-buildsig",
     "loglistener",
     "merkleroot",
+    "minfs",
     "netprotocol",
     "runtests",
     "xdc-server",
diff --git a/system/host/abigen/BUILD.gn b/system/host/abigen/BUILD.gn
new file mode 100644
index 0000000..d98fc4b
--- /dev/null
+++ b/system/host/abigen/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+host_tool("abigen") {
+  sources = [
+    "abigen.cpp",
+    "abigen_generator.cpp",
+    "generator.cpp",
+    "header_generator.cpp",
+    "json_generator.cpp",
+    "kernel_wrapper_generator.cpp",
+    "parser/parser.cpp",
+    "rust_binding_generator.cpp",
+    "syscall_parser.cpp",
+    "types.cpp",
+    "vdso_wrapper_generator.cpp",
+  ]
+}
diff --git a/system/host/blobfs/BUILD.gn b/system/host/blobfs/BUILD.gn
new file mode 100644
index 0000000..21a9e5e
--- /dev/null
+++ b/system/host/blobfs/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+host_tool("blobfs") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/blobfs",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/fs-host",
+    "$zx/third_party/ulib/lz4",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/host/fvm/BUILD.gn b/system/host/fvm/BUILD.gn
new file mode 100644
index 0000000..2a06c11
--- /dev/null
+++ b/system/host/fvm/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+host_tool("fvm") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fvm-host",
+  ]
+}
diff --git a/system/host/minfs/BUILD.gn b/system/host/minfs/BUILD.gn
new file mode 100644
index 0000000..13db44f
--- /dev/null
+++ b/system/host/minfs/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+host_tool("minfs") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fs-host",
+    "$zx/system/ulib/minfs",
+  ]
+}
diff --git a/system/host/mkkdtb/mkkdtb.c b/system/host/mkkdtb/mkkdtb.c
deleted file mode 100644
index ee24de2..0000000
--- a/system/host/mkkdtb/mkkdtb.c
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2017 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.
-
-/* mkkdtb - packages kernel file and dtb in kdtb format, required by some
-            bootloaders instead of just appending dtb to end of kernel.
-*/
-
-#include <assert.h>
-#include <ctype.h>
-#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-typedef struct {
-    char magic[4];
-    uint32_t kern_size;
-    uint32_t dtb_size;
-} kdtb_header_t;
-
-int print_usage(void) {
-    printf("mkkdtb kernfile dtbfile outfile\n");
-    return 0;
-}
-
-int main(int argc, char** argv) {
-
-    int retval = 0;
-
-    uint8_t* kern_buffer = NULL;
-    uint8_t* dtb_buffer = NULL;
-
-    FILE* dtb_fd = NULL;
-    FILE* out_fd = NULL;
-
-    kdtb_header_t kheader = {"KDTB", 0, 0};
-
-    if (argc < 4) {
-        print_usage();
-        return -1;
-    }
-
-    FILE* kernel_fd = fopen(argv[1], "r");
-    if (!kernel_fd) {
-        fprintf(stderr, "Kernel file not found\n");
-        retval = -1;
-        goto fail;
-    }
-
-    dtb_fd = fopen(argv[2], "r");
-    if (!dtb_fd) {
-        fprintf(stderr, "DTB file not found\n");
-        retval = -1;
-        goto fail;
-    }
-
-    out_fd = fopen(argv[3], "w");
-    if (!out_fd) {
-        fprintf(stderr, "Can't open output file\n");
-        retval = -1;
-        goto fail;
-    }
-
-    fseek(kernel_fd, 0, SEEK_END);
-    kheader.kern_size = ftell(kernel_fd);
-    fseek(kernel_fd, 0, SEEK_SET);
-
-    fseek(dtb_fd, 0, SEEK_END);
-    kheader.dtb_size = ftell(dtb_fd);
-    fseek(dtb_fd, 0, SEEK_SET);
-
-    kern_buffer = malloc(kheader.kern_size);
-    if (!kern_buffer) {
-        retval = -1;
-        goto fail;
-    }
-    if (fread(kern_buffer, kheader.kern_size, 1, kernel_fd) != 1) {
-        fprintf(stderr, "kernel read error\n");
-        retval = -1;
-        goto fail;
-    }
-
-    dtb_buffer = malloc(kheader.dtb_size);
-    if (!dtb_buffer) {
-        retval = -1;
-        goto fail;
-    }
-    if (fread(dtb_buffer, kheader.dtb_size, 1, dtb_fd) != 1) {
-        fprintf(stderr, "dtb read error\n");
-        retval = -1;
-        goto fail;
-    }
-
-    fwrite(&kheader, sizeof(kheader), 1, out_fd);
-    fwrite(kern_buffer, sizeof(uint8_t), kheader.kern_size, out_fd);
-    fwrite(dtb_buffer, sizeof(uint8_t), kheader.dtb_size, out_fd);
-
-fail:
-    if (kernel_fd)
-        fclose(kernel_fd);
-    if (dtb_fd)
-        fclose(dtb_fd);
-    if (out_fd)
-        fclose(out_fd);
-    if (kern_buffer)
-        free(kern_buffer);
-    if (dtb_buffer)
-        free(dtb_buffer);
-    return retval;
-}
\ No newline at end of file
diff --git a/system/host/mkkdtb/rules.mk b/system/host/mkkdtb/rules.mk
deleted file mode 100644
index 4afd661..0000000
--- a/system/host/mkkdtb/rules.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2017 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.
-
-LOCAL_DIR := $(GET_LOCAL_DIR)
-
-MODULE := $(LOCAL_DIR)
-
-MODULE_TYPE := hostapp
-
-MODULE_SRCS += \
-    $(LOCAL_DIR)/mkkdtb.c \
-
-include make/module.mk
diff --git a/system/uapp/BUILD.gn b/system/uapp/BUILD.gn
new file mode 100644
index 0000000..3258c0f
--- /dev/null
+++ b/system/uapp/BUILD.gn
@@ -0,0 +1,83 @@
+# 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.
+
+group("uapp") {
+  testonly = true
+  deps = [
+    "$zx/system/ulib/driver-info:driverinfo",
+    "aslr-analysis",
+    "audio",
+    "audio-codec",
+    "backlight",
+    "banjo-dummy",
+    "biotime",
+    "blktest",
+    "blobfs",
+    "channel-perf",
+    "clock",
+    "clock:clkctl",
+    "crasher",
+    "dd",
+    "df",
+    "disk-pave",
+    "display-test",
+    "dlog",
+    "driverctl",
+    "ethtool",
+    "fs-fsck",
+    "fs-mkfs",
+    "fs-mount",
+    "fs-umount",
+    "fuzz",
+    "fvm-check",
+    "gfxfractal",
+    "gfxlatency",
+    "gfxtest",
+    "gpt",
+    "hid",
+    "hidsensor",
+    "hidtouch",
+    "i2c",
+    "ihda",
+    "iochk",
+    "iotime",
+    "kstress",
+    "loadgen",
+    "lsblk",
+    "lsdev",
+    "lspwr",
+    "lsusb",
+    "lz4",
+    "midiecho",
+    "minfs",
+    "namespace",
+    "nand-loader",
+    "nand-util",
+    "netdump",
+    "ping",
+    "psutils",
+    "rng-trials",
+    "run-vc",
+    "runtests",
+    "serial-test",
+    "spawn",
+    "storage-metrics",
+    "strerror",
+    "suspendtest",
+    "sysconfig",
+    "system-version",
+    "tee-test",
+    "thread-depth",
+    "thread-stress",
+    "trace-benchmark",
+    "trace-example",
+    "traceme",
+    "unbind",
+    "usb-fwloader",
+    "usbctl",
+    "waitfor",
+    "watch",
+    "xdc-test",
+  ]
+}
diff --git a/system/uapp/aslr-analysis/BUILD.gn b/system/uapp/aslr-analysis/BUILD.gn
new file mode 100644
index 0000000..5ebbdd7
--- /dev/null
+++ b/system/uapp/aslr-analysis/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("aslr-analysis") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/audio-codec/BUILD.gn b/system/uapp/audio-codec/BUILD.gn
new file mode 100644
index 0000000..a6db85e
--- /dev/null
+++ b/system/uapp/audio-codec/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("audio-codec") {
+  sources = [
+    "audio-codec.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/audio/BUILD.gn b/system/uapp/audio/BUILD.gn
new file mode 100644
index 0000000..dfcf897
--- /dev/null
+++ b/system/uapp/audio/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+executable("audio") {
+  sources = [
+    "audio.cpp",
+    "sine-source.cpp",
+    "wav-common.cpp",
+    "wav-sink.cpp",
+    "wav-source.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/audio-utils",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/backlight/BUILD.gn b/system/uapp/backlight/BUILD.gn
new file mode 100644
index 0000000..71c0c83
--- /dev/null
+++ b/system/uapp/backlight/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("backlight") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-backlight:c",
+    "$zx/system/ulib/fdio",
+  ]
+}
diff --git a/system/uapp/banjo-dummy/BUILD.gn b/system/uapp/banjo-dummy/BUILD.gn
new file mode 100644
index 0000000..949e4a2
--- /dev/null
+++ b/system/uapp/banjo-dummy/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("banjo-dummy") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-bt-gattsvc",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/biotime/BUILD.gn b/system/uapp/biotime/BUILD.gn
new file mode 100644
index 0000000..b6d2f66
--- /dev/null
+++ b/system/uapp/biotime/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+executable("biotime") {
+  testonly = true
+  sources = [
+    "biotime.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/blktest/BUILD.gn b/system/uapp/blktest/BUILD.gn
new file mode 100644
index 0000000..32d96a0
--- /dev/null
+++ b/system/uapp/blktest/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("blktest") {
+  testonly = true
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/blktest",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/uapp/blobfs/BUILD.gn b/system/uapp/blobfs/BUILD.gn
new file mode 100644
index 0000000..9cba759
--- /dev/null
+++ b/system/uapp/blobfs/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+executable("blobfs") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/blobfs",
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/lz4",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/uapp/channel-perf/BUILD.gn b/system/uapp/channel-perf/BUILD.gn
new file mode 100644
index 0000000..af978c8
--- /dev/null
+++ b/system/uapp/channel-perf/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("channel-perf") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/clock/BUILD.gn b/system/uapp/clock/BUILD.gn
new file mode 100644
index 0000000..45eccfe
--- /dev/null
+++ b/system/uapp/clock/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+executable("clock") {
+  sources = [
+    "clock.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("clkctl") {
+  sources = [
+    "clkctl.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/crasher/BUILD.gn b/system/uapp/crasher/BUILD.gn
new file mode 100644
index 0000000..d9edc02
--- /dev/null
+++ b/system/uapp/crasher/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("crasher") {
+  sources = [
+    "cpp_specific.cpp",
+    "crasher.c",
+  ]
+  cflags = [ "-fstack-protector-all" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/dd/BUILD.gn b/system/uapp/dd/BUILD.gn
new file mode 100644
index 0000000..be68c59
--- /dev/null
+++ b/system/uapp/dd/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("dd") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/df/BUILD.gn b/system/uapp/df/BUILD.gn
new file mode 100644
index 0000000..936dada
--- /dev/null
+++ b/system/uapp/df/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+executable("df") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/uapp/disk-pave/BUILD.gn b/system/uapp/disk-pave/BUILD.gn
new file mode 100644
index 0000000..c21cdfc
--- /dev/null
+++ b/system/uapp/disk-pave/BUILD.gn
@@ -0,0 +1,77 @@
+# 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.
+
+group("disk-pave") {
+  deps = [
+    ":install-disk-image",
+  ]
+}
+
+executable("install-disk-image") {
+  sources = [
+    "disk-pave.cpp",
+    "pave-lib.cpp",
+  ]
+  deps = [
+    ":pave-utils",
+    "$zx/system/fidl/fuchsia-hardware-block:c",
+    "$zx/system/fidl/fuchsia-hardware-skipblock:c",
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/crypto",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/zxcrypt",
+    "$zx/third_party/ulib/cksum",
+    "$zx/third_party/ulib/lz4",
+  ]
+}
+
+source_set("pave-utils") {
+  sources = [
+    "device-partitioner.cpp",
+    "pave-utils.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-block:c",
+    "$zx/system/fidl/fuchsia-hardware-skipblock:c",
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/chromeos-disk-setup",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxcrypt",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
+
+test("install-disk-image-test") {
+  output_name = "install-disk-image-test"
+  sources = [
+    "test/device-partitioner-test.cpp",
+    "test/main.cpp",
+  ]
+  include_dirs = [ "." ]
+  deps = [
+    ":pave-utils",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/uapp/display-test/BUILD.gn b/system/uapp/display-test/BUILD.gn
new file mode 100644
index 0000000..5101b63
--- /dev/null
+++ b/system/uapp/display-test/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+executable("display-test") {
+  sources = [
+    "display.cpp",
+    "image.cpp",
+    "main.cpp",
+    "virtual-layer.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-display:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/dlog/BUILD.gn b/system/uapp/dlog/BUILD.gn
new file mode 100644
index 0000000..efc2e6d
--- /dev/null
+++ b/system/uapp/dlog/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("dlog") {
+  sources = [
+    "dlog.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/driverctl/BUILD.gn b/system/uapp/driverctl/BUILD.gn
new file mode 100644
index 0000000..efcb479
--- /dev/null
+++ b/system/uapp/driverctl/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("driverctl") {
+  sources = [
+    "driverctl.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk:headers",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/ethtool/BUILD.gn b/system/uapp/ethtool/BUILD.gn
new file mode 100644
index 0000000..f589f6e
--- /dev/null
+++ b/system/uapp/ethtool/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("ethtool") {
+  sources = [
+    "ethtool.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-ethernet:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/inet6",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/fs-fsck/BUILD.gn b/system/uapp/fs-fsck/BUILD.gn
new file mode 100644
index 0000000..40af1c8
--- /dev/null
+++ b/system/uapp/fs-fsck/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+group("fs-fsck") {
+  deps = [
+    ":fsck",
+  ]
+}
+
+executable("fsck") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/fs-mkfs/BUILD.gn b/system/uapp/fs-mkfs/BUILD.gn
new file mode 100644
index 0000000..777bfee
--- /dev/null
+++ b/system/uapp/fs-mkfs/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+group("fs-mkfs") {
+  deps = [
+    ":mkfs",
+  ]
+}
+
+executable("mkfs") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/fs-mount/BUILD.gn b/system/uapp/fs-mount/BUILD.gn
new file mode 100644
index 0000000..139608a
--- /dev/null
+++ b/system/uapp/fs-mount/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+group("fs-mount") {
+  deps = [
+    ":mount",
+  ]
+}
+
+executable("mount") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/fs-umount/BUILD.gn b/system/uapp/fs-umount/BUILD.gn
new file mode 100644
index 0000000..2744496
--- /dev/null
+++ b/system/uapp/fs-umount/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+group("fs-umount") {
+  deps = [
+    ":umount",
+  ]
+}
+
+executable("umount") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/fuzz/BUILD.gn b/system/uapp/fuzz/BUILD.gn
new file mode 100644
index 0000000..cab528c
--- /dev/null
+++ b/system/uapp/fuzz/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+executable("fuzz") {
+  sources = [
+    "fuzz.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fuzz-utils",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/fvm-check/BUILD.gn b/system/uapp/fvm-check/BUILD.gn
new file mode 100644
index 0000000..d3aae7a
--- /dev/null
+++ b/system/uapp/fvm-check/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+executable("fvm-check") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/cksum",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/uapp/gfxfractal/BUILD.gn b/system/uapp/gfxfractal/BUILD.gn
new file mode 100644
index 0000000..4f31601
--- /dev/null
+++ b/system/uapp/gfxfractal/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("gfxfractal") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/framebuffer",
+    "$zx/system/ulib/gfx",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/gfxlatency/BUILD.gn b/system/uapp/gfxlatency/BUILD.gn
new file mode 100644
index 0000000..2814aae
--- /dev/null
+++ b/system/uapp/gfxlatency/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+executable("gfxlatency") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-display:c",
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gfx",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/gfxtest/BUILD.gn b/system/uapp/gfxtest/BUILD.gn
new file mode 100644
index 0000000..8c98e43
--- /dev/null
+++ b/system/uapp/gfxtest/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("gfxtest") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/framebuffer",
+    "$zx/system/ulib/gfx",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/gpt/BUILD.gn b/system/uapp/gpt/BUILD.gn
new file mode 100644
index 0000000..6df24cc
--- /dev/null
+++ b/system/uapp/gpt/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+executable("gpt") {
+  sources = [
+    "gpt.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/uapp/hid/BUILD.gn b/system/uapp/hid/BUILD.gn
new file mode 100644
index 0000000..233501a
--- /dev/null
+++ b/system/uapp/hid/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+executable("hid") {
+  sources = [
+    "main.cpp",
+    "report.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/hid-parser",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/hidsensor/BUILD.gn b/system/uapp/hidsensor/BUILD.gn
new file mode 100644
index 0000000..3358695
--- /dev/null
+++ b/system/uapp/hidsensor/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("hidsensor") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/hidtouch/BUILD.gn b/system/uapp/hidtouch/BUILD.gn
new file mode 100644
index 0000000..6f6d7a6
--- /dev/null
+++ b/system/uapp/hidtouch/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+executable("hidtouch") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-display:c",
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/framebuffer",
+    "$zx/system/ulib/hid",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/i2c/BUILD.gn b/system/uapp/i2c/BUILD.gn
new file mode 100644
index 0000000..e58f666
--- /dev/null
+++ b/system/uapp/i2c/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("i2c") {
+  sources = [
+    "i2c.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-i2c:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/ihda/BUILD.gn b/system/uapp/ihda/BUILD.gn
new file mode 100644
index 0000000..e4e3ee4
--- /dev/null
+++ b/system/uapp/ihda/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+executable("ihda") {
+  sources = [
+    "ihda.cpp",
+    "intel_hda_codec.cpp",
+    "intel_hda_controller.cpp",
+    "intel_hda_device.cpp",
+    "print_codec_state.cpp",
+    "zircon_device.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/intel-hda",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/iochk/BUILD.gn b/system/uapp/iochk/BUILD.gn
new file mode 100644
index 0000000..dad298a
--- /dev/null
+++ b/system/uapp/iochk/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+executable("iochk") {
+  sources = [
+    "iochk.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-skipblock:c",
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/iotime/BUILD.gn b/system/uapp/iotime/BUILD.gn
new file mode 100644
index 0000000..92e0d22
--- /dev/null
+++ b/system/uapp/iotime/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("iotime") {
+  sources = [
+    "iotime.c",
+  ]
+  deps = [
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/kstress/BUILD.gn b/system/uapp/kstress/BUILD.gn
new file mode 100644
index 0000000..4f69304
--- /dev/null
+++ b/system/uapp/kstress/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+executable("kstress") {
+  sources = [
+    "main.cpp",
+    "stress_test.cpp",
+    "vmstress.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/loadgen/BUILD.gn b/system/uapp/loadgen/BUILD.gn
new file mode 100644
index 0000000..42fb87c
--- /dev/null
+++ b/system/uapp/loadgen/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("loadgen") {
+  sources = [
+    "loadgen.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/lsblk/BUILD.gn b/system/uapp/lsblk/BUILD.gn
new file mode 100644
index 0000000..1464d0a
--- /dev/null
+++ b/system/uapp/lsblk/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+executable("lsblk") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-skipblock:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/uapp/lsdev/BUILD.gn b/system/uapp/lsdev/BUILD.gn
new file mode 100644
index 0000000..291802d
--- /dev/null
+++ b/system/uapp/lsdev/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("lsdev") {
+  sources = [
+    "lsdev.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/lspwr/BUILD.gn b/system/uapp/lspwr/BUILD.gn
new file mode 100644
index 0000000..f4d865b
--- /dev/null
+++ b/system/uapp/lspwr/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("lspwr") {
+  sources = [
+    "lspwr.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-power:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/lsusb/BUILD.gn b/system/uapp/lsusb/BUILD.gn
new file mode 100644
index 0000000..5f9a877b
--- /dev/null
+++ b/system/uapp/lsusb/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("lsusb") {
+  sources = [
+    "lsusb.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-usb-device:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/lz4/BUILD.gn b/system/uapp/lz4/BUILD.gn
new file mode 100644
index 0000000..8035247
--- /dev/null
+++ b/system/uapp/lz4/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("lz4") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/lz4",
+  ]
+}
diff --git a/system/uapp/midiecho/BUILD.gn b/system/uapp/midiecho/BUILD.gn
new file mode 100644
index 0000000..fa70c0a
--- /dev/null
+++ b/system/uapp/midiecho/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("midiecho") {
+  sources = [
+    "midiecho.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/minfs/BUILD.gn b/system/uapp/minfs/BUILD.gn
new file mode 100644
index 0000000..713320d
--- /dev/null
+++ b/system/uapp/minfs/BUILD.gn
@@ -0,0 +1,32 @@
+# 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.
+
+executable("minfs") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-minfs:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/minfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/namespace/BUILD.gn b/system/uapp/namespace/BUILD.gn
new file mode 100644
index 0000000..197384b
--- /dev/null
+++ b/system/uapp/namespace/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("namespace") {
+  sources = [
+    "namespace.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/nand-loader/BUILD.gn b/system/uapp/nand-loader/BUILD.gn
new file mode 100644
index 0000000..00cb691
--- /dev/null
+++ b/system/uapp/nand-loader/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+executable("nand-loader") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/nand-util/BUILD.gn b/system/uapp/nand-util/BUILD.gn
new file mode 100644
index 0000000..47d5c56
--- /dev/null
+++ b/system/uapp/nand-util/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+executable("nand-util") {
+  sources = [
+    "aml.cpp",
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/fidl/fuchsia-nand:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/uapp/netdump/BUILD.gn b/system/uapp/netdump/BUILD.gn
new file mode 100644
index 0000000..a558527
--- /dev/null
+++ b/system/uapp/netdump/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("netdump") {
+  sources = [
+    "netdump.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-ethernet:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/inet6",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/ping/BUILD.gn b/system/uapp/ping/BUILD.gn
new file mode 100644
index 0000000..652d8ed
--- /dev/null
+++ b/system/uapp/ping/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("ping") {
+  sources = [
+    "ping.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/inet6",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/psutils/BUILD.gn b/system/uapp/psutils/BUILD.gn
new file mode 100644
index 0000000..76bb78c
--- /dev/null
+++ b/system/uapp/psutils/BUILD.gn
@@ -0,0 +1,168 @@
+# 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.
+
+group("psutils") {
+  deps = [
+    ":kill",
+    ":killall",
+    ":kstats",
+    ":memgraph",
+    ":ps",
+    ":signal",
+    ":threads",
+    ":top",
+    ":vmaps",
+    ":vmos",
+  ]
+}
+
+executable("ps") {
+  sources = [
+    "ps.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("top") {
+  sources = [
+    "top.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("kill") {
+  sources = [
+    "kill.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("killall") {
+  sources = [
+    "killall.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("vmaps") {
+  sources = [
+    "vmaps.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("vmos") {
+  sources = [
+    "vmo-utils.c",
+    "vmos.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("memgraph") {
+  sources = [
+    "memgraph.cpp",
+    "resources.c",
+    "vmo-utils.c",
+  ]
+  include_dirs = [ target_gen_dir ]
+  deps = [
+    ":gen-memgraph-schema",
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+# Generate an include file that contains the schema JSON.
+action("gen-memgraph-schema") {
+  outputs = [
+    "$target_gen_dir/memgraph-schema.h",
+  ]
+  sources = [
+    "memgraph-schema.json",
+  ]
+  script = "gen-memgraph-schema-header.sh"
+  args = rebase_path(outputs, root_build_dir) +
+         rebase_path(sources, root_build_dir)
+}
+
+executable("kstats") {
+  sources = [
+    "kstats.c",
+    "resources.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("threads") {
+  sources = [
+    "threads.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/inspector",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/backtrace",
+    "$zx/third_party/ulib/ngunwind",
+  ]
+}
+
+executable("signal") {
+  sources = [
+    "signal.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/psutils/gen-memgraph-schema-header.sh b/system/uapp/psutils/gen-memgraph-schema-header.sh
new file mode 100755
index 0000000..f424e45
--- /dev/null
+++ b/system/uapp/psutils/gen-memgraph-schema-header.sh
@@ -0,0 +1,14 @@
+#!/bin/sh -e
+# 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.
+
+exec > "$1"
+shift
+
+echo '// DO NOT EDIT THIS FILE'
+echo "// Generated from $0 $*"
+echo '#pragma once'
+echo 'static const char kMemgraphSchema[] = R":JSON:('
+cat "$@"
+echo '):JSON:";'
diff --git a/system/uapp/rng-trials/BUILD.gn b/system/uapp/rng-trials/BUILD.gn
new file mode 100644
index 0000000..8ad8268
--- /dev/null
+++ b/system/uapp/rng-trials/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("rng-trials") {
+  sources = [
+    "rng-trials.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/run-vc/BUILD.gn b/system/uapp/run-vc/BUILD.gn
new file mode 100644
index 0000000..7de523b
--- /dev/null
+++ b/system/uapp/run-vc/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("run-vc") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/runtests/BUILD.gn b/system/uapp/runtests/BUILD.gn
new file mode 100644
index 0000000..3b5dd1d
--- /dev/null
+++ b/system/uapp/runtests/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+executable("runtests") {
+  testonly = true
+  sources = [
+    "runtests.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-logger:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/loader-service",
+    "$zx/system/ulib/runtests-utils",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/serial-test/BUILD.gn b/system/uapp/serial-test/BUILD.gn
new file mode 100644
index 0000000..8772a32
--- /dev/null
+++ b/system/uapp/serial-test/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("serial-test") {
+  sources = [
+    "serial-test.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/spawn/BUILD.gn b/system/uapp/spawn/BUILD.gn
new file mode 100644
index 0000000..544c0dd
--- /dev/null
+++ b/system/uapp/spawn/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("spawn") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/storage-metrics/BUILD.gn b/system/uapp/storage-metrics/BUILD.gn
new file mode 100644
index 0000000..a46bfa7
--- /dev/null
+++ b/system/uapp/storage-metrics/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+executable("storage-metrics") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-minfs:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/uapp/strerror/BUILD.gn b/system/uapp/strerror/BUILD.gn
new file mode 100644
index 0000000..6e3d3e7
--- /dev/null
+++ b/system/uapp/strerror/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("strerror") {
+  sources = [
+    "strerror.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/suspendtest/BUILD.gn b/system/uapp/suspendtest/BUILD.gn
new file mode 100644
index 0000000..67f85ad
--- /dev/null
+++ b/system/uapp/suspendtest/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("suspendtest") {
+  sources = [
+    "suspendtest.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/sysconfig/BUILD.gn b/system/uapp/sysconfig/BUILD.gn
new file mode 100644
index 0000000..fd80772
--- /dev/null
+++ b/system/uapp/sysconfig/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+executable("sysconfig") {
+  sources = [
+    "sysconfig.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk:headers",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/kvstore",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/uapp/system-version/BUILD.gn b/system/uapp/system-version/BUILD.gn
new file mode 100644
index 0000000..8f075ed
--- /dev/null
+++ b/system/uapp/system-version/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("system-version") {
+  sources = [
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/tee-test/BUILD.gn b/system/uapp/tee-test/BUILD.gn
new file mode 100644
index 0000000..a581e26b
--- /dev/null
+++ b/system/uapp/tee-test/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("tee-test") {
+  sources = [
+    "tee-test.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/tee-client-api",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/thread-depth/BUILD.gn b/system/uapp/thread-depth/BUILD.gn
new file mode 100644
index 0000000..a13bd24
--- /dev/null
+++ b/system/uapp/thread-depth/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+group("thread-depth") {
+  deps = [
+    ":thread-depth-test",
+  ]
+}
+
+executable("thread-depth-test") {
+  sources = [
+    "thread-depth.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/thread-stress/BUILD.gn b/system/uapp/thread-stress/BUILD.gn
new file mode 100644
index 0000000..41a6c40
--- /dev/null
+++ b/system/uapp/thread-stress/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+group("thread-stress") {
+  deps = [
+    ":thread-stress-test",
+  ]
+}
+
+executable("thread-stress-test") {
+  sources = [
+    "thread-stress.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/trace-benchmark/BUILD.gn b/system/uapp/trace-benchmark/BUILD.gn
new file mode 100644
index 0000000..a25f6ea
--- /dev/null
+++ b/system/uapp/trace-benchmark/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+executable("trace-benchmark") {
+  sources = [
+    "benchmarks.cpp",
+    "benchmarks_ntrace.cpp",
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider:trace-handler",
+    "$zx/system/ulib/trace-vthread",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/trace-example/BUILD.gn b/system/uapp/trace-example/BUILD.gn
new file mode 100644
index 0000000..a476e1f
--- /dev/null
+++ b/system/uapp/trace-example/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+executable("trace-example") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/traceme/BUILD.gn b/system/uapp/traceme/BUILD.gn
new file mode 100644
index 0000000..efa0af9
--- /dev/null
+++ b/system/uapp/traceme/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("traceme") {
+  sources = [
+    "traceme.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/unbind/BUILD.gn b/system/uapp/unbind/BUILD.gn
new file mode 100644
index 0000000..16acc52
--- /dev/null
+++ b/system/uapp/unbind/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("unbind") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/usb-fwloader/BUILD.gn b/system/uapp/usb-fwloader/BUILD.gn
new file mode 100644
index 0000000..ddec9b6
--- /dev/null
+++ b/system/uapp/usb-fwloader/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+executable("usb-fwloader") {
+  testonly = true
+  sources = [
+    "usb-fwloader.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-usb-fwloader:c",
+    "$zx/system/fidl/fuchsia-hardware-usb-tester:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/uapp/usbctl/BUILD.gn b/system/uapp/usbctl/BUILD.gn
new file mode 100644
index 0000000..c2b553e
--- /dev/null
+++ b/system/uapp/usbctl/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+executable("usbctl") {
+  sources = [
+    "usbctl.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-usb-modeswitch",
+    "$zx/system/fidl/fuchsia-hardware-usb-peripheral:c",
+    "$zx/system/fidl/fuchsia-hardware-usb-virtual-bus:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/uapp/waitfor/BUILD.gn b/system/uapp/waitfor/BUILD.gn
new file mode 100644
index 0000000..e728c89
--- /dev/null
+++ b/system/uapp/waitfor/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("waitfor") {
+  sources = [
+    "waitfor.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/uapp/watch/BUILD.gn b/system/uapp/watch/BUILD.gn
new file mode 100644
index 0000000..c61b104
--- /dev/null
+++ b/system/uapp/watch/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+executable("watch") {
+  sources = [
+    "watch.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+  ]
+}
diff --git a/system/uapp/xdc-test/BUILD.gn b/system/uapp/xdc-test/BUILD.gn
new file mode 100644
index 0000000..7452292
--- /dev/null
+++ b/system/uapp/xdc-test/BUILD.gn
@@ -0,0 +1,31 @@
+# Copyright 018 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.
+
+executable("xdc-test") {
+  sources = [
+    "xdc-device.cpp",
+    "xdc-test.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-usb-debug:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+host_tool("xdc-test-host") {
+  sources = [
+    "xdc-host.cpp",
+    "xdc-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/xdc-host-utils",
+    "$zx/system/ulib/xdc-server-utils",
+  ]
+}
diff --git a/system/ulib/BUILD.gn b/system/ulib/BUILD.gn
new file mode 100644
index 0000000..353296c
--- /dev/null
+++ b/system/ulib/BUILD.gn
@@ -0,0 +1,150 @@
+# 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("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+import("$zx/public/gn/zbi.gni")
+
+# TODO(mcgrathr): This is all temporary hacks for integrating with
+# the legacy Fuchsia GN build.  This file should not exist at all.
+
+foreach(cpu, standard_fuchsia_cpus) {
+  zbi_input("asan-manifest-$cpu") {
+    testonly = true
+    deps = [
+      ":asan-libs-$cpu",
+    ]
+    metadata = {
+      images = [
+        {
+          type = "manifest"
+          name = "asan-libs"
+          path = rebase_path("$target_gen_dir/$target_name.manifest",
+                             root_build_dir)
+        },
+      ]
+    }
+  }
+
+  select_toolchain("asan-libs-$cpu") {
+    testonly = true
+    cpu = cpu
+    environment_label = "$zx/public/gn/toolchain:user"
+    variant = "asan"
+    deps = [
+      ":ulib",
+    ]
+  }
+}
+
+if (current_cpu != "") {
+  group("ulib") {
+    testonly = true
+    deps = [
+      "$zx/system/dev/lib/broadcom",
+      "$zx/system/dev/lib/usb",
+      "$zx/system/fidl/fuchsia-net-stack:c",
+      "async",
+      "async-loop",
+      "async-testutils",
+      "audio-driver-proto",
+      "audio-proto-utils",
+      "audio-utils",
+      "backtrace-request",
+      "bitmap",
+      "blktest",
+      "blobfs",
+      "block-client",
+      "bootdata",
+      "bootfs",
+      "bootsvc-protocol",
+      "c",
+      "chromeos-disk-setup",
+      "cobalt-client",
+      "crypto",
+      "ddk",
+      "ddktl",
+      "devmgr-integration-test",
+      "devmgr-launcher",
+      "digest",
+      "dispatcher-pool",
+      "driver",
+      "driver-info",
+      "edid",
+      "elf-search",
+      "elfload",
+      "explicit-memory",
+      "fbl",
+      "fdio",
+      "fidl",
+      "fidl-async",
+      "fidl-utils",
+      "fit",
+      "framebuffer",
+      "fs",
+      "fs-management",
+      "fs-test-utils",
+      "ftl",
+      "fuzz-utils",
+      "fvm",
+      "fzl",
+      "gfx",
+      "gpt",
+      "hid",
+      "hid-parser",
+      "hwreg",
+      "inet6",
+      "inspect",
+      "inspector",
+      "intel-hda",
+      "kvstore",
+      "launchpad",
+      "ldmsg",
+      "libzbi",
+      "loader-service",
+      "lockdep",
+      "logger",
+      "memfs",
+      "minfs",
+      "mini-process",
+      "pci",
+      "perftest",
+      "port",
+      "pretty",
+      "process-launcher",
+      "region-alloc",
+      "rtc",
+      "runtests-utils",
+      "runtime",
+      "smbios",
+      "svc",
+      "sync",
+      "syslog",
+      "sysmem",
+      "task-utils",
+      "tee-client-api",
+      "test-utils",
+      "tftp",
+      "trace",
+      "trace-engine",
+      "trace-provider",
+      "trace-reader",
+      "trace-test-utils",
+      "trace-vthread",
+      "unittest",
+      "utf_conversion",
+      "virtio",
+      "xdc-host-utils",
+      "xdc-server-utils",
+      "zircon",
+      "zircon-internal",
+      "zx",
+      "zxcpp",
+      "zxcrypt",
+      "zxio",
+      "zxs",
+      "zxtest",
+    ]
+  }
+}
diff --git a/system/ulib/async-loop/BUILD.gn b/system/ulib/async-loop/BUILD.gn
new file mode 100644
index 0000000..c099aec
--- /dev/null
+++ b/system/ulib/async-loop/BUILD.gn
@@ -0,0 +1,42 @@
+# Copyright 018 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.
+
+library("async-loop") {
+  sdk = "source"
+  sdk_headers = [ "lib/async-loop/loop.h" ]
+  sources = [
+    "loop.c",
+  ]
+  public_deps = [
+    # <lib/async-loop/loop.h> has #include <lib/async/dispatcher.h>.
+    "$zx/system/ulib/async:headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+library("async-loop-cpp") {
+  sdk = "source"
+  sdk_headers = [ "lib/async-loop/cpp/loop.h" ]
+  sources = [
+    "loop_wrapper.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    ":async-loop",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/zircon",
+  ]
+  public_deps = [
+    ":headers",
+
+    # <lib/async-loop/cpp/loop.h> has #include <lib/zx/time.h>.
+    "$zx/system/ulib/zx:headers",
+  ]
+}
diff --git a/system/ulib/async-testutils/BUILD.gn b/system/ulib/async-testutils/BUILD.gn
new file mode 100644
index 0000000..36e13a3
--- /dev/null
+++ b/system/ulib/async-testutils/BUILD.gn
@@ -0,0 +1,42 @@
+# 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.
+
+library("async-testutils") {
+  sdk = "source"
+  sdk_headers = [
+    "lib/async-testutils/dispatcher_stub.h",
+    "lib/async-testutils/test_loop.h",
+    "lib/async-testutils/test_loop_dispatcher.h",
+    "lib/async-testutils/time-keeper.h",
+  ]
+  testonly = true
+  sources = [
+    "dispatcher_stub.cpp",
+    "test_loop.cpp",
+    "test_loop_dispatcher.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  public_deps = [
+    # <lib/async-testutils/dispatcher.h_stub> has #include <lib/async/dispatcher.h>.
+    "$zx/system/ulib/async:headers",
+
+    # <lib/async-testutils/test_loop_dispatcher.h> has #include <fbl/macros.h>.
+    "$zx/system/ulib/fbl:headers",
+
+    # <lib/async-testutils/dispatcher.h_stub> has #include <lib/zx/time.h>.
+    "$zx/system/ulib/zx:headers",
+
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/async/BUILD.gn b/system/ulib/async/BUILD.gn
new file mode 100644
index 0000000..45fad2a
--- /dev/null
+++ b/system/ulib/async/BUILD.gn
@@ -0,0 +1,74 @@
+# 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.
+
+library("async") {
+  sdk = "source"
+  sdk_headers = []
+  foreach(file,
+          [
+            "dispatcher.h",
+            "exception.h",
+            "receiver.h",
+            "task.h",
+            "time.h",
+            "trap.h",
+            "wait.h",
+          ]) {
+    sdk_headers += [ "lib/async/$file" ]
+  }
+  sources = [
+    "ops.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+library("async-cpp") {
+  sdk = "source"
+  sdk_headers = []
+  foreach(file,
+          [
+            "cpp/exception.h",
+            "cpp/receiver.h",
+            "cpp/task.h",
+            "cpp/time.h",
+            "cpp/trap.h",
+            "cpp/wait.h",
+          ]) {
+    sdk_headers += [ "lib/async/$file" ]
+  }
+  public_deps = [
+    # <lib/async/cpp/task.h> has #include <lib/zx/time.h>.
+    "$zx/system/ulib/zx:headers",
+
+    # <lib/async/cpp/task.h> has #include <fbl/function.h>.
+    "$zx/system/ulib/fbl:headers",
+  ]
+  sources = [
+    "exception.cpp",
+    "receiver.cpp",
+    "task.cpp",
+    "trap.cpp",
+    "wait.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    ":async",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
+
+library("async-default") {
+  sdk = "shared"
+  sdk_headers = [ "lib/async/default.h" ]
+  shared = true
+  sources = [
+    "default.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+}
diff --git a/system/ulib/audio-driver-proto/BUILD.gn b/system/ulib/audio-driver-proto/BUILD.gn
new file mode 100644
index 0000000..56b80fa
--- /dev/null
+++ b/system/ulib/audio-driver-proto/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+library("audio-driver-proto") {
+  sdk = "source"
+  sdk_headers = [ "audio-proto/audio-proto.h" ]
+  sources = [
+    "audio-proto.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+}
diff --git a/system/ulib/audio-proto-utils/BUILD.gn b/system/ulib/audio-proto-utils/BUILD.gn
new file mode 100644
index 0000000..104d8fa
--- /dev/null
+++ b/system/ulib/audio-proto-utils/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+library("audio-proto-utils") {
+  sdk = "source"
+  sdk_headers = [ "audio-proto-utils/format-utils.h" ]
+  sources = [
+    "format-utils.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+  ]
+}
diff --git a/system/ulib/audio-utils/BUILD.gn b/system/ulib/audio-utils/BUILD.gn
new file mode 100644
index 0000000..d9368f9
--- /dev/null
+++ b/system/ulib/audio-utils/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+library("audio-utils") {
+  sdk = "source"
+  sdk_headers = [
+    "audio-utils/audio-device-stream.h",
+    "audio-utils/audio-input.h",
+    "audio-utils/audio-output.h",
+    "audio-utils/audio-stream.h",
+  ]
+  sources = [
+    "audio-device-stream.cpp",
+    "audio-input.cpp",
+    "audio-output.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/backtrace-request/BUILD.gn b/system/ulib/backtrace-request/BUILD.gn
new file mode 100644
index 0000000..40de441
--- /dev/null
+++ b/system/ulib/backtrace-request/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+library("backtrace-request") {
+  sdk = "source"
+  sdk_headers = [ "lib/backtrace-request/backtrace-request.h" ]
+  sources = []
+}
diff --git a/system/ulib/bitmap/BUILD.gn b/system/ulib/bitmap/BUILD.gn
new file mode 100644
index 0000000..7cf90bb
--- /dev/null
+++ b/system/ulib/bitmap/BUILD.gn
@@ -0,0 +1,33 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("bitmap") {
+  sdk = "source"
+  sdk_headers = [
+    "bitmap/bitmap.h",
+    "bitmap/raw-bitmap.h",
+    "bitmap/rle-bitmap.h",
+    "bitmap/storage.h",
+  ]
+  kernel = true
+  host = true
+  static = true
+  sources = [
+    "raw-bitmap.cpp",
+    "rle-bitmap.cpp",
+  ]
+  public_deps = [
+    "$zx/system/ulib/fbl:headers",
+  ]
+  if (!is_kernel && !is_host) {
+    deps = [
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/ulib/blktest/BUILD.gn b/system/ulib/blktest/BUILD.gn
new file mode 100644
index 0000000..b86bd91
--- /dev/null
+++ b/system/ulib/blktest/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+library("blktest") {
+  shared = true
+  testonly = true
+  sources = [
+    "blktest.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/blobfs/BUILD.gn b/system/ulib/blobfs/BUILD.gn
new file mode 100644
index 0000000..6ac4282
--- /dev/null
+++ b/system/ulib/blobfs/BUILD.gn
@@ -0,0 +1,68 @@
+# 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.
+
+library("blobfs") {
+  host = true
+  sources = [
+    "common.cpp",
+    "extent-reserver.cpp",
+    "fsck.cpp",
+    "iterator/allocated-extent-iterator.cpp",
+    "iterator/block-iterator.cpp",
+    "iterator/vector-extent-iterator.cpp",
+    "lz4.cpp",
+    "node-reserver.cpp",
+  ]
+  if (is_fuchsia) {
+    sources += [
+      "allocator.cpp",
+      "blob-cache.cpp",
+      "blob.cpp",
+      "blobfs.cpp",
+      "cache-node.cpp",
+      "directory.cpp",
+      "iterator/node-populator.cpp",
+      "journal.cpp",
+      "metrics.cpp",
+      "writeback.cpp",
+    ]
+  } else {
+    sources += [ "host.cpp" ]
+  }
+  public_deps = [
+    "$zx/system/ulib/bitmap:headers",
+    "$zx/system/ulib/fs:headers",
+  ]
+  if (is_fuchsia) {
+    public_deps += [ "$zx/system/ulib/block-client:headers" ]
+  }
+  deps = [
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio:headers",
+    "$zx/third_party/ulib/cksum",
+    "$zx/third_party/ulib/lz4",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+  if (is_fuchsia) {
+    deps += [
+      "$zx/system/ulib/async",
+      "$zx/system/ulib/async:async-cpp",
+      "$zx/system/ulib/async:async-default",
+      "$zx/system/ulib/async-loop",
+      "$zx/system/ulib/async-loop:async-loop-cpp",
+      "$zx/system/ulib/block-client",
+      "$zx/system/ulib/c",
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/fzl",
+      "$zx/system/ulib/sync",
+      "$zx/system/ulib/trace",
+      "$zx/system/ulib/trace-engine",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/ulib/blobfs/test/BUILD.gn b/system/ulib/blobfs/test/BUILD.gn
new file mode 100644
index 0000000..c76e60b
--- /dev/null
+++ b/system/ulib/blobfs/test/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+group("test") {
+  deps = [
+    ":blobfs-unit",
+  ]
+}
+
+test("blobfs-unit") {
+  sources = [
+    "allocated-extent-iterator-test.cpp",
+    "allocator-test.cpp",
+    "blob-cache-test.cpp",
+    "compressor-test.cpp",
+    "extent-reserver-test.cpp",
+    "journal-test.cpp",
+    "main.cpp",
+    "node-populator-test.cpp",
+    "node-reserver-test.cpp",
+    "utils.cpp",
+    "vector-extent-iterator-test.cpp",
+  ]
+  deps = [
+    "..",
+  ]
+}
diff --git a/system/ulib/block-client/BUILD.gn b/system/ulib/block-client/BUILD.gn
new file mode 100644
index 0000000..a888cf7
--- /dev/null
+++ b/system/ulib/block-client/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+library("block-client") {
+  sources = [
+    "client.c",
+    "client.cpp",
+  ]
+  public_deps = [
+    # <block-client/cpp/client.h> has #include <lib/zx/fifo.h>.
+    "$zx/system/ulib/zx:headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/ddk:headers",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/bootdata/BUILD.gn b/system/ulib/bootdata/BUILD.gn
new file mode 100644
index 0000000..ce26fb5
--- /dev/null
+++ b/system/ulib/bootdata/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+library("bootdata") {
+  sources = [
+    "decompress.c",
+  ]
+  deps = [
+    "$zx/system/ulib/c",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/lz4",
+  ]
+}
diff --git a/system/ulib/bootfs/BUILD.gn b/system/ulib/bootfs/BUILD.gn
new file mode 100644
index 0000000..07baf68
--- /dev/null
+++ b/system/ulib/bootfs/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+library("bootfs") {
+  sources = [
+    "parser.cpp",
+  ]
+  deps = [
+    "$zx/public/gn/config:visibility_hidden",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+test("bootfs-test") {
+  sources = [
+    "parser-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/bootfs",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/bootsvc-protocol/BUILD.gn b/system/ulib/bootsvc-protocol/BUILD.gn
new file mode 100644
index 0000000..dd33287
--- /dev/null
+++ b/system/ulib/bootsvc-protocol/BUILD.gn
@@ -0,0 +1,9 @@
+# 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.
+
+library("bootsvc-protocol") {
+  sdk = "source"
+  sdk_headers = [ "lib/bootsvc-protocol/processargs.h" ]
+  sources = []
+}
diff --git a/system/ulib/c/BUILD.gn b/system/ulib/c/BUILD.gn
new file mode 100644
index 0000000..ac4d441
--- /dev/null
+++ b/system/ulib/c/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+library("c") {
+  sdk = "shared"
+  sdk_headers = [] # TODO
+  shared = true
+  static = false
+
+  # At link time and in DT_SONAME, musl is known as libc.so.  But the
+  # (only) place it needs to be installed at runtime is where the
+  # PT_INTERP strings embedded in executables point, which is ld.so.1.
+  install_path = "lib/${toolchain.libprefix}ld.so.1"
+
+  public_deps = [
+    "$zx/third_party/ulib/musl:headers",
+  ]
+
+  # The code comes from musl, where a source_set is defined.
+  sources = []
+  deps = [
+    "$zx/third_party/ulib/musl",
+  ]
+
+  if (toolchain.environment == "user") {
+    # Suppress the circularity.
+    configs -= [ "$zx/public/gn/config:user" ]
+  }
+
+  # This library is on the whitelist for driver() shared library deps.
+  # It doesn't trigger the assert_no_metadata() check, and it prunes the
+  # metadata walk here so our own deps are not subject to the check.
+  metadata = {
+    driver_blacklist = []
+    driver_blacklist_barrier = []
+  }
+}
+
+group("crt1") {
+  deps = [
+    "$zx/third_party/ulib/musl:crt1",
+  ]
+}
diff --git a/system/ulib/chromeos-disk-setup/BUILD.gn b/system/ulib/chromeos-disk-setup/BUILD.gn
new file mode 100644
index 0000000..5bbd3be
--- /dev/null
+++ b/system/ulib/chromeos-disk-setup/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+library("chromeos-disk-setup") {
+  sources = [
+    "chromeos-disk-setup.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/cobalt-client/BUILD.gn b/system/ulib/cobalt-client/BUILD.gn
new file mode 100644
index 0000000..ff9cb31
--- /dev/null
+++ b/system/ulib/cobalt-client/BUILD.gn
@@ -0,0 +1,47 @@
+# 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.
+
+library("cobalt-client") {
+  sdk = "source"
+  sdk_headers = [
+    "cobalt-client/cpp/collector-internal.h",
+    "cobalt-client/cpp/collector.h",
+    "cobalt-client/cpp/counter-internal.h",
+    "cobalt-client/cpp/counter.h",
+    "cobalt-client/cpp/histogram-internal.h",
+    "cobalt-client/cpp/histogram.h",
+    "cobalt-client/cpp/metric-options.h",
+    "cobalt-client/cpp/timer.h",
+    "cobalt-client/cpp/types-internal.h",
+  ]
+  host = true
+  sources = [
+    "collector.cpp",
+    "counter.cpp",
+    "histogram.cpp",
+    "metric_info.cpp",
+  ]
+  if (is_fuchsia) {
+    sources += [ "cobalt_logger.cpp" ]
+  }
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  public_deps = [
+    # <cobalt-client/cpp/timer.h> has #include <lib/fzl/time.h>.
+    "$zx/system/ulib/fzl:headers",
+
+    # <cobalt-client/cpp/types-internal.h> has #include <fuchsia/cobalt/c/fidl.h>.
+    "$zx/system/fidl/fuchsia-cobalt:c.headers",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-cobalt:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/crypto/BUILD.gn b/system/ulib/crypto/BUILD.gn
new file mode 100644
index 0000000..9ca40d5
--- /dev/null
+++ b/system/ulib/crypto/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+library("crypto") {
+  shared = true
+  sources = [
+    "aead.cpp",
+    "bytes.cpp",
+    "cipher.cpp",
+    "digest.cpp",
+    "error.cpp",
+    "hkdf.cpp",
+    "hmac.cpp",
+    "secret.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/explicit-memory",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/ulib/ddk/BUILD.gn b/system/ulib/ddk/BUILD.gn
new file mode 100644
index 0000000..c9c3fc3
--- /dev/null
+++ b/system/ulib/ddk/BUILD.gn
@@ -0,0 +1,80 @@
+# 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.
+
+library("ddk") {
+  sdk = "static"
+  sdk_headers = [
+    "ddk/metadata/bad-block.h",
+    "ddk/metadata/buttons.h",
+    "ddk/metadata/camera.h",
+    "ddk/metadata/gpt.h",
+    "ddk/metadata/nand.h",
+    "ddk/protocol/auxdata.h",
+    "ddk/protocol/bt-gatt-svc-lib.h",
+    "ddk/protocol/bt-gatt-svc-lib.h.~1~",
+    "ddk/protocol/i2c-lib.h",
+    "ddk/protocol/pci-lib.h",
+    "ddk/protocol/platform-device-lib.h",
+    "ddk/trace/event.h",
+    "ddk/binding.h",
+    "ddk/debug.h",
+    "ddk/device.h",
+    "ddk/driver.h",
+    "ddk/io-buffer.h",
+    "ddk/metadata.h",
+    "ddk/mmio-buffer.h",
+    "ddk/phys-iter.h",
+    "ddk/physiter.h",
+    "ddk/platform-defs.h",
+    "ddk/protodefs.h",
+    "hw/arch_ops.h",
+    "hw/inout.h",
+    "hw/pci.h",
+    "hw/reg.h",
+    "hw/sdhci.h",
+    "hw/sdio.h",
+    "hw/sdmmc.h",
+  ]
+  sources = [
+    "io-buffer.c",
+    "mmio-buffer.c",
+    "phys-iter.c",
+  ]
+  public_deps = [
+    # <ddk/io-buffer.h> has #include <zircon/syscalls.h>.
+    "$zx/system/ulib/zircon:headers",
+
+    # <ddk/protocol/rawnand.h> has #include <fuchsia/hardware/nand/c/fidl.h>.
+    "$zx/system/fidl/fuchsia-hardware-nand:c.headers",
+
+    # <ddk/trace/event.h> has #include <trace/internal/event_common.h>.
+    "$zx/system/ulib/trace:headers",
+
+    # <ddk/protocol/i2c-lib.h> has #include <ddk/protocol/i2c.h>.
+    "$zx/system/banjo/ddk-protocol-i2c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+  ]
+  if (!is_kernel) {
+    public_deps += [ "$zx/system/core/devmgr/devhost:enable_driver_tracing" ]
+  }
+}
+
+test("ddk-unittest") {
+  sources = [
+    "test/main.cpp",
+    "test/phys-iter-test.cpp",
+  ]
+  deps = [
+    ":ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/ddktl/BUILD.gn b/system/ulib/ddktl/BUILD.gn
new file mode 100644
index 0000000..a69bf5b
--- /dev/null
+++ b/system/ulib/ddktl/BUILD.gn
@@ -0,0 +1,70 @@
+# 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.
+
+library("ddktl") {
+  sdk = "static"
+  sdk_headers = [
+    "ddktl/protocol/empty-protocol.h",
+    "ddktl/device-internal.h",
+    "ddktl/device.h",
+    "ddktl/i2c-channel.h",
+    "ddktl/mmio.h",
+    "ddktl/pdev.h",
+  ]
+  sources = [
+    "pdev.cpp",
+  ]
+  public_deps = [
+    # <ddktl/pdev.h> has #include <ddktl/protocol/clk.h>.
+    "$zx/system/banjo/ddk-protocol-clk",
+
+    # <ddktl/pdev.h> has #include <ddktl/protocol/gpio.h>.
+    "$zx/system/banjo/ddk-protocol-gpio",
+
+    # <ddktl/pdev.h> has #include <ddktl/protocol/platform/device.h>.
+    "$zx/system/banjo/ddk-protocol-platform-device",
+
+    # <ddktl/device-internal.h> has #include <fbl/type_support.h>.
+    "$zx/system/ulib/fbl:headers",
+
+    # <ddktl/protocol/display-controller.h> has #include <lib/zx/vmo.h>.
+    "$zx/system/ulib/zx:headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-gpio",
+    "$zx/system/banjo/ddk-protocol-i2c",
+    "$zx/system/banjo/ddk-protocol-platform-device",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+test_driver("ddktl-test") {
+  sources = [
+    "test/ddktl-test-binding.c",
+    "test/ddktl-test.cpp",
+    "test/device-tests.cpp",
+    "test/ethernet-tests.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-test",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/devmgr-integration-test/BUILD.gn b/system/ulib/devmgr-integration-test/BUILD.gn
new file mode 100644
index 0000000..c1c5c13
--- /dev/null
+++ b/system/ulib/devmgr-integration-test/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+library("devmgr-integration-test") {
+  sdk = "shared"
+  sdk_headers = [ "lib/devmgr-integration-test/fixture.h" ]
+
+  # TODO: testonly = true
+  shared = true
+  sources = [
+    "file-wait.cpp",
+    "launcher.cpp",
+  ]
+  public_deps = [
+    # <lib/devmgr-integration-test/fixture.h> has #include <lib/devmgr-launcher/launch.h>.
+    "$zx/system/ulib/devmgr-launcher:headers",
+  ]
+  deps = [
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/devmgr-launcher/BUILD.gn b/system/ulib/devmgr-launcher/BUILD.gn
new file mode 100644
index 0000000..38b21ab
--- /dev/null
+++ b/system/ulib/devmgr-launcher/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+library("devmgr-launcher") {
+  sdk = "shared"
+  sdk_headers = [
+    "lib/devmgr-launcher/launch.h",
+    "lib/devmgr-launcher/processargs.h",
+  ]
+  shared = true
+  sources = [
+    "launcher.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/bootsvc-protocol",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/dispatcher-pool/BUILD.gn b/system/ulib/dispatcher-pool/BUILD.gn
new file mode 100644
index 0000000..8d354bb
--- /dev/null
+++ b/system/ulib/dispatcher-pool/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+library("dispatcher-pool") {
+  sdk = "source"
+  sdk_headers = [
+    "dispatcher-pool/dispatcher-channel.h",
+    "dispatcher-pool/dispatcher-event-source.h",
+    "dispatcher-pool/dispatcher-execution-domain.h",
+    "dispatcher-pool/dispatcher-interrupt.h",
+    "dispatcher-pool/dispatcher-thread-pool.h",
+    "dispatcher-pool/dispatcher-timer.h",
+    "dispatcher-pool/dispatcher-wakeup-event.h",
+  ]
+  sources = [
+    "dispatcher-channel.cpp",
+    "dispatcher-event-source.cpp",
+    "dispatcher-execution-domain.cpp",
+    "dispatcher-interrupt.cpp",
+    "dispatcher-thread-pool.cpp",
+    "dispatcher-timer.cpp",
+    "dispatcher-wakeup-event.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/driver-info/BUILD.gn b/system/ulib/driver-info/BUILD.gn
new file mode 100644
index 0000000..b82c1f2
--- /dev/null
+++ b/system/ulib/driver-info/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+library("driver-info") {
+  sources = [
+    "driver-info.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+}
+
+executable("driverinfo") {
+  sources = [
+    "driver-info-app.c",
+  ]
+  deps = [
+    ":driver-info",
+    "$zx/system/ulib/fdio",
+  ]
+}
diff --git a/system/ulib/driver/BUILD.gn b/system/ulib/driver/BUILD.gn
new file mode 100644
index 0000000..079aa44
--- /dev/null
+++ b/system/ulib/driver/BUILD.gn
@@ -0,0 +1,7 @@
+# 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.
+
+group("driver") {
+  public_deps = [ "$zx/system/core/devmgr/devhost:driver" ]
+}
diff --git a/system/ulib/edid/BUILD.gn b/system/ulib/edid/BUILD.gn
new file mode 100644
index 0000000..1f07bf6
--- /dev/null
+++ b/system/ulib/edid/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+library("edid") {
+  sources = [
+    "edid.cpp",
+    "eisa_vid_lut.cpp",
+    "timings.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/elf-search/BUILD.gn b/system/ulib/elf-search/BUILD.gn
new file mode 100644
index 0000000..de869ca
--- /dev/null
+++ b/system/ulib/elf-search/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+library("elf-search") {
+  sdk = "source"
+  sdk_headers = [ "elf-search.h" ]
+  sources = [
+    "elf-search.cpp",
+  ]
+  public_deps = [
+    "$zx/system/ulib/fbl:headers",
+    "$zx/system/ulib/zx:headers",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/elfload/BUILD.gn b/system/ulib/elfload/BUILD.gn
new file mode 100644
index 0000000..a7760d4
--- /dev/null
+++ b/system/ulib/elfload/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+library("elfload") {
+  sources = [
+    "elf-load.c",
+  ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/explicit-memory/BUILD.gn b/system/ulib/explicit-memory/BUILD.gn
new file mode 100644
index 0000000..a4cb504
--- /dev/null
+++ b/system/ulib/explicit-memory/BUILD.gn
@@ -0,0 +1,20 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("explicit-memory") {
+  sdk = "static"
+  sdk_headers = [ "explicit-memory/bytes.h" ]
+  kernel = true
+  static = true
+  sources = [
+    "bytes.c",
+  ]
+  if (!is_kernel) {
+    deps = [
+      "$zx/system/ulib/fbl",
+    ]
+  }
+}
diff --git a/system/ulib/fdio/BUILD.gn b/system/ulib/fdio/BUILD.gn
new file mode 100644
index 0000000..7a874c2
--- /dev/null
+++ b/system/ulib/fdio/BUILD.gn
@@ -0,0 +1,63 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("fdio") {
+  sdk = "shared"
+  sdk_headers = [
+    "lib/fdio/debug.h",
+    "lib/fdio/io.h",
+    "lib/fdio/limits.h",
+    "lib/fdio/namespace.h",
+    "lib/fdio/private.h",
+    "lib/fdio/spawn.h",
+    "lib/fdio/unsafe.h",
+    "lib/fdio/util.h",
+    "lib/fdio/vfs.h",
+    "lib/fdio/watcher.h",
+  ]
+  shared = true
+  sources = [
+    "bsdsocket.c",
+    "debug.c",
+    "get-vmo.c",
+    "namespace.c",
+    "null.c",
+    "remoteio.c",
+    "socket.c",
+    "spawn.c",
+    "stubs.c",
+    "uname.c",
+    "unistd.c",
+    "waitable.cpp",
+    "watcher.c",
+    "zxio.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-ldsvc:c",
+    "$zx/system/fidl/fuchsia-net:c",
+    "$zx/system/fidl/fuchsia-process:c",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxio",
+    "$zx/system/ulib/zxs",
+  ]
+
+  # TODO(mcgrathr): Temporary kludge for legacy Fuchsia GN build integration.
+  if (toolchain.variant == "gcc" || toolchain.variant == "clang") {
+    metadata = {
+      images = [
+        {
+          name = "fdio"
+          type = "so"
+          path = rebase_path("$target_out_dir/libfdio.so.debug", root_build_dir)
+        },
+      ]
+    }
+  }
+}
diff --git a/system/ulib/fidl-async/BUILD.gn b/system/ulib/fidl-async/BUILD.gn
new file mode 100644
index 0000000..2e52b02
--- /dev/null
+++ b/system/ulib/fidl-async/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+library("fidl-async") {
+  sdk = "source"
+  sdk_headers = [ "lib/fidl-async/bind.h" ]
+  sources = [
+    "bind.c",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/fidl-utils/BUILD.gn b/system/ulib/fidl-utils/BUILD.gn
new file mode 100644
index 0000000..e153bf9
--- /dev/null
+++ b/system/ulib/fidl-utils/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+library("fidl-utils") {
+  sdk = "source"
+  sdk_headers = [ "lib/fidl-utils/bind.h" ]
+  sources = []
+  deps = [
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fidl-async",
+  ]
+  public_deps = [
+    "$zx/system/ulib/async:headers",
+    "$zx/system/ulib/fbl:headers",
+    "$zx/system/ulib/fidl:headers",
+    "$zx/system/ulib/fidl-async:headers",
+    "$zx/system/ulib/zx:headers",
+  ]
+}
diff --git a/system/ulib/fidl/BUILD.gn b/system/ulib/fidl/BUILD.gn
new file mode 100644
index 0000000..e41de0b
--- /dev/null
+++ b/system/ulib/fidl/BUILD.gn
@@ -0,0 +1,43 @@
+# 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.
+
+library("fidl") {
+  sdk = "source"
+  sdk_headers = [
+    "lib/fidl/cpp/builder.h",
+    "lib/fidl/cpp/message.h",
+    "lib/fidl/cpp/message_buffer.h",
+    "lib/fidl/cpp/message_builder.h",
+    "lib/fidl/cpp/message_part.h",
+    "lib/fidl/cpp/string_view.h",
+    "lib/fidl/cpp/vector_view.h",
+    "lib/fidl/llcpp/array_wrapper.h",
+    "lib/fidl/llcpp/decoded_message.h",
+    "lib/fidl/llcpp/encoded_message.h",
+    "lib/fidl/llcpp/traits.h",
+    "lib/fidl/coding.h",
+    "lib/fidl/epitaph.h",
+    "lib/fidl/internal.h",
+    "lib/fidl/transport.h",
+  ]
+  sources = [
+    "builder.cpp",
+    "decoding.cpp",
+    "encoding.cpp",
+    "epitaph.c",
+    "formatting.cpp",
+    "handle_closing.cpp",
+    "message.cpp",
+    "message_buffer.cpp",
+    "message_builder.cpp",
+    "transport.cpp",
+    "validating.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/framebuffer/BUILD.gn b/system/ulib/framebuffer/BUILD.gn
new file mode 100644
index 0000000..924c1da
--- /dev/null
+++ b/system/ulib/framebuffer/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+library("framebuffer") {
+  sdk = "static"
+  sdk_headers = [ "lib/framebuffer/framebuffer.h" ]
+  sources = [
+    "framebuffer.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-display:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/fs-host/BUILD.gn b/system/ulib/fs-host/BUILD.gn
new file mode 100644
index 0000000..1dfebd6
--- /dev/null
+++ b/system/ulib/fs-host/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+library("fs-host") {
+  host = true
+  sources = [
+    "common.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+  ]
+}
diff --git a/system/ulib/fs-management/BUILD.gn b/system/ulib/fs-management/BUILD.gn
new file mode 100644
index 0000000..1ea81c7
--- /dev/null
+++ b/system/ulib/fs-management/BUILD.gn
@@ -0,0 +1,51 @@
+# 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.
+
+library("fs-management") {
+  sdk = "shared"
+  sdk_headers = [
+    "fs-management/fvm.h",
+    "fs-management/mount.h",
+    "fs-management/ram-nand.h",
+    "fs-management/ramdisk.h",
+  ]
+  shared = true
+  sources = [
+    "fsck.cpp",
+    "fvm.cpp",
+    "launch.cpp",
+    "mkfs.cpp",
+    "mount.cpp",
+    "ram-nand.cpp",
+    "ramdisk.cpp",
+  ]
+  public_deps = [
+    # <zircon/device/ram-nand.h> has #include <fuchsia/hardware/nand/c/fidl.h>.
+    "$zx/system/fidl/fuchsia-hardware-nand:c.headers",
+
+    # <fs-management/ram-nand.h> has #include <lib/devmgr-integration-test/fixture.h>.
+    "$zx/system/ulib/devmgr-integration-test:headers",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-nand:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+  data_deps = [
+    "$zx/system/uapp/minfs",
+    "$zx/system/uapp/blobfs",
+    "$zx/third_party/uapp/mkfs-msdosfs",
+    "$zx/third_party/uapp/fsck-msdosfs",
+  ]
+}
diff --git a/system/ulib/fs-test-utils/BUILD.gn b/system/ulib/fs-test-utils/BUILD.gn
new file mode 100644
index 0000000..87b3772
--- /dev/null
+++ b/system/ulib/fs-test-utils/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+library("fs-test-utils") {
+  sdk = "source"
+  sdk_headers = [
+    "fs-test-utils/fixture.h",
+    "fs-test-utils/perftest.h",
+    "fs-test-utils/unittest.h",
+  ]
+  testonly = true
+  sources = [
+    "fixture.cpp",
+    "perftest.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/fs/BUILD.gn b/system/ulib/fs/BUILD.gn
new file mode 100644
index 0000000..a785bc3
--- /dev/null
+++ b/system/ulib/fs/BUILD.gn
@@ -0,0 +1,100 @@
+# 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.
+
+library("fs") {
+  sdk = "source"
+  sdk_headers = [
+    "fs/block-txn.h",
+    "fs/client.h",
+    "fs/connection.h",
+    "fs/fvm.h",
+    "fs/handler.h",
+    "fs/lazy-dir.h",
+    "fs/locking.h",
+    "fs/managed-vfs.h",
+    "fs/metrics.h",
+    "fs/pseudo-dir.h",
+    "fs/pseudo-file.h",
+    "fs/queue.h",
+    "fs/ref_counted.h",
+    "fs/remote-dir.h",
+    "fs/remote.h",
+    "fs/service.h",
+    "fs/synchronous-vfs.h",
+    "fs/ticker.h",
+    "fs/trace.h",
+    "fs/vfs.h",
+    "fs/vmo-file.h",
+    "fs/vnode.h",
+    "fs/watcher.h",
+  ]
+  host = true
+  static = true
+
+  public_deps = [
+    "$zx/system/ulib/async:headers",
+    "$zx/system/ulib/fbl:headers",
+    "$zx/system/ulib/fdio:headers",
+  ]
+
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon-internal",
+  ]
+
+  sources = [
+    "block-txn.cpp",
+    "vfs.cpp",
+    "vnode.cpp",
+  ]
+
+  if (is_fuchsia) {
+    sources += [
+      "connection.cpp",
+      "fvm.cpp",
+      "handler.cpp",
+      "lazy-dir.cpp",
+      "managed-vfs.cpp",
+      "metrics.cpp",
+      "mount.cpp",
+      "pseudo-dir.cpp",
+      "pseudo-file.cpp",
+      "remote-dir.cpp",
+      "service.cpp",
+      "synchronous-vfs.cpp",
+      "unmount.cpp",
+      "vmo-file.cpp",
+      "watcher.cpp",
+    ]
+    public_deps += [
+      "$zx/system/ulib/zx:headers",
+
+      # <fs/vnode.h> has #include <fuchsia/io/c/fidl.h>.
+      "$zx/system/fidl/fuchsia-io:c.headers",
+
+      # <fs/metrics.h> has #include <cobalt-client/cpp/collector.h>.
+      "$zx/system/ulib/cobalt-client:headers",
+    ]
+    configs += [ "$zx/public/gn/config:visibility_hidden" ]
+    deps += [
+      "$zx/system/fidl/fuchsia-cobalt:c",
+      "$zx/system/fidl/fuchsia-io:c",
+      "$zx/system/fidl/fuchsia-mem:c",
+      "$zx/system/ulib/async",
+      "$zx/system/ulib/async:async-cpp",
+      "$zx/system/ulib/cobalt-client",
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/fidl",
+      "$zx/system/ulib/fidl-utils",
+      "$zx/system/ulib/fzl",
+      "$zx/system/ulib/sync",
+      "$zx/system/ulib/trace",
+      "$zx/system/ulib/trace-engine",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/ulib/ftl/BUILD.gn b/system/ulib/ftl/BUILD.gn
new file mode 100644
index 0000000..7144dd5
--- /dev/null
+++ b/system/ulib/ftl/BUILD.gn
@@ -0,0 +1,50 @@
+# 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.
+
+library("ftl") {
+  sources = [
+    "ftln/ftln_init.c",
+    "ftln/ftln_intrnl.c",
+    "ftln/ftln_rd.c",
+    "ftln/ftln_util.c",
+    "ftln/ndm-driver.cpp",
+    "ftln/volume.cpp",
+    "ndm/ndm_init.c",
+    "ndm/ndm_intrnl.c",
+    "ndm/ndm_vols.c",
+    "utils/aalloc.c",
+    "utils/crc32_tbl.c",
+    "utils/fsmem.c",
+    "utils/fsys.c",
+    "utils/fsysinit.c",
+    "utils/ftl_mc.c",
+    "utils/semaphore.cpp",
+    "utils/sys.c",
+  ]
+  deps = [
+    ":config",
+    "$zx/system/ulib/backtrace-request",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+config("config") {
+  visibility = [ ":*" ]
+  defines = [ "NDM_DEBUG" ]
+  include_dirs = [
+    ".",
+    "utils",
+    "inc",
+    "inc/kprivate",
+  ]
+  cflags = [ "-Wno-sign-compare" ]
+  if (is_gcc) {
+    cflags += [ "-Wno-discarded-qualifiers" ]
+  } else {
+    cflags += [ "-Wno-incompatible-pointer-types-discards-qualifiers" ]
+  }
+}
diff --git a/system/ulib/fuzz-utils/BUILD.gn b/system/ulib/fuzz-utils/BUILD.gn
new file mode 100644
index 0000000..55047ca
--- /dev/null
+++ b/system/ulib/fuzz-utils/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+library("fuzz-utils") {
+  sources = [
+    "fuzzer.cpp",
+    "path.cpp",
+    "string-list.cpp",
+    "string-map.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/fvm-host/BUILD.gn b/system/ulib/fvm-host/BUILD.gn
new file mode 100644
index 0000000..8075453
--- /dev/null
+++ b/system/ulib/fvm-host/BUILD.gn
@@ -0,0 +1,35 @@
+# 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.
+
+library("fvm-host") {
+  host = true
+  sources = [
+    "container/container.cpp",
+    "container/fvm.cpp",
+    "container/sparse.cpp",
+    "format/blobfs.cpp",
+    "format/format.cpp",
+    "format/minfs.cpp",
+    "fvm-info.cpp",
+    "sparse-paver.cpp",
+  ]
+  public_deps = [
+    "$zx/system/ulib/blobfs",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/minfs",
+    "$zx/third_party/ulib/lz4",
+
+    # include/fvm/format.h has #include <fs-management/mount.h>
+    # though that library is not really meant for host code.
+    "$zx/system/ulib/fs-management:headers",
+  ]
+
+  deps = [
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/ulib/fvm/BUILD.gn b/system/ulib/fvm/BUILD.gn
new file mode 100644
index 0000000..45c40f2
--- /dev/null
+++ b/system/ulib/fvm/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+library("fvm") {
+  host = true
+  sources = [
+    "fvm-check.cpp",
+    "fvm.cpp",
+    "sparse-reader.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/lz4",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+  public_deps = [
+    # <fvm/fvm.h> has #include <digest/digest.h>.
+    "$zx/system/ulib/digest:headers",
+
+    # <fvm/fvm.h> has #include <gpt/gpt.h>.
+    "$zx/system/ulib/gpt:headers",
+  ]
+  if (is_fuchsia) {
+    deps += [
+      "$zx/system/ulib/gpt",
+      "$zx/system/ulib/sync",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/ulib/fzl/BUILD.gn b/system/ulib/fzl/BUILD.gn
new file mode 100644
index 0000000..2cdd742
--- /dev/null
+++ b/system/ulib/fzl/BUILD.gn
@@ -0,0 +1,43 @@
+# 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.
+
+library("fzl") {
+  sdk = "source"
+  sdk_headers = [
+    "lib/fzl/fdio.h",
+    "lib/fzl/fifo.h",
+    "lib/fzl/memory-probe.h",
+    "lib/fzl/owned-vmo-mapper.h",
+    "lib/fzl/pinned-vmo.h",
+    "lib/fzl/resizeable-vmo-mapper.h",
+    "lib/fzl/time.h",
+    "lib/fzl/vmar-manager.h",
+    "lib/fzl/vmo-mapper.h",
+    "lib/fzl/vmo-pool.h",
+  ]
+  sources = [
+    "memory-probe.cpp",
+    "owned-vmo-mapper.cpp",
+    "pinned-vmo.cpp",
+    "resizeable-vmo-mapper.cpp",
+    "time.cpp",
+    "vmar-manager.cpp",
+    "vmo-mapper.cpp",
+    "vmo-pool.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zx",
+  ]
+  public_deps = [
+    "$zx/system/ulib/fbl:headers",
+
+    # <lib/fzl/fdio.h> has #include <lib/fdio/unsafe.h>.
+    "$zx/system/ulib/fdio:headers",
+
+    # <lib/fzl/fdio.h> has #include <lib/zx/channel.h>.
+    "$zx/system/ulib/zx:headers",
+  ]
+}
diff --git a/system/ulib/gfx/BUILD.gn b/system/ulib/gfx/BUILD.gn
new file mode 100644
index 0000000..c5d0a57
--- /dev/null
+++ b/system/ulib/gfx/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+library("gfx") {
+  sources = [
+    "gfx.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/gpt/BUILD.gn b/system/ulib/gpt/BUILD.gn
new file mode 100644
index 0000000..b9d170d
--- /dev/null
+++ b/system/ulib/gpt/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+library("gpt") {
+  sources = [
+    "cros.cpp",
+    "gpt.cpp",
+  ]
+  public_deps = [
+    # <gpt/gpt.h> has #include <fbl/unique_ptr.h>.
+    "$zx/system/ulib/fbl:headers",
+  ]
+  deps = [
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/ulib/hid-parser/BUILD.gn b/system/ulib/hid-parser/BUILD.gn
new file mode 100644
index 0000000..b9674e9
--- /dev/null
+++ b/system/ulib/hid-parser/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+library("hid-parser") {
+  sdk = "static"
+  sdk_headers = [
+    "hid-parser/item.h",
+    "hid-parser/parser.h",
+    "hid-parser/usages.h",
+  ]
+  sources = [
+    "item.cpp",
+    "parser.cpp",
+    "report.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/hid/BUILD.gn b/system/ulib/hid/BUILD.gn
new file mode 100644
index 0000000..360334a
--- /dev/null
+++ b/system/ulib/hid/BUILD.gn
@@ -0,0 +1,46 @@
+# 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.
+
+library("hid") {
+  sdk = "shared"
+  sdk_headers = [
+    "hid/acer12.h",
+    "hid/ambient-light.h",
+    "hid/boot.h",
+    "hid/buttons.h",
+    "hid/descriptor.h",
+    "hid/egalax.h",
+    "hid/eyoyo.h",
+    "hid/ft3x27.h",
+    "hid/gt92xx.h",
+    "hid/hid.h",
+    "hid/ltr-578als.h",
+    "hid/paradise.h",
+    "hid/samsung.h",
+    "hid/usages.h",
+  ]
+  shared = true
+  sources = [
+    "acer12.c",
+    "ambient-light.c",
+    "bma253.c",
+    "buttons.c",
+    "egalax.c",
+    "eyoyo.c",
+    "ft3x27.c",
+    "ft6336.c",
+    "gt92xx.c",
+    "hid.c",
+    "keymaps.c",
+    "ltr-578als.c",
+    "paradise.c",
+    "samsung.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/hwreg/BUILD.gn b/system/ulib/hwreg/BUILD.gn
new file mode 100644
index 0000000..c3b6465
--- /dev/null
+++ b/system/ulib/hwreg/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("hwreg") {
+  sdk = "source"
+  sdk_headers = [
+    "hwreg/bitfields.h",
+    "hwreg/internal.h",
+    "hwreg/mmio.h",
+  ]
+  kernel = true
+  static = true
+  sources = [
+    "printers.cpp",
+  ]
+  deps = [
+    "$zx/kernel/lib/fbl",
+  ]
+}
diff --git a/system/ulib/inet6/BUILD.gn b/system/ulib/inet6/BUILD.gn
new file mode 100644
index 0000000..dfbba54
--- /dev/null
+++ b/system/ulib/inet6/BUILD.gn
@@ -0,0 +1,21 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("inet6") {
+  sources = [
+    "checksum.c",
+    "eth-client.c",
+    "inet6.c",
+    "netifc.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-ethernet:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/system/ulib/inspect/BUILD.gn b/system/ulib/inspect/BUILD.gn
new file mode 100644
index 0000000..80d548b
--- /dev/null
+++ b/system/ulib/inspect/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+library("inspect") {
+  sdk = "source"
+  sdk_headers = [
+    "lib/inspect/block.h",
+    "lib/inspect/heap.h",
+    "lib/inspect/limits.h",
+    "lib/inspect/scanner.h",
+    "lib/inspect/snapshot.h",
+  ]
+  sources = [
+    "heap.cpp",
+    "scanner.cpp",
+    "snapshot.cpp",
+  ]
+  deps = [
+    "$zx/public/gn/config:visibility_hidden",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/syslog",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/inspect/test/BUILD.gn b/system/ulib/inspect/test/BUILD.gn
new file mode 100644
index 0000000..fe77516
--- /dev/null
+++ b/system/ulib/inspect/test/BUILD.gn
@@ -0,0 +1,29 @@
+# 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.
+
+group("test") {
+  testonly = true
+  deps = [
+    ":inspect",
+  ]
+}
+
+test("inspect") {
+  sources = [
+    "heap_tests.cpp",
+    "main.cpp",
+    "scanner_tests.cpp",
+    "snapshot_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/inspect",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/inspector/BUILD.gn b/system/ulib/inspector/BUILD.gn
new file mode 100644
index 0000000..7d066dc
--- /dev/null
+++ b/system/ulib/inspector/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+library("inspector") {
+  sdk = "static"
+  sdk_headers = [ "inspector/inspector.h" ]
+  sources = [
+    "backtrace.cpp",
+    "debug-info.cpp",
+    "dso-list.cpp",
+    "registers.cpp",
+    "utils.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/backtrace-request",
+    "$zx/system/ulib/elf-search",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/backtrace",
+    "$zx/third_party/ulib/ngunwind",
+  ]
+
+  # Compile this with frame pointers so that if we crash
+  # the simplistic unwinder will work.
+  configs -= [ "$zx/public/gn/config:default_frame_pointers" ]
+  configs += [ "$zx/public/gn/config:frame_pointers" ]
+}
diff --git a/system/ulib/intel-hda/BUILD.gn b/system/ulib/intel-hda/BUILD.gn
new file mode 100644
index 0000000..fdc80c5
--- /dev/null
+++ b/system/ulib/intel-hda/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+library("intel-hda") {
+  sources = [
+    "codec-utils/codec-driver-base.cpp",
+    "codec-utils/stream-base.cpp",
+    "utils/codec-caps.cpp",
+    "utils/utils.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  public_deps = [
+    # <intel-hda/codec-utils/stream-base.h> has #include <ddk/protocol/intelhda/codec.h>.
+    "$zx/system/banjo/ddk-protocol-intelhda-codec",
+  ]
+  deps = [
+    "$zx/system/ulib/audio-driver-proto",
+    "$zx/system/ulib/audio-proto-utils",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/dispatcher-pool",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/kvstore/BUILD.gn b/system/ulib/kvstore/BUILD.gn
new file mode 100644
index 0000000..c87e4a5
--- /dev/null
+++ b/system/ulib/kvstore/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+library("kvstore") {
+  sources = [
+    "kvstore.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/third_party/ulib/cksum",
+  ]
+}
+
+test("kvstore-test") {
+  output_name = "kvstore-test"
+  sources = [
+    "kvstore-test.c",
+  ]
+  deps = [
+    ":kvstore",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/unittest",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/ulib/launchpad/BUILD.gn b/system/ulib/launchpad/BUILD.gn
new file mode 100644
index 0000000..209841e
--- /dev/null
+++ b/system/ulib/launchpad/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+library("launchpad") {
+  shared = true
+  sources = [
+    "elf.c",
+    "fdio.c",
+    "launchpad.c",
+    "vmo.c",
+  ]
+  deps = [
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/ldmsg",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/ldmsg/BUILD.gn b/system/ulib/ldmsg/BUILD.gn
new file mode 100644
index 0000000..e750900
--- /dev/null
+++ b/system/ulib/ldmsg/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+library("ldmsg") {
+  sdk = "static"
+  sdk_headers = [ "ldmsg/ldmsg.h" ]
+  sources = [
+    "ldmsg.c",
+  ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+
+  if (toolchain.environment == "user") {
+    # This library is used by libc, so suppress the circularity.
+    configs -= [ "$zx/public/gn/config:user" ]
+  }
+
+  # However, it uses <string.h> for memcpy.
+  deps += [ "$zx/system/ulib/c:headers" ]
+}
diff --git a/system/ulib/libzbi/BUILD.gn b/system/ulib/libzbi/BUILD.gn
new file mode 100644
index 0000000..6704f03
--- /dev/null
+++ b/system/ulib/libzbi/BUILD.gn
@@ -0,0 +1,29 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("libzbi") {
+  sdk = "static"
+  sdk_headers = [
+    "libzbi/zbi-cpp.h",
+    "libzbi/zbi-split.h",
+    "libzbi/zbi-zx.h",
+    "libzbi/zbi.h",
+  ]
+  host = true
+  kernel = true
+  static = true
+  sources = [
+    "zbi.c",
+  ]
+  output_prefix_override = true
+  if (is_fuchsia && !is_kernel) {
+    sources += [ "zbi-zx.cpp" ]
+    deps = [
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/zx",
+    ]
+  }
+}
diff --git a/system/ulib/loader-service/BUILD.gn b/system/ulib/loader-service/BUILD.gn
new file mode 100644
index 0000000..4b46214
--- /dev/null
+++ b/system/ulib/loader-service/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+library("loader-service") {
+  sdk = "static"
+  sdk_headers = [ "loader-service/loader-service.h" ]
+  sources = [
+    "loader-service.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/ldmsg",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/lockdep/BUILD.gn b/system/ulib/lockdep/BUILD.gn
new file mode 100644
index 0000000..e740938
--- /dev/null
+++ b/system/ulib/lockdep/BUILD.gn
@@ -0,0 +1,38 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("lockdep") {
+  sdk = "source"
+  sdk_headers = [
+    "lockdep/common.h",
+    "lockdep/global_reference.h",
+    "lockdep/guard.h",
+    "lockdep/guard_multiple.h",
+    "lockdep/lock_class.h",
+    "lockdep/lock_class_state.h",
+    "lockdep/lock_dependency_set.h",
+    "lockdep/lock_policy.h",
+    "lockdep/lock_traits.h",
+    "lockdep/lockdep.h",
+    "lockdep/runtime_api.h",
+    "lockdep/thread_lock_state.h",
+  ]
+  kernel = true
+  static = true
+  sources = [
+    "lock_dep.cpp",
+  ]
+  public_deps = [
+    "$zx/system/ulib/fbl:headers",
+  ]
+  if (!is_kernel) {
+    configs += [ "$zx/public/gn/config:visibility_hidden" ]
+    deps = [
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/zx",
+    ]
+  }
+}
diff --git a/system/ulib/logger/BUILD.gn b/system/ulib/logger/BUILD.gn
new file mode 100644
index 0000000..dcdfd5a
--- /dev/null
+++ b/system/ulib/logger/BUILD.gn
@@ -0,0 +1,30 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("logger") {
+  sources = [
+    "logger.cpp",
+    "provider.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-logger:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/syslog",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+  public_deps = [
+    # <lib/logger/logger.h> has #include <lib/fidl/cpp/message_buffer.h>.
+    "$zx/system/ulib/fidl",
+
+    # <lib/logger/provider.h> has #include <lib/svc/service.h>.
+    "$zx/system/ulib/svc:headers",
+
+    # <lib/logger/logger.h> has #include <lib/async/cpp/wait.h>.
+    "$zx/system/ulib/async:async-cpp.headers",
+  ]
+}
diff --git a/system/ulib/memfs/BUILD.gn b/system/ulib/memfs/BUILD.gn
new file mode 100644
index 0000000..23870cc
--- /dev/null
+++ b/system/ulib/memfs/BUILD.gn
@@ -0,0 +1,57 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+# libmemfs-cpp.a: The C++ client library.
+#
+# Used to implement the C++ components of Memfs, which
+# can be plugged into ulib/fs.
+library("memfs-cpp") {
+  sdk = "source"
+  sdk_headers = [ "lib/memfs/cpp/vnode.h" ]
+  sources = [
+    "directory.cpp",
+    "dnode.cpp",
+    "file.cpp",
+    "memfs.cpp",
+    "vmo.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+# libmemfs.so: The C ABI client library.
+#
+# Used to create local temporary filesystems.
+library("memfs") {
+  sdk = "shared"
+  sdk_headers = [ "lib/memfs/memfs.h" ]
+  shared = true
+  sources = [
+    "memfs-local.cpp",
+  ]
+  public_deps = [
+    # <lib/memfs/memfs.h> has #include <lib/sync/completion.h>.
+    "$zx/system/ulib/sync:headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    ":memfs-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+  ]
+}
diff --git a/system/ulib/minfs/BUILD.gn b/system/ulib/minfs/BUILD.gn
new file mode 100644
index 0000000..5f91b47
--- /dev/null
+++ b/system/ulib/minfs/BUILD.gn
@@ -0,0 +1,57 @@
+# 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.
+
+library("minfs") {
+  host = true
+  static = true
+  sources = [
+    "allocator.cpp",
+    "bcache.cpp",
+    "fsck.cpp",
+    "inode-manager.cpp",
+    "minfs.cpp",
+    "superblock.cpp",
+    "transaction-limits.cpp",
+    "vnode.cpp",
+    "writeback.cpp",
+  ]
+  if (!is_fuchsia) {
+    sources += [ "host.cpp" ]
+  }
+  public_deps = [
+    "$zx/system/ulib/bitmap:headers",
+    "$zx/system/ulib/fbl:headers",
+    "$zx/system/ulib/fs:headers",
+  ]
+  deps = [
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/zircon-internal",
+  ]
+  if (is_fuchsia) {
+    public_deps += [ "$zx/system/ulib/zx:headers" ]
+    configs += [ "$zx/public/gn/config:visibility_hidden" ]
+    deps += [
+      "$zx/system/fidl/fuchsia-io:c",
+      "$zx/system/fidl/fuchsia-minfs:c",
+      "$zx/system/ulib/async",
+      "$zx/system/ulib/async:async-cpp",
+      "$zx/system/ulib/async:async-default",
+      "$zx/system/ulib/async-loop",
+      "$zx/system/ulib/async-loop:async-loop-cpp",
+      "$zx/system/ulib/block-client",
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/fidl",
+      "$zx/system/ulib/fidl-utils",
+      "$zx/system/ulib/fzl",
+      "$zx/system/ulib/sync",
+      "$zx/system/ulib/trace",
+      "$zx/system/ulib/trace-engine",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/ulib/mini-process/BUILD.gn b/system/ulib/mini-process/BUILD.gn
new file mode 100644
index 0000000..4c1736d
--- /dev/null
+++ b/system/ulib/mini-process/BUILD.gn
@@ -0,0 +1,29 @@
+# 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.
+
+library("mini-process") {
+  testonly = true
+  shared = true
+  sources = [
+    "mini-process.c",
+  ]
+  deps = [
+    ":subprocess",
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+source_set("subprocess") {
+  visibility = [ ":*" ]
+  testonly = true
+  sources = [
+    "subprocess.c",
+  ]
+  configs += [ "$zx/public/gn/config:no_sanitizers" ]
+  deps = [
+    ":headers",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/pci/BUILD.gn b/system/ulib/pci/BUILD.gn
new file mode 100644
index 0000000..3d7a163
--- /dev/null
+++ b/system/ulib/pci/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+library("pci") {
+  sources = [
+    "pio.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/perftest/BUILD.gn b/system/ulib/perftest/BUILD.gn
new file mode 100644
index 0000000..9fc1f78
--- /dev/null
+++ b/system/ulib/perftest/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+library("perftest") {
+  sdk = "source"
+  sdk_headers = [
+    "perftest/perftest.h",
+    "perftest/results.h",
+    "perftest/runner.h",
+  ]
+  testonly = true
+  sources = [
+    "results.cpp",
+    "runner.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/port/BUILD.gn b/system/ulib/port/BUILD.gn
new file mode 100644
index 0000000..bc1b972
--- /dev/null
+++ b/system/ulib/port/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+library("port") {
+  sources = [
+    "port.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/process-launcher/BUILD.gn b/system/ulib/process-launcher/BUILD.gn
new file mode 100644
index 0000000..772f7b8
--- /dev/null
+++ b/system/ulib/process-launcher/BUILD.gn
@@ -0,0 +1,29 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("process-launcher") {
+  sources = [
+    "launcher.cpp",
+    "provider.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-ldsvc:c",
+    "$zx/system/fidl/fuchsia-process:c",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+
+  public_deps = [
+    # <lib/process-launcher/launcher.h> has #include <lib/svc/service.h>.
+    "$zx/system/ulib/svc:headers",
+  ]
+}
diff --git a/system/ulib/region-alloc/BUILD.gn b/system/ulib/region-alloc/BUILD.gn
new file mode 100644
index 0000000..e6575cc
--- /dev/null
+++ b/system/ulib/region-alloc/BUILD.gn
@@ -0,0 +1,20 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("region-alloc") {
+  kernel = true
+  static = true
+  sources = [
+    "region-alloc-c-api.cpp",
+    "region-alloc.cpp",
+  ]
+  if (!is_kernel) {
+    deps = [
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/ulib/rtc/BUILD.gn b/system/ulib/rtc/BUILD.gn
new file mode 100644
index 0000000..a79a36d
--- /dev/null
+++ b/system/ulib/rtc/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+library("rtc") {
+  sources = [
+    "librtc.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/runtime/BUILD.gn b/system/ulib/runtime/BUILD.gn
new file mode 100644
index 0000000..a467ff8
--- /dev/null
+++ b/system/ulib/runtime/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+library("runtime") {
+  sources = [
+    "message.c",
+    "processargs.c",
+    "thread.c",
+  ]
+
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+
+  if (toolchain.environment == "user") {
+    configs -= [ "$zx/public/gn/config:user" ]
+  }
+
+  configs += [
+    "$zx/public/gn/config:visibility_hidden",
+
+    # This code is used in early startup, where safe-stack is not ready yet.
+    "$zx/public/gn/config:no_sanitizers",
+  ]
+}
diff --git a/system/ulib/runtime/processargs.c b/system/ulib/runtime/processargs.c
index 17c505f..23570c9 100644
--- a/system/ulib/runtime/processargs.c
+++ b/system/ulib/runtime/processargs.c
@@ -5,7 +5,6 @@
 #include <runtime/processargs.h>
 
 #include <zircon/syscalls.h>
-#include <string.h>
 
 // TODO(mcgrathr): Is there a better error code to use for marshalling
 // protocol violations?
diff --git a/system/ulib/simplehid/BUILD.gn b/system/ulib/simplehid/BUILD.gn
new file mode 100644
index 0000000..d5b12f8
--- /dev/null
+++ b/system/ulib/simplehid/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+library("simplehid") {
+  sources = []
+  public_deps = [
+    # <lib/simplehid/simplehid.h> has #include <ddktl/protocol/hidbus.h>.
+    "$zx/system/banjo/ddk-protocol-hidbus",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/simplehid/test/BUILD.gn b/system/ulib/simplehid/test/BUILD.gn
new file mode 100644
index 0000000..8ef56e6
--- /dev/null
+++ b/system/ulib/simplehid/test/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+group("test") {
+  testonly = true
+  deps = [
+    ":simplehid",
+  ]
+}
+
+test("simplehid") {
+  sources = [
+    "simplehid-test.cpp",
+  ]
+  deps = [
+    "$zx/system/dev/lib/fake_ddk",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "..",
+  ]
+}
diff --git a/system/ulib/smbios/BUILD.gn b/system/ulib/smbios/BUILD.gn
new file mode 100644
index 0000000..1405f7f
--- /dev/null
+++ b/system/ulib/smbios/BUILD.gn
@@ -0,0 +1,16 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("smbios") {
+  kernel = true
+  static = true
+  sources = [
+    "smbios.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+  ]
+}
diff --git a/system/ulib/svc/BUILD.gn b/system/ulib/svc/BUILD.gn
new file mode 100644
index 0000000..01fa810
--- /dev/null
+++ b/system/ulib/svc/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+library("svc") {
+  sdk = "source"
+  sdk_headers = [
+    "lib/svc/outgoing.h",
+    "lib/svc/service.h",
+  ]
+  sources = [
+    "outgoing.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+  public_deps = [
+    "$zx/system/ulib/async:headers",
+    "$zx/system/ulib/fs:headers",
+    "$zx/system/ulib/zx:headers",
+  ]
+}
diff --git a/system/ulib/sync/BUILD.gn b/system/ulib/sync/BUILD.gn
new file mode 100644
index 0000000..21e51f1
--- /dev/null
+++ b/system/ulib/sync/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+library("sync") {
+  sdk = "static"
+  sdk_headers = [
+    "lib/sync/internal/condition-template.h",
+    "lib/sync/completion.h",
+    "lib/sync/condition.h",
+    "lib/sync/mutex.h",
+  ]
+  sources = [
+    "completion.c",
+    "condition.cpp",
+    "mutex.c",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+  ]
+
+  if (toolchain.environment == "user") {
+    # This library is used by libc, so suppress the circularity.
+    configs -= [ "$zx/public/gn/config:user" ]
+    configs += [
+      # This code is used in early startup, where safe-stack setup is not
+      # ready yet.
+      "$zx/public/gn/config:no_sanitizers",
+      "$zx/system/ulib/c:headers",
+    ]
+  }
+}
diff --git a/system/ulib/syslog/BUILD.gn b/system/ulib/syslog/BUILD.gn
new file mode 100644
index 0000000..a13fb52
--- /dev/null
+++ b/system/ulib/syslog/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+library("syslog") {
+  sdk = "shared"
+  sdk_headers = [
+    "lib/syslog/global.h",
+    "lib/syslog/logger.h",
+    "lib/syslog/wire_format.h",
+  ]
+  shared = true
+  sources = [
+    "fx_logger.cpp",
+    "global.cpp",
+    "logger.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-logger:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/sysmem/BUILD.gn b/system/ulib/sysmem/BUILD.gn
new file mode 100644
index 0000000..ae3b481
--- /dev/null
+++ b/system/ulib/sysmem/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+library("sysmem") {
+  sources = [
+    "sysmem.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysmem:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fidl-async",
+    "$zx/system/ulib/syslog",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+  public_deps = [
+    "$zx/system/ulib/svc:headers",
+  ]
+}
diff --git a/system/ulib/task-utils/BUILD.gn b/system/ulib/task-utils/BUILD.gn
new file mode 100644
index 0000000..b2ebda4
--- /dev/null
+++ b/system/ulib/task-utils/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+library("task-utils") {
+  sources = [
+    "get.c",
+    "walker.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/tee-client-api/BUILD.gn b/system/ulib/tee-client-api/BUILD.gn
new file mode 100644
index 0000000..ff9d8e8
--- /dev/null
+++ b/system/ulib/tee-client-api/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+library("tee-client-api") {
+  sdk = "shared"
+  sdk_headers = []
+  foreach(file,
+          [
+            "tee_client_api.h",
+            "tee-client-types.h",
+          ]) {
+    sdk_headers += [ "lib/tee-client-api/$file" ]
+  }
+  shared = true
+  sources = [
+    "tee-client-api.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-tee:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/test-utils/BUILD.gn b/system/ulib/test-utils/BUILD.gn
new file mode 100644
index 0000000..4eb6afd
--- /dev/null
+++ b/system/ulib/test-utils/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+library("test-utils") {
+  testonly = true
+  shared = true
+  sources = [
+    "test-utils.c",
+  ]
+  deps = [
+    "$zx/system/ulib/backtrace-request",
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/system/ulib/trace-engine/BUILD.gn b/system/ulib/trace-engine/BUILD.gn
new file mode 100644
index 0000000..9a11782
--- /dev/null
+++ b/system/ulib/trace-engine/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+library("trace-engine") {
+  sdk = "shared"
+  sdk_headers = [
+    "trace-engine/buffer_internal.h",
+    "trace-engine/context.h",
+    "trace-engine/fields.h",
+    "trace-engine/handler.h",
+    "trace-engine/instrumentation.h",
+    "trace-engine/types.h",
+  ]
+  shared = true
+  sources = [
+    "context.cpp",
+    "context_api.cpp",
+    "engine.cpp",
+    "nonce.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+
+  # TODO: defines = [ "DDK_TRACING" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/trace-provider/BUILD.gn b/system/ulib/trace-provider/BUILD.gn
new file mode 100644
index 0000000..65167e4
--- /dev/null
+++ b/system/ulib/trace-provider/BUILD.gn
@@ -0,0 +1,55 @@
+# 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.
+
+library("trace-provider") {
+  sdk = "static"
+  sdk_headers = [
+    "trace-provider/fdio_connect.h",
+    "trace-provider/handler.h",
+    "trace-provider/provider.h",
+  ]
+  sources = [
+    "fdio_connect.cpp",
+    "provider_impl.cpp",
+    "provider_with_fdio.cpp",
+    "session.cpp",
+    "trace_provider.fidl.client.cpp",
+    "trace_provider.fidl.h",
+    "trace_provider.fidl.tables.cpp",
+    "utils.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    ":trace-handler",
+    "$zx/system/fidl/fuchsia-tracelink:c.headers",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zx",
+  ]
+}
+
+# For apps that use the trace engine, but not via a trace provider.
+# These are usually test and benchmarking apps.
+# Normal apps are not expected to use this.
+library("trace-handler") {
+  sdk = "static"
+  sdk_headers = []
+  sources = [
+    "handler.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/trace-reader/BUILD.gn b/system/ulib/trace-reader/BUILD.gn
new file mode 100644
index 0000000..a27ea47
--- /dev/null
+++ b/system/ulib/trace-reader/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+library("trace-reader") {
+  sdk = "source"
+  sdk_headers = [
+    "trace-reader/reader.h",
+    "trace-reader/reader_internal.h",
+    "trace-reader/records.h",
+  ]
+  host = true
+  sources = [
+    "reader.cpp",
+    "records.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  public_deps = [
+    # <trace-reader/records.h> has #include <trace-engine/types.h>.
+    "$zx/system/ulib/trace-engine:headers",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace-engine",
+  ]
+  if (is_fuchsia) {
+    sources += [ "reader_internal.cpp" ]
+    deps += [ "$zx/system/ulib/zxcpp" ]
+  }
+}
diff --git a/system/ulib/trace-test-utils/BUILD.gn b/system/ulib/trace-test-utils/BUILD.gn
new file mode 100644
index 0000000..d516968
--- /dev/null
+++ b/system/ulib/trace-test-utils/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+library("trace-test-utils") {
+  sdk = "source"
+  sdk_headers = [
+    "trace-test-utils/compare_records.h",
+    "trace-test-utils/read_records.h",
+    "trace-test-utils/squelch.h",
+  ]
+  testonly = true
+  sources = [
+    "compare_records.cpp",
+    "read_records.cpp",
+    "squelch.cpp",
+  ]
+  deps = [
+    "$zx/public/gn/config:visibility_hidden",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace-reader",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/ulib/trace-vthread/BUILD.gn b/system/ulib/trace-vthread/BUILD.gn
new file mode 100644
index 0000000..73d0a07
--- /dev/null
+++ b/system/ulib/trace-vthread/BUILD.gn
@@ -0,0 +1,45 @@
+# 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.
+
+library("trace-vthread") {
+  sdk = "static"
+  sdk_headers = [
+    "trace-vthread/internal/event_vthread.h",
+    "trace-vthread/event_vthread.h",
+  ]
+  sources = [
+    "event_vthread.cpp",
+  ]
+  deps = [
+    "$zx/public/gn/config:visibility_hidden",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+test("trace-vthread-test") {
+  sources = [
+    "event_vthread_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop.cpp",
+    "$zx/system/ulib/async.cpp",
+    "$zx/system/ulib/async.default",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider.handler",
+    "$zx/system/ulib/trace-reader",
+    "$zx/system/ulib/trace-test-utils",
+    "$zx/system/ulib/trace-vthread",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/trace/BUILD.gn b/system/ulib/trace/BUILD.gn
new file mode 100644
index 0000000..b8380aa
--- /dev/null
+++ b/system/ulib/trace/BUILD.gn
@@ -0,0 +1,36 @@
+# 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.
+
+library("trace") {
+  sdk = "static"
+  sdk_headers = [
+    "trace/internal/event_args.h",
+    "trace/internal/event_common.h",
+    "trace/internal/event_internal.h",
+    "trace/internal/pairs_internal.h",
+    "trace/event.h",
+    "trace/event_args.h",
+    "trace/observer.h",
+  ]
+  sources = [
+    "event.cpp",
+    "observer.cpp",
+  ]
+  public_deps = [
+    # <trace/internal/event_common.h> has #include <trace-engine/instrumentation.h>.
+    "$zx/system/ulib/trace-engine:headers",
+
+    # <trace/internal/event_args.h> has #include <fbl/string_traits.h>.
+    "$zx/system/ulib/fbl:headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/utf_conversion/BUILD.gn b/system/ulib/utf_conversion/BUILD.gn
new file mode 100644
index 0000000..7c6ae4a
--- /dev/null
+++ b/system/ulib/utf_conversion/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+library("utf_conversion") {
+  sdk = "static"
+  sdk_headers = [ "utf_conversion/utf_conversion.h" ]
+  sources = [
+    "utf_conversion.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+  ]
+}
diff --git a/system/ulib/virtio/BUILD.gn b/system/ulib/virtio/BUILD.gn
new file mode 100644
index 0000000..6c74694
--- /dev/null
+++ b/system/ulib/virtio/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+library("virtio") {
+  sdk = "source"
+  sdk_headers = [
+    "virtio/balloon.h",
+    "virtio/block.h",
+    "virtio/console.h",
+    "virtio/gpu.h",
+    "virtio/input.h",
+    "virtio/net.h",
+    "virtio/virtio.h",
+    "virtio/virtio_ids.h",
+    "virtio/virtio_ring.h",
+    "virtio/vsock.h",
+    "virtio/wl.h",
+  ]
+  sources = []
+}
diff --git a/system/ulib/zircon/BUILD.gn b/system/ulib/zircon/BUILD.gn
new file mode 100644
index 0000000..e97a09e
--- /dev/null
+++ b/system/ulib/zircon/BUILD.gn
@@ -0,0 +1,171 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+import("$zx/kernel/syscalls/abigen.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+
+# The vDSO can't be built with instrumentation.
+exclude_tags = [ "instrumented" ]
+
+if (toolchain.tags + exclude_tags - exclude_tags != toolchain.tags ||
+    toolchain.environment != "user") {
+  # References from other toolchains just redirect.  This prevents extra
+  # abigen runs in other toolchains just to get identical generated headers.
+  foreach(target,
+          [
+            "zircon",
+            "headers",
+          ]) {
+    select_toolchain(target) {
+      environment_label = "$zx/public/gn/toolchain:user"
+      deps = [
+        ":$target",
+      ]
+    }
+  }
+} else {
+  # TODO(mcgrathr): Rename the source files and the abigen switch.
+  if (zircon_cpu == "x86") {
+    zircon_cpu = "x86-64"
+    abigen_cpu = "x86"
+  } else if (zircon_cpu == "arm64") {
+    abigen_cpu = "arm"
+  }
+
+  library("zircon") {
+    sdk = "shared"
+    sdk_headers = [ "zircon/status.h" ] # TODO
+    shared = true
+    static = false
+
+    # The vDSO is never installed as a file, only baked into the kernel.
+    install_path = false
+
+    sources = [
+      "data.S",
+      "syscall-wrappers.cpp",
+      "zx_cache_flush.cpp",
+      "zx_channel_call.cpp",
+      "zx_cprng_draw.cpp",
+      "zx_deadline_after.cpp",
+      "zx_status_get_string.cpp",
+      "zx_system_get_dcache_line_size.cpp",
+      "zx_system_get_features.cpp",
+      "zx_system_get_num_cpus.cpp",
+      "zx_system_get_physmem.cpp",
+      "zx_system_get_version.cpp",
+      "zx_ticks_get.cpp",
+      "zx_ticks_per_second.cpp",
+    ]
+
+    configs += [ ":config" ]
+    deps = [
+      ":syscall-asm",
+      "$zx/kernel/lib/vdso:headers",
+    ]
+    public_deps = [
+      ":generated-public-headers",
+    ]
+
+    # Instruct the linker to preserve the hidden alternate entry points.
+    # Note, "./" makes GN realize this is a file rather than a -l switch.
+    libs = [ "./alternates.ld" ]
+
+    if (toolchain.environment == "user") {
+      # This doesn't get normal default deps on libc.
+      configs -= [ "$zx/public/gn/config:user" ]
+      if (is_gcc) {
+        # However, GCC's <x86inrin.h> needs <stdlib.h> indirectly.
+        configs += [ "$zx/system/ulib/c:headers" ]
+      }
+    }
+
+    # This library is on the whitelist for driver() shared library deps.
+    # It doesn't trigger the assert_no_metadata() check, and it prunes the
+    # metadata walk here so our own deps are not subject to the check.
+    metadata = {
+      driver_blacklist = []
+      driver_blacklist_barrier = []
+    }
+  }
+
+  config("config") {
+    visibility = [ ":*" ]
+
+    # This library should not depend on libc.
+    cflags = [ "-ffreestanding" ]
+    public_deps = [
+      "$zx/public/gn/config:no_sanitizers",
+    ]
+
+    include_dirs = [ target_gen_dir ]
+    deps = [
+      ":generate",
+    ]
+  }
+
+  source_set("syscall-asm") {
+    sources = [
+      "syscalls-$zircon_cpu.S",
+      "zx_futex_wake_handle_close_thread_exit-$zircon_cpu.S",
+      "zx_vmar_unmap_handle_close_thread_exit-$zircon_cpu.S",
+    ]
+    configs += [ ":config" ]
+    deps = [
+      "$zx/kernel/syscalls:syscall-abi",
+    ]
+    if (toolchain.environment == "user") {
+      configs -= [ "$zx/public/gn/config:user" ]
+    }
+  }
+
+  config("generated-public-headers") {
+    include_dirs = [ root_gen_dir ]
+    deps = [
+      ":generate",
+    ]
+  }
+
+  abigen("generate") {
+    visibility = [ ":*" ]
+    gen = [
+      # These are the public headers.
+      {
+        args = [ "-user-header" ]
+        outputs = [
+          "$root_gen_dir/zircon/syscalls/definitions.h",
+        ]
+      },
+      {
+        args = [ "-rust" ]
+        outputs = [
+          "$root_gen_dir/zircon/syscalls/definitions.rs",
+        ]
+      },
+
+      # TODO(mcgrathr): Drop the zircon/ prefix from the remaining files.
+      # These are private.
+      {
+        args = [ "-vdso-header" ]
+        outputs = [
+          "$target_gen_dir/zircon/syscall-vdso-definitions.h",
+        ]
+      },
+      {
+        args = [ "-vdso-wrappers" ]
+        outputs = [
+          "$target_gen_dir/zircon/syscall-vdso-wrappers.inc",
+        ]
+      },
+      {
+        args = [ "-${abigen_cpu}-asm" ]
+        outputs = [
+          "$target_gen_dir/zircon/syscalls-$zircon_cpu.S",
+        ]
+      },
+    ]
+  }
+}
diff --git a/system/ulib/zx/BUILD.gn b/system/ulib/zx/BUILD.gn
new file mode 100644
index 0000000..95a5c4a
--- /dev/null
+++ b/system/ulib/zx/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.
+
+assert(is_fuchsia)
+
+library("zx") {
+  sdk = "source"
+  sdk_headers = [
+    "lib/zx/bti.h",
+    "lib/zx/channel.h",
+    "lib/zx/debuglog.h",
+    "lib/zx/event.h",
+    "lib/zx/eventpair.h",
+    "lib/zx/fifo.h",
+    "lib/zx/guest.h",
+    "lib/zx/handle.h",
+    "lib/zx/interrupt.h",
+    "lib/zx/iommu.h",
+    "lib/zx/job.h",
+    "lib/zx/log.h",
+    "lib/zx/object.h",
+    "lib/zx/object_traits.h",
+    "lib/zx/pmt.h",
+    "lib/zx/port.h",
+    "lib/zx/process.h",
+    "lib/zx/profile.h",
+    "lib/zx/resource.h",
+    "lib/zx/socket.h",
+    "lib/zx/suspend_token.h",
+    "lib/zx/task.h",
+    "lib/zx/thread.h",
+    "lib/zx/time.h",
+    "lib/zx/timer.h",
+    "lib/zx/vcpu.h",
+    "lib/zx/vmar.h",
+    "lib/zx/vmo.h",
+  ]
+  sources = [
+    "bti.cpp",
+    "channel.cpp",
+    "debuglog.cpp",
+    "event.cpp",
+    "eventpair.cpp",
+    "fifo.cpp",
+    "guest.cpp",
+    "interrupt.cpp",
+    "iommu.cpp",
+    "job.cpp",
+    "log.cpp",
+    "port.cpp",
+    "process.cpp",
+    "profile.cpp",
+    "resource.cpp",
+    "socket.cpp",
+    "thread.cpp",
+    "timer.cpp",
+    "vcpu.cpp",
+    "vmar.cpp",
+    "vmo.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+  public_deps = [
+    "$zx/system/ulib/zircon:headers",
+  ]
+}
diff --git a/system/ulib/zxcpp/BUILD.gn b/system/ulib/zxcpp/BUILD.gn
new file mode 100644
index 0000000..7ad33da
--- /dev/null
+++ b/system/ulib/zxcpp/BUILD.gn
@@ -0,0 +1,26 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+if (is_kernel) {  # TODO(mcgrathr): just move the code into the kernel proper
+  library("zxcpp") {
+    kernel = true
+    sources = [
+      "new.cpp",
+      "pure_virtual.cpp",
+    ]
+    if (toolchain.environment == "kernel") {
+      # Avoid circularity.
+      configs -= [ "$zx/kernel/vm:headers" ]
+    }
+  }
+} else {
+  # TODO(mcgrathr): Convert users to use the static-libc++ config directly.
+  group("zxcpp") {
+    public_deps = [
+      "$zx/public/gn/config:static-libc++",
+    ]
+  }
+}
diff --git a/system/ulib/zxcrypt/BUILD.gn b/system/ulib/zxcrypt/BUILD.gn
new file mode 100644
index 0000000..f0ed2dc
--- /dev/null
+++ b/system/ulib/zxcrypt/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+library("zxcrypt") {
+  shared = true
+  sources = [
+    "volume.cpp",
+  ]
+  public_deps = [
+    # <zxcrypt/volume.h> has #include <crypto/aead.h>.
+    "$zx/system/ulib/crypto:headers",
+
+    # <zxcrypt/volume.h> has #include <ddk/device.h>.
+    "$zx/system/ulib/ddk:headers",
+  ]
+  configs += [ "$zx/public/gn/config:integer-paranoia" ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-block",
+    "$zx/system/ulib/crypto",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/ulib/zxio/BUILD.gn b/system/ulib/zxio/BUILD.gn
new file mode 100644
index 0000000..435cf3b
--- /dev/null
+++ b/system/ulib/zxio/BUILD.gn
@@ -0,0 +1,35 @@
+# 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.
+
+library("zxio") {
+  sdk = "static"
+  sdk_headers = [
+    "lib/zxio/inception.h",
+    "lib/zxio/null.h",
+    "lib/zxio/ops.h",
+    "lib/zxio/types.h",
+    "lib/zxio/zxio.h",
+  ]
+  sources = [
+    "debuglog.cpp",
+    "null.cpp",
+    "pipe.cpp",
+    "remote.cpp",
+    "socket.cpp",
+    "vmofile.cpp",
+    "zxio.cpp",
+  ]
+  public_deps = [
+    # <lib/zxio/zxio.h> has #include <fuchsia/io/c/fidl.h>.
+    "$zx/system/fidl/fuchsia-io:c.headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-net:c",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxs",
+  ]
+}
diff --git a/system/ulib/zxs/BUILD.gn b/system/ulib/zxs/BUILD.gn
new file mode 100644
index 0000000..943fce7
--- /dev/null
+++ b/system/ulib/zxs/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+library("zxs") {
+  sdk = "static"
+  sdk_headers = [
+    "lib/zxs/protocol.h",
+    "lib/zxs/zxs.h",
+  ]
+  sources = [
+    "zxs.cpp",
+  ]
+  public_deps = [
+    # <lib/zxs/zxs.h> has #include <fuchsia/net/c/fidl.h>.
+    "$zx/system/fidl/fuchsia-net:c.headers",
+  ]
+  configs += [ "$zx/public/gn/config:visibility_hidden" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-net:c",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/ulib/zxtest/BUILD.gn b/system/ulib/zxtest/BUILD.gn
new file mode 100644
index 0000000..1cc05b7
--- /dev/null
+++ b/system/ulib/zxtest/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+library("zxtest") {
+  sdk = "source"
+  sdk_headers = [
+    "zxtest/base/event-broadcaster.h",
+    "zxtest/base/observer.h",
+    "zxtest/base/test-case.h",
+    "zxtest/base/test-driver.h",
+    "zxtest/base/test-info.h",
+    "zxtest/base/test-internal.h",
+    "zxtest/base/test.h",
+    "zxtest/base/types.h",
+  ]
+  sources = [
+    "assertion.cpp",
+    "event-broadcaster.cpp",
+    "reporter.cpp",
+    "runner.cpp",
+    "test-case.cpp",
+    "test-info.cpp",
+    "test.cpp",
+  ]
+  deps = [
+    "$zx/public/gn/config:visibility_hidden",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/ulib/zxtest/test/BUILD.gn b/system/ulib/zxtest/test/BUILD.gn
new file mode 100644
index 0000000..af27dd8
--- /dev/null
+++ b/system/ulib/zxtest/test/BUILD.gn
@@ -0,0 +1,29 @@
+# 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.
+
+group("test") {
+  testonly = true
+  deps = [
+    ":zxtest",
+  ]
+}
+
+test("zxtest") {
+  sources = [
+    "event-broadcaster_test.cpp",
+    "main.cpp",
+    "runner_test.cpp",
+    "test-case_test.cpp",
+    "test-info_test.cpp",
+    "test_test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxtest",
+  ]
+}
diff --git a/system/utest/BUILD.gn b/system/utest/BUILD.gn
new file mode 100644
index 0000000..6288b8b
--- /dev/null
+++ b/system/utest/BUILD.gn
@@ -0,0 +1,203 @@
+# 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("$zx/public/gn/build_api.gni")
+import("$zx/public/gn/config/standard.gni")
+import("$zx/public/gn/toolchain/select_toolchain.gni")
+import("$zx/public/gn/zbi.gni")
+
+if (current_cpu != "") {
+  group("utest") {
+    testonly = true
+
+    deps = [
+      ":host",  # TODO(mcgrathr): reach this differently?
+      "$zx/system/core/bootsvc:bootsvc-tests",
+      "$zx/system/core/virtcon:virtual-console-test",
+      "$zx/system/dev/block/ftl/test",
+      "$zx/system/dev/block/fvm/test",
+      "$zx/system/dev/input/bma253:bma253-test",
+      "$zx/system/dev/lib/usb:usb-wrapper-test",
+      "$zx/system/dev/nand/broker:nand",
+      "$zx/system/dev/nand/nandpart:nandpart-test",
+      "$zx/system/dev/nand/ram-nand:ram-nand-test",
+      "$zx/system/dev/nand/skip-block:skip-block-test",
+      "$zx/system/uapp/disk-pave:install-disk-image-test",
+      "$zx/system/ulib/inspect/test",
+      "$zx/system/ulib/kvstore:kvstore-test",
+      "$zx/system/ulib/pretty:pretty-test",
+      "$zx/system/ulib/simplehid/test",
+      "$zx/system/ulib/tftp:tftp-test",
+      "$zx/system/ulib/zxtest/test",
+      "abigen",
+      "async",
+      "async-loop",
+      "async-testutils",
+      "biotime",
+      "bitmap",
+      "blobfs",
+      "blobfs-bench",
+      "camera",
+      "channel-fatal",
+      "chromeos-disk-setup",
+      "cleanup",
+      "cobalt-client",
+      "compiler",
+      "core",
+      "cprng",
+      "crypto",
+      "ctor",
+      "debugger",
+      "devfs",
+      "digest",
+      "dlfcn",
+      "dlopen-indirect-deps",
+      "driver-tests",
+      "dump1",
+      "elf-search",
+      "entropy",
+      "errno",
+      "ethernet",
+      "events",
+      "evil",
+      "exception",
+      "exit",
+      "fbl",
+      "fdio",
+      "fidl",
+      "fidl-simple",
+      "fpu",
+      "fs",
+      "fs-bench",
+      "fs-management",
+      "fs-test-utils",
+      "fs-vnode",
+      "fuzz-utils",
+      "fvm",
+      "fzl",
+      "getentropy",
+      "handle-alias",
+      "hid-parser",
+      "hypervisor",
+      "int-types",
+      "kernel-unittests",
+      "launchpad",
+      "libfzl",
+      "libgpt",
+      "libhwreg",
+      "libzx",
+      "logger",
+      "memfs",
+      "msd",
+      "namespace",
+      "perftest",
+      "policy",
+      "posixio",
+      "processor",
+      "property",
+      "pty",
+      "qsort",
+      "race-tests",
+      "ramdisk",
+      "region-alloc",
+      "register-state",
+      "rtc-lib",
+      "runtests-utils",
+      "sanitizer",
+      "spawn",
+      "stdio",
+      "sysconf",
+      "sysinfo",
+      "syslog",
+      "task-utils",
+      "thread-initial-state",
+      "thread-state",
+      "time",
+      "timers",
+      "trace",
+      "trace-reader",
+      "usb",
+      "utf_conversion",
+      "util",
+      "vdso",
+      "vdso-base",
+      "vdso-variant",
+      "vmo",
+      "zbi",
+      "zxcrypt",
+      "zxio",
+      "zxs",
+
+      # disabled for now:
+      #"bad-kernel-access",
+
+      # TODO(fuzztest): "edid"
+    ]
+    if (current_cpu == "x64") {
+      deps += [ "x86-umip" ]
+    }
+  }
+
+  # This plus a kernel in deps makes a zbi() that's just for running core-tests.
+  zbi_input("core-tests") {
+    testonly = true
+    type = "cmdline"
+    args = [ "--entry=userboot=bin/core-tests" ]
+    deps = [
+      "$zx/system/utest/core:core-tests",
+    ]
+  }
+
+  group("host-tests") {
+    testonly = true
+    deps = [
+      "banjo-compiler",
+      "fbl",
+      "fidl-compiler",
+      "fit",
+      "fs-host",
+      "fvm-host",
+      "runtests-utils",
+      "trace-reader",
+      "util",
+      "zbi",
+    ]
+  }
+}
+
+# Build the host tests for each host.
+foreach(host, standard_build_hosts) {
+  select_toolchain("host-tests-${host.os}-${host.cpu}") {
+    testonly = true
+    environment_label = "$zx/public/gn/toolchain:host"
+    cpu = host.cpu
+    os = host.os
+    deps = [
+      ":host-tests",
+    ]
+  }
+}
+
+group("host-tests-all-platforms") {
+  testonly = true
+  deps = []
+  foreach(host, standard_build_hosts) {
+    deps += [ ":host-tests-${host.os}-${host.cpu}" ]
+  }
+}
+
+group("host") {
+  testonly = true
+  deps = [
+    ":host-tests-${host_os}-${host_cpu}",
+  ]
+}
+
+build_api_module("host_tests") {
+  testonly = true
+  deps = [
+    ":host-tests-all-platforms",
+  ]
+  data_keys = [ "test_spec" ]
+}
diff --git a/system/utest/abigen/BUILD.gn b/system/utest/abigen/BUILD.gn
new file mode 100644
index 0000000..8c5a109
--- /dev/null
+++ b/system/utest/abigen/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("abigen") {
+  sources = [
+    "abigen.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/async-loop/BUILD.gn b/system/utest/async-loop/BUILD.gn
new file mode 100644
index 0000000..efe0754
--- /dev/null
+++ b/system/utest/async-loop/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+test("async-loop") {
+  sources = [
+    "loop_tests.cpp",
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/async-testutils/BUILD.gn b/system/utest/async-testutils/BUILD.gn
new file mode 100644
index 0000000..686181e
--- /dev/null
+++ b/system/utest/async-testutils/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+test("async-testutils") {
+  sources = [
+    "main.c",
+    "test_loop_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-testutils",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/async/BUILD.gn b/system/utest/async/BUILD.gn
new file mode 100644
index 0000000..7acf4f0
--- /dev/null
+++ b/system/utest/async/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+test("async") {
+  sources = [
+    "default_tests.cpp",
+    "exception_tests.cpp",
+    "main.c",
+    "receiver_tests.cpp",
+    "task_tests.cpp",
+    "time_tests.cpp",
+    "trap_tests.cpp",
+    "wait_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-testutils",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/backtrace-request/BUILD.gn b/system/utest/backtrace-request/BUILD.gn
new file mode 100644
index 0000000..e105b40
--- /dev/null
+++ b/system/utest/backtrace-request/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("backtrace-request") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/backtrace-request",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/bad-kernel-access/BUILD.gn b/system/utest/bad-kernel-access/BUILD.gn
new file mode 100644
index 0000000..10f389c
--- /dev/null
+++ b/system/utest/bad-kernel-access/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("bad-kernel-access") {
+  sources = [
+    "bad-kernel-access.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/banjo-compiler/BUILD.gn b/system/utest/banjo-compiler/BUILD.gn
new file mode 100644
index 0000000..8fef2ae
--- /dev/null
+++ b/system/utest/banjo-compiler/BUILD.gn
@@ -0,0 +1,75 @@
+# 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.
+
+# The generation depends only on the source, so do it only once.
+if (current_toolchain == default_toolchain) {
+  action("gen-examples") {
+    visibility = [ ":examples" ]
+    examples_dir = "$zx/system/host/banjo/examples"
+    outputs = [
+      "$target_gen_dir/examples.cpp",
+    ]
+    sources = [
+      "$examples_dir/alignment.banjo",
+      "$examples_dir/empty.banjo",
+      "$examples_dir/enums.banjo",
+      "$examples_dir/events.banjo",
+      "$examples_dir/example-0.banjo",
+      "$examples_dir/example-1.banjo",
+      "$examples_dir/example-2.banjo",
+      "$examples_dir/example-3.banjo",
+      "$examples_dir/example-4.banjo",
+      "$examples_dir/example-5.banjo",
+      "$examples_dir/example-6.banjo",
+      "$examples_dir/example-7.banjo",
+      "$examples_dir/example-8.banjo",
+      "$examples_dir/example-9.banjo",
+      "$examples_dir/interface-ordinals.banjo",
+      "$examples_dir/library-a/point.banjo",
+      "$examples_dir/library-b/view.banjo",
+      "$examples_dir/simple.banjo",
+      "$examples_dir/tables.banjo",
+      "$examples_dir/test.banjo",
+      "$examples_dir/types.banjo",
+      "testdata/badformat.banjo.noformat",
+      "testdata/goodformat.banjo",
+    ]
+    script = "../fidl-compiler/gen-examples.sh"
+    args = rebase_path(outputs, root_build_dir) +
+           rebase_path(sources, root_build_dir)
+  }
+} else {
+  test("banjo-compiler") {
+    sources = [
+      "dup_attributes_tests.cpp",
+      "flat_ast_tests.cpp",
+      "formatter_unittests.cpp",
+      "json_generator_tests.cpp",
+      "main.cpp",
+      "max_bytes_tests.cpp",
+      "max_handle_tests.cpp",
+      "parsing_tests.cpp",
+      "superinterface_tests.cpp",
+      "using_tests.cpp",
+      "visitor_unittests.cpp",
+    ]
+    deps = [
+      ":examples",
+      "$zx/system/host/banjo/lib",
+      "$zx/system/ulib/unittest",
+    ]
+  }
+
+  source_set("examples") {
+    gen_label = ":gen-examples($default_toolchain)"
+    gen_dir = get_label_info(gen_label, "target_gen_dir")
+    include_dirs = [ "." ]
+    sources = [
+      "$gen_dir/examples.cpp",
+    ]
+    deps = [
+      gen_label,
+    ]
+  }
+}
diff --git a/system/utest/biotime/BUILD.gn b/system/utest/biotime/BUILD.gn
new file mode 100644
index 0000000..10a403d
--- /dev/null
+++ b/system/utest/biotime/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("biotime") {
+  sources = [
+    "biotime-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/bitmap/BUILD.gn b/system/utest/bitmap/BUILD.gn
new file mode 100644
index 0000000..faafa8e
--- /dev/null
+++ b/system/utest/bitmap/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+test("bitmap") {
+  sources = [
+    "main.c",
+    "raw-bitmap-tests.cpp",
+    "rle-bitmap-tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/blobfs-bench/BUILD.gn b/system/utest/blobfs-bench/BUILD.gn
new file mode 100644
index 0000000..610b6cd
--- /dev/null
+++ b/system/utest/blobfs-bench/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+test("blobfs-bench") {
+  sources = [
+    "blobfs-bench.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/blobfs",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fs-test-utils",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/utest/blobfs/BUILD.gn b/system/utest/blobfs/BUILD.gn
new file mode 100644
index 0000000..90f28fb
--- /dev/null
+++ b/system/utest/blobfs/BUILD.gn
@@ -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.
+
+test("blobfs") {
+  test_group = "fs"
+  sources = [
+    "blobfs.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/blobfs",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/lz4",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/utest/camera/BUILD.gn b/system/utest/camera/BUILD.gn
new file mode 100644
index 0000000..25e77d5
--- /dev/null
+++ b/system/utest/camera/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+test("camera") {
+  sources = [
+    "camera.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-camera:c",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/channel-fatal/BUILD.gn b/system/utest/channel-fatal/BUILD.gn
new file mode 100644
index 0000000..211bcb8
--- /dev/null
+++ b/system/utest/channel-fatal/BUILD.gn
@@ -0,0 +1,25 @@
+# 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("$zx/public/gn/toolchain/select_toolchain.gni")
+
+test("channel-fatal") {
+  sources = [
+    "channel-fatal-test.c",
+  ]
+  configs += [ ":vdso_code_config" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+select_toolchain("vdso_code_config") {
+  environment_label = "$zx/kernel"
+  deps = [
+    "$zx/kernel/lib/vdso:vdso-code-header",
+  ]
+}
diff --git a/system/utest/chromeos-disk-setup/BUILD.gn b/system/utest/chromeos-disk-setup/BUILD.gn
new file mode 100644
index 0000000..886f9d4
--- /dev/null
+++ b/system/utest/chromeos-disk-setup/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+test("chromeos-disk-setup") {
+  sources = [
+    "chromeos-disk-setup.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/chromeos-disk-setup",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxio",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/utest/cleanup/BUILD.gn b/system/utest/cleanup/BUILD.gn
new file mode 100644
index 0000000..dfc39d6
--- /dev/null
+++ b/system/utest/cleanup/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("cleanup") {
+  sources = [
+    "cleanup.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/cobalt-client/BUILD.gn b/system/utest/cobalt-client/BUILD.gn
new file mode 100644
index 0000000..f5d8df1
--- /dev/null
+++ b/system/utest/cobalt-client/BUILD.gn
@@ -0,0 +1,36 @@
+# 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.
+
+test("cobalt-client") {
+  sources = [
+    "cobalt_logger_test.cpp",
+    "collector_test.cpp",
+    "counter_test.cpp",
+    "histogram_test.cpp",
+    "metric_options_test.cpp",
+    "test_main.cpp",
+    "timer_test.cpp",
+    "types_internal_test.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-cobalt:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/cobalt-client",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fidl-utils",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/compiler/BUILD.gn b/system/utest/compiler/BUILD.gn
new file mode 100644
index 0000000..cedfc78
--- /dev/null
+++ b/system/utest/compiler/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("compiler") {
+  sources = [
+    "integer.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:integer-paranoia" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/BUILD.gn b/system/utest/core/BUILD.gn
new file mode 100644
index 0000000..090e882
--- /dev/null
+++ b/system/utest/core/BUILD.gn
@@ -0,0 +1,97 @@
+# 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.
+
+# Each subdirectory just provides an eponymous source_set().
+core_tests = [
+  "bad-syscall",
+  "c11-condvar",
+  "c11-mutex",
+  "c11-thread",
+  "channel",
+  "clock",
+  "cookies",
+  "echo",
+  "elf-tls",
+  "event-pair",
+  "fifo",
+  "futex",
+  "handle-close",
+  "handle-info",
+  "handle-transfer",
+  "handle-wait",
+  "job",
+  "memory-mapping",
+  "object-child",
+  "object-info",
+  "port",
+  "process",
+  "pthread",
+  "pthread-barrier",
+  "pthread-tls",
+  "socket",
+  "stack",
+  "sync-completion",
+  "sync-condition",
+  "sync-mutex",
+  "threads",
+  "time",
+  "vmar",
+  "vmo-signal",
+]
+
+# These tests need get_root_resource(), which is only available in the
+# unified core-tests binary.
+unified_only = [
+  "interrupt",
+  "profile",
+  "resource",
+]
+
+group("core") {
+  testonly = true
+  deps = [
+    ":core-tests",  # Together.
+  ]
+  foreach(test, core_tests) {
+    deps += [ ":$test" ]  # And alone.
+  }
+}
+
+# First, build all of those into the standalone core-tests binary.  This
+# can be run directly from userboot with nothing else on the system.
+# It's not a test() so that it won't be run by `runtests`, since that
+# runs all the individual test() binaries created below.
+executable("core-tests") {
+  testonly = true
+  deps = core_tests + unified_only
+  sources = [
+    "main.c",
+  ]
+  deps += [
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+# Next, build each into its own standalone test binary.
+# These all use the same main function.
+source_set("unittest_main") {
+  testonly = true
+  sources = [
+    "unittest_main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/unittest",
+  ]
+}
+
+foreach(test_name, core_tests) {
+  test(test_name) {
+    test_group = "core"
+    deps = [
+      ":unittest_main",
+      test_name,
+    ]
+  }
+}
diff --git a/system/utest/core/bad-syscall/BUILD.gn b/system/utest/core/bad-syscall/BUILD.gn
new file mode 100644
index 0000000..5f7042f
--- /dev/null
+++ b/system/utest/core/bad-syscall/BUILD.gn
@@ -0,0 +1,20 @@
+# 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("$zx/kernel/params.gni")
+
+source_set("bad-syscall") {
+  testonly = true
+  sources = [
+    "bad-syscall.c",
+    "syscall.S",
+  ]
+  defines = [ "KERNEL_ASPACE_BASE=$kernel_aspace_base" ]
+  deps = [
+    "$zx/kernel/syscalls:syscall-abi",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/bad-syscall/bad-syscall.c b/system/utest/core/bad-syscall/bad-syscall.c
index bd7f682..9fdf245 100644
--- a/system/utest/core/bad-syscall/bad-syscall.c
+++ b/system/utest/core/bad-syscall/bad-syscall.c
@@ -52,9 +52,3 @@
 RUN_TEST(bad_access_test)
 RUN_TEST(bad_syscall_num_test)
 END_TEST_CASE(bad_syscall_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/c11-condvar/BUILD.gn b/system/utest/core/c11-condvar/BUILD.gn
new file mode 100644
index 0000000..479ee5b
--- /dev/null
+++ b/system/utest/core/c11-condvar/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("c11-condvar") {
+  testonly = true
+  sources = [
+    "condvar.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/c11-condvar/condvar.c b/system/utest/core/c11-condvar/condvar.c
index a8e1641..fb6524e 100644
--- a/system/utest/core/c11-condvar/condvar.c
+++ b/system/utest/core/c11-condvar/condvar.c
@@ -118,9 +118,3 @@
 RUN_TEST(cnd_test)
 RUN_TEST(cnd_timedwait_timeout_test)
 END_TEST_CASE(cnd_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/c11-mutex/BUILD.gn b/system/utest/core/c11-mutex/BUILD.gn
new file mode 100644
index 0000000..021e0fc
--- /dev/null
+++ b/system/utest/core/c11-mutex/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("c11-mutex") {
+  testonly = true
+  sources = [
+    "mutex.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/c11-mutex/mutex.c b/system/utest/core/c11-mutex/mutex.c
index a616cd7..e15f1f9 100644
--- a/system/utest/core/c11-mutex/mutex.c
+++ b/system/utest/core/c11-mutex/mutex.c
@@ -242,9 +242,3 @@
 RUN_TEST(test_static_initializer)
 RUN_TEST(test_timeout_elapsed)
 END_TEST_CASE(mtx_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/c11-thread/BUILD.gn b/system/utest/core/c11-thread/BUILD.gn
new file mode 100644
index 0000000..b3dcea4
--- /dev/null
+++ b/system/utest/core/c11-thread/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("c11-thread") {
+  testonly = true
+  sources = [
+    "thread.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/c11-thread/thread.c b/system/utest/core/c11-thread/thread.c
index bb30bbb..e260527 100644
--- a/system/utest/core/c11-thread/thread.c
+++ b/system/utest/core/c11-thread/thread.c
@@ -118,9 +118,3 @@
 RUN_TEST(long_name_succeeds)
 RUN_TEST(detach_self_test)
 END_TEST_CASE(c11_thread_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/channel/BUILD.gn b/system/utest/core/channel/BUILD.gn
new file mode 100644
index 0000000..483672d
--- /dev/null
+++ b/system/utest/core/channel/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("channel") {
+  testonly = true
+  sources = [
+    "channel.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/utest/channel-fatal:vdso_code_config",
+  ]
+}
diff --git a/system/utest/core/channel/channel.c b/system/utest/core/channel/channel.c
index 8fbbd12..e74818a 100644
--- a/system/utest/core/channel/channel.c
+++ b/system/utest/core/channel/channel.c
@@ -1067,9 +1067,3 @@
 RUN_TEST(channel_write_different_sizes)
 RUN_TEST(channel_write_takes_all_handles)
 END_TEST_CASE(channel_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/clock/BUILD.gn b/system/utest/core/clock/BUILD.gn
new file mode 100644
index 0000000..ae18ec5
--- /dev/null
+++ b/system/utest/core/clock/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("clock") {
+  testonly = true
+  sources = [
+    "clock.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/clock/clock.c b/system/utest/core/clock/clock.c
index 56a0d9c..8f8ce33 100644
--- a/system/utest/core/clock/clock.c
+++ b/system/utest/core/clock/clock.c
@@ -35,9 +35,3 @@
 BEGIN_TEST_CASE(clock_tests)
 RUN_TEST(clock_monotonic_test)
 END_TEST_CASE(clock_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/cookies/BUILD.gn b/system/utest/core/cookies/BUILD.gn
new file mode 100644
index 0000000..c9d8c8e
--- /dev/null
+++ b/system/utest/core/cookies/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("cookies") {
+  testonly = true
+  sources = [
+    "cookies.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/cookies/cookies.c b/system/utest/core/cookies/cookies.c
index 05f77a0..b2c9a5b 100644
--- a/system/utest/core/cookies/cookies.c
+++ b/system/utest/core/cookies/cookies.c
@@ -99,9 +99,3 @@
 RUN_TEST(test_cookie_actions);
 RUN_TEST(test_cookie_eventpair);
 END_TEST_CASE(cookie_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/echo/BUILD.gn b/system/utest/core/echo/BUILD.gn
new file mode 100644
index 0000000..63ae7cb
--- /dev/null
+++ b/system/utest/core/echo/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("echo") {
+  testonly = true
+  sources = [
+    "echo.c",
+    "message.c",
+    "struct.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/echo/echo.c b/system/utest/core/echo/echo.c
index 2da036f..5dbab1d 100644
--- a/system/utest/core/echo/echo.c
+++ b/system/utest/core/echo/echo.c
@@ -146,10 +146,3 @@
 BEGIN_TEST_CASE(echo_tests)
 RUN_TEST(echo_test)
 END_TEST_CASE(echo_tests)
-
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/elf-tls/BUILD.gn b/system/utest/core/elf-tls/BUILD.gn
new file mode 100644
index 0000000..39eb10b
--- /dev/null
+++ b/system/utest/core/elf-tls/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("elf-tls") {
+  testonly = true
+  sources = [
+    "tls.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/elf-tls/tls.cpp b/system/utest/core/elf-tls/tls.cpp
index fc75f17..c1ffd1c 100644
--- a/system/utest/core/elf-tls/tls.cpp
+++ b/system/utest/core/elf-tls/tls.cpp
@@ -174,9 +174,3 @@
 BEGIN_TEST_CASE(elf_tls_tests)
 RUN_TEST(ExecutableTlsTest)
 END_TEST_CASE(elf_tls_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/event-pair/BUILD.gn b/system/utest/core/event-pair/BUILD.gn
new file mode 100644
index 0000000..37298b5
--- /dev/null
+++ b/system/utest/core/event-pair/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("event-pair") {
+  testonly = true
+  sources = [
+    "event-pair.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/event-pair/event-pair.c b/system/utest/core/event-pair/event-pair.c
index ad6187a..8816a0c 100644
--- a/system/utest/core/event-pair/event-pair.c
+++ b/system/utest/core/event-pair/event-pair.c
@@ -135,9 +135,3 @@
 RUN_TEST(signal_peer_test)
 RUN_TEST(signal_peer_closed_test)
 END_TEST_CASE(eventpair_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/fifo/BUILD.gn b/system/utest/core/fifo/BUILD.gn
new file mode 100644
index 0000000..f49ad97
--- /dev/null
+++ b/system/utest/core/fifo/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("fifo") {
+  testonly = true
+  sources = [
+    "fifo.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/fifo/fifo.c b/system/utest/core/fifo/fifo.c
index ef76514..6d42959 100644
--- a/system/utest/core/fifo/fifo.c
+++ b/system/utest/core/fifo/fifo.c
@@ -166,9 +166,3 @@
 RUN_TEST(peer_closed_test)
 RUN_TEST(options_test)
 END_TEST_CASE(fifo_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/futex/BUILD.gn b/system/utest/core/futex/BUILD.gn
new file mode 100644
index 0000000..eb797a6
--- /dev/null
+++ b/system/utest/core/futex/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("futex") {
+  testonly = true
+  sources = [
+    "futex.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/futex/futex.cpp b/system/utest/core/futex/futex.cpp
index b24e25f..eff10d2 100644
--- a/system/utest/core/futex/futex.cpp
+++ b/system/utest/core/futex/futex.cpp
@@ -560,10 +560,3 @@
 RUN_TEST(TestFutexMisaligned);
 RUN_TEST(TestEventSignaling);
 END_TEST_CASE(futex_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/handle-close/BUILD.gn b/system/utest/core/handle-close/BUILD.gn
new file mode 100644
index 0000000..202e8f6
--- /dev/null
+++ b/system/utest/core/handle-close/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("handle-close") {
+  testonly = true
+  sources = [
+    "handle-close.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/handle-close/handle-close.c b/system/utest/core/handle-close/handle-close.c
index 4f0523e..5a9d9c8 100644
--- a/system/utest/core/handle-close/handle-close.c
+++ b/system/utest/core/handle-close/handle-close.c
@@ -102,9 +102,3 @@
 RUN_TEST(handle_close_many_invalid_test)
 RUN_TEST(handle_close_many_duplicate_test)
 END_TEST_CASE(handle_close_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/handle-info/BUILD.gn b/system/utest/core/handle-info/BUILD.gn
new file mode 100644
index 0000000..eaecf4d
--- /dev/null
+++ b/system/utest/core/handle-info/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("handle-info") {
+  testonly = true
+  sources = [
+    "handle-info.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/handle-info/handle-info.c b/system/utest/core/handle-info/handle-info.c
index dc57613..bff5b42 100644
--- a/system/utest/core/handle-info/handle-info.c
+++ b/system/utest/core/handle-info/handle-info.c
@@ -169,9 +169,3 @@
 RUN_TEST(handle_related_koid_test)
 RUN_TEST(handle_rights_test)
 END_TEST_CASE(handle_info_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/handle-transfer/BUILD.gn b/system/utest/core/handle-transfer/BUILD.gn
new file mode 100644
index 0000000..705c57d
--- /dev/null
+++ b/system/utest/core/handle-transfer/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("handle-transfer") {
+  testonly = true
+  sources = [
+    "handle-transfer.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/handle-transfer/handle-transfer.c b/system/utest/core/handle-transfer/handle-transfer.c
index 2ebed95..4d17b5b 100644
--- a/system/utest/core/handle-transfer/handle-transfer.c
+++ b/system/utest/core/handle-transfer/handle-transfer.c
@@ -144,9 +144,3 @@
 RUN_TEST(handle_transfer_test)
 RUN_TEST(handle_transfer_cancel_wait_test)
 END_TEST_CASE(handle_transfer_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/handle-wait/BUILD.gn b/system/utest/core/handle-wait/BUILD.gn
new file mode 100644
index 0000000..b012b2a
--- /dev/null
+++ b/system/utest/core/handle-wait/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("handle-wait") {
+  testonly = true
+  sources = [
+    "handle-wait.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/handle-wait/handle-wait.c b/system/utest/core/handle-wait/handle-wait.c
index 91d6750..218e078 100644
--- a/system/utest/core/handle-wait/handle-wait.c
+++ b/system/utest/core/handle-wait/handle-wait.c
@@ -286,10 +286,3 @@
 BEGIN_TEST_CASE(handle_wait_tests)
 RUN_TEST(handle_wait_test);
 END_TEST_CASE(handle_wait_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/interrupt/BUILD.gn b/system/utest/core/interrupt/BUILD.gn
new file mode 100644
index 0000000..0b5471b
--- /dev/null
+++ b/system/utest/core/interrupt/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("interrupt") {
+  testonly = true
+  sources = [
+    "interrupt-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/core/job/BUILD.gn b/system/utest/core/job/BUILD.gn
new file mode 100644
index 0000000..cc08efc
--- /dev/null
+++ b/system/utest/core/job/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("job") {
+  testonly = true
+  sources = [
+    "jobs.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/mini-process",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/memory-mapping/BUILD.gn b/system/utest/core/memory-mapping/BUILD.gn
new file mode 100644
index 0000000..cd78061
--- /dev/null
+++ b/system/utest/core/memory-mapping/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("memory-mapping") {
+  testonly = true
+  sources = [
+    "memory-mapping.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/memory-mapping/memory-mapping.cpp b/system/utest/core/memory-mapping/memory-mapping.cpp
index a2e1f0b..cd4a93bf 100644
--- a/system/utest/core/memory-mapping/memory-mapping.cpp
+++ b/system/utest/core/memory-mapping/memory-mapping.cpp
@@ -269,10 +269,3 @@
 RUN_TEST(mmap_flags_test);
 RUN_TEST_ENABLE_CRASH_HANDLER(mprotect_test);
 END_TEST_CASE(memory_mapping_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/object-child/BUILD.gn b/system/utest/core/object-child/BUILD.gn
new file mode 100644
index 0000000..aae4715
--- /dev/null
+++ b/system/utest/core/object-child/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("object-child") {
+  testonly = true
+  sources = [
+    "object-child.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/object-child/object-child.cpp b/system/utest/core/object-child/object-child.cpp
index 5ce966d..e574270 100644
--- a/system/utest/core/object-child/object-child.cpp
+++ b/system/utest/core/object-child/object-child.cpp
@@ -29,9 +29,3 @@
 BEGIN_TEST_CASE(object_get_child_tests)
 RUN_TEST(handle_invalid);
 END_TEST_CASE(object_get_child_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/object-info/BUILD.gn b/system/utest/core/object-info/BUILD.gn
new file mode 100644
index 0000000..40c7890
--- /dev/null
+++ b/system/utest/core/object-info/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("object-info") {
+  testonly = true
+  sources = [
+    "object-info.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/mini-process",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/object-info/object-info.cpp b/system/utest/core/object-info/object-info.cpp
index 939e005..66a5ede 100644
--- a/system/utest/core/object-info/object-info.cpp
+++ b/system/utest/core/object-info/object-info.cpp
@@ -1078,9 +1078,3 @@
 RUN_TEST(handle_stats_control);
 
 END_TEST_CASE(object_info_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/pager/BUILD.gn b/system/utest/core/pager/BUILD.gn
new file mode 100644
index 0000000..c0062f0
--- /dev/null
+++ b/system/utest/core/pager/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+test("pager") {
+  test_group = "core"
+  sources = [
+    "pager.cpp",
+    "test_thread.cpp",
+    "userpager.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/elf-search",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/inspector",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/backtrace",
+    "$zx/third_party/ulib/ngunwind",
+  ]
+}
diff --git a/system/utest/core/port/BUILD.gn b/system/utest/core/port/BUILD.gn
new file mode 100644
index 0000000..0cc68b6
--- /dev/null
+++ b/system/utest/core/port/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("port") {
+  testonly = true
+  sources = [
+    "ports.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/port/ports.cpp b/system/utest/core/port/ports.cpp
index 370ccb3..cf169d3 100644
--- a/system/utest/core/port/ports.cpp
+++ b/system/utest/core/port/ports.cpp
@@ -701,9 +701,3 @@
 RUN_TEST(threads_event_repeat)
 RUN_TEST_LARGE(cancel_stress)
 END_TEST_CASE(port_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/process/BUILD.gn b/system/utest/core/process/BUILD.gn
new file mode 100644
index 0000000..f1d7537
--- /dev/null
+++ b/system/utest/core/process/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("process") {
+  testonly = true
+  sources = [
+    "process.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/mini-process",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/process/process.cpp b/system/utest/core/process/process.cpp
index 78ee0f7..f3f92c4 100644
--- a/system/utest/core/process/process.cpp
+++ b/system/utest/core/process/process.cpp
@@ -682,10 +682,3 @@
 RUN_TEST(suspend_twice_before_creating_threads);
 RUN_TEST(suspend_with_dying_thread);
 END_TEST_CASE(process_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/profile/BUILD.gn b/system/utest/core/profile/BUILD.gn
new file mode 100644
index 0000000..d9b45cf
--- /dev/null
+++ b/system/utest/core/profile/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("profile") {
+  testonly = true
+  sources = [
+    "profile.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/pthread-barrier/BUILD.gn b/system/utest/core/pthread-barrier/BUILD.gn
new file mode 100644
index 0000000..daca1cb
--- /dev/null
+++ b/system/utest/core/pthread-barrier/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("pthread-barrier") {
+  testonly = true
+  sources = [
+    "barrier.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/pthread-barrier/barrier.c b/system/utest/core/pthread-barrier/barrier.c
index e0f9af2..19a63ab 100644
--- a/system/utest/core/pthread-barrier/barrier.c
+++ b/system/utest/core/pthread-barrier/barrier.c
@@ -68,9 +68,3 @@
 BEGIN_TEST_CASE(pthread_barrier_tests)
 RUN_TEST(test_barrier)
 END_TEST_CASE(pthread_barrier_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/pthread-tls/BUILD.gn b/system/utest/core/pthread-tls/BUILD.gn
new file mode 100644
index 0000000..f13a658
--- /dev/null
+++ b/system/utest/core/pthread-tls/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("pthread-tls") {
+  testonly = true
+  sources = [
+    "tls-test.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/pthread-tls/tls-test.c b/system/utest/core/pthread-tls/tls-test.c
index 98c2957..8dd8a8a 100644
--- a/system/utest/core/pthread-tls/tls-test.c
+++ b/system/utest/core/pthread-tls/tls-test.c
@@ -75,9 +75,3 @@
 BEGIN_TEST_CASE(tls_tests)
 RUN_TEST(tls_test)
 END_TEST_CASE(tls_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/pthread/BUILD.gn b/system/utest/core/pthread/BUILD.gn
new file mode 100644
index 0000000..c5802a7
--- /dev/null
+++ b/system/utest/core/pthread/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("pthread") {
+  testonly = true
+  sources = [
+    "pthread.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/pthread/pthread.cpp b/system/utest/core/pthread/pthread.cpp
index 7e47a3a..3998fe1 100644
--- a/system/utest/core/pthread/pthread.cpp
+++ b/system/utest/core/pthread/pthread.cpp
@@ -327,9 +327,3 @@
 RUN_TEST(pthread_getstack_main_thread)
 RUN_TEST(pthread_getstack_other_thread)
 END_TEST_CASE(pthread_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/resource/BUILD.gn b/system/utest/core/resource/BUILD.gn
new file mode 100644
index 0000000..9b4332f
--- /dev/null
+++ b/system/utest/core/resource/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("resource") {
+  testonly = true
+  sources = [
+    "resource.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/core/socket/BUILD.gn b/system/utest/core/socket/BUILD.gn
new file mode 100644
index 0000000..f00c3ec
--- /dev/null
+++ b/system/utest/core/socket/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("socket") {
+  testonly = true
+  sources = [
+    "socket.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/socket/socket.c b/system/utest/core/socket/socket.c
index abcaf6f..ce04e03 100644
--- a/system/utest/core/socket/socket.c
+++ b/system/utest/core/socket/socket.c
@@ -1227,9 +1227,3 @@
 RUN_TEST(socket_share_consumes_on_failure)
 RUN_TEST(socket_signals2)
 END_TEST_CASE(socket_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/stack/BUILD.gn b/system/utest/core/stack/BUILD.gn
new file mode 100644
index 0000000..494286c
--- /dev/null
+++ b/system/utest/core/stack/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("stack") {
+  testonly = true
+  sources = [
+    "stack-test.c",
+  ]
+  cflags = [ "-fstack-protector-all" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/runtime:headers",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/stack/stack-test.c b/system/utest/core/stack/stack-test.c
index d960d04..d975dc6 100644
--- a/system/utest/core/stack/stack-test.c
+++ b/system/utest/core/stack/stack-test.c
@@ -124,9 +124,3 @@
 RUN_TEST(main_thread_stack_tests)
 RUN_TEST(other_thread_stack_tests)
 END_TEST_CASE(stack_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/sync-completion/BUILD.gn b/system/utest/core/sync-completion/BUILD.gn
new file mode 100644
index 0000000..be90517
--- /dev/null
+++ b/system/utest/core/sync-completion/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+source_set("sync-completion") {
+  testonly = true
+  sources = [
+    "completion.cpp",
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/sync-completion/main.c b/system/utest/core/sync-completion/main.c
index ca7ffe1..cafcb19 100644
--- a/system/utest/core/sync-completion/main.c
+++ b/system/utest/core/sync-completion/main.c
@@ -82,9 +82,3 @@
 RUN_TEST(test_completions)
 RUN_TEST(test_timeout)
 END_TEST_CASE(sync_completion_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/sync-condition/BUILD.gn b/system/utest/core/sync-condition/BUILD.gn
new file mode 100644
index 0000000..50195c9
--- /dev/null
+++ b/system/utest/core/sync-condition/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("sync-condition") {
+  testonly = true
+  sources = [
+    "condition.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/sync-condition/condition.cpp b/system/utest/core/sync-condition/condition.cpp
index 73b9ff7..af536a6 100644
--- a/system/utest/core/sync-condition/condition.cpp
+++ b/system/utest/core/sync-condition/condition.cpp
@@ -44,10 +44,3 @@
 RUN_TEST(Condition::condition_test);
 RUN_TEST(Condition::condition_timeout_test);
 END_TEST_CASE(sync_condition_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/sync-mutex/BUILD.gn b/system/utest/core/sync-mutex/BUILD.gn
new file mode 100644
index 0000000..28a7c72
--- /dev/null
+++ b/system/utest/core/sync-mutex/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("sync-mutex") {
+  testonly = true
+  sources = [
+    "mutex.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/sync-mutex/mutex.c b/system/utest/core/sync-mutex/mutex.c
index 357dd10..b6c95ac 100644
--- a/system/utest/core/sync-mutex/mutex.c
+++ b/system/utest/core/sync-mutex/mutex.c
@@ -209,9 +209,3 @@
 RUN_TEST(test_try_mutexes)
 RUN_TEST(test_timeout_elapsed)
 END_TEST_CASE(sync_mutex_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/threads/BUILD.gn b/system/utest/core/threads/BUILD.gn
new file mode 100644
index 0000000..d9699a6
--- /dev/null
+++ b/system/utest/core/threads/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+source_set("threads") {
+  testonly = true
+  sources = [
+    "register-set.cpp",
+    "threads.cpp",
+  ]
+  deps = [
+    ":thread-functions",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+source_set("thread-functions") {
+  testonly = true
+  visibility = [ ":*" ]
+  sources = [
+    "thread-functions/thread-functions.cpp",
+  ]
+  configs += [ "$zx/public/gn/config:no_sanitizers" ]
+  deps = [
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/threads/threads.cpp b/system/utest/core/threads/threads.cpp
index 8f4b23d..62c5d3a 100644
--- a/system/utest/core/threads/threads.cpp
+++ b/system/utest/core/threads/threads.cpp
@@ -1677,9 +1677,3 @@
 // RUN_TEST(TestDebugRegistersValidation);
 
 END_TEST_CASE(threads_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/time/BUILD.gn b/system/utest/core/time/BUILD.gn
new file mode 100644
index 0000000..4417293
--- /dev/null
+++ b/system/utest/core/time/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("time") {
+  testonly = true
+  sources = [
+    "ticks.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/time/ticks.c b/system/utest/core/time/ticks.c
index 92eb3e7..095c34d 100644
--- a/system/utest/core/time/ticks.c
+++ b/system/utest/core/time/ticks.c
@@ -28,9 +28,3 @@
 BEGIN_TEST_CASE(ticks_tests)
 RUN_TEST(elapsed_time_using_ticks)
 END_TEST_CASE(ticks_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/unittest_main.c b/system/utest/core/unittest_main.c
new file mode 100644
index 0000000..825da0f
--- /dev/null
+++ b/system/utest/core/unittest_main.c
@@ -0,0 +1,9 @@
+// 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.
+
+#include <unittest/unittest.h>
+
+int main(int argc, char** argv) {
+    return unittest_run_all_tests(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/system/utest/core/vmar/BUILD.gn b/system/utest/core/vmar/BUILD.gn
new file mode 100644
index 0000000..c13de06
--- /dev/null
+++ b/system/utest/core/vmar/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("vmar") {
+  testonly = true
+  sources = [
+    "vmar.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/vmar/vmar.cpp b/system/utest/core/vmar/vmar.cpp
index d600ebe..a709232 100644
--- a/system/utest/core/vmar/vmar.cpp
+++ b/system/utest/core/vmar/vmar.cpp
@@ -2022,10 +2022,3 @@
 RUN_TEST(partial_unmap_and_write);
 RUN_TEST(partial_unmap_with_vmar_offset);
 END_TEST_CASE(vmar_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
-}
-#endif
diff --git a/system/utest/core/vmo-signal/BUILD.gn b/system/utest/core/vmo-signal/BUILD.gn
new file mode 100644
index 0000000..bd7918e
--- /dev/null
+++ b/system/utest/core/vmo-signal/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("vmo-signal") {
+  testonly = true
+  sources = [
+    "vmo-signal.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/core/vmo-signal/vmo-signal.c b/system/utest/core/vmo-signal/vmo-signal.c
index 99b73fb..552a197 100644
--- a/system/utest/core/vmo-signal/vmo-signal.c
+++ b/system/utest/core/vmo-signal/vmo-signal.c
@@ -130,9 +130,3 @@
 RUN_TEST(vmo_child_signal_clone_test)
 RUN_TEST(vmo_child_signal_map_test)
 END_TEST_CASE(vmo_signal_tests)
-
-#ifndef BUILD_COMBINED_TESTS
-int main(int argc, char** argv) {
-    return unittest_run_all_tests(argc, argv) ? 0 : -1;
-}
-#endif
diff --git a/system/utest/cprng/BUILD.gn b/system/utest/cprng/BUILD.gn
new file mode 100644
index 0000000..7984cee
--- /dev/null
+++ b/system/utest/cprng/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("cprng") {
+  sources = [
+    "cprng.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/crypto/BUILD.gn b/system/utest/crypto/BUILD.gn
new file mode 100644
index 0000000..1ce640c
--- /dev/null
+++ b/system/utest/crypto/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("crypto") {
+  sources = [
+    "main.c",
+    "utils.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/crypto",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/ctor/BUILD.gn b/system/utest/ctor/BUILD.gn
new file mode 100644
index 0000000..59124fc
--- /dev/null
+++ b/system/utest/ctor/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+test("ctor") {
+  sources = [
+    "ctor.cpp",
+  ]
+  deps = [
+    ":dso-ctor",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+
+library("dso-ctor") {
+  visibility = [ ":*" ]
+  testonly = true
+  shared = true
+  sources = [
+    "dso-ctor/dso-ctor.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/debugger/BUILD.gn b/system/utest/debugger/BUILD.gn
new file mode 100644
index 0000000..2490157
--- /dev/null
+++ b/system/utest/debugger/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+test("debugger") {
+  sources = [
+    "debugger.cpp",
+    "utils.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/backtrace-request",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/test-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/system/utest/devfs/BUILD.gn b/system/utest/devfs/BUILD.gn
new file mode 100644
index 0000000..a84045d
--- /dev/null
+++ b/system/utest/devfs/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+test("devfs") {
+  test_group = "fs"
+  sources = [
+    "fdio-tests.cpp",
+    "fidl-tests.cpp",
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/device-enumeration/BUILD.gn b/system/utest/device-enumeration/BUILD.gn
new file mode 100644
index 0000000..fde3b15
--- /dev/null
+++ b/system/utest/device-enumeration/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+test("device-enumeration") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/digest/BUILD.gn b/system/utest/digest/BUILD.gn
new file mode 100644
index 0000000..5ab234c
--- /dev/null
+++ b/system/utest/digest/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+test("digest") {
+  sources = [
+    "digest.cpp",
+    "main.c",
+    "merkle-tree.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/utest/dlfcn/BUILD.gn b/system/utest/dlfcn/BUILD.gn
new file mode 100644
index 0000000..d29e56e
--- /dev/null
+++ b/system/utest/dlfcn/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+test("dlfcn") {
+  sources = [
+    "dlfcn.c",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/fdio",
+
+    # This test uses liblaunchpad.so as the test library to dlopen.
+    # We don't want it to already be there when we call dlopen, but
+    # we use launchpad_vmo_from_file to load it!  So link it statically.
+    "$zx/system/ulib/launchpad:static",
+    "$zx/system/ulib/ldmsg",
+    "$zx/system/ulib/loader-service",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/dlopen-indirect-deps/BUILD.gn b/system/utest/dlopen-indirect-deps/BUILD.gn
new file mode 100644
index 0000000..1919006
--- /dev/null
+++ b/system/utest/dlopen-indirect-deps/BUILD.gn
@@ -0,0 +1,49 @@
+# 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.
+
+test("dlopen-indirect-deps") {
+  sources = [
+    "dlopen-indirect-deps.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+  data_deps = [
+    ":dlopen-indirect-deps-test-module",
+  ]
+}
+
+library("dlopen-indirect-deps-test-module") {
+  visibility = [ ":*" ]
+  testonly = true
+  shared = true
+  sources = [
+    "dlopen-indirect-deps-test-module/test-module.c",
+  ]
+  deps = [
+    ":dlopen-indirect-deps-test-liba",
+  ]
+}
+
+library("dlopen-indirect-deps-test-liba") {
+  visibility = [ ":*" ]
+  testonly = true
+  shared = true
+  sources = [
+    "dlopen-indirect-deps-test-module/dlopen-indirect-deps-test-liba/liba.c",
+  ]
+  deps = [
+    ":dlopen-indirect-deps-test-libb",
+  ]
+}
+
+library("dlopen-indirect-deps-test-libb") {
+  visibility = [ ":*" ]
+  testonly = true
+  shared = true
+  sources = [
+    "dlopen-indirect-deps-test-module/dlopen-indirect-deps-test-liba/dlopen-indirect-deps-test-libb/libb.c",
+  ]
+}
diff --git a/system/utest/driver-tests/BUILD.gn b/system/utest/driver-tests/BUILD.gn
new file mode 100644
index 0000000..f42d90b
--- /dev/null
+++ b/system/utest/driver-tests/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+test("driver-tests") {
+  test_group = "ddk"
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-device-test:c",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/dump1/BUILD.gn b/system/utest/dump1/BUILD.gn
new file mode 100644
index 0000000..768d51c
--- /dev/null
+++ b/system/utest/dump1/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+executable("dump1") {
+  sources = [
+    "dump1.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/elf-search/BUILD.gn b/system/utest/elf-search/BUILD.gn
new file mode 100644
index 0000000..d94bacf
--- /dev/null
+++ b/system/utest/elf-search/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("elf-search") {
+  sources = [
+    "elf-search-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/elf-search",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/entropy/BUILD.gn b/system/utest/entropy/BUILD.gn
new file mode 100644
index 0000000..68bd03a
--- /dev/null
+++ b/system/utest/entropy/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+test("entropy") {
+  sources = [
+    "entropy.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/errno/BUILD.gn b/system/utest/errno/BUILD.gn
new file mode 100644
index 0000000..f8dcc2c
--- /dev/null
+++ b/system/utest/errno/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("errno") {
+  sources = [
+    "errno.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/ethernet/BUILD.gn b/system/utest/ethernet/BUILD.gn
new file mode 100644
index 0000000..5c06300
--- /dev/null
+++ b/system/utest/ethernet/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+test("ethernet") {
+  sources = [
+    "ethernet.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/fidl/fuchsia-hardware-ethernet:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/events/BUILD.gn b/system/utest/events/BUILD.gn
new file mode 100644
index 0000000..517c613
--- /dev/null
+++ b/system/utest/events/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("events") {
+  sources = [
+    "events.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/evil/BUILD.gn b/system/utest/evil/BUILD.gn
new file mode 100644
index 0000000..3d76f1e
--- /dev/null
+++ b/system/utest/evil/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+executable("evil") {
+  output_name = "evil-tests"
+  sources = [
+    "evil.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/exception/BUILD.gn b/system/utest/exception/BUILD.gn
new file mode 100644
index 0000000..9952a3f
--- /dev/null
+++ b/system/utest/exception/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("exception") {
+  sources = [
+    "exception.c",
+  ]
+  deps = [
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/test-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/exit/BUILD.gn b/system/utest/exit/BUILD.gn
new file mode 100644
index 0000000..e4a9c22
--- /dev/null
+++ b/system/utest/exit/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+test("exit") {
+  sources = [
+    "exit.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/utest/fbl/BUILD.gn b/system/utest/fbl/BUILD.gn
new file mode 100644
index 0000000..5ffce1a
--- /dev/null
+++ b/system/utest/fbl/BUILD.gn
@@ -0,0 +1,64 @@
+# 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.
+
+test("fbl") {
+  include_dirs = [ "include" ]
+  sources = [
+    "algorithm_tests.cpp",
+    "array_tests.cpp",
+    "atomic_tests.cpp",
+    "auto_call_tests.cpp",
+    "forward_tests.cpp",
+    "function_tests.cpp",
+    "intrusive_container_tests.cpp",
+    "intrusive_doubly_linked_list_tests.cpp",
+    "intrusive_hash_table_dll_tests.cpp",
+    "intrusive_hash_table_sll_tests.cpp",
+    "intrusive_singly_linked_list_tests.cpp",
+    "intrusive_wavl_tree_tests.cpp",
+    "main.c",
+    "recycler_tests.cpp",
+    "ref_ptr_tests.cpp",
+    "string_buffer_tests.cpp",
+    "string_piece_tests.cpp",
+    "string_printf_tests.cpp",
+    "string_tests.cpp",
+    "string_traits_tests.cpp",
+    "type_info_tests.cpp",
+    "type_support_tests.cpp",
+    "unique_fd_tests.cpp",
+    "unique_free_ptr_tests.cpp",
+    "unique_ptr_tests.cpp",
+    "vector_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/unittest",
+  ]
+
+  if (is_fuchsia) {
+    # These tests won't run on the host. There are two primary reasons for this.
+    #
+    # First, Some of these tests (ref_counted_upgradeable and
+    # slab_allocator) need fbl::Mutex which currently isn't supported on
+    # the host.
+    #
+    # Second, some of these tests make use of the ASSERT_DEATH macro to
+    # ensure that certain actions result in program termination.  Again,
+    # this is not currently suppoted in the host test environment.
+    #
+    # See: TODO(ZX-1053)
+    sources += [
+      "condition_variable_tests.cpp",
+      "ref_counted_tests.cpp",
+      "slab_allocator_tests.cpp",
+    ]
+    deps += [
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/utest/fdio/BUILD.gn b/system/utest/fdio/BUILD.gn
new file mode 100644
index 0000000..3f2b660
--- /dev/null
+++ b/system/utest/fdio/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+test("fdio") {
+  sources = [
+    "fdio_handle_fd.c",
+    "fdio_open_max.c",
+    "fdio_path_canonicalize.c",
+    "fdio_root.c",
+    "fdio_socket.c",
+    "fdio_socketpair.c",
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/fidl-compiler/BUILD.gn b/system/utest/fidl-compiler/BUILD.gn
new file mode 100644
index 0000000..be3c6c9
--- /dev/null
+++ b/system/utest/fidl-compiler/BUILD.gn
@@ -0,0 +1,83 @@
+# 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.
+
+# The generation depends only on the source, so do it only once.
+if (current_toolchain == default_toolchain) {
+  action("gen-examples") {
+    visibility = [ ":examples" ]
+    examples_dir = "$zx/system/host/fidl/examples"
+    outputs = [
+      "$target_gen_dir/examples.cpp",
+    ]
+    sources = [
+      "$examples_dir/alignment.fidl",
+      "$examples_dir/empty.fidl",
+      "$examples_dir/enums.fidl",
+      "$examples_dir/events.fidl",
+      "$examples_dir/example-0.fidl",
+      "$examples_dir/example-1.fidl",
+      "$examples_dir/example-10.fidl",
+      "$examples_dir/example-2.fidl",
+      "$examples_dir/example-3.fidl",
+      "$examples_dir/example-4.fidl",
+      "$examples_dir/example-5.fidl",
+      "$examples_dir/example-6.fidl",
+      "$examples_dir/example-7.fidl",
+      "$examples_dir/example-8.fidl",
+      "$examples_dir/example-9.fidl",
+      "$examples_dir/interface-ordinals.fidl",
+      "$examples_dir/library-a/point.fidl",
+      "$examples_dir/library-b/view.fidl",
+      "$examples_dir/simple.fidl",
+      "$examples_dir/tables.fidl",
+      "$examples_dir/test.fidl",
+      "$examples_dir/types.fidl",
+      "testdata/badformat.fidl.noformat",
+      "testdata/goodformat.fidl",
+    ]
+    script = "gen-examples.sh"
+    args = rebase_path(outputs, root_build_dir) +
+           rebase_path(sources, root_build_dir)
+  }
+} else {
+  test("fidl-compiler") {
+    sources = [
+      "attributes_tests.cpp",
+      "consts_tests.cpp",
+      "enums_tests.cpp",
+      "flat_ast_tests.cpp",
+      "formatter_unittests.cpp",
+      "json_generator_tests.cpp",
+      "main.cpp",
+      "max_bytes_multipass_tests.cpp",
+      "max_bytes_tests.cpp",
+      "max_handle_tests.cpp",
+      "optionals_tests.cpp",
+      "ordinals_tests.cpp",
+      "parsing_tests.cpp",
+      "superinterface_tests.cpp",
+      "table_tests.cpp",
+      "types_tests.cpp",
+      "using_tests.cpp",
+      "visitor_unittests.cpp",
+    ]
+    deps = [
+      ":examples",
+      "$zx/system/host/fidl",
+      "$zx/system/ulib/unittest",
+    ]
+  }
+
+  source_set("examples") {
+    gen_label = ":gen-examples($default_toolchain)"
+    gen_dir = get_label_info(gen_label, "target_gen_dir")
+    include_dirs = [ "." ]
+    sources = [
+      "$gen_dir/examples.cpp",
+    ]
+    deps = [
+      gen_label,
+    ]
+  }
+}
diff --git a/system/utest/fidl-compiler/gen-examples.sh b/system/utest/fidl-compiler/gen-examples.sh
new file mode 100755
index 0000000..b9d645e
--- /dev/null
+++ b/system/utest/fidl-compiler/gen-examples.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# 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.
+
+OUTPUT="$1"
+shift
+
+set -e
+exec > "$OUTPUT"
+
+cat <<\EOF
+// Autogenerated: Do not modify!
+#include <map>
+#include <string>
+#include "examples.h"
+
+std::map<std::string, std::string> Examples::map_ = {
+EOF
+
+for file; do
+
+  echo "    {\"$file\", R\"FIDL("
+  cat "$file"
+  echo ")FIDL\"},"
+done
+
+echo '};'
diff --git a/system/utest/fidl-simple/BUILD.gn b/system/utest/fidl-simple/BUILD.gn
new file mode 100644
index 0000000..9ed480f
--- /dev/null
+++ b/system/utest/fidl-simple/BUILD.gn
@@ -0,0 +1,51 @@
+# 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("$zx/public/gn/fidl.gni")
+
+if (is_fuchsia) {
+  test("fidl-simple") {
+    sources = [
+      "client_tests.c",
+      "fakesocket_tests.cpp",
+      "ldsvc_tests.c",
+      "main.c",
+      "server_tests.c",
+      "spaceship_tests.c",
+      "spaceship_tests.cpp",
+    ]
+    deps = [
+      ":fidl.test.spaceship.c",
+      ":fidl.test.fakesocket.c",
+      "$zx/system/fidl/fuchsia-crash:c",
+      "$zx/system/fidl/fuchsia-ldsvc:c",
+      "$zx/system/fidl/fuchsia-mem:c",
+      "$zx/system/ulib/async",
+      "$zx/system/ulib/async:async-default",
+      "$zx/system/ulib/async-loop",
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/fidl",
+      "$zx/system/ulib/fidl-utils",
+      "$zx/system/ulib/unittest",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
+
+fidl_library("fidl.test.spaceship") {
+  visibility = [ ":*" ]
+  sources = [
+    "spaceship.fidl",
+  ]
+}
+
+fidl_library("fidl.test.fakesocket") {
+  visibility = [ ":*" ]
+  sources = [
+    "fakesocket.fidl",
+  ]
+}
diff --git a/system/utest/fidl/BUILD.gn b/system/utest/fidl/BUILD.gn
new file mode 100644
index 0000000..f1638c4
--- /dev/null
+++ b/system/utest/fidl/BUILD.gn
@@ -0,0 +1,29 @@
+# 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.
+
+test("fidl") {
+  sources = [
+    "abi_tests.cpp",
+    "cpp_types_tests.cpp",
+    "decoding_tests.cpp",
+    "encoding_tests.cpp",
+    "fidl_coded_types.cpp",
+    "formatting_tests.cpp",
+    "handle_closing_tests.cpp",
+    "llcpp_types_tests.cpp",
+    "main.c",
+    "message_tests.cpp",
+    "validating_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/fit/BUILD.gn b/system/utest/fit/BUILD.gn
new file mode 100644
index 0000000..4caf20c
--- /dev/null
+++ b/system/utest/fit/BUILD.gn
@@ -0,0 +1,40 @@
+# 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.
+
+test("fit") {
+  sources = [
+    "bridge_tests.cpp",
+    "defer_tests.cpp",
+    "examples/function_example1.cpp",
+    "examples/function_example2.cpp",
+    "examples/promise_example1.cpp",
+    "examples/promise_example2.cpp",
+    "examples/utils.cpp",
+    "function_tests.cpp",
+    "future_tests.cpp",
+    "main.c",
+    "nullable_tests.cpp",
+    "optional_tests.cpp",
+    "pending_task_tests.cpp",
+    "promise_tests.cpp",
+    "result_tests.cpp",
+    "scheduler_tests.cpp",
+    "scope_tests.cpp",
+    "sequencer_tests.cpp",
+    "single_threaded_executor_tests.cpp",
+    "suspended_task_tests.cpp",
+    "traits_tests.cpp",
+    "variant_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fit",
+    "$zx/system/ulib/unittest",
+  ]
+  if (is_fuchsia) {
+    deps += [
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/utest/fpu/BUILD.gn b/system/utest/fpu/BUILD.gn
new file mode 100644
index 0000000..f0faa6d
--- /dev/null
+++ b/system/utest/fpu/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+test("fpu") {
+  sources = [
+    "fputest.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/utest/fpu/fputest.c b/system/utest/fpu/fputest.c
index 21222f5..0490a80 100644
--- a/system/utest/fpu/fputest.c
+++ b/system/utest/fpu/fputest.c
@@ -10,7 +10,6 @@
 #include <unistd.h>
 
 #include <zircon/compiler.h>
-#include <zircon/syscalls.h>
 #include <unittest/unittest.h>
 
 #define THREAD_COUNT 8
diff --git a/system/utest/fs-bench/BUILD.gn b/system/utest/fs-bench/BUILD.gn
new file mode 100644
index 0000000..50c294b
--- /dev/null
+++ b/system/utest/fs-bench/BUILD.gn
@@ -0,0 +1,38 @@
+# 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.
+
+test("fs-bench") {
+  test_group = "fs"
+  sources = [
+    "fs-bench.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fs-test-utils",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/fs-host/BUILD.gn b/system/utest/fs-host/BUILD.gn
new file mode 100644
index 0000000..a13dd0e
--- /dev/null
+++ b/system/utest/fs-host/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+test("fs-host") {
+  sources = [
+    "main.cpp",
+    "test-basic.cpp",
+    "test-directory.cpp",
+    "test-maxfile.cpp",
+    "test-rw-workers.cpp",
+    "test-sparse.cpp",
+    "test-truncate.cpp",
+    "util.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/minfs",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon-internal",
+  ]
+}
diff --git a/system/utest/fs-management/BUILD.gn b/system/utest/fs-management/BUILD.gn
new file mode 100644
index 0000000..59b6082
--- /dev/null
+++ b/system/utest/fs-management/BUILD.gn
@@ -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.
+
+test("fs-management") {
+  test_group = "fs"
+  sources = [
+    "fs-management.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fs-test-utils",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/fs-test-utils/BUILD.gn b/system/utest/fs-test-utils/BUILD.gn
new file mode 100644
index 0000000..4945ec6
--- /dev/null
+++ b/system/utest/fs-test-utils/BUILD.gn
@@ -0,0 +1,41 @@
+# 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.
+
+test("fs-test-utils") {
+  test_group = "fs"
+  sources = [
+    "fixture_test.cpp",
+    "main.cpp",
+    "perftest_test.cpp",
+    "unittest_test.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fs-test-utils",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/fs-vnode/BUILD.gn b/system/utest/fs-vnode/BUILD.gn
new file mode 100644
index 0000000..2787b8f
--- /dev/null
+++ b/system/utest/fs-vnode/BUILD.gn
@@ -0,0 +1,35 @@
+# 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.
+
+test("fs-vnode") {
+  sources = [
+    "lazy-dir-tests.cpp",
+    "main.c",
+    "pseudo-dir-tests.cpp",
+    "pseudo-file-tests.cpp",
+    "remote-dir-tests.cpp",
+    "service-tests.cpp",
+    "teardown-tests.cpp",
+    "vmo-file-tests.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/fs/BUILD.gn b/system/utest/fs/BUILD.gn
new file mode 100644
index 0000000..4d27990
--- /dev/null
+++ b/system/utest/fs/BUILD.gn
@@ -0,0 +1,96 @@
+# 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.
+
+test("fs") {
+  test_group = "fs"
+  sources = [
+    "filesystems.cpp",
+    "main.cpp",
+    "metrics_test.cpp",
+    "misc.c",
+    "test-access.cpp",
+    "test-append.cpp",
+    "test-attr.c",
+    "test-basic.c",
+    "test-clone.cpp",
+    "test-directory.cpp",
+    "test-dot-dot.c",
+    "test-fcntl.cpp",
+    "test-link.c",
+    "test-lseek.cpp",
+    "test-maxfile.cpp",
+    "test-minfs.cpp",
+    "test-mmap.cpp",
+    "test-overflow.c",
+    "test-persist.cpp",
+    "test-random-op.c",
+    "test-realpath.cpp",
+    "test-rename.c",
+    "test-resize.cpp",
+    "test-rw-workers.c",
+    "test-rw.cpp",
+    "test-sparse.cpp",
+    "test-sync.c",
+    "test-threading.cpp",
+    "test-truncate.cpp",
+    "test-unlink.cpp",
+    "test-watcher.cpp",
+    "wrap.c",
+  ]
+
+  wrap_symbols = [
+    "chdir",
+    "link",
+    "mkdir",
+    "open",
+    "opendir",
+    "realpath",
+    "remove",
+    "rename",
+    "renameat",
+    "rmdir",
+    "stat",
+    "symlink",
+    "truncate",
+    "unlink",
+    "utimes",
+  ]
+  ldflags = []
+  foreach(symbol, wrap_symbols) {
+    ldflags += [ "-Wl,--wrap,$symbol" ]
+  }
+
+  deps = [
+    "$zx/system/fidl/fuchsia-cobalt:c",
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-mem:c",
+    "$zx/system/fidl/fuchsia-minfs:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/cobalt-client",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/minfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zircon-internal",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/utest/fuzz-utils/BUILD.gn b/system/utest/fuzz-utils/BUILD.gn
new file mode 100644
index 0000000..c0bf4dc
--- /dev/null
+++ b/system/utest/fuzz-utils/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+test("fuzz-utils") {
+  sources = [
+    "fixture.cpp",
+    "fuzzer-fixture.cpp",
+    "main.cpp",
+    "test-fuzzer.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fuzz-utils",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/fvm-host/BUILD.gn b/system/utest/fvm-host/BUILD.gn
new file mode 100644
index 0000000..bea976c
--- /dev/null
+++ b/system/utest/fvm-host/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+test("fvm-host") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fvm-host",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/utest/fvm/BUILD.gn b/system/utest/fvm/BUILD.gn
new file mode 100644
index 0000000..26fb82f
--- /dev/null
+++ b/system/utest/fvm/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+test("fvm") {
+  sources = [
+    "fvm.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/bitmap",
+    "$zx/system/ulib/blobfs",
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/minfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/cksum",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/utest/fzl/BUILD.gn b/system/utest/fzl/BUILD.gn
new file mode 100644
index 0000000..ccf98fb
--- /dev/null
+++ b/system/utest/fzl/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+test("fzl") {
+  sources = [
+    "fdio.cpp",
+    "main.c",
+    "memory_probe_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/getentropy/BUILD.gn b/system/utest/getentropy/BUILD.gn
new file mode 100644
index 0000000..14eafc1
--- /dev/null
+++ b/system/utest/getentropy/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("getentropy") {
+  sources = [
+    "getentropy.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/handle-alias/BUILD.gn b/system/utest/handle-alias/BUILD.gn
new file mode 100644
index 0000000..1defc82
--- /dev/null
+++ b/system/utest/handle-alias/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("handle-alias") {
+  sources = [
+    "handle-alias.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/hid-parser/BUILD.gn b/system/utest/hid-parser/BUILD.gn
new file mode 100644
index 0000000..69102b4
--- /dev/null
+++ b/system/utest/hid-parser/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("hid-parser") {
+  sources = [
+    "hid-parser-test.cpp",
+    "hid-report-data.cpp",
+    "hid-utest-data.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/hid-parser",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
+# TODO(fuzztest): sources=["hid-parser-fuzztest.cpp"]
diff --git a/system/utest/hid/BUILD.gn b/system/utest/hid/BUILD.gn
new file mode 100644
index 0000000..e5ebeed
--- /dev/null
+++ b/system/utest/hid/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+test("hid") {
+  sources = [
+    "hid-test.cpp",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-hidbus",
+    "$zx/system/fidl/fuchsia-hardware-input:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/driver",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/hid-parser",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/hypervisor/BUILD.gn b/system/utest/hypervisor/BUILD.gn
new file mode 100644
index 0000000..d09ad48
--- /dev/null
+++ b/system/utest/hypervisor/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("hypervisor") {
+  sources = [
+    "${zircon_cpu}.S",
+    "guest.cpp",
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/int-types/BUILD.gn b/system/utest/int-types/BUILD.gn
new file mode 100644
index 0000000..f8cabae
--- /dev/null
+++ b/system/utest/int-types/BUILD.gn
@@ -0,0 +1,27 @@
+# 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.
+
+test("int-types") {
+  sources = [
+    "int-types.c",
+    "int-types.cpp",
+    "wchar-type.c",
+    "wchar-type.cpp",
+  ]
+  configs += [ ":config" ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+}
+
+config("config") {
+  visibility = [ ":*" ]
+
+  # The C file here uses a macro to detect whether a type is signed, by
+  # comparing the values of -1 and 0. This leads to complaints about
+  # vacuously true comparisons, which we don't care about.
+  cflags = [ "-Wno-type-limits" ]
+}
diff --git a/system/utest/kernel-unittests/BUILD.gn b/system/utest/kernel-unittests/BUILD.gn
new file mode 100644
index 0000000..4c6b871
--- /dev/null
+++ b/system/utest/kernel-unittests/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+test("kernel-unittests") {
+  sources = [
+    "kernel-unittests.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/launchpad/BUILD.gn b/system/utest/launchpad/BUILD.gn
new file mode 100644
index 0000000..dad2d61
--- /dev/null
+++ b/system/utest/launchpad/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+test("launchpad") {
+  sources = [
+    "launchpad.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/libfzl/BUILD.gn b/system/utest/libfzl/BUILD.gn
new file mode 100644
index 0000000..d4b7eda
--- /dev/null
+++ b/system/utest/libfzl/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+test("libfzl") {
+  sources = [
+    "fzl-test.cpp",
+    "main.c",
+    "owned-vmo-mapper-tests.cpp",
+    "resizeable-vmo-mapper-tests.cpp",
+    "vmo-pool-tests.cpp",
+    "vmo-probe.cpp",
+    "vmo-vmar-tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/libgpt/BUILD.gn b/system/utest/libgpt/BUILD.gn
new file mode 100644
index 0000000..7075c56
--- /dev/null
+++ b/system/utest/libgpt/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+test("libgpt") {
+  sources = [
+    "libgpt-tests.cpp",
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/third_party/ulib/cksum",
+  ]
+}
diff --git a/system/utest/libhwreg/BUILD.gn b/system/utest/libhwreg/BUILD.gn
new file mode 100644
index 0000000..da27d3b
--- /dev/null
+++ b/system/utest/libhwreg/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("libhwreg") {
+  sources = [
+    "bitfields-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/ddktl",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/hwreg",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/libzx/BUILD.gn b/system/utest/libzx/BUILD.gn
new file mode 100644
index 0000000..74259e5
--- /dev/null
+++ b/system/utest/libzx/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("libzx") {
+  sources = [
+    "traits.cpp",
+    "zx-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/logger/BUILD.gn b/system/utest/logger/BUILD.gn
new file mode 100644
index 0000000..fb6700e
--- /dev/null
+++ b/system/utest/logger/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+test("logger") {
+  sources = [
+    "test.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-logger:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fidl",
+    "$zx/system/ulib/logger",
+    "$zx/system/ulib/syslog",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/memfs/BUILD.gn b/system/utest/memfs/BUILD.gn
new file mode 100644
index 0000000..a3f6809
--- /dev/null
+++ b/system/utest/memfs/BUILD.gn
@@ -0,0 +1,33 @@
+# 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.
+
+test("memfs") {
+  test_group = "fs"
+  sources = [
+    "fidl-tests.cpp",
+    "main.c",
+    "memfs-tests.cpp",
+    "vmofile-tests.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/memfs",
+    "$zx/system/ulib/memfs:memfs-cpp",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/msd/BUILD.gn b/system/utest/msd/BUILD.gn
new file mode 100644
index 0000000..9804c18
--- /dev/null
+++ b/system/utest/msd/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+executable("msd") {
+  output_name = "msd-test"
+  testonly = true
+  sources = [
+    "msd.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/namespace/BUILD.gn b/system/utest/namespace/BUILD.gn
new file mode 100644
index 0000000..f662dac
--- /dev/null
+++ b/system/utest/namespace/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("namespace") {
+  sources = [
+    "namespace-test.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/perftest/BUILD.gn b/system/utest/perftest/BUILD.gn
new file mode 100644
index 0000000..4b8b665
--- /dev/null
+++ b/system/utest/perftest/BUILD.gn
@@ -0,0 +1,38 @@
+# 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.
+
+test("perftest") {
+  sources = [
+    "clock-test.cpp",
+    "handle-creation-test.cpp",
+    "malloc-test.cpp",
+    "memcpy-test.cpp",
+    "mutex-test.cpp",
+    "null-test.cpp",
+    "process-test.cpp",
+    "results-test.cpp",
+    "runner-test.cpp",
+    "sleep-test.cpp",
+    "syscalls-test.cpp",
+    "timer-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/perftest",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/platform-bus/BUILD.gn b/system/utest/platform-bus/BUILD.gn
new file mode 100644
index 0000000..675b076
--- /dev/null
+++ b/system/utest/platform-bus/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+test("platform-bus") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/devmgr-integration-test",
+    "$zx/system/ulib/devmgr-launcher",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/libzbi",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/policy/BUILD.gn b/system/utest/policy/BUILD.gn
new file mode 100644
index 0000000..6fba038
--- /dev/null
+++ b/system/utest/policy/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+test("policy") {
+  sources = [
+    "job-policy.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/mini-process",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/posixio/BUILD.gn b/system/utest/posixio/BUILD.gn
new file mode 100644
index 0000000..bd48163
--- /dev/null
+++ b/system/utest/posixio/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("posixio") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/processor/BUILD.gn b/system/utest/processor/BUILD.gn
new file mode 100644
index 0000000..53b7563
--- /dev/null
+++ b/system/utest/processor/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("processor") {
+  sources = [
+    "processor.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/property/BUILD.gn b/system/utest/property/BUILD.gn
new file mode 100644
index 0000000..ec96001
--- /dev/null
+++ b/system/utest/property/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+test("property") {
+  sources = [
+    "property.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/test-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/pty/BUILD.gn b/system/utest/pty/BUILD.gn
new file mode 100644
index 0000000..f21c5cb
--- /dev/null
+++ b/system/utest/pty/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+test("pty") {
+  sources = [
+    "pty-test.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/utest/qsort/BUILD.gn b/system/utest/qsort/BUILD.gn
new file mode 100644
index 0000000..5fd7828
--- /dev/null
+++ b/system/utest/qsort/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+test("qsort") {
+  sources = [
+    "qsort.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/utest/race-tests/BUILD.gn b/system/utest/race-tests/BUILD.gn
new file mode 100644
index 0000000..10c73a7
--- /dev/null
+++ b/system/utest/race-tests/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("race-tests") {
+  sources = [
+    "race-tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/ramdisk/BUILD.gn b/system/utest/ramdisk/BUILD.gn
new file mode 100644
index 0000000..e5471cb
--- /dev/null
+++ b/system/utest/ramdisk/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+test("ramdisk") {
+  sources = [
+    "main.c",
+    "ramdisk.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/region-alloc/BUILD.gn b/system/utest/region-alloc/BUILD.gn
new file mode 100644
index 0000000..586d72b
--- /dev/null
+++ b/system/utest/region-alloc/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("region-alloc") {
+  sources = [
+    "main.c",
+    "region-alloc-c-api.c",
+    "region-alloc.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/region-alloc",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/register-state/BUILD.gn b/system/utest/register-state/BUILD.gn
new file mode 100644
index 0000000..0259eb8
--- /dev/null
+++ b/system/utest/register-state/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("register-state") {
+  sources = [
+    "register-state-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/rtc-lib/BUILD.gn b/system/utest/rtc-lib/BUILD.gn
new file mode 100644
index 0000000..817678f
--- /dev/null
+++ b/system/utest/rtc-lib/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+test("rtc-lib") {
+  sources = [
+    "rtc.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-rtc:c",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/rtc",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/runtests-utils/BUILD.gn b/system/utest/runtests-utils/BUILD.gn
new file mode 100644
index 0000000..2760a8e
--- /dev/null
+++ b/system/utest/runtests-utils/BUILD.gn
@@ -0,0 +1,47 @@
+# 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.
+
+test("runtests-utils") {
+  sources = [
+    "runtests-utils-test-utils.cpp",
+    "runtests-utils-test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/runtests-utils",
+    "$zx/system/ulib/unittest",
+  ]
+  if (is_fuchsia) {
+    sources += [
+      "fuchsia-run-test.cpp",
+      "fuchsia-test-main.cpp",
+      "log-exporter-test.cpp",
+    ]
+    deps += [ "$zx/system/ulib/memfs" ]
+    data_deps = [
+      ":publish-data-helper",
+    ]
+  } else {
+    sources += [ "posix-test-main.cpp" ]
+  }
+}
+
+if (is_fuchsia) {
+  executable("publish-data-helper") {
+    testonly = true
+    visibility = [ ":*" ]
+    sources = [
+      "helper/publish-data-helper.c",
+    ]
+    deps = [
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/unittest",
+      "$zx/system/ulib/zircon",
+    ]
+
+    # TODO: Don't instrument the helper until we have a way to route sinks
+    # from the inner runtests instance to the outer one so they make it
+    # into summary.json.
+  }
+}
diff --git a/system/utest/sanitizer/BUILD.gn b/system/utest/sanitizer/BUILD.gn
new file mode 100644
index 0000000..fd7f6e0
--- /dev/null
+++ b/system/utest/sanitizer/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+test("sanitizer") {
+  test_group = "libc"
+  sources = [
+    "sanitizer-utils.c",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/ldmsg",
+    "$zx/system/ulib/loader-service",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/spawn/BUILD.gn b/system/utest/spawn/BUILD.gn
new file mode 100644
index 0000000..dd855a4
--- /dev/null
+++ b/system/utest/spawn/BUILD.gn
@@ -0,0 +1,44 @@
+# 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.
+
+test("spawn") {
+  sources = [
+    "spawn.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+  data_deps = [
+    ":spawn-child",
+    ":spawn-launcher",
+  ]
+}
+
+executable("spawn-child") {
+  visibility = [ ":*" ]
+  testonly = true
+  sources = [
+    "child.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
+
+executable("spawn-launcher") {
+  visibility = [ ":*" ]
+  testonly = true
+  sources = [
+    "launcher.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/stdio/BUILD.gn b/system/utest/stdio/BUILD.gn
new file mode 100644
index 0000000..a171649
--- /dev/null
+++ b/system/utest/stdio/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("stdio") {
+  sources = [
+    "stdio.c",
+    "util.c",
+  ]
+  deps = [
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/sysconf/BUILD.gn b/system/utest/sysconf/BUILD.gn
new file mode 100644
index 0000000..544bff6
--- /dev/null
+++ b/system/utest/sysconf/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+test("sysconf") {
+  sources = [
+    "sysconf.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+  ]
+}
diff --git a/system/utest/sysinfo/BUILD.gn b/system/utest/sysinfo/BUILD.gn
new file mode 100644
index 0000000..568e0e1
--- /dev/null
+++ b/system/utest/sysinfo/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+test("sysinfo") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/syslog/BUILD.gn b/system/utest/syslog/BUILD.gn
new file mode 100644
index 0000000..150f927
--- /dev/null
+++ b/system/utest/syslog/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("syslog") {
+  sources = [
+    "main.c",
+    "syslog_socket_tests.cpp",
+    "syslog_tests.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/syslog",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/task-utils/BUILD.gn b/system/utest/task-utils/BUILD.gn
new file mode 100644
index 0000000..30d8fef
--- /dev/null
+++ b/system/utest/task-utils/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+test("task-utils") {
+  sources = [
+    "walker.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/task-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/thread-initial-state/BUILD.gn b/system/utest/thread-initial-state/BUILD.gn
new file mode 100644
index 0000000..80180c8
--- /dev/null
+++ b/system/utest/thread-initial-state/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("thread-initial-state") {
+  sources = [
+    "init-state.c",
+  ]
+  if (current_cpu == "x64") {
+    sources += [ "x86-64.S" ]
+  } else {
+    sources += [ "${zircon_cpu}.S" ]
+  }
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/thread-state/BUILD.gn b/system/utest/thread-state/BUILD.gn
new file mode 100644
index 0000000..54e9fca
--- /dev/null
+++ b/system/utest/thread-state/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("thread-state") {
+  sources = [
+    "thread-state.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-sysinfo:c",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/test-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/time/BUILD.gn b/system/utest/time/BUILD.gn
new file mode 100644
index 0000000..872a3f0
--- /dev/null
+++ b/system/utest/time/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("time") {
+  sources = [
+    "time_test.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/timers/BUILD.gn b/system/utest/timers/BUILD.gn
new file mode 100644
index 0000000..6e7301c
--- /dev/null
+++ b/system/utest/timers/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+test("timers") {
+  sources = [
+    "timers.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/trace-reader/BUILD.gn b/system/utest/trace-reader/BUILD.gn
new file mode 100644
index 0000000..6e140fc
--- /dev/null
+++ b/system/utest/trace-reader/BUILD.gn
@@ -0,0 +1,25 @@
+# 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.
+
+test("trace-reader") {
+  sources = [
+    "main.c",
+    "reader_tests.cpp",
+    "records_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-reader",
+    "$zx/system/ulib/unittest",
+  ]
+  if (is_fuchsia) {
+    deps += [
+      "$zx/system/ulib/fdio",
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/zx",
+      "$zx/system/ulib/zxcpp",
+    ]
+  }
+}
diff --git a/system/utest/trace/BUILD.gn b/system/utest/trace/BUILD.gn
new file mode 100644
index 0000000..27e07a2
--- /dev/null
+++ b/system/utest/trace/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+test("trace") {
+  sources = [
+    "engine_tests.cpp",
+    "event_tests.c",
+    "event_tests.cpp",
+    "event_tests_ntrace.c",
+    "event_tests_ntrace.cpp",
+    "fields_tests.cpp",
+    "fixture.cpp",
+    "main.c",
+    "no_optimization.c",
+    "record_tests.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/async-loop:async-loop-cpp",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/trace",
+    "$zx/system/ulib/trace-engine",
+    "$zx/system/ulib/trace-provider:trace-handler",
+    "$zx/system/ulib/trace-reader",
+    "$zx/system/ulib/trace-test-utils",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+
+    # fdio is here so that things like printf work.
+    # Otherwise they silently fail (output is dropped).
+    "$zx/system/ulib/fdio",
+  ]
+}
diff --git a/system/utest/usb/BUILD.gn b/system/utest/usb/BUILD.gn
new file mode 100644
index 0000000..995441e
--- /dev/null
+++ b/system/utest/usb/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("usb") {
+  sources = [
+    "usb-test.c",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-hardware-usb-tester:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/utf_conversion/BUILD.gn b/system/utest/utf_conversion/BUILD.gn
new file mode 100644
index 0000000..6061a38
--- /dev/null
+++ b/system/utest/utf_conversion/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("utf_conversion") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/utf_conversion",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/util/BUILD.gn b/system/utest/util/BUILD.gn
new file mode 100644
index 0000000..f5f41bc
--- /dev/null
+++ b/system/utest/util/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("util") {
+  sources = [
+    "listnode.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/unittest",
+  ]
+  if (is_fuchsia) {
+    deps += [
+      "$zx/system/ulib/zircon",
+      "$zx/system/ulib/fdio",
+    ]
+  }
+}
diff --git a/system/utest/util/listnode.cpp b/system/utest/util/listnode.cpp
index 1a74322..d0d5790 100644
--- a/system/utest/util/listnode.cpp
+++ b/system/utest/util/listnode.cpp
@@ -168,9 +168,6 @@
 RUN_TEST(list_splice_split);
 END_TEST_CASE(listnode_tests)
 
-#ifndef BUILD_COMBINED_TESTS
 int main(int argc, char** argv) {
-    bool success = unittest_run_all_tests(argc, argv);
-    return success ? 0 : -1;
+    return unittest_run_all_tests(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-#endif  // BUILD_COMBINED_TESTS
diff --git a/system/utest/vdso-base/BUILD.gn b/system/utest/vdso-base/BUILD.gn
new file mode 100644
index 0000000..bf2c0c4
--- /dev/null
+++ b/system/utest/vdso-base/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+test("vdso-base") {
+  sources = [
+    "vdso-base.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/vdso-variant/BUILD.gn b/system/utest/vdso-variant/BUILD.gn
new file mode 100644
index 0000000..8f03359
--- /dev/null
+++ b/system/utest/vdso-variant/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+test("vdso-variant") {
+  sources = [
+    "vdso-variant.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/launchpad",
+    "$zx/system/ulib/zircon",
+  ]
+  data_deps = [
+    ":vdso-variant-helper",
+  ]
+}
+
+executable("vdso-variant-helper") {
+  visibility = [ ":*" ]
+  testonly = true
+  sources = [
+    "helper/vdso-variant-helper.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/system/utest/vdso/BUILD.gn b/system/utest/vdso/BUILD.gn
new file mode 100644
index 0000000..9a1b434
--- /dev/null
+++ b/system/utest/vdso/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("vdso") {
+  sources = [
+    "vdso.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/elfload",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+  ]
+}
diff --git a/system/utest/vmo/BUILD.gn b/system/utest/vmo/BUILD.gn
new file mode 100644
index 0000000..ed4bae4
--- /dev/null
+++ b/system/utest/vmo/BUILD.gn
@@ -0,0 +1,19 @@
+# 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.
+
+test("vmo") {
+  sources = [
+    "bench.cpp",
+    "vmo.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fzl",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/x86-umip/BUILD.gn b/system/utest/x86-umip/BUILD.gn
new file mode 100644
index 0000000..749f374
--- /dev/null
+++ b/system/utest/x86-umip/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+test("x86-umip") {
+  sources = [
+    "main.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+  ]
+}
diff --git a/system/utest/zbi/BUILD.gn b/system/utest/zbi/BUILD.gn
new file mode 100644
index 0000000..9f46d25
--- /dev/null
+++ b/system/utest/zbi/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+test("zbi") {
+  sources = [
+    "zbi.cpp",
+  ]
+  deps = [
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/libzbi",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/unittest",
+  ]
+  if (is_fuchsia) {
+    deps += [ "$zx/system/ulib/fdio" ]
+  }
+}
diff --git a/system/utest/zxcrypt/BUILD.gn b/system/utest/zxcrypt/BUILD.gn
new file mode 100644
index 0000000..6536c6a
--- /dev/null
+++ b/system/utest/zxcrypt/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+test("zxcrypt") {
+  sources = [
+    "main.c",
+    "test-device.cpp",
+    "volume.cpp",
+    "zxcrypt.cpp",
+  ]
+  include_dirs = [ ".." ]
+  deps = [
+    "$zx/system/ulib/block-client",
+    "$zx/system/ulib/crypto",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/digest",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/fs",
+    "$zx/system/ulib/fs-management",
+    "$zx/system/ulib/fvm",
+    "$zx/system/ulib/gpt",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/sync",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxcrypt",
+    "$zx/third_party/ulib/cryptolib",
+    "$zx/third_party/ulib/uboringssl",
+  ]
+}
diff --git a/system/utest/zxio/BUILD.gn b/system/utest/zxio/BUILD.gn
new file mode 100644
index 0000000..bde236d
--- /dev/null
+++ b/system/utest/zxio/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+test("zxio") {
+  sources = [
+    "main.c",
+    "null-test.cpp",
+    "vmofile-test.cpp",
+    "zxio-test.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-io:c",
+    "$zx/system/fidl/fuchsia-net:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxio",
+    "$zx/system/ulib/zxs",
+  ]
+}
diff --git a/system/utest/zxs/BUILD.gn b/system/utest/zxs/BUILD.gn
new file mode 100644
index 0000000..f4e0f4f
--- /dev/null
+++ b/system/utest/zxs/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+test("zxs") {
+  sources = [
+    "main.c",
+    "zxs-test.cpp",
+  ]
+  deps = [
+    "$zx/system/fidl/fuchsia-net:c",
+    "$zx/system/ulib/async",
+    "$zx/system/ulib/async:async-cpp",
+    "$zx/system/ulib/async:async-default",
+    "$zx/system/ulib/async-loop",
+    "$zx/system/ulib/fbl",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/unittest",
+    "$zx/system/ulib/zircon",
+    "$zx/system/ulib/zx",
+    "$zx/system/ulib/zxcpp",
+    "$zx/system/ulib/zxs",
+  ]
+}
diff --git a/third_party/dev/ethernet/e1000/BUILD.gn b/third_party/dev/ethernet/e1000/BUILD.gn
new file mode 100644
index 0000000..257e3e4
--- /dev/null
+++ b/third_party/dev/ethernet/e1000/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+driver("e1000") {
+  sources = [
+    "e1000_80003es2lan.c",
+    "e1000_82540.c",
+    "e1000_82541.c",
+    "e1000_82542.c",
+    "e1000_82543.c",
+    "e1000_82571.c",
+    "e1000_82575.c",
+    "e1000_api.c",
+    "e1000_i210.c",
+    "e1000_ich8lan.c",
+    "e1000_mac.c",
+    "e1000_manage.c",
+    "e1000_mbx.c",
+    "e1000_nvm.c",
+    "e1000_osdep.c",
+    "e1000_phy.c",
+    "e1000_vf.c",
+    "fuchsia.c",
+  ]
+  deps = [
+    "$zx/system/banjo/ddk-protocol-ethernet",
+    "$zx/system/banjo/ddk-protocol-pci",
+    "$zx/system/ulib/ddk",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/third_party/lib/acpica/BUILD.gn b/third_party/lib/acpica/BUILD.gn
new file mode 100644
index 0000000..df50095
--- /dev/null
+++ b/third_party/lib/acpica/BUILD.gn
@@ -0,0 +1,237 @@
+# 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("$zx/kernel/params.gni")
+
+declare_args() {
+  # Enable debug output in the ACPI library (used by the ACPI bus driver).
+  enable_acpi_debug = false
+}
+
+config("headers") {
+  include_dirs = [ "source/include" ]
+}
+
+# Disable warnings we won't fix in third-party code.  Putting this in a
+# separate config rather than direclty in the target gets these flags
+# correctly ordered after the $zx/public/gn/config:default_warnings flags.
+config("disable_warnings") {
+  visibility = [ ":*" ]
+
+  cflags = [ "-Wno-implicit-fallthrough" ]
+  if (is_gcc) {
+    cflags += [ "-Wno-format-signedness" ]
+    cflags_c = [ "-Wno-discarded-qualifiers" ]
+  } else {
+    cflags += [
+      "-Wno-incompatible-pointer-types-discards-qualifiers",
+      "-Wno-null-pointer-arithmetic",
+    ]
+  }
+}
+
+static_library("acpica") {
+  public_deps = [
+    ":headers",
+  ]
+
+  # Local sources use #include "acpi.h", not #include <acpica/acpi.h>.
+  include_dirs = [ "source/include/acpica" ]
+
+  configs += [ ":disable_warnings" ]
+
+  # We need to specify -fno-strict-aliasing, since ACPICA has a habit of
+  # violating strict aliasing rules in some of its macros.  Rewriting this
+  # code would increase the maintenance cost of bringing in the latest
+  # upstream ACPICA, so instead we mitigate the problem with a compile-time
+  # flag.  We take the more conservative approach of disabling
+  # strict-aliasing-based optimizations, rather than disabling warnings.
+  cflags = [ "-fno-strict-aliasing" ]
+
+  sources = [
+    "source/components/hardware/hwregs.c",
+    "source/components/hardware/hwsleep.c",
+    "source/components/hardware/hwvalid.c",
+    "source/components/hardware/hwxface.c",
+    "source/components/hardware/hwxfsleep.c",
+    "source/components/tables/tbdata.c",
+    "source/components/tables/tbfadt.c",
+    "source/components/tables/tbfind.c",
+    "source/components/tables/tbinstal.c",
+    "source/components/tables/tbprint.c",
+    "source/components/tables/tbutils.c",
+    "source/components/tables/tbxface.c",
+    "source/components/tables/tbxfroot.c",
+    "source/components/utilities/utalloc.c",
+    "source/components/utilities/utexcep.c",
+    "source/components/utilities/utglobal.c",
+    "source/components/utilities/utmisc.c",
+    "source/components/utilities/utstring.c",
+    "source/components/utilities/utxferror.c",
+  ]
+
+  if (is_kernel) {
+    sources += [ "source/os_specific/service_layers/oszircon.cpp" ]
+    deps = [
+      "$zx/kernel/platform/pc:headers",
+    ]
+  } else {
+    sources += [
+      "source/common/ahids.c",
+      "source/common/ahpredef.c",
+      "source/common/ahtable.c",
+      "source/common/getopt.c",
+      "source/components/dispatcher/dsargs.c",
+      "source/components/dispatcher/dscontrol.c",
+      "source/components/dispatcher/dsdebug.c",
+      "source/components/dispatcher/dsfield.c",
+      "source/components/dispatcher/dsinit.c",
+      "source/components/dispatcher/dsmethod.c",
+      "source/components/dispatcher/dsmthdat.c",
+      "source/components/dispatcher/dsobject.c",
+      "source/components/dispatcher/dsopcode.c",
+      "source/components/dispatcher/dsutils.c",
+      "source/components/dispatcher/dswexec.c",
+      "source/components/dispatcher/dswload.c",
+      "source/components/dispatcher/dswload2.c",
+      "source/components/dispatcher/dswscope.c",
+      "source/components/dispatcher/dswstate.c",
+      "source/components/events/evevent.c",
+      "source/components/events/evglock.c",
+      "source/components/events/evgpe.c",
+      "source/components/events/evgpeblk.c",
+      "source/components/events/evgpeinit.c",
+      "source/components/events/evgpeutil.c",
+      "source/components/events/evhandler.c",
+      "source/components/events/evmisc.c",
+      "source/components/events/evregion.c",
+      "source/components/events/evrgnini.c",
+      "source/components/events/evsci.c",
+      "source/components/events/evxface.c",
+      "source/components/events/evxfevnt.c",
+      "source/components/events/evxfgpe.c",
+      "source/components/events/evxfregn.c",
+      "source/components/executer/exconfig.c",
+      "source/components/executer/exconvrt.c",
+      "source/components/executer/excreate.c",
+      "source/components/executer/exdebug.c",
+      "source/components/executer/exdump.c",
+      "source/components/executer/exfield.c",
+      "source/components/executer/exfldio.c",
+      "source/components/executer/exmisc.c",
+      "source/components/executer/exmutex.c",
+      "source/components/executer/exnames.c",
+      "source/components/executer/exoparg1.c",
+      "source/components/executer/exoparg2.c",
+      "source/components/executer/exoparg3.c",
+      "source/components/executer/exoparg6.c",
+      "source/components/executer/exprep.c",
+      "source/components/executer/exregion.c",
+      "source/components/executer/exresnte.c",
+      "source/components/executer/exresolv.c",
+      "source/components/executer/exresop.c",
+      "source/components/executer/exstore.c",
+      "source/components/executer/exstoren.c",
+      "source/components/executer/exstorob.c",
+      "source/components/executer/exsystem.c",
+      "source/components/executer/extrace.c",
+      "source/components/executer/exutils.c",
+      "source/components/hardware/hwacpi.c",
+      "source/components/hardware/hwesleep.c",
+      "source/components/hardware/hwgpe.c",
+      "source/components/hardware/hwpci.c",
+      "source/components/hardware/hwtimer.c",
+      "source/components/namespace/nsaccess.c",
+      "source/components/namespace/nsalloc.c",
+      "source/components/namespace/nsarguments.c",
+      "source/components/namespace/nsconvert.c",
+      "source/components/namespace/nsdump.c",
+      "source/components/namespace/nsdumpdv.c",
+      "source/components/namespace/nseval.c",
+      "source/components/namespace/nsinit.c",
+      "source/components/namespace/nsload.c",
+      "source/components/namespace/nsnames.c",
+      "source/components/namespace/nsobject.c",
+      "source/components/namespace/nsparse.c",
+      "source/components/namespace/nspredef.c",
+      "source/components/namespace/nsprepkg.c",
+      "source/components/namespace/nsrepair.c",
+      "source/components/namespace/nsrepair2.c",
+      "source/components/namespace/nssearch.c",
+      "source/components/namespace/nsutils.c",
+      "source/components/namespace/nswalk.c",
+      "source/components/namespace/nsxfeval.c",
+      "source/components/namespace/nsxfname.c",
+      "source/components/namespace/nsxfobj.c",
+      "source/components/parser/psargs.c",
+      "source/components/parser/psloop.c",
+      "source/components/parser/psobject.c",
+      "source/components/parser/psopcode.c",
+      "source/components/parser/psopinfo.c",
+      "source/components/parser/psparse.c",
+      "source/components/parser/psscope.c",
+      "source/components/parser/pstree.c",
+      "source/components/parser/psutils.c",
+      "source/components/parser/pswalk.c",
+      "source/components/parser/psxface.c",
+      "source/components/resources/rsaddr.c",
+      "source/components/resources/rscalc.c",
+      "source/components/resources/rscreate.c",
+      "source/components/resources/rsdumpinfo.c",
+      "source/components/resources/rsinfo.c",
+      "source/components/resources/rsio.c",
+      "source/components/resources/rsirq.c",
+      "source/components/resources/rslist.c",
+      "source/components/resources/rsmemory.c",
+      "source/components/resources/rsmisc.c",
+      "source/components/resources/rsserial.c",
+      "source/components/resources/rsutils.c",
+      "source/components/resources/rsxface.c",
+      "source/components/tables/tbxfload.c",
+      "source/components/utilities/utaddress.c",
+      "source/components/utilities/utbuffer.c",
+      "source/components/utilities/utcache.c",
+      "source/components/utilities/utclib.c",
+      "source/components/utilities/utcopy.c",
+      "source/components/utilities/utdebug.c",
+      "source/components/utilities/utdecode.c",
+      "source/components/utilities/utdelete.c",
+      "source/components/utilities/uterror.c",
+      "source/components/utilities/uteval.c",
+      "source/components/utilities/uthex.c",
+      "source/components/utilities/utids.c",
+      "source/components/utilities/utinit.c",
+      "source/components/utilities/utlock.c",
+      "source/components/utilities/utmath.c",
+      "source/components/utilities/utmutex.c",
+      "source/components/utilities/utnonansi.c",
+      "source/components/utilities/utobject.c",
+      "source/components/utilities/utosi.c",
+      "source/components/utilities/utownerid.c",
+      "source/components/utilities/utpredef.c",
+      "source/components/utilities/utprint.c",
+      "source/components/utilities/utresrc.c",
+      "source/components/utilities/utstate.c",
+      "source/components/utilities/uttrack.c",
+      "source/components/utilities/utuuid.c",
+      "source/components/utilities/utxface.c",
+      "source/components/utilities/utxfinit.c",
+      "source/components/utilities/utxfmutex.c",
+      "source/os_specific/service_layers/osfuchsia.cpp",
+    ]
+    deps = [
+      "$zx/system/ulib/ddk",
+      "$zx/system/ulib/fbl",
+      "$zx/system/ulib/pci",
+      "$zx/system/ulib/zxcpp",
+    ]
+    defines = []
+    if (enable_user_pci) {
+      defines += [ "ENABLE_USER_PCI" ]
+    }
+    if (enable_acpi_debug) {
+      defines += [ "ACPI_DEBUG_OUTPUT" ]
+    }
+  }
+}
diff --git a/third_party/lib/jitterentropy/BUILD.gn b/third_party/lib/jitterentropy/BUILD.gn
new file mode 100644
index 0000000..1d6843a
--- /dev/null
+++ b/third_party/lib/jitterentropy/BUILD.gn
@@ -0,0 +1,33 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("jitterentropy") {
+  kernel = true
+  sources = [
+    "jitterentropy-base.c",
+  ]
+  include_dirs = [ "arch/$zircon_cpu" ]
+
+  # According to its documentation, jitterentropy must be compiled at
+  # optimization level -O0.
+  #
+  # TODO(SEC-14): Test the code generated at various optimization
+  # levels. If there is a significant difference in entropy quality,
+  # replace the relevant C code by assembly code to protect against future
+  # compiler changes.
+  configs -= [ "$zx/public/gn/config:opt_level" ]
+  configs += [ ":config" ]
+}
+
+config("config") {
+  visibility = [ ":*" ]
+  cflags = [
+    "-O0",
+
+    # The original Makefile also specifies -fwrapv.
+    "-fwrapv",
+  ]
+}
diff --git a/third_party/uapp/BUILD.gn b/third_party/uapp/BUILD.gn
new file mode 100644
index 0000000..c550a9c
--- /dev/null
+++ b/third_party/uapp/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+group("uapp") {
+  deps = [
+    "dash",
+    "fsck-msdosfs",
+    "kilo",
+    "mkfs-msdosfs",
+  ]
+}
diff --git a/third_party/uapp/dash/BUILD.gn b/third_party/uapp/dash/BUILD.gn
new file mode 100644
index 0000000..95b2d94
--- /dev/null
+++ b/third_party/uapp/dash/BUILD.gn
@@ -0,0 +1,86 @@
+# 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.
+
+executable("dash") {
+  output_name = "sh"
+  sources = [
+    "src/alias.c",
+    "src/arith_yacc.c",
+    "src/arith_yylex.c",
+    "src/bltin/printf.c",
+    "src/bltin/test.c",
+    "src/bltin/times.c",
+    "src/bltin/zircon.c",
+    "src/builtins.c",
+    "src/cd.c",
+    "src/error.c",
+    "src/eval.c",
+    "src/exec.c",
+    "src/expand.c",
+    "src/init.c",
+    "src/input.c",
+    "src/jobs.c",
+    "src/main.c",
+    "src/memalloc.c",
+    "src/miscbltin.c",
+    "src/mystring.c",
+    "src/nodes.c",
+    "src/options.c",
+    "src/output.c",
+    "src/output.h",
+    "src/parser.c",
+    "src/process.c",
+    "src/redir.c",
+    "src/show.c",
+    "src/signames.c",
+    "src/syntax.c",
+    "src/system.c",
+    "src/tab.c",
+    "src/trap.c",
+    "src/var.c",
+  ]
+  configs += [ ":config" ]
+  deps = [
+    "$zx/system/fidl/fuchsia-device-manager:c",
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/pretty",
+    "$zx/system/ulib/zircon",
+    "$zx/third_party/ulib/linenoise",
+  ]
+}
+
+config("config") {
+  visibility = [ ":*" ]
+  defines = [
+    "BSD",
+    "DEBUG",
+    "IFS_BROKEN",
+    "JOBS=0",
+    "SHELL",
+    "USE_LINENOISE",
+    "_GNU_SOURCE",
+  ]
+  include_dirs = [ "src" ]
+  cflags = [
+    "-include",
+    rebase_path("config.h", root_build_dir),
+  ]
+
+  # TODO: Fix Warnings
+  cflags_c = [
+    "-Wno-strict-prototypes",
+    "-Wno-sign-compare",
+    "-Wno-logical-not-parentheses",
+  ]
+  if (is_gcc) {
+    cflags_c += [ "-Wno-discarded-qualifiers" ]
+  } else {
+    cflags_c += [
+      "-Wno-incompatible-pointer-types-discards-qualifiers",
+      "-Wno-gnu-designator",
+      "-Wno-format-security",
+      "-Wno-string-plus-int",
+    ]
+  }
+}
diff --git a/third_party/uapp/fsck-msdosfs/BUILD.gn b/third_party/uapp/fsck-msdosfs/BUILD.gn
new file mode 100644
index 0000000..7ac7662
--- /dev/null
+++ b/third_party/uapp/fsck-msdosfs/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+executable("fsck-msdosfs") {
+  sources = [
+    "boot.c",
+    "check.c",
+    "dir.c",
+    "fat.c",
+    "main.c",
+  ]
+  deps = [
+    "$zx/system/ulib/fdio",
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/third_party/uapp/kilo/BUILD.gn b/third_party/uapp/kilo/BUILD.gn
new file mode 100644
index 0000000..b7990ff
--- /dev/null
+++ b/third_party/uapp/kilo/BUILD.gn
@@ -0,0 +1,22 @@
+# 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.
+
+executable("kilo") {
+  sources = [
+    "kilo.c",
+  ]
+  configs += [ ":config" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+  ]
+}
+
+config("config") {
+  visibility = [ ":*" ]
+  if (is_gcc) {
+    cflags_c = [ "-Wno-discarded-qualifiers" ]
+  } else {
+    cflags = [ "-Wno-incompatible-pointer-types-discards-qualifiers" ]
+  }
+}
diff --git a/third_party/ulib/backtrace/BUILD.gn b/third_party/ulib/backtrace/BUILD.gn
new file mode 100644
index 0000000..01f7da9
--- /dev/null
+++ b/third_party/ulib/backtrace/BUILD.gn
@@ -0,0 +1,28 @@
+# 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.
+
+library("backtrace") {
+  sdk = "shared"
+  sdk_headers = [
+    "backtrace/backtrace-supported.h",
+    "backtrace/backtrace.h",
+  ]
+  shared = true
+  include_dirs = [ "include/backtrace" ]
+  sources = [
+    "alloc.c",
+    "dwarf.c",
+    "elf.c",
+    "fileline.c",
+    "posix.c",
+    "read.c",
+    "sort.c",
+    "state.c",
+  ]
+
+  # Compile this with frame pointers so that if we crash
+  # the simplistic unwinder will work.
+  configs -= [ "$zx/public/gn/config:default_frame_pointers" ]
+  configs += [ "$zx/public/gn/config:frame_pointers" ]
+}
diff --git a/third_party/ulib/chromiumos-platform-ec/BUILD.gn b/third_party/ulib/chromiumos-platform-ec/BUILD.gn
new file mode 100644
index 0000000..8c60adc
--- /dev/null
+++ b/third_party/ulib/chromiumos-platform-ec/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+assert(current_cpu == "x64")
+
+library("chromiumos-platform-ec") {
+  sources = [
+    "comm-lpc.cpp",
+  ]
+}
diff --git a/third_party/ulib/cryptolib/BUILD.gn b/third_party/ulib/cryptolib/BUILD.gn
new file mode 100644
index 0000000..6876400
--- /dev/null
+++ b/third_party/ulib/cryptolib/BUILD.gn
@@ -0,0 +1,12 @@
+# Copyright 2019 The Fuchsia Authors
+#
+# Use of this source code is governed by a MIT-style
+# license that can be found in the LICENSE file or at
+# https://opensource.org/licenses/MIT
+
+library("cryptolib") {
+  kernel = true
+  sources = [
+    "cryptolib.c",
+  ]
+}
diff --git a/third_party/ulib/jemalloc/BUILD.gn b/third_party/ulib/jemalloc/BUILD.gn
new file mode 100644
index 0000000..374323f
--- /dev/null
+++ b/third_party/ulib/jemalloc/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+source_set("jemalloc") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  include_dirs = [ "include" ]
+  sources = [
+    "src/arena.c",
+    "src/base.c",
+    "src/bitmap.c",
+    "src/ckh.c",
+    "src/ctl.c",
+    "src/extent.c",
+    "src/extent_dss.c",
+    "src/extent_mmap.c",
+    "src/jemalloc.c",
+    "src/large.c",
+    "src/mutex.c",
+    "src/nstime.c",
+    "src/pages.c",
+    "src/prof.c",
+    "src/rtree.c",
+    "src/stats.c",
+    "src/tcache.c",
+    "src/tsd.c",
+    "src/util.c",
+    "src/witness.c",
+  ]
+}
diff --git a/third_party/ulib/linenoise/BUILD.gn b/third_party/ulib/linenoise/BUILD.gn
new file mode 100644
index 0000000..3fb51a4
--- /dev/null
+++ b/third_party/ulib/linenoise/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+library("linenoise") {
+  sources = [
+    "linenoise.c",
+  ]
+  include_dirs = [ "include/linenoise" ]
+  deps = [
+    "$zx/system/ulib/fdio",
+  ]
+}
diff --git a/third_party/ulib/musl/BUILD.gn b/third_party/ulib/musl/BUILD.gn
new file mode 100644
index 0000000..5e9258e
--- /dev/null
+++ b/third_party/ulib/musl/BUILD.gn
@@ -0,0 +1,104 @@
+# 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.
+
+config("headers") {
+  visibility = [
+    "./*",
+    "$zx/system/ulib/c:*",
+  ]
+  include_dirs = [ "include" ]
+}
+
+config("musl_config") {
+  visibility = [
+    "./*",
+    "$zx/third_party/ulib/jemalloc:*",
+  ]
+  include_dirs = [
+    "src/internal",
+    "arch/${toolchain.cpu}",
+  ]
+  public_deps = [
+    ":headers",
+    "$zx/system/ulib/runtime",
+    "$zx/system/ulib/zircon",
+  ]
+
+  defines = [ "_XOPEN_SOURCE=700" ]
+
+  # TODO(kulakowski): Clean up the junkier -Wno flags below.
+  cflags = [
+    "-Wno-sign-compare",
+    "-Werror=incompatible-pointer-types",
+    "-Wno-implicit-fallthrough",
+  ]
+
+  if (!is_gcc) {
+    # Some of this code runs before the TLS area for the canary is set up.
+    # TODO(mcgrathr): Isolate this to exactly what code needs it.
+    cflags += [ "-fno-stack-protector" ]
+  }
+  
+  cflags += [ "-ffreestanding" ]
+}
+
+if (toolchain.environment == "user") {
+  group("musl") {
+    visibility = [ "$zx/system/ulib/c:*" ]
+    deps = [
+      "$zx/third_party/ulib/jemalloc",
+      "ldso",
+      "pthread",
+      "sanitizers",
+      "src/complex",
+      "src/conf",
+      "src/ctype",
+      "src/dirent",
+      "src/env",
+      "src/errno",
+      "src/exit",
+      "src/fcntl",
+      "src/fenv",
+      "src/internal",
+      "src/ipc",
+      "src/ldso",
+      "src/legacy",
+      "src/linux",
+      "src/locale",
+      "src/math",
+      "src/misc",
+      "src/mman",
+      "src/multibyte",
+      "src/network",
+      "src/passwd",
+      "src/prng",
+      "src/process",
+      "src/regex",
+      "src/sched",
+      "src/setjmp",
+      "src/signal",
+      "src/stat",
+      "src/stdio",
+      "src/stdlib",
+      "src/string",
+      "src/temp",
+      "src/termios",
+      "src/thread",
+      "src/time",
+      "src/unistd",
+      "stubs",
+      "third_party/smoothsort",
+      "third_party/tre",
+      "zircon",
+    ]
+  }
+
+  source_set("crt1") {
+    visibility = [ "$zx/system/ulib/c:crt1" ]
+    configs -= [ "$zx/public/gn/config:user" ]
+    sources = [
+      "arch/${toolchain.cpu}/Scrt1.S",
+    ]
+  }
+}
diff --git a/third_party/ulib/musl/ldso/BUILD.gn b/third_party/ulib/musl/ldso/BUILD.gn
new file mode 100644
index 0000000..ebf83c5
--- /dev/null
+++ b/third_party/ulib/musl/ldso/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("ldso") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [
+    "$zx/system/ulib/ldmsg",
+  ]
+  sources = [
+    "$zx/third_party/ulib/musl/arch/${toolchain.cpu}/dl-entry.S",
+    "dlstart.c",
+    "dynlink-sancov.S",
+    "dynlink.c",
+  ]
+}
diff --git a/third_party/ulib/musl/pthread/BUILD.gn b/third_party/ulib/musl/pthread/BUILD.gn
new file mode 100644
index 0000000..04e0796
--- /dev/null
+++ b/third_party/ulib/musl/pthread/BUILD.gn
@@ -0,0 +1,89 @@
+# 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.
+
+source_set("pthread") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "pthread_atfork.c",
+    "pthread_attr_destroy.c",
+    "pthread_attr_get.c",
+    "pthread_attr_init.c",
+    "pthread_attr_setdetachstate.c",
+    "pthread_attr_setguardsize.c",
+    "pthread_attr_setschedparam.c",
+    "pthread_attr_setstacksize.c",
+    "pthread_barrier_destroy.c",
+    "pthread_barrier_init.c",
+    "pthread_barrier_wait.c",
+    "pthread_barrierattr_destroy.c",
+    "pthread_barrierattr_init.c",
+    "pthread_cancel.c",
+    "pthread_cond_broadcast.c",
+    "pthread_cond_destroy.c",
+    "pthread_cond_init.c",
+    "pthread_cond_signal.c",
+    "pthread_cond_timedwait.c",
+    "pthread_cond_wait.c",
+    "pthread_condattr_destroy.c",
+    "pthread_condattr_init.c",
+    "pthread_condattr_setclock.c",
+    "pthread_create.c",
+    "pthread_detach.c",
+    "pthread_equal.c",
+    "pthread_getattr_np.c",
+    "pthread_getconcurrency.c",
+    "pthread_getcpuclockid.c",
+    "pthread_getspecific.c",
+    "pthread_join.c",
+    "pthread_key.c",
+    "pthread_kill.c",
+    "pthread_mutex_consistent.c",
+    "pthread_mutex_destroy.c",
+    "pthread_mutex_getprioceiling.c",
+    "pthread_mutex_init.c",
+    "pthread_mutex_lock.c",
+    "pthread_mutex_setprioceiling.c",
+    "pthread_mutex_timedlock.c",
+    "pthread_mutex_trylock.c",
+    "pthread_mutex_unlock.c",
+    "pthread_mutexattr_destroy.c",
+    "pthread_mutexattr_init.c",
+    "pthread_mutexattr_setprotocol.c",
+    "pthread_mutexattr_setrobust.c",
+    "pthread_mutexattr_settype.c",
+    "pthread_once.c",
+    "pthread_rwlock_destroy.c",
+    "pthread_rwlock_init.c",
+    "pthread_rwlock_rdlock.c",
+    "pthread_rwlock_timedrdlock.c",
+    "pthread_rwlock_timedwrlock.c",
+    "pthread_rwlock_tryrdlock.c",
+    "pthread_rwlock_trywrlock.c",
+    "pthread_rwlock_unlock.c",
+    "pthread_rwlock_wrlock.c",
+    "pthread_rwlockattr_destroy.c",
+    "pthread_rwlockattr_init.c",
+    "pthread_self.c",
+    "pthread_setcancelstate.c",
+    "pthread_setcanceltype.c",
+    "pthread_setconcurrency.c",
+    "pthread_setspecific.c",
+    "pthread_sigmask.c",
+    "pthread_spin_destroy.c",
+    "pthread_spin_init.c",
+    "pthread_spin_lock.c",
+    "pthread_spin_trylock.c",
+    "pthread_spin_unlock.c",
+    "pthread_testcancel.c",
+    "sem_destroy.c",
+    "sem_getvalue.c",
+    "sem_init.c",
+    "sem_post.c",
+    "sem_timedwait.c",
+    "sem_trywait.c",
+    "sem_unlink.c",
+    "sem_wait.c",
+  ]
+}
diff --git a/third_party/ulib/musl/sanitizers/BUILD.gn b/third_party/ulib/musl/sanitizers/BUILD.gn
new file mode 100644
index 0000000..21bd6c2
--- /dev/null
+++ b/third_party/ulib/musl/sanitizers/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+source_set("sanitizers") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__asan_early_init.c",
+    "asan-stubs.c",
+    "hooks.c",
+    "log.c",
+  ]
+
+  # There is no '#if __has_feature(coverage)', so this file has to be
+  # excluded from the build entirely when not in use.
+  sancov = [ "$zx/public/gn/config/sanitizers:sancov" ]
+  if (configs + sancov - sancov != configs) {
+    sources += [ "sancov-stubs.S" ]
+  }
+}
diff --git a/third_party/ulib/musl/src/complex/BUILD.gn b/third_party/ulib/musl/src/complex/BUILD.gn
new file mode 100644
index 0000000..05e429a
--- /dev/null
+++ b/third_party/ulib/musl/src/complex/BUILD.gn
@@ -0,0 +1,67 @@
+# 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.
+
+source_set("complex") {
+  include_dirs = [ "$zx/third_party/ulib/musl/third_party/include" ]
+  sources = [
+    "cabs.c",
+    "cabsf.c",
+    "cabsl.c",
+    "cacos.c",
+    "cacosf.c",
+    "cacosh.c",
+    "cacoshf.c",
+    "cacoshl.c",
+    "cacosl.c",
+    "carg.c",
+    "cargf.c",
+    "cargl.c",
+    "casin.c",
+    "casinf.c",
+    "casinh.c",
+    "casinhf.c",
+    "casinhl.c",
+    "casinl.c",
+    "catanh.c",
+    "catanhf.c",
+    "catanhl.c",
+    "ccos.c",
+    "ccosf.c",
+    "ccoshl.c",
+    "ccosl.c",
+    "cexpl.c",
+    "cimag.c",
+    "cimagf.c",
+    "cimagl.c",
+    "clog.c",
+    "clogf.c",
+    "clogl.c",
+    "conj.c",
+    "conjf.c",
+    "conjl.c",
+    "cpow.c",
+    "cpowf.c",
+    "cpowl.c",
+    "cproj.c",
+    "cprojf.c",
+    "cprojl.c",
+    "creal.c",
+    "crealf.c",
+    "creall.c",
+    "csin.c",
+    "csinf.c",
+    "csinhl.c",
+    "csinl.c",
+    "csqrtl.c",
+    "ctan.c",
+    "ctanf.c",
+    "ctanhl.c",
+    "ctanl.c",
+  ]
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [
+    "$zx/third_party/ulib/musl/third_party/complex",
+  ]
+}
diff --git a/third_party/ulib/musl/src/conf/BUILD.gn b/third_party/ulib/musl/src/conf/BUILD.gn
new file mode 100644
index 0000000..4c8ffa4
--- /dev/null
+++ b/third_party/ulib/musl/src/conf/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+source_set("conf") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "confstr.c",
+    "fpathconf.c",
+    "pathconf.c",
+    "sysconf.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/ctype/BUILD.gn b/third_party/ulib/musl/src/ctype/BUILD.gn
new file mode 100644
index 0000000..a9d49a6
--- /dev/null
+++ b/third_party/ulib/musl/src/ctype/BUILD.gn
@@ -0,0 +1,47 @@
+# 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.
+
+source_set("ctype") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__ctype_b_loc.c",
+    "__ctype_get_mb_cur_max.c",
+    "__ctype_tolower_loc.c",
+    "__ctype_toupper_loc.c",
+    "isalnum.c",
+    "isalpha.c",
+    "isascii.c",
+    "isblank.c",
+    "iscntrl.c",
+    "isdigit.c",
+    "isgraph.c",
+    "islower.c",
+    "isprint.c",
+    "ispunct.c",
+    "isspace.c",
+    "isupper.c",
+    "iswalnum.c",
+    "iswalpha.c",
+    "iswblank.c",
+    "iswcntrl.c",
+    "iswctype.c",
+    "iswdigit.c",
+    "iswgraph.c",
+    "iswlower.c",
+    "iswprint.c",
+    "iswpunct.c",
+    "iswspace.c",
+    "iswupper.c",
+    "iswxdigit.c",
+    "isxdigit.c",
+    "toascii.c",
+    "tolower.c",
+    "toupper.c",
+    "towctrans.c",
+    "wcswidth.c",
+    "wctrans.c",
+    "wcwidth.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/dirent/BUILD.gn b/third_party/ulib/musl/src/dirent/BUILD.gn
new file mode 100644
index 0000000..3cd9e36
--- /dev/null
+++ b/third_party/ulib/musl/src/dirent/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+source_set("dirent") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "alphasort.c",
+    "scandir.c",
+    "versionsort.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/env/BUILD.gn b/third_party/ulib/musl/src/env/BUILD.gn
new file mode 100644
index 0000000..5471f5f
--- /dev/null
+++ b/third_party/ulib/musl/src/env/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+source_set("env") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__environ.c",
+    "__libc_start_main.c",
+    "__stack_chk_fail.c",
+    "clearenv.c",
+    "getenv.c",
+    "putenv.c",
+    "setenv.c",
+    "unsetenv.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/errno/BUILD.gn b/third_party/ulib/musl/src/errno/BUILD.gn
new file mode 100644
index 0000000..ad80c5a
--- /dev/null
+++ b/third_party/ulib/musl/src/errno/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+source_set("errno") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__errno_location.c",
+    "strerror.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/exit/BUILD.gn b/third_party/ulib/musl/src/exit/BUILD.gn
new file mode 100644
index 0000000..93ebacf
--- /dev/null
+++ b/third_party/ulib/musl/src/exit/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+source_set("exit") {
+  sources = [
+    "_Exit.c",
+    "__cxa_thread_atexit.c",
+    "abort.c",
+    "assert.c",
+    "at_quick_exit.c",
+    "atexit.c",
+    "exit.c",
+    "quick_exit.c",
+  ]
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+}
diff --git a/third_party/ulib/musl/src/fcntl/BUILD.gn b/third_party/ulib/musl/src/fcntl/BUILD.gn
new file mode 100644
index 0000000..ec5f4da
--- /dev/null
+++ b/third_party/ulib/musl/src/fcntl/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+source_set("fcntl") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "creat.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/fenv/BUILD.gn b/third_party/ulib/musl/src/fenv/BUILD.gn
new file mode 100644
index 0000000..0151f79
--- /dev/null
+++ b/third_party/ulib/musl/src/fenv/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("fenv") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "${toolchain.cpu}/fenv.c",
+    "__flt_rounds.c",
+    "fegetexceptflag.c",
+    "feholdexcept.c",
+    "fesetexceptflag.c",
+    "fesetround.c",
+    "feupdateenv.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/internal/BUILD.gn b/third_party/ulib/musl/src/internal/BUILD.gn
new file mode 100644
index 0000000..7a54ff4
--- /dev/null
+++ b/third_party/ulib/musl/src/internal/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+source_set("internal") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "floatscan.c",
+    "intscan.c",
+    "libc.c",
+    "shgetc.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/ipc/BUILD.gn b/third_party/ulib/musl/src/ipc/BUILD.gn
new file mode 100644
index 0000000..2427d90
--- /dev/null
+++ b/third_party/ulib/musl/src/ipc/BUILD.gn
@@ -0,0 +1,23 @@
+# 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.
+
+source_set("ipc") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "ftok.c",
+    "msgctl.c",
+    "msgget.c",
+    "msgrcv.c",
+    "msgsnd.c",
+    "semctl.c",
+    "semget.c",
+    "semop.c",
+    "semtimedop.c",
+    "shmat.c",
+    "shmctl.c",
+    "shmdt.c",
+    "shmget.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/ldso/BUILD.gn b/third_party/ulib/musl/src/ldso/BUILD.gn
new file mode 100644
index 0000000..126531f
--- /dev/null
+++ b/third_party/ulib/musl/src/ldso/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+source_set("ldso") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "${toolchain.cpu}/tlsdesc.S",
+    "dlclose.c",
+    "dlerror.c",
+    "dlinfo.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/legacy/BUILD.gn b/third_party/ulib/musl/src/legacy/BUILD.gn
new file mode 100644
index 0000000..02b73fb
--- /dev/null
+++ b/third_party/ulib/musl/src/legacy/BUILD.gn
@@ -0,0 +1,18 @@
+# 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.
+
+source_set("legacy") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "err.c",
+    "euidaccess.c",
+    "futimes.c",
+    "getdtablesize.c",
+    "getpagesize.c",
+    "getpass.c",
+    "isastream.c",
+    "lutimes.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/linux/BUILD.gn b/third_party/ulib/musl/src/linux/BUILD.gn
new file mode 100644
index 0000000..33d2e09
--- /dev/null
+++ b/third_party/ulib/musl/src/linux/BUILD.gn
@@ -0,0 +1,16 @@
+# 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.
+
+source_set("linux") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "adjtime.c",
+    "flock.c",
+    "sethostname.c",
+    "settimeofday.c",
+    "stime.c",
+    "utimes.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/locale/BUILD.gn b/third_party/ulib/musl/src/locale/BUILD.gn
new file mode 100644
index 0000000..1dfb538
--- /dev/null
+++ b/third_party/ulib/musl/src/locale/BUILD.gn
@@ -0,0 +1,31 @@
+# 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.
+
+source_set("locale") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__lctrans.c",
+    "__mo_lookup.c",
+    "c_locale.c",
+    "catclose.c",
+    "catgets.c",
+    "catopen.c",
+    "duplocale.c",
+    "freelocale.c",
+    "iconv.c",
+    "langinfo.c",
+    "locale_map.c",
+    "localeconv.c",
+    "newlocale.c",
+    "pleval.c",
+    "setlocale.c",
+    "strcoll.c",
+    "strfmon.c",
+    "strxfrm.c",
+    "uselocale.c",
+    "wcscoll.c",
+    "wcsxfrm.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/math/BUILD.gn b/third_party/ulib/musl/src/math/BUILD.gn
new file mode 100644
index 0000000..dd145e2
--- /dev/null
+++ b/third_party/ulib/musl/src/math/BUILD.gn
@@ -0,0 +1,188 @@
+# 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.
+
+source_set("math") {
+  include_dirs = [ "$zx/third_party/ulib/musl/third_party/include" ]
+  sources = [
+    "__expo2.c",
+    "__expo2f.c",
+    "__fpclassify.c",
+    "__fpclassifyf.c",
+    "__fpclassifyl.c",
+    "__invtrigl.c",
+    "__signbit.c",
+    "__signbitf.c",
+    "__signbitl.c",
+    "acosh.c",
+    "acoshf.c",
+    "acoshl.c",
+    "asinh.c",
+    "asinhf.c",
+    "asinhl.c",
+    "atanh.c",
+    "atanhf.c",
+    "atanhl.c",
+    "ceil.c",
+    "ceilf.c",
+    "copysign.c",
+    "copysignf.c",
+    "copysignl.c",
+    "cosh.c",
+    "coshf.c",
+    "coshl.c",
+    "cosl.c",
+    "exp10.c",
+    "exp10f.c",
+    "exp10l.c",
+    "fdim.c",
+    "fdimf.c",
+    "fdiml.c",
+    "finite.c",
+    "finitef.c",
+    "floor.c",
+    "floorf.c",
+    "fmax.c",
+    "fmaxf.c",
+    "fmaxl.c",
+    "fmin.c",
+    "fminf.c",
+    "fminl.c",
+    "fmod.c",
+    "fmodf.c",
+    "frexp.c",
+    "frexpf.c",
+    "frexpl.c",
+    "hypot.c",
+    "hypotf.c",
+    "hypotl.c",
+    "ilogb.c",
+    "ilogbf.c",
+    "ilogbl.c",
+    "ldexp.c",
+    "ldexpf.c",
+    "ldexpl.c",
+    "lgamma.c",
+    "lgammaf.c",
+    "llround.c",
+    "llroundf.c",
+    "llroundl.c",
+    "logb.c",
+    "logbf.c",
+    "logbl.c",
+    "lround.c",
+    "lroundf.c",
+    "lroundl.c",
+    "modf.c",
+    "modff.c",
+    "modfl.c",
+    "nan.c",
+    "nanf.c",
+    "nanl.c",
+    "nearbyint.c",
+    "nearbyintf.c",
+    "nearbyintl.c",
+    "nextafter.c",
+    "nextafterf.c",
+    "nextafterl.c",
+    "nexttoward.c",
+    "nexttowardf.c",
+    "nexttowardl.c",
+    "remainder.c",
+    "remainderf.c",
+    "remquo.c",
+    "remquof.c",
+    "remquol.c",
+    "rint.c",
+    "rintf.c",
+    "round.c",
+    "roundf.c",
+    "roundl.c",
+    "scalbln.c",
+    "scalblnf.c",
+    "scalblnl.c",
+    "scalbn.c",
+    "scalbnf.c",
+    "scalbnl.c",
+    "signgam.c",
+    "significand.c",
+    "significandf.c",
+    "sincosl.c",
+    "sinh.c",
+    "sinhf.c",
+    "sinhl.c",
+    "sinl.c",
+    "tanh.c",
+    "tanhf.c",
+    "tanhl.c",
+    "tanl.c",
+    "tgamma.c",
+    "tgammaf.c",
+    "trunc.c",
+    "truncf.c",
+  ]
+  if (current_cpu == "x64") {
+    sources += [
+      "x86_64/__invtrigl.S",
+      "x86_64/acosl.S",
+      "x86_64/asinl.S",
+      "x86_64/atan2l.S",
+      "x86_64/atanl.S",
+      "x86_64/ceill.S",
+      "x86_64/exp2l.S",
+      "x86_64/expl.S",
+      "x86_64/expm1l.S",
+      "x86_64/fabs.S",
+      "x86_64/fabsf.S",
+      "x86_64/fabsl.S",
+      "x86_64/floorl.S",
+      "x86_64/fmodl.S",
+      "x86_64/llrint.S",
+      "x86_64/llrintf.S",
+      "x86_64/llrintl.S",
+      "x86_64/log10l.S",
+      "x86_64/log1pl.S",
+      "x86_64/log2l.S",
+      "x86_64/logl.S",
+      "x86_64/lrint.S",
+      "x86_64/lrintf.S",
+      "x86_64/lrintl.S",
+      "x86_64/remainderl.S",
+      "x86_64/rintl.S",
+      "x86_64/sqrt.S",
+      "x86_64/sqrtf.S",
+      "x86_64/sqrtl.S",
+      "x86_64/truncl.S",
+    ]
+  } else {
+    sources += [
+      "ceill.c",
+      "fabsl.c",
+      "floorl.c",
+      "fmodl.c",
+      "llrint.c",
+      "llrintf.c",
+      "llrintl.c",
+      "lrint.c",
+      "lrintf.c",
+      "lrintl.c",
+      "remainderl.c",
+      "rintl.c",
+      "sqrtl.c",
+      "truncl.c",
+    ]
+  }
+  if (current_cpu == "arm64") {
+    sources += [
+      "aarch64/fabs.S",
+      "aarch64/fabsf.S",
+      "aarch64/sqrt.S",
+      "aarch64/sqrtf.S",
+    ]
+  }
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [
+    "$zx/third_party/ulib/musl/third_party/math",
+  ]
+}
diff --git a/third_party/ulib/musl/src/misc/BUILD.gn b/third_party/ulib/musl/src/misc/BUILD.gn
new file mode 100644
index 0000000..e97aa44
--- /dev/null
+++ b/third_party/ulib/musl/src/misc/BUILD.gn
@@ -0,0 +1,32 @@
+# 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.
+
+source_set("misc") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "a64l.c",
+    "basename.c",
+    "dirname.c",
+    "ffs.c",
+    "ffsl.c",
+    "ffsll.c",
+    "get_current_dir_name.c",
+    "getauxval.c",
+    "getdomainname.c",
+    "gethostid.c",
+    "getopt.c",
+    "getopt_long.c",
+    "getsubopt.c",
+    "initgroups.c",
+    "issetugid.c",
+    "lockf.c",
+    "openpty.c",
+    "ptsname.c",
+    "pty.c",
+    "setdomainname.c",
+    "syslog.c",
+    "wordexp.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/mman/BUILD.gn b/third_party/ulib/musl/src/mman/BUILD.gn
new file mode 100644
index 0000000..d156620
--- /dev/null
+++ b/third_party/ulib/musl/src/mman/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+source_set("mman") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "madvise.c",
+    "mlock.c",
+    "mlockall.c",
+    "mmap.c",
+    "mprotect.c",
+    "msync.c",
+    "munlock.c",
+    "munlockall.c",
+    "munmap.c",
+    "posix_madvise.c",
+    "shm_open.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/multibyte/BUILD.gn b/third_party/ulib/musl/src/multibyte/BUILD.gn
new file mode 100644
index 0000000..4324dd9
--- /dev/null
+++ b/third_party/ulib/musl/src/multibyte/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+source_set("multibyte") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "btowc.c",
+    "c16rtomb.c",
+    "c32rtomb.c",
+    "internal.c",
+    "mblen.c",
+    "mbrlen.c",
+    "mbrtoc16.c",
+    "mbrtoc32.c",
+    "mbrtowc.c",
+    "mbsinit.c",
+    "mbsnrtowcs.c",
+    "mbsrtowcs.c",
+    "mbstowcs.c",
+    "mbtowc.c",
+    "wcrtomb.c",
+    "wcsnrtombs.c",
+    "wcsrtombs.c",
+    "wcstombs.c",
+    "wctob.c",
+    "wctomb.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/network/BUILD.gn b/third_party/ulib/musl/src/network/BUILD.gn
new file mode 100644
index 0000000..342f7f2
--- /dev/null
+++ b/third_party/ulib/musl/src/network/BUILD.gn
@@ -0,0 +1,66 @@
+# 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.
+
+source_set("network") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "accept.c",
+    "dn_comp.c",
+    "dn_expand.c",
+    "dn_skipname.c",
+    "dns_parse.c",
+    "ent.c",
+    "ether.c",
+    "gai_strerror.c",
+    "gethostbyaddr.c",
+    "gethostbyaddr_r.c",
+    "gethostbyname.c",
+    "gethostbyname2.c",
+    "gethostbyname2_r.c",
+    "gethostbyname_r.c",
+    "getifaddrs.c",
+    "getnameinfo.c",
+    "getservbyname.c",
+    "getservbyname_r.c",
+    "getservbyport.c",
+    "getservbyport_r.c",
+    "h_errno.c",
+    "herror.c",
+    "hstrerror.c",
+    "htonl.c",
+    "htons.c",
+    "if_freenameindex.c",
+    "if_indextoname.c",
+    "if_nameindex.c",
+    "if_nametoindex.c",
+    "in6addr_any.c",
+    "in6addr_loopback.c",
+    "inet_addr.c",
+    "inet_aton.c",
+    "inet_legacy.c",
+    "inet_ntoa.c",
+    "inet_ntop.c",
+    "inet_pton.c",
+    "lookup_ipliteral.c",
+    "lookup_serv.c",
+    "netlink.c",
+    "netname.c",
+    "ns_parse.c",
+    "ntohl.c",
+    "ntohs.c",
+    "proto.c",
+    "recv.c",
+    "res_init.c",
+    "res_mkquery.c",
+    "res_msend.c",
+    "res_query.c",
+    "res_querydomain.c",
+    "res_send.c",
+    "res_state.c",
+    "resolvconf.c",
+    "send.c",
+    "serv.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/passwd/BUILD.gn b/third_party/ulib/musl/src/passwd/BUILD.gn
new file mode 100644
index 0000000..e9f04a2
--- /dev/null
+++ b/third_party/ulib/musl/src/passwd/BUILD.gn
@@ -0,0 +1,24 @@
+# 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.
+
+source_set("passwd") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "fgetgrent.c",
+    "fgetpwent.c",
+    "getgr_a.c",
+    "getgr_r.c",
+    "getgrent.c",
+    "getgrent_a.c",
+    "getgrouplist.c",
+    "getpw_a.c",
+    "getpw_r.c",
+    "getpwent.c",
+    "getpwent_a.c",
+    "nscd_query.c",
+    "putgrent.c",
+    "putpwent.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/prng/BUILD.gn b/third_party/ulib/musl/src/prng/BUILD.gn
new file mode 100644
index 0000000..07e8617
--- /dev/null
+++ b/third_party/ulib/musl/src/prng/BUILD.gn
@@ -0,0 +1,21 @@
+# 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.
+
+source_set("prng") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__rand48_step.c",
+    "__seed48.c",
+    "drand48.c",
+    "lcong48.c",
+    "lrand48.c",
+    "mrand48.c",
+    "rand.c",
+    "rand_r.c",
+    "random.c",
+    "seed48.c",
+    "srand48.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/process/BUILD.gn b/third_party/ulib/musl/src/process/BUILD.gn
new file mode 100644
index 0000000..bf59d4e
--- /dev/null
+++ b/third_party/ulib/musl/src/process/BUILD.gn
@@ -0,0 +1,40 @@
+# 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.
+
+source_set("process") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "execl.c",
+    "execle.c",
+    "execlp.c",
+    "execv.c",
+    "execve.c",
+    "execvp.c",
+    "fexecve.c",
+    "fork.c",
+    "posix_spawn.c",
+    "posix_spawn_file_actions_addclose.c",
+    "posix_spawn_file_actions_adddup2.c",
+    "posix_spawn_file_actions_addopen.c",
+    "posix_spawn_file_actions_destroy.c",
+    "posix_spawn_file_actions_init.c",
+    "posix_spawnattr_destroy.c",
+    "posix_spawnattr_getflags.c",
+    "posix_spawnattr_getpgroup.c",
+    "posix_spawnattr_getsigdefault.c",
+    "posix_spawnattr_getsigmask.c",
+    "posix_spawnattr_init.c",
+    "posix_spawnattr_sched.c",
+    "posix_spawnattr_setflags.c",
+    "posix_spawnattr_setpgroup.c",
+    "posix_spawnattr_setsigdefault.c",
+    "posix_spawnattr_setsigmask.c",
+    "posix_spawnp.c",
+    "system.c",
+    "wait.c",
+    "waitid.c",
+    "waitpid.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/regex/BUILD.gn b/third_party/ulib/musl/src/regex/BUILD.gn
new file mode 100644
index 0000000..3ea4eaa
--- /dev/null
+++ b/third_party/ulib/musl/src/regex/BUILD.gn
@@ -0,0 +1,12 @@
+# 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.
+
+source_set("regex") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "fnmatch.c",
+    "glob.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/sched/BUILD.gn b/third_party/ulib/musl/src/sched/BUILD.gn
new file mode 100644
index 0000000..8a4bdbf
--- /dev/null
+++ b/third_party/ulib/musl/src/sched/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+source_set("sched") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "affinity.c",
+    "sched_cpucount.c",
+    "sched_get_priority_max.c",
+    "sched_getcpu.c",
+    "sched_getparam.c",
+    "sched_getscheduler.c",
+    "sched_rr_get_interval.c",
+    "sched_setparam.c",
+    "sched_setscheduler.c",
+    "sched_yield.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/setjmp/BUILD.gn b/third_party/ulib/musl/src/setjmp/BUILD.gn
new file mode 100644
index 0000000..8d5fd6f
--- /dev/null
+++ b/third_party/ulib/musl/src/setjmp/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+# TODO(mcgrathr): This code was all rewritten from scratch.  Move it out of
+# third_party/ulib/musl into system/ulib/c.
+
+source_set("setjmp") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "${toolchain.cpu}/longjmp.S",
+    "${toolchain.cpu}/setjmp.S",
+    "longjmp.c",
+    "setjmp.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/signal/BUILD.gn b/third_party/ulib/musl/src/signal/BUILD.gn
new file mode 100644
index 0000000..e2872f5
--- /dev/null
+++ b/third_party/ulib/musl/src/signal/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+source_set("signal") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "getitimer.c",
+    "kill.c",
+    "killpg.c",
+    "psiginfo.c",
+    "psignal.c",
+    "raise.c",
+    "setitimer.c",
+    "sigaction.c",
+    "sigaddset.c",
+    "sigaltstack.c",
+    "sigandset.c",
+    "sigdelset.c",
+    "sigemptyset.c",
+    "sigfillset.c",
+    "siginterrupt.c",
+    "sigisemptyset.c",
+    "sigismember.c",
+    "signal.c",
+    "sigorset.c",
+    "sigpause.c",
+    "sigpending.c",
+    "sigprocmask.c",
+    "sigqueue.c",
+    "sigrtmax.c",
+    "sigrtmin.c",
+    "sigsuspend.c",
+    "sigtimedwait.c",
+    "sigwait.c",
+    "sigwaitinfo.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/stat/BUILD.gn b/third_party/ulib/musl/src/stat/BUILD.gn
new file mode 100644
index 0000000..d230244
--- /dev/null
+++ b/third_party/ulib/musl/src/stat/BUILD.gn
@@ -0,0 +1,15 @@
+# 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.
+
+source_set("stat") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "futimesat.c",
+    "lchmod.c",
+    "mkfifoat.c",
+    "mknodat.c",
+    "statvfs.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/stdio/BUILD.gn b/third_party/ulib/musl/src/stdio/BUILD.gn
new file mode 100644
index 0000000..01f0085
--- /dev/null
+++ b/third_party/ulib/musl/src/stdio/BUILD.gn
@@ -0,0 +1,123 @@
+# 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.
+
+source_set("stdio") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__fclose_ca.c",
+    "__fdopen.c",
+    "__fmodeflags.c",
+    "__fopen_rb_ca.c",
+    "__lockfile.c",
+    "__overflow.c",
+    "__stdio_close.c",
+    "__stdio_exit.c",
+    "__stdio_read.c",
+    "__stdio_seek.c",
+    "__stdio_write.c",
+    "__stdout_write.c",
+    "__string_read.c",
+    "__toread.c",
+    "__towrite.c",
+    "__uflow.c",
+    "asprintf.c",
+    "clearerr.c",
+    "dprintf.c",
+    "fclose.c",
+    "feof.c",
+    "ferror.c",
+    "fflush.c",
+    "fgetc.c",
+    "fgetln.c",
+    "fgetpos.c",
+    "fgets.c",
+    "fgetwc.c",
+    "fgetws.c",
+    "fileno.c",
+    "flockfile.c",
+    "fmemopen.c",
+    "fopen.c",
+    "fprintf.c",
+    "fputc.c",
+    "fputs.c",
+    "fputwc.c",
+    "fputws.c",
+    "fread.c",
+    "freopen.c",
+    "fscanf.c",
+    "fseek.c",
+    "fsetpos.c",
+    "ftell.c",
+    "ftrylockfile.c",
+    "funlockfile.c",
+    "fwide.c",
+    "fwprintf.c",
+    "fwrite.c",
+    "fwscanf.c",
+    "getc.c",
+    "getc_unlocked.c",
+    "getchar.c",
+    "getchar_unlocked.c",
+    "getdelim.c",
+    "getline.c",
+    "gets.c",
+    "getw.c",
+    "getwc.c",
+    "getwchar.c",
+    "ofl.c",
+    "ofl_add.c",
+    "open_memstream.c",
+    "open_wmemstream.c",
+    "pclose.c",
+    "perror.c",
+    "popen.c",
+    "printf.c",
+    "putc.c",
+    "putc_unlocked.c",
+    "putchar.c",
+    "putchar_unlocked.c",
+    "puts.c",
+    "putw.c",
+    "putwc.c",
+    "putwchar.c",
+    "remove.c",
+    "rewind.c",
+    "scanf.c",
+    "setbuf.c",
+    "setbuffer.c",
+    "setlinebuf.c",
+    "setvbuf.c",
+    "snprintf.c",
+    "sprintf.c",
+    "sscanf.c",
+    "stderr.c",
+    "stdin.c",
+    "stdout.c",
+    "swprintf.c",
+    "swscanf.c",
+    "tempnam.c",
+    "tmpfile.c",
+    "tmpnam.c",
+    "ungetc.c",
+    "ungetwc.c",
+    "vasprintf.c",
+    "vdprintf.c",
+    "vfprintf.c",
+    "vfscanf.c",
+    "vfwprintf.c",
+    "vfwscanf.c",
+    "vprintf.c",
+    "vscanf.c",
+    "vsnprintf.c",
+    "vsprintf.c",
+    "vsscanf.c",
+    "vswprintf.c",
+    "vswscanf.c",
+    "vwprintf.c",
+    "vwscanf.c",
+    "wprintf.c",
+    "wscanf.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/stdlib/BUILD.gn b/third_party/ulib/musl/src/stdlib/BUILD.gn
new file mode 100644
index 0000000..9d1739f
--- /dev/null
+++ b/third_party/ulib/musl/src/stdlib/BUILD.gn
@@ -0,0 +1,30 @@
+# 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.
+
+source_set("stdlib") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "abs.c",
+    "atof.c",
+    "atoi.c",
+    "atol.c",
+    "atoll.c",
+    "bsearch.c",
+    "div.c",
+    "ecvt.c",
+    "fcvt.c",
+    "gcvt.c",
+    "imaxabs.c",
+    "imaxdiv.c",
+    "labs.c",
+    "ldiv.c",
+    "llabs.c",
+    "lldiv.c",
+    "strtod.c",
+    "strtol.c",
+    "wcstod.c",
+    "wcstol.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/string/BUILD.gn b/third_party/ulib/musl/src/string/BUILD.gn
new file mode 100644
index 0000000..c6d6703
--- /dev/null
+++ b/third_party/ulib/musl/src/string/BUILD.gn
@@ -0,0 +1,222 @@
+# 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.
+
+group("string") {
+  deps = [
+    ":bsd",
+    ":extmem",
+    ":extstr",
+    ":stdmem",
+    ":stdstr",
+    ":wcs",
+    ":wmem",
+  ]
+}
+
+if (toolchain.environment == "user") {
+  remove_configs = [ "$zx/public/gn/config:user" ]
+} else {
+  remove_configs = []
+}
+
+# These are the functions the compiler produces implicit calls to.
+source_set("compiler") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  if (current_cpu == "arm64") {
+    # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'.
+    include_dirs = [ "$zx/" ]
+    sources = [
+      "aarch64/memcpy.S",
+      "aarch64/memset.S",
+    ]
+  } else if (current_cpu == "x64") {
+    sources = [
+      "x86_64/memcpy.S",
+      "x86_64/memset.S",
+    ]
+  } else {
+    sources = [
+      "memcpy.c",
+      "memset.c",
+    ]
+  }
+}
+
+source_set("stdmem") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  configs += [ ":compiler" ]
+  sources = [
+    "memrchr.c",
+  ]
+  if (current_cpu == "arm64") {
+    # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'.
+    include_dirs = [ "$zx/" ]
+    sources += [ "aarch64/memmove.S" ]
+  } else if (current_cpu == "x64") {
+    sources += [ "x86_64/memmove.S" ]
+  } else {
+    sources += [ "memmove.c" ]
+  }
+  if (current_cpu == "arm64") {
+    sources += [
+      "$zx/third_party/lib/cortex-strings/src/aarch64/memchr.S",
+      "$zx/third_party/lib/cortex-strings/src/aarch64/memcmp.S",
+    ]
+  } else {
+    sources += [
+      "memchr.c",
+      "memcmp.c",
+    ]
+  }
+}
+
+source_set("extmem") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "memccpy.c",
+    "memmem.c",
+  ]
+  if (current_cpu == "x64" && !defined(toolchain.sanitizer)) {
+    # Only use the assembly version if x86-64 and not sanitized.
+    sources += [ "x86_64/mempcpy.S" ]
+  } else {
+    sources += [ "mempcpy.c" ]
+  }
+}
+
+source_set("minimal_str") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  if (current_cpu == "arm64") {
+    sources = [
+      "$zx/third_party/lib/cortex-strings/src/aarch64/strlen.S",
+      "$zx/third_party/lib/cortex-strings/src/aarch64/strncmp.S",
+    ]
+  } else {
+    sources = [
+      "strlen.c",
+      "strncmp.c",
+    ]
+  }
+}
+
+source_set("stdstr") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [ ":minimal_str" ]
+  sources = [
+    "strcat.c",
+    "strcspn.c",
+    "strdup.c",
+    "strerror_r.c",
+    "strncat.c",
+    "strncpy.c",
+    "strpbrk.c",
+    "strrchr.c",
+    "strspn.c",
+    "strstr.c",
+    "strtok.c",
+    "strtok_r.c",
+  ]
+  if (current_cpu == "arm64") {
+    sources += [
+      "$zx/third_party/lib/cortex-strings/src/aarch64/strchr.S",
+      "$zx/third_party/lib/cortex-strings/src/aarch64/strcmp.S",
+      "$zx/third_party/lib/cortex-strings/src/aarch64/strcpy.S",
+    ]
+  } else {
+    sources += [
+      "strchr.c",
+      "strcmp.c",
+      "strcpy.c",
+    ]
+  }
+}
+
+source_set("extstr") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "stpcpy.c",
+    "stpncpy.c",
+    "strcasecmp.c",
+    "strcasestr.c",
+    "strlcat.c",
+    "strlcpy.c",
+    "strncasecmp.c",
+    "strndup.c",
+    "strsep.c",
+    "strsignal.c",
+    "strverscmp.c",
+  ]
+  if (current_cpu == "arm64") {
+    # These use '#include "third_party/lib/cortex-strings/src/aarch64/..."'.
+    include_dirs = [ "$zx/" ]
+    sources += [
+      "$zx/third_party/lib/cortex-strings/src/aarch64/strnlen.S",
+      "aarch64/strchrnul.S",
+    ]
+  } else {
+    sources += [
+      "strchrnul.c",
+      "strnlen.c",
+    ]
+  }
+}
+
+source_set("bsd") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "bcmp.c",
+    "bcopy.c",
+    "bzero.c",
+    "index.c",
+    "rindex.c",
+    "swab.c",
+  ]
+}
+
+source_set("wcs") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "wcpcpy.c",
+    "wcpncpy.c",
+    "wcscasecmp.c",
+    "wcscat.c",
+    "wcschr.c",
+    "wcscmp.c",
+    "wcscpy.c",
+    "wcscspn.c",
+    "wcsdup.c",
+    "wcslen.c",
+    "wcsncasecmp.c",
+    "wcsncat.c",
+    "wcsncmp.c",
+    "wcsncpy.c",
+    "wcsnlen.c",
+    "wcspbrk.c",
+    "wcsrchr.c",
+    "wcsspn.c",
+    "wcsstr.c",
+    "wcstok.c",
+    "wcswcs.c",
+  ]
+}
+
+source_set("wmem") {
+  configs -= remove_configs
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "wmemchr.c",
+    "wmemcmp.c",
+    "wmemcpy.c",
+    "wmemmove.c",
+    "wmemset.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/string/aarch64/memcpy.S b/third_party/ulib/musl/src/string/aarch64/memcpy.S
index d75abb7..8e72c83 100644
--- a/third_party/ulib/musl/src/string/aarch64/memcpy.S
+++ b/third_party/ulib/musl/src/string/aarch64/memcpy.S
@@ -9,5 +9,9 @@
 
 #include "third_party/lib/cortex-strings/src/aarch64/memcpy.S"
 
+#ifdef HIDDEN
+    .hidden memcpy
+#lse
 ALIAS(memcpy, __unsanitized_memcpy)
 ASAN_WEAK_ALIAS(memcpy)
+#endif
diff --git a/third_party/ulib/musl/src/string/aarch64/memmove.S b/third_party/ulib/musl/src/string/aarch64/memmove.S
index f5497bf..7b1d62a 100644
--- a/third_party/ulib/musl/src/string/aarch64/memmove.S
+++ b/third_party/ulib/musl/src/string/aarch64/memmove.S
@@ -1,4 +1,4 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
+// Copyright 2017, 2018 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.
 
@@ -9,5 +9,9 @@
 
 #include "third_party/lib/cortex-strings/src/aarch64/memmove.S"
 
+#ifdef HIDDEN
+    .hidden memmove
+#else
 ALIAS(memmove, __unsanitized_memmove)
 ASAN_WEAK_ALIAS(memmove)
+#endif
diff --git a/third_party/ulib/musl/src/string/x86_64/memcpy.S b/third_party/ulib/musl/src/string/x86_64/memcpy.S
index f07b462..97a7f6a 100644
--- a/third_party/ulib/musl/src/string/x86_64/memcpy.S
+++ b/third_party/ulib/musl/src/string/x86_64/memcpy.S
@@ -15,7 +15,11 @@
     ret
 END(memcpy)
 
+#ifdef HIDDEN
+    .hidden memcpy
+#else
 ALIAS(memcpy, __unsanitized_memcpy)
 ASAN_WEAK_ALIAS(memcpy)
+#endif
 ALIAS(memcpy, __memcpy_fwd)
 .hidden __memcpy_fwd
diff --git a/third_party/ulib/musl/src/string/x86_64/memmove.S b/third_party/ulib/musl/src/string/x86_64/memmove.S
index 52c8d98..79904f6 100644
--- a/third_party/ulib/musl/src/string/x86_64/memmove.S
+++ b/third_party/ulib/musl/src/string/x86_64/memmove.S
@@ -16,5 +16,9 @@
 	ret
 END(memmove)
 
+#ifdef HIDDEN
+    .hidden memmove
+#else
 ALIAS(memmove, __unsanitized_memmove)
 ASAN_WEAK_ALIAS(memmove)
+#endif
diff --git a/third_party/ulib/musl/src/string/x86_64/memset.S b/third_party/ulib/musl/src/string/x86_64/memset.S
index 2f01840..fbc2ec0 100644
--- a/third_party/ulib/musl/src/string/x86_64/memset.S
+++ b/third_party/ulib/musl/src/string/x86_64/memset.S
@@ -17,9 +17,13 @@
     ret
 END(memset)
 
+#ifdef HIDDEN
+    .hidden memset
+#else
 ALIAS(memset, __unsanitized_memset)
 ASAN_WEAK_ALIAS(memset)
 
 // This name is called from inside libc to avoid going through the PLT.
 .hidden __libc_memset
 ALIAS(memset, __libc_memset)
+#endif
diff --git a/third_party/ulib/musl/src/temp/BUILD.gn b/third_party/ulib/musl/src/temp/BUILD.gn
new file mode 100644
index 0000000..e117f99
--- /dev/null
+++ b/third_party/ulib/musl/src/temp/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("temp") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__randname.c",
+    "mkdtemp.c",
+    "mkostemp.c",
+    "mkostemps.c",
+    "mkstemp.c",
+    "mkstemps.c",
+    "mktemp.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/termios/BUILD.gn b/third_party/ulib/musl/src/termios/BUILD.gn
new file mode 100644
index 0000000..213a7c9
--- /dev/null
+++ b/third_party/ulib/musl/src/termios/BUILD.gn
@@ -0,0 +1,20 @@
+# 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.
+
+source_set("termios") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "cfgetospeed.c",
+    "cfmakeraw.c",
+    "cfsetospeed.c",
+    "tcdrain.c",
+    "tcflow.c",
+    "tcflush.c",
+    "tcgetattr.c",
+    "tcgetsid.c",
+    "tcsendbreak.c",
+    "tcsetattr.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/thread/BUILD.gn b/third_party/ulib/musl/src/thread/BUILD.gn
new file mode 100644
index 0000000..2809221
--- /dev/null
+++ b/third_party/ulib/musl/src/thread/BUILD.gn
@@ -0,0 +1,39 @@
+# 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.
+
+source_set("thread") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [
+    "$zx/system/ulib/sync",
+  ]
+  sources = [
+    "__timedwait.c",
+    "__tls_get_addr.c",
+    "__wait.c",
+    "allocate.c",
+    "call_once.c",
+    "cnd_broadcast.c",
+    "cnd_destroy.c",
+    "cnd_init.c",
+    "cnd_signal.c",
+    "cnd_timedwait.c",
+    "cnd_wait.c",
+    "mtx_destroy.c",
+    "mtx_init.c",
+    "mtx_lock.c",
+    "mtx_timedlock.c",
+    "mtx_trylock.c",
+    "mtx_unlock.c",
+    "safestack.c",
+    "thrd_create.c",
+    "thrd_detach.c",
+    "thrd_exit.c",
+    "thrd_join.c",
+    "thrd_sleep.c",
+    "thrd_yield.c",
+    "tss.c",
+    "tss_set.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/time/BUILD.gn b/third_party/ulib/musl/src/time/BUILD.gn
new file mode 100644
index 0000000..4ce546a
--- /dev/null
+++ b/third_party/ulib/musl/src/time/BUILD.gn
@@ -0,0 +1,45 @@
+# 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.
+
+source_set("time") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "__asctime.c",
+    "__map_file.c",
+    "__month_to_secs.c",
+    "__secs_to_tm.c",
+    "__tm_to_secs.c",
+    "__tz.c",
+    "__year_to_secs.c",
+    "asctime.c",
+    "asctime_r.c",
+    "clock.c",
+    "clock_getcpuclockid.c",
+    "clock_getres.c",
+    "clock_gettime.c",
+    "clock_nanosleep.c",
+    "clock_settime.c",
+    "ctime.c",
+    "ctime_r.c",
+    "difftime.c",
+    "ftime.c",
+    "getdate.c",
+    "gettimeofday.c",
+    "gmtime.c",
+    "gmtime_r.c",
+    "localtime.c",
+    "localtime_r.c",
+    "mktime.c",
+    "nanosleep.c",
+    "strftime.c",
+    "strptime.c",
+    "time.c",
+    "timegm.c",
+    "times.c",
+    "timespec_get.c",
+    "utime.c",
+    "wcsftime.c",
+  ]
+}
diff --git a/third_party/ulib/musl/src/unistd/BUILD.gn b/third_party/ulib/musl/src/unistd/BUILD.gn
new file mode 100644
index 0000000..493aa48
--- /dev/null
+++ b/third_party/ulib/musl/src/unistd/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+source_set("unistd") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "_exit.c",
+    "acct.c",
+    "alarm.c",
+    "ctermid.c",
+    "gethostname.c",
+    "getlogin.c",
+    "getlogin_r.c",
+    "pause.c",
+    "posix_close.c",
+    "setpgrp.c",
+    "sleep.c",
+    "tcgetpgrp.c",
+    "tcsetpgrp.c",
+    "ttyname.c",
+    "ualarm.c",
+    "usleep.c",
+  ]
+}
diff --git a/third_party/ulib/musl/stubs/BUILD.gn b/third_party/ulib/musl/stubs/BUILD.gn
new file mode 100644
index 0000000..c1d4eb6
--- /dev/null
+++ b/third_party/ulib/musl/stubs/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+source_set("stubs") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "idstubs.c",
+    "iostubs.c",
+    "socketstubs.c",
+  ]
+}
diff --git a/third_party/ulib/musl/third_party/complex/BUILD.gn b/third_party/ulib/musl/third_party/complex/BUILD.gn
new file mode 100644
index 0000000..ec52892
--- /dev/null
+++ b/third_party/ulib/musl/third_party/complex/BUILD.gn
@@ -0,0 +1,26 @@
+# 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.
+
+source_set("complex") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  include_dirs = [ "$zx/third_party/ulib/musl/third_party/include" ]
+  sources = [
+    "__cexp.c",
+    "__cexpf.c",
+    "catan.c",
+    "catanf.c",
+    "catanl.c",
+    "ccosh.c",
+    "ccoshf.c",
+    "cexp.c",
+    "cexpf.c",
+    "csinh.c",
+    "csinhf.c",
+    "csqrt.c",
+    "csqrtf.c",
+    "ctanh.c",
+    "ctanhf.c",
+  ]
+}
diff --git a/third_party/ulib/musl/third_party/math/BUILD.gn b/third_party/ulib/musl/third_party/math/BUILD.gn
new file mode 100644
index 0000000..ce1dd47
--- /dev/null
+++ b/third_party/ulib/musl/third_party/math/BUILD.gn
@@ -0,0 +1,94 @@
+# 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.
+
+source_set("math") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  include_dirs = [ "$zx/third_party/ulib/musl/third_party/include" ]
+  sources = [
+    "__cos.c",
+    "__cosdf.c",
+    "__cosl.c",
+    "__polevll.c",
+    "__rem_pio2.c",
+    "__rem_pio2_large.c",
+    "__rem_pio2f.c",
+    "__rem_pio2l.c",
+    "__sin.c",
+    "__sindf.c",
+    "__sinl.c",
+    "__tan.c",
+    "__tandf.c",
+    "__tanl.c",
+    "acos.c",
+    "acosf.c",
+    "asin.c",
+    "asinf.c",
+    "atan.c",
+    "atan2.c",
+    "atan2f.c",
+    "atanf.c",
+    "cbrt.c",
+    "cbrtf.c",
+    "cbrtl.c",
+    "cos.c",
+    "cosf.c",
+    "erf.c",
+    "erff.c",
+    "erfl.c",
+    "exp.c",
+    "exp2.c",
+    "exp2f.c",
+    "expf.c",
+    "expm1.c",
+    "expm1f.c",
+    "fma.c",
+    "fmaf.c",
+    "fmal.c",
+    "j0.c",
+    "j0f.c",
+    "j1.c",
+    "j1f.c",
+    "jn.c",
+    "jnf.c",
+    "lgamma_r.c",
+    "lgammaf_r.c",
+    "lgammal.c",
+    "log.c",
+    "log10.c",
+    "log10f.c",
+    "log1p.c",
+    "log1pf.c",
+    "log2.c",
+    "log2f.c",
+    "logf.c",
+    "pow.c",
+    "powf.c",
+    "powl.c",
+    "scalb.c",
+    "scalbf.c",
+    "sin.c",
+    "sincos.c",
+    "sincosf.c",
+    "sinf.c",
+    "tan.c",
+    "tanf.c",
+    "tgammal.c",
+  ]
+  if (current_cpu != "x64") {
+    sources += [
+      "acosl.c",
+      "asinl.c",
+      "atan2l.c",
+      "atanl.c",
+      "exp2l.c",
+      "expl.c",
+      "expm1l.c",
+      "log10l.c",
+      "log1pl.c",
+      "log2l.c",
+      "logl.c",
+    ]
+  }
+}
diff --git a/third_party/ulib/musl/third_party/smoothsort/BUILD.gn b/third_party/ulib/musl/third_party/smoothsort/BUILD.gn
new file mode 100644
index 0000000..157ded1
--- /dev/null
+++ b/third_party/ulib/musl/third_party/smoothsort/BUILD.gn
@@ -0,0 +1,11 @@
+# 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.
+
+source_set("smoothsort") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "qsort.c",
+  ]
+}
diff --git a/third_party/ulib/musl/third_party/tre/BUILD.gn b/third_party/ulib/musl/third_party/tre/BUILD.gn
new file mode 100644
index 0000000..0a0804b
--- /dev/null
+++ b/third_party/ulib/musl/third_party/tre/BUILD.gn
@@ -0,0 +1,14 @@
+# 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.
+
+source_set("tre") {
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  sources = [
+    "regcomp.c",
+    "regerror.c",
+    "regexec.c",
+    "tre-mem.c",
+  ]
+}
diff --git a/third_party/ulib/musl/zircon/BUILD.gn b/third_party/ulib/musl/zircon/BUILD.gn
new file mode 100644
index 0000000..c7c1d65
--- /dev/null
+++ b/third_party/ulib/musl/zircon/BUILD.gn
@@ -0,0 +1,17 @@
+# 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.
+
+source_set("zircon") {
+  sources = [
+    "getentropy.c",
+    "internal.c",
+    "take_startup_handle.c",
+    "thrd_get_zx_handle.c",
+  ]
+  configs -= [ "$zx/public/gn/config:user" ]
+  configs += [ "$zx/third_party/ulib/musl:musl_config" ]
+  deps = [
+    "$zx/system/ulib/runtime",
+  ]
+}
diff --git a/third_party/ulib/ngunwind/BUILD.gn b/third_party/ulib/ngunwind/BUILD.gn
new file mode 100644
index 0000000..289dcc7
--- /dev/null
+++ b/third_party/ulib/ngunwind/BUILD.gn
@@ -0,0 +1,131 @@
+# 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("$zx/public/gn/config/levels.gni")
+
+library("ngunwind") {
+  sdk = "shared"
+  sdk_headers = [
+    "ngunwind/private/compiler.h",
+    "ngunwind/private/config.h",
+    "ngunwind/private/dwarf-config.h",
+    "ngunwind/private/dwarf_i.h",
+    "ngunwind/private/elf32.h",
+    "ngunwind/private/elf64.h",
+    "ngunwind/private/elfxx.h",
+    "ngunwind/private/fuchsia_i.h",
+    "ngunwind/private/libunwind-common.h",
+    "ngunwind/private/libunwind-dynamic.h",
+    "ngunwind/private/libunwind_i.h",
+    "ngunwind/private/mempool.h",
+    "ngunwind/private/remote.h",
+    "ngunwind/private/tgt-aarch64.h",
+    "ngunwind/private/tgt-arm.h",
+    "ngunwind/private/tgt-x86_64.h",
+    "ngunwind/private/tgt_i-aarch64.h",
+    "ngunwind/private/tgt_i-arm.h",
+    "ngunwind/private/tgt_i-x86_64.h",
+    "ngunwind/dwarf-eh.h",
+    "ngunwind/dwarf.h",
+    "ngunwind/fuchsia.h",
+    "ngunwind/libunwind.h",
+  ]
+  shared = true
+  configs += [ ":private_config" ]
+  deps = [
+    "$zx/system/ulib/zircon",
+  ]
+  sources = [
+    "src/dwarf/Gexpr.c",
+    "src/dwarf/Gfde.c",
+    "src/dwarf/Gfind_proc_info-lsb.c",
+    "src/dwarf/Gfind_unwind_table.c",
+    "src/dwarf/Gparser.c",
+    "src/dwarf/Gpe.c",
+    "src/dwarf/Gstep.c",
+    "src/dwarf/global.c",
+    "src/fuchsia.c",
+    "src/mi/Gdestroy_addr_space.c",
+    "src/mi/Gdyn-extract.c",
+    "src/mi/Gdyn-remote.c",
+    "src/mi/Gfind_dynamic_proc_info.c",
+    "src/mi/Gget_accessors.c",
+    "src/mi/Gget_fpreg.c",
+    "src/mi/Gget_proc_info_by_ip.c",
+    "src/mi/Gget_proc_name.c",
+    "src/mi/Gget_reg.c",
+    "src/mi/Gput_dynamic_unwind_info.c",
+    "src/mi/Gset_caching_policy.c",
+    "src/mi/Gset_fpreg.c",
+    "src/mi/Gset_reg.c",
+    "src/mi/common.c",
+    "src/mi/flush_cache.c",
+    "src/mi/init.c",
+    "src/mi/mempool.c",
+    "src/mi/strerror.c",
+  ]
+  if (current_cpu == "arm64") {
+    sources += [
+      "src/aarch64/Gcreate_addr_space.c",
+      "src/aarch64/Gget_proc_info.c",
+      "src/aarch64/Gget_save_loc.c",
+      "src/aarch64/Gglobal.c",
+      "src/aarch64/Ginit.c",
+      "src/aarch64/Ginit_local.c",
+      "src/aarch64/Ginit_remote.c",
+      "src/aarch64/Gregs.c",
+      "src/aarch64/Gsignal_frame.c",
+      "src/aarch64/Gstash_frame.c",
+      "src/aarch64/Gstep.c",
+      "src/aarch64/fuchsia.c",
+      "src/aarch64/regname.c",
+      "src/elf64.c",
+    ]
+  } else if (current_cpu == "x64") {
+    sources += [
+      "src/elf64.c",
+      "src/x86_64/Gcreate_addr_space.c",
+      "src/x86_64/Gget_proc_info.c",
+      "src/x86_64/Gget_save_loc.c",
+      "src/x86_64/Gglobal.c",
+      "src/x86_64/Ginit.c",
+      "src/x86_64/Ginit_local.c",
+      "src/x86_64/Ginit_remote.c",
+      "src/x86_64/Gregs.c",
+      "src/x86_64/Gsignal_frame.c",
+      "src/x86_64/Gstash_frame.c",
+      "src/x86_64/Gstep.c",
+      "src/x86_64/fuchsia.c",
+      "src/x86_64/regname.c",
+    ]
+  }
+
+  # Compile this with frame pointers so that if we crash
+  # the simplistic unwinder will work.
+  configs -= [ "$zx/public/gn/config:default_frame_pointers" ]
+  configs += [ "$zx/public/gn/config:frame_pointers" ]
+
+  if (opt_level < 2) {
+    # Force -O2 since the library doesn't build with -Og.
+    configs -= [ "$zx/public/gn/config:opt_level" ]
+    cflags = [ "-O2" ]
+  }
+}
+
+config("private_config") {
+  visibility = [ ":*" ]
+
+  defines = [ "DEBUG" ]
+  include_dirs = [
+    "include/ngunwind",
+    "include/ngunwind/private",
+  ]
+
+  # cflags has to go in a config rather than directly in the target because
+  # the target's cflags comes before the standard configs that include the
+  # positive -W* switches, but -Wno-* switches must come afterwards.
+  if (!is_gcc) {
+    cflags = [ "-Wno-absolute-value" ]
+  }
+}
diff --git a/third_party/ulib/usbhost/BUILD.gn b/third_party/ulib/usbhost/BUILD.gn
new file mode 100644
index 0000000..9a25d8a
--- /dev/null
+++ b/third_party/ulib/usbhost/BUILD.gn
@@ -0,0 +1,13 @@
+# 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.
+
+assert(current_os == "linux")
+
+library("usbhost") {
+  host = true
+  static = false
+  sources = [
+    "usbhost.c",
+  ]
+}