skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.7k stars 185 forks source link

Wildcard expansion #3

Closed Koromix closed 3 years ago

Koromix commented 3 years ago

First, thanks for this project :)

Unlike the msys2 build, the GCC/G++ build in this project does not seem to expand glob patterns. For example, if I run g++ -o test.exe src\*.cc, it fails:

g++: error: src\*.cc: Invalid argument
g++: fatal error: no input files

This works with msys2. This is not a deal breaker but it would be nice to have. This is not just about msys2; Clang and MSVC (cl) also perform expansion.

skeeto commented 3 years ago

Thanks for pointing this out. It seems msys2 uses a custom solution that I can't figure out, but GCC 8+ has a --enable-mingw-wildcard build option to enable this feature. I've now enabled this option, and it's working as I expect.

Now, I can't say I'm entirely happy about this. w64devkit is intended to be driven primarily by the provided busybox-w32 shell, which already handles wildcard expansion. This new configuration creates a second layer of wildcard expansion underneath the shell, and so, like msys2, certain w64devkit shell commands will no longer behave as they should. See this discussion about busybox-w32:

https://frippery.org/busybox/globbing.html

That being said, this only comes into play when compiling source files containing ? or * characters. So, pragmatically speaking, this is still a win. If you use those characters in your source file names, then you deserve whatever's coming.

Koromix commented 3 years ago

Thanks !

I admit this is not ideal. Pretty much nothing related to command line parsing is ideal on Windows.