Skip to content

Conversation

@ariasmn
Copy link
Contributor

@ariasmn ariasmn commented Nov 15, 2025

What?

Updated the Makefile to automatically detect the operating system and download the appropriate protoc binary for Windows, Linux, and macOS when running the generate task.

Had a Mac laying around gathering dust, decided to set it up and do this quick PR because why not. Tested on a M1 Pro, although since it's using the universal binary should work on Intel based ones too.
For Windows, tested on a Windows 11 VM.

Why?

The previous Makefile only supported Linux, causing build failures on macOS and Windows.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

Closes #4966

This was a bit cumbersome because of the multiple ways of
setting the work environemnt (local vs MinGW Go/make installation).

I don't think we should handle all the cases and each user that runs
`make generate` should be able to fix their environment to make it work.

I've used MinGW64 + local Go installation and it's working.
@ariasmn ariasmn requested a review from a team as a code owner November 15, 2025 16:36
@ariasmn ariasmn requested review from joanlopez and oleiade and removed request for a team November 15, 2025 16:36
Comment on lines +5 to +7
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
PROTOC_ARCHIVE := protoc-$(PROTOC_VERSION)-win64.zip
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe someone with more Windows expertise can help here, because I don't really know how to set it up correctly. From what I've gathered:

  • The OS environment variable is always present on Windows, so it's safe to use.
  • I tested this using MSYS2 with a native Go installation, not the MSYS2 Go package.

Also, I didn't differentiate between 32-bit and 64-bit Windows since we don't do that for Linux either, but it could be added if needed. But in the 64-bit VM is working fine.

Comment on lines +24 to 25
@if [ -z "$(DETECTED_OS)" ]; then \
echo "Error: Can't install protoc on your OS, please install protoc-$(PROTOC_VERSION) manually." >&2; \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I maintained the same logic here, but this could be improved by checking if protoc is already installed and skipping the download entirely. Currently, even if you have protoc installed manually, the task will fail if your OS doesn't match Windows, Linux, or Darwin. Should be fairly easy to add.

@mstoykov mstoykov added this to the v1.5.0 milestone Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make generate only works on linux

2 participants