diff --git a/build_scripts/build_lib.sh b/build_scripts/build_lib.sh index 45bb44b..2df2616 100644 --- a/build_scripts/build_lib.sh +++ b/build_scripts/build_lib.sh @@ -5,6 +5,6 @@ source build_scripts/init.sh print "${CYAN}=============[build_lib]==============\n" clear_dir bin clear_dir obj -compile_c "-O2 -fpic -shared" "$SRC_C tests/test_marshalling.c" -compile_cpp "-O2 -fpic -shared" "$SRC_CPP" -link "-shared -O2 -fpic -flto -Wl,-soname,$LIB_FILE" "$LIB_FILE" +compile_c "$BUILD_LIB_C_ARGS" "$SRC_C tests/test_marshalling.c" +compile_cpp "$BUILD_LIB_C_ARGS" "$SRC_CPP" +link "$BUILD_LIB_CPP_ARGS $BUILD_LIB_LINKER_ARGS" "$LIB_FILE" diff --git a/build_scripts/build_test.sh b/build_scripts/build_test.sh index 26bc10f..5ff01e8 100644 --- a/build_scripts/build_test.sh +++ b/build_scripts/build_test.sh @@ -5,6 +5,6 @@ source build_scripts/init.sh print "${CYAN}=============[build_test]=============\n" clear_dir bin clear_dir obj -compile_c "-O0 -g" "$SRC_C $TESTS_C" -compile_cpp "-O0 -g" "$SRC_CPP $TESTS_CPP" -link " " $TEST_FILE +compile_c "$BUILD_TEST_C_ARGS" "$SRC_C $TESTS_C" +compile_cpp "$BUILD_TEST_CPP_ARGS" "$SRC_CPP $TESTS_CPP" +link "$BUILD_TEST_CPP_ARGS $BUILD_TEST_LINKER_ARGS" $TEST_FILE diff --git a/build_scripts/default.config.sh b/build_scripts/default.config.sh index 740a22e..819273a 100644 --- a/build_scripts/default.config.sh +++ b/build_scripts/default.config.sh @@ -2,18 +2,26 @@ OUTDIR=bin OBJDIR=obj -TEST_FILE=kerep.com -LIB_FILE=kerep.so -DLL_FILE=kerep.dll CMP_C=gcc CMP_CPP=g++ STD_C=c11 STD_CPP=c++17 WARN_C="-Wall -Wno-discarded-qualifiers" #-Wextra -WARN_CPP="-Wall -Wconversion-null -Wno-unused-variable -Wno-return-type" #-Wextra +WARN_CPP="-Wall -Wno-unused-variable -Wno-return-type" #-Wextra SRC_C="$( find src -name *.c)" SRC_CPP="$( find src -name *.cpp)" TESTS_C="$( find tests -name *.c)" TESTS_CPP="$(find tests -name *.cpp)" -VALGRIND_ARGS=-s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \ - --leak-check=full --show-leak-kinds=all +VALGRIND_ARGS=-s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ --leak-check=full --show-leak-kinds=all + +# build_lib +LIB_FILE=kerep.so +BUILD_LIB_C_ARGS="-O2 -fpic -shared" +BUILD_LIB_CPP_ARGS="$BUILD_LIB_CPP_ARGS" +BUILD_LIB_LINKER_ARGS="-flto -Wl,-soname,$LIB_FILE" + +# build_test +TEST_FILE=kerep.com +BUILD_TEST_C_ARGS="-O0 -g" +BUILD_TEST_CPP_ARGS="$BUILD_TEST_CPP_ARGS" +BUILD_TEST_LINKER_ARGS="" diff --git a/build_scripts/functions.sh b/build_scripts/functions.sh index 15939de..f7a23ca 100644 --- a/build_scripts/functions.sh +++ b/build_scripts/functions.sh @@ -21,6 +21,7 @@ function compile { print "${BLUE}args: ${GRAY}$args\n" local sources=$5 print "${BLUE}sources: ${GRAY}$sources\n" + local error=0 for srcfile in $sources do local object="$OBJDIR/$(basename $srcfile).o" @@ -28,9 +29,14 @@ function compile { if ! $($cmp -std=$std $warn $args -c -o $object $srcfile) then print "${RED}some error happened\n" - exit 1 + error=1 fi done + + if [ $error != 0 ] + then + exit 1 + fi } # (args, sources) @@ -54,7 +60,7 @@ function link { print "${BLUE}outfile: ${GRAY}$outfile\n" local objects="$(find $OBJDIR -name *.o)" print "${BLUE}objects: ${GRAY}$objects\n" - if $CMP_C $args -o $outfile $(echo $objects | tr '\n' ' ') + if $CMP_CPP $args -o $outfile $(echo $objects | tr '\n' ' ') then print "${GREEN}file $CYAN$outfile ${GREEN}created\n" rm -rf $OBJDIR