--workspace_status_command does not compose (or work transparently when building outside the source dir) #2910
Labels
P2
We'll consider working on this in future. (Assignee optional)
stale
Issues or PRs that are stale (no activity for 30 days)
team-ExternalDeps
External dependency handling, remote repositiories, WORKSPACE file.
type: feature request
The best practice for git build stamping in C++ today is described in #2893. To make this work in a way that is transparent to developers, you provide the workspace status script in a file, e.g.
tools/get_workspace_status
and place intools/bazel.rc
:build --workspace_status_command=tools/get_workspace_status
. That way, most folks who checkout your project from GitHub never need to worry about adding this to the Bazel build command-line.There's two issues with this:
If you perform your build outside the source directory (e.g. let's say the source is in
/source
and I build in/build
viabazel build //... --package_path %workspace%:/source
, then Bazel doesn't know where to findtools/get_workspace_status
. We hit this in the Envoy CI system where we have this build arrangement, and required symlinks (https://github.com/lyft/envoy/blob/master/ci/build_setup.sh#L86) to make it work. This seems like a hack, there should be a better way. For example, it should be possible to have paths be relative to the source directory somehow, maybe arbitrary Bazel labels.If you have the above arrangement in project A, which gets used as a dependency of project B via
git_repository
, then project B needs to not only reference project A viagit_repository
, but somehow:tools/bazel.rc
abuild --workspace_status_command
entry.--workspace_status_command
attools/get_workspace_status
from A.Further complicating (2), project B might have its own notion of what constitutes workspace status, which might be completely different to project A. Each project might need some different notion of
BUILD_SCM_REVISION
to include as a C++ string in its version information.I think we really need workspace status to not just be a Bazel flag, but a first class property of a project's build system, inside the build rules to solve (2)
@PiotrSikora @mattklein123 @lizan envoyproxy/envoy#415 envoyproxy/envoy#857
The text was updated successfully, but these errors were encountered: