Skip to content

Commit

Permalink
windows launcher: Make the launcer 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 18, 2024
1 parent 8ae2570 commit ff8ac7a
Show file tree
Hide file tree
Showing 11 changed files with 2,185 additions and 3 deletions.
8 changes: 8 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ platform(
],
)

platform(
name = "windows_x86_64",
constraint_values = [
"@platforms//os:windows",
"@platforms//cpu:x86_64",
],
)

REMOTE_PLATFORMS = ("rbe_ubuntu2004",)

[
Expand Down
3 changes: 3 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,6 @@ register_toolchains("@local_config_winsdk//:all")
register_toolchains("//src/main/res:empty_rc_toolchain")

register_toolchains("@graalvm_toolchains//:gvm")

llvm_mingw_extension = use_extension("//third_party/llvm_mingw:defs.bzl", "llvm_mingw_extension")
use_repo(llvm_mingw_extension, "llvm_mingw_linux_x86_64")
36 changes: 36 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
11 changes: 11 additions & 0 deletions src/tools/launcher/launcher_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#endif

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

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

#if defined(_MSC_VER)
int wmain(int argc, wchar_t* argv[]) {
#else
int main() {
int argc = 0;
wchar_t** argv = CommandLineToArgvW(GetCommandLineW(), &argc);
if (argv == nullptr) {
die(L"CommandLineToArgvW failed.");
}
#endif
// 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
// ".runfiles") work as expected. Note that GetExecutableFileName may return a
Expand Down
Empty file added third_party/llvm_mingw/BUILD
Empty file.
Loading

0 comments on commit ff8ac7a

Please sign in to comment.