Skip to content

Commit

Permalink
Update 3ds docker toolchain (#2701)
Browse files Browse the repository at this point in the history
* update 3ds docker

* try to fix 3ds lua error

* revert and try to fix wren error

* disable lua and scheme for 3ds

* try to fix lua

* try to fix lua

* try to fix lua

* test

* revert

* try to fix lua

* test

* test

* continue

* possible last lua fix

* disable javascript in 3ds

* disable js correctly

* disable python for 3ds

* try to fix script.c

* try to fix another error

* test

* try to fix miniaudio

* test

* test

* test

* test

* test

* test

* try to fix gif errors

* test

* test

* test

* continue

* try with official devkitarm docker image

* test

* clean

* proper miniaudio fix

* mianiaudio version used before

* use cmake to build 3dsx

* use explicit name

* fix 3ds build instructions

* use NINTENDO_3DS from devkitPro cmakery

* fixup build commands

* output to build/bin

* update tested version

---------

Co-authored-by: Dave Murphy <[email protected]>
  • Loading branch information
Miguel-hrvs and WinterMute authored Nov 11, 2024
1 parent e30b273 commit ce24e76
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 54 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ jobs:
# === Nintendo 3DS build ===
nintendo-3ds:
runs-on: ubuntu-latest
container: nesbox/devkitpro-tic80:latest
container: devkitpro/devkitarm:latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand All @@ -334,12 +334,11 @@ jobs:
- name: Build
run: |
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON ..
make -j$(nproc)
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_WITH_SCHEME=OFF -DBUILD_WITH_JS=OFF -DBUILD_WITH_PYTHON=OFF ..
cmake --build build --parallel
- name: Deploy
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "tic80-nintendo-3ds"
path: build/bin/tic80.3dsx
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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)
if(ANDROID OR EMSCRIPTEN OR NINTENDO_3DS OR BAREMETALPI)
set(BUILD_STATIC_DEFAULT ON)
else()
set(BUILD_STATIC_DEFAULT OFF)
Expand Down Expand Up @@ -64,15 +64,15 @@ message("BUILD_SDLGPU: ${BUILD_SDLGPU}")
message("BUILD_TOUCH_INPUT: ${BUILD_TOUCH_INPUT}")
message("BUILD_WITH_ALL: ${BUILD_WITH_ALL}")

if (N3DS)
if (NINTENDO_3DS)
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)
if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN AND NOT ANDROID AND NOT NINTENDO_3DS)
set(LINUX TRUE)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD")
Expand Down
9 changes: 3 additions & 6 deletions build/n3ds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

## Requirements

* devkitARM (tested on release 54, please use latest) + the 3ds-dev meta package
* devkitARM (tested on release 65, please use latest) + the 3ds-dev meta package
* the following additional packages:
* devkitpro-pkgbuild-helpers
* 3ds-libpng
* 3ds-pkg-config
* 3ds-zlib

## Building instructions

```
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake -DN3DS=TRUE
make
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake
cmake --build build
```

You should now be able to find `tic80.3dsx` in build/bin.
5 changes: 0 additions & 5 deletions build/n3ds/elf_to_3dsx.sh

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/lua.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if(BUILD_WITH_LUA)
${CMAKE_SOURCE_DIR}/src
)

if(N3DS)
if(NINTENDO_3DS)
target_compile_definitions(luaapi PUBLIC LUA_32BITS)
endif()

Expand Down
26 changes: 17 additions & 9 deletions cmake/n3ds.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,34 @@
# TIC-80 app (N3DS)
################################

if(N3DS)
if(NINTENDO_3DS)
set(TIC80_SRC ${TIC80_SRC}
${CMAKE_SOURCE_DIR}/src/system/n3ds/utils.c
${CMAKE_SOURCE_DIR}/src/system/n3ds/keyboard.c
${CMAKE_SOURCE_DIR}/src/system/n3ds/main.c
)

add_executable(tic80_n3ds ${TIC80_SRC})
add_executable(tic80 ${TIC80_SRC})

