lw-build-system/skel/scripts/build.c++.tests/build.tests

40 lines
849 B
Plaintext
Raw Normal View History

# These are external variables, and shouldn't clash with anything else
# TESTS_BUILT
#
build_target lib
LIBS="${LIBCPP}"
if [ -z ${TESTS_BUILT} ]
then
echo "Building test programs..."
do_cmd mkdir -p obj/tests || return 1
for SRC in src/tests/*.cpp
do
TEST="obj/tests/$(basename ${SRC} | sed -e 's,.cpp$,,')"
MODIFIED=0
for file in ${LIBCPP} ${SRC}
do
if [ ${file} -nt ${TEST} ]
then
MODIFIED=1
break
fi
done
if [ ${MODIFIED} -ne 0 ]
then
do_cmd ${CXX} -Iobj ${CFLAGS} -o ${TEST} ${SRC} ${LIBS} || return 1
print_success "Built ${TEST}"
else
print_success "${TEST} is up to date"
fi
done
print_success "All tests built"
TESTS_BUILT=1
fi