Restrict cargo to //third_party/rust_crates

Change-Id: I505be9e5905d16896c9087d10e0bba7d6acb29fb
diff --git a/.cargo/config b/.cargo/config
index 746bd01..92a7f2f 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -1,3 +1,10 @@
 [target.aarch64-unknown-linux-musl]
 linker = "aarch64-linux-gnu-gcc"
 rustflags = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ]
+
+[source.crates-io]
+replace-with = "vendored-sources"
+
+[source.vendored-sources]
+directory = "rust-crates/rustc_deps/vendor"
+
diff --git a/.gitignore b/.gitignore
index 0f9d898..3a1a183 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 target
 out
+rust-crates
\ No newline at end of file
diff --git a/build.sh b/build.sh
index 4f25ec1..87e4eae 100755
--- a/build.sh
+++ b/build.sh
@@ -25,6 +25,14 @@
 declare -r OUT_DIR="out/${ARCH}"
 declare -r IMAGE_FILE="out/linux-tests-${ARCH}.img"
 
+if [ ! -d "rust-crates" ]; then
+  git clone "https://fuchsia.googlesource.com/third_party/rust-crates"
+else
+  pushd "rust-crates"
+  git pull
+  popd
+fi
+
 cargo build --target=${TARGET}
 
 mkdir -p ${OUT_DIR}