-
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
workspace_status_command should accept program on the PATH #4802
Comments
I think this is a reasonable request and I can't think of a good workaround. @lfpino : can the bazel client do this -- what I just wrote in the prev. sentence -- especially considering bazelrc files? |
This issue reminds me of #964. About your idea Laszlo, --workspace_status_command is parsed in the server so I don't see how the client can inspect the argument. Maybe the solution is to bundle a platform-independent workspace_status_command in Bazel as suggested in #964 and make it the default value of the flag. |
@lfpino :
Can we change that? I mean can we parse the args in the client and if the argument starts with Alternatively, the server needs to know |
Luckily, all the machinery is in place: bazel/src/main/java/com/google/devtools/build/lib/bazel/BazelWorkspaceStatusModule.java Lines 102 to 113 in 6586621
This is where Bazel creates the Command to run the WSC. The |
FYI, I don't have the capacity to work on this. |
@alexeagle , I thought more about this problem, and it's I think @alexeagle , @lberki : WDYT? |
Bumping priority. |
Yep, allowing In fact, it _almost works today, since one could say |
|
That workaround doesn't help much given that the OP was for a setting that would work on Windows too. |
Sorry I dropped the ball on this bug for so long.
Could you explain why they couldn't stamp binaries?
What language would that script be written in? Currently Bazel runs the |
If it's a shell script I can't run it on Windows, right? |
Right.
Unfortunately I don't know. I reckon the
Maybe it already does! Could you give it a try and comment here? |
I was able to use node to output stamp vars with bazel v0.16.1 on windows and mac using: .bazelrc
./build/bazel_stamp_vars.js#!/usr/bin/env node
const childProcess = require('child_process');
const execFile = childProcess.execFile;
function execStampVar(varName, executableFile, args) {
return new Promise((resolve, reject) => {
try {
execFile(executableFile, args, (error, stdout, stderr) => {
if (error) {
reject(stderr);
}
resolve(`${varName} ${stdout}`);
});
} catch (e) {
reject(e);
}
});
}
(async function writeStampVars() {
const stampVarPromises = [
execStampVar('GIT_COMMIT', 'git', ['rev-parse', 'HEAD']),
];
const stampVars = await Promise.all(stampVarPromises);
stampVars.forEach(sv => console.log(sv));
})()
.then(() => process.exit(0))
.catch(e => {
console.error(`Writing stamp variables failed: ${e.message}`);
process.exit(1);
}); |
@enriched thanks for demonstrating that! @laszlocsomor I think we could lower the priority. My only remaining issue is that it requires that |
Thanks @alexeagle and @enriched , I'll lower the priority. |
We do pass PATH from the client environment through to the workspace action. It seems like it should look up the path on the PATH, doesn't it? |
How do you know that the string contains the path of an executable vs. a Bash command? |
Remove support for bash commands? |
I doubt we can just remove support for Bash commands, as there are users relying on this feature who would likely miss it. See: #5002 (comment) |
Currently workspace_status_command requires a path to a script in the project.
This is hard to make portable between platforms. Making this a shell script means Windows developers on the team can't stamp binaries.
There is some discussion about this:
https://stackoverflow.com/questions/48159516/default-platform-specific-bazel-flags-in-bazel-rc
GerritCodeReview/gerrit@7a8f40f
The current solutions are workarounds.
The most convenient way to solve this IMO is to put a platform-independent script in the PATH, just like git subcommands (e.g.
git-bazel-stamp
). Then Bazel can always use--workspace_status_command=git-bazel-stamp
and it's up to developers to install this git subcommand before stamping releases.Thanks to @gregmagolan for pointing this out and @laszlocsomor for discussion
The text was updated successfully, but these errors were encountered: