pw_toolchain: Support Rust toolchains in downstream projects

Change-Id: I74f22a6b46a25b881ced36ccc22910a11f9f1443
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/209871
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Erik Gilling <konkers@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/pw_toolchain/rust/defs.bzl b/pw_toolchain/rust/defs.bzl
index 11fdb4e..3041af3 100644
--- a/pw_toolchain/rust/defs.bzl
+++ b/pw_toolchain/rust/defs.bzl
@@ -80,11 +80,13 @@
 ]
 
 # buildifier: disable=unnamed-macro
-def pw_rust_register_toolchain_and_target_repos(cipd_tag):
+def pw_rust_register_toolchain_and_target_repos(cipd_tag, pigweed_repo_name = "@pigweed"):
     """Declare and register CIPD repos for Rust toolchain and target rupport.
 
     Args:
       cipd_tag: Tag with which to select specific package versions.
+      pigweed_repo_name: The name of the pigweed used to reference build files
+        for the registered repositories.  Defaults to "@pigweed".
     """
     for host in HOSTS:
         cipd_os = host["os"]
@@ -93,14 +95,14 @@
 
         cipd_repository(
             name = "rust_toolchain_host_{}_{}".format(host["os"], host["cpu"]),
-            build_file = "//pw_toolchain/rust:rust_toolchain.BUILD",
+            build_file = "{}//pw_toolchain/rust:rust_toolchain.BUILD".format(pigweed_repo_name),
             path = "fuchsia/third_party/rust/host/{}-{}".format(cipd_os, host["cipd_arch"]),
             tag = cipd_tag,
         )
 
         cipd_repository(
             name = "rust_toolchain_target_{}".format(host["triple"]),
-            build_file = "//pw_toolchain/rust:rust_stdlib.BUILD",
+            build_file = "{}//pw_toolchain/rust:rust_stdlib.BUILD".format(pigweed_repo_name),
             path = "fuchsia/third_party/rust/target/{}".format(host["triple"]),
             tag = cipd_tag,
         )
@@ -108,7 +110,7 @@
     for target in EXTRA_TARGETS:
         cipd_repository(
             name = "rust_toolchain_target_{}".format(target["triple"]),
-            build_file = "//pw_toolchain/rust:rust_stdlib.BUILD",
+            build_file = "{}//pw_toolchain/rust:rust_stdlib.BUILD".format(pigweed_repo_name),
             path = "fuchsia/third_party/rust/target/{}".format(target["triple"]),
             tag = cipd_tag,
         )