Squashed 'third_party/rules_rust/' content from commit bf59038ca
git-subtree-dir: third_party/rules_rust
git-subtree-split: bf59038cac11798cbaef9f3bf965bad8182b97fa
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
Change-Id: I5a20e403203d670df467ea97dde9a4ac40339a8d
diff --git a/proto/raze/patch/BUILD.bazel b/proto/raze/patch/BUILD.bazel
new file mode 100644
index 0000000..a5e9d2a
--- /dev/null
+++ b/proto/raze/patch/BUILD.bazel
@@ -0,0 +1,8 @@
+package(default_visibility = ["//proto/raze:__subpackages__"])
+
+filegroup(
+ name = "patches",
+ srcs = [
+ "protobuf-2.8.2.patch",
+ ],
+)
diff --git a/proto/raze/patch/README.md b/proto/raze/patch/README.md
new file mode 100644
index 0000000..2cd05d7
--- /dev/null
+++ b/proto/raze/patch/README.md
@@ -0,0 +1,31 @@
+# Patches
+
+Cargo raze, in its remote mode allows for patches to be applied to a repository
+before building it with rustc. It is advisable to use this functionality
+sparingly, if at all. Also note that the patch is applied after all of the
+dependency resolution has been completed by cargo raze, and that patching the
+version of a dependency will not cause cargo raze to update that dependency in
+the BUILD file.
+
+The patch itself can be generated using git or another tool. The output of git
+diff requires the `-p1` option to remove the leading `/` from the git diff patch
+format.
+
+## protobuf-2.8.2
+
+The protobuf crate from the rust-protobuf repository introduced a build.rs
+script in the 2.x.x series. This generates a small version.rs file that would be
+[included into lib.rs](https://github.com/stepancheg/rust-protobuf/blob/v2.8/protobuf/src/lib.rs#L122).
+However, the build.rs file requires a number of environment variables, normally
+provided by cargo to the build file. Cargo raze does not provide these
+variables. The resulting code includes a version string and version identifier.
+The version string is then used by protobuf-codegen to generate code refering to
+the identifier in the protobuf library. The use can be seen
+[here](https://github.com/stepancheg/rust-protobuf/blob/v2.8/protobuf-codegen/src/lib.rs#L160).
+This is to enforce at compile time that the version of protobuf-codegen matches
+the version of the protobuf crate.
+
+For this crate, the patch that is applied is replacing the include! macro with
+what would be generated by the build.rs file. This lets us avoid running the
+build file altogether, at the expense of having to update the patch for every
+version.
diff --git a/proto/raze/patch/protobuf-2.8.2.patch b/proto/raze/patch/protobuf-2.8.2.patch
new file mode 100644
index 0000000..c81a911
--- /dev/null
+++ b/proto/raze/patch/protobuf-2.8.2.patch
@@ -0,0 +1,13 @@
+diff --git a/src/lib.rs b/src/lib.rs
+index b487e6e..38b7f7c 100644
+--- a/src/lib.rs
++++ b/src/lib.rs
+@@ -119,4 +119,7 @@ pub const VERSION: &str = "";
+ #[cfg(never)]
+ #[doc(hidden)]
+ pub const VERSION_IDENT: &str = "";
+-include!(concat!(env!("OUT_DIR"), "/version.rs"));
++pub const VERSION: &'static str = "2.8.2";
++#[doc(hidden)]
++pub const VERSION_IDENT: &'static str = "VERSION_2_8_2";
++pub const VERSION_2_8_2: () = ();