Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add experimental_expose_build_files flag #1345

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sewerynplazuk
Copy link

@sewerynplazuk sewerynplazuk commented Nov 18, 2024

Attempt to solve #932.

Following the example given in the linked issue, with the new flag experimental_expose_build_files, it is possible to granularly expose the build files of individual packages, as an example:

swift_deps.configure_package(
    name = "swift-nio-transport-services",
    experimental_expose_build_files = True,
)
swift_deps.configure_package(
    name = "swift-protobuf",
    experimental_expose_build_files = True,
)
use_repo(
    swift_deps,
    "swift_deps_info",
    "swift_package",
    "swiftpkg_swift_nio_transport_services",
    "swiftpkg_swift_protobuf",
)

@sewerynplazuk sewerynplazuk changed the title Add experimental_expose_build_files flag feat: add experimental_expose_build_files flag Nov 19, 2024
Comment on lines +181 to +184
doc = "Allows to expose internal build files required for package compilation. " +
"This option is experimental and should be used at your own risk. " +
"The structure and labels of exposed build files may change in future releases " +
"without requiring a major version bump.",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reformat this a multiline string (""" """)? I find that they are easier to maintain.

@@ -175,8 +175,19 @@ PATCH_ATTRS = {
),
}

EXPERIMENTAL_ATTRS = {
"experimental_expose_build_files": attr.bool(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really have an experimental flag policy. Perhaps we should rename it to publicly_expose_all_targets. WDYT?

Comment on lines +1062 to +1065
def _build_file_visibility(repository_ctx):
experimental_expose_build_files = getattr(repository_ctx.attr, "experimental_expose_build_files", False)
return ["//visibility:public"] if experimental_expose_build_files else ["//:__subpackages__"]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of checking the flag value in this module, let's add expose_build_files to pkg_info here. We should read the value here like we do the remote and commit.

Once we do that, we can stop passing repository_ctx into the bowels of the build file generation logic.

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.

2 participants