Skip to content

Commit

Permalink
windows launcher: Make the launcher compile under mingw
Browse files Browse the repository at this point in the history
TEST: bazel build --platforms=//:windows_x86_64  --extra_toolchains=@llvm_mingw_linux_x86_64//:cc-toolchain-linux_x86_64-windows_x86_64 //src/tools/launcher:launcher
  • Loading branch information
BoleynSu committed Dec 19, 2024
1 parent e586a5e commit bf26bcc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/native/windows/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

#include "src/main/native/windows/file.h"

#include <WinIoCtl.h>
#include <stdint.h> // uint8_t
#include <versionhelpers.h>
#include <winbase.h>
#include <windows.h>
#include <winioctl.h>

#include <memory>
#include <sstream>
Expand Down
2 changes: 1 addition & 1 deletion src/main/native/windows/process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include "src/main/native/windows/process.h"

#include <versionhelpers.h>
#include <windows.h>
#include <VersionHelpers.h>

#include <memory>
#include <sstream>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/launcher/java_launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ wstring JavaBinaryLauncher::CreateClasspathJar(const wstring& classpath) {
binary_base_path + rand_id + L".jar_manifest";
blaze_util::AddUncPrefixMaybe(&jar_manifest_file_path);
#if (__cplusplus >= 201703L)
wofstream jar_manifest_file(std::filesystem::path(jar_manifest_file_path));
wofstream jar_manifest_file{std::filesystem::path(jar_manifest_file_path)};
#else
wofstream jar_manifest_file(jar_manifest_file_path);
#endif
Expand Down
17 changes: 17 additions & 0 deletions src/tools/launcher/launcher_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#endif

#include <windows.h>
#include <processenv.h>
#include <shellapi.h>
#include <winbase.h>

#include <memory>
#include <string>
Expand Down Expand Up @@ -64,6 +67,20 @@ static std::wstring GetExecutableFileName() {
return buffer.substr(0, length);
}

#if defined(__MINGW32__) && not defined(BAZEL_MINGW_UNICODE)
int wmain(int argc, wchar_t* argv[]);
int main() {
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
Expand Down

0 comments on commit bf26bcc

Please sign in to comment.