Add build script and gitignore

This initial commit adds a relatively advanced build-script and a very
small .gitignore file which should definitely be expanded.
This commit is contained in:
Eric-Paul Ickhorn 2024-09-07 22:09:47 +02:00
commit ae29a46e8f
Signed by: epickh
GPG Key ID: 1358818BAA38B104
2 changed files with 87 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.private/
.build/
voxula

83
scripts/build.bash Normal file
View File

@ -0,0 +1,83 @@
cd $(dirname $0)
SCRIPT_PATH=$(pwd)
cd ../..
PROJECT_PATH=$(pwd)
function list_modules() {
MODULE_FOLDER=$1
MODULES=$(ls $MODULE_FOLDER)
for MODULE in $MODULES
do
if [[ -d "$MODULE_FOLDER/$MODULE/src-c" ]];
then
echo $MODULE
fi
done
}
function make_object_name() {
SOURCE_PATH=$1
OBJECT_NAME=$(echo $SOURCE_PATH | tr "-" "_" | tr "/" "-")
echo $OBJECT_NAME.o
}
function list_sources() {
MODULE_PATH=$1
ENTRY_PATH=$(pwd)
cd $MODULE_PATH
SOURCES=$(find . -type f | grep ".c$")
for SOURCE in $SOURCES
do
echo $SOURCE | cut -c 3-
done
cd $ENTRY_PATH
}
function make_include_statements() {
MODULE_NAME=$1
for INCLUDE_PATH in $(cat modules/$MODULE_NAME/includes.txt)
do
MODIFIED_PATH="${INCLUDE_PATH//"{self}"/"modules/$PROJECT_PATH/$MODULE_NAME"}"
MODIFIED_PATH="${MODIFIED_PATH//"{module-folder}"/"$PROJECT_PATH/modules"}"
echo "-I ${MODIFIED_PATH//"{dependencies}"/"$PROJECT_PATH/dependencies"}"
done
}
function build_single_module() {
MODULE_NAME=$1
mkdir -p $PROJECT_PATH/.build/modules/$MODULE_NAME/objects
rm -f $PROJECT_PATH/.build/modules/$MODULE_NAME/objects/*.o
echo "| ========================================>"
echo "| Now building module: $MODULE_NAME"
echo "| ========================================>"
INCLUDE_STATEMENTS=$(make_include_statements $MODULE_NAME)
SOURCES=$(list_sources modules/$MODULE_NAME/src-c)
for SOURCE in $SOURCES
do
echo "> $SOURCE"
OBJECT_NAME=$(make_object_name $SOURCE)
gcc -c -o .build/modules/$MODULE_NAME/objects/$OBJECT_NAME -g3 modules/$MODULE_NAME/src-c/$SOURCE $INCLUDE_STATEMENTS
done
ar -rvs .build/archives/voxula-$MODULE_NAME.a .build/modules/$MODULE_NAME/objects/*.o
}
mkdir -p .build/archives
rm -f .build/archives/*.a
MODULE_LIST=$(list_modules "modules")
for MODULE in $MODULE_LIST
do
build_single_module $MODULE
done
gcc -g3 -o voxula .build/archives/*.a