From df65850678a792148de48b724947af35f4978809 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 23 Feb 2025 15:06:12 +0000 Subject: [PATCH] Add support for building different components of the library --- compile | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/compile b/compile index 46bac00..e3c90a2 100755 --- a/compile +++ b/compile @@ -1,6 +1,17 @@ #!/bin/bash BUILD_TYPE="debug" +COMPONENTS="all" + +function join_array { + DELIM="$1" + shift + local IFS="$DELIM" + echo "$*" +} + +SUPPORTED_COMPONENTS=("all" "testing" "os" "core") +COMPONENTS_STRING="$(join_array "|" ${SUPPORTED_COMPONENTS[@]})" while [[ $# > 0 ]];do case $1 in @@ -8,8 +19,14 @@ while [[ $# > 0 ]];do BUILD_TYPE="release" shift ;; + --components) + COMPONENTS="$2" + shift + shift + ;; *|-*|--*) echo "Unknown option $1" + echo "Usage: $0 [--release] [--components $COMPONENTS_STRING (Default: all)]" exit 1 ;; esac @@ -25,7 +42,26 @@ if [[ $CC == "gcc" ]]; then fi INCLUDE="$(find src -type d | xargs -I{} echo -n "-I{} ")" -SRC="$(find src -type f -name "*.c" | xargs -I{} echo -n "{} ")" + +case $COMPONENTS in + all) + SRC="src/wapp.c" + ;; + testing) + SRC="src/testing/wapp_testing.c" + ;; + os) + SRC="src/os/wapp_os.c" + ;; + core) + SRC="src/core/wapp_core.c" + ;; + *) + echo "Unrecognised option for components: $COMPONENTS" + echo "Accepted options: $COMPONENTS_STRING" + exit 2 + ;; +esac TEST_INCLUDE="$(find tests -type d | xargs -I{} echo -n "-I{} ")" TEST_SRC="$(find tests -type f -name "*.c" | xargs -I{} echo -n "{} ")"