target_include_directories(tic80_n3ds PRIVATE
target_include_directories(tic80 PRIVATE
${DEVKITPRO}/portlibs/3ds/include
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src)

target_link_directories(tic80_n3ds PRIVATE ${DEVKITPRO}/libctru/lib ${DEVKITPRO}/portlibs/3ds/lib)
target_link_libraries(tic80_n3ds tic80studio png citro3d)
target_link_directories(tic80 PRIVATE ${DEVKITPRO}/libctru/lib ${DEVKITPRO}/portlibs/3ds/lib)
target_link_libraries(tic80 tic80studio png citro3d)

add_custom_command(TARGET tic80_n3ds
POST_BUILD
COMMAND ${CMAKE_SOURCE_DIR}/build/n3ds/elf_to_3dsx.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build
ctr_generate_smdh(tic80.smdh
NAME "TIC-80 tiny computer"
DESCRIPTION "Fantasy computer for making, playing and sharing tiny games"
AUTHOR "Nesbox"
ICON ${CMAKE_SOURCE_DIR}/build/n3ds/icon.png
)

ctr_create_3dsx(tic80
SMDH tic80.smdh
ROMFS ${CMAKE_SOURCE_DIR}/build/n3ds/romfs
OUTPUT ${CMAKE_SOURCE_DIR}/build/bin/tic80.3dsx
)

endif()
2 changes: 1 addition & 1 deletion cmake/naett.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# naett
################################

if(NOT RPI AND NOT N3DS AND NOT EMSCRIPTEN AND NOT BAREMETALPI)
if(NOT RPI AND NOT NINTENDO_3DS AND NOT EMSCRIPTEN AND NOT BAREMETALPI)
set(USE_NAETT TRUE)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/quickjs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if(BUILD_WITH_JS)
target_compile_definitions(quickjs PRIVATE DUMP_LEAKS)
endif()

if(BAREMETALPI OR N3DS)
if(BAREMETALPI OR NINTENDO_3DS)
target_compile_definitions(quickjs PRIVATE POOR_CLIB)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/scheme.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(BUILD_WITH_SCHEME)
${CMAKE_SOURCE_DIR}/src
)

if (N3DS)
if (NINTENDO_3DS)
target_compile_definitions(scheme PRIVATE S7_N3DS)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ZLIB
################################

if (NOT N3DS)
if (NOT NINTENDO_3DS)

set(ZLIB_DIR ${THIRDPARTY_DIR}/zlib)
set(ZLIB_SRC
Expand Down
10 changes: 5 additions & 5 deletions src/api/luaapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1595,14 +1595,14 @@ static s32 lua_ffts(lua_State* lua)
return 0;
}

static s32 lua_dofile(lua_State *lua)
static int lua_dofile(lua_State *lua)
{
luaL_error(lua, "unknown method: \"dofile\"\n");

return 0;
}

static s32 lua_loadfile(lua_State *lua)
static int lua_loadfile(lua_State *lua)
{
luaL_error(lua, "unknown method: \"loadfile\"\n");

Expand Down Expand Up @@ -1634,12 +1634,12 @@ void luaapi_init(tic_core* core)
{
static const struct{lua_CFunction func; const char* name;} ApiItems[] =
{
#define API_FUNC_DEF(name, ...) {lua_ ## name, #name},
#define API_FUNC_DEF(name, ...) {(lua_CFunction)(lua_ ## name), #name},
TIC_API_LIST(API_FUNC_DEF)
#undef API_FUNC_DEF

#if defined(BUILD_DEPRECATED)
{lua_textri, "textri"},
{(lua_CFunction)lua_textri, "textri"},
#endif
};

Expand All @@ -1665,7 +1665,7 @@ void luaapi_close(tic_mem* tic)
** Message handler which appends stract trace to exceptions.
** This function was extractred from lua.c.
*/
static s32 msghandler (lua_State *lua)
static int msghandler (lua_State *lua)
{
const char *msg = lua_tostring(lua, 1);
if (msg == NULL) /* is error object not a string? */
Expand Down
2 changes: 1 addition & 1 deletion src/api/wren.c
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ static void initAPI(tic_core* core)
}
}

static void reportError(WrenVM* vm, WrenErrorType type, const char* module, s32 line, const char* message)
static void reportError(WrenVM* vm, WrenErrorType type, const char* module, int line, const char* message)
{
tic_core* core = getWrenCore(vm);

Expand Down
9 changes: 5 additions & 4 deletions src/ext/gif.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static gif_image* readGif(GifFileType *gif)
{
gif_image* image = NULL;

s32 error = 0;
int error = 0;

if(gif)
{
Expand Down Expand Up @@ -101,7 +101,7 @@ static gif_image* readGif(GifFileType *gif)

case EXTENSION_RECORD_TYPE:
{
s32 extCode = 0;
int extCode = 0;
GifByteType* extension = NULL;

if (DGifGetExtension(gif, &extCode, &extension) == GIF_ERROR)
Expand Down Expand Up @@ -167,7 +167,7 @@ typedef struct
s32 pos;
} GifBuffer;

static s32 readBuffer(GifFileType* gif, GifByteType* data, s32 size)
static int readBuffer(GifFileType* gif, GifByteType* data, int size)
{
GifBuffer* buffer = (GifBuffer*)gif->UserData;

Expand All @@ -177,14 +177,15 @@ static s32 readBuffer(GifFileType* gif, GifByteType* data, s32 size)
return size;
}

gif_image* gif_read_data(const void* data, s32 size)
gif_image* gif_read_data(const void* data, int size)
{
GifBuffer buffer = {data, 0};
GifFileType *gif = DGifOpen(&buffer, readBuffer, NULL);

return readGif(gif);
}


void gif_close(gif_image* image)
{
if(image)
Expand Down
2 changes: 1 addition & 1 deletion src/ext/gif.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ typedef struct
s32 colors;
} gif_image;

gif_image* gif_read_data(const void* buffer, s32 size);
gif_image* gif_read_data(const void* buffer, int size);
void gif_close(gif_image* image);
6 changes: 3 additions & 3 deletions src/ext/miniaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -16137,7 +16137,7 @@ static ma_result ma_thread_create__posix(ma_thread* pThread, ma_thread_priority
int result;
pthread_attr_t* pAttr = NULL;

#if !defined(__EMSCRIPTEN__)
#if !defined(__EMSCRIPTEN__) && !defined(__3DS__)
/* Try setting the thread priority. It's not critical if anything fails here. */
pthread_attr_t attr;
if (pthread_attr_init(&attr) == 0) {
Expand Down Expand Up @@ -17864,7 +17864,7 @@ Dynamic Linking
#ifdef MA_POSIX
/* No need for dlfcn.h if we're not using runtime linking. */
#ifndef MA_NO_RUNTIME_LINKING
#include <dlfcn.h>
#include "../../vendor/dlfcn/src/dlfcn.h"
#endif
#endif

Expand Down Expand Up @@ -17995,7 +17995,7 @@ DEVICE I/O

/* No need for dlfcn.h if we're not using runtime linking. */
#ifndef MA_NO_RUNTIME_LINKING
#include <dlfcn.h>
#include "../../vendor/dlfcn/src/dlfcn.h"
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void tic_add_script(const tic_script* script)
if(index < MAX_SUPPORTED_LANGS)
{
Scripts[index] = script;
qsort(Scripts, index + 1, sizeof Scripts[0], compareScripts);
qsort(Scripts, index + 1, sizeof Scripts[0], (int (*)(const void *, const void *))compareScripts);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/studio/editors/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ static void setGotoMode(Code* code)
code->jump.line = -1;
}

static s32 funcCompare(const void* a, const void* b)
static int funcCompare(const void* a, const void* b)
{
const tic_outline_item* item1 = (const tic_outline_item*)a;
const tic_outline_item* item2 = (const tic_outline_item*)b;
Expand Down
6 changes: 3 additions & 3 deletions src/studio/screens/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ static s32 casecmp(const char *str1, const char *str2)
return (s32) ((u8) tolower(*str1) - (u8) tolower(*str2));
}

static inline s32 itemcmp(const void* a, const void* b)
static inline int itemcmp(const void* a, const void* b)
{
const FileItem* item1 = a;
const FileItem* item2 = b;
Expand Down Expand Up @@ -4489,12 +4489,12 @@ void forceAutoSave(Console* console, const char* cart_name)
commandDone(console);
}

static s32 cmdcmp(const void* a, const void* b)
static int cmdcmp(const void* a, const void* b)
{
return strcmp(((const Command*)a)->name, ((const Command*)b)->name);
}

static s32 apicmp(const void* a, const void* b)
static int apicmp(const void* a, const void* b)
{
return strcmp(((const ApiItem*)a)->name, ((const ApiItem*)b)->name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/studio/screens/surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static bool addMenuItem(const char* name, const char* title, const char* hash, s
return true;
}

static s32 itemcmp(const void* a, const void* b)
static int itemcmp(const void* a, const void* b)
{
const SurfItem* item1 = a;
const SurfItem* item2 = b;
Expand Down

0 comments on commit ce24e76

Please sign in to comment.