vp-build/common/build-style/zig-build.sh
Isaac Freund 020e1aa54b build-styles: add zig-build
We call this "zig-build" instead of just "zig" as this build-style
relies on usage of the zig build system. In the future, other build
systems such as meson may support zig code. Furthermore, the zig
build system may be used to build C/C++ code as well, not just zig.
2021-11-13 11:46:21 -03:00

42 lines
1.3 KiB
Bash

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 \
--sysroot "${XBPS_CROSS_BASE}" \
--libc xbps_zig_libc.txt \
-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
-Drelease-safe --prefix /usr install \
${configure_args}
}
do_install() {
cp -r zig-out/* "${DESTDIR}"
}