From fd4e9dfbdd15a88e5784d93d03ce0ee008c69eb8 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 23 Feb 2025 15:05:06 +0000 Subject: [PATCH 1/5] Add single header and single source entries for each component --- src/common/wapp_common.h | 8 ++++++++ src/core/wapp_core.c | 10 ++++++++++ src/core/wapp_core.h | 10 ++++++++++ src/os/wapp_os.c | 17 +++++++++++++++++ src/os/wapp_os.h | 17 +++++++++++++++++ src/testing/{ => tester}/tester.c | 0 src/testing/{ => tester}/tester.h | 0 src/testing/wapp_testing.c | 9 +++++++++ src/testing/wapp_testing.h | 9 +++++++++ src/wapp.c | 8 ++++++++ src/wapp.h | 9 +++++++++ 11 files changed, 97 insertions(+) create mode 100644 src/common/wapp_common.h create mode 100644 src/core/wapp_core.c create mode 100644 src/core/wapp_core.h create mode 100644 src/os/wapp_os.c create mode 100644 src/os/wapp_os.h rename src/testing/{ => tester}/tester.c (100%) rename src/testing/{ => tester}/tester.h (100%) create mode 100644 src/testing/wapp_testing.c create mode 100644 src/testing/wapp_testing.h create mode 100644 src/wapp.c create mode 100644 src/wapp.h diff --git a/src/common/wapp_common.h b/src/common/wapp_common.h new file mode 100644 index 0000000..71f8363 --- /dev/null +++ b/src/common/wapp_common.h @@ -0,0 +1,8 @@ +#ifndef WAPP_COMMON_H +#define WAPP_COMMON_H + +#include "aliases.h" +#include "misc_utils.h" +#include "platform.h" + +#endif // !WAPP_COMMON_H diff --git a/src/core/wapp_core.c b/src/core/wapp_core.c new file mode 100644 index 0000000..3f14036 --- /dev/null +++ b/src/core/wapp_core.c @@ -0,0 +1,10 @@ +#ifndef WAPP_CORE_C +#define WAPP_CORE_C + +#include "wapp_core.h" +#include "mem_arena.c" +#include "mem_arena_allocator.c" +#include "mem_allocator.c" +#include "str8.c" + +#endif // !WAPP_CORE_C diff --git a/src/core/wapp_core.h b/src/core/wapp_core.h new file mode 100644 index 0000000..0cf370b --- /dev/null +++ b/src/core/wapp_core.h @@ -0,0 +1,10 @@ +#ifndef WAPP_CORE_H +#define WAPP_CORE_H + +#include "mem_arena_allocator.h" +#include "mem_arena.h" +#include "mem_allocator.h" +#include "str8.h" +#include "wapp_common.h" + +#endif // !WAPP_CORE_H diff --git a/src/os/wapp_os.c b/src/os/wapp_os.c new file mode 100644 index 0000000..027c451 --- /dev/null +++ b/src/os/wapp_os.c @@ -0,0 +1,17 @@ +#ifndef WAPP_OS_C +#define WAPP_OS_C + +#include "wapp_os.h" +#include "termcolour_win.c" +#include "termcolour_posix.c" +#include "termcolour.c" +#include "commander_win.c" +#include "commander.c" +#include "commander_posix.c" +#include "mem_utils_win.c" +#include "mem_utils.c" +#include "mem_utils_posix.c" +#include "cpath.c" +#include "wapp_core.c" + +#endif // !WAPP_OS_C diff --git a/src/os/wapp_os.h b/src/os/wapp_os.h new file mode 100644 index 0000000..8a7c5f9 --- /dev/null +++ b/src/os/wapp_os.h @@ -0,0 +1,17 @@ +#ifndef WAPP_OS_H +#define WAPP_OS_H + +#include "termcolour.h" +#include "terminal_colours.h" +#include "shell_utils.h" +#include "commander_output.h" +#include "commander.h" +#include "mem_utils_ops.h" +#include "mem_utils_win.h" +#include "mem_utils.h" +#include "mem_utils_posix.h" +#include "cpath.h" +#include "wapp_common.h" +#include "wapp_core.h" + +#endif // !WAPP_OS_H diff --git a/src/testing/tester.c b/src/testing/tester/tester.c similarity index 100% rename from src/testing/tester.c rename to src/testing/tester/tester.c diff --git a/src/testing/tester.h b/src/testing/tester/tester.h similarity index 100% rename from src/testing/tester.h rename to src/testing/tester/tester.h diff --git a/src/testing/wapp_testing.c b/src/testing/wapp_testing.c new file mode 100644 index 0000000..d56d3ee --- /dev/null +++ b/src/testing/wapp_testing.c @@ -0,0 +1,9 @@ +#ifndef WAPP_TESTING_C +#define WAPP_TESTING_C + +#include "wapp_testing.h" +#include "tester.c" +#include "wapp_core.c" +#include "wapp_os.c" + +#endif // !WAPP_TESTING_C diff --git a/src/testing/wapp_testing.h b/src/testing/wapp_testing.h new file mode 100644 index 0000000..b808f34 --- /dev/null +++ b/src/testing/wapp_testing.h @@ -0,0 +1,9 @@ +#ifndef WAPP_TESTING_H +#define WAPP_TESTING_H + +#include "tester.h" +#include "wapp_common.h" +#include "wapp_core.h" +#include "wapp_os.h" + +#endif // !WAPP_TESTING_H diff --git a/src/wapp.c b/src/wapp.c new file mode 100644 index 0000000..a037923 --- /dev/null +++ b/src/wapp.c @@ -0,0 +1,8 @@ +#ifndef WAPP_C +#define WAPP_C + +#include "wapp_core.c" +#include "wapp_os.c" +#include "wapp_testing.c" + +#endif // !WAPP_C diff --git a/src/wapp.h b/src/wapp.h new file mode 100644 index 0000000..75d761c --- /dev/null +++ b/src/wapp.h @@ -0,0 +1,9 @@ +#ifndef WAPP_H +#define WAPP_H + +#include "wapp_common.h" +#include "wapp_core.h" +#include "wapp_os.h" +#include "wapp_testing.h" + +#endif // !WAPP_H -- 2.39.5 From 716c8238a7cb33aa18878181ee75d5f05bab207d Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 23 Feb 2025 15:05:56 +0000 Subject: [PATCH 2/5] Reformat --- tests/wapptest.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/wapptest.c b/tests/wapptest.c index 30c6b0a..631fe02 100644 --- a/tests/wapptest.c +++ b/tests/wapptest.c @@ -7,8 +7,6 @@ #include "tester.h" #include - - int main(void) { wapp_tester_run_tests(test_arena_allocator, test_arena_init, -- 2.39.5 From df65850678a792148de48b724947af35f4978809 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 23 Feb 2025 15:06:12 +0000 Subject: [PATCH 3/5] 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 "{} ")" -- 2.39.5 From b994ebbf494e5f1c21be3570f56f42f02f5acdf8 Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 23 Feb 2025 15:06:35 +0000 Subject: [PATCH 4/5] Switch Windows build to use the single translation unit build --- build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.ps1 b/build.ps1 index 51c7632..13f16ce 100644 --- a/build.ps1 +++ b/build.ps1 @@ -8,7 +8,7 @@ $GeneralFlags = "/Wall /WX /wd4996" $LibraryFlags = "/LD" $IncludeDirs = Get-ChildItem -Path src -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')} -$SrcFiles = Get-ChildItem -Path src -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')} +$SrcFiles = "src/wapp.c" $TestIncludeDirs = Get-ChildItem -Path tests -Recurse -Directory -ErrorAction SilentlyContinue -Force | %{$("/I " + '"' + $_.FullName + '"')} $TestSrcFiles = Get-ChildItem -Path tests -Recurse -Filter *.c -ErrorAction SilentlyContinue -Force | %{$('"' + $_.FullName + '"')} -- 2.39.5 From c8145e82f704e8504892d5d0849e0717b0781f4a Mon Sep 17 00:00:00 2001 From: Abdelrahman Date: Sun, 23 Feb 2025 15:17:49 +0000 Subject: [PATCH 5/5] Add missing include --- src/wapp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wapp.c b/src/wapp.c index a037923..8b06b75 100644 --- a/src/wapp.c +++ b/src/wapp.c @@ -1,6 +1,7 @@ #ifndef WAPP_C #define WAPP_C +#include "wapp.h" #include "wapp_core.c" #include "wapp_os.c" #include "wapp_testing.c" -- 2.39.5