Skip to content

Commit

Permalink
reviving the sokol build
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed Jun 1, 2024
1 parent 43a0317 commit 3e37e88
Show file tree
Hide file tree
Showing 47 changed files with 720 additions and 7,279 deletions.
79 changes: 34 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
COPY /Y build\janet\janetconf.h vendor\janet\src\conf\janetconf.h
cd build
cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_SDL=ON ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
Expand All @@ -38,7 +38,7 @@ jobs:
run: |
COPY /Y build\janet\janetconf.h vendor\janet\src\conf\janetconf.h
cd build
cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake -G "Visual Studio 16 2019" -A Win32 -T v141_xp -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=ON -DBUILD_WITH_ALL=ON -DBUILD_SDL=ON ..
cmake --build . --config MinSizeRel --parallel
# === Windows ===
Expand All @@ -59,7 +59,7 @@ jobs:
shell: cmd
run: |
cd build
cmake -G "Visual Studio 16 2019" -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
Expand All @@ -74,7 +74,7 @@ jobs:
shell: cmd
run: |
cd build
cmake -G "Visual Studio 16 2019" -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=ON -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
# === Windows MinGW-64 ===
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
shell: bash
run: |
cd build
cmake -G "MSYS Makefiles" -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_WITH_JANET=OFF ..
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_WITH_JANET=OFF ..
cmake --build . --config MinSizeRel --parallel
# === Ubuntu ===
Expand All @@ -128,12 +128,12 @@ jobs:
- name: Install
run: |
sudo apt-get update
sudo apt-get install libglu1-mesa-dev libasound2-dev libpulse-dev libaudio-dev libsamplerate0-dev libcurl4-openssl-dev -y
sudo apt-get install libxi-dev libxcursor-dev libglu1-mesa-dev libasound2-dev libpulse-dev libaudio-dev libsamplerate0-dev libcurl4-openssl-dev -y
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_SDL=ON ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
Expand All @@ -147,7 +147,7 @@ jobs:
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=ON -DBUILD_WITH_ALL=ON -DBUILD_SDL=ON ..
cmake --build . --config MinSizeRel --parallel
# === Raspberry PI ===
Expand All @@ -169,7 +169,7 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=rpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=rpi/toolchain.cmake -DBUILD_WITH_ALL=ON -DBUILD_SDL=ON ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
Expand All @@ -183,7 +183,7 @@ jobs:
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=On -DCMAKE_TOOLCHAIN_FILE=rpi/toolchain.cmake ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=ON -DCMAKE_TOOLCHAIN_FILE=rpi/toolchain.cmake -DBUILD_SDL=ON ..
cmake --build . --config MinSizeRel --parallel
# === Raspberry PI 1-4 Bare Metal ===
Expand Down Expand Up @@ -222,7 +222,7 @@ jobs:
run: |
git apply build/baremetalpi/circle.patch
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON -DBUILD_STATIC=ON ..
make tic80studio -j$(nproc)
cd baremetalpi
make -j$(nproc)
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:
run: |
git apply build/baremetalpi/circle.patch
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=baremetalpi/toolchain.cmake -DBUILD_WITH_ALL=ON -DBUILD_STATIC=ON ..
make tic80studio -j$(nproc)
cd baremetalpi
make -j$(nproc)
Expand Down Expand Up @@ -328,7 +328,7 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DBUILD_STATIC=ON -DN3DS=TRUE -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
make -j$(nproc)
- name: Deploy
Expand All @@ -353,7 +353,7 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
Expand All @@ -367,7 +367,7 @@ jobs:
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=ON -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
# === MacOS 14 / arm64 ===
Expand All @@ -386,7 +386,7 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
Expand All @@ -400,7 +400,7 @@ jobs:
- name: Build Pro
run: |
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_SDLGPU=On -DBUILD_PRO=On -DBUILD_WITH_ALL=ON ..
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_PRO=ON -DBUILD_WITH_ALL=ON ..
cmake --build . --config MinSizeRel --parallel
# === Android ===
Expand All @@ -416,32 +416,21 @@ jobs:
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r21e
ndk-version: r22b
add-to-path: false
local-cache: true

- name: set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Build
run: |
cd build/android
chmod +x gradlew
./gradlew assembleRelease
cp app/build/outputs/apk/release/app-release.apk tic80.apk
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
cd build
cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_STATIC=ON -DBUILD_TOUCH_INPUT=ON -DBUILD_WITH_RUBY=OFF -DBUILD_WITH_ALL=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-28 ..
cmake --build . --config MinSizeRel --parallel
- name: Deploy
uses: actions/upload-artifact@v4
with:
name: "tic80-android"
path: build/android/tic80.apk
path: build/bin/tic80.so

