Added the first version of build.bash
This commit is contained in:
parent
ffa46be623
commit
1f8ff01c81
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
PROJECT_ROOT=`pwd`
|
||||
GCC_ARGUMENTS="-std=c11 -Wall"
|
||||
|
||||
MODULES=(
|
||||
"core"
|
||||
)
|
||||
|
||||
# Arguments:
|
||||
# 1) Path to the module
|
||||
# 2) Include Statements
|
||||
function compile_folder() {
|
||||
|
||||
OBJECTS_FOLDER="$PROJECT_ROOT/.build/objects/$1"
|
||||
mkdir -p $OBJECTS_FOLDER
|
||||
cd $PROJECT_ROOT/$1
|
||||
|
||||
cd src-c/
|
||||
for SOURCE_FILE in $(find .)
|
||||
do
|
||||
# Create every folder except of the source root folder (src-c/).
|
||||
if [[ $SOURCE_FILE != "." ]] then
|
||||
if [[ -d $SOURCE_FILE ]] then
|
||||
mkdir $SOURCE_FILE
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f $SOURCE_FILE ]] then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Cut out the ./ at the front of the path
|
||||
SOURCE_FILE=$(echo $SOURCE_FILE | cut -c 3-)
|
||||
|
||||
echo "==== Building '$SOURCE_FILE' ===="
|
||||
gcc -c $GCC_ARGUMENTS -o $OBJECTS_FOLDER/$SOURCE_FILE.o $SOURCE_FILE $2
|
||||
done
|
||||
}
|
||||
|
||||
function compile_all_modules() {
|
||||
for MODULE in $MODULES
|
||||
do
|
||||
echo "============ CURRENT MODULE: $MODULE ============"
|
||||
compile_folder "$MODULE" "-I $PROJECT_ROOT/$MODULE/exports/"
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
"release")
|
||||
GCC_ARGUMENTS="$GCC_ARGUMENTS -O3"
|
||||
compile_all_modules
|
||||
;;
|
||||
|
||||
"small")
|
||||
GCC_ARGUMENTS="$GCC_ARGUMENTS -Os"
|
||||
compile_all_modules
|
||||
;;
|
||||
|
||||
"debug")
|
||||
GCC_ARGUMENTS="$GCC_ARGUMENTS -p -g3 -Wextra"
|
||||
compile_all_modules
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Please choose one of the following profiles:"
|
||||
echo "[ release | small | debug ]"
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue