github.com/sercand/please@v13.4.0+incompatible/docs/pleasings.html (about)

     1  
     2      <h1>Extra rules (aka. Pleasings)</h1>
     3  
     4      <p>Please comes with built-in rules for Go, Python, Java, C++, Protocol Buffers
     5        and a few other bits & pieces. While it's nice to have a bunch of capabilities by
     6        default, it's obviously not practical for every language to be part of the core repo,
     7        and indeed part of the original design was to make it easy to add support for new
     8        languages without having to update the core code.
     9      </p>
    10  
    11      <p>We collect support for additional languages in
    12        <a href="https://github.com/thought-machine/pleasings">a separate repo</a>.
    13        These are somewhat pithily named Pleasings and have rules for various new languages that are
    14        either still pretty early stage and unstable (the rules, not the language :) ) or
    15        sufficiently esoteric that having them part of the core seems inappropriate.
    16      </p>
    17  
    18      <h2>Loading additional rules</h2>
    19  
    20      <p>The simplest and most lightweight way to load new rules is to do it directly with
    21        <code>subinclude</code>, like so:</p>
    22  
    23      <pre><code>
    24          subinclude('https://github.com/thought-machine/pleasings/raw/master/rust/rust.build_defs')
    25  
    26          rust_library(
    27              name = 'my_rust_lib',
    28              srcs = ['mine.rs'],
    29          )
    30      </code></pre>
    31  
    32      <p>Some rules may have extra requirements, for example some single package in which you have
    33        to set up a one-off set of targets. The individual rules will document what's required.</p>
    34  
    35      <h2>The more repeatable solution</h2>
    36  
    37      <p>As noted the above solution is nice and lightweight, and Please will take care of
    38        deduplicating & caching the download from github, so it works fairly well for straightforward
    39        cases. But there are times when you might want more control, like pinning to a particular
    40        version so you're not broken by any incompatible changes, or hash verifying the downloaded
    41        rules so you know you're always getting what you expect.
    42      </p>
    43  
    44      <p>The idiomatic way of achieving this is to set up one centralised package to do the
    45        download more carefully and subinclude from there. Conventionally we use
    46        <code>//build_defs</code> but of course this package can be anywhere. You'd set up
    47        <code>//build_defs/BUILD</code> as follows:
    48      </p>
    49  
    50      <pre><code>
    51          package(default_visibility = ['PUBLIC'])
    52  
    53          remote_file(
    54              name = 'rust',
    55              url = 'https://raw.githubusercontent.com/thought-machine/pleasings/4a8158a65ef39e7dd9a1569fbfa1e5eec398e066/rust/rust.build_defs',
    56              hashes = [
    57                  'bbfa10e522cfc870bfcbfbae6b899b770b54031a',
    58              ],
    59          )
    60      </code></pre>
    61  
    62      <p>Then from any other package in your repo you could write the following:</p>
    63  
    64      <pre><code>
    65          subinclude('//build_defs:rust')
    66  
    67          rust_library(
    68              name = 'my_rust_lib',
    69              srcs = ['mine.rs'],
    70          )
    71      </code></pre>
    72  
    73      <p>This has the advantage of a shorter call to <code>subinclude</code> in each package,
    74        but more seriously states the expected revision & hash in a centralised location so
    75        your build always uses the same upstream version of the rules to compile it.
    76      </p>