You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No em dashes or contractions, matching the agent-facing docs already in
the repo. Also drops a few facts that would go stale without anything
catching them: the registry overlay glob, the platform count, and the
claim that nothing loads defs.bzl.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .github/skills/bazel/SKILL.md
+44-46Lines changed: 44 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
name: bazel
3
-
description: Conventions for editing Bazel files in the github/codeql repository — the shared `misc/bazel` helpers, `codeql_platform_select` and the `{CODEQL_PLATFORM}` packaging placeholder, adding `MODULE.bazel` dependencies, and the `semmle_code` stub that keeps the standalone build working. Use when editing any `BUILD.bazel`, `*.bzl`, `MODULE.bazel` or `.bazelrc` here, and before validating such an edit.
3
+
description: Conventions for editing Bazel files in the github/codeql repository: the shared `misc/bazel` helpers, `codeql_platform_select` and the `{CODEQL_PLATFORM}` packaging placeholder, adding `MODULE.bazel` dependencies, and the `semmle_code` stub that keeps the standalone build working. Use when editing any `BUILD.bazel`, `*.bzl`, `MODULE.bazel` or `.bazelrc` here, and before validating such an edit.
4
4
---
5
5
6
6
# Bazel in the codeql repository
@@ -12,11 +12,11 @@ also consumed by an internal module that depends on it; standalone builds replac
12
12
13
13
Things that will waste your time or produce a wrong edit here. Read this section even if you skip the rest.
14
14
15
-
***`//...` does not work.**`bazel build //...`, and even `bazel query //...`, fail at the repo root — the patched
16
-
modules under `misc/bazel/registry/modules/*/*/overlay` are real packages referencing repos that are not visible from
17
-
the main repo, and [`.bazelrc`](../../../.bazelrc) notes that transitions break `...` builds separately. **Validate
18
-
the specific target or package you changed**, not a recursive pattern. The error names an unrelated directory and is
19
-
very easy to misdiagnose.
15
+
***`//...` does not work.**`bazel build //...`, and even `bazel query //...`, fail at the repo root: the patched
16
+
modules under [`misc/bazel/registry`](../../../misc/bazel/registry) are real packages referencing repos that are not
17
+
visible from the main repo, and [`.bazelrc`](../../../.bazelrc) notes separately that transitions break `...` builds.
18
+
The error names a registry directory unrelated to your edit, so it is easy to misdiagnose. **Validate the specific
19
+
target or package you changed**, not a recursive pattern.
20
20
***There is no `MODULE.bazel.lock`, deliberately.**[`.bazelrc`](../../../.bazelrc) sets `--lockfile_mode=off` because
21
21
the workspace-relative module override makes a lockfile unstable. Do not add one, and do not "fix" its absence.
22
22
***`linux_arm64` vs `linux-arm64`.** The keyword argument and config setting use an underscore; the platform *string*
@@ -26,40 +26,40 @@ Things that will waste your time or produce a wrong edit here. Read this section
26
26
27
27
## Rules of thumb
28
28
29
-
***Copy a neighbouring target rather than inventing a shape.**Note that packaging is not uniform — some packages use
30
-
the `codeql_*` wrappers, others still use `pkg_files` directly — so copy the closest *working* neighbour and prefer
31
-
the wrapper for new code.
29
+
***Copy a neighbouring target rather than inventing a shape.**Packaging is not uniform: some packages use the
30
+
`codeql_*` wrappers, others still use `pkg_files` directly. Copy the closest *working* neighbour, and prefer the
31
+
wrapper for new code.
32
32
***Pin anything fetched over the network** with `sha256` or `integrity`. Bazel only *warns* on an unpinned download, so
33
33
nothing fails loudly, but the build stops being reproducible and a retagged upstream release silently changes what you
34
-
build. `lfs_archive` is the exception — content is pinned by git object.
35
-
***Format with `bazel run //misc/bazel/buildifier`.** It rewrites in place, so don't hand-tune formatting. Also wired as
36
-
a `pre-commit` hook ([`.pre-commit-config.yaml`](../../../.pre-commit-config.yaml)).
34
+
build. `lfs_archive` is the exception: content is pinned by git object.
35
+
***Format with `bazel run //misc/bazel/buildifier`.** It rewrites in place, so do not hand-tune formatting. Also wired
36
+
as a `pre-commit` hook ([`.pre-commit-config.yaml`](../../../.pre-commit-config.yaml)).
37
37
38
38
## Where new code goes
39
39
40
40
Bazel's own macro / rule / repository-rule distinction applies as usual. What is repo-specific:
41
41
42
-
| Adding…| Goes in |
42
+
| Adding | Goes in |
43
43
| --- | --- |
44
-
| a new packaging shape | extend [`misc/bazel/pkg.bzl`](../../../misc/bazel/pkg.bzl) — don't fork `pkg_files`|
45
-
| a new OS or arch split |[`misc/bazel/os.bzl`](../../../misc/bazel/os.bzl) — don't hand-roll a `select()` over `@platforms//`|
46
-
| a fetch of something external | a repository rule ([`lfs.bzl`](../../../misc/bazel/lfs.bzl), [`ripunzip.bzl`](../../../misc/ripunzip/ripunzip.bzl)) — not a `genrule`|
44
+
| a new packaging shape | extend [`misc/bazel/pkg.bzl`](../../../misc/bazel/pkg.bzl), do not fork `pkg_files`|
45
+
| a new OS or arch split |[`misc/bazel/os.bzl`](../../../misc/bazel/os.bzl), do not hand-roll a `select()` over `@platforms//`|
46
+
| a fetch of something external | a repository rule ([`lfs.bzl`](../../../misc/bazel/lfs.bzl), [`ripunzip.bzl`](../../../misc/ripunzip/ripunzip.bzl)), not a `genrule`|
47
47
| a wrapper used by one language | next to that language ([`swift/rules.bzl`](../../../swift/rules.bzl)) |
48
48
| a wrapper used across languages |`misc/bazel/`|
49
49
50
50
Prefer inline rules in `BUILD.bazel`. A `.bzl` file earns its `load()` only when the shape repeats across packages or a
51
51
value must be computed: [`rust.bzl`](../../../misc/bazel/rust.bzl) is worth it because every Rust binary that ships in a
52
52
pack must get the same universal-binary wrapper and symbols test, and forgetting either is a release bug. A local
53
-
debugging aid opts out and declares a plain `rust_binary` — see `swift-syntax-parse` in
53
+
debugging aid opts out and declares a plain `rust_binary`; see `swift-syntax-parse` in
54
54
[`unified/swift-syntax-rs/BUILD.bazel`](../../../unified/swift-syntax-rs/BUILD.bazel). The `_gen_binaries` list in
55
-
[`go/BUILD.bazel`](../../../go/BUILD.bazel) does not earn a `.bzl` — it is shared by two targets in one file, so a local
56
-
variable does the job.
55
+
[`go/BUILD.bazel`](../../../go/BUILD.bazel) does not earn a `.bzl`, because it is shared within a single file, where a
56
+
local variable does the job.
57
57
58
58
Macros here are typically a thin public wrapper around a private rule (`codeql_csharp_binary`, `swift_cc_binary`). Keep
59
-
the rule narrow and the ergonomics in the macro. Each macro decorates the caller's `name` to mint its helper targets
60
-
(`internal/<name>`, `single_arch/<name>`, `bin/<name>`), but the visibility they get is that macro's choice — private,
61
-
package default, or the caller's own — so read it instead of assuming. When an error names a target you cannot find in
62
-
any source file, a macro minted it — grep the suffix under `misc/bazel/`.
59
+
the rule narrow and the ergonomics in the macro. Each macro decorates the caller's `name` to mint its helper targets,
60
+
for example `internal/<name>` or `single_arch/<name>`. Their visibility is that macro's choice (private, package
61
+
default, or the caller's own), so read the macro instead of assuming. When an error names a target you cannot find in
62
+
any source file, a macro minted it: grep the suffix under `misc/bazel/`.
63
63
64
64
## Shared helpers
65
65
@@ -74,16 +74,15 @@ Frequently-used pieces, so you load the existing one instead of rewriting it. Re
0 commit comments