build scripts improved
This commit is contained in:
parent
ed0fb16d53
commit
cb64df9218
@ -5,6 +5,6 @@ source build_scripts/init.sh
|
|||||||
print "${CYAN}=============[build_lib]==============\n"
|
print "${CYAN}=============[build_lib]==============\n"
|
||||||
clear_dir bin
|
clear_dir bin
|
||||||
clear_dir obj
|
clear_dir obj
|
||||||
compile_c "-O2 -fpic -shared" "$SRC_C tests/test_marshalling.c"
|
compile_c "$BUILD_LIB_C_ARGS" "$SRC_C tests/test_marshalling.c"
|
||||||
compile_cpp "-O2 -fpic -shared" "$SRC_CPP"
|
compile_cpp "$BUILD_LIB_C_ARGS" "$SRC_CPP"
|
||||||
link "-shared -O2 -fpic -flto -Wl,-soname,$LIB_FILE" "$LIB_FILE"
|
link "$BUILD_LIB_CPP_ARGS $BUILD_LIB_LINKER_ARGS" "$LIB_FILE"
|
||||||
|
|||||||
@ -5,6 +5,6 @@ source build_scripts/init.sh
|
|||||||
print "${CYAN}=============[build_test]=============\n"
|
print "${CYAN}=============[build_test]=============\n"
|
||||||
clear_dir bin
|
clear_dir bin
|
||||||
clear_dir obj
|
clear_dir obj
|
||||||
compile_c "-O0 -g" "$SRC_C $TESTS_C"
|
compile_c "$BUILD_TEST_C_ARGS" "$SRC_C $TESTS_C"
|
||||||
compile_cpp "-O0 -g" "$SRC_CPP $TESTS_CPP"
|
compile_cpp "$BUILD_TEST_CPP_ARGS" "$SRC_CPP $TESTS_CPP"
|
||||||
link " " $TEST_FILE
|
link "$BUILD_TEST_CPP_ARGS $BUILD_TEST_LINKER_ARGS" $TEST_FILE
|
||||||
|
|||||||
@ -2,18 +2,26 @@
|
|||||||
|
|
||||||
OUTDIR=bin
|
OUTDIR=bin
|
||||||
OBJDIR=obj
|
OBJDIR=obj
|
||||||
TEST_FILE=kerep.com
|
|
||||||
LIB_FILE=kerep.so
|
|
||||||
DLL_FILE=kerep.dll
|
|
||||||
CMP_C=gcc
|
CMP_C=gcc
|
||||||
CMP_CPP=g++
|
CMP_CPP=g++
|
||||||
STD_C=c11
|
STD_C=c11
|
||||||
STD_CPP=c++17
|
STD_CPP=c++17
|
||||||
WARN_C="-Wall -Wno-discarded-qualifiers" #-Wextra
|
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_C="$( find src -name *.c)"
|
||||||
SRC_CPP="$( find src -name *.cpp)"
|
SRC_CPP="$( find src -name *.cpp)"
|
||||||
TESTS_C="$( find tests -name *.c)"
|
TESTS_C="$( find tests -name *.c)"
|
||||||
TESTS_CPP="$(find tests -name *.cpp)"
|
TESTS_CPP="$(find tests -name *.cpp)"
|
||||||
VALGRIND_ARGS=-s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ \
|
VALGRIND_ARGS=-s --read-var-info=yes --track-origins=yes --fullpath-after=kerep/ --leak-check=full --show-leak-kinds=all
|
||||||
--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=""
|
||||||
|
|||||||
@ -21,6 +21,7 @@ function compile {
|
|||||||
print "${BLUE}args: ${GRAY}$args\n"
|
print "${BLUE}args: ${GRAY}$args\n"
|
||||||
local sources=$5
|
local sources=$5
|
||||||
print "${BLUE}sources: ${GRAY}$sources\n"
|
print "${BLUE}sources: ${GRAY}$sources\n"
|
||||||
|
local error=0
|
||||||
for srcfile in $sources
|
for srcfile in $sources
|
||||||
do
|
do
|
||||||
local object="$OBJDIR/$(basename $srcfile).o"
|
local object="$OBJDIR/$(basename $srcfile).o"
|
||||||
@ -28,9 +29,14 @@ function compile {
|
|||||||
if ! $($cmp -std=$std $warn $args -c -o $object $srcfile)
|
if ! $($cmp -std=$std $warn $args -c -o $object $srcfile)
|
||||||
then
|
then
|
||||||
print "${RED}some error happened\n"
|
print "${RED}some error happened\n"
|
||||||
exit 1
|
error=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ $error != 0 ]
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# (args, sources)
|
# (args, sources)
|
||||||
@ -54,7 +60,7 @@ function link {
|
|||||||
print "${BLUE}outfile: ${GRAY}$outfile\n"
|
print "${BLUE}outfile: ${GRAY}$outfile\n"
|
||||||
local objects="$(find $OBJDIR -name *.o)"
|
local objects="$(find $OBJDIR -name *.o)"
|
||||||
print "${BLUE}objects: ${GRAY}$objects\n"
|
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
|
then
|
||||||
print "${GREEN}file $CYAN$outfile ${GREEN}created\n"
|
print "${GREEN}file $CYAN$outfile ${GREEN}created\n"
|
||||||
rm -rf $OBJDIR
|
rm -rf $OBJDIR
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user