Add prebuilts as a submodule.

This contains prebuilt build tools. They are used during development as
well as for server builds.

Change-Id: Ia6fc5cbadf99e4978abd7f371d09b94e545ca433
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..96882df
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "prebuilts"]
+	path = prebuilts
+	url = sso://hafnium/hafnium/prebuilts
diff --git a/Makefile b/Makefile
index 6a6736f..3847c07 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,10 @@
 OUT ?= out
 
-GN ?= ../gn/out/gn
-NINJA ?= ninja
+# Set path to prebuilts
+UNNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]')
+PREBUILTS := prebuilts/$(UNNAME_S)-x64
+GN ?= $(PREBUILTS)/gn/gn
+NINJA ?= $(PREBUILTS)/ninja/ninja
 
 # Configure the build arguments
 GCC ?= false
@@ -11,7 +14,7 @@
 all: $(OUT)/build.ninja
 	@$(NINJA) -C $(OUT)
 
-$(OUT)/build.ninja: $(GN) $(OUT)/args.gn
+$(OUT)/build.ninja: $(OUT)/args.gn
 	@$(GN) gen $(OUT)
 
 # Configure the build by loading the configuration arguments for the
@@ -24,11 +27,6 @@
 	@echo >> $@
 	@cat $< >> $@
 
-$(GN):
-	git clone https://gn.googlesource.com/gn ../gn
-	cd ../gn && python build/gen.py
-	ninja -C ../gn/out
-
 clean:
 	@$(NINJA) -C $(OUT) -t clean
 
diff --git a/build/toolchain/host/BUILD.gn b/build/toolchain/host/BUILD.gn
index 76db0e6..4532e0d 100644
--- a/build/toolchain/host/BUILD.gn
+++ b/build/toolchain/host/BUILD.gn
@@ -1,3 +1,10 @@
+# Host toolchain specific build arguments.
+declare_args() {
+  # Build with a specific compiler version e.g. when building with clang, set
+  # to "3.9" to build with `clang-3.9`.
+  host_cc_version = ""
+}
+
 # Template for host toolchains.
 template("cc_toolchain") {
   toolchain(target_name) {
@@ -7,6 +14,10 @@
 
     cc = "${invoker.cc}"
     cxx = "${invoker.cxx}"
+    if (host_cc_version != "") {
+      cc += "-${host_cc_version}"
+      cxx += "-${host_cc_version}"
+    }
     if (defined(invoker.cflags)) {
       cc += " ${invoker.cflags}"
       cxx += " ${invoker.cflags}"
diff --git a/kokoro/ubuntu/build.sh b/kokoro/ubuntu/build.sh
index 596ca4f..95da482 100755
--- a/kokoro/ubuntu/build.sh
+++ b/kokoro/ubuntu/build.sh
@@ -11,16 +11,18 @@
 then
 	# Server
 	cd git/hafnium
-	mkdir out
-	echo "arch_cc_version = \"3.9\"" > out/args.gn
+	make out/args.gn
+	echo "arch_cc_version = \"3.9\"" >> out/args.gn
+	echo "host_cc_version = \"3.9\"" >> out/args.gn
 else
 	# Local
 	echo "Testing kokoro build locally..."
+	make out/args.gn
 fi
 
 # TODO: Kokoro is missing ninja, gcc-4.9 or above and qemu
 # Check the build works
-# make
+make
 
 # # Check to code looks healthy, failing if any changes were made
 # make format
diff --git a/prebuilts b/prebuilts
new file mode 160000
index 0000000..7ea7831
--- /dev/null
+++ b/prebuilts
@@ -0,0 +1 @@
+Subproject commit 7ea7831e75ae22fa0a1467c302e656819132a6fd