-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[chore] Fix make generate on Windows #43509
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
[chore] Fix make generate on Windows #43509
Conversation
| .PHONY: for-all | ||
| for-all: | ||
| @set -e; for dir in $(ALL_MODS); do \ | ||
| @set -e; for dir in $${ALL_MODS}; do \ |
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.
This is needed given the limits for command-line length on Windows. This way ALL_MODS is passed as an environment variable instead of being expanded in place.
|
It looks like this PR broke the I believe the problem is that |
#### Description #43509 changed the `make for-all` Makefile target to access the `ALL_MODS` variable through environment variables instead of expanding it into the shell command, in order to bypass Windows' 8192 byte command line length limit. However, the environment variable was not defined, which led to `make for-all` becoming a no-op. This can be confirmed by running `make for-all CMD='echo test'`. (I discovered this issue because [this PR](open-telemetry/opentelemetry-collector#13996) in core repository, which should be failing `contrib-tests`, suddenly started passing them. This was because the job inserts `replace` statements in a copy of contrib using `for-all`; failing to do that caused the contrib tests to run against whatever version of core is imported here rather than against the PR's code.) This PR fixes that oversight, by adding the `export` keyword to the `ALL_MODS` variable.
|
ops, sorry about that @jade-guiton-dd and thanks for the fix. My validation of this was bad, kind of completed an "empty" generate 🤦🏼 The |
Fix the `generate` target so developers using Windows can do `make generate` for their components on Windows. Main things in this change: 1. Use of path that can be pre-pended to `PATH`, the one being used contains `:` and even escaping it is not enough to get it to correctly work when it is being included in `PATH` 2. Ensure that on Windows all tools used by `go generate` have the `exe` extension. This is needed because the `cmd` package used by `go generate` checks for the known executable extensions on Windows. Notice that `make` and Git Bash don't require that and same extension is not needed for the other tools. 3. The `generate` target now triggers building the tools it needs as various other targets so it can avoid the full `install-tools`. Future work: - `go.*` targets are really slow on Windows since they trigger the re-evaluation of all shell commands that are really expensive on Windows. Basically any recursive make call from `for-all` is currently too expensive on Windows. - Move the definition of components custom tools to the respective components, possibly using the new go.mod `tool` directive. For now I opted to keep the tool used by `githubreceiver` as it is.
#### Description open-telemetry#43509 changed the `make for-all` Makefile target to access the `ALL_MODS` variable through environment variables instead of expanding it into the shell command, in order to bypass Windows' 8192 byte command line length limit. However, the environment variable was not defined, which led to `make for-all` becoming a no-op. This can be confirmed by running `make for-all CMD='echo test'`. (I discovered this issue because [this PR](open-telemetry/opentelemetry-collector#13996) in core repository, which should be failing `contrib-tests`, suddenly started passing them. This was because the job inserts `replace` statements in a copy of contrib using `for-all`; failing to do that caused the contrib tests to run against whatever version of core is imported here rather than against the PR's code.) This PR fixes that oversight, by adding the `export` keyword to the `ALL_MODS` variable.
Fix the
generatetarget so developers using Windows can domake generatefor their components on Windows. Main things in this change:PATH, the one being used contains:and even escaping it is not enough to get it to correctly work when it is being included inPATHgo generatehave theexeextension. This is needed because thecmdpackage used bygo generatechecks for the known executable extensions on Windows. Notice thatmakeand Git Bash don't require that and same extension is not needed for the other tools.generatetarget now triggers building the tools it needs as various other targets so it can avoid the fullinstall-tools.Future work:
go.*targets are really slow on Windows since they trigger the re-evaluation of all shell commands that are really expensive on Windows. Basically any recursive make call fromfor-allis currently too expensive on Windows.tooldirective. For now I opted to keep the tool used bygithubreceiveras it is.