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

--workspace_status_command does not compose (or work transparently when building outside the source dir) #2910

Closed
htuch opened this issue Apr 28, 2017 · 3 comments
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

Comments

@htuch
Copy link

htuch commented Apr 28, 2017

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 in tools/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:

  1. If you perform your build outside the source directory (e.g. let's say the source is in /source and I build in /build via bazel build //... --package_path %workspace%:/source, then Bazel doesn't know where to find tools/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.

  2. 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 via git_repository, but somehow:

    1. Know to add to its own tools/bazel.rc a build --workspace_status_command entry.
    2. Know how to find project A on the filesystem to consume its --workspace_status_command at tools/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

@htuch htuch changed the title --workspace_status_command does not compose or work transparently when building outside the source dir --workspace_status_command does not compose (or work transparently when building outside the source dir) Apr 28, 2017
@dslomov dslomov added P2 We'll consider working on this in future. (Assignee optional) external-repos-triaged labels Jan 10, 2018
@dslomov dslomov added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. and removed category: extensibility > external repositories labels Mar 21, 2019
@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@sgowroji sgowroji added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 3, 2023
@sgowroji
Copy link
Member

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

@bcsgh
Copy link

bcsgh commented Feb 15, 2023

If this is actually completed, please post a link to the feature that completed it.

If no such feature has been released please update the closed status with something more accurate (e.g. "we think this is a bad idea and won't be implementing it" or "we just blindly closed this without even knowing what was being asked for").

@bcsgh
Copy link

bcsgh commented Feb 15, 2023

BTW: it's very much a hack, but there is a way to get at state like the git HEAD without setting --workspace_status_command:

https://github.com/bcsgh/bazel_rules/blob/master/status_repository/repo.bzl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

6 participants