From ff094b50f2cb24830f1be5c7eb882a9d55233226 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 18:46:43 +0000 Subject: [PATCH 1/8] First attempt to use new CI runner. (#55) Reviewed-on: https://git.telodendria.io/Telodendria/Cytoplasm/pulls/55 Co-authored-by: Jordan Bancino Co-committed-by: Jordan Bancino --- .forgejo/workflows/compile.yaml | 18 ++++++++++++++++++ .gitea/workflows/compile.yaml | 25 ------------------------- 2 files changed, 18 insertions(+), 25 deletions(-) create mode 100644 .forgejo/workflows/compile.yaml delete mode 100644 .gitea/workflows/compile.yaml diff --git a/.forgejo/workflows/compile.yaml b/.forgejo/workflows/compile.yaml new file mode 100644 index 0000000..3c3cef3 --- /dev/null +++ b/.forgejo/workflows/compile.yaml @@ -0,0 +1,18 @@ +name: Compile Cytoplasm +run-name: Compile Cytoplasm on ${{ forgejo.actor }} +on: [push] + +jobs: + "Compile Cytoplasm": + strategy: + matrix: + os: [alpine] + arch: [aarch64] + runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] + steps: + - name: Check out repository + uses: actions/checkout@v3 + - name: Configure Cytoplasm + run: ./configure + - name: Build Cytoplasm + run: make diff --git a/.gitea/workflows/compile.yaml b/.gitea/workflows/compile.yaml deleted file mode 100644 index 1185758..0000000 --- a/.gitea/workflows/compile.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Compile Cytoplasm -run-name: Compile Cytoplasm on ${{ gitea.actor }} -on: [push] - -jobs: - "Compile Cytoplasm": - strategy: - matrix: - os: [debian-v12.4, alpine-v3.19, openbsd-v7.4, freebsd-v14.0, netbsd-v9.3] - arch: [x86, x86_64] - exclude: - # 32-bit OpenBSD does not behave well in QEMU. Even when using - # QEMU to emulate i386, it utilizes 100% of its CPU core and is - # still extremely sluggish. Thus, we don't have a working 32-bit - # OpenBSD runner, so exclude it from the matrix configuration. - - os: openbsd-v7.4 - arch: x86 - runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] - steps: - - name: Check out repository - uses: actions/checkout@v3 - - name: Configure Cytoplasm - run: ./configure - - name: Build Cytoplasm - run: make From 4a21567bc5d471b3849807486a6276560377ae54 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 14:52:41 -0400 Subject: [PATCH 2/8] 2nd CI attempt --- .forgejo/workflows/compile.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/compile.yaml b/.forgejo/workflows/compile.yaml index 3c3cef3..f1fbf1a 100644 --- a/.forgejo/workflows/compile.yaml +++ b/.forgejo/workflows/compile.yaml @@ -10,8 +10,8 @@ jobs: arch: [aarch64] runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] steps: - - name: Check out repository - uses: actions/checkout@v3 + #- name: Check out repository + # uses: actions/checkout@v3 - name: Configure Cytoplasm run: ./configure - name: Build Cytoplasm From 10c8784f25cde638e0795fb8fd71cf916a94b5d3 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 14:59:13 -0400 Subject: [PATCH 3/8] . --- .forgejo/workflows/compile.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/compile.yaml b/.forgejo/workflows/compile.yaml index f1fbf1a..f762bdf 100644 --- a/.forgejo/workflows/compile.yaml +++ b/.forgejo/workflows/compile.yaml @@ -10,8 +10,8 @@ jobs: arch: [aarch64] runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] steps: - #- name: Check out repository - # uses: actions/checkout@v3 + - name: Check out repository + uses: actions/checkout@v4 - name: Configure Cytoplasm run: ./configure - name: Build Cytoplasm From af4a14226116719eb504f0213fa549bf1e967194 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 15:00:08 -0400 Subject: [PATCH 4/8] Whoops, typo --- .forgejo/workflows/compile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/compile.yaml b/.forgejo/workflows/compile.yaml index f762bdf..72f7f50 100644 --- a/.forgejo/workflows/compile.yaml +++ b/.forgejo/workflows/compile.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ["${{ matrix.os }}", "${{ matrix.arch }}"] steps: - name: Check out repository - uses: actions/checkout@v4 + uses: actions/checkout@v4 - name: Configure Cytoplasm run: ./configure - name: Build Cytoplasm From f7c51ee019c0cffdc200a4fd4f82ce7cd6e89d61 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 15:47:01 -0400 Subject: [PATCH 5/8] Basic work toward compiling on Darwin --- configure | 2 +- include/Cytoplasm/Platform.h | 66 ++++++++++++++++++++++++++++++++++++ src/Util.c | 9 +++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 include/Cytoplasm/Platform.h diff --git a/configure b/configure index deb186e..a1331ef 100755 --- a/configure +++ b/configure @@ -37,7 +37,7 @@ case "$(uname)" in # These systems typically use GCC. SCRIPT_ARGS="${SCRIPT_ARGS} --cc=gcc" ;; - OpenBSD|FreeBSD) + OpenBSD|FreeBSD|Darwin) # These systems typically use Clang. SCRIPT_ARGS="${SCRIPT_ARGS} --cc=clang" ;; diff --git a/include/Cytoplasm/Platform.h b/include/Cytoplasm/Platform.h new file mode 100644 index 0000000..a15da6f --- /dev/null +++ b/include/Cytoplasm/Platform.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2022-2024 Jordan Bancino <@jordan:bancino.net> + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef CYTOPLASM_PLATFORM_H +#define CYTOPLASM_PLATFORM_H + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) + #define PLATFORM_WINDOWS + + #ifdef _WIN64 + #define PLATFORM_WIN64 + #else + #define PLATFORM_WIN32 + #endif +#elif __APPLE__ + #define PLATFORM_DARWIN + + #include + #if TARGET_IPHONE_SIMULATOR + // iOS, tvOS, or watchOS Simulator + #define PLATFORM_IPHONE + #elif TARGET_OS_MACCATALYST + // Mac's Catalyst (ports iOS API into Mac, like UIKit). + #define PLATFORM_CATALYST + #elif TARGET_OS_IPHONE + // iOS, tvOS, or watchOS device + #define PLATFORM_IPHONE + #elif TARGET_OS_MAC + // Other kinds of Apple platforms + #define PLATFORM_MAC + #else + # error "Unknown Apple platform" + #endif +#elif __ANDROID__ + #define PLATFORM_ANDROID +#elif __linux__ + #define PLATFORM_LINUX +#elif __unix__ // all unices not caught above + #define PLATFORM_UNIX +#elif defined(_POSIX_VERSION) + #define PLATFORM_POSIX +#else +# error "Unknown compiler" +#endif + +#endif // CYTOPLASM_PLATFORM_H diff --git a/src/Util.c b/src/Util.c index 962ff0b..e01ae4f 100644 --- a/src/Util.c +++ b/src/Util.c @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -89,6 +90,10 @@ UtilTsMillis(void) return ts; } +#ifdef PLATFORM_DARWIN +#define st_mtim st_mtimespec +#endif + uint64_t UtilLastModified(char *path) { @@ -105,6 +110,10 @@ UtilLastModified(char *path) return ts; } +#ifdef PLATFORM_DARWIN +#undef st_mtim +#endif + int UtilMkdir(const char *dir, const mode_t mode) { From 63bd8791019cfaf7b782c4600464d8cd9240351c Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 16:23:06 -0400 Subject: [PATCH 6/8] Run CI on pull requests. --- .forgejo/workflows/compile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/compile.yaml b/.forgejo/workflows/compile.yaml index 72f7f50..fc35606 100644 --- a/.forgejo/workflows/compile.yaml +++ b/.forgejo/workflows/compile.yaml @@ -1,6 +1,6 @@ name: Compile Cytoplasm run-name: Compile Cytoplasm on ${{ forgejo.actor }} -on: [push] +on: [push, pull_request] jobs: "Compile Cytoplasm": From 6827d4fc39f5527b8836f6fe7dff35b1b97cb571 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 16:26:46 -0400 Subject: [PATCH 7/8] Documentation is enforced. --- include/Cytoplasm/Platform.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/Cytoplasm/Platform.h b/include/Cytoplasm/Platform.h index a15da6f..e490af4 100644 --- a/include/Cytoplasm/Platform.h +++ b/include/Cytoplasm/Platform.h @@ -24,6 +24,13 @@ #ifndef CYTOPLASM_PLATFORM_H #define CYTOPLASM_PLATFORM_H +/*** + * @Nm Platform + * @Nd A simple macro header that determines what platform the application + * is being built for. + * @Dd September 21, 2024 + */ + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) #define PLATFORM_WINDOWS From 4f316ff7b3a955b831ca4aefb8679ddf3396a7d0 Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Sat, 21 Sep 2024 16:31:31 -0400 Subject: [PATCH 8/8] Documentation generator doesn't support C99 comments. --- include/Cytoplasm/Platform.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/Cytoplasm/Platform.h b/include/Cytoplasm/Platform.h index e490af4..c18e7d7 100644 --- a/include/Cytoplasm/Platform.h +++ b/include/Cytoplasm/Platform.h @@ -44,16 +44,12 @@ #include #if TARGET_IPHONE_SIMULATOR - // iOS, tvOS, or watchOS Simulator #define PLATFORM_IPHONE #elif TARGET_OS_MACCATALYST - // Mac's Catalyst (ports iOS API into Mac, like UIKit). #define PLATFORM_CATALYST #elif TARGET_OS_IPHONE - // iOS, tvOS, or watchOS device #define PLATFORM_IPHONE #elif TARGET_OS_MAC - // Other kinds of Apple platforms #define PLATFORM_MAC #else # error "Unknown Apple platform" @@ -62,7 +58,7 @@ #define PLATFORM_ANDROID #elif __linux__ #define PLATFORM_LINUX -#elif __unix__ // all unices not caught above +#elif __unix__ #define PLATFORM_UNIX #elif defined(_POSIX_VERSION) #define PLATFORM_POSIX @@ -70,4 +66,4 @@ # error "Unknown compiler" #endif -#endif // CYTOPLASM_PLATFORM_H +#endif /* CYTOPLASM_PLATFORM_H */