Skip to content

Commit

Permalink
Initial macOS support
Browse files Browse the repository at this point in the history
Compiles successfully, but no idea if it runs as I can't test OpenGL in a VM.
  • Loading branch information
rollerozxa committed May 5, 2024
1 parent c57b38d commit fcbbfc2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Expand Up @@ -53,6 +53,8 @@ elseif(SCREENSHOT_BUILD)
set(TMS_BACKEND "screenshot-linux")
elseif(HAIKU)
set(TMS_BACKEND "haiku")
elseif(APPLE)
set(TMS_BACKEND "macos")
else()
set(TMS_BACKEND "linux")
endif()
Expand Down Expand Up @@ -271,6 +273,8 @@ else()
set(COMMON_FLAGS "${COMMON_FLAGS} -DGL_GLEXT_PROTOTYPES -DNO_UI -DTMS_BACKEND_LINUX_SS")
elseif(HAIKU)
set(COMMON_FLAGS "${COMMON_FLAGS} -DTMS_BACKEND_HAIKU")
elseif(APPLE)
set(COMMON_FLAGS "${COMMON_FLAGS} -DTMS_BACKEND_MACOS")
else()
set(COMMON_FLAGS "${COMMON_FLAGS} -DTMS_BACKEND_LINUX")
endif()
Expand All @@ -292,9 +296,12 @@ set(CMAKE_CXX_FLAGS_RELEASE "${COMMON_FLAGS_RELEASE} -O2 -fvisibility-inlines-hi
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
set(CMAKE_CXX_FLAGS_DEBUG "${COMMON_FLAGS_DEBUG}")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O,-s,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-Wl,-O,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
# macOS Clang's linker doesn't like these flags
if(NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O,-s,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "-Wl,-O,--gc-sections")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
endif()

if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-mwindows")
Expand Down
2 changes: 2 additions & 0 deletions src/tms/backends/macos/main.cc
@@ -0,0 +1,2 @@
// Inherit from Linux backend
#include "../linux/main.cc"
27 changes: 10 additions & 17 deletions src/tms/core/backend.h
@@ -1,22 +1,6 @@
#ifndef _BACKEND__H_
#define _BACKEND__H_

#if !defined TMS_BACKEND_LINUX \
&& !defined TMS_BACKEND_LINUX_SS \
&& !defined TMS_BACKEND_ANDROID \
&& !defined TMS_BACKEND_WINDOWS \
&& !defined TMS_BACKEND_IOS \
&& !defined TMS_BACKEND_HAIKU
#error Undefined platform, please add a TMS backend for it
#endif

#if !defined TMS_BACKEND_PC \
&& !defined TMS_BACKEND_MOBILE
#error Either TMS_BACKEND_PC or TMS_BACKEND_MOBILE need to be defined for your platform.
#endif

#include <tms/core/err.h>

#if defined(TMS_BACKEND_WINDOWS)
#define OS_STRING "Windows"
#elif defined(TMS_BACKEND_LINUX) || defined(TMS_BACKEND_LINUX_SS)
Expand All @@ -27,10 +11,19 @@
#define OS_STRING "iOS"
#elif defined(TMS_BACKEND_HAIKU)
#define OS_STRING "Haiku"
#elif defined(TMS_BACKEND_MACOS)
#define OS_STRING "macOS"
#else
#define OS_STRING "unknown"
#error Undefined platform, please add a TMS backend for it
#endif

#if !defined TMS_BACKEND_PC \
&& !defined TMS_BACKEND_MOBILE
#error Either TMS_BACKEND_PC or TMS_BACKEND_MOBILE need to be defined for your platform.
#endif

#include <tms/core/err.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/tms/core/pipeline.c
Expand Up @@ -10,7 +10,7 @@
static struct tms_pipeline pipelines[TMS_NUM_PIPELINES] = {0};
static int n_local_uniforms = 0;

#if defined(TMS_BACKEND_WINDOWS) || defined(TMS_BACKEND_LINUX) || defined(TMS_BACKEND_HAIKU)
#if defined(TMS_BACKEND_PC) || !defined(TMS_BACKEND_LINUX_SS)
// Some things in the pipeline are different for Windows/Linux as compared to Android (GL/GLES differences? dunno)
// The desktop pipeline is the "cool" pipeline as decided by me.
#define TMS_COOL_PIPELINE
Expand Down

0 comments on commit fcbbfc2

Please sign in to comment.