-
Notifications
You must be signed in to change notification settings - Fork 176
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
pkg_files(strip_prefix) behavior is confusing w.r.t. flattening a tree of files #354
Comments
This is indeed derived from legacy behavior. See I'm not fundamentally opposed to this idea, but my (selfish) counterpoint to this is that many source trees do have any reasonable mapping between where they are located in the source tree and where they end up being installed/packaged. As proposed, this would require the propagation of new attributes in this (relatively common) case. In any case, I can see why this would be confusing and impede initial use of the framework. I'd call it a quirk more than anything else, but that could just be me having written and watched the framework used internally for a while. So far, nobody has complained about this, although, that isn't necessarily a sign that it's the best option. To your points:
I'd rather call this attribute
I would instead treat Thoughts? |
Which way to do you mean that? "many source trees to have a reasonable" or "do not have any reasonable". I think the former based on the rest of the text. I'm sort of surprised. We always have paths like "//websearch/some_product/iphone/.../the/app/structure". For distributing the app, we almost always use strip_prefix from the root through the BUILD file. OR... are we talking about different things? That you mean the layout of files under the top level of the application and I am talking about the path to the application?
That sounds good to me. I may send a PR to add just that soon.
Why should they be mutually exclusive? They operate on different pieces of the path. If you had |
I meant to say "do not have any reasonable mapping". Bah. I guess I'm referring to the layout of files under the top level of the application, although both can be a problem at times. The particular application I am supporting in our monorepo installs various binaries to (mostly) self-contained locations. While many of the files used in the applications are present in under a particular prefix in the repository (e.g. Because of this, we often strip everything and name the precise locations where everything ends up living. I can imagine some open source projects having a similar problem -- directory structures in the source tree can be somewhat arbitrary there as well.
I see. I wasn't sure where the squashing/flattening was intended to begin; I assumed it was relative to the root. With all that in mind, I feel that the precise behavior needs to be specified a little more. In particular, how will |
From offline discussion today, I think we agreed on
|
After some time pondering this: some use cases for
In these cases, the repository-relative path is helpful, otherwise, the repository paths paths need to be encoded in the BUILD files as prefixes, which can be inconvenient. |
Even if this is breaking behavior, we could theoretically mitigate this by providing a script that does the transformation for users. If, for example, the default is simply switched from flattening to preserving from-package prefix roots, one could probably use |
I think preserving hierarchy without |
Reading the discussion, I think we should take a step back and maybe even
rethink the names. Unless you use it a lot, I don't think from_root, or
from_pkg have an obvious meaning. Perhaps splitting the concepts up will
make more sense. Something like
- files always have the path from root to package stripped.
- if you don't want that, there is the prefix attribute. To make it easy
to bring back the package name, we could use a magic
constant prefix.this_package().
- then strip_prefix is always from the current directory down, so generally
you won't use it.
- and we could have flatten as another attribute (to bring back the old
behavior)
OR strip_prefix could be strip_prefix.flatten().
I don't think there is any case for stripping the prefix from the current
path and flattening together. Flatten always wins.
…On Thu, Dec 2, 2021 at 12:18 PM Mark Zeren ***@***.***> wrote:
I think preserving hierarchy without strip_prefix =
strip_prefix.from_pkg() is the right default. We should consider taking a
breaking change with buildifier assisted migration.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#354 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXHHHBNUC6KUMTEQ5TSORDUO6S67ANCNFSM442UXIBA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Hm. Interesting. Immediate thoughts:
Agreed. At the very least, this should be the default to reduce user surprise.
I like the idea, but we would need a way to manipulate the repository path/package paths in a clean way. This has the potential for making modifications from I guess another thought is that I like the idea of
I'm not fundamentally opposed to this idea (the "current directory" being the current package), but we should be as consistent as possible.
|
Maybe |
We discussed this in our public meeting today. To summarize:
Side note: we don't need the ability to manipulate the package path ( genrule(
name = "a",
cmd = "echo %s >$@" % package_name().replace('/src/', '/source/'),
outs = ["x"],
) I will likely have time to address the core parts of this issue (the non- |
Deliverables:
|
I just opened #805 to document a surprising behavior whereby It feels like it might be in scope for this issue? |
Example file tree
docs/BUILD
filegroup(name = "docs", srcs = glob(["**/*"]))
BUILD
This gives the output I expect - that the directory tree is preserved.
But.... if I do not have
strip_prefix
,pkg_files
flattens the tree and I get the error.Error in fail: After renames, multiple sources (at least docs/index.md, docs/reference/index.md) map to the same destination. Consider adjusting strip_prefix and/or renames
This might be a carry over from legacy behavior, but it is strange and confusing.
Proposal
pkg_files
adds an attributesquash_tree
bool, default=False which controls squashing the tree.The text was updated successfully, but these errors were encountered: