Skip to content

Commit

Permalink
Initial TWL toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyquagsire23 committed Sep 22, 2023
1 parent 5ad21aa commit e895f53
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ build_linux_arm64_flatpak/*
build_linux_x86_64_flatpak/*
build_android_aarch64/*
build_android_arm32/*
build_nintendo_dsi/*
flatpak_openjkdf2/*
.flatpak-builder/*
OpenJKDF2.flatpak
Expand Down
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ set(PLAT_WASM FALSE CACHE BOOL "Emscripten WASM target")
set(PLAT_HOOKS FALSE CACHE BOOL "Hook DLL target")
set(PLAT_MSVC FALSE CACHE BOOL "Windows 64-bit MSVC")
set(PLAT_ANDROID_ARM64 FALSE CACHE BOOL "Android AArch64")
set(PLAT_TWL FALSE CACHE BOOL "Nintendo DSi")
set(PLAT_AUTO FALSE CACHE BOOL "Target the host OS")

# Set PLAT_AUTO if a platform isn't specifically selected
if(NOT PLAT_LINUX_32 AND NOT PLAT_LINUX_64 AND NOT PLAT_MACOS AND NOT PLAT_MACOS_X86_64 AND NOT PLAT_MINGW_X86_64 AND NOT PLAT_WASM AND NOT PLAT_HOOKS)
if(NOT PLAT_LINUX_32 AND NOT PLAT_LINUX_64 AND NOT PLAT_MACOS AND NOT PLAT_MACOS_X86_64 AND NOT PLAT_MINGW_X86_64 AND NOT PLAT_WASM AND NOT PLAT_HOOKS AND NOT PLAT_TWL)
set(PLAT_AUTO TRUE)
endif()

Expand All @@ -57,6 +58,7 @@ set(TARGET_WIN32 FALSE)
set(TARGET_WASM FALSE)
set(TARGET_ANDROID FALSE)
set(TARGET_ANDROID_ARM64 FALSE)
set(TARGET_TWL FALSE)
set(TARGET_HOOKS FALSE)
set(TARGET_NO_BLOBS FALSE)
set(TARGET_CAN_JKGM FALSE)
Expand Down Expand Up @@ -133,6 +135,8 @@ elseif(PLAT_ANDROID_ARM64)
include(cmake_modules/plat_android_arm64.cmake)
elseif(PLAT_MSVC)
include(cmake_modules/plat_msvc.cmake)
elseif(PLAT_TWL)
include(cmake_modules/plat_twl.cmake)
else()
message(FATAL_ERROR "Unknown platform! Cannot continue.")
endif()
Expand Down
19 changes: 19 additions & 0 deletions build_twl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
#make flex/flex
#make byacc/yacc

export OPENJKDF2_RELEASE_COMMIT=$(git log -1 --format="%H")
export OPENJKDF2_RELEASE_COMMIT_SHORT=$(git rev-parse --short=8 HEAD)

#NDK_TOOLCHAIN_BINS=$(dirname $(find "$ANDROID_NDK_HOME/" -name "aarch64-linux-android31-clang"))
#PATH=$PATH:$NDK_TOOLCHAIN_BINS

#rm -rf build_win64
mkdir -p build_nintendo_dsi && cd build_nintendo_dsi
OPENJKDF2_BUILD_DIR=$(pwd)

# Prevent macOS headers from getting linked in
export -n SDKROOT MACOSX_DEPLOYMENT_TARGET CPLUS_INCLUDE_PATH C_INCLUDE_PATH

cmake .. --toolchain $(pwd)/../cmake_modules/toolchain_twl.cmake && make -j10 openjkdf2
cd ..
45 changes: 45 additions & 0 deletions cmake_modules/plat_twl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
macro(plat_initialize)
message( STATUS "Targeting Nintendo DSi" )

set(BIN_NAME "openjkdf2")

#add_definitions(-DARCH_WASM)

# These are the standard features for full game support
set(TARGET_USE_PHYSFS FALSE)
#set(TARGET_USE_BASICSOCKETS TRUE)
set(TARGET_USE_GAMENETWORKINGSOCKETS FALSE)
set(TARGET_USE_LIBSMACKER TRUE)
set(TARGET_USE_LIBSMUSHER TRUE)
set(TARGET_USE_SDL2 FALSE)
set(TARGET_USE_OPENGL FALSE)
set(TARGET_USE_OPENAL FALSE)
set(TARGET_POSIX TRUE)
set(TARGET_NO_BLOBS TRUE)
set(TARGET_CAN_JKGM FALSE)
set(OPENJKDF2_NO_ASAN TRUE)
set(TARGET_USE_CURL FALSE)
set(TARGET_FIND_OPENAL FALSE)

if(OPENJKDF2_USE_BLOBS)
set(TARGET_NO_BLOBS FALSE)
endif()

set(TARGET_BUILD_TESTS FALSE)
set(SDL2_COMMON_LIBS "")

set(TARGET_TWL TRUE)

add_link_options(-fno-exceptions)
add_compile_options(-fno-exceptions)
add_compile_options(-O2 -Wuninitialized -fshort-wchar -Wall -Wno-unused-variable -Wno-parentheses -Wno-missing-braces)
endmacro()

macro(plat_specific_deps)
set(SDL2_COMMON_LIBS "")
endmacro()

macro(plat_link_and_package)
target_link_libraries(${BIN_NAME} PRIVATE -lm -lSDL2 -lSDL2_mixer -lGL -lGLEW -lopenal)
target_link_libraries(sith_engine PRIVATE nlohmann_json::nlohmann_json)
endmacro()
40 changes: 40 additions & 0 deletions cmake_modules/toolchain_twl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CMake toolchain file
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION "0.0.0")
set(CMAKE_SYSTEM_PROCESSOR arm)

if(DEFINED ENV{DEVKITPRO})
set(DEVKITPRO $ENV{DEVKITPRO})
else()
set(DEVKITPRO /opt/devkitpro)
endif()

if(DEFINED ENV{DEVKITARM})
set(DEVKITARM $ENV{DEVKITARM})
else()
set(DEVKITARM ${DEVKITPRO}/devkitARM)
endif()

if(DEFINED ENV{NDSTOOL})
set(NDSTOOL $ENV{NDSTOOL})
else()
set(NDSTOOL ${DEVKITPRO}/tools/bin/ndstool)
endif()

set(TOOLCHAIN_PREFIX arm-none-eabi)
set(TOOLCHAIN_PREFIX_PATH ${DEVKITARM}/bin/${TOOLCHAIN_PREFIX})

set(CMAKE_C_COMPILER "${TOOLCHAIN_PREFIX_PATH}-gcc" CACHE STRING "C compiler" FORCE)
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX_PATH}-g++" CACHE STRING "C++ compiler" FORCE)

set(CMAKE_C_FLAGS_INIT "")
set(CMAKE_CXX_FLAGS_INIT ${CMAKE_C_FLAGS_INIT})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

set(PLAT_TWL TRUE)

message( STATUS "Nintendo DSi ARM32 toolchain invoked" )

0 comments on commit e895f53

Please sign in to comment.