2.3 KiB
Porting Dethrace to other systems
Operating Systems
Assuming an operating system called foo, follow the steps to add support for it.
- Add a new file
os/foo.h
and implement the required functions defined in os.h:
OS_InstallSignalHandler
OS_fopen
OS_ConsoleReadPassword
- Update
src/harness/CMakeLists.h
and add a new conditional section for "os/foo.h", based on existing conditions for Windows, MacOS etc.
For example:
...
elseif( _FOO_ )
target_sources(harness PRIVATE
os/foo.c
)
...
Platform (windowing / input)
A Platform
in dethrace implements windowing and input handling.
The default platform is SDL2
, which uses SDL2 for windowing and input. See platforms/sdl_opengl.c.
To add a new Platform
:
-
Create a
src/harness/my_platform.c
file where you'll implement your platform-specific callbacks. Define a public fully-initializedconst tPlatform_bootstrap MYPLATFORM_bootstrap
variable in this file. -
Add the the following code fragments to appropriate locations in
src/harness/harness.c
:extern const tPlatform_bootstrap MYPLATFORM_bootstrap;
#ifdef DETHRACE_PLATFORM_MYPLATFORM &MYPLATFORM_bootstrap, #endif
-
Add new conditionals to
CMakeLists.txt
andsrc/harness/CMakeLists.txt
for your new platformFor example:
# CMakeLists.txt option(DETHRACE_PLATFORM_MYPLATFORM "Enable my platform" OFF) if(DETHRACE_PLATFORM_MYPLATFORM) find_package(MyPlatform REQUIRED) endif()
# src/harness/CMakeLists.txt if(DETHRACE_PLATFORM_MYPLATFORM) target_sources(harness PRIVATE my_platform.c ) target_compile_definitions(harness PRIVATE DETHRACE_PLATFORM_MYPLATFORM) target_link_libraries(harness PRIVATE MyPlatform::MyPlatform) endif()
-
Hook up all the function pointers using the sdl2 platform as a guide.
-
Run cmake to update your build with the new platform
cd build cmake -DDETHRACE_PLATFORM_MYPLATFORM=ON .. cmake --build .
-
Build
-cmake --build .