added support for Windows targets
This commit is contained in:
parent
4a6eef7945
commit
72475ee012
14
README.md
14
README.md
@ -152,6 +152,8 @@ register_toolchains(
|
|||||||
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
|
"@zig_sdk//toolchain:linux_arm64_gnu.2.28",
|
||||||
"@zig_sdk//toolchain:darwin_amd64",
|
"@zig_sdk//toolchain:darwin_amd64",
|
||||||
"@zig_sdk//toolchain:darwin_arm64",
|
"@zig_sdk//toolchain:darwin_arm64",
|
||||||
|
"@zig_sdk//toolchain:windows_amd64",
|
||||||
|
"@zig_sdk//toolchain:windows_arm64",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -318,6 +320,18 @@ is currently not implemented.
|
|||||||
target macos.10 (Catalina), macos.11 (Big Sur) or macos.12 (Monterey). It
|
target macos.10 (Catalina), macos.11 (Big Sur) or macos.12 (Monterey). It
|
||||||
currently targets the lowest version, without ability to change it.
|
currently targets the lowest version, without ability to change it.
|
||||||
|
|
||||||
|
## Windows: output file extensions
|
||||||
|
|
||||||
|
Bazel won't use common Windows file extensions for built output binaries.
|
||||||
|
Instead, it will generate binaries with common Unix extensions that you might
|
||||||
|
have to manually rename before deploying them to an actual Windows system:
|
||||||
|
|
||||||
|
| Binary type | Bazel extension | Windows extension |
|
||||||
|
|----------------|-----------------|-------------------|
|
||||||
|
| Static library | .a | .lib |
|
||||||
|
| Shared library | .so | .dll |
|
||||||
|
| Executable | (no extension) | .exe |
|
||||||
|
|
||||||
# Known Issues In Upstream
|
# Known Issues In Upstream
|
||||||
|
|
||||||
This section lists issues that I've stumbled into when using `zig cc`, and is
|
This section lists issues that I've stumbled into when using `zig cc`, and is
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
load("@bazel-zig-cc//toolchain/private:defs.bzl", "LIBCS")
|
load("@bazel-zig-cc//toolchain/private:defs.bzl", "LIBCS")
|
||||||
|
|
||||||
_CPUS = (("x86_64", "amd64"), ("aarch64", "arm64"))
|
_CPUS = (("x86_64", "amd64"), ("aarch64", "arm64"))
|
||||||
|
_OS = {
|
||||||
|
"linux": ["linux"],
|
||||||
|
"macos": ["macos", "darwin"],
|
||||||
|
"windows": ["windows"],
|
||||||
|
}
|
||||||
|
|
||||||
def declare_platforms():
|
def declare_platforms():
|
||||||
# create @zig_sdk//{os}_{arch}_platform entries with zig and go conventions
|
# create @zig_sdk//{os}_{arch}_platform entries with zig and go conventions
|
||||||
for zigcpu, gocpu in _CPUS:
|
for zigcpu, gocpu in _CPUS:
|
||||||
for bzlos, oss in {"linux": ["linux"], "macos": ["macos", "darwin"]}.items():
|
for bzlos, oss in _OS.items():
|
||||||
for os in oss:
|
for os in oss:
|
||||||
declare_platform(gocpu, zigcpu, bzlos, os)
|
declare_platform(gocpu, zigcpu, bzlos, os)
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ def target_structs():
|
|||||||
ret = []
|
ret = []
|
||||||
for zigcpu, gocpu in (("x86_64", "amd64"), ("aarch64", "arm64")):
|
for zigcpu, gocpu in (("x86_64", "amd64"), ("aarch64", "arm64")):
|
||||||
ret.append(_target_darwin(gocpu, zigcpu))
|
ret.append(_target_darwin(gocpu, zigcpu))
|
||||||
|
ret.append(_target_windows(gocpu, zigcpu))
|
||||||
ret.append(_target_linux_musl(gocpu, zigcpu))
|
ret.append(_target_linux_musl(gocpu, zigcpu))
|
||||||
for glibc in _GLIBCS:
|
for glibc in _GLIBCS:
|
||||||
ret.append(_target_linux_gnu(gocpu, zigcpu, glibc))
|
ret.append(_target_linux_gnu(gocpu, zigcpu, glibc))
|
||||||
@ -70,6 +71,24 @@ def _target_darwin(gocpu, zigcpu):
|
|||||||
tool_paths = {"ld": "ld64.lld"},
|
tool_paths = {"ld": "ld64.lld"},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _target_windows(gocpu, zigcpu):
|
||||||
|
return struct(
|
||||||
|
gotarget = "windows_{}".format(gocpu),
|
||||||
|
zigtarget = "{}-windows-gnu".format(zigcpu),
|
||||||
|
includes = [
|
||||||
|
"libunwind/include",
|
||||||
|
"libc/include/any-windows-any",
|
||||||
|
],
|
||||||
|
linkopts = [],
|
||||||
|
copts = [],
|
||||||
|
bazel_target_cpu = "x64_windows",
|
||||||
|
constraint_values = [
|
||||||
|
"@platforms//os:windows",
|
||||||
|
"@platforms//cpu:{}".format(zigcpu),
|
||||||
|
],
|
||||||
|
tool_paths = {"ld": "ld64.lld"},
|
||||||
|
)
|
||||||
|
|
||||||
def _target_linux_gnu(gocpu, zigcpu, glibc_version):
|
def _target_linux_gnu(gocpu, zigcpu, glibc_version):
|
||||||
glibc_suffix = "gnu.{}".format(glibc_version)
|
glibc_suffix = "gnu.{}".format(glibc_version)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user