48 lines
2 KiB
Bash
Executable file
48 lines
2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# check-fileroots.sh - Host-cc gate for the run-time file roots
|
|
# (src/core/fileRoot.h, JL_HAS_FILE_ROOTS, which the DVX port defines): with
|
|
# the flag, DATA/ is read under the port's read root and SAVES/ and
|
|
# joeylog.txt are written under its write root; without it the layout every
|
|
# other port has, all relative to the current directory, is unchanged.
|
|
#
|
|
# Builds the BLANK port (the check-blank.sh source set) plus
|
|
# tests/host/fileRootHost.c twice, with the POSIX save HAL flags check-save.sh
|
|
# uses: once with -DJL_HAS_FILE_ROOTS (the harness is the port: its roots are
|
|
# folders in a temp dir) and once without. Each runs in an empty current
|
|
# directory of its own, and the flagless program must not contain
|
|
# jlLogClose, which exists only under the flag. Exits nonzero on any failed
|
|
# check.
|
|
set -euo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
cc=${CC:-cc}
|
|
work=$(mktemp -d -t joeylib-fileroots.XXXXXX)
|
|
trap 'rm -rf "$work"' EXIT
|
|
|
|
cd "$repo"
|
|
build() {
|
|
"$cc" -DJOEYLIB_PLATFORM_BLANK -DJL_HAS_SAVE_DIR_ENSURE -DJL_HAS_SAVE_DELETE "$@" \
|
|
-Iinclude -Iinclude/joey -Isrc/core -Isrc/codegen -Wall -Wextra \
|
|
src/core/*.c src/generic/*.c src/blank/blank.c tests/host/fileRootHost.c
|
|
}
|
|
build -DJL_HAS_FILE_ROOTS -o "$work/rootsHost"
|
|
build -o "$work/plainHost"
|
|
|
|
if nm "$work/plainHost" | grep -qw jlLogClose; then
|
|
echo "check-fileroots: FAIL - jlLogClose is in the build without JL_HAS_FILE_ROOTS" >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "$work/roots" "$work/plain"
|
|
fails=0
|
|
( cd "$work/roots" && "$work/rootsHost" "$work/readRoot/" "$work/writeRoot/" ) || fails=1
|
|
( cd "$work/plain" && "$work/plainHost" ) || fails=1
|
|
if [ "$fails" != 0 ]; then
|
|
echo "check-fileroots: FAIL" >&2
|
|
exit 1
|
|
fi
|
|
echo "check-fileroots: PASS (roots honoured under JL_HAS_FILE_ROOTS; the flagless layout unchanged)"
|