Skip to content

starlark_repository: capture upstream BUILD files as starlark_package…#423

Merged
pcj merged 1 commit into
stardocfrom
stardoc-packageinfo
May 19, 2026
Merged

starlark_repository: capture upstream BUILD files as starlark_package…#423
pcj merged 1 commit into
stardocfrom
stardoc-packageinfo

Conversation

@pcj
Copy link
Copy Markdown
Member

@pcj pcj commented May 19, 2026

Adds a new "preserve" build_file_generation mode that runs cmd/preserve_packages between fetch_repo and gazelle. The tool mirrors fetch_repo -clean semantics (deletes WORKSPACE / MODULE.bazel / etc.) but renames BUILD and BUILD.bazel to BUILD.package and BUILD.bazel.package so the upstream package layout is preserved as opaque files rather than discarded.

The starlarkrepository gazelle extension grows a parallel pair of kinds alongside starlark_module / starlark_module_library:

  • starlark_package: one per BUILD*.package, src points at the preserved file. Name is the dot-sanitized filename (BUILD.package -> BUILD_package) to avoid clashing with starlark_module names derived from .bzl files.
  • starlark_package_library: emitted at the configured root, named "starlark_packages" (not "packages", which would clash with packages.bzl). Its packages attr is populated in Resolve via the RuleIndex.

starlark_repository.archive/.local default build_file_generation to "preserve" so users get the new behavior automatically; they can still override.

… targets

Adds a new "preserve" build_file_generation mode that runs cmd/preserve_packages
between fetch_repo and gazelle. The tool mirrors fetch_repo -clean semantics
(deletes WORKSPACE / MODULE.bazel / etc.) but renames BUILD and BUILD.bazel to
BUILD.package and BUILD.bazel.package so the upstream package layout is
preserved as opaque files rather than discarded.

The starlarkrepository gazelle extension grows a parallel pair of kinds
alongside starlark_module / starlark_module_library:

  - starlark_package: one per BUILD*.package, src points at the preserved file.
    Name is the dot-sanitized filename (BUILD.package -> BUILD_package) to
    avoid clashing with starlark_module names derived from .bzl files.
  - starlark_package_library: emitted at the configured root, named
    "starlark_packages" (not "packages", which would clash with packages.bzl).
    Its `packages` attr is populated in Resolve via the RuleIndex.

starlark_repository.archive/.local default build_file_generation to "preserve"
so users get the new behavior automatically; they can still override.
@pcj pcj force-pushed the stardoc-packageinfo branch from 3efe9ed to 87f41b7 Compare May 19, 2026 05:25
@pcj pcj merged commit ab383bb into stardoc May 19, 2026
1 check passed
@pcj pcj deleted the stardoc-packageinfo branch May 19, 2026 05:30
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