<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ARCHITECTURE.md - fork/rules_rust @ patching</title>
<meta name="description" content="ARCHITECTURE.md in fork/rules_rust at patching.">
<meta property="og:title" content="ARCHITECTURE.md - fork/rules_rust @ patching">
<meta property="og:description" content="ARCHITECTURE.md in fork/rules_rust at patching.">
<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="patching" data-tip="285c36a623da1fba565098c0a65746ca7a2f7ebf">
<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">Jonathon Belotti</span><span class="commit-message" data-commit="e054e33970f881cd8f71bb8e662f11b4e11e8bd1">Fix typos in ARCHITECTURE.md (#821)</span><span class="snapshot-sha sha" data-commit="e054e33970f881cd8f71bb8e662f11b4e11e8bd1">e054e339</span><time datetime="2021-07-04T22:51:47+10:00" title="2021-07-04 22:51:47 +1000">2021-07-04</time></p>
<header class="topbar"><details class="switcher"><summary>patching</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 class="current" 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 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> / <span class="cur">ARCHITECTURE.md</span></nav>
<span class="view-stats"><span>2.6 KiB</span><span>58 lines</span></span><span class="actions"><a class="raw" href="/fork/rules_rust/raw/c9a7a09ab8b65dd4aad9d3354b783b33deed6c4a/ARCHITECTURE.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>Rules Rust - Architecture</h1>
<p>In this file we describe how we think about the architecture
of <code>rules_rust</code>. Its goal is to help contributors orient themselves, and to
document code restrictions and assumptions.</p>
<p>In general we try to follow the common standard defined by
https://docs.bazel.build/versions/master/skylark/deploying.html.</p>
<h2>//rust</h2>
<p>This is the core package of the rules. It contains all the core rules such as
<code>rust_binary</code> and <code>rust_library</code>. It also contains <code>rust_common</code>, a Starlark
struct providing all rules_rust APIs that one might need when writing custom
rules integrating with rules_rust.</p>
<p><code>//rust</code> and all its subpackages have to be standalone. Users who only need
the core rules should be able to ignore all other packages.</p>
<p><code>//rust:defs.bzl</code> is the file that all users of <code>rules_rust</code> will be using.
Everything in this file can be used (depended on) and is supported  (though
stability is not currently guaranteed across commits, see
<a href="https://github.com/bazelbuild/rules_rust/issues/600">#600</a>). Typically this
file re-exports definitions from other files, typically from <code>//rust/private</code>.
Also other packages in <code>rules_rust</code> should access core rules through the public
API only. We expect dogfooding our own APIs increases their
quality.</p>
<p><code>//rust/private</code> package contains code for rule implementation. This file can only
depend on <code>//rust</code> and its subpackages. Exceptions are Bazel's builtin packages
and public APIs of other rules (such as <code>rules_cc</code>). Depending on
<code>//rust/private</code> from packages other than <code>//rust</code> is not supported, we reserve
the right to change anything there and not tell anybody.</p>
<p>When core rules need custom tools (such as process wrapper, launcher, test
runner, and so on), they should be stored in <code>//rust/tools</code> (for public tools)
or in <code>//rust/private/tools</code> (for private tools). These should:</p>
<ul>
<li>be essential (it does not make sense to have core rules without them)</li>
<li>have few or no third party dependencies, and their third party dependencies
should be checked in.</li>
<li>be usable for cross compilation</li>
<li>have only essential requirements on the host system (requiring that a custom
library is installed on the system is frowned upon)</li>
</ul>
<h2>//examples (@examples)</h2>
<p>Examples package is actually a local repository. This repository can have
additional dependencies on anything that helps demonstrate an example. Non
trivial examples should have an accompanying README.md file.</p>
<p>The goal of examples is to demonstrate usage of <code>rules_rust</code>, not to test code.
Use <code>//test</code> for testing.</p>
<h2>//test</h2>
<p>Contains unit (in <code>//test/unit</code>) and integration tests. CI configuration is
stored in .bazelci.</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>Rules Rust - Architecture</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">In this file we describe how we think about the architecture</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text">of `rules_rust`. Its goal is to help contributors orient themselves, and to</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">document code restrictions and assumptions.</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">In general we try to follow the common standard defined by</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text">https://docs.bazel.build/versions/master/skylark/deploying.html.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"><a-p>##</a-p> <a-tt>//rust</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">This is the core package of the rules. It contains all the core rules such as</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text">`rust_binary` and `rust_library`. It also contains `rust_common`, a Starlark</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text">struct providing all rules_rust APIs that one might need when writing custom</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text">rules integrating with rules_rust.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text">`//rust` and all its subpackages have to be standalone. Users who only need</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text">the core rules should be able to ignore all other packages.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text">`//rust:defs.bzl` is the file that all users of `rules_rust` will be using.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text">Everything in this file can be used (depended on) and is supported  (though</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text">stability is not currently guaranteed across commits, see</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text">[#600](https://github.com/bazelbuild/rules_rust/issues/600)). Typically this</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text">file re-exports definitions from other files, typically from `//rust/private`.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text">Also other packages in `rules_rust` should access core rules through the public</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text">API only. We expect dogfooding our own APIs increases their</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text">quality.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text">`//rust/private` package contains code for rule implementation. This file can only</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text">depend on `//rust` and its subpackages. Exceptions are Bazel&#39;s builtin packages</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text">and public APIs of other rules (such as `rules_cc`). Depending on</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text">`//rust/private` from packages other than `//rust` is not supported, we reserve</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text">the right to change anything there and not tell anybody.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text">When core rules need custom tools (such as process wrapper, launcher, test</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text">runner, and so on), they should be stored in `//rust/tools` (for public tools)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text">or in `//rust/private/tools` (for private tools). These should:</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"><a-p>* </a-p>be essential (it does not make sense to have core rules without them)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"><a-p>* </a-p>have few or no third party dependencies, and their third party dependencies</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"><a-p>  </a-p>  should be checked in.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text"><a-p>* </a-p>be usable for cross compilation</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text"><a-p>* </a-p>have only essential requirements on the host system (requiring that a custom</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text"><a-p>  </a-p>  library is installed on the system is frowned upon)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text"><a-p>## </a-p><a-tt>//examples (@examples)</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text"><a-p>Examples package is actually a local repository. This repository can have</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"><a-p>additional dependencies on anything that helps demonstrate an example. Non</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text"><a-p>trivial examples should have an accompanying README.md file.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text"><a-p>The goal of examples is to demonstrate usage of `rules_rust`, not to test code.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text"><a-p>Use `//test` for testing.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L55" href="#L55">55</a><span class="code-text"><a-p>## </a-p><a-tt>//test</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L56" href="#L56">56</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L57" href="#L57">57</a><span class="code-text">Contains unit (in `//test/unit`) and integration tests. CI configuration is</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L58" href="#L58">58</a><span class="code-text">stored in .bazelci.</span></span></pre></div></div>
</main>
</body>
</html>
