From 38eeb4303e4201794d49bf794bbe86cb24a21bd5 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Wed, 4 May 2022 18:28:15 +0200 Subject: [PATCH] created basic app source code --- build.sh | 39 +++++++++++++++++++++++++++++++++++++-- src/app/main.c | 8 ++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/app/main.c diff --git a/build.sh b/build.sh index 20bd325..55a1f0a 100644 --- a/build.sh +++ b/build.sh @@ -10,12 +10,18 @@ testFile="src/lib/test/main.c" sourceFiles="src/lib/*.c" includeFiles="include/*.h" +appFile="src/app/main.c" + compiler="cc" + testOutput="out/why2-test" +appOutput="out/why2-app" + installOutput="libwhy2.so" -flags="-Wall -ljson-c -lcurl" includeDirectory="/usr/include/why2" +flags="-Wall -ljson-c -lcurl" + if [[ "$1" == "test" ]]; then ########## TEST ########## ### echo "Using '$compiler' as default compiler." @@ -98,13 +104,42 @@ elif [[ "$1" == "install" ]]; then ########## INSTALL ########## ### rm -rf *.o +elif [[ "$1" == "app" ]]; then ########## BUILD APP ########## + ### + echo "Using '$compiler' as default compiler." + ### + + flags="-Wall" + + # Check for debug flag + if [[ "$2" == "debug" ]]; then ########## TEST & DEBUG ########## + flags="$flags -g" + echo "Using debug flag" + fi + + ### + echo "Compiling... (Flags: $flags)" + ### + + # Compile + $compiler $appFile $flags -o $appOutput + + # Compilation failed + if [[ $? -ne 0 ]]; then + echo -e "\nCompilation failed." + exit 1 + fi + + ### + echo "Output generated as '$appOutput'" + ### else ########## ELSE ########## if [[ "$1" == "installTest" ]]; then ########## INSTALL & TEST ########## ./build.sh install ./build.sh test else ########## ERR ########## ### - echo "You have to enter 'test' or 'install' as arguments." + echo "You have to enter 'install', 'test' or 'app' as arguments. (Or 'installTest' for install & test)" ### exit 1 diff --git a/src/app/main.c b/src/app/main.c new file mode 100644 index 0000000..9425a3d --- /dev/null +++ b/src/app/main.c @@ -0,0 +1,8 @@ +#include + +int main(void) +{ + printf("Hello, World!\n"); + + return 0; +} \ No newline at end of file