mirror of
https://github.com/chatmail/core.git
synced 2026-04-05 23:22:11 +03:00
This avoids cluttering workdir with unpacked tarball and will work automatically once PEP-723 is implemented.
58 lines
1.3 KiB
Python
Executable File
58 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# /// pyproject
|
|
# [run]
|
|
# dependencies = [
|
|
# "ziglang==0.11.0"
|
|
# ]
|
|
# ///
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def flag_filter(flag: str) -> bool:
|
|
# Workaround for <https://github.com/sfackler/rust-openssl/issues/2043>.
|
|
if flag == "-latomic":
|
|
return False
|
|
|
|
if flag == "-lc":
|
|
return False
|
|
if flag == "-Wl,-melf_i386":
|
|
return False
|
|
if "self-contained" in flag and "crt" in flag:
|
|
return False
|
|
return True
|
|
|
|
|
|
def main():
|
|
args = [flag for flag in sys.argv[1:] if flag_filter(flag)]
|
|
zig_target = os.environ["ZIG_TARGET"]
|
|
zig_cpu = os.environ.get("ZIG_CPU")
|
|
if zig_cpu:
|
|
zig_cpu_args = ["-mcpu=" + zig_cpu]
|
|
args = [x for x in args if not x.startswith("-march")]
|
|
else:
|
|
zig_cpu_args = []
|
|
|
|
# Disable atomics and use locks instead in OpenSSL.
|
|
# Zig toolchains do not provide atomics.
|
|
# This is a workaround for <https://github.com/deltachat/deltachat-core-rust/issues/4799>
|
|
args += ["-DBROKEN_CLANG_ATOMICS"]
|
|
|
|
subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"-m",
|
|
"ziglang",
|
|
"cc",
|
|
"-target",
|
|
zig_target,
|
|
*zig_cpu_args,
|
|
*args,
|
|
],
|
|
check=True,
|
|
)
|
|
|
|
|
|
main()
|