112 lines
1.7 KiB
Plaintext
112 lines
1.7 KiB
Plaintext
cc-clean(){
|
|
rm -rf ./**/*.out 2>/dev/null
|
|
}
|
|
|
|
cc-run(){
|
|
local file
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: cc-run <file> [args...]" >&2
|
|
return 1
|
|
fi
|
|
|
|
cc-clean
|
|
|
|
file="$1"
|
|
shift
|
|
|
|
cc -std=c99 "${file}" -o "${file}.out" -Wall -Wextra -Werror && \
|
|
"./${file}.out" "$@"
|
|
|
|
cc-clean
|
|
}
|
|
|
|
cc-run-test-inline(){
|
|
local file
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: cc-run <file> [args...]" >&2
|
|
return 1
|
|
fi
|
|
|
|
cc-clean
|
|
|
|
file="$1"
|
|
shift
|
|
|
|
if command -v norminette &>/dev/null
|
|
then
|
|
norminette "${file}"
|
|
fi
|
|
|
|
cc -std=c99 "${file}" -o "${file}.out" -Wall -Wextra -Werror -DTEST=please && \
|
|
"./${file}.out" "$@"
|
|
|
|
cc-clean
|
|
}
|
|
|
|
cc-run-test(){
|
|
local file
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: cc-run <file> [args...]" >&2
|
|
return 1
|
|
fi
|
|
|
|
cc-clean
|
|
|
|
file="$1"
|
|
shift
|
|
|
|
# remove trailing .c if present
|
|
base="${file%.*}"
|
|
|
|
if command -v norminette &>/dev/null; then
|
|
norminette "${base}.c"
|
|
fi
|
|
|
|
# compile base.test.c -> base.test.out and run it
|
|
cc -std=c99 "${base}.test.c" -o "${base}.test.out" -Wall -Wextra -Werror &&
|
|
"./${base}.test.out" "$@"
|
|
|
|
cc-clean
|
|
}
|
|
|
|
|
|
cc-run-lax(){
|
|
local file
|
|
if [ -z "$1" ]; then
|
|
echo "Usage: cc-run <file> [args...]" >&2
|
|
return 1
|
|
fi
|
|
|
|
cc-clean
|
|
|
|
file="$1"
|
|
shift
|
|
|
|
if command -v norminette &>/dev/null
|
|
then
|
|
norminette "${file}"
|
|
fi
|
|
|
|
cc -std=c99 "${file}" -o "${file}.out" -DTEST=please && \
|
|
"./${file}.out" "$@"
|
|
|
|
cc-clean
|
|
}
|
|
|
|
cc-test(){
|
|
local test base
|
|
cc-clean
|
|
if ! ls *_test.c >/dev/null 2>&1; then
|
|
echo "No _test.c files found" >&2
|
|
return 1
|
|
fi
|
|
for test in *_test.c; do
|
|
base="${test%.c}"
|
|
cc "${test}" -o "${base}.out" -Wall -Wextra -Werror
|
|
done
|
|
for test in *_test.out; do
|
|
"./${test}"
|
|
done
|
|
# cc-clean
|
|
}
|