# === HTML ===
html:
Expand All @@ -462,73 +451,73 @@ jobs:
- name: Build lua
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=ON -DTIC80_TARGET=tic80lua .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=ON -DTIC80_TARGET=tic80lua .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build ruby
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_RUBY=ON -DTIC80_TARGET=tic80ruby .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_RUBY=ON -DTIC80_TARGET=tic80ruby .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build js
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JS=ON -DTIC80_TARGET=tic80js .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JS=ON -DTIC80_TARGET=tic80js .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build moon
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_MOON=ON -DTIC80_TARGET=tic80moon .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_MOON=ON -DTIC80_TARGET=tic80moon .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build fennel
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_FENNEL=ON -DTIC80_TARGET=tic80fennel .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_FENNEL=ON -DTIC80_TARGET=tic80fennel .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build scheme
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SCHEME=ON -DTIC80_TARGET=tic80scheme .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SCHEME=ON -DTIC80_TARGET=tic80scheme .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build squirrel
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SQUIRREL=ON -DTIC80_TARGET=tic80squirrel .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_SQUIRREL=ON -DTIC80_TARGET=tic80squirrel .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build wren
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WREN=ON -DTIC80_TARGET=tic80wren .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WREN=ON -DTIC80_TARGET=tic80wren .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build wasm
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WASM=ON -DTIC80_TARGET=tic80wasm .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_WASM=ON -DTIC80_TARGET=tic80wasm .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build janet
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JANET=ON -DTIC80_TARGET=tic80janet .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_JANET=ON -DTIC80_TARGET=tic80janet .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build python
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_PYTHON=ON -DTIC80_TARGET=tic80python .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_LUA=OFF -DBUILD_WITH_PYTHON=ON -DTIC80_TARGET=tic80python .. --fresh
cmake --build . --config MinSizeRel --parallel
- name: Build all
run: |
cd build
emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON .. --fresh
emcmake cmake -DBUILD_STATIC=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON .. --fresh
cmake --build . --config MinSizeRel --parallel
cp html/index.html bin/index.html
Expand Down
50 changes: 20 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,48 @@ message("VERSION_HASH: ${VERSION_HASH}")

configure_file("${PROJECT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h")

if(ANDROID OR EMSCRIPTEN OR N3DS OR BAREMETALPI)
set(BUILD_STATIC_DEFAULT ON)
else()
set(BUILD_STATIC_DEFAULT OFF)
endif()

set(BUILD_PLAYER_DEFAULT OFF)
set(BUILD_LIBRETRO_DEFAULT OFF)
set(BUILD_TOUCH_INPUT_DEFAULT ${ANDROID})
set(BUILD_WITH_ALL_DEFAULT OFF)

option(BUILD_STATIC "Static runtime" ${BUILD_STATIC_DEFAULT})
option(BUILD_WITH_ALL "Build all supported scripts" ${BUILD_WITH_ALL_DEFAULT})
option(BUILD_SDL "SDL Enabled" ON)
option(BUILD_STATIC "Static runtime" OFF)
option(BUILD_WITH_ALL "Build all supported scripts" OFF)
option(BUILD_SDL "SDL Enabled" OFF)
option(BUILD_SDLGPU "SDL GPU Enabled" OFF)
option(BUILD_SOKOL "Sokol Enabled" OFF)
option(BUILD_LIBRETRO "libretro Enabled" ${BUILD_LIBRETRO_DEFAULT})
option(BUILD_LIBRETRO "libretro Enabled" OFF)
option(BUILD_TOOLS "bin2txt prj2cart" OFF)
option(BUILD_EDITORS "Build cart editors" ON)
option(BUILD_PRO "Build PRO version" FALSE)
option(BUILD_PLAYER "Build standalone players" ${BUILD_PLAYER_DEFAULT})
option(BUILD_TOUCH_INPUT "Build with touch input support" ${BUILD_TOUCH_INPUT_DEFAULT})
option(BUILD_PLAYER "Build standalone players" OFF)
option(BUILD_TOUCH_INPUT "Build with touch input support" OFF)
option(BUILD_NO_OPTIMIZATION "Build without optimizations for debugging" OFF)
option(BUILD_ASAN_DEBUG "Build with AddressSanitizer" OFF)
option(BUILD_WITH_ZLIB "Build with zlib linked" ON)
option(TIC80_TARGET "Target binary suffix")

if(WIN32 OR EMSCRIPTEN OR ANDROID OR APPLE)
if(NOT BUILD_SDL AND NOT BUILD_SOKOL)
set(BUILD_SOKOL ON)
endif()
endif()

if(NOT TIC80_TARGET)
set(TIC80_TARGET tic80)
endif()

if (BUILD_NO_OPTIMIZATION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
else()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(LINKER_FLAGS_MINSIZEREL "-Wl,-dead_strip")
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} ${LINKER_FLAGS_MINSIZEREL}")
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} ${LINKER_FLAGS_MINSIZEREL}")
endif()
endif()

if (BUILD_ASAN_DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()

if(NOT BUILD_SDL)
set(BUILD_SDLGPU OFF)
endif()

add_library(runtime INTERFACE)

if(BUILD_STATIC)
Expand All @@ -71,18 +68,12 @@ endif()
target_compile_definitions(runtime INTERFACE BUILD_DEPRECATED)

message("BUILD_STATIC: ${BUILD_STATIC}")
message("BUILD_SOKOL: ${BUILD_SOKOL}")
message("BUILD_SDL: ${BUILD_SDL}")
message("BUILD_SDLGPU: ${BUILD_SDLGPU}")
message("BUILD_TOUCH_INPUT: ${BUILD_TOUCH_INPUT}")
message("BUILD_WITH_ALL: ${BUILD_WITH_ALL}")

if (N3DS)
set(BUILD_SDL OFF)
endif()

if (BAREMETALPI)
set(BUILD_SDL OFF)
endif()

if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT N3DS)
set(LINUX TRUE)

Expand Down Expand Up @@ -130,7 +121,6 @@ if(RPI)
endif()

set(THIRDPARTY_DIR ${CMAKE_SOURCE_DIR}/vendor)
set(DEMO_CARTS_IN ${CMAKE_SOURCE_DIR}/demos)

include(cmake/gif.cmake)
include(cmake/blipbuf.cmake)
Expand Down
Loading

0 comments on commit 3e37e88

Please sign in to comment.