77 lines
2.0 KiB
Bash
77 lines
2.0 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
cd $(dirname "$(pwd)/$0")
|
||
|
REPOSITORY_FOLDER=$(pwd)
|
||
|
|
||
|
MAIN_OBJECTS_FOLDER="$REPOSITORY_FOLDER/.build/objects/"
|
||
|
DEFAULT_LINKAGE_PATHS="
|
||
|
$REPOSITORY_FOLDER/.build/maintree-core.a
|
||
|
$REPOSITORY_FOLDER/.build/librr-core.a
|
||
|
$REPOSITORY_FOLDER/.build/librr-platform.a
|
||
|
"
|
||
|
|
||
|
function get_include_path_configuration() {
|
||
|
TEST_PATH=$1
|
||
|
|
||
|
INCLUDE_CONFIG_PATH="$TEST_PATH/include_paths.txt"
|
||
|
INCLUDE_STATEMENTS="-I $TEST_PATH/inc-c/"
|
||
|
if [[ ! -f $INCLUDE_CONFIG_PATH ]]
|
||
|
then
|
||
|
return
|
||
|
fi
|
||
|
|
||
|
for LINE in $(cat $INCLUDE_CONFIG_PATH)
|
||
|
do
|
||
|
INCLUDE_STATEMENTS="$INCLUDE_STATEMENTS -I $REPOSITORY_FOLDER/$LINE"
|
||
|
done
|
||
|
}
|
||
|
|
||
|
function get_linkage_path_configuration() {
|
||
|
TEST_PATH=$1
|
||
|
|
||
|
LINKAGE_PATHS=$DEFAULT_LINKAGE_PATHS
|
||
|
if [[ -f "$TEST_PATH/linkage_paths.txt" ]]
|
||
|
then
|
||
|
for LINKAGE_ITEM in $(cat "$TEST_PATH/linkage_paths.txt")
|
||
|
do
|
||
|
LINKAGE_PATHS="$LINKAGE_PATHS $REPOSITORY_FOLDER/$LINKAGE_ITEM"
|
||
|
done
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
function compile_single_test() {
|
||
|
TEST_PATH=$1
|
||
|
TEST_NAME=$(basename $TEST_PATH)
|
||
|
|
||
|
echo "Compiling Test: $TEST_NAME"
|
||
|
|
||
|
# TODO: As a small improvement, the tests could be able to have multiple sub-folders for sources.
|
||
|
|
||
|
get_include_path_configuration $TEST_PATH
|
||
|
get_linkage_path_configuration $TEST_PATH
|
||
|
gcc -o $TEST_PATH/$TEST_NAME.elf $TEST_PATH/*.c $LINKAGE_PATHS $INCLUDE_STATEMENTS
|
||
|
}
|
||
|
|
||
|
function compile_all_tests_of_module() {
|
||
|
MODULE_NAME=$1
|
||
|
|
||
|
echo "================================================================"
|
||
|
echo "COMPILING ALL TESTS OF MODULE: '$MODULE_NAME'."
|
||
|
echo " "
|
||
|
|
||
|
TEST_PATH_LIST_PATH="$REPOSITORY_FOLDER/$MODULE_NAME/build-config/tests.txt"
|
||
|
if [[ ! -f $TEST_PATH_LIST_PATH ]]
|
||
|
then
|
||
|
echo "Couldn't find list of tests for module '$MODULE_NAME'. Skipping."
|
||
|
return
|
||
|
fi
|
||
|
|
||
|
for RELATIVE_TEST_PATH in $(cat $TEST_PATH_LIST_PATH)
|
||
|
do
|
||
|
TEST_PATH=$REPOSITORY_FOLDER/$MODULE_NAME/$RELATIVE_TEST_PATH
|
||
|
compile_single_test $TEST_PATH
|
||
|
done
|
||
|
}
|
||
|
|
||
|
compile_all_tests_of_module core
|