-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 launcher: Make the launcher compile under mingw #24752
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ | |
#endif | ||
|
||
#include <windows.h> | ||
#include <processenv.h> | ||
#include <shellapi.h> | ||
#include <winbase.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
@@ -64,6 +67,24 @@ static std::wstring GetExecutableFileName() { | |
return buffer.substr(0, length); | ||
} | ||
|
||
#if defined(__MINGW32__) && not defined(BAZEL_MINGW_UNICODE) | ||
// MinGW requires linkopt=-municode to use wmain as entry point. | ||
// The below allows fallback to main when BAZEL_MINGW_UNICODE is not defined. | ||
// Otherwise, to use wmain directly, one needs to use both linkopt=-municode and | ||
// copt=-DBAZEL_MINGW_UNICODE. | ||
int wmain(int argc, wchar_t* argv[]); | ||
int main() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mingw requires linkopt There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add this comment in the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do it later. I am on a train currently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comments added. PTAL. |
||
int argc = 0; | ||
wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc); | ||
if (argv == nullptr) { | ||
die(L"CommandLineToArgvW failed."); | ||
} | ||
int result = wmain(argc, argv); | ||
LocalFree(argv); | ||
return result; | ||
} | ||
#endif | ||
|
||
int wmain(int argc, wchar_t* argv[]) { | ||
// In case the given binary path is a shortened Windows 8dot3 path, we convert | ||
// it back to its long path form so that path manipulations (e.g. appending | ||
|
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.
We need to use curly brackets here to declare a variable.