<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>proto/3rdparty/patches/README.md - fork/rules_rust @ 0.9.0</title>
<meta name="description" content="proto/3rdparty/patches/README.md in fork/rules_rust at 0.9.0.">
<meta property="og:title" content="proto/3rdparty/patches/README.md - fork/rules_rust @ 0.9.0">
<meta property="og:description" content="proto/3rdparty/patches/README.md in fork/rules_rust at 0.9.0.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="0.9.0" data-tip="0f3457316623f3f336fe72337c1e47932c046d15">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/rules_rust</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/rules_rust</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">UebelAndre</span><span class="commit-message" data-commit="83a03ab03e112bf4ba168b3dd03462b763b1ccb2">Updated proto rules to fetch dependencies using crate_universe (#1491)</span><span class="snapshot-sha sha" data-commit="83a03ab03e112bf4ba168b3dd03462b763b1ccb2">83a03ab0</span><time datetime="2022-08-02T06:11:47-07:00" title="2022-08-02 06:11:47 -0700">2022-08-02</time></p>
<header class="topbar"><details class="switcher"><summary>0.9.0</summary><div class="menu"><strong>branches</strong><a href="/fork/rules_rust/ref/cleanup/">cleanup</a><a href="/fork/rules_rust/ref/gh-pages/">gh-pages</a><a href="/fork/rules_rust/ref/main/">main</a><a href="/fork/rules_rust/ref/patching/">patching</a><a href="/fork/rules_rust/ref/rust-analyzer/">rust-analyzer</a><strong>tags</strong><a href="/fork/rules_rust/ref/0.10.0/">0.10.0</a><a href="/fork/rules_rust/ref/0.11.0/">0.11.0</a><a href="/fork/rules_rust/ref/0.5.0/">0.5.0</a><a href="/fork/rules_rust/ref/0.6.0/">0.6.0</a><a href="/fork/rules_rust/ref/0.7.0/">0.7.0</a><a href="/fork/rules_rust/ref/0.8.0/">0.8.0</a><a href="/fork/rules_rust/ref/0.8.1/">0.8.1</a><a class="current" href="/fork/rules_rust/ref/0.9.0/">0.9.0</a><a class="all" href="/fork/rules_rust/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/rules_rust/">rules_rust</a> / <a href="/fork/rules_rust/ref/0.9.0/tree/proto/">proto</a> / <a href="/fork/rules_rust/ref/0.9.0/tree/proto/3rdparty/">3rdparty</a> / <a href="/fork/rules_rust/ref/0.9.0/tree/proto/3rdparty/patches/">patches</a> / <span class="cur">README.md</span></nav>
<span class="view-stats"><span>1.3 KiB</span><span>27 lines</span></span><span class="actions"><a class="raw" href="/fork/rules_rust/raw/56e910b159ac10dbfa6aea3a7233c9f7e01ffcfe/proto/3rdparty/patches/README.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1>Patches</h1>
<p>Details related to patches required for the rules_rust protobuf rules.</p>
<h2>protobuf-2.8.2</h2>
<p>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
<a href="https://github.com/stepancheg/rust-protobuf/blob/v2.8/protobuf/src/lib.rs#L122">included into lib.rs</a>.
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
<a href="https://github.com/stepancheg/rust-protobuf/blob/v2.8/protobuf-codegen/src/lib.rs#L160">here</a>.
This is to enforce at compile time that the version of protobuf-codegen matches
the version of the protobuf crate.</p>
<p>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.</p>
<h2>com_google_protobuf-v3.10.0-bzl_visibility</h2>
<p>The patches here provide the required visibility to <code>*.bzl</code> files used by the rules defined in <code>com_google_protobuf</code>.</p>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>Patches</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">Details related to patches required for the rules_rust protobuf rules.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"><a-p>##</a-p> <a-tt>protobuf-2.8.2</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">The protobuf crate from the rust-protobuf repository introduced a build.rs</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">script in the 2.x.x series. This generates a small version.rs file that would be</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">[included into lib.rs](https://github.com/stepancheg/rust-protobuf/blob/v2.8/protobuf/src/lib.rs#L122).</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text">However, the build.rs file requires a number of environment variables, normally</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">provided by cargo to the build file. Cargo raze does not provide these</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">variables. The resulting code includes a version string and version identifier.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text">The version string is then used by protobuf-codegen to generate code refering to</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text">the identifier in the protobuf library. The use can be seen</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text">[here](https://github.com/stepancheg/rust-protobuf/blob/v2.8/protobuf-codegen/src/lib.rs#L160).</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text">This is to enforce at compile time that the version of protobuf-codegen matches</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text">the version of the protobuf crate.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text">For this crate, the patch that is applied is replacing the include! macro with</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text">what would be generated by the build.rs file. This lets us avoid running the</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text">build file altogether, at the expense of having to update the patch for every</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text">version.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"><a-p>##</a-p> <a-tt>com_google_protobuf-v3.10.0-bzl_visibility</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text">The patches here provide the required visibility to `*.bzl` files used by the rules defined in `com_google_protobuf`.</span></span></pre></div></div>
</main>
</body>
</html>
