[go] use the usual go build rules for bootstrap

This is needed because `go run` can't work without GOCACHE being defined
in the environment, preventing bootstrap.

Change-Id: I3c2c591d9a9d862c1a8701f17d49b399d7659e89
diff --git a/BUILD.gn b/BUILD.gn
index d0f13d5..c47d358 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -13,24 +13,17 @@
 
 if (current_toolchain == target_toolchain) {
   _go_root = "$host_tools_dir/goroot"
-  _bootstrap_goroot = "//buildtools/${host_platform}/go"
 
-  action("makeroot") {
+  compiled_action("makeroot") {
     visibility = [ ":makefuchsia" ]
 
-    inputs = [
-      "makeroot.go",
-    ]
-
     depfile = "$target_gen_dir/$target_name.d"
     outputs = [
       "$target_gen_dir/$target_name.stamp",
     ]
 
-    script = rebase_path(_bootstrap_goroot + "/bin/go")
+    tool = "makeroot"
     args = [
-      "run",
-      rebase_path("makeroot.go", root_build_dir),
       "-source-goroot",
       rebase_path(".", root_build_dir),
       "-target-goroot",
@@ -45,7 +38,7 @@
     ]
   }
 
-  action("makefuchsia") {
+  compiled_action("makefuchsia") {
     visibility = [ ":go_runtime" ]
     deps = [
       ":makeroot",
@@ -56,12 +49,10 @@
       "$target_gen_dir/$target_name.stamp",
     ]
 
-    script = rebase_path(_bootstrap_goroot + "/bin/go")
+    tool = "makefuchsia"
     args = [
-      "run",
-      rebase_path("makefuchsia.go", root_build_dir),
       "-bootstrap-goroot",
-      rebase_path(_bootstrap_goroot),
+      rebase_path("//buildtools/${host_platform}/go"),
       "-gocache",
       gocache_dir,
       "-goroot",
diff --git a/makefuchsia/BUILD.gn b/makefuchsia/BUILD.gn
new file mode 100644
index 0000000..7a29008
--- /dev/null
+++ b/makefuchsia/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.
+
+import("//build/go/go_binary.gni")
+import("//build/go/go_library.gni")
+
+go_library("makefuchsia_lib") {
+  name = "makefuchsia"
+}
+
+go_binary("makefuchsia") {
+  gopackage = "makefuchsia"
+
+  deps = [
+    ":makefuchsia_lib",
+  ]
+}
diff --git a/makefuchsia.go b/makefuchsia/makefuchsia.go
similarity index 100%
rename from makefuchsia.go
rename to makefuchsia/makefuchsia.go
diff --git a/makeroot/BUILD.gn b/makeroot/BUILD.gn
new file mode 100644
index 0000000..dfe8d94
--- /dev/null
+++ b/makeroot/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.
+
+import("//build/go/go_binary.gni")
+import("//build/go/go_library.gni")
+
+go_library("makeroot_lib") {
+  name = "makeroot"
+}
+
+go_binary("makeroot") {
+  gopackage = "makeroot"
+
+  deps = [
+    ":makeroot_lib",
+  ]
+}
diff --git a/makeroot.go b/makeroot/makeroot.go
similarity index 100%
rename from makeroot.go
rename to makeroot/makeroot.go