-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(deps): OS agnostic make generate
#5414
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
base: master
Are you sure you want to change the base?
Conversation
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.
| ifeq ($(OS),Windows_NT) | ||
| DETECTED_OS := Windows | ||
| PROTOC_ARCHIVE := protoc-$(PROTOC_VERSION)-win64.zip |
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.
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
OSenvironment 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.
| @if [ -z "$(DETECTED_OS)" ]; then \ | ||
| echo "Error: Can't install protoc on your OS, please install protoc-$(PROTOC_VERSION) manually." >&2; \ |
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.
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.
joanlopez
left a comment
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.
It works for me! 👍🏻
Can somebody else test this in other OSes (i.e. Windows), please?
cc/ @oleiade @AgnesToulet
What?
Updated the
Makefileto automatically detect the operating system and download the appropriate protoc binary for Windows, Linux, and macOS when running thegeneratetask.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
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.
Related PR(s)/Issue(s)
Closes #4966