1
0
Fork 0
mirror of https://github.com/xHyroM/void-packages.git synced 2024-11-24 15:21:06 +01:00
void-packages/common/build-style/zig-build.sh

48 lines
1.4 KiB
Bash
Raw Normal View History

2024-03-29 08:12:19 +01:00
do_build() {
local zig_target zig_cpu
# TODO: This duplication between build-profiles and cross-profiles
# is totally unnecessary. It would be nice if there was some way to
# avoid it.
if [ "$CROSS_BUILD" ]; then
zig_target="${XBPS_CROSS_ZIG_TARGET}"
zig_cpu="${XBPS_CROSS_ZIG_CPU}"
else
zig_target="${XBPS_ZIG_TARGET}"
zig_cpu="${XBPS_ZIG_CPU}"
fi
# Inform zig of the required libc include paths.
cat > xbps_zig_libc.txt <<-EOF
include_dir=${XBPS_CROSS_BASE}/usr/include
sys_include_dir=${XBPS_CROSS_BASE}/usr/include
crt_dir=${XBPS_CROSS_BASE}/usr/lib
msvc_lib_dir=
kernel32_lib_dir=
gcc_dir=
EOF
# The Zig build system only has a single install step, there is no
# way to build artifacts for a given prefix and then install those artifacts
# to that prefix at some later time. Therefore, we build and install to the zig-out
# directory and later copy the artifacts to the destdir in do_install().
# We use zig-out to avoid path conflicts as it is the default install
# prefix used by the zig build system.
DESTDIR="zig-out" zig build \
-j"${XBPS_MAKEJOBS}" \
2024-03-29 08:12:19 +01:00
--sysroot "${XBPS_CROSS_BASE}" \
--search-prefix "${XBPS_CROSS_BASE}/usr" \
--prefix /usr \
--global-cache-dir /host/zig \
2024-03-29 08:12:19 +01:00
--libc xbps_zig_libc.txt \
--release=safe \
--verbose \
2024-03-29 08:12:19 +01:00
-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
install \
2024-03-29 08:12:19 +01:00
${configure_args}
}
do_install() {
cp -r zig-out/* "${DESTDIR}"
}