os-test-bins: pre-compile tests using makefiles, so they can be run using makefiles on redox

This commit is contained in:
Jeremy Soller 2026-01-09 13:22:20 -07:00
parent 8da1a94f51
commit 44c77960af
No known key found for this signature in database
GPG Key ID: 670FDFB5428E05CA

View File

@ -5,24 +5,16 @@ same_as = "../os-test"
template = "custom"
script = """
DYNAMIC_INIT
SRC=${COOKBOOK_SOURCE}
DST=${COOKBOOK_STAGE}/root/os-test
if [ -z "$TESTBIN" ]; then
pushd ${SRC}
for file in */*/*.c; do
filename="${file%.*}"
mkdir -p $(dirname $DST/$filename)
# adding "true" because compilation can fail
${CC} ${CFLAGS} ${LDFLAGS} "$SRC/$file" -o "$DST/$filename" -Wall || true
echo "./$filename" >> $DST/run.sh
done
popd
else
mkdir -p $(dirname $DST/$TESTBIN)
${CC} ${CFLAGS} ${LDFLAGS} "$SRC/$TESTBIN.c" -o "$DST/$TESTBIN" -Wall
fi
if [ -n "TESTBIN" ]; then
"${COOKBOOK_REDOXER}" write-exec "$DST/$TESTBIN"
fi
# Copy source to /usr/share/os-test
mkdir -p "${COOKBOOK_STAGE}/usr/share/os-test"
cd "${COOKBOOK_STAGE}/usr/share/os-test"
rsync -a "${COOKBOOK_SOURCE}/" "./"
# Pre-compile tests for Redox
make OS=Redox CC="${CC_WRAPPER} ${GNU_TARGET}-gcc" \
CFLAGS= CPPFLAGS= \
LDFLAGS= EXTRA_LDFLAGS= \
CC_FOR_BUILD="${CC_WRAPPER} cc" CFLAGS_FOR_BUILD= CPPFLAGS_FOR_BUILD= \
LDFLAGS_FOR_BUILD= -j ${COOKBOOK_MAKE_JOBS} all
"""