added Windows target testing
This commit is contained in:
parent
72475ee012
commit
6f2ae838cd
@ -5,6 +5,7 @@ packages:
|
||||
- qemu-user-static
|
||||
- binfmt-support
|
||||
- moreutils
|
||||
- wine-binfmt
|
||||
sources:
|
||||
- https://git.sr.ht/~motiejus/bazel-zig-cc
|
||||
environment:
|
||||
|
10
README.md
10
README.md
@ -401,8 +401,9 @@ This repository is used on the following (host) platforms:
|
||||
- `windows_amd64`, a.k.a. `x64`.
|
||||
|
||||
The tests are running (CId) on linux-amd64, and are assuming the kernel is
|
||||
configured to run arm64 binaries. There are two reasonably convenient ways to
|
||||
configure arm64 emulation:
|
||||
configured to run `linux_arm64` and `windows_amd64` binaries.
|
||||
|
||||
There are two reasonably convenient ways to configure `linux_arm64` emulation:
|
||||
|
||||
1. Install and configure [`binfmt_misc`][binfmt_misc]:
|
||||
```
|
||||
@ -414,6 +415,11 @@ configure arm64 emulation:
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
```
|
||||
|
||||
In order to install and configure `windows_amd64` emulation:
|
||||
```
|
||||
apt install wine-binfmt
|
||||
```
|
||||
|
||||
## Transient docker environment
|
||||
|
||||
A standalone Docker environment to play with bazel-zig-cc:
|
||||
|
@ -51,11 +51,13 @@ zig_toolchains()
|
||||
|
||||
register_toolchains(
|
||||
# if no `--platform` is specified, these toolchains will be used for
|
||||
# (linux,darwin)x(amd64,arm64)
|
||||
# (linux,darwin,windows)x(amd64,arm64)
|
||||
"@zig_sdk//toolchain:linux_amd64_gnu.2.19",
|
||||
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
|
||||
"@zig_sdk//toolchain:darwin_amd64",
|
||||
"@zig_sdk//toolchain:darwin_arm64",
|
||||
"@zig_sdk//toolchain:windows_amd64",
|
||||
"@zig_sdk//toolchain:windows_arm64",
|
||||
|
||||
# amd64 toolchains for libc-aware platforms:
|
||||
"@zig_sdk//libc_aware/toolchain:linux_amd64_gnu.2.19",
|
||||
|
14
ci/test
14
ci/test
@ -1,3 +1,13 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
exec bazel test ...
|
||||
bazel test ...
|
||||
|
||||
# Windows tests
|
||||
# Unfortunately wine-binfmt breaks within the bazel sandbox, so we disable it
|
||||
# to run this test.
|
||||
bazel test //test/c:winver_windows_amd64 \
|
||||
--spawn_strategy=standalone
|
||||
# There is no no easy way to run windows_arm64 binaries on Linux, so we just
|
||||
# cross compile one for testing.
|
||||
bazel build //test/c:winver_windows_arm64
|
||||
|
24
test/c/BUILD
24
test/c/BUILD
@ -1,4 +1,4 @@
|
||||
load("@bazel-zig-cc//rules:platform.bzl", "platform_binary")
|
||||
load("@bazel-zig-cc//rules:platform.bzl", "platform_binary", "platform_test")
|
||||
|
||||
cc_binary(
|
||||
name = "which_libc",
|
||||
@ -34,3 +34,25 @@ cc_binary(
|
||||
("linux_arm64", "//platform:linux_arm64", "glibc_2.28"),
|
||||
]
|
||||
]
|
||||
|
||||
cc_binary(
|
||||
name = "winver",
|
||||
srcs = ["main_winver.c"],
|
||||
target_compatible_with = [
|
||||
"@platforms//os:windows",
|
||||
],
|
||||
)
|
||||
|
||||
platform_test(
|
||||
name = "winver_windows_amd64",
|
||||
src = "winver",
|
||||
platform = "//platform:windows_amd64",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
platform_binary(
|
||||
name = "winver_windows_arm64",
|
||||
src = "winver",
|
||||
platform = "//platform:windows_arm64",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
16
test/c/main_winver.c
Normal file
16
test/c/main_winver.c
Normal file
@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
|
||||
int main() {
|
||||
DWORD version = GetVersion();
|
||||
DWORD majorVersion = (DWORD)(LOBYTE(LOWORD(version)));
|
||||
DWORD minorVersion = (DWORD)(HIBYTE(LOWORD(version)));
|
||||
|
||||
DWORD build = 0;
|
||||
if (version < 0x80000000) {
|
||||
build = (DWORD)(HIWORD(version));
|
||||
}
|
||||
|
||||
printf("Running Windows version %d.%d (%d).\n", majorVersion, minorVersion, build);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user