github.com/sercand/please@v13.4.0+incompatible/docs/subrepos.html (about) 1 <h1>Subrepos</h1> 2 3 <p class="experimental">This feature is still experimental; some aspects may not work fully 4 or at all just yet. Proceed with caution!</p> 5 6 <p>It is possible to pull in dependencies from separate repositories using Please. 7 These are called subrepos and are defined in BUILD files.</p> 8 9 <p>They're heavily based on Bazel's similar concept and a certain amount of interoperability 10 is possible.</p> 11 12 <h2>Defining a subrepo</h2> 13 14 <p>Subrepos are defined using builtins like <a href="lexicon.html#http_archive">http_archive</a> or 15 <a href="lexicon.html#new_http_archive">new_http_archive</a>. These download a remote file and 16 extract it, and make the contents available to other rules. The main difference is that 17 <code>new_http_archive</code> needs to be given a BUILD file but <code>http_archive</code> 18 uses one existing within the file.</p> 19 20 <p>For example (as seen at the root of the Please repo): 21 <pre><code>http_archive( 22 name = "pleasings", 23 hashes = ["388baebf9381c619f13507915f16d0165a5dc13e"], 24 strip_prefix = "pleasings-f0c549b375067802400699247106e4907de917c2", 25 urls = ["https://github.com/thought-machine/pleasings/archive/f0c549b375067802400699247106e4907de917c2.zip"], 26 ) 27 </code></pre></p> 28 29 <p>Currently, subrepo rules only work when placed at the repo root. In future we intend to 30 lift this restriction. In Bazel compatibility mode they can also be used within the 31 WORKSPACE file.</p> 32 33 <h2>Using subrepos</h2> 34 35 <p>Rules within subrepos can be referenced using an <code>@</code> prefix on rules, anywhere 36 where a build rule would normally be accepted. For example: 37 <pre><code>subinclude("@pleasings//go:go_bindata") 38 39 cc_test( 40 name = "my_test", 41 ... 42 deps = [ 43 "@pleasings//eggs:spam", 44 ], 45 ) 46 </code></pre> 47 48 In this case <code>pleasings</code> corresponds to the name of the subrepo as declared in 49 the <code>http_archive</code> rule above.</p> 50 51 <p>Subrepos also underpin <a href="cross_compiling.html">cross-compiling</a> and share the same 52 syntax; you can use that to reference architectures as well. There is currently some ambiguity 53 here and so it is best not to define subrepo names that match cross-compile architectures.</p> 54 55 <p>If the subrepo and the package names are the same, for example, <code>@unittest_cpp//:unittest_cpp</code>, 56 the build label reference to the target can be abbreviated, like so:</p> 57 58 <pre><code> 59 cc_test( 60 name = "my_test", 61 ... 62 deps = [ 63 "@unittest_cpp", 64 ], 65 ) 66 </code></pre>