2021-11-02 13:47:36 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-11-08 09:08:29 +00:00
|
|
|
. ./ci/zinc/linux_base.sh
|
2021-11-02 13:47:36 +00:00
|
|
|
|
2021-11-08 09:08:29 +00:00
|
|
|
ZIG="$DEPS_LOCAL/bin/zig"
|
2021-11-02 13:47:36 +00:00
|
|
|
TARGET="${ARCH}-linux-musl"
|
|
|
|
MCPU="baseline"
|
|
|
|
|
|
|
|
# Make the `zig version` number consistent.
|
|
|
|
# This will affect the cmake command below.
|
|
|
|
git config core.abbrev 9
|
|
|
|
|
|
|
|
# Build debug zig.
|
|
|
|
echo "BUILD debug zig with zig:$($ZIG version)"
|
|
|
|
|
|
|
|
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
|
|
|
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
|
|
|
|
|
|
|
mkdir _debug
|
|
|
|
cd _debug
|
|
|
|
cmake .. \
|
2021-11-08 09:08:29 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \
|
|
|
|
-DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
|
2021-11-02 13:47:36 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
-DZIG_TARGET_TRIPLE="$TARGET" \
|
|
|
|
-DZIG_TARGET_MCPU="$MCPU" \
|
|
|
|
-DZIG_STATIC=ON \
|
|
|
|
-GNinja
|
|
|
|
|
|
|
|
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
|
|
|
|
# so that installation and testing do not get affected by them.
|
|
|
|
unset CC
|
|
|
|
unset CXX
|
|
|
|
|
|
|
|
ninja $JOBS install
|
|
|
|
|
2021-11-08 09:08:29 +00:00
|
|
|
ZIG=$DEBUG_STAGING/bin/zig
|
2021-11-02 13:47:36 +00:00
|
|
|
|
|
|
|
# Here we rebuild zig but this time using the Zig binary we just now produced to
|
|
|
|
# build zig1.o rather than relying on the one built with stage0. See
|
|
|
|
# https://github.com/ziglang/zig/issues/6830 for more details.
|
|
|
|
cmake .. -DZIG_EXECUTABLE="$ZIG"
|
|
|
|
ninja $JOBS install
|
|
|
|
|
|
|
|
cd $WORKSPACE
|
|
|
|
|
|
|
|
# Build release zig.
|
|
|
|
echo "BUILD release zig with zig:$($ZIG version)"
|
|
|
|
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
|
|
|
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
|
|
|
mkdir _release
|
|
|
|
cd _release
|
|
|
|
cmake .. \
|
2021-11-08 09:08:29 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \
|
|
|
|
-DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
|
2021-11-02 13:47:36 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DZIG_TARGET_TRIPLE="$TARGET" \
|
|
|
|
-DZIG_TARGET_MCPU="$MCPU" \
|
|
|
|
-DZIG_STATIC=ON \
|
|
|
|
-GNinja
|
|
|
|
unset CC
|
|
|
|
unset CXX
|
|
|
|
ninja $JOBS install
|
|
|
|
|
|
|
|
cd $WORKSPACE
|
|
|
|
|
|
|
|
# Look for non-conforming code formatting.
|
|
|
|
# Formatting errors can be fixed by running `zig fmt` on the files printed here.
|
|
|
|
$ZIG fmt --check .
|
|
|
|
|
2021-11-08 09:08:29 +00:00
|
|
|
# Explicit exit helps show last command duration.
|
|
|
|
exit
|