1

Use artifact_name_pattern to specify proper macos and windows artifact names.

On macos, dynamic libraries are generated as "libfoo.dylib".

On windows, executables end with ".exe", static libraries end with ".lib",
and dynamic libraries end with ".dll".
This commit is contained in:
Jeremy Volkman
2022-12-17 15:27:21 -08:00
committed by Motiejus Jakštys
parent 6ee01496be
commit cc8f113489
4 changed files with 39 additions and 11 deletions

View File

@@ -39,6 +39,10 @@ def declare_cc_toolchains(os, zig_sdk_path):
for incl in getattr(target_config, "compiler_extra_includes", []):
copts = copts + ["-include", zig_sdk_path + "/" + incl]
# We can't pass a list of structs to a rule, so we use json encoding.
artifact_name_patterns = getattr(target_config, "artifact_name_patterns", [])
artifact_name_pattern_strings = [json.encode(p) for p in artifact_name_patterns]
zig_cc_toolchain_config(
name = zigtarget + "_cc_config",
target = zigtarget,
@@ -53,6 +57,7 @@ def declare_cc_toolchains(os, zig_sdk_path):
compiler = "clang",
abi_version = "unknown",
abi_libc_version = "unknown",
artifact_name_patterns = artifact_name_pattern_strings,
visibility = ["//visibility:private"],
)

View File

@@ -72,6 +72,13 @@ def _target_macos(gocpu, zigcpu):
"@platforms//cpu:{}".format(zigcpu),
],
tool_paths = {"ld": "ld64.lld"},
artifact_name_patterns = [
{
"category_name": "dynamic_library",
"prefix": "lib",
"extension": ".dylib",
},
],
)
def _target_windows(gocpu, zigcpu):
@@ -92,6 +99,23 @@ def _target_windows(gocpu, zigcpu):
"@platforms//cpu:{}".format(zigcpu),
],
tool_paths = {"ld": "ld64.lld"},
artifact_name_patterns = [
{
"category_name": "static_library",
"prefix": "",
"extension": ".lib",
},
{
"category_name": "dynamic_library",
"prefix": "",
"extension": ".dll",
},
{
"category_name": "executable",
"prefix": "",
"extension": ".exe",
},
],
)
def _target_linux_gnu(gocpu, zigcpu, glibc_version):
@@ -126,6 +150,7 @@ def _target_linux_gnu(gocpu, zigcpu, glibc_version):
],
libc_constraint = "@zig_sdk//libc:{}".format(glibc_suffix),
tool_paths = {"ld": "ld.lld"},
artifact_name_patterns = [],
)
def _target_linux_musl(gocpu, zigcpu):
@@ -151,4 +176,5 @@ def _target_linux_musl(gocpu, zigcpu):
],
libc_constraint = "@zig_sdk//libc:musl",
tool_paths = {"ld": "ld.lld"},
artifact_name_patterns = [],
)