Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,70 @@ jobs:
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel

# === Ubuntu-arm64 GLES2 ===
linux-arm64-gles2:
runs-on: ubuntu-22.04-arm

steps:
- uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0

- name: Install Toolchain and Dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ xz-utils wget python3 rake pkg-config binutils libsdl2-dev libgles2-mesa-dev libegl1-mesa-dev

- name: Generate Stubs
run: |
for lib in /usr/lib/aarch64-linux-gnu/libSDL2-2.0.so.0 /usr/lib/aarch64-linux-gnu/libGLESv2.so.2 /usr/lib/aarch64-linux-gnu/libEGL.so.1; do \
outname=$(basename $lib | sed 's/-2.0//; s/\.so\..*/.so/') && \
echo "Generating stubs for $outname from $lib" && \
nm -D $lib | grep " T " | awk '{print "void " $3 "(){}"}' > stubs.c && \
sudo rm -f /usr/lib/aarch64-linux-gnu/$outname && \
sudo gcc -shared -Wl,-soname,$outname -o /usr/lib/aarch64-linux-gnu/$outname stubs.c; \
done

- name: Build
run: |
cd build/linux
cmake ../.. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_PRO=OFF \
-DBUILD_WITH_ALL=ON \
-DCMAKE_C_FLAGS_RELEASE="-Ofast -flto" \
-DCMAKE_CXX_FLAGS_RELEASE="-Ofast -flto" \
-DBUILD_SDL=ON \
-DBUILD_SDLGPU=ON \
-DUSE_GLES2=ON \
-DUSE_EGL=ON \
-DBUILD_EDITORS=OFF \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-DBUILD_EDITORS=OFF, I think this is a bit of an assumption here. Just because they're on arm64 linux doesn't mean the user only intends to play the games.

I'm doing edits on my armhf board.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it's a bit opinionated. I'm sending new PRs to enable a easier integration with gamepads without requiring to disable the editor tools. I also wonder how much BUILD_EDITORS affects performance, EMUUROM is the one that has a bit of slow down in some sections. I will test the difference sometime later.

Ideally we could make many builds, but then it takes forever the Github CI, maybe if we enable caching the compilation of the vendor src would help quite a bit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my suggestion on the other PR, this sounds like something better suited for a configuration file, rather than a parallel build.

If this shipped with the editor, desktop linux arm64 users would be able to grab a prebuilt binary, and if it were a config, that would also make for a great feature for those handhelds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After @nesbox approves #2952, I can then change this to BUILD_EDITORS=ON

-DBUILD_SURF=ON \
-DPREFER_SYSTEM_SDL2=ON \
-DBUILD_STATIC=ON \
-DTIC_DATA_PATH="/userdata/roms/tic80/"
cmake --build . --target tic80 --config Release --parallel

- name: Pack
run: |
mkdir -p build/linux/share/applications
mkdir -p build/linux/share/mime/packages
mkdir -p build/linux/share/icons
cp build/linux/tic80.desktop build/linux/share/applications/
cp build/linux/tic80.xml build/linux/share/mime/packages/
cp build/linux/tic80.png build/linux/share/icons/

- name: Deploy
uses: actions/upload-artifact@v6
with:
name: "tic80-linux-arm64-gles2"
path: |
build/linux/bin/tic80
build/linux/bin/*.so
build/linux/lib/*.so
build/linux/share/*

# === Ubuntu gcc14 ===
linux-gcc14-glibc239:
runs-on: ubuntu-24.04
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ endif()

if(NINTENDO_SWITCH AND NOT LIBRETRO_STATIC)
set(PREFER_SYSTEM_LIBRARIES ON)
if(NOT TIC_DATA_PATH)
set(TIC_DATA_PATH "/switch/tic80")
endif()
endif()

add_library(runtime INTERFACE)

if(TIC_DATA_PATH)
target_compile_definitions(runtime INTERFACE TIC_DATA_PATH="${TIC_DATA_PATH}")
endif()

if(BUILD_STATIC)
set(TIC_RUNTIME STATIC)
target_compile_definitions(runtime INTERFACE TIC_RUNTIME_STATIC)
Expand Down Expand Up @@ -105,6 +112,10 @@ if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID)
endif()
endif()

option(PREFER_SYSTEM_SDL2 "Prefer system SDL2" ${PREFER_SYSTEM_LIBRARIES})
option(USE_GLES2 "Use GLES2" OFF)
option(USE_EGL "Use EGL" OFF)

if (BUILD_NO_OPTIMIZATION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
Expand Down
2 changes: 1 addition & 1 deletion cmake/core.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if(BUILD_STATIC)
target_link_libraries(tic80core PRIVATE wasm)
endif()

target_link_libraries(tic80core PRIVATE runtime)
target_link_libraries(tic80core PUBLIC runtime)

endif()

Expand Down
45 changes: 35 additions & 10 deletions cmake/sdl.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################################
# SDL2
################################
if(PREFER_SYSTEM_LIBRARIES)
if(PREFER_SYSTEM_SDL2)
find_package(SDL2)
if(SDL2_FOUND)
if(NINTENDO_SWITCH)
Expand All @@ -18,7 +18,7 @@ if(PREFER_SYSTEM_LIBRARIES)
endif()


if(BUILD_SDL AND NOT EMSCRIPTEN AND NOT RPI AND NOT PREFER_SYSTEM_LIBRARIES)
if(BUILD_SDL AND NOT EMSCRIPTEN AND NOT RPI AND NOT PREFER_SYSTEM_SDL2)

if(WIN32)
set(HAVE_LIBC TRUE)
Expand Down Expand Up @@ -69,9 +69,12 @@ if(BUILD_SDL AND BUILD_PLAYER AND NOT RPI)
target_link_options(player-sdl PRIVATE -static)
endif()

target_link_libraries(player-sdl PRIVATE tic80core SDL2main)
target_link_libraries(player-sdl PRIVATE tic80core)
if(NOT PREFER_SYSTEM_SDL2)
target_link_libraries(player-sdl PRIVATE SDL2main)
endif()

if(BUILD_STATIC)
if(BUILD_STATIC AND NOT USE_GLES2)
target_link_libraries(player-sdl PRIVATE SDL2-static)
else()
target_link_libraries(player-sdl PRIVATE SDL2)
Expand All @@ -94,7 +97,7 @@ set(SDLGPU_SRC
${SDLGPU_DIR}/externals/stb_image_write/stb_image_write.c
)

if(NOT ANDROID AND NOT NINTENDO_SWITCH)
if(NOT ANDROID AND NOT NINTENDO_SWITCH AND NOT USE_GLES2)
list(APPEND SDLGPU_SRC
${SDLGPU_DIR}/renderer_GLES_1.c
${SDLGPU_DIR}/renderer_GLES_3.c
Expand All @@ -110,24 +113,39 @@ endif()

add_library(sdlgpu STATIC ${SDLGPU_SRC})

if(EMSCRIPTEN OR ANDROID OR NINTENDO_SWITCH)
if(EMSCRIPTEN OR ANDROID OR NINTENDO_SWITCH OR USE_GLES2)
target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES_1 SDL_GPU_DISABLE_GLES_3 SDL_GPU_DISABLE_OPENGL)
else()
target_compile_definitions(sdlgpu PRIVATE GLEW_STATIC SDL_GPU_DISABLE_GLES SDL_GPU_DISABLE_OPENGL_3 SDL_GPU_DISABLE_OPENGL_4)
endif()

target_include_directories(sdlgpu PUBLIC ${THIRDPARTY_DIR}/sdl-gpu/include)
target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl2/include)
target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/glew)
target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/glew/GL)
target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/stb_image)
target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl-gpu/src/externals/stb_image_write)

if(USE_GLES2 OR USE_EGL)
target_include_directories(sdlgpu PRIVATE ${THIRDPARTY_DIR}/sdl2/src/video/khronos)
endif()

if(WIN32)
target_link_libraries(sdlgpu opengl32)
endif()

if(LINUX)
target_link_libraries(sdlgpu GL)
if(USE_GLES2)
target_link_libraries(sdlgpu GLESv2)
endif()

if(USE_EGL)
target_link_libraries(sdlgpu EGL)
endif()

if(NOT USE_GLES2 AND NOT USE_EGL)
target_link_libraries(sdlgpu GL)
endif()
endif()

if(APPLE)
Expand All @@ -153,7 +171,9 @@ if(NINTENDO_SWITCH)
endif()

if(NOT EMSCRIPTEN)
if(BUILD_STATIC)
if(PREFER_SYSTEM_SDL2)
target_link_libraries(sdlgpu SDL2)
elseif(BUILD_STATIC AND NOT USE_GLES2)
target_link_libraries(sdlgpu SDL2-static)
else()
target_link_libraries(sdlgpu SDL2)
Expand Down Expand Up @@ -187,6 +207,8 @@ if(BUILD_SDL)
add_executable(${TIC80_TARGET} ${TIC80_SRC})
endif()

target_include_directories(${TIC80_TARGET} PRIVATE ${THIRDPARTY_DIR}/sdl2/include)

if(MINGW)
target_link_libraries(${TIC80_TARGET} mingw32)
target_link_options(${TIC80_TARGET} PRIVATE -static -mconsole)
Expand All @@ -200,7 +222,7 @@ if(BUILD_SDL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ASSERTIONS=1")
endif()

elseif(NOT ANDROID)
elseif(NOT ANDROID AND NOT PREFER_SYSTEM_SDL2)
target_link_libraries(${TIC80_TARGET} SDL2main)
endif()

Expand All @@ -223,12 +245,15 @@ if(BUILD_SDL)

if(BUILD_SDLGPU)
target_link_libraries(${TIC80_TARGET} sdlgpu)
if(LINUX)
target_link_libraries(${TIC80_TARGET} pthread dl m)
endif()
else()
if(EMSCRIPTEN)
elseif(RPI)
target_link_libraries(${TIC80_TARGET} libSDL2.a bcm_host pthread)
else()
if(BUILD_STATIC)
if(BUILD_STATIC AND NOT USE_GLES2)
target_link_libraries(${TIC80_TARGET} SDL2-static)
else()
target_link_libraries(${TIC80_TARGET} SDL2)
Expand Down
14 changes: 7 additions & 7 deletions src/system/sdl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern void gotoMenu(Studio* studio);
#include <windows.h>
#endif

#if defined(__TIC_ANDROID__) || defined(__SWITCH__)
#if defined(__TIC_ANDROID__) || defined(__SWITCH__) || defined(TIC_DATA_PATH)
#include <sys/stat.h>
#endif

Expand Down Expand Up @@ -1395,7 +1395,12 @@ static const char* getAppFolder()
{
static char appFolder[TICNAME_MAX];

#if defined(__EMSCRIPTEN__)
#if defined(TIC_DATA_PATH)

strcpy(appFolder, TIC_DATA_PATH);
mkdir(appFolder, 0777);

#elif defined(__EMSCRIPTEN__)

strcpy(appFolder, "/" TIC_PACKAGE "/" TIC_NAME "/");

Expand All @@ -1406,11 +1411,6 @@ static const char* getAppFolder()
strcat(appFolder, AppFolder);
mkdir(appFolder, 0777);

#elif defined(__SWITCH__)

strcpy(appFolder, "/switch/tic80");
mkdir(appFolder, 0777);

#else

char* path = SDL_GetPrefPath(TIC_PACKAGE, TIC_NAME);
Expand Down