镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Generate the capnp files with one pattern rule - #156

Open
FrogAi wants to merge 1 commit into
pfeiferj:mainfrom
FrogAi:capnp-pattern-rule
Open

FrogAi wants to merge 1 commit into
pfeiferj:mainfrom
FrogAi:capnp-pattern-rule

Conversation

@FrogAi

@FrogAi FrogAi commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

The Makefile has five "cereal/*.capnp.go" rules that are the same rule with a different file name. This replaces them with one "%.capnp.go: %.capnp" pattern rule. "capnp compile -ogo" writes the ".go" file next to the schema, so "$<" gives the same command each rule had. The "capnp" target still lists the five files, so a new schema only needs adding there.

Audit report

Testing

In "golang:1.26.2-bookworm" with Debian's "capnp":

  • "make -n capnp" and "make -n build" print the same commands as main with every schema newer than its ".go" file, with none newer, and with only "log.capnp" newer.
  • A real "make capnp" after touching "custom.capnp" regenerated only "custom.capnp.go", and it came out the same as the committed file.

Difference

If a schema is deleted but its ".capnp.go" is left behind, main stops with "No rule to make target", while the pattern rule says "Nothing to be done" and keeps the old file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant