Add fresh CMake/platform scaffolding, core engine, and SDL3 window

Platform folders, cmake target/option/platform detection, Linux and PSP
scripts and Docker setup, assert/util/thread/error/log/perf/time/console/
engine/display modules, and an SDL3 window cleared to red.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
YourWishesandClaude Sonnet 5.5 committed 2026-11-07 17:02:14 -06:00
1 parent 3710924503
commit 65c4a9c051
107 files changed
+4773 -127

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Determines DUSK_TARGET_SYSTEM when it was not explicitly provided with
# -DDUSK_TARGET_SYSTEM=<target>. Must be included after project() so that the
# compiler and CMAKE_SYSTEM_NAME are known.
#
# Console toolchains all cross compile as "Generic", so they are recognised by
# the compiler they configure.
if(DUSK_TARGET_SYSTEM)
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (explicit)")
return()
endif()
if(CMAKE_C_COMPILER MATCHES "psp-")
set(DUSK_DETECTED_SYSTEM "psp")
elseif(CMAKE_C_COMPILER MATCHES "arm-vita-eabi")
set(DUSK_DETECTED_SYSTEM "vita")
elseif(CMAKE_C_COMPILER MATCHES "powerpc-eabi")
set(DUSK_DETECTED_SYSTEM "dolphin")
elseif(CMAKE_C_COMPILER MATCHES "ps2")
set(DUSK_DETECTED_SYSTEM "ps2")
elseif(CMAKE_C_COMPILER MATCHES "sh-elf")
set(DUSK_DETECTED_SYSTEM "dreamcast")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(DUSK_DETECTED_SYSTEM "windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(DUSK_DETECTED_SYSTEM "linux")
else()
message(FATAL_ERROR
"Could not determine the target platform (system: ${CMAKE_SYSTEM_NAME}, "
"compiler: ${CMAKE_C_COMPILER}). Pass -DDUSK_TARGET_SYSTEM=<target>."
)
endif()
set(DUSK_TARGET_SYSTEM "${DUSK_DETECTED_SYSTEM}" CACHE STRING
"Target platform" FORCE
)
set_property(CACHE DUSK_TARGET_SYSTEM PROPERTY STRINGS
linux windows psp dolphin vita ps2 dreamcast
)
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (detected)")
+27
View File
@@ -0,0 +1,27 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the dolphin target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS duskdolphin)
# Default values for the shared options declared in the root CMakeLists.txt.
# Assertions are faked (compiled out) unless this is a Debug build.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
else()
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
endif()
set(DUSK_DEFAULT_BACKTRACE OFF)
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
DUSK_PLATFORM_ENDIAN_BIG
DUSK_DOLPHIN
DUSK_THREAD_PTHREAD
)
+26
View File
@@ -0,0 +1,26 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the dreamcast target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS duskdreamcast)
# Default values for the shared options declared in the root CMakeLists.txt.
# Assertions are faked (compiled out) unless this is a Debug build.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
else()
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
endif()
set(DUSK_DEFAULT_BACKTRACE OFF)
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
DUSK_PLATFORM_ENDIAN_LITTLE
DUSK_DREAMCAST
)
+32
View File
@@ -0,0 +1,32 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the linux target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS dusklinux dusksdl3 duskvulkan)
# Default values for the shared options declared in the root CMakeLists.txt.
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
set(DUSK_DEFAULT_BACKTRACE ON)
set(DUSK_DEFAULT_TRACK_MEMORY ON)
# Linux runs on both endiannesses, so detect it from the target compiler.
include(TestBigEndian)
test_big_endian(DUSK_IS_BIG_ENDIAN)
if(DUSK_IS_BIG_ENDIAN)
set(DUSK_ENDIAN_DEFINITION DUSK_PLATFORM_ENDIAN_BIG)
else()
set(DUSK_ENDIAN_DEFINITION DUSK_PLATFORM_ENDIAN_LITTLE)
endif()
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
${DUSK_ENDIAN_DEFINITION}
DUSK_LINUX
DUSK_THREAD_PTHREAD
DUSK_TIME_DYNAMIC
)
+40
View File
@@ -0,0 +1,40 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# All user facing CMake options and their defaults. Included by the root
# CMakeLists.txt after the platform's target.cmake, which supplies the
# DUSK_DEFAULT_* values used below. DUSK_TARGET_SYSTEM itself is declared by
# determineplatform.cmake.
# General
option(DUSK_BUILD_TESTS "Enable tests." OFF)
option(DUSK_NETWORK "Enable network support." ON)
# Game metadata
set(DUSK_GAME_NAME "Dusk" CACHE STRING "Game display name.")
set(DUSK_GAME_AUTHOR "YourWishes" CACHE STRING "Game author / coder.")
if(NOT DEFINED DUSK_VERSION)
string(TIMESTAMP DUSK_VERSION "debug-%y%m%d%H%M%S")
endif()
# Platform dependent defaults
option(DUSK_ASSERTIONS_FAKED
"Compile assertions out (they do nothing)."
${DUSK_DEFAULT_ASSERTIONS_FAKED}
)
option(DUSK_BACKTRACE
"Log a stack trace on assertion failure."
${DUSK_DEFAULT_BACKTRACE}
)
option(DUSK_TRACK_MEMORY
"Track memoryAllocate() call sites to help find memory leaks."
${DUSK_DEFAULT_TRACK_MEMORY}
)
# Tests mock assertions, so they can never be faked.
if(DUSK_BUILD_TESTS AND DUSK_ASSERTIONS_FAKED)
message(STATUS "DUSK_BUILD_TESTS: forcing DUSK_ASSERTIONS_FAKED off")
set(DUSK_ASSERTIONS_FAKED OFF CACHE BOOL "" FORCE)
endif()
+26
View File
@@ -0,0 +1,26 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the ps2 target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS duskps2)
# Default values for the shared options declared in the root CMakeLists.txt.
# Assertions are faked (compiled out) unless this is a Debug build.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
else()
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
endif()
set(DUSK_DEFAULT_BACKTRACE OFF)
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
DUSK_PLATFORM_ENDIAN_LITTLE
DUSK_PS2
)
+27
View File
@@ -0,0 +1,27 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the psp target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS duskpsp)
# Default values for the shared options declared in the root CMakeLists.txt.
# Assertions are faked (compiled out) unless this is a Debug build.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
else()
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
endif()
set(DUSK_DEFAULT_BACKTRACE OFF)
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
DUSK_PLATFORM_ENDIAN_LITTLE
DUSK_PSP
DUSK_THREAD_PTHREAD
)
+27
View File
@@ -0,0 +1,27 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the vita target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS duskvita)
# Default values for the shared options declared in the root CMakeLists.txt.
# Assertions are faked (compiled out) unless this is a Debug build.
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
else()
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
endif()
set(DUSK_DEFAULT_BACKTRACE OFF)
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
DUSK_PLATFORM_ENDIAN_LITTLE
DUSK_VITA
DUSK_THREAD_PTHREAD
)
+21
View File
@@ -0,0 +1,21 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Platform setup for the windows target, included by the root CMakeLists.txt.
# Only sets defaults and definitions; the root applies them.
# Source directories to build for this platform.
set(DUSK_PLATFORM_DIRS duskwindows dusksdl3 duskvulkan)
# Default values for the shared options declared in the root CMakeLists.txt.
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
set(DUSK_DEFAULT_BACKTRACE OFF)
set(DUSK_DEFAULT_TRACK_MEMORY ON)
# Platform definitions.
set(DUSK_PLATFORM_DEFINITIONS
DUSK_PLATFORM_ENDIAN_LITTLE
DUSK_WINDOWS
)