-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow artifact -> artifact symlink actions from Starlark #10695
Conversation
private void registerSymlinkAction( | ||
Artifact output, Artifact input, String progressMessage) throws EvalException { | ||
if (output.isSymlink()) { | ||
throw Starlark.errorf("output of symlink action must be created by declare_file()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "symlinks pointing to artifacts must be created by declare_file()?"
If you want a dangling symlink, it has to created by declare_symlink()
, doesn't it?
// TODO(yannic): This should be configurable. | ||
String progressMessage = "Creating symlink " + outputArtifact.getRootRelativePathString(); | ||
|
||
if (target instanceof String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@laurentlb , is this kind of behavior change based on the runtime type of the argument okay?
It seems to be reasonable on the surface, but there doesn't seem to be that many instances of this in our code and maybe explicitly specifying which one we want like actions.symlink(output, file=<file>)
/ actions.symlink(output, symlink=<string>)
would be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I actually like having actions.symlink(output, file=<file>)
/ actions.symlink(output, symlink=<string>)
more than overloading target
based on the runtime type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, but I want this to be idiomatic, that's why I asked for @laurentlb 's opinion!
src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
Outdated
Show resolved
Hide resolved
Some thoughts:
|
I agree. Maybe we need to resolve the situation about the experimental dangling symlink feature. Do we want to support it? Is it going away? |
We definitely want to support it in the long term. For now, however, the fully supported one is the artifact -> artifact symlink. |
"Normal" symlink functionality (i.e. artifact -> artifact) is currently non-existent in Starlark, only unresolved symlinks are available behind
See 1. for
Seems like we all agree that overloading is not the way to go. |
Let's go with I just realized that this is inconsistent with the |
If it's experimental it needs to be behind a flag.
Any thoughts on |
67efa42
to
7e3d5c9
Compare
EOF | ||
|
||
# bazel build //a:a && fail "build succeeded" | ||
# [[ "$?" == 1 ]] || fail "unexpected exit code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't quite figure out why this isn't failing.
Looking at this comment, it seems like the action should fail.
Am I missing something here, or is that comment out-of date (or invalid for Bazel)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe. That's because Bazel makes every output file executable (which is not how I would like it to be, but it would be quite difficult to change now :( ). Probably this is where:
If you want to test this functionality, symlink to a source file instead of one that was built by Bazel itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but not exactly what I wanted to hear :/.
I'll use your workaround and symlink to a source file for the test.
This is ready for review now. @brandjon I decided to stick with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. Feel free to nag me more in the future :)
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
EOF | ||
|
||
# bazel build //a:a && fail "build succeeded" | ||
# [[ "$?" == 1 ]] || fail "unexpected exit code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe. That's because Bazel makes every output file executable (which is not how I would like it to be, but it would be quite difficult to change now :( ). Probably this is where:
If you want to test this functionality, symlink to a source file instead of one that was built by Bazel itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! ptal
EOF | ||
|
||
# bazel build //a:a && fail "build succeeded" | ||
# [[ "$?" == 1 ]] || fail "unexpected exit code" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but not exactly what I wanted to hear :/.
I'll use your workaround and symlink to a source file for the test.
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. Let me see if this can still be imported.
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
Update: internal change is being reviewed by @brandjon |
Any updates on this? |
Hi Yannic, I had a few comments from the internal review, but first I want to step back and make sure I understand the big picture. I'm particularly cautious because we seem to have skipped a Starlark API review for this change and for lberki@'s earlier dangling symlink feature (which up until now has been marked experimental). Questions for @lberki:
For @Yannic and @lberki: I want to make sure we're on the same page. Does this describe the API?
I'll reply with my comments from the internal review shortly. |
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're distinguishing between artifacts created by declare_file
and declare_symlink
, do we have a way to expose the difference to users? Like a myfile.is_symlink
bool (similar to is_source
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you got the API right (modulo small caveat: symlink()
with ``isSymlink() == false` may actually copy on Windows).
If we're distinguishing between artifacts created by
declare_file
anddeclare_symlink
, do we have a way to expose the difference to users? Like amyfile.is_symlink
bool (similar tois_source
)?
.is_symlink
isn't available on FileAPI
yet, but it seems not too complicated to add it (Artifact
already known whether it's a symlink or not). Should we add it as part of this change?
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.is_symlink
isn't available onFileAPI
yet, but it seems not too complicated to add it (Artifact
already known whether it's a symlink or not). Should we add it as part of this change?
No, this PR is already large enough and iterated enough times. :) Happy to accept this in a follow-up, or leave an open FR.
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
Outdated
Show resolved
Hide resolved
@lberki, when you get a chance please weigh in on these three concerns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.is_symlink
isn't available onFileAPI
yet, but it seems not too complicated to add it (Artifact
already known whether it's a symlink or not). Should we add it as part of this change?No, this PR is already large enough and iterated enough times. :) Happy to accept this in a follow-up, or leave an open FR.
Filed #11209
src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkActionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/skylarkbuildapi/SkylarkActionFactoryApi.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'll get my answers from @lberki on the internal merge. Thanks!
re: #10695 (comment), we are on the same page.
|
Thanks, that should be everything then! |
(In internal merge, I added a documentation note to |
Updates #7514