Skip to content

Instantly share code, notes, and snippets.

View rrbutani's full-sized avatar
🐢
slowly but surely

Rahul Butani rrbutani

🐢
slowly but surely
  • 19:28 (UTC -07:00)
View GitHub Profile
'''Module extension machinery that fetches NuGet packages, given a
`packages.lock.json` file (NuGet lock file).
Intended for use with `nuget_repo` in `rules_dotnet`.
The machinery here makes use of the NuGet v3 API to fill in information not
present in the lock file (i.e. dependency edges, actual nupkg hashes,
information about tools) and makes use of the module extension facts API for
speed (i.e. so that subsequent module extension evaluations for the same
dependencies do not need to hit the NuGet APIs again).

known:

  • ctx.expand_location expands to .path, not short_path
    • there's a hidden kwarg (that we are not allowed to use) short_paths that provides the latter...

to be determined (by this experiment):

  1. are variables provided via the toolchains attr implicitly added to ctx.var?
  2. how do rules, in practice, grab files from elements in toolchains and add them to the inputs of the action(s) crafted?
  3. what targets/files are implicitly available to ctx.expand_location?
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_on

VCS UUM Library Experiments

....

Notes on Library Ordering

notes:

  • post-order (children before parents) order is what makes sense for

default 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 library and binary rules (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
❯ pytest --chrome-trace parallel-baseline.json -n auto --dist=worksteal
664 passed, 24 warnings in 9.08s

chrome trace of running pytest w/xdist's workstealing strategy

❯ pytest --chrome-trace parallel-reordered.json -n auto --dist=worksteal --expensive-tests-first