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

Windows build fix for some mingw gnu make situations #1870

Merged
merged 2 commits into from
Jan 30, 2023
Merged

Windows build fix for some mingw gnu make situations #1870

merged 2 commits into from
Jan 30, 2023

Conversation

DRNadler
Copy link
Contributor

When tools/top.mk finds it is running on Windows, it expects SHELL set to cmd.exe.
Some Windows development environments invoke a mingw version of gnu make with SHELL set to /bin/sh or /bin/bash (either explicitly or by default), in which case tinyUSB make fails when a $(shell...) command feeds DOS syntax to sh. We can't just use sh, as many Windows environments won't have unix utilities like realpath (used by this makefile for sh shell commands).

This fix forces SHELL=cmd.exe on Windows and documents the issue. Also adds additional documentation to help the next person...

With this fix, tinyUSB can be easily built and debugged in environments like NXP's MCUxpresso (import as a makefile project).

DRNadler and others added 2 commits January 22, 2023 12:11
…t to cmd.exe.

Some Windows development environments invoke a mingw version of gnu make
with SHELL set to /bin/sh or /bin/bash (either explicitly or by default),
in which case tinyUSB make fails when a $(shell...) command feeds DOS syntax to sh.
We can't just use sh, as many Windows environments won't have unix utilities
like realpath (used by this makefile for sh shell commands).

This fix forces SHELL=cmd.exe on Windows and documents the issue.
Also adds additional documentation to help the next person...

With this fix, tinyUSB can be easily built and debugged in environments like
NXP's MCUxpresso (import as a makefile project).
Copy link
Owner

@hathach hathach left a comment

Choose a reason for hiding this comment

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

superb! thank you for your PR, I made a minor clean up on the comment. Haven't tested it on windows machine, but look good

@hathach hathach merged commit 8681dbb into hathach:master Jan 30, 2023
@DRNadler
Copy link
Contributor Author

Thanks! Dumb question though: We all hate comment syntax in make and shell that essentially prohibits space before comment # mark. But, I put the following on one line so that it would be easy to see when someone greps for CMDEXE to find out it's exact meaning. So, sorry for the question, why did you break it into multiple lines?
Thanks again for your great work!
Best Regards, Dave
CMDEXE := 1# makefile shell commands should use syntax for DOS CMD, not unix sh

@hathach
Copy link
Owner

hathach commented Jan 30, 2023

it is just my personal preference, I found having the inline comment for makefile not as readable as one line above the actual command.

@DRNadler DRNadler deleted the WindowsBuildFix branch January 30, 2023 15:23
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.

2 participants