feat: add odin_library rule for collection-based package imports#7
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds the rule — a source-aggregation rule that groups files and exposes them via so that targets can import them as Odin collections.
New files
odin/private/common.bzl— sharedget_package_dir()helper (extracted frombinary.bzl)odin/private/library.bzl—OdinLibraryInfoprovider +odin_libraryrulee2e/smoke/lib/greetings.odin— library test sourceModified files
odin/private/binary.bzl— addeddepsattr,-collection:<name>=<root>flags, dep srcs in action inputs, duplicate collection name validationodin/defs.bzl— exportsodin_librarye2e/smoke/BUILD.bazel—odin_librarytarget +depsonodin_binarye2e/smoke/hello/hello.odin— imports library viaimport greetings "greetings:lib"README.md— documentsodin_library+depsattrDesign
odin_libraryis source aggregation only (no compilation step)odin_librarytargetodin_binaryconsumes deps by passing-collection:<name>=<root>to the Odin compilerpackagedeclaration name), so users should useimport myname "collection:dir"for explicit aliasesEdge cases handled
deps→ backward compatible (existingodin_binaryworks unchanged)fail()with clear errorfail()with clear errorHow was it tested?
bazel build //...in root workspace — passescd e2e/smoke && bazel build //...— passes./e2e/smoke/bazel-bin/hello— prints both "Hellope, Odin from Bazel!" and "Greetings from the library, Bazel!"pre-commit run --all-files— buildifier + typos pass@change-validator— all 3 findings addressed (duplicate collection names, root-level srcs rejection, unused attrs removed)Checklist
check.yaml— lint + test matrix)odin_libraryrule +depsattrodin_binarywithoutdepsworks unchanged)