slang solution1.sv --enable-legacy-protect -I . -Wno-protected-envelope
slang solution2.sv --enable-legacy-protect -I . -Wno-protected-envelope --translate-off-format slang_pragma,translate_off,translate_ondefault on attr.label (and attr.label_list, attr.string_keyed_label_dict) can be a function!
- but: only for private attributes
this includes things like "late bound defaults"
but also your own functions can ask for other (public) attributes of the rule as keyword args and use them to compute a default!
a neat alternative to initializers on rules
Previously we explored a way to have some degree of dynamic dependencies in Bazel (input "subsetting") using TreeArtifacts.
The particular use case modeled in the previous gist involved:
- a language with somewhat coarse
libraryandbinaryrules (i.e. each rule describes a collection of files and their collective dependencies — the default for most Bazel rulesets) - a monolithic (and slow!) compiler whose compilation unit size is the entire binary (rather than something smaller like modules or source files)
- i.e. exacerbating the pain of not having "perfect" file-level dependency information
- source files that can be easily (and quickly) scanned to determine which dependencies are unused
...
observations:
- path mapping does not really[^1] "mask" out the repo name from non-main repo paths: source files OR generated artifacts
- this means that whether you build a particular target (or really produce a particular action for the target) when that target is in the main (root) repo vs. when its in an "external" repo effects the paths used in the action
- i.e. you will not get cache hits if you build
//:your_targetand then pull your repo into another bazel workspace as@fooand build@foo//:your_target - TODO: would be nice to repo names as well...
- path mapping silently falls back to using unmapped paths if the set of mapped paths has any conflicts (see
:example_both)
- note that
ctx.actions.run(_shell)'sinputsdoes influence path mapping and does appear to factor into how conflicts are detected but... if you try to add a path to the command line (i.e. viaarguments) that you haven't listed ininputsit isn't an error — some path mapping heuristi
the idea is to have testonly-esque checks
consider a project where we want to partition content (for an existing rule) into three categories:
- "open-source"; a.k.a.
oss - "proprietary"; a.k.a.
prp - "development-only"; a.k.a.
dev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! for a given `N`, how many unique shapes of `N` contiguous minos (all connected via at least one | |
| //! of the four cardinal directions) are possible? | |
| //! | |
| //! a shape is unique if no translation or rotation of a shape makes it the same as another shape | |
| use std::{collections::HashSet, fmt}; | |
| #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] | |
| struct Coord<const N: usize> { | |
| x: u8, // 0 <= x < N |
NewerOlder
