From 9e3d53c4df6c0ab0dfa9167162c7d79fd7c1bc8a Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 03:22:43 +0200 Subject: [PATCH 01/19] - add support for 3ds - refactor meson files into smaller parts, so that the main file isn't that big - refactor switch cross file --- meson.build | 612 +-------------------------------- platforms/3ds/meson.build | 189 ++++++++++ platforms/build-3ds.sh | 252 ++++++++++++++ platforms/build-android.sh | 2 +- platforms/build-switch.sh | 94 +++-- platforms/switch/meson.build | 180 ++++++++++ tools/dependencies/meson.build | 289 ++++++++++++++++ tools/install/meson.build | 94 +++++ tools/options/meson.build | 72 ++++ 9 files changed, 1152 insertions(+), 632 deletions(-) create mode 100644 platforms/3ds/meson.build create mode 100755 platforms/build-3ds.sh create mode 100644 platforms/switch/meson.build create mode 100644 tools/dependencies/meson.build create mode 100644 tools/install/meson.build create mode 100644 tools/options/meson.build diff --git a/meson.build b/meson.build index 49a7176e..42ee0457 100644 --- a/meson.build +++ b/meson.build @@ -15,497 +15,13 @@ project( ) -core_lib = { - 'src_files': [], - 'inc_dirs': [], - 'compile_args': ['-DOOPETRIS_VERSION=' + meson.project_version()], - 'deps': [], -} - -recordings_lib = { - 'src_files': [], - 'inc_dirs': [], - 'compile_args': [], - 'deps': [], -} - -graphics_lib = { - 'src_files': [], - 'inc_dirs': [], - 'compile_args': [], - 'deps': [], -} - -global_deps = [] -graphic_application_deps = [] - -cpp = meson.get_compiler('cpp') - -build_with_libcpp = false - -if cpp.get_id() == 'gcc' - add_project_arguments('-Wold-style-cast', language: ['cpp']) -elif cpp.get_id() == 'clang' - - build_with_libcpp_option = get_option('clang_libcpp') - - build_with_libcpp = build_with_libcpp_option.enabled() - - if build_with_libcpp_option.auto() - if host_machine.system() == 'darwin' - build_with_libcpp = true - else - - cpp_lib = cpp.find_library('c++', required: false) - cppabi_lib = cpp.find_library('c++abi', required: false) - - if cpp_lib.found() and cppabi_lib.found() - build_with_libcpp = true - else - build_with_libcpp = false - endif - endif - endif - - if build_with_libcpp - add_global_link_arguments('-stdlib=libc++', language: ['cpp']) - add_global_arguments('-stdlib=libc++', language: ['cpp']) - global_deps += [cpp.find_library('c++'), cpp.find_library('c++abi')] - endif - -endif - -if ( - get_option('buildtype') == 'debug' - or get_option('buildtype') == 'debugoptimized' -) - core_lib += { - 'compile_args': [core_lib.get('compile_args'), '-DDEBUG_BUILD'], - } -endif - - - -only_allow_native_libs = false -if meson.is_cross_build() - if host_machine.system() == 'switch' - # we do not link to code that was compiled with gcc 10.1, the code we link with is all compiled with gcc 13.2 - core_lib += { - 'compile_args': [core_lib.get('compile_args'), '-Wno-psabi'], - } - - only_allow_native_libs = true - endif -endif - - -sdl2_dep = dependency( - 'sdl2', - 'SDL2', - allow_fallback: false, - required: only_allow_native_libs, -) - -if sdl2_dep.found() - graphics_lib += { - 'deps': [graphics_lib.get('deps'), sdl2_dep], - } -else - sdl2_dep = dependency( - 'sdl2', - required: true, - default_options: {'test': false}, - ) - sdl2main_dep = dependency( - 'sdl2main', - required: true, - fallback: 'sdl2', - ) - - graphic_application_deps += sdl2main_dep - - graphics_lib += { - 'deps': [graphics_lib.get('deps'), sdl2_dep], - } -endif - -sdl2_ttf_dep = dependency( - 'sdl2_ttf', - 'SDL2_ttf', - allow_fallback: not only_allow_native_libs, - required: true, -) -graphics_lib += { - 'deps': [graphics_lib.get('deps'), sdl2_ttf_dep], -} - -sdl2_image_dep = dependency( - 'sdl2_image', - 'SDL2_image', - allow_fallback: not only_allow_native_libs, - required: true, -) -graphics_lib += { - 'deps': [graphics_lib.get('deps'), sdl2_image_dep], -} - -# a dirty thing atm, until mpg123 is ported to meson (maybe never...) -mpg123_dep = dependency( - 'mpg123', - allow_fallback: true, - required: false, -) -sdl2_mixer_flags = {'flac': 'enabled'} -sdl2_mixer_defines = ['-DAUDIO_WITH_FLAC_SUPPORT'] -if mpg123_dep.found() - sdl2_mixer_flags += {'mpg123': 'enabled'} - sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' -else - mpg123_dep = cpp.find_library('mpg123', required: only_allow_native_libs) - if mpg123_dep.found() - sdl2_mixer_flags += {'mpg123': 'enabled'} - sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' - - meson.override_dependency('mpg123', mpg123_dep) - endif -endif - - - -sdl2_mixer_dep = dependency( - 'sdl2_mixer', - 'SDL2_mixer', - allow_fallback: not only_allow_native_libs, - required: true, - default_options: sdl2_mixer_flags, -) -graphics_lib += { - 'deps': [graphics_lib.get('deps'), sdl2_mixer_dep], - 'compile_args': [graphics_lib.get('compile_args'), sdl2_mixer_defines], -} - -if (meson.is_cross_build() and host_machine.system() == 'switch') - - fmt_lib = dependency( - 'fmt', - required: false, - allow_fallback: false, - ) - - if fmt_lib.found() - core_lib += {'deps': [core_lib.get('deps'), fmt_lib]} - else - - fmt_header_only_dep = dependency( - 'fmt_header_only', - required: true, - allow_fallback: true, - default_options: {'default_library': 'static'}, - ) - - meson.override_dependency('fmt', fmt_header_only_dep) - - core_lib += {'deps': [core_lib.get('deps'), fmt_header_only_dep]} - endif - -else - - # clang with libc++ creates some really long and confusing linker errors, so just use the header only library - if cpp.get_id() == 'clang' and build_with_libcpp - fmt_dep = dependency( - 'fmt_header_only', - required: true, - allow_fallback: true, - default_options: {'default_library': 'static'}, - ) - meson.override_dependency('fmt', fmt_dep) - else - fmt_dep = dependency( - 'fmt', - required: true, - ) - endif - - - core_lib += {'deps': [core_lib.get('deps'), fmt_dep]} -endif - -spdlog_dep = dependency( - 'spdlog', - required: true, - default_options: {'tests': 'disabled'}, -) -graphics_lib += {'deps': [graphics_lib.get('deps'), spdlog_dep]} - -nlohmann_json_dep = dependency( - 'nlohmann_json', - required: true, -) -core_lib += {'deps': [core_lib.get('deps'), nlohmann_json_dep]} - -# check std::expected support -have_std_expected = cpp.compiles( - ''' -#include -int main() { - using T = std::expected; - return 0; -} -''', - args: core_lib.get('compile_args'), -) - -if not have_std_expected - message('Compiler doesn\'t support std::expected, using fallback') - - tl_exp_dep = dependency('tl-expected', required: true) - core_lib += { - 'compile_args': [core_lib.get('compile_args'), '-D_USE_TL_EXPECTED'], - 'deps': [core_lib.get('deps'), tl_exp_dep], - } -else - message('Compiler support std::expected, using that') -endif - -# check std::optional support -have_std_optional = cpp.compiles( - ''' -#include -int main() { - using T = std::optional; - return 0; -} -''', - args: core_lib.get('compile_args'), -) - -if not have_std_optional - message('Compiler doesn\'t support std::optional, using fallback') - tl_opt_dep = dependency('tl-optional', required: true) - core_lib += { - 'compile_args': [core_lib.get('compile_args'), '-D_USE_TL_OPTIONAL'], - 'deps': [core_lib.get('deps'), tl_opt_dep], - } -else - message('Compiler support std::optional, using that') -endif - - - -magic_enum_dep = dependency( - 'magic_enum', - required: true, - default_options: {'test': false}, -) -core_lib += {'deps': [core_lib.get('deps'), magic_enum_dep]} - -argparse_dep = dependency('argparse', required: true) -core_lib += {'deps': [core_lib.get('deps'), argparse_dep]} - -online_multiplayer_supported = true - - -if meson.is_cross_build() and host_machine.system() == 'switch' - online_multiplayer_supported = false - core_lib += { - 'compile_args': [ - core_lib.get('compile_args'), - '-D_ONLINE_MULTIPLAYER_NOT_SUPPORTED', - ], - } -else - cpp_httlib_dep = dependency( - 'cpp-httplib', - required: true, - default_options: { - 'cpp-httplib_openssl': 'enabled', - 'cpp-httplib_zlib': 'enabled', - }, - ) - core_lib += {'deps': [core_lib.get('deps'), cpp_httlib_dep]} -endif - -utf8cpp_dep = dependency( - 'utf8cpp', - required: true, - version: '>=4.0.0', -) -core_lib += {'deps': [core_lib.get('deps'), utf8cpp_dep]} - -if (meson.is_cross_build() and host_machine.system() == 'switch') - - ## TODO: use the PR #126 to clean up this config a little bit more - - switch_dependencies = [ - 'EGL', - 'GLESv2', - 'glapi', - 'drm_nouveau', - 'nx', - 'freetype', - 'z', - 'bz2', - 'png', - 'opusfile', - 'opus', - 'vorbisfile', - 'vorbis', - 'ogg', - 'modplug', - 'harfbuzz', - 'FLAC', - 'curl', - ] - - - library_dirs = meson.get_external_property('library_dirs') - - switch_deps = [] - foreach dep : switch_dependencies - switch_deps += cpp.find_library( - dep, - required: true, - dirs: library_dirs, - ) - endforeach - graphics_lib += {'deps': [graphics_lib.get('deps'), switch_deps]} - -endif - -is_flatpak_build = get_option('flatpak_build') - -have_file_dialogs = false -have_discord_sdk = false - - -nfde_dep = dependency( - 'nativefiledialog-extended', - required: not meson.is_cross_build(), - default_options: { - 'xdg-desktop-portal': is_flatpak_build ? 'enabled' : 'auto', - }, -) -if nfde_dep.found() - have_file_dialogs = true - graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_HAVE_FILE_DIALOGS', - ], - 'deps': [graphics_lib.get('deps'), nfde_dep], - } -endif - -discord_sdk_dep = dependency( - 'discord-game-sdk', - required: not meson.is_cross_build(), - default_options: {'clang_libcpp': 'disabled'}, -) -if discord_sdk_dep.found() - have_discord_sdk = true - graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_HAVE_DISCORD_SDK', - ], - 'deps': [graphics_lib.get('deps'), discord_sdk_dep], - } -endif +subdir('tools/options') +subdir('tools/dependencies') subdir('src') -## TODO: only install needed ones, since sometimes we only need e.g. flacs or mp3 and no icons etc. -## install assets -install_subdir( - 'assets', - install_dir: 'share/oopetris', - exclude_files: ['oopetris.desktop.in', 'OOPetris.svg', 'recordings.magic'], - exclude_directories: ['icon'], -) - -app_name = 'oopetris' -if is_flatpak_build - app_name = 'com.github.mgerhold.OOPetris' - core_lib += { - 'compile_args': [ - core_lib.get('compile_args'), - '-DFLATPAK_BUILD', - '-DBUILD_INSTALLER', - ], - } -endif - -conf = configuration_data() -conf.set('APP_NAME', app_name) - -datadir = get_option('prefix') / get_option('datadir') - - -if host_machine.system() == 'linux' - - fs = import('fs') - - magic_dir = datadir / 'misc' - magic_file = magic_dir / 'magic' - oopetris_magic_file = 'assets' / 'recordings.magic' - - if fs.exists(magic_file) - - cat_prog = find_program('cat') - - custom_target( - 'magic_file_append', - command: [cat_prog, '@INPUT@'], - capture: true, - input: [oopetris_magic_file, magic_file], - output: 'magic', - install_dir: magic_dir, - ) - - else - - install_data( - oopetris_magic_file, - install_dir: magic_dir, - rename: ['magic'], - ) - - endif -endif - -desktop_file = configure_file( - input: 'assets/oopetris.desktop.in', - output: app_name + '.desktop', - configuration: conf, - install: true, - install_dir: datadir / 'applications', -) - -logos = [ - '24x24.png', - '48x48.png', - '64x64.png', - '72x72.png', - '96x96.png', - '128x128.png', - '144x144.png', - '160x160.png', - '192x192.png', - '256x256.png', - '512x512.png', - 'scalable.svg', -] - -foreach logo : logos - name = logo.split('.')[0] - ext = logo.split('.')[1] - install_data( - 'assets' / 'icon' / logo, - install_dir: datadir / 'icons' / 'hicolor' / name / 'apps', - rename: [app_name + '.' + ext], - ) -endforeach +subdir('tools/install') if meson.is_cross_build() and host_machine.system() == 'android' @@ -518,117 +34,21 @@ if meson.is_cross_build() and host_machine.system() == 'android' 'werror': true, }, ) -elif meson.is_cross_build() and host_machine.system() == 'switch' - elf_file = build_target( - 'oopetris.elf', +elif meson.is_cross_build() and host_machine.system() == 'switch' + switch_options = [ + app_name, main_files, - dependencies: [liboopetris_graphics_dep, graphic_application_deps], - override_options: { - 'warning_level': '3', - 'werror': true, - }, - target_type: 'executable', - ) - - - use_nacp = ['true', 'True', '1', true].contains( - meson.get_external_property('USE_NACP'), - ) - - elf2nro = find_program('elf2nro') - # executable input elf file, output nro file - NROFLAGS = [elf2nro, 'oopetris.elf', 'oopetris.nro'] - NRO_DEPS = [elf_file] - NACP_DEPS = NRO_DEPS - - fs = import('fs') - - if use_nacp - nacptool = find_program('nacptool') - NACPFLAGS = [nacptool, '--create'] - - APP_NAME = meson.get_external_property('APP_NAME', 'oopetris') - NACPFLAGS += APP_NAME - - - APP_AUTHOR = meson.get_external_property('APP_AUTHOR', '') - if APP_AUTHOR == '' - error('If USE_NACP is set, you have to provie an APP_AUTHOR') - endif - NACPFLAGS += APP_AUTHOR - - APP_VERSION = meson.get_external_property('APP_VERSION', '') - if APP_VERSION == '' - error('If USE_NACP is set, you have to provie an APP_VERSION') - endif - NACPFLAGS += APP_VERSION - - NACPFLAGS += 'oopetris.nacp' # outfile - - - APP_TITLEID = meson.get_external_property('APP_TITLEID', '') - - # optional - if APP_TITLEID != '' - NACPFLAGS += '--titleid=' + APP_TITLEID - endif - - - # nacptool --create name author version oopetris.nacp - # optional: --titleid= - nacp_file = custom_target( - 'oopetris.nacp', - command: NACPFLAGS, - output: ['oopetirs.nacp'], - depends: NACP_DEPS, - ) - NROFLAGS += '--nacp=oopetris.nacp' - NRO_DEPS += nacp_file - - - endif - - - default_icon = meson.get_external_property('libnx') / 'default_icon.jpg' - - app_icon = meson.get_external_property('APP_ICON', default_icon) - - if not fs.exists(app_icon) - error('APP_ICON should exist, but doesn\'t: \'' + app_icon + '\'') - endif - - if not fs.is_absolute(app_icon) - app_icon = meson.project_source_root() / app_icon - endif - - - NROFLAGS += '--icon=' + app_icon - - - romfs_dir = meson.get_external_property('romfs_dir') - - if not fs.exists(romfs_dir) - error('romfs_dir should exist, but doesn\'t: \'' + romfs_dir + '\'') - endif - - if not fs.is_absolute(romfs_dir) - romfs_dir = meson.project_source_root() / romfs_dir - endif - - - NROFLAGS += '--romfsdir=' + romfs_dir - - # elf2nro oopetris.elf oopetris.nro NROFLAGS - custom_target( - 'oopetris.nro', - command: NROFLAGS, - depends: NRO_DEPS, - output: ['oopetris.nro'], - build_by_default: true, - ) - - + [liboopetris_graphics_dep, graphic_application_deps], + ] + subdir('platforms/switch') +elif meson.is_cross_build() and host_machine.system() == '3ds' + _3ds_options = [ + app_name, + main_files, + [liboopetris_graphics_dep, graphic_application_deps], + ] + subdir('platforms/3ds') else executable( diff --git a/platforms/3ds/meson.build b/platforms/3ds/meson.build new file mode 100644 index 00000000..8b05e307 --- /dev/null +++ b/platforms/3ds/meson.build @@ -0,0 +1,189 @@ + +## get the options object and "unpack" it + +_3ds_exe_name = _3ds_options[0] +_3ds_src_files = _3ds_options[1] +_3ds_deps = _3ds_options[2] + + +# libraries + +_3ds_dependencies = [ + 'flac', + 'freetype2', + 'ogg', + 'ogg', + 'opus', + 'opusfile', + 'vorbisidec', + 'zlib', +] + +_3ds_dependencies_native = [ + 'bz2', + 'ctru', + 'mad', + 'mikmod', + 'modplug', + 'png16', + 'SDL2main', +] + + +_3ds_library_dirs = meson.get_external_property('library_dirs', ['']) +if _3ds_library_dirs.length() == 0 + error('property \'library_dirs\' has to be set!') +endif + +foreach dep : _3ds_dependencies + _3ds_deps += dependency( + dep, + required: true, + allow_fallback: false, + native: false, + ) +endforeach + +c = meson.get_compiler('c') +foreach dep : _3ds_dependencies_native + _3ds_deps += c.find_library( + dep, + required: true, + dirs: _3ds_library_dirs, + ) +endforeach + + +## compilation + +_3ds_elf_file = build_target( + _3ds_exe_name + '.elf', + _3ds_src_files, + dependencies: _3ds_deps, + override_options: { + 'warning_level': '3', + 'werror': true, + }, + native: false, + target_type: 'executable', +) + +use_smdh = ['true', 'True', '1', true].contains( + meson.get_external_property('USE_SMDH', ''), +) + + +_3dsxtool = find_program('3dsxtool') + +_3DSX_FLAGS = [_3dsxtool, _3ds_elf_file.full_path(), _3ds_exe_name + '.3dsx'] +_3DSX_DEPS = [_3ds_elf_file] +SMDH_DEPS = _3DSX_DEPS + +fs = import('fs') + +if use_smdh + + smdhtool = find_program('smdhtool') + SMDH_FLAGS = [smdhtool, '--create'] + + APP_NAME = meson.get_external_property('APP_NAME', _3ds_exe_name) + SMDH_FLAGS += APP_NAME + + APP_DESC = meson.get_external_property('APP_DESC', '') + if APP_DESC == '' + error('If USE_SMDH is set, you have to provide an APP_DESC') + endif + SMDH_FLAGS += APP_DESC + + + APP_AUTHOR = meson.get_external_property('APP_AUTHOR', '') + if APP_AUTHOR == '' + error('If USE_SMDH is set, you have to provide an APP_AUTHOR') + endif + SMDH_FLAGS += APP_AUTHOR + + LIBCTRU = meson.get_external_property('libctru', '') + if LIBCTRU == '' + error('property \'libctru\' has to be set!') + endif + + _3ds_default_icon = LIBCTRU / 'default_icon.png' + + APP_ICON = meson.get_external_property('APP_ICON', _3ds_default_icon) + + if not fs.is_absolute(APP_ICON) + APP_ICON = meson.project_source_root() / APP_ICON + endif + + + if not fs.exists(APP_ICON) + error('APP_ICON should exist, but doesn\'t: \'' + APP_ICON + '\'') + endif + + SMDH_FLAGS += APP_ICON + + + SMDH_FLAGS += ( + _3ds_exe_name + '.smdh' # outfile + ) + + + + APP_SMALL_ICON = meson.get_external_property('APP_SMALL_ICON', '') + + if APP_SMALL_ICON != '' + if not fs.is_absolute(APP_SMALL_ICON) + APP_SMALL_ICON = meson.project_source_root() / APP_SMALL_ICON + endif + + + if not fs.exists(APP_SMALL_ICON) + error( + 'APP_SMALL_ICON should exist, but doesn\'t: \'' + APP_SMALL_ICON + + '\'', + ) + endif + + SMDH_FLAGS += APP_SMALL_ICON + endif + + + + # smdhtool --create <_3ds_exe_name>.smdh [] + smdh_file = custom_target( + _3ds_exe_name + '.smdh', + command: SMDH_FLAGS, + output: [_3ds_exe_name + '.smdh'], + depends: SMDH_DEPS, + ) + _3DSX_FLAGS += '--smdh=' + _3ds_exe_name + '.smdh' + _3DSX_DEPS += smdh_file + +endif + + + +APP_ROMFS = meson.get_external_property('APP_ROMFS', '') + +if APP_ROMFS != '' + + if not fs.is_absolute(APP_ROMFS) + APP_ROMFS = meson.project_source_root() / APP_ROMFS + endif + + if not fs.exists(APP_ROMFS) + error('APP_ROMFS should exist, but doesn\'t: \'' + APP_ROMFS + '\'') + endif + + _3DSX_FLAGS += '--romfs=' + APP_ROMFS + +endif + +# 3dsxtool <_3ds_exe_name>.elf <_3ds_exe_name>.3dsx <_3DSX_FLAGS> +custom_target( + _3ds_exe_name + '.3dsx', + command: _3DSX_FLAGS, + depends: _3DSX_DEPS, + output: [_3ds_exe_name + '.3dsx'], + build_by_default: true, +) diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh new file mode 100755 index 00000000..8fba424f --- /dev/null +++ b/platforms/build-3ds.sh @@ -0,0 +1,252 @@ +#!/usr/bin/env bash + +set -e + +export DEVKITPRO="/opt/devkitpro" +export ARCH_DEVKIT_FOLDER="$DEVKITPRO/devkitARM" +export COMPILER_BIN="$ARCH_DEVKIT_FOLDER/bin" +export ARCH_DEVKIT_LIB="$ARCH_DEVKIT_FOLDER/lib" +export PATH="$DEVKITPRO/tools/bin:$COMPILER_BIN:$PATH" + +export PORTLIBS_PATH="$DEVKITPRO/portlibs" +export PORTLIBS_PATH_3DS="$PORTLIBS_PATH/3ds" +export LIBCTRU="$DEVKITPRO/libctru" + +export PORTLIBS_LIB="$PORTLIBS_PATH_3DS/lib" +export LIBCTRU_LIB="$LIBCTRU/lib" + +export PKG_CONFIG_PATH_PORTLIB="$PORTLIBS_LIB/pkgconfig/" +export PKG_CONFIG_PATH="$PKG_CONFIG_PATH_PORTLIB" + +export ROMFS="platforms/romfs" + +export BUILD_DIR="build-3ds" + +export TOOL_PREFIX="arm-none-eabi" + +export BIN_DIR="$PORTLIBS_PATH_3DS/bin" +export PKG_CONFIG_EXEC="$BIN_DIR/$TOOL_PREFIX-pkg-config" +export CMAKE="$BIN_DIR/$TOOL_PREFIX-cmake" + +export PATH="$BIN_DIR:$PATH" + +export CC="$COMPILER_BIN/$TOOL_PREFIX-gcc" +export CXX="$COMPILER_BIN/$TOOL_PREFIX-g"++ +export AS="$COMPILER_BIN/$TOOL_PREFIX-as" +export AR="$COMPILER_BIN/$TOOL_PREFIX-gcc-ar" +export RANLIB="$COMPILER_BIN/$TOOL_PREFIX-gcc-ranlib" +export NM="$COMPILER_BIN/$TOOL_PREFIX-gcc-nm" +export OBJCOPY="$COMPILER_BIN/$TOOL_PREFIX-objcopy" +export STRIP="$COMPILER_BIN/$TOOL_PREFIX-strip" + +export ARCH="arm" +export ARM_VERSION="arm11mpcore" +export ENDIANESS="little" + +export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard', '-mtp=soft','-mword-relocations', '-ffunction-sections', '-fdata-sections'" + +export COMPILE_FLAGS="'-D_3DS','-D__3DS__', '-isystem', '$LIBCTRU/include', '-I$PORTLIBS_PATH_3DS/include'" + +export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBCTRU_LIB','-fPIE','-specs=$ARCH_DEVKIT_FOLDER/$TOOL_PREFIX/lib/3dsx.specs'" + +export CROSS_FILE="./platforms/crossbuild-3ds.ini" + +cat <"$CROSS_FILE" +[host_machine] +system = '3ds' +cpu_family = '$ARCH' +cpu = '$ARM_VERSION' +endian = '$ENDIANESS' + +[target_machine] +system = '3ds' +cpu_family = '$ARCH' +cpu = '$ARM_VERSION' +endian = '$ENDIANESS' + +[constants] +devkitpro = '$DEVKITPRO' + +[binaries] +c = '$CC' +cpp = '$CXX' +ar = '$AR' +as = '$AS' +ranlib = '$RANLIB' +strip = '$STRIP' +objcopy = '$OBJCOPY' +nm = '$NM' +pkg-config = '$PKG_CONFIG_EXEC' +cmake='$CMAKE' +freetype-config='$BIN_DIR/freetype-config' +libpng16-config='$BIN_DIR/libpng16-config' +libpng-config='$BIN_DIR/libpng-config' +sdl2-config='$BIN_DIR/bin/sdl2-config' + +[built-in options] +c_std = 'c11' +cpp_std = 'c++20' +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] +cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] + + +[properties] +pkg_config_libdir = '$PKG_CONFIG_PATH' +needs_exe_wrapper = true +library_dirs= ['$LIBCTRU_LIB', '$PORTLIBS_LIB'] +libctru='$LIBCTRU' + +APP_NAME = 'sdl_example' +APP_AUTHOR = 'Totto16' +APP_DESC = 'SDL Example' + +USE_SMDH = true + +APP_ROMFS='$ROMFS' + +EOF + +## build sdl2 and libraries (ttf, mixer, image) + +export SDL_TOP_BUILD_DIR="SDL2_local_build_3ds" +export SDL_BUILD_DIR="build_dir" + +export SDL_ROOT_DIR="$PORTLIBS_PATH_3DS" + +mkdir -p "$SDL_TOP_BUILD_DIR" + +cd "$SDL_TOP_BUILD_DIR" || exit 1 + +echo "*" >.gitignore + +mkdir -p "$SDL_ROOT_DIR" + +# build sdl2 + +export SDL2_SRC_DIR="SDL2-2.28.5" + +if [ ! -d "$SDL2_SRC_DIR" ]; then + + wget "https://github.com/libsdl-org/SDL/releases/download/release-2.28.5/SDL2-2.28.5.tar.gz" + tar xzf SDL2-2.28.5.tar.gz + rm -rf SDL2-2.28.5.tar.gz + + cd $SDL2_SRC_DIR + + cmake -S. "-B$SDL_BUILD_DIR" -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$SDL_ROOT_DIR/" + cmake --build "$SDL_BUILD_DIR" + cmake --install "$SDL_BUILD_DIR" --prefix "$SDL_ROOT_DIR/" + + cd .. + +fi + +export SDL_CMAKE_DIR="$SDL_ROOT_DIR/lib/cmake/SDL2" + +# build sdl2_ttf + +export SDL2_TTF_SRC_DIR="SDL2_ttf-2.22.0" + +if [ ! -d "$SDL2_TTF_SRC_DIR" ]; then + + wget "https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.22.0/SDL2_ttf-2.22.0.tar.gz" + tar xzf SDL2_ttf-2.22.0.tar.gz + rm -rf SDL2_ttf-2.22.0.tar.gz + + cd $SDL2_TTF_SRC_DIR + + cmake -S. "-B$SDL_BUILD_DIR" -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release "-DSDL2_DIR=$SDL_CMAKE_DIR" "-DSDL2TTF_SAMPLES=OFF" "-DCMAKE_INSTALL_PREFIX=$SDL_ROOT_DIR/" + cmake --build "$SDL_BUILD_DIR" + cmake --install "$SDL_BUILD_DIR" --prefix "$SDL_ROOT_DIR/" + + cd .. + +fi + +# build sdl2_mixer + +export SDL2_MIXER_SRC_DIR="SDL2_mixer-2.8.0" + +if [ ! -d "$SDL2_MIXER_SRC_DIR" ]; then + + wget "https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.8.0/SDL2_mixer-2.8.0.tar.gz" + tar xzf SDL2_mixer-2.8.0.tar.gz + rm -rf SDL2_mixer-2.8.0.tar.gz + + cd $SDL2_MIXER_SRC_DIR + + cmake -S. "-B$SDL_BUILD_DIR" -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release "-DSDL2_DIR=$SDL_CMAKE_DIR" "-DSDL2MIXER_DEPS_SHARED=OFF" "-DSDL2MIXER_MIDI=OFF" "-DSDL2MIXER_WAVPACK=OFF" "-DCMAKE_INSTALL_PREFIX=$SDL_ROOT_DIR/" + cmake --build "$SDL_BUILD_DIR" + cmake --install "$SDL_BUILD_DIR" --prefix "$SDL_ROOT_DIR/" + + cd .. + +fi + +# build sdl2_image + +export SDL2_IMAGE_SRC_DIR="SDL2_image-2.8.2" + +if [ ! -d "$SDL2_IMAGE_SRC_DIR" ]; then + + wget "https://github.com/libsdl-org/SDL_image/releases/download/release-2.8.2/SDL2_image-2.8.2.tar.gz" + tar xzf SDL2_image-2.8.2.tar.gz + rm -rf SDL2_image-2.8.2.tar.gz + + cd $SDL2_IMAGE_SRC_DIR + + cmake -S. "-B$SDL_BUILD_DIR" -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release "-DSDL2_DIR=$SDL_CMAKE_DIR" "-DCMAKE_INSTALL_PREFIX=$SDL_ROOT_DIR/" + cmake --build "$SDL_BUILD_DIR" + cmake --install "$SDL_BUILD_DIR" --prefix "$SDL_ROOT_DIR/" + + cd .. + +fi + +# exit the build tree + +cd .. + +## options: "smart, complete_rebuild" +export COMPILE_TYPE="smart" + +if [ "$#" -eq 0 ]; then + # nothing + echo "Using compile type '$COMPILE_TYPE'" +elif [ "$#" -eq 1 ]; then + COMPILE_TYPE="$1" +else + echo "Too many arguments given, expected at most 1" + exit 1 +fi + +if [ "$COMPILE_TYPE" == "smart" ]; then + : # noop +elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then + : # noop +else + echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'" + exit 1 +fi + +if [ ! -d "$ROMFS" ]; then + + mkdir -p $ROMFS + + cp -r assets $ROMFS + +fi + +if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then + + meson setup "$BUILD_DIR" \ + "--wipe" \ + --cross-file "$CROSS_FILE" \ + -Dbuildtype=release \ + -Ddefault_library=static + +fi + +meson compile -C "$BUILD_DIR" diff --git a/platforms/build-android.sh b/platforms/build-android.sh index 99e966d5..39cc64ed 100755 --- a/platforms/build-android.sh +++ b/platforms/build-android.sh @@ -68,7 +68,7 @@ elif [ "$#" -eq 1 ]; then ARCH_KEYS_INDEX=("$FOUND") else - echo "Too many argumetns given, expected at most 1" + echo "Too many arguments given, expected at most 1" exit 1 fi diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 1669247d..9f92bbe4 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -2,36 +2,34 @@ set -e -## options: "smart, complete_rebuild" -export COMPILE_TYPE="smart" - -export DEVKITPRO=/opt/devkitpro -export COMPILER_BIN="$DEVKITPRO/devkitA64/bin" +export DEVKITPRO="/opt/devkitpro" +export ARCH_DEVKIT_FOLDER="$DEVKITPRO/devkitA64" +export COMPILER_BIN="$ARCH_DEVKIT_FOLDER/bin" export PATH="$DEVKITPRO/tools/bin:$COMPILER_BIN:$PATH" export PORTLIBS_PATH="$DEVKITPRO/portlibs" -export LIBNX=$DEVKITPRO/libnx +export PORTLIBS_PATH_SWITCH="$PORTLIBS_PATH/switch" +export LIBNX="$DEVKITPRO/libnx" -export PORTLIBS_LIB=$PORTLIBS_PATH/switch/lib -export LIBNX_LIB=$LIBNX/lib +export PORTLIBS_LIB="$PORTLIBS_PATH_SWITCH/lib" +export LIBNX_LIB="$LIBNX/lib" export PKG_CONFIG_PATH="$PORTLIBS_LIB/pkgconfig/" -export ROMFS=platforms/romfs +export ROMFS="platforms/romfs" export BUILD_DIR="build-switch" -export TOOL_PREFIX=aarch64-none-elf +export TOOL_PREFIX="aarch64-none-elf" -export BIN_DIR=/opt/devkitpro/portlibs/switch/bin -export PKG_CONFIG_EXEC=$BIN_DIR/$TOOL_PREFIX-pkg-config +export BIN_DIR="$PORTLIBS_PATH_SWITCH/bin" +export PKG_CONFIG_EXEC="$BIN_DIR/$TOOL_PREFIX-pkg-config" export CMAKE="$BIN_DIR/$TOOL_PREFIX-cmake" export PATH="$BIN_DIR:$PATH" export CC="$COMPILER_BIN/$TOOL_PREFIX-gcc" export CXX="$COMPILER_BIN/$TOOL_PREFIX-g"++ -# export LD="$COMPILER_BIN/$TOOL_PREFIX-ld" export AS="$COMPILER_BIN/$TOOL_PREFIX-as" export AR="$COMPILER_BIN/$TOOL_PREFIX-gcc-ar" export RANLIB="$COMPILER_BIN/$TOOL_PREFIX-gcc-ranlib" @@ -39,21 +37,30 @@ export NM="$COMPILER_BIN/$TOOL_PREFIX-gcc-nm" export OBJCOPY="$COMPILER_BIN/$TOOL_PREFIX-objcopy" export STRIP="$COMPILER_BIN/$TOOL_PREFIX-strip" -export ARCH=aarch64 -export ARM_VERSION=armv8-a -export COMMON_FLAGS="'-D__SWITCH__','-D__LIBNX__','-DNOSTYLUS','-D_XOPEN_SOURCE'" +export ARCH="aarch64" +export CPU_ARCH="cortex-a57" +export ENDIANESS="little" -export ARCH_ARGS="'-march=armv8-a','-mtp=soft','-fPIE'" +export COMMON_FLAGS="'-ftls-model=local-exec','-march=armv8-a+crc+crypto','-mtune=cortex-a57','-mtp=soft','-ftls-model=local-exec','-fPIC','-ffunction-sections','-fdata-sections'" -export LD_LIBS_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB'" -export ASFLAGS="-g $ARCH_ARGS" +export COMPILE_FLAGS="'-D__SWITCH__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'" -cat <"./platforms/crossbuild-switch.ini" +export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB','-fPIE','-specs=$DEVKITPRO/libnx/switch.specs'" + +export CROSS_FILE="./platforms/crossbuild-switch.ini" + +cat <"$CROSS_FILE" [host_machine] system = 'switch' cpu_family = '$ARCH' -cpu = '$ARM_VERSION' -endian = 'little' +cpu = '$CPU_ARCH' +endian = '$ENDIANESS' + +[target_machine] +system = 'switch' +cpu_family = '$ARCH' +cpu = '$CPU_ARCH' +endian = '$ENDIANESS' [constants] devkitpro = '$DEVKITPRO' @@ -76,29 +83,42 @@ sdl2-config='$BIN_DIR/sdl2-config' [built-in options] c_std = 'c11' -cpp_std = 'c++23' -c_args = [$ARCH_ARGS,$COMMON_FLAGS] -cpp_args = [$ARCH_ARGS,$COMMON_FLAGS] -c_link_args = ['-specs=$DEVKITPRO/libnx/switch.specs','-g', $ARCH_ARGS, $LD_LIBS_FLAGS] -cpp_link_args = ['-specs=$DEVKITPRO/libnx/switch.specs','-g', $ARCH_ARGS, $LD_LIBS_FLAGS] +cpp_std = 'c++20' +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] +cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] [properties] pkg_config_libdir = '$PKG_CONFIG_PATH' needs_exe_wrapper = true library_dirs= ['$LIBNX_LIB', '$PORTLIBS_LIB'] -romfs_dir='$ROMFS' libnx='$LIBNX' -APP_ICON='$ROMFS/assets/icon/512x512.png' -USE_NACP = true -APP_TITLE = 'oopetris' -APP_AUTHOR = 'coder2k' +APP_NAME = 'sdl_example' +APP_AUTHOR = 'Totto16' APP_VERSION = '1.0' +USE_NACP = true + +APP_ROMFS='$ROMFS' EOF +## options: "smart, complete_rebuild" +export COMPILE_TYPE="smart" + +if [ "$#" -eq 0 ]; then + # nothing + echo "Using compile type '$COMPILE_TYPE'" +elif [ "$#" -eq 1 ]; then + COMPILE_TYPE="$1" +else + echo "Too many arguments given, expected at most 1" + exit 1 +fi + if [ "$COMPILE_TYPE" == "smart" ]; then : # noop elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then @@ -108,15 +128,19 @@ else exit 1 fi -mkdir -p $ROMFS +if [ ! -d "$ROMFS" ]; then + + mkdir -p $ROMFS -cp -r assets $ROMFS + cp -r assets $ROMFS + +fi if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then meson setup "$BUILD_DIR" \ "--wipe" \ - --cross-file "./platforms/crossbuild-switch.ini" \ + --cross-file "$CROSS_FILE" \ -Dbuildtype=release \ -Ddefault_library=static diff --git a/platforms/switch/meson.build b/platforms/switch/meson.build new file mode 100644 index 00000000..01f6f4c2 --- /dev/null +++ b/platforms/switch/meson.build @@ -0,0 +1,180 @@ + +## get the options object and "unpack" it + +switch_exe_name = switch_options[0] +switch_src_files = switch_options[1] +switch_deps = switch_options[2] + + +# libraries + +switch_dependencies = [ + 'harfbuzz', + 'egl', + 'flac', + 'freetype2', + 'glapi', + 'glesv2', + 'ogg', + 'opus', + 'opusfile', + 'vorbis', + 'vorbisfile', + 'zlib', +] + +switch_dependencies_native = [ + 'bz2', + 'drm_nouveau', + 'modplug', + 'nx', + 'png16', + 'SDL2main', +] + + +foreach dep : switch_dependencies + switch_deps += dependency( + dep, + required: true, + allow_fallback: false, + native: false, + ) +endforeach + +switch_library_dirs = meson.get_external_property('library_dirs', ['']) +if switch_library_dirs.length() == 0 + error('property \'library_dirs\' has to be set!') +endif + +c = meson.get_compiler('c') +foreach dep : switch_dependencies_native + switch_deps += c.find_library( + dep, + required: true, + dirs: switch_library_dirs, + ) +endforeach + + + +## compilation + +switch_elf_file = build_target( + switch_exe_name + '.elf', + switch_src_files, + dependencies: switch_deps, + override_options: { + 'warning_level': '3', + 'werror': true, + }, + native: false, + target_type: 'executable', +) + +use_nacp = ['true', 'True', '1', true].contains( + meson.get_external_property('USE_NACP', ''), +) + + +elf2nro = find_program('elf2nro') +# executable input elf file, output nro file +NRO_FLAGS = [elf2nro, switch_elf_file.full_path(), switch_exe_name + '.nro'] +NRO_DEPS = [switch_elf_file] +NACP_DEPS = NRO_DEPS + +fs = import('fs') + +if use_nacp + nacptool = find_program('nacptool') + NACP_FLAGS = [nacptool, '--create'] + + APP_NAME = meson.get_external_property('APP_NAME', switch_exe_name) + NACP_FLAGS += APP_NAME + + + APP_AUTHOR = meson.get_external_property('APP_AUTHOR', '') + if APP_AUTHOR == '' + error('If USE_NACP is set, you have to provide an APP_AUTHOR') + endif + NACP_FLAGS += APP_AUTHOR + + APP_VERSION = meson.get_external_property('APP_VERSION', '') + if APP_VERSION == '' + error('If USE_NACP is set, you have to provide an APP_VERSION') + endif + NACP_FLAGS += APP_VERSION + + NACP_FLAGS += ( + switch_exe_name + '.nacp' # outfile + ) + + + APP_TITLEID = meson.get_external_property('APP_TITLEID', '') + + # optional + if APP_TITLEID != '' + NACP_FLAGS += '--titleid=' + APP_TITLEID + endif + + + # nacptool --create .nacp + # optional: --titleid= + nacp_file = custom_target( + switch_exe_name + '.nacp', + command: NACP_FLAGS, + output: [switch_exe_name + '.nacp'], + depends: NACP_DEPS, + ) + NRO_FLAGS += '--nacp=' + switch_exe_name + '.nacp' + NRO_DEPS += nacp_file + + +endif + +LIBNX = meson.get_external_property('libnx', '') +if LIBNX == '' + error('property \'libnx\' has to be set!') +endif + +switch_default_icon = LIBNX / 'default_icon.jpg' + +APP_ICON = meson.get_external_property('APP_ICON', switch_default_icon) + +if not fs.is_absolute(APP_ICON) + APP_ICON = meson.project_source_root() / APP_ICON +endif + + +if not fs.exists(APP_ICON) + error('APP_ICON should exist, but doesn\'t: \'' + APP_ICON + '\'') +endif + + + +NRO_FLAGS += '--icon=' + APP_ICON + + +APP_ROMFS = meson.get_external_property('APP_ROMFS', '') + +if APP_ROMFS != '' + if not fs.is_absolute(APP_ROMFS) + APP_ROMFS = meson.project_source_root() / APP_ROMFS + endif + + if not fs.exists(APP_ROMFS) + error('APP_ROMFS should exist, but doesn\'t: \'' + APP_ROMFS + '\'') + endif + + NRO_FLAGS += '--romfsdir=' + APP_ROMFS + +endif + +# elf2nro .elf .nro +custom_target( + switch_exe_name + '.nro', + command: NRO_FLAGS, + depends: NRO_DEPS, + output: [switch_exe_name + '.nro'], + build_by_default: true, +) diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build new file mode 100644 index 00000000..190747cf --- /dev/null +++ b/tools/dependencies/meson.build @@ -0,0 +1,289 @@ + + +only_allow_native_libs = false +if meson.is_cross_build() + if host_machine.system() == 'switch' + # we do not link to code that was compiled with gcc 10.1, the code we link with is all compiled with gcc 13.2 + core_lib += { + 'compile_args': [core_lib.get('compile_args'), '-Wno-psabi'], + } + + only_allow_native_libs = true + endif +endif + + + + +sdl2_dep = dependency( + 'sdl2', + 'SDL2', + allow_fallback: false, + required: only_allow_native_libs, +) + +if sdl2_dep.found() + graphics_lib += { + 'deps': [graphics_lib.get('deps'), sdl2_dep], + } +else + sdl2_dep = dependency( + 'sdl2', + required: true, + default_options: {'test': false}, + ) + sdl2main_dep = dependency( + 'sdl2main', + required: true, + fallback: 'sdl2', + ) + + graphic_application_deps += sdl2main_dep + + graphics_lib += { + 'deps': [graphics_lib.get('deps'), sdl2_dep], + } +endif + +sdl2_ttf_dep = dependency( + 'sdl2_ttf', + 'SDL2_ttf', + allow_fallback: not only_allow_native_libs, + required: true, +) +graphics_lib += { + 'deps': [graphics_lib.get('deps'), sdl2_ttf_dep], +} + +sdl2_image_dep = dependency( + 'sdl2_image', + 'SDL2_image', + allow_fallback: not only_allow_native_libs, + required: true, +) +graphics_lib += { + 'deps': [graphics_lib.get('deps'), sdl2_image_dep], +} + +# a dirty thing atm, until mpg123 is ported to meson (maybe never...) +mpg123_dep = dependency( + 'mpg123', + allow_fallback: true, + required: false, +) +sdl2_mixer_flags = {'flac': 'enabled'} +sdl2_mixer_defines = ['-DAUDIO_WITH_FLAC_SUPPORT'] +if mpg123_dep.found() + sdl2_mixer_flags += {'mpg123': 'enabled'} + sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' +else + mpg123_dep = cpp.find_library('mpg123', required: only_allow_native_libs) + if mpg123_dep.found() + sdl2_mixer_flags += {'mpg123': 'enabled'} + sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' + + meson.override_dependency('mpg123', mpg123_dep) + endif +endif + + + +sdl2_mixer_dep = dependency( + 'sdl2_mixer', + 'SDL2_mixer', + allow_fallback: not only_allow_native_libs, + required: true, + default_options: sdl2_mixer_flags, +) +graphics_lib += { + 'deps': [graphics_lib.get('deps'), sdl2_mixer_dep], + 'compile_args': [graphics_lib.get('compile_args'), sdl2_mixer_defines], +} + +if (meson.is_cross_build() and host_machine.system() == 'switch') + + fmt_lib = dependency( + 'fmt', + required: false, + allow_fallback: false, + ) + + if fmt_lib.found() + core_lib += {'deps': [core_lib.get('deps'), fmt_lib]} + else + + fmt_header_only_dep = dependency( + 'fmt_header_only', + required: true, + allow_fallback: true, + default_options: {'default_library': 'static'}, + ) + + meson.override_dependency('fmt', fmt_header_only_dep) + + core_lib += {'deps': [core_lib.get('deps'), fmt_header_only_dep]} + endif + +else + + # clang with libc++ creates some really long and confusing linker errors, so just use the header only library + if cpp.get_id() == 'clang' and build_with_libcpp + fmt_dep = dependency( + 'fmt_header_only', + required: true, + allow_fallback: true, + default_options: {'default_library': 'static'}, + ) + meson.override_dependency('fmt', fmt_dep) + else + fmt_dep = dependency( + 'fmt', + required: true, + ) + endif + + + core_lib += {'deps': [core_lib.get('deps'), fmt_dep]} +endif + +spdlog_dep = dependency( + 'spdlog', + required: true, + default_options: {'tests': 'disabled'}, +) +graphics_lib += {'deps': [graphics_lib.get('deps'), spdlog_dep]} + +nlohmann_json_dep = dependency( + 'nlohmann_json', + required: true, +) +core_lib += {'deps': [core_lib.get('deps'), nlohmann_json_dep]} + +# check std::expected support +have_std_expected = cpp.compiles( + ''' +#include +int main() { + using T = std::expected; + return 0; +} +''', + args: core_lib.get('compile_args'), +) + +if not have_std_expected + message('Compiler doesn\'t support std::expected, using fallback') + + tl_exp_dep = dependency('tl-expected', required: true) + core_lib += { + 'compile_args': [core_lib.get('compile_args'), '-D_USE_TL_EXPECTED'], + 'deps': [core_lib.get('deps'), tl_exp_dep], + } +else + message('Compiler support std::expected, using that') +endif + +# check std::optional support +have_std_optional = cpp.compiles( + ''' +#include +int main() { + using T = std::optional; + return 0; +} +''', + args: core_lib.get('compile_args'), +) + +if not have_std_optional + message('Compiler doesn\'t support std::optional, using fallback') + tl_opt_dep = dependency('tl-optional', required: true) + core_lib += { + 'compile_args': [core_lib.get('compile_args'), '-D_USE_TL_OPTIONAL'], + 'deps': [core_lib.get('deps'), tl_opt_dep], + } +else + message('Compiler support std::optional, using that') +endif + + + +magic_enum_dep = dependency( + 'magic_enum', + required: true, + default_options: {'test': false}, +) +core_lib += {'deps': [core_lib.get('deps'), magic_enum_dep]} + +argparse_dep = dependency('argparse', required: true) +core_lib += {'deps': [core_lib.get('deps'), argparse_dep]} + +online_multiplayer_supported = true + + +if meson.is_cross_build() and host_machine.system() == 'switch' + online_multiplayer_supported = false + core_lib += { + 'compile_args': [ + core_lib.get('compile_args'), + '-D_ONLINE_MULTIPLAYER_NOT_SUPPORTED', + ], + } +else + cpp_httlib_dep = dependency( + 'cpp-httplib', + required: true, + default_options: { + 'cpp-httplib_openssl': 'enabled', + 'cpp-httplib_zlib': 'enabled', + }, + ) + core_lib += {'deps': [core_lib.get('deps'), cpp_httlib_dep]} +endif + +utf8cpp_dep = dependency( + 'utf8cpp', + required: true, + version: '>=4.0.0', +) +core_lib += {'deps': [core_lib.get('deps'), utf8cpp_dep]} + +is_flatpak_build = get_option('flatpak_build') + +have_file_dialogs = false +have_discord_sdk = false + + +nfde_dep = dependency( + 'nativefiledialog-extended', + required: not meson.is_cross_build(), + default_options: { + 'xdg-desktop-portal': is_flatpak_build ? 'enabled' : 'auto', + }, +) +if nfde_dep.found() + have_file_dialogs = true + graphics_lib += { + 'compile_args': [ + graphics_lib.get('compile_args'), + '-D_HAVE_FILE_DIALOGS', + ], + 'deps': [graphics_lib.get('deps'), nfde_dep], + } +endif + +discord_sdk_dep = dependency( + 'discord-game-sdk', + required: not meson.is_cross_build(), + default_options: {'clang_libcpp': 'disabled'}, +) +if discord_sdk_dep.found() + have_discord_sdk = true + graphics_lib += { + 'compile_args': [ + graphics_lib.get('compile_args'), + '-D_HAVE_DISCORD_SDK', + ], + 'deps': [graphics_lib.get('deps'), discord_sdk_dep], + } +endif diff --git a/tools/install/meson.build b/tools/install/meson.build new file mode 100644 index 00000000..239ca775 --- /dev/null +++ b/tools/install/meson.build @@ -0,0 +1,94 @@ + +## TODO: only install needed ones, since sometimes we only need e.g. flacs or mp3 and no icons etc. +## install assets +install_subdir( + 'assets', + install_dir: 'share/oopetris', + exclude_files: ['oopetris.desktop.in', 'OOPetris.svg', 'recordings.magic'], + exclude_directories: ['icon'], +) + +app_name = 'oopetris' +if is_flatpak_build + app_name = 'com.github.mgerhold.OOPetris' + core_lib += { + 'compile_args': [ + core_lib.get('compile_args'), + '-DFLATPAK_BUILD', + '-DBUILD_INSTALLER', + ], + } +endif + +conf = configuration_data() +conf.set('APP_NAME', app_name) + +datadir = get_option('prefix') / get_option('datadir') + + +if host_machine.system() == 'linux' + + fs = import('fs') + + magic_dir = datadir / 'misc' + magic_file = magic_dir / 'magic' + oopetris_magic_file = ( + meson.project_source_root() / 'assets' / 'recordings.magic' + ) + + if fs.exists(magic_file) + + cat_prog = find_program('cat') + + custom_target( + 'magic_file_append', + command: [cat_prog, '@INPUT@'], + capture: true, + input: [oopetris_magic_file, magic_file], + output: 'magic', + install_dir: magic_dir, + ) + + else + + install_data( + oopetris_magic_file, + install_dir: magic_dir, + rename: ['magic'], + ) + + endif +endif + +configure_file( + input: meson.project_source_root() / 'assets/oopetris.desktop.in', + output: app_name + '.desktop', + configuration: conf, + install: true, + install_dir: datadir / 'applications', +) + +logos = [ + '24x24.png', + '48x48.png', + '64x64.png', + '72x72.png', + '96x96.png', + '128x128.png', + '144x144.png', + '160x160.png', + '192x192.png', + '256x256.png', + '512x512.png', + 'scalable.svg', +] + +foreach logo : logos + name = logo.split('.')[0] + ext = logo.split('.')[1] + install_data( + meson.project_source_root() / 'assets' / 'icon' / logo, + install_dir: datadir / 'icons' / 'hicolor' / name / 'apps', + rename: [app_name + '.' + ext], + ) +endforeach diff --git a/tools/options/meson.build b/tools/options/meson.build new file mode 100644 index 00000000..09a67073 --- /dev/null +++ b/tools/options/meson.build @@ -0,0 +1,72 @@ + +core_lib = { + 'src_files': [], + 'inc_dirs': [], + 'compile_args': ['-DOOPETRIS_VERSION=' + meson.project_version()], + 'deps': [], +} + +recordings_lib = { + 'src_files': [], + 'inc_dirs': [], + 'compile_args': [], + 'deps': [], +} + +graphics_lib = { + 'src_files': [], + 'inc_dirs': [], + 'compile_args': [], + 'deps': [], +} + +global_deps = [] +graphic_application_deps = [] + + +cpp = meson.get_compiler('cpp') + +build_with_libcpp = false + +if cpp.get_id() == 'gcc' + add_project_arguments('-Wold-style-cast', language: ['cpp']) +elif cpp.get_id() == 'clang' + + build_with_libcpp_option = get_option('clang_libcpp') + + build_with_libcpp = build_with_libcpp_option.enabled() + + if build_with_libcpp_option.auto() + if host_machine.system() == 'darwin' + build_with_libcpp = true + else + + cpp_lib = cpp.find_library('c++', required: false) + cppabi_lib = cpp.find_library('c++abi', required: false) + + if cpp_lib.found() and cppabi_lib.found() + build_with_libcpp = true + else + build_with_libcpp = false + endif + endif + endif + + if build_with_libcpp + add_global_link_arguments('-stdlib=libc++', language: ['cpp']) + add_global_arguments('-stdlib=libc++', language: ['cpp']) + global_deps += [cpp.find_library('c++'), cpp.find_library('c++abi')] + endif + +endif + +if ( + get_option('buildtype') == 'debug' + or get_option('buildtype') == 'debugoptimized' +) + core_lib += { + 'compile_args': [core_lib.get('compile_args'), '-DDEBUG_BUILD'], + } +endif + + From 1112168e3bb0f900f1d7504fd1ab59c0faaa4af2 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 17:28:26 +0200 Subject: [PATCH 02/19] fix 3ds and switch build options in the build configuration --- assets/oopetris.desktop.in | 2 +- meson.build | 2 - platforms/build-3ds.sh | 15 +++--- platforms/build-switch.sh | 15 +++--- tools/dependencies/meson.build | 86 +++++++++++++++------------------- tools/install/meson.build | 2 +- 6 files changed, 59 insertions(+), 63 deletions(-) diff --git a/assets/oopetris.desktop.in b/assets/oopetris.desktop.in index 5837cd1f..bcc24871 100644 --- a/assets/oopetris.desktop.in +++ b/assets/oopetris.desktop.in @@ -2,7 +2,7 @@ Version=1.0 Type=Application Name=OOPetris -Comment=A tetris clone in OOP +Comment=A Tetris clone in OOP Exec=oopetris Icon=@APP_NAME@ Terminal=false diff --git a/meson.build b/meson.build index 42ee0457..b7546c6b 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,6 @@ project( version: '0.5.3', ) - subdir('tools/options') subdir('tools/dependencies') @@ -75,7 +74,6 @@ else endif - if get_option('tests') subdir('tests') endif diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh index 8fba424f..890f256e 100755 --- a/platforms/build-3ds.sh +++ b/platforms/build-3ds.sh @@ -45,6 +45,9 @@ export ENDIANESS="little" export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard', '-mtp=soft','-mword-relocations', '-ffunction-sections', '-fdata-sections'" +# compat flags for some POSIX functions +export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'" + export COMPILE_FLAGS="'-D_3DS','-D__3DS__', '-isystem', '$LIBCTRU/include', '-I$PORTLIBS_PATH_3DS/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBCTRU_LIB','-fPIE','-specs=$ARCH_DEVKIT_FOLDER/$TOOL_PREFIX/lib/3dsx.specs'" @@ -85,9 +88,9 @@ sdl2-config='$BIN_DIR/bin/sdl2-config' [built-in options] c_std = 'c11' -cpp_std = 'c++20' -c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] -cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +cpp_std = 'c++23' +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] @@ -98,9 +101,9 @@ needs_exe_wrapper = true library_dirs= ['$LIBCTRU_LIB', '$PORTLIBS_LIB'] libctru='$LIBCTRU' -APP_NAME = 'sdl_example' -APP_AUTHOR = 'Totto16' -APP_DESC = 'SDL Example' +APP_NAME = 'oopetris' +APP_AUTHOR = 'coder2k' +APP_DESC = 'A Tetris clone in OOP' USE_SMDH = true diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 9f92bbe4..716ad60c 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -43,6 +43,9 @@ export ENDIANESS="little" export COMMON_FLAGS="'-ftls-model=local-exec','-march=armv8-a+crc+crypto','-mtune=cortex-a57','-mtp=soft','-ftls-model=local-exec','-fPIC','-ffunction-sections','-fdata-sections'" +# compat flags for some POSIX functions +export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'" + export COMPILE_FLAGS="'-D__SWITCH__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB','-fPIE','-specs=$DEVKITPRO/libnx/switch.specs'" @@ -83,9 +86,9 @@ sdl2-config='$BIN_DIR/sdl2-config' [built-in options] c_std = 'c11' -cpp_std = 'c++20' -c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] -cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +cpp_std = 'c++23' +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] @@ -96,9 +99,9 @@ needs_exe_wrapper = true library_dirs= ['$LIBNX_LIB', '$PORTLIBS_LIB'] libnx='$LIBNX' -APP_NAME = 'sdl_example' -APP_AUTHOR = 'Totto16' -APP_VERSION = '1.0' +APP_NAME = 'oopetris' +APP_AUTHOR = 'coder2k' +APP_VERSION = '0.5.3' USE_NACP = true diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build index 190747cf..947baf56 100644 --- a/tools/dependencies/meson.build +++ b/tools/dependencies/meson.build @@ -2,8 +2,8 @@ only_allow_native_libs = false if meson.is_cross_build() - if host_machine.system() == 'switch' - # we do not link to code that was compiled with gcc 10.1, the code we link with is all compiled with gcc 13.2 + if host_machine.system() == 'switch' or host_machine.system() == '3ds' + # we do not link to code that was compiled with gcc 10.1 / gcc 7.1, the code we link with is all compiled with gcc 13.2 core_lib += { 'compile_args': [core_lib.get('compile_args'), '-Wno-psabi'], } @@ -14,7 +14,6 @@ endif - sdl2_dep = dependency( 'sdl2', 'SDL2', @@ -77,7 +76,7 @@ if mpg123_dep.found() sdl2_mixer_flags += {'mpg123': 'enabled'} sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' else - mpg123_dep = cpp.find_library('mpg123', required: only_allow_native_libs) + mpg123_dep = cpp.find_library('mpg123', required: false) if mpg123_dep.found() sdl2_mixer_flags += {'mpg123': 'enabled'} sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' @@ -87,7 +86,6 @@ else endif - sdl2_mixer_dep = dependency( 'sdl2_mixer', 'SDL2_mixer', @@ -100,58 +98,49 @@ graphics_lib += { 'compile_args': [graphics_lib.get('compile_args'), sdl2_mixer_defines], } -if (meson.is_cross_build() and host_machine.system() == 'switch') - - fmt_lib = dependency( - 'fmt', - required: false, - allow_fallback: false, - ) - - if fmt_lib.found() - core_lib += {'deps': [core_lib.get('deps'), fmt_lib]} - else - - fmt_header_only_dep = dependency( - 'fmt_header_only', - required: true, - allow_fallback: true, - default_options: {'default_library': 'static'}, - ) +fmt_use_header_only = false - meson.override_dependency('fmt', fmt_header_only_dep) +if ( + meson.is_cross_build() + and (host_machine.system() == 'switch' + or host_machine.system() == '3ds') +) + fmt_use_header_only = true + # clang with libc++ creates some really long and confusing linker errors, so just use the header only library +elif cpp.get_id() == 'clang' and build_with_libcpp + fmt_use_header_only = true +endif - core_lib += {'deps': [core_lib.get('deps'), fmt_header_only_dep]} - endif +if fmt_use_header_only + fmt_header_only_dep = dependency( + 'fmt_header_only', + required: true, + allow_fallback: true, + ) + meson.override_dependency('fmt', fmt_header_only_dep) + fmt_dep = fmt_header_only_dep else + fmt_dep = dependency('fmt', required: true, allow_fallback: true) +endif - # clang with libc++ creates some really long and confusing linker errors, so just use the header only library - if cpp.get_id() == 'clang' and build_with_libcpp - fmt_dep = dependency( - 'fmt_header_only', - required: true, - allow_fallback: true, - default_options: {'default_library': 'static'}, - ) - meson.override_dependency('fmt', fmt_dep) - else - fmt_dep = dependency( - 'fmt', - required: true, - ) - endif - +core_lib += {'deps': [core_lib.get('deps'), fmt_dep]} - core_lib += {'deps': [core_lib.get('deps'), fmt_dep]} -endif spdlog_dep = dependency( 'spdlog', required: true, default_options: {'tests': 'disabled'}, ) -graphics_lib += {'deps': [graphics_lib.get('deps'), spdlog_dep]} +graphics_lib += { + 'deps': [graphics_lib.get('deps'), spdlog_dep], +} + +if (meson.is_cross_build() and host_machine.system() == '3ds') + graphics_lib += { + 'compile_args': [graphics_lib.get('compile_args'), '-DSPDLOG_NO_TLS'], + } +endif nlohmann_json_dep = dependency( 'nlohmann_json', @@ -221,7 +210,11 @@ core_lib += {'deps': [core_lib.get('deps'), argparse_dep]} online_multiplayer_supported = true -if meson.is_cross_build() and host_machine.system() == 'switch' +if ( + meson.is_cross_build() + and (host_machine.system() == 'switch' + or host_machine.system() == '3ds') +) online_multiplayer_supported = false core_lib += { 'compile_args': [ @@ -275,7 +268,6 @@ endif discord_sdk_dep = dependency( 'discord-game-sdk', required: not meson.is_cross_build(), - default_options: {'clang_libcpp': 'disabled'}, ) if discord_sdk_dep.found() have_discord_sdk = true diff --git a/tools/install/meson.build b/tools/install/meson.build index 239ca775..2fbedbd9 100644 --- a/tools/install/meson.build +++ b/tools/install/meson.build @@ -2,7 +2,7 @@ ## TODO: only install needed ones, since sometimes we only need e.g. flacs or mp3 and no icons etc. ## install assets install_subdir( - 'assets', + meson.project_source_root() / 'assets', install_dir: 'share/oopetris', exclude_files: ['oopetris.desktop.in', 'OOPetris.svg', 'recordings.magic'], exclude_directories: ['icon'], From 43113addb3fa8ab521ebbc2a542eb919afd88cc6 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 17:29:44 +0200 Subject: [PATCH 03/19] fix 3ds build in c++ files, fix some things that differ in 32 bit vs 64 bit environments --- src/application.cpp | 2 +- src/graphics/renderer.hpp | 2 +- src/graphics/texture.cpp | 3 ++- src/helper/command_line_arguments.hpp | 4 +--- src/main.cpp | 4 ++++ src/platform/capabilities.cpp | 5 +++-- src/thirdparty/hash-library/sha256.cpp | 7 +++++++ 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 01078880..1039df55 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -52,7 +52,7 @@ void Application::run() { #ifdef DEBUG_BUILD auto start_time = SDL_GetPerformanceCounter(); const auto update_time = SDL_GetPerformanceFrequency() / 2; //0.5 s - const double count_per_s = static_cast(SDL_GetPerformanceFrequency()); + const auto count_per_s = static_cast(SDL_GetPerformanceFrequency()); u64 frame_counter = 0; #endif using namespace std::chrono_literals; diff --git a/src/graphics/renderer.hpp b/src/graphics/renderer.hpp index e07dce95..2686201f 100644 --- a/src/graphics/renderer.hpp +++ b/src/graphics/renderer.hpp @@ -93,5 +93,5 @@ struct Renderer final { void present() const; private: - void draw_self_computed_circle_impl(const shapes::IPoint& center, int diameter) const; + void draw_self_computed_circle_impl(const shapes::IPoint& center, i32 diameter) const; }; diff --git a/src/graphics/texture.cpp b/src/graphics/texture.cpp index 46af02cd..65d64abd 100644 --- a/src/graphics/texture.cpp +++ b/src/graphics/texture.cpp @@ -1,5 +1,6 @@ #include "texture.hpp" +#include "graphics/point.hpp" #include "helper/graphic_utils.hpp" @@ -99,7 +100,7 @@ Texture::~Texture() { } [[nodiscard]] shapes::UPoint Texture::size() const { - shapes::IPoint size; + shapes::AbstractPoint size; const auto result = SDL_QueryTexture(m_raw_texture, nullptr, nullptr, &size.x, &size.y); if (result < 0) { diff --git a/src/helper/command_line_arguments.hpp b/src/helper/command_line_arguments.hpp index 9982ca71..2f372650 100644 --- a/src/helper/command_line_arguments.hpp +++ b/src/helper/command_line_arguments.hpp @@ -34,9 +34,7 @@ struct CommandLineArguments final { .default_value(default_starting_level); parser.add_argument("-s", "--silent").help("disable audio output").default_value(false).implicit_value(true); try { - if (not arguments.empty()) { - parser.parse_args(arguments); - } + parser.parse_args(arguments); if (auto path = parser.present("--recording")) { diff --git a/src/main.cpp b/src/main.cpp index d680f7d1..282e51d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,6 +51,10 @@ int main(int argc, char** argv) { arguments.emplace_back(argv[i]); //NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic) } + if (arguments.empty()) { + arguments.emplace_back("oopetris"); + } + constexpr auto window_name = constants::program_name.c_str(); std::unique_ptr window{ nullptr }; diff --git a/src/platform/capabilities.cpp b/src/platform/capabilities.cpp index ba93991c..362c2007 100644 --- a/src/platform/capabilities.cpp +++ b/src/platform/capabilities.cpp @@ -41,6 +41,8 @@ namespace { return "Android"; #elif defined(__SWITCH__) return "Nintendo Switch"; +#elif defined(__3DS__) + return "Nintendo 3DS"; #elif defined(FLATPAK_BUILD) return "Linux (Flatpak)"; #elif defined(__linux__) @@ -63,10 +65,9 @@ namespace { return false; } - return true; -#elif defined(__SWITCH__) +#elif defined(__SWITCH__) || defined(__3DS__) UNUSED(url); return false; #else diff --git a/src/thirdparty/hash-library/sha256.cpp b/src/thirdparty/hash-library/sha256.cpp index b651fe13..66edea18 100644 --- a/src/thirdparty/hash-library/sha256.cpp +++ b/src/thirdparty/hash-library/sha256.cpp @@ -20,6 +20,13 @@ #define __BYTE_ORDER __BYTE_ORDER__ #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ #endif +#elif defined(__3DS__) +#if !(defined(__BYTE_ORDER__) or defined(__ORDER_BIG_ENDIAN__)) +#error "__BYTE_ORDER__ or __ORDER_BIG_ENDIAN__ not defined"! +#else +#define __BYTE_ORDER __BYTE_ORDER__ +#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ +#endif #elif defined(__APPLE__) #include #else From 2c3d8401b605e41c4609f2a298d36ff1237a84d7 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 17:29:58 +0200 Subject: [PATCH 04/19] remove unused option from discord wrap --- .../packagefiles/discord_game_sdk/meson_options.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/subprojects/packagefiles/discord_game_sdk/meson_options.txt b/subprojects/packagefiles/discord_game_sdk/meson_options.txt index 3539dfde..847cd6dc 100644 --- a/subprojects/packagefiles/discord_game_sdk/meson_options.txt +++ b/subprojects/packagefiles/discord_game_sdk/meson_options.txt @@ -6,10 +6,3 @@ option( value: false, description: 'whether to built the examples', ) - -option( - 'clang_libcpp', - type: 'feature', - value: 'auto', - description: 'if using clang, build with libc++ instead of libstdc++ (gcc stdlib)', -) From c39beb06f7b6c25291e03fbe1ba2489395f6f04c Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 18:02:43 +0200 Subject: [PATCH 05/19] add specializations for 3ds specific behavior in some places --- src/application.cpp | 9 ++++++++- src/game/input_creator.cpp | 1 + src/graphics/sdl_context.cpp | 10 ++++++---- src/helper/graphic_utils.cpp | 2 +- src/main.cpp | 7 +------ src/platform/capabilities.cpp | 2 +- src/platform/platform.hpp | 2 +- src/platform/switch_buttons.hpp | 2 +- src/scenes/pause/pause.cpp | 1 + 9 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 1039df55..cc862e6f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -10,7 +10,9 @@ #include #if defined(__SWITCH__) -#include "switch.h" +#include +#elif defined(__3DS__) +#include <3ds.h> #endif namespace { @@ -63,10 +65,15 @@ void Application::run() { auto start_execution_time = std::chrono::steady_clock::now(); while (m_is_running + //TODO factor out #if defined(__SWITCH__) // see https://switchbrew.github.io/libnx/applet_8h.html#a7ed640e5f4a81ed3960c763fdc1521c5 // this checks for some other reasons why this app should quit, its switch specific and appletMainLoop() +#elif defined(__3DS__) + // see https://libctru.devkitpro.org/apt_8h.html#a84808c36d9a8c389896ecf241c7f89cb + // this checks for some other reasons why this app should quit, its 3ds specific + and aptMainLoop() #endif ) { diff --git a/src/game/input_creator.cpp b/src/game/input_creator.cpp index d3805e10..84181ca7 100644 --- a/src/game/input_creator.cpp +++ b/src/game/input_creator.cpp @@ -7,6 +7,7 @@ #include "platform/replay_input.hpp" #include +//TODO: support 3ds #if defined(__ANDROID__) #include "platform/android_input.hpp" #elif defined(__SWITCH__) diff --git a/src/graphics/sdl_context.cpp b/src/graphics/sdl_context.cpp index f34ba34f..c002ba65 100644 --- a/src/graphics/sdl_context.cpp +++ b/src/graphics/sdl_context.cpp @@ -6,7 +6,9 @@ #include #if defined(__SWITCH__) -#include "switch.h" +#include +#elif defined(__3DS__) +#include <3ds.h> #endif #if defined(_HAVE_FILE_DIALOGS) @@ -24,18 +26,18 @@ SdlContext::SdlContext() { throw helper::InitializationError{ fmt::format("Failed in initializing sdl ttf: {}", TTF_GetError()) }; } -#if defined(__SWITCH__) +#if defined(__SWITCH__) or defined(__3DS__) // based on: https://github.com/carstene1ns/switch-sdl2-demo // mount the romfs in the executable as "romfs:/" (this is fine since only one app can run at the time on the switch) romfsInit(); - // init joystick and other nintendo switch specific things + // init joystick and other nintendo switch / 3ds specific things SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_JoystickEventState(SDL_ENABLE); // only use the first joystick! - //TODO, since local multiplayer on a switch is possible, test here if there are more then one joysticks available (e.g. left and right controller) then ask the user if he wants to play local multiplayer, implement that in JoystickInput (in the SDL event the joystick index is present) + //TODO, since local multiplayer on a switch / 3ds is possible, test here if there are more then one joysticks available (e.g. left and right controller) then ask the user if he wants to play local multiplayer, implement that in JoystickInput (in the SDL event the joystick index is present) SDL_JoystickOpen(0); #endif diff --git a/src/helper/graphic_utils.cpp b/src/helper/graphic_utils.cpp index 5fc635c2..23730be3 100644 --- a/src/helper/graphic_utils.cpp +++ b/src/helper/graphic_utils.cpp @@ -55,7 +55,7 @@ std::vector utils::supported_features() { [[nodiscard]] std::filesystem::path utils::get_assets_folder() { #if defined(__ANDROID__) return std::filesystem::path{ "" }; -#elif defined(__SWITCH__) +#elif defined(__SWITCH__) or defined(__3DS__) // this is in the internal storage of the nintendo switch, it ios mounted by libnx (runtime switch support library) and filled at compile time with assets (its called ROMFS there) return std::filesystem::path{ "romfs:/assets" }; #elif defined(BUILD_INSTALLER) diff --git a/src/main.cpp b/src/main.cpp index 282e51d8..d1a1392f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,11 +15,6 @@ #include #include -#if defined(__SWITCH__) -#include "switch.h" -#include -#endif - int main(int argc, char** argv) { const auto logs_path = utils::get_root_folder() / "logs"; @@ -60,7 +55,7 @@ int main(int argc, char** argv) { std::unique_ptr window{ nullptr }; try { -#if defined(__ANDROID__) or defined(__SWITCH__) +#if defined(__ANDROID__) or defined(__SWITCH__) or defined(__3DS__) window = std::make_unique(window_name, WindowPosition::Centered); #else static constexpr int width = 1280; diff --git a/src/platform/capabilities.cpp b/src/platform/capabilities.cpp index 362c2007..9d5efe96 100644 --- a/src/platform/capabilities.cpp +++ b/src/platform/capabilities.cpp @@ -5,7 +5,7 @@ #include "helper/utils.hpp" #include "platform/capabilities.hpp" - +//TODO: support 3ds too #if defined(__SWITCH__) #include "platform/switch_buttons.hpp" #endif diff --git a/src/platform/platform.hpp b/src/platform/platform.hpp index cae3820f..a12db7be 100644 --- a/src/platform/platform.hpp +++ b/src/platform/platform.hpp @@ -23,7 +23,7 @@ namespace utils { #if defined(__ANDROID__) return "android"; -#elif defined(__SWITCH__) +#elif defined(__SWITCH__) or defined(__3DS__) return "console"; #else return "pc"; diff --git a/src/platform/switch_buttons.hpp b/src/platform/switch_buttons.hpp index a8f9971c..d130b50f 100644 --- a/src/platform/switch_buttons.hpp +++ b/src/platform/switch_buttons.hpp @@ -5,7 +5,7 @@ #if defined(__SWITCH__) -#include "switch.h" +#include // some switch buttons, from libnx, but since SDL doesn't handle inputs as flags, like libnx, the have to be reversed and reversing 1 << x = log_2(x), this is done constexpr diff --git a/src/scenes/pause/pause.cpp b/src/scenes/pause/pause.cpp index f57b7702..7ed41a5c 100644 --- a/src/scenes/pause/pause.cpp +++ b/src/scenes/pause/pause.cpp @@ -8,6 +8,7 @@ #if defined(__SWITCH__) #include "platform/switch_buttons.hpp" #endif + namespace scenes { Pause::Pause(ServiceProvider* service_provider, const ui::Layout& layout) : Scene{ service_provider, layout }, m_heading { From 2ae44c07ca80f8353bc615938f1a67dd1cefb9e8 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 18:34:17 +0200 Subject: [PATCH 06/19] - adding console helper, to factor out some common things from 3ds + switch - adding debug logger to the consoles --- platforms/build-3ds.sh | 6 ++-- platforms/build-android.sh | 6 ++-- platforms/build-switch.sh | 4 +-- src/application.cpp | 19 +++--------- src/helper/console_helpers.cpp | 56 ++++++++++++++++++++++++++++++++++ src/helper/console_helpers.hpp | 55 +++++++++++++++++++++++++++++++++ src/helper/meson.build | 2 ++ src/main.cpp | 4 ++- 8 files changed, 129 insertions(+), 23 deletions(-) create mode 100644 src/helper/console_helpers.cpp create mode 100644 src/helper/console_helpers.hpp diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh index 890f256e..1cb2f6f7 100755 --- a/platforms/build-3ds.sh +++ b/platforms/build-3ds.sh @@ -43,12 +43,12 @@ export ARCH="arm" export ARM_VERSION="arm11mpcore" export ENDIANESS="little" -export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard', '-mtp=soft','-mword-relocations', '-ffunction-sections', '-fdata-sections'" +export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard','-mtp=soft','-mword-relocations','-ffunction-sections','-fdata-sections'" # compat flags for some POSIX functions export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'" -export COMPILE_FLAGS="'-D_3DS','-D__3DS__', '-isystem', '$LIBCTRU/include', '-I$PORTLIBS_PATH_3DS/include'" +export COMPILE_FLAGS="'-D_3DS','-D__3DS__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBCTRU/include','-I$PORTLIBS_PATH_3DS/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBCTRU_LIB','-fPIE','-specs=$ARCH_DEVKIT_FOLDER/$TOOL_PREFIX/lib/3dsx.specs'" @@ -98,7 +98,7 @@ cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] [properties] pkg_config_libdir = '$PKG_CONFIG_PATH' needs_exe_wrapper = true -library_dirs= ['$LIBCTRU_LIB', '$PORTLIBS_LIB'] +library_dirs= ['$LIBCTRU_LIB','$PORTLIBS_LIB'] libctru='$LIBCTRU' APP_NAME = 'oopetris' diff --git a/platforms/build-android.sh b/platforms/build-android.sh index 39cc64ed..ed334ab4 100755 --- a/platforms/build-android.sh +++ b/platforms/build-android.sh @@ -290,8 +290,8 @@ c_std = 'c11' cpp_std = 'c++23' c_args = ['--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-DHAVE_USR_INCLUDE_MALLOC_H','-D_MALLOC_H','-D__BITNESS=$BITNESS'] cpp_args = ['--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-D__BITNESS=$BITNESS'] -c_link_args = ['-fPIE', '-L$SYS_ROOT/usr/lib'] -cpp_link_args = ['-fPIE', '-L$SYS_ROOT/usr/lib'] +c_link_args = ['-fPIE','-L$SYS_ROOT/usr/lib'] +cpp_link_args = ['-fPIE','-L$SYS_ROOT/usr/lib'] prefix = '$SYS_ROOT' libdir = '$LIB_PATH' @@ -307,7 +307,7 @@ EOF ln -s "$BASE_PATH/sources/android/cpufeatures/cpu-features.c" "$PWD/subprojects/cpu-features/src/cpu-features.c" ln -s "$BASE_PATH/sources/android/cpufeatures/cpu-features.h" "$PWD/subprojects/cpu-features/include/cpu-features.h" cat <"$PWD/subprojects/cpu-features/meson.build" -project('cpu-features', 'c') +project('cpu-features','c') meson.override_dependency( 'cpu-features', diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 716ad60c..ea8be659 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -46,7 +46,7 @@ export COMMON_FLAGS="'-ftls-model=local-exec','-march=armv8-a+crc+crypto','-mtun # compat flags for some POSIX functions export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'" -export COMPILE_FLAGS="'-D__SWITCH__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'" +export COMPILE_FLAGS="'-D__SWITCH__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB','-fPIE','-specs=$DEVKITPRO/libnx/switch.specs'" @@ -96,7 +96,7 @@ cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] [properties] pkg_config_libdir = '$PKG_CONFIG_PATH' needs_exe_wrapper = true -library_dirs= ['$LIBNX_LIB', '$PORTLIBS_LIB'] +library_dirs= ['$LIBNX_LIB','$PORTLIBS_LIB'] libnx='$LIBNX' APP_NAME = 'oopetris' diff --git a/src/application.cpp b/src/application.cpp index cc862e6f..84179536 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -9,10 +9,8 @@ #include #include -#if defined(__SWITCH__) -#include -#elif defined(__3DS__) -#include <3ds.h> +#if defined(__CONSOLE__) +#include "helper/console_helpers.hpp" #endif namespace { @@ -65,20 +63,13 @@ void Application::run() { auto start_execution_time = std::chrono::steady_clock::now(); while (m_is_running - //TODO factor out -#if defined(__SWITCH__) - // see https://switchbrew.github.io/libnx/applet_8h.html#a7ed640e5f4a81ed3960c763fdc1521c5 - // this checks for some other reasons why this app should quit, its switch specific - and appletMainLoop() -#elif defined(__3DS__) - // see https://libctru.devkitpro.org/apt_8h.html#a84808c36d9a8c389896ecf241c7f89cb - // this checks for some other reasons why this app should quit, its 3ds specific - and aptMainLoop() + +#if defined(__CONSOLE__) + and console::inMainLoop() #endif ) { - m_event_dispatcher.dispatch_pending_events(); update(); render(); diff --git a/src/helper/console_helpers.cpp b/src/helper/console_helpers.cpp new file mode 100644 index 00000000..680e49ba --- /dev/null +++ b/src/helper/console_helpers.cpp @@ -0,0 +1,56 @@ + +#include "helper/errors.hpp" +#if defined(__NINTENDO_CONSOLE__) + +#include "console_helpers.hpp" + +#if defined(__SWITCH__) +#include +#elif defined(__3DS__) +#include <3ds.h> +#endif + +void console::debug_write(const char* text, size_t size) { +#ifdef __3DS__ + svcOutputDebugString(text, size); +#elif defined(__SWITCH__) + svcOutputDebugString(text, size); +#else +#error "not implemented" +#endif +} + +void console::platform_init() { +#if defined(__3DS__) || defined(__SWITCH__) + Result ret = romfsInit(); + if (R_FAILED(ret)) { + throw helper::IniInitializationError(fmt::format("romfsInit() failed: {:#2x}", (unsigned int) ret)); + } +#else +#error "not implemented" +#endif +} + +void console::platform_exit() { +#if defined(__3DS__) || defined(__SWITCH__) + Result ret = romfsExit(); + if (R_FAILED(ret)) { + throw helper::IniInitializationError(fmt::format("romfsExit() failed: {:#2x}", (unsigned int) ret)); + } +#else +#error "not implemented" +#endif +} + +bool console::inMainLoop() { +#ifdef __3DS__ + return aptMainLoop(); +#elif defined(__SWITCH__) + return appletMainLoop(); +#else +#error "not implemented" +#endif +} + + +#endif diff --git a/src/helper/console_helpers.hpp b/src/helper/console_helpers.hpp new file mode 100644 index 00000000..4768e47c --- /dev/null +++ b/src/helper/console_helpers.hpp @@ -0,0 +1,55 @@ + + +#pragma once + +#if defined(__CONSOLE__) + +namespace console { + + void debug_write(const char* text, size_t size); + + inline void debug_print(const char* text) { + debug_write(text, strlen(text)); + } + + inline void debug_print(const std::string& value) { + debug_write(value.c_str(), value.size()); + } + + void platform_init(); + + void platform_exit(); + + [[nodiscard]] bool inMainLoop(); + + + template + class debug_sink final : public base_sink { + public: + explicit debug_sink() { } + debug_sink(const debug_sink&) = delete; + debug_sink& operator=(const debug_sink&) = delete; + + protected: + void sink_it_(const details::log_msg& msg) override { + memory_buf_t formatted; + base_sink::formatter_->format(msg, formatted); + debug_write(formatted.data(), static_cast(formatted.size())); + } + + void flush_() override { + // noop + } + + std::ostream& ostream_; + bool force_flush_; + }; + + using debug_sink_mt = debug_sink; + using debug_sink_st = debug_sink; + + +} // namespace console + + +#endif diff --git a/src/helper/meson.build b/src/helper/meson.build index da4976e9..9cff7832 100644 --- a/src/helper/meson.build +++ b/src/helper/meson.build @@ -29,6 +29,8 @@ core_src_files += files( graphics_src_files += files( 'clock_source.cpp', 'clock_source.hpp', + 'console_helpers.cpp', + 'console_helpers.hpp', 'graphic_utils.cpp', 'graphic_utils.hpp', 'message_box.cpp', diff --git a/src/main.cpp b/src/main.cpp index d1a1392f..fa4dcb0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,8 +25,10 @@ int main(int argc, char** argv) { std::vector sinks; #if defined(__ANDROID__) sinks.push_back(std::make_shared()); +#elif defined(__CONSOLE__) + sinks.push_back(std::make_shared()); #else - sinks.push_back(std::make_shared()); + sinks.push_back(std::make_shared()); #endif sinks.push_back(std::make_shared( fmt::format("{}/oopetris.log", logs_path.string()), 1024 * 1024 * 10, 5, true From 3640622f09ccee1275f589a6a13a323d3825f4b6 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 18:37:00 +0200 Subject: [PATCH 07/19] add 3ds to the ci builds --- .github/workflows/nintendo.yml | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nintendo.yml b/.github/workflows/nintendo.yml index 90b3d08a..e4247c7f 100644 --- a/.github/workflows/nintendo.yml +++ b/.github/workflows/nintendo.yml @@ -1,4 +1,4 @@ -name: Nintendo Switch CI +name: Nintendo CI on: push: @@ -7,10 +7,23 @@ on: workflow_dispatch: jobs: - switch-build: + build: + name: Nintendo ${{ matrix.config.name }} CI runs-on: ubuntu-22.04 container: - image: devkitpro/devkita64 ## base on debian:buster-slim + image: devkitpro/${{ matrix.config.container }} ## base on debian:buster-slim + strategy: + fail-fast: false + matrix: + config: + - name: 3ds + extension: 3dsx + container: devkitarm + + - name: switch + extension: nro + container: devkita64 + steps: - uses: actions/checkout@v4 with: @@ -30,10 +43,10 @@ jobs: - name: Configure and Build run: | - bash ./platforms/build-switch.sh + bash ./platforms/build-${{ matrix.config.name }}.sh - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: oopetris.nro - path: build-switch/oopetris.nro + name: ${{ matrix.config.name }} Executable + path: build-${{ matrix.config.name }}/oopetris.${{ matrix.config.extension }} From 9ba9b35f298967a630d77e0e0d107d9d92f753e3 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 20:57:10 +0200 Subject: [PATCH 08/19] add option to not only build teh release for 3ds, switch and android, build debug per default, but use release in CI --- .github/workflows/android.yml | 2 +- .github/workflows/nintendo.yml | 2 +- platforms/build-3ds.sh | 9 +++++++-- platforms/build-android.sh | 22 ++++++++++++++++------ platforms/build-switch.sh | 9 +++++++-- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5c476657..a0837045 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -50,7 +50,7 @@ jobs: - name: Build natibe libraries run: | - bash ./platforms/build-android.sh ${{ matrix.config.arch }} + bash ./platforms/build-android.sh ${{ matrix.config.arch }} complete_rebuild release cp -r ./assets/ platforms/android/app/src/main - name: Build APK diff --git a/.github/workflows/nintendo.yml b/.github/workflows/nintendo.yml index e4247c7f..169d9ae3 100644 --- a/.github/workflows/nintendo.yml +++ b/.github/workflows/nintendo.yml @@ -43,7 +43,7 @@ jobs: - name: Configure and Build run: | - bash ./platforms/build-${{ matrix.config.name }}.sh + bash ./platforms/build-${{ matrix.config.name }}.sh complete_rebuild release - name: Upload artifacts uses: actions/upload-artifact@v4 diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh index 1cb2f6f7..c5cd7df8 100755 --- a/platforms/build-3ds.sh +++ b/platforms/build-3ds.sh @@ -215,13 +215,18 @@ cd .. ## options: "smart, complete_rebuild" export COMPILE_TYPE="smart" +export BUILDTYPE="debug" + if [ "$#" -eq 0 ]; then # nothing echo "Using compile type '$COMPILE_TYPE'" elif [ "$#" -eq 1 ]; then COMPILE_TYPE="$1" +elif [ "$#" -eq 2 ]; then + COMPILE_TYPE="$1" + BUILDTYPE="$2" else - echo "Too many arguments given, expected at most 1" + echo "Too many arguments given, expected 1 or 2" exit 1 fi @@ -247,7 +252,7 @@ if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then meson setup "$BUILD_DIR" \ "--wipe" \ --cross-file "$CROSS_FILE" \ - -Dbuildtype=release \ + "-Dbuildtype=$BUILDTYPE" \ -Ddefault_library=static fi diff --git a/platforms/build-android.sh b/platforms/build-android.sh index ed334ab4..80afee8e 100755 --- a/platforms/build-android.sh +++ b/platforms/build-android.sh @@ -2,9 +2,6 @@ set -e -## options: "smart, complete_rebuild" -export COMPILE_TYPE="smart" - mkdir -p toolchains export NDK_VER_DOWNLOAD="r26d" @@ -47,10 +44,15 @@ mapfile -t ARCH_KEYS < <(jq 'keys' -M -r -c "$BASE_PATH/meta/abis.json" | tr -d export ARCH_KEYS_INDEX=("${!ARCH_KEYS[@]}") +## options: "smart, complete_rebuild" +export COMPILE_TYPE="smart" + +export BUILDTYPE="debug" + if [ "$#" -eq 0 ]; then # nothing echo "Using all architectures" -elif [ "$#" -eq 1 ]; then +elif [ "$#" -eq 1 ] || [ "$#" -eq 2 ] || [ "$#" -eq 3 ]; then ARCH=$1 FOUND="" @@ -67,8 +69,16 @@ elif [ "$#" -eq 1 ]; then fi ARCH_KEYS_INDEX=("$FOUND") + + if [ "$#" -eq 2 ]; then + COMPILE_TYPE="$2" + elif [ "$#" -eq 3 ]; then + COMPILE_TYPE="$2" + BUILDTYPE="$3" + fi + else - echo "Too many arguments given, expected at most 1" + echo "Too many arguments given, expected 1 ,2 or 3" exit 1 fi @@ -334,7 +344,7 @@ EOF "--includedir=$INC_PATH" \ "--libdir=usr/lib/$ARM_NAME_TRIPLE/$SDK_VERSION" \ --cross-file "./platforms/crossbuild-android-$ARM_TARGET_ARCH.ini" \ - -Dbuildtype=release \ + "-Dbuildtype=$BUILDTYPE" \ -Dsdl2:use_hidapi=disabled \ -Dcpp_args=-DAUDIO_PREFER_MP3 \ -Dclang_libcpp=disabled diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index ea8be659..62e3a6bf 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -112,13 +112,18 @@ EOF ## options: "smart, complete_rebuild" export COMPILE_TYPE="smart" +export BUILDTYPE="debug" + if [ "$#" -eq 0 ]; then # nothing echo "Using compile type '$COMPILE_TYPE'" elif [ "$#" -eq 1 ]; then COMPILE_TYPE="$1" +elif [ "$#" -eq 2 ]; then + COMPILE_TYPE="$1" + BUILDTYPE="$2" else - echo "Too many arguments given, expected at most 1" + echo "Too many arguments given, expected 1 or 2" exit 1 fi @@ -144,7 +149,7 @@ if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then meson setup "$BUILD_DIR" \ "--wipe" \ --cross-file "$CROSS_FILE" \ - -Dbuildtype=release \ + "-Dbuildtype=$BUILDTYPE" \ -Ddefault_library=static fi From 4f88763054223e64842dc56e5a627ee7ad656a26 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 21:03:45 +0200 Subject: [PATCH 09/19] - fix compilation errors - factor more switch and 3ds functions out into console helpers --- src/game/input_creator.cpp | 8 ++--- src/graphics/sdl_context.cpp | 18 ++++------ src/helper/console_helpers.cpp | 35 +++++++++++++++++-- src/helper/console_helpers.hpp | 17 ++++----- src/main.cpp | 5 +++ src/platform/capabilities.cpp | 14 ++++---- src/platform/capabilities.hpp | 10 +++--- ...switch_buttons.hpp => console_buttons.hpp} | 6 ++++ .../{switch_input.cpp => console_input.cpp} | 16 +++++++-- .../{switch_input.hpp => console_input.hpp} | 4 +-- src/platform/meson.build | 12 ++++--- src/platform/platform.hpp | 1 + src/scenes/pause/pause.cpp | 5 --- tools/dependencies/meson.build | 5 +++ 14 files changed, 107 insertions(+), 49 deletions(-) rename src/platform/{switch_buttons.hpp => console_buttons.hpp} (96%) rename src/platform/{switch_input.cpp => console_input.cpp} (90%) rename src/platform/{switch_input.hpp => console_input.hpp} (93%) diff --git a/src/game/input_creator.cpp b/src/game/input_creator.cpp index 84181ca7..b3192a4b 100644 --- a/src/game/input_creator.cpp +++ b/src/game/input_creator.cpp @@ -7,11 +7,11 @@ #include "platform/replay_input.hpp" #include -//TODO: support 3ds + #if defined(__ANDROID__) #include "platform/android_input.hpp" -#elif defined(__SWITCH__) -#include "platform/switch_input.hpp" +#elif defined(__CONSOLE__) +#include "platform/console_input.hpp" #else #include "platform/keyboard_input.hpp" #endif @@ -28,7 +28,7 @@ namespace { auto* const event_dispatcher = &(service_provider->event_dispatcher()); #if defined(__ANDROID__) auto input = std::make_unique(event_dispatcher); -#elif defined(__SWITCH__) +#elif defined(__CONSOLE__) auto input = std::make_unique(event_dispatcher); #else auto input = std::make_unique(keyboard_controls, event_dispatcher); diff --git a/src/graphics/sdl_context.cpp b/src/graphics/sdl_context.cpp index c002ba65..e86ab4dc 100644 --- a/src/graphics/sdl_context.cpp +++ b/src/graphics/sdl_context.cpp @@ -5,10 +5,8 @@ #include #include -#if defined(__SWITCH__) -#include -#elif defined(__3DS__) -#include <3ds.h> +#if defined(__CONSOLE__) +#include "helper/console_helpers.hpp" #endif #if defined(_HAVE_FILE_DIALOGS) @@ -26,11 +24,10 @@ SdlContext::SdlContext() { throw helper::InitializationError{ fmt::format("Failed in initializing sdl ttf: {}", TTF_GetError()) }; } -#if defined(__SWITCH__) or defined(__3DS__) - // based on: https://github.com/carstene1ns/switch-sdl2-demo +#if defined(__CONSOLE__) + console::platform_init(); - // mount the romfs in the executable as "romfs:/" (this is fine since only one app can run at the time on the switch) - romfsInit(); + //TODO: factor out // init joystick and other nintendo switch / 3ds specific things SDL_InitSubSystem(SDL_INIT_JOYSTICK); @@ -58,9 +55,8 @@ SdlContext::~SdlContext() { NFD::Quit(); #endif -#if defined(__SWITCH__) - // unmount romfs again - romfsExit(); +#if defined(__CONSOLE__) + console::platform_exit(); #endif TTF_Quit(); diff --git a/src/helper/console_helpers.cpp b/src/helper/console_helpers.cpp index 680e49ba..7525eadf 100644 --- a/src/helper/console_helpers.cpp +++ b/src/helper/console_helpers.cpp @@ -4,12 +4,16 @@ #include "console_helpers.hpp" +#include "helper/utils.hpp" + #if defined(__SWITCH__) #include #elif defined(__3DS__) #include <3ds.h> #endif +#include + void console::debug_write(const char* text, size_t size) { #ifdef __3DS__ svcOutputDebugString(text, size); @@ -20,11 +24,38 @@ void console::debug_write(const char* text, size_t size) { #endif } +#define IN_OUT_BUF_SIZE 0x100 + +[[nodiscard]] std::string console::open_url(const std::string& url) { +#if defined(__3DS__) + const auto size = url.size() >= 0x100 ? url.size() + 1 : 0x100; + + char* buffer = malloc(size); + + memcpy(buffer, url.c_str(), url.size()); + buffer[url.size()] = '\0'; + + aptLaunchLibraryApplet(APPID_WEB, buffer, IN_OUT_BUF_SIZE, 0); + + const auto result = std::string{ buffer }; + + free(buffer); + + return result; +#elif defined(__SWITCH__) + UNUSED(url); + return ""; +#else +#error "not implemented" +#endif +} + + void console::platform_init() { #if defined(__3DS__) || defined(__SWITCH__) Result ret = romfsInit(); if (R_FAILED(ret)) { - throw helper::IniInitializationError(fmt::format("romfsInit() failed: {:#2x}", (unsigned int) ret)); + throw helper::InitializationError(fmt::format("romfsInit() failed: {:#2x}", static_cast(ret))); } #else #error "not implemented" @@ -35,7 +66,7 @@ void console::platform_exit() { #if defined(__3DS__) || defined(__SWITCH__) Result ret = romfsExit(); if (R_FAILED(ret)) { - throw helper::IniInitializationError(fmt::format("romfsExit() failed: {:#2x}", (unsigned int) ret)); + throw helper::InitializationError(fmt::format("romfsExit() failed: {:#2x}", static_cast(ret))); } #else #error "not implemented" diff --git a/src/helper/console_helpers.hpp b/src/helper/console_helpers.hpp index 4768e47c..e7803a52 100644 --- a/src/helper/console_helpers.hpp +++ b/src/helper/console_helpers.hpp @@ -4,6 +4,8 @@ #if defined(__CONSOLE__) +#include + namespace console { void debug_write(const char* text, size_t size); @@ -16,6 +18,8 @@ namespace console { debug_write(value.c_str(), value.size()); } + [[nodiscard]] std::string open_url(const std::string& url); + void platform_init(); void platform_exit(); @@ -24,29 +28,26 @@ namespace console { template - class debug_sink final : public base_sink { + class debug_sink final : public spdlog::sinks::base_sink { public: explicit debug_sink() { } debug_sink(const debug_sink&) = delete; debug_sink& operator=(const debug_sink&) = delete; protected: - void sink_it_(const details::log_msg& msg) override { - memory_buf_t formatted; - base_sink::formatter_->format(msg, formatted); + void sink_it_(const spdlog::details::log_msg& msg) override { + spdlog::memory_buf_t formatted; + spdlog::sinks::base_sink::formatter_->format(msg, formatted); debug_write(formatted.data(), static_cast(formatted.size())); } void flush_() override { // noop } - - std::ostream& ostream_; - bool force_flush_; }; using debug_sink_mt = debug_sink; - using debug_sink_st = debug_sink; + using debug_sink_st = debug_sink; } // namespace console diff --git a/src/main.cpp b/src/main.cpp index fa4dcb0f..74de1383 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,11 @@ #include #endif +#if defined(__CONSOLE__) +#include "helper/console_helpers.hpp" +#endif + + #include #include #include diff --git a/src/platform/capabilities.cpp b/src/platform/capabilities.cpp index 9d5efe96..1c8082ba 100644 --- a/src/platform/capabilities.cpp +++ b/src/platform/capabilities.cpp @@ -5,9 +5,9 @@ #include "helper/utils.hpp" #include "platform/capabilities.hpp" -//TODO: support 3ds too -#if defined(__SWITCH__) -#include "platform/switch_buttons.hpp" +#if defined(__CONSOLE__) +#include "helper/console_helpers.hpp" +#include "platform/console_buttons.hpp" #endif @@ -67,10 +67,12 @@ namespace { return true; -#elif defined(__SWITCH__) || defined(__3DS__) - UNUSED(url); - return false; +#elif defined(__CONSOLE__) + auto result = console::open_url(url); + spdlog::info("Returned string from url open was: {}", result); + return true; #else + //TODO: this is dangerous, if we supply user input, so use SDL_OpenURL preferably #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) const std::string shellCommand = "start " + url; diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index 5ff99b4d..7963e06f 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -14,11 +14,11 @@ #include "helper/types.hpp" #include "helper/utils.hpp" -#if defined(__SWITCH__) -#include "platform/switch_buttons.hpp" +#if defined(__CONSOLE__) +#include "platform/console_buttons.hpp" #endif -//TODO factor this file into mulitple ones, according to logic distribution of what the functions are doing +//TODO factor this file into mulitple ones, according to logic distribution of what the functions are doing, remove and refacator the input helper functions namespace utils { @@ -53,7 +53,7 @@ namespace utils { {static_cast(CrossPlatformAction::OPEN_SETTINGS), { 0 }}, { static_cast(CrossPlatformAction::TAB), { 0 }} }; -#elif defined(__SWITCH__) +#elif defined(__CONSOLE__) { { static_cast(CrossPlatformAction::OK),{ JOYCON_A } }, { static_cast(CrossPlatformAction::PAUSE), { JOYCON_PLUS }}, @@ -90,7 +90,7 @@ namespace utils { [[nodiscard]] constexpr Capabilities get_capabilities() { #if defined(__ANDROID__) return Capabilities{ false, true, Orientation::Portrait }; -#elif defined(__SWITCH__) +#elif defined(__SWITCH__) or defined(__3DS__) return Capabilities{ true, false, Orientation::Landscape }; #else return Capabilities{ true, true, Orientation::Landscape }; diff --git a/src/platform/switch_buttons.hpp b/src/platform/console_buttons.hpp similarity index 96% rename from src/platform/switch_buttons.hpp rename to src/platform/console_buttons.hpp index d130b50f..9ed781a2 100644 --- a/src/platform/switch_buttons.hpp +++ b/src/platform/console_buttons.hpp @@ -2,6 +2,8 @@ #pragma once +#if defined(__CONSOLE__) + #if defined(__SWITCH__) @@ -47,4 +49,8 @@ static_assert(BITL(JOYCON_B) == HidNpadButton_B); static_assert(BITL(JOYCON_PLUS) == HidNpadButton_Plus); +#endif + +//TODO: implement for 3ds + #endif diff --git a/src/platform/switch_input.cpp b/src/platform/console_input.cpp similarity index 90% rename from src/platform/switch_input.cpp rename to src/platform/console_input.cpp index ea7dd9ff..c92f934a 100644 --- a/src/platform/switch_input.cpp +++ b/src/platform/console_input.cpp @@ -1,6 +1,6 @@ -#if defined(__SWITCH__) -#include "switch_input.hpp" +#if defined(__CONSOLE__) +#include "console_input.hpp" void JoystickInput::handle_event(const SDL_Event& event, const Window*) { @@ -19,6 +19,9 @@ void JoystickInput::update(SimulationStep simulation_step_index) { Input::update(simulation_step_index); } +#if defined(__SWITCH__) + + helper::optional JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const { if (event.type == SDL_JOYBUTTONDOWN) { const auto button = event.jbutton.button; @@ -69,5 +72,14 @@ helper::optional JoystickInput::sdl_event_to_input_event(const SDL_E } return helper::nullopt; } +#elif defined(__3DS__) + +helper::optional JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const { + return helper::nullopt; +} + +//TODO: implement for 3ds +#endif + #endif diff --git a/src/platform/switch_input.hpp b/src/platform/console_input.hpp similarity index 93% rename from src/platform/switch_input.hpp rename to src/platform/console_input.hpp index c6cfb8d2..82fb2e7a 100644 --- a/src/platform/switch_input.hpp +++ b/src/platform/console_input.hpp @@ -2,11 +2,11 @@ #pragma once -#if defined(__SWITCH__) +#if defined(__CONSOLE__) +#include "console_buttons.hpp" #include "input.hpp" #include "manager/event_dispatcher.hpp" -#include "switch_buttons.hpp" struct JoystickInput : public Input, public EventListener { private: diff --git a/src/platform/meson.build b/src/platform/meson.build index c698fb65..f7d92f2f 100644 --- a/src/platform/meson.build +++ b/src/platform/meson.build @@ -13,11 +13,15 @@ if meson.is_cross_build() and host_machine.system() == 'android' 'android_input.cpp', 'android_input.hpp', ) -elif meson.is_cross_build() and host_machine.system() == 'switch' +elif ( + meson.is_cross_build() + and (host_machine.system() == 'switch' + or host_machine.system() == '3ds') +) graphics_src_files += files( - 'switch_buttons.hpp', - 'switch_input.cpp', - 'switch_input.hpp', + 'console_buttons.hpp', + 'console_input.cpp', + 'console_input.hpp', ) else graphics_src_files += files( diff --git a/src/platform/platform.hpp b/src/platform/platform.hpp index a12db7be..b87c5092 100644 --- a/src/platform/platform.hpp +++ b/src/platform/platform.hpp @@ -3,6 +3,7 @@ #pragma once #include "helper/parse_json.hpp" +#include "helper/types.hpp" enum class Platform : u8 { PC, Android, Console }; diff --git a/src/scenes/pause/pause.cpp b/src/scenes/pause/pause.cpp index 7ed41a5c..f98828d4 100644 --- a/src/scenes/pause/pause.cpp +++ b/src/scenes/pause/pause.cpp @@ -4,11 +4,6 @@ #include "platform/capabilities.hpp" #include - -#if defined(__SWITCH__) -#include "platform/switch_buttons.hpp" -#endif - namespace scenes { Pause::Pause(ServiceProvider* service_provider, const ui::Layout& layout) : Scene{ service_provider, layout }, m_heading { diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build index 947baf56..a36bf312 100644 --- a/tools/dependencies/meson.build +++ b/tools/dependencies/meson.build @@ -216,6 +216,11 @@ if ( or host_machine.system() == '3ds') ) online_multiplayer_supported = false + + # TODO: use libcurl and + # https://github.com/uctakeoff/uc-curl + # or https://github.com/JosephP91/curlcpp + core_lib += { 'compile_args': [ core_lib.get('compile_args'), From 16cea44a2c20fa0db39d9d9c641f20663e2d8dcb Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 21:07:54 +0200 Subject: [PATCH 10/19] fix final 3ds build failures --- src/helper/console_helpers.cpp | 5 +++-- src/platform/capabilities.cpp | 8 ++++---- src/platform/capabilities.hpp | 3 ++- src/platform/console_input.cpp | 3 ++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/helper/console_helpers.cpp b/src/helper/console_helpers.cpp index 7525eadf..99af1e49 100644 --- a/src/helper/console_helpers.cpp +++ b/src/helper/console_helpers.cpp @@ -10,6 +10,7 @@ #include #elif defined(__3DS__) #include <3ds.h> +#include #endif #include @@ -30,12 +31,12 @@ void console::debug_write(const char* text, size_t size) { #if defined(__3DS__) const auto size = url.size() >= 0x100 ? url.size() + 1 : 0x100; - char* buffer = malloc(size); + char* buffer = reinterpret_cast(malloc(size)); memcpy(buffer, url.c_str(), url.size()); buffer[url.size()] = '\0'; - aptLaunchLibraryApplet(APPID_WEB, buffer, IN_OUT_BUF_SIZE, 0); + aptLaunchLibraryApplet(APPID_WEB, buffer, size, 0); const auto result = std::string{ buffer }; diff --git a/src/platform/capabilities.cpp b/src/platform/capabilities.cpp index 1c8082ba..65c84287 100644 --- a/src/platform/capabilities.cpp +++ b/src/platform/capabilities.cpp @@ -75,16 +75,16 @@ namespace { //TODO: this is dangerous, if we supply user input, so use SDL_OpenURL preferably #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) - const std::string shellCommand = "start " + url; + const std::string shell_command = "start " + url; #elif defined(__APPLE__) - const std::string shellCommand = "open " + url; + const std::string shell_command = "open " + url; #elif defined(__linux__) - const std::string shellCommand = "xdg-open " + url; + const std::string shell_command = "xdg-open " + url; #else #error "Unsupported platform" #endif - const auto result = system(shellCommand.c_str()); + const auto result = system(shell_command.c_str()); if (result < 0) { spdlog::error("Error in opening url: {}", get_error_from_errno()); return false; diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index 7963e06f..ff9848e3 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -53,7 +53,7 @@ namespace utils { {static_cast(CrossPlatformAction::OPEN_SETTINGS), { 0 }}, { static_cast(CrossPlatformAction::TAB), { 0 }} }; -#elif defined(__CONSOLE__) +#elif defined(__SWITCH__) { { static_cast(CrossPlatformAction::OK),{ JOYCON_A } }, { static_cast(CrossPlatformAction::PAUSE), { JOYCON_PLUS }}, @@ -70,6 +70,7 @@ namespace utils { {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, { static_cast(CrossPlatformAction::TAB), {}}, // no tab support }; +//TODO: support 3ds #else { { static_cast(CrossPlatformAction::OK), { SDLK_RETURN, SDLK_SPACE }}, diff --git a/src/platform/console_input.cpp b/src/platform/console_input.cpp index c92f934a..266bd529 100644 --- a/src/platform/console_input.cpp +++ b/src/platform/console_input.cpp @@ -74,11 +74,12 @@ helper::optional JoystickInput::sdl_event_to_input_event(const SDL_E } #elif defined(__3DS__) +//TODO: implement for 3ds helper::optional JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const { + UNUSED(event); return helper::nullopt; } -//TODO: implement for 3ds #endif From 98cf7abf6039eddb57b10fc3179d8c5a61506642 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 21:10:26 +0200 Subject: [PATCH 11/19] refactor some ifdefs --- src/discord/core.hpp | 2 +- src/helper/graphic_utils.cpp | 4 ++-- src/main.cpp | 2 +- src/platform/capabilities.hpp | 2 +- src/platform/platform.hpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/discord/core.hpp b/src/discord/core.hpp index 06850906..272e69d9 100644 --- a/src/discord/core.hpp +++ b/src/discord/core.hpp @@ -21,7 +21,7 @@ namespace constants::discord { //TODO: this isn't correct for all platforms and needs to be tested #if defined(__ANDROID__) constexpr const char* platform_dependent_launch_arguments = ""; -#elif defined(__SWITCH__) +#elif defined(__CONSOLE__) #error "Not supported" #elif defined(FLATPAK_BUILD) constexpr const char* platform_dependent_launch_arguments = "flatpak run com.github.mgerhold.OOPetris --discord"; diff --git a/src/helper/graphic_utils.cpp b/src/helper/graphic_utils.cpp index 23730be3..4bf36507 100644 --- a/src/helper/graphic_utils.cpp +++ b/src/helper/graphic_utils.cpp @@ -34,7 +34,7 @@ std::vector utils::supported_features() { throw std::runtime_error{ "Failed in getting the Pref Path: " + std::string{ SDL_GetError() } }; } return std::filesystem::path{ std::string{ pref_path } }; -#elif defined(__SWITCH__) +#elif defined(__CONSOLE__) // this is in the sdcard of the switch, since internal storage is read-only for applications! return std::filesystem::path{ "." }; @@ -55,7 +55,7 @@ std::vector utils::supported_features() { [[nodiscard]] std::filesystem::path utils::get_assets_folder() { #if defined(__ANDROID__) return std::filesystem::path{ "" }; -#elif defined(__SWITCH__) or defined(__3DS__) +#elif defined(__CONSOLE__) // this is in the internal storage of the nintendo switch, it ios mounted by libnx (runtime switch support library) and filled at compile time with assets (its called ROMFS there) return std::filesystem::path{ "romfs:/assets" }; #elif defined(BUILD_INSTALLER) diff --git a/src/main.cpp b/src/main.cpp index 74de1383..948de8e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char** argv) { std::unique_ptr window{ nullptr }; try { -#if defined(__ANDROID__) or defined(__SWITCH__) or defined(__3DS__) +#if defined(__ANDROID__) or defined(__CONSOLE__) window = std::make_unique(window_name, WindowPosition::Centered); #else static constexpr int width = 1280; diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index ff9848e3..53d9e059 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -87,7 +87,7 @@ namespace utils { }; #endif - + //TODO: refactor [[nodiscard]] constexpr Capabilities get_capabilities() { #if defined(__ANDROID__) return Capabilities{ false, true, Orientation::Portrait }; diff --git a/src/platform/platform.hpp b/src/platform/platform.hpp index b87c5092..ad53796a 100644 --- a/src/platform/platform.hpp +++ b/src/platform/platform.hpp @@ -24,7 +24,7 @@ namespace utils { #if defined(__ANDROID__) return "android"; -#elif defined(__SWITCH__) or defined(__3DS__) +#elif defined(__CONSOLE__) return "console"; #else return "pc"; From e95e14728bcd51aa1f8c8573d8ebf0152a40dd51 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 23:06:33 +0200 Subject: [PATCH 12/19] fix 3ds run, it's dirty atm --- assets/fonts/LeroyLetteringLightBeta01.ttf | Bin 0 -> 46780 bytes platforms/build-3ds.sh | 13 +++++-------- platforms/build-android.sh | 2 +- platforms/build-switch.sh | 13 +++++-------- src/application.cpp | 15 ++++++++++----- src/graphics/renderer.cpp | 16 +++++++++++----- src/helper/console_helpers.hpp | 11 ++++++++++- tools/dependencies/meson.build | 16 ++++++++++++++++ 8 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 assets/fonts/LeroyLetteringLightBeta01.ttf diff --git a/assets/fonts/LeroyLetteringLightBeta01.ttf b/assets/fonts/LeroyLetteringLightBeta01.ttf new file mode 100644 index 0000000000000000000000000000000000000000..03029862b87e73647acbea105361e159250faa38 GIT binary patch literal 46780 zcmeFad6*8#u<-^q!eE<4YzEu-;S2ZOC%D(Lrsw@4vZ}gAngQ{i|9Rhc zv%l=j$|WMsi4*6XIOoJkLJ1)*{z=3+aOtr<4>&I<6B7CrT>ajmV-wxWg!U34^v(Ev z?TH-+Pu}s_yDlZES7a@XSd(v5fC zbbIOW>Zb`wpCm;1{hOY5&yAOVJ$x4TUq#5z&EI^(?RTr6?Q3}VUP7$Dy!p)O8@~2# z|AVM6gZFzkv2hIfQ7otr1Sr2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u8n{#~2A8RJ@EmYIeSZnq ztL&KtE=rtNUx39eHYFn_&BtpYDrtHDduFTvla3&Bg(uZ%s6?=|3MYAwk41}_Ic zL^iAgf3GeAuT&R0dG^+8t)--t^;pZ*MoPc8^Al&jo_cuO~$*(xtqbe z)h*yX>W|=`)ve%qa2L`|tW)=@+rSOlMzvAh&TQa5bq9FAx)Xdr{Rwi^)g}kk{ zgYT&4!ClOZUqRx(0KTVQG+svTzXZOoUIsrLoJKh-D3cJ;mb6#SR^3_Pk1fXCG5-~jlXGSorix&H@i C#J%qT literal 0 HcmV?d00001 diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh index c5cd7df8..b92b919c 100755 --- a/platforms/build-3ds.sh +++ b/platforms/build-3ds.sh @@ -45,9 +45,6 @@ export ENDIANESS="little" export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard','-mtp=soft','-mword-relocations','-ffunction-sections','-fdata-sections'" -# compat flags for some POSIX functions -export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'" - export COMPILE_FLAGS="'-D_3DS','-D__3DS__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBCTRU/include','-I$PORTLIBS_PATH_3DS/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBCTRU_LIB','-fPIE','-specs=$ARCH_DEVKIT_FOLDER/$TOOL_PREFIX/lib/3dsx.specs'" @@ -87,10 +84,10 @@ libpng-config='$BIN_DIR/libpng-config' sdl2-config='$BIN_DIR/bin/sdl2-config' [built-in options] -c_std = 'c11' +c_std = 'gnu11' cpp_std = 'c++23' -c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] -cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] @@ -241,9 +238,9 @@ fi if [ ! -d "$ROMFS" ]; then - mkdir -p $ROMFS + mkdir -p "$ROMFS" - cp -r assets $ROMFS + cp -r assets "$ROMFS" fi diff --git a/platforms/build-android.sh b/platforms/build-android.sh index 80afee8e..44037acb 100755 --- a/platforms/build-android.sh +++ b/platforms/build-android.sh @@ -296,7 +296,7 @@ pkg-config = 'false' llvm-config = 'llvm-config' [built-in options] -c_std = 'c11' +c_std = 'gnu11' cpp_std = 'c++23' c_args = ['--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-DHAVE_USR_INCLUDE_MALLOC_H','-D_MALLOC_H','-D__BITNESS=$BITNESS'] cpp_args = ['--sysroot=${SYS_ROOT:?}','-fPIE','-fPIC','--target=$ARM_COMPILER_TRIPLE','-D__BITNESS=$BITNESS'] diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 62e3a6bf..0d2cd5ff 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -43,9 +43,6 @@ export ENDIANESS="little" export COMMON_FLAGS="'-ftls-model=local-exec','-march=armv8-a+crc+crypto','-mtune=cortex-a57','-mtp=soft','-ftls-model=local-exec','-fPIC','-ffunction-sections','-fdata-sections'" -# compat flags for some POSIX functions -export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'" - export COMPILE_FLAGS="'-D__SWITCH__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB','-fPIE','-specs=$DEVKITPRO/libnx/switch.specs'" @@ -85,10 +82,10 @@ libpng-config='$BIN_DIR/libpng-config' sdl2-config='$BIN_DIR/sdl2-config' [built-in options] -c_std = 'c11' +c_std = 'gnu11' cpp_std = 'c++23' -c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] -cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] @@ -138,9 +135,9 @@ fi if [ ! -d "$ROMFS" ]; then - mkdir -p $ROMFS + mkdir -p "$ROMFS" - cp -r assets $ROMFS + cp -r assets "$ROMFS" fi diff --git a/src/application.cpp b/src/application.cpp index 84179536..bc0593bc 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -285,11 +285,16 @@ void Application::try_load_settings() { void Application::load_resources() { constexpr auto fonts_size = 128; - const std::vector> fonts{ - { FontId::Default, "PressStart2P.ttf"}, - { FontId::Arial, "arial.ttf"}, - {FontId::NotoColorEmoji, "NotoColorEmoji.ttf"}, - { FontId::Symbola, "Symbola.ttf"} + const std::vector> fonts { +#if defined(__3DS__) + //TODO: debug why the other font crashed, not on loading, but on trying to render text! + { FontId::Default, "LeroyLetteringLightBeta01.ttf" }, +#else + { FontId::Default, "PressStart2P.ttf" }, +#endif + { FontId::Arial, "arial.ttf" }, { FontId::NotoColorEmoji, "NotoColorEmoji.ttf" }, { + FontId::Symbola, "Symbola.ttf" + } }; for (const auto& [font_id, path] : fonts) { const auto font_path = utils::get_assets_folder() / "fonts" / path; diff --git a/src/graphics/renderer.cpp b/src/graphics/renderer.cpp index 91e5785b..fed3b9ae 100644 --- a/src/graphics/renderer.cpp +++ b/src/graphics/renderer.cpp @@ -3,13 +3,19 @@ //TODO: assert return values of all sdl functions -Renderer::Renderer(const Window& window, const VSync v_sync) - : m_renderer{ SDL_CreateRenderer( - window.get_sdl_window(), - -1, +Renderer::Renderer(const Window& window, const VSync v_sync) : m_renderer { + SDL_CreateRenderer( + window.get_sdl_window(), -1, (v_sync == VSync::Enabled ? SDL_RENDERER_PRESENTVSYNC : 0) | SDL_RENDERER_TARGETTEXTURE +#if defined(__3DS__) + | SDL_RENDERER_SOFTWARE +#else | SDL_RENDERER_ACCELERATED - ) } { +#endif + ) +} +{ + if (m_renderer == nullptr) { throw helper::InitializationError{ fmt::format("Failed creating a SDL Renderer: {}", SDL_GetError()) }; } diff --git a/src/helper/console_helpers.hpp b/src/helper/console_helpers.hpp index e7803a52..05df762d 100644 --- a/src/helper/console_helpers.hpp +++ b/src/helper/console_helpers.hpp @@ -38,7 +38,16 @@ namespace console { void sink_it_(const spdlog::details::log_msg& msg) override { spdlog::memory_buf_t formatted; spdlog::sinks::base_sink::formatter_->format(msg, formatted); - debug_write(formatted.data(), static_cast(formatted.size())); + + auto size = formatted.size(); + + // debug_write already writes an newline at the end! + if (size > 0 and formatted.data()[size - 1] == '\n') { + formatted.data()[size - 1] = '\0'; + --size; + } + + debug_write(formatted.data(), size); } void flush_() override { diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build index a36bf312..d9b1cf08 100644 --- a/tools/dependencies/meson.build +++ b/tools/dependencies/meson.build @@ -9,6 +9,22 @@ if meson.is_cross_build() } only_allow_native_libs = true + + # TODO: debug, if exceptions or rtti work on the 3ds + + # if host_machine.system() == '3ds' + # add_global_link_arguments( + # '-fno-rtti', + # '-fno-exceptions', + # language: ['cpp'], + # ) + # add_global_arguments( + # '-fno-rtti', + # '-fno-exceptions', + # language: ['cpp'], + # ) + # endif + endif endif From 9fe4790535823d84639491d53cc98e010cf589e0 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Sun, 14 Apr 2024 23:48:17 +0200 Subject: [PATCH 13/19] - add more switch buttons, add descriptions to if - add 3ds buttons and use them - define console_input --- src/platform/capabilities.hpp | 18 ++++- src/platform/console_buttons.hpp | 124 +++++++++++++++++++++++++------ src/platform/console_input.cpp | 51 ++++++++++++- 3 files changed, 168 insertions(+), 25 deletions(-) diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index 53d9e059..fe3d833c 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -70,7 +70,23 @@ namespace utils { {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, { static_cast(CrossPlatformAction::TAB), {}}, // no tab support }; -//TODO: support 3ds +#elif defined(__3DS__) + { + { static_cast(CrossPlatformAction::OK),{ JOYCON_A } }, + { static_cast(CrossPlatformAction::PAUSE), { JOYCON_SELECT }}, + { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_SELECT }}, + { static_cast(CrossPlatformAction::EXIT), { JOYCON_START }}, + { static_cast(CrossPlatformAction::DOWN), + { JOYCON_DPAD_DOWN, JOYCON_CSTICK_DOWN, JOYCON_CPAD_DOWN } }, + { static_cast(CrossPlatformAction::UP), { JOYCON_DPAD_UP, JOYCON_CSTICK_UP, JOYCON_CPAD_UP }}, + { static_cast(CrossPlatformAction::LEFT), + { JOYCON_DPAD_LEFT, JOYCON_CSTICK_LEFT, JOYCON_CPAD_LEFT } }, + { static_cast(CrossPlatformAction::RIGHT), + { JOYCON_DPAD_RIGHT, JOYCON_CSTICK_RIGHT, JOYCON_CPAD_RIGHT } }, + { static_cast(CrossPlatformAction::CLOSE), { JOYCON_X }}, + {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::TAB), {}}, // no tab support +}; #else { { static_cast(CrossPlatformAction::OK), { SDLK_RETURN, SDLK_SPACE }}, diff --git a/src/platform/console_buttons.hpp b/src/platform/console_buttons.hpp index 9ed781a2..3e4dbb80 100644 --- a/src/platform/console_buttons.hpp +++ b/src/platform/console_buttons.hpp @@ -14,7 +14,7 @@ namespace { // this is rounding down since >> 1 throws away the least significant bit, but if its a power of two it is spot on - constexpr unsigned BITL_REVERSE(unsigned x) { + constexpr unsigned long BITL_REVERSE(unsigned long x) { return x == 1 ? 0 : 1 + BITL_REVERSE(x >> 1); } }; // namespace @@ -22,25 +22,50 @@ namespace { //using C enum (not enum class) on purpose enum JOYCON { - JOYCON_A = BITL_REVERSE(HidNpadButton_A), - JOYCON_B = BITL_REVERSE(HidNpadButton_B), - JOYCON_X = BITL_REVERSE(HidNpadButton_X), - JOYCON_Y = BITL_REVERSE(HidNpadButton_Y), - - JOYCON_PLUS = BITL_REVERSE(HidNpadButton_Plus), - JOYCON_MINUS = BITL_REVERSE(HidNpadButton_Minus), - JOYCON_CROSS_LEFT = BITL_REVERSE(HidNpadButton_Left), - JOYCON_CROSS_UP = BITL_REVERSE(HidNpadButton_Up), - JOYCON_CROSS_RIGHT = BITL_REVERSE(HidNpadButton_Right), - JOYCON_CROSS_DOWN = BITL_REVERSE(HidNpadButton_Down), - JOYCON_LDPAD_LEFT = BITL_REVERSE(HidNpadButton_StickLLeft), - JOYCON_LDPAD_UP = BITL_REVERSE(HidNpadButton_StickLUp), - JOYCON_LDPAD_RIGHT = BITL_REVERSE(HidNpadButton_StickLRight), - JOYCON_LDPAD_DOWN = BITL_REVERSE(HidNpadButton_StickLDown), - JOYCON_RDPAD_LEFT = BITL_REVERSE(HidNpadButton_StickRLeft), - JOYCON_RDPAD_UP = BITL_REVERSE(HidNpadButton_StickRUp), - JOYCON_RDPAD_RIGHT = BITL_REVERSE(HidNpadButton_StickRRight), - JOYCON_RDPAD_DOWN = BITL_REVERSE(HidNpadButton_StickRDown) + // see /opt/devkitpro/libnx/include/switch/services/hid.h + + JOYCON_A = BITL_REVERSE(HidNpadButton_A), ///< A button / Right face button + JOYCON_B = BITL_REVERSE(HidNpadButton_B), ///< B button / Down face button + JOYCON_X = BITL_REVERSE(HidNpadButton_X), ///< X button / Up face button + JOYCON_Y = BITL_REVERSE(HidNpadButton_Y), ///< Y button / Left face button + + //NOTE: stick buttons are not key events, but can be moved, these need separate handling + JOYCON_STICK_L = BITL(HidNpadButton_StickL), ///< Left Stick button + JOYCON_STICK_R = BITL(HidNpadButton_StickR), ///< Right Stick button + + JOYCON_L = BITL_REVERSE(HidNpadButton_L), ///< L button + JOYCON_R = BITL(HidNpadButton_R), ///< R button + JOYCON_ZL = BITL(HidNpadButton_ZL), ///< ZL button + JOYCON_ZR = BITL(HidNpadButton_ZR), ///< ZR button + + + JOYCON_PLUS = BITL_REVERSE(HidNpadButton_Plus), ///< Plus button + JOYCON_MINUS = BITL_REVERSE(HidNpadButton_Minus), ///< Minus button + + // DPAD alias CROSS + JOYCON_DPAD_LEFT = BITL_REVERSE(HidNpadButton_Left), ///< D-Pad Left button + JOYCON_DPAD_UP = BITL_REVERSE(HidNpadButton_Up), ///< D-Pad Up button + JOYCON_DPAD_RIGHT = BITL_REVERSE(HidNpadButton_Right), ///< D-Pad Right button + JOYCON_DPAD_DOWN = BITL_REVERSE(HidNpadButton_Down), ///< D-Pad Down button + + JOYCON_LDPAD_LEFT = BITL_REVERSE(HidNpadButton_StickLLeft), ///< Left Stick pseudo-button when moved Left + JOYCON_LDPAD_UP = BITL_REVERSE(HidNpadButton_StickLUp), ///< Left Stick pseudo-button when moved Up + JOYCON_LDPAD_RIGHT = BITL_REVERSE(HidNpadButton_StickLRight), ///< Left Stick pseudo-button when moved Right + JOYCON_LDPAD_DOWN = BITL_REVERSE(HidNpadButton_StickLDown), ///< Left Stick pseudo-button when moved Down + + JOYCON_RDPAD_LEFT = BITL_REVERSE(HidNpadButton_StickRLeft), ///< Right Stick pseudo-button when moved Left + JOYCON_RDPAD_UP = BITL_REVERSE(HidNpadButton_StickRUp), ///< Right Stick pseudo-button when moved Up + JOYCON_RDPAD_RIGHT = BITL_REVERSE(HidNpadButton_StickRRight), ///< Right Stick pseudo-button when moved Right + JOYCON_RDPAD_DOWN = BITL_REVERSE(HidNpadButton_StickRDown), ///< Right Stick pseudo-button when moved Left + + + JOYCON_JOYCONL_SL = BITL_REVERSE(HidNpadButton_LeftSL), ///< SL button on Left Joy-Con + JOYCON_JOYCONL_SR = BITL_REVERSE(HidNpadButton_LeftSR), ///< SR button on Left Joy-Con + + JOYCON_JOYCONR_SL = BITL_REVERSE(HidNpadButton_RightSL), ///< SL button on Right Joy-Con + JOYCON_JOYCONR_SL = BITL_REVERSE(HidNpadButton_RightSR), ///< SR button on Right Joy-Con + + JOYCON_VERIFICATION = BITL_REVERSE(HidNpadButton_Verification), ///< Verification }; @@ -48,9 +73,66 @@ enum JOYCON { static_assert(BITL(JOYCON_B) == HidNpadButton_B); static_assert(BITL(JOYCON_PLUS) == HidNpadButton_Plus); +#elif defined(__3DS__) + + +#include <3ds.h> + +// some 3ds buttons, from libctru, but since SDL doesn't handle inputs as flags, like libctru, the have to be reversed and reversing 1 << x = log_2(x), this is done constexpr + + +namespace { + // this is rounding down since >> 1 throws away the least significant bit, but if its a power of two it is spot on + constexpr unsigned int BIT_REVERSE(unsigned int x) { + return x == 1 ? 0 : 1 + BIT_REVERSE(x >> 1); + } +}; // namespace + +//using C enum (not enum class) on purpose +enum JOYCON { + + // see /opt/devkitpro/libctru/include/3ds/services/hid.h + + JOYCON_A = BIT_REVERSE(KEY_A), ///< A + JOYCON_B = BIT_REVERSE(KEY_B), ///< B + + JOYCON_SELECT = BIT_REVERSE(KEY_SELECT), ///< Select + JOYCON_START = BIT_REVERSE(KEY_START), ///< Start + + JOYCON_DPAD_RIGHT = BIT_REVERSE(KEY_DRIGHT), ///< D-Pad Right + JOYCON_DPAD_LEFT = BIT_REVERSE(KEY_DLEFT), ///< D-Pad Left + JOYCON_DPAD_UP = BIT_REVERSE(KEY_DUP), ///< D-Pad Up + JOYCON_DPAD_DOWN = BIT_REVERSE(KEY_DDOWN), ///< D-Pad Down + + JOYCON_R = BIT_REVERSE(KEY_R), ///< R + JOYCON_L = BIT_REVERSE(KEY_L), ///< L + JOYCON_X = BIT_REVERSE(KEY_X), ///< X + JOYCON_Y = BIT_REVERSE(KEY_Y), ///< Y + + JOYCON_ZL = BIT_REVERSE(KEY_ZL), ///< ZL (New 3DS only) + JOYCON_ZR = BIT_REVERSE(KEY_ZR), ///< ZR (New 3DS only) + + // has to be handled separately, but MIGHT be used in some form by SDL2 + JOYCON_TOUCH = BIT_REVERSE(KEY_TOUCH), ///< Touch (Not actually provided by HID) + + JOYCON_CSTICK_RIGHT = BIT_REVERSE(KEY_CSTICK_RIGHT), ///< C-Stick Right (New 3DS only) + JOYCON_CSTICK_LEFT = BIT_REVERSE(KEY_CSTICK_LEFT), ///< C-Stick Left (New 3DS only) + JOYCON_CSTICK_UP = BIT_REVERSE(KEY_CSTICK_UP), ///< C-Stick Up (New 3DS only) + JOYCON_CSTICK_DOWN = BIT_REVERSE(KEY_CSTICK_DOWN), ///< C-Stick Down (New 3DS only) + + JOYCON_CPAD_RIGHT = BIT_REVERSE(KEY_CPAD_RIGHT), ///< Circle Pad Right + JOYCON_CPAD_LEFT = BIT_REVERSE(KEY_CPAD_LEFT), ///< Circle Pad Left + JOYCON_CPAD_UP = BIT_REVERSE(KEY_CPAD_UP), ///< Circle Pad Up + JOYCON_CPAD_DOWN = BIT_REVERSE(KEY_CPAD_DOWN), ///< Circle Pad Down + +}; + +// some static asserts to check if BIT_REVERSE works as expected +static_assert(BIT(JOYCON_B) == KEY_B); +static_assert(BIT(JOYCON_SELECT) == KEY_SELECT); + #endif -//TODO: implement for 3ds #endif diff --git a/src/platform/console_input.cpp b/src/platform/console_input.cpp index 266bd529..3a1b6d1f 100644 --- a/src/platform/console_input.cpp +++ b/src/platform/console_input.cpp @@ -74,12 +74,57 @@ helper::optional JoystickInput::sdl_event_to_input_event(const SDL_E } #elif defined(__3DS__) -//TODO: implement for 3ds + helper::optional JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const { - UNUSED(event); + if (event.type == SDL_JOYBUTTONDOWN) { + const auto button = event.jbutton.button; + if (button == JOYCON_Y) { + return InputEvent::RotateLeftPressed; + } + if (button == JOYCON_X) { + return InputEvent::RotateRightPressed; + } + if (button == JOYCON_DPAD_DOWN or button == JOYCON_CSTICK_DOWN) { + return InputEvent::MoveDownPressed; + } + if (button == JOYCON_DPAD_LEFT or button == JOYCON_CSTICK_LEFT) { + return InputEvent::MoveLeftPressed; + } + if (button == JOYCON_DPAD_RIGHT or button == JOYCON_CSTICK_RIGHT) { + return InputEvent::MoveRightPressed; + } + if (button == JOYCON_A) { + return InputEvent::DropPressed; + } + if (button == JOYCON_B) { + return InputEvent::HoldPressed; + } + } else if (event.type == SDL_JOYBUTTONUP) { + const auto button = event.jbutton.button; + if (button == JOYCON_Y) { + return InputEvent::RotateLeftReleased; + } + if (button == JOYCON_X) { + return InputEvent::RotateRightReleased; + } + if (button == JOYCON_DPAD_DOWN or button == JOYCON_CSTICK_DOWN) { + return InputEvent::MoveDownReleased; + } + if (button == JOYCON_DPAD_LEFT or button == JOYCON_CSTICK_LEFT) { + return InputEvent::MoveLeftReleased; + } + if (button == JOYCON_DPAD_RIGHT or button == JOYCON_CSTICK_RIGHT) { + return InputEvent::MoveRightReleased; + } + if (button == JOYCON_A) { + return InputEvent::DropReleased; + } + if (button == JOYCON_B) { + return InputEvent::HoldReleased; + } + } return helper::nullopt; } - #endif From 662aaddbb4a729ab86915fcd3d7fbcc6de166415 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Mon, 15 Apr 2024 00:16:00 +0200 Subject: [PATCH 14/19] make 3ds keys work --- platforms/build-3ds.sh | 2 +- platforms/build-switch.sh | 2 +- src/manager/event_dispatcher.hpp | 1 - src/platform/capabilities.cpp | 26 +++++++++++++++++++++++++- src/platform/capabilities.hpp | 10 +++++----- src/platform/console_input.cpp | 8 ++++---- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh index b92b919c..68bb0829 100755 --- a/platforms/build-3ds.sh +++ b/platforms/build-3ds.sh @@ -240,7 +240,7 @@ if [ ! -d "$ROMFS" ]; then mkdir -p "$ROMFS" - cp -r assets "$ROMFS" + cp -r assets "$ROMFS/" fi diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 0d2cd5ff..67365ec6 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -137,7 +137,7 @@ if [ ! -d "$ROMFS" ]; then mkdir -p "$ROMFS" - cp -r assets "$ROMFS" + cp -r assets "$ROMFS/" fi diff --git a/src/manager/event_dispatcher.hpp b/src/manager/event_dispatcher.hpp index 54b46975..9e3683a1 100644 --- a/src/manager/event_dispatcher.hpp +++ b/src/manager/event_dispatcher.hpp @@ -38,7 +38,6 @@ struct EventDispatcher final { SDL_Event event; while (SDL_PollEvent(&event) != 0) { - if (m_input_activated) { switch (event.type) { case SDL_KEYDOWN: diff --git a/src/platform/capabilities.cpp b/src/platform/capabilities.cpp index 65c84287..9bde5b1a 100644 --- a/src/platform/capabilities.cpp +++ b/src/platform/capabilities.cpp @@ -127,7 +127,8 @@ namespace { const std::vector needed_events = utils::key_map.at(static_cast(action)); for (const auto& needed_event : needed_events) { // NOLINT(readability-use-anyofallof) -#if defined(__SWITCH__) +#if defined(__SWITCH__) or defined(__3DS__) + //TODO: some events use the SDL_JOYAXISMOTION event, but that needs to be done in the next reiteration of these helpers! if (event.type == SDL_JOYBUTTONDOWN and event.jbutton.button == needed_event) { return true; } @@ -213,6 +214,29 @@ namespace { default: utils::unreachable(); } +#elif defined(__3DS__) + switch (action) { + case CrossPlatformAction::OK: + return "A"; + case CrossPlatformAction::PAUSE: + case CrossPlatformAction::UNPAUSE: + return "Y"; + case CrossPlatformAction::CLOSE: + case CrossPlatformAction::EXIT: + return "X"; + case CrossPlatformAction::DOWN: + return "Down"; + case CrossPlatformAction::UP: + return "Up"; + case CrossPlatformAction::LEFT: + return "Left"; + case CrossPlatformAction::RIGHT: + return "Right"; + case CrossPlatformAction::OPEN_SETTINGS: + return "Select"; + default: + utils::unreachable(); + } #else switch (action) { case CrossPlatformAction::OK: diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index fe3d833c..baa47c60 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -73,9 +73,9 @@ namespace utils { #elif defined(__3DS__) { { static_cast(CrossPlatformAction::OK),{ JOYCON_A } }, - { static_cast(CrossPlatformAction::PAUSE), { JOYCON_SELECT }}, - { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_SELECT }}, - { static_cast(CrossPlatformAction::EXIT), { JOYCON_START }}, + { static_cast(CrossPlatformAction::PAUSE), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::EXIT), { JOYCON_X }}, { static_cast(CrossPlatformAction::DOWN), { JOYCON_DPAD_DOWN, JOYCON_CSTICK_DOWN, JOYCON_CPAD_DOWN } }, { static_cast(CrossPlatformAction::UP), { JOYCON_DPAD_UP, JOYCON_CSTICK_UP, JOYCON_CPAD_UP }}, @@ -83,8 +83,8 @@ namespace utils { { JOYCON_DPAD_LEFT, JOYCON_CSTICK_LEFT, JOYCON_CPAD_LEFT } }, { static_cast(CrossPlatformAction::RIGHT), { JOYCON_DPAD_RIGHT, JOYCON_CSTICK_RIGHT, JOYCON_CPAD_RIGHT } }, - { static_cast(CrossPlatformAction::CLOSE), { JOYCON_X }}, - {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::CLOSE), { JOYCON_X }}, + {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_SELECT }}, { static_cast(CrossPlatformAction::TAB), {}}, // no tab support }; #else diff --git a/src/platform/console_input.cpp b/src/platform/console_input.cpp index 3a1b6d1f..c9b160b0 100644 --- a/src/platform/console_input.cpp +++ b/src/platform/console_input.cpp @@ -78,10 +78,10 @@ helper::optional JoystickInput::sdl_event_to_input_event(const SDL_E helper::optional JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const { if (event.type == SDL_JOYBUTTONDOWN) { const auto button = event.jbutton.button; - if (button == JOYCON_Y) { + if (button == JOYCON_L) { return InputEvent::RotateLeftPressed; } - if (button == JOYCON_X) { + if (button == JOYCON_R) { return InputEvent::RotateRightPressed; } if (button == JOYCON_DPAD_DOWN or button == JOYCON_CSTICK_DOWN) { @@ -101,10 +101,10 @@ helper::optional JoystickInput::sdl_event_to_input_event(const SDL_E } } else if (event.type == SDL_JOYBUTTONUP) { const auto button = event.jbutton.button; - if (button == JOYCON_Y) { + if (button == JOYCON_L) { return InputEvent::RotateLeftReleased; } - if (button == JOYCON_X) { + if (button == JOYCON_R) { return InputEvent::RotateRightReleased; } if (button == JOYCON_DPAD_DOWN or button == JOYCON_CSTICK_DOWN) { From 7c7d8b126bbef2838c990fcb9855936b5d3e3aa0 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Mon, 15 Apr 2024 00:22:43 +0200 Subject: [PATCH 15/19] add 3ds to the list of supported platforms in the readme --- README.md | 4 ++-- docs/3ds.md | 24 ++++++++++++++++++++++++ docs/develop.md | 6 ++++++ src/ui/components/color_picker.cpp | 4 ++-- src/ui/components/textinput.cpp | 2 +- 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 docs/3ds.md diff --git a/README.md b/README.md index 54172c30..cc7d9d42 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ It is written in [OOP](https://en.wikipedia.org/wiki/Object-oriented_programming ## Platform support -This officially supports Linux, Windows, MacOS, Android and Nintendo switch. +This officially supports Linux, Windows, MacOS, Android, Nintendo Switch and Nintendo 3DS. Why these? Because it was fun to port the application to those platforms 😋 @@ -27,7 +27,7 @@ To download artifacts, click on the newest action and download the artifacts. [Linux (Flatpak)](https://github.com/mgerhold/oopetris/actions/workflows/flatpak.yml) -[Nintendo Switch](https://github.com/mgerhold/oopetris/actions/workflows/nintendo.yml) +[Nintendo Switch /3DS](https://github.com/mgerhold/oopetris/actions/workflows/nintendo.yml) There is no correct Windows and MacOS build atm, you have to built it yourself or use the (maybe not published yet) release builds on github. diff --git a/docs/3ds.md b/docs/3ds.md new file mode 100644 index 00000000..c510db45 --- /dev/null +++ b/docs/3ds.md @@ -0,0 +1,24 @@ +# Nintendo 3DS build + +## Prerequisites + +- a C++23 compatible cross compiler, we only support The [devkitpro](https://devkitpro.org/) one +- meson + + +## Compiling + + +Cross Compiling is only possible on linux-like systems. + +SDL2 officially supports 3ds, so there are no portlibs, so on the initial run of the bash script, SDL2 will be built, and installed into the devkitpro portlibs root folder, this might need sudo (but installing the other toolchains from devkitpro required that too). + +We use meson and cross-compilation files, everything is wrapped into shell script, so you just need to run: + + +```bash +./platforms/build-3ds.sh + +``` +After that you can find the runnable executable (also supports emulators) +in `build-3ds/oopetris.3dsx` diff --git a/docs/develop.md b/docs/develop.md index 6a19ecf9..2a574225 100644 --- a/docs/develop.md +++ b/docs/develop.md @@ -22,6 +22,12 @@ For concrete instructions, see the list below: [switch](switch.md) + +## Nintendo 3DS + +[switch](3ds.md) + + ## Android [android](android.md) diff --git a/src/ui/components/color_picker.cpp b/src/ui/components/color_picker.cpp index a7e6548b..107e1238 100644 --- a/src/ui/components/color_picker.cpp +++ b/src/ui/components/color_picker.cpp @@ -130,7 +130,7 @@ void detail::ColorCanvas::draw_pseudo_circle(const ServiceProvider& service_prov u32 diameter = 5; - // width == height here, since we assured that in the construction of the layout fro this component, so instead of taking the min of width and height i just use width, this fact is only used here, since it's not that bad, if it changes sometime in teh future + // width == height here, since we assured that in the construction of the layout fro this component, so instead of taking the min of width and height i just use width, this fact is only used here, since it's not that bad, if it changes sometime in the future if (const double percentage_diameter = static_cast(layout().get_rect().width()) * 0.03; percentage_diameter >= static_cast(diameter)) { diameter = static_cast(percentage_diameter); @@ -356,7 +356,7 @@ ui::ColorPicker::ColorPicker( this->m_color = Color{ hsv_color }; // if we hover at e.g. the edges, and don't change anything, we don't need to call after_color_change - // this also helps, since the slider reports change on click and on release, even if teh position doesn't change there + // this also helps, since the slider reports change on click and on release, even if the position doesn't change there if (previous_color == this->m_color) { return; } diff --git a/src/ui/components/textinput.cpp b/src/ui/components/textinput.cpp index a9742a31..197e25ec 100644 --- a/src/ui/components/textinput.cpp +++ b/src/ui/components/textinput.cpp @@ -335,7 +335,7 @@ void ui::TextInput::recalculate_textures(bool text_changed) { //NOLINT(readabili } else if ((m_scaled_text_size - cursor_middle) < static_cast(fill_rect().width())) { final_offset = m_scaled_text_size - static_cast(fill_rect().width()); - // if we reached the end, we have shift the cursor for some pixels, so that we can see the bar xD, thsi strectehces it slightly, but it's a simple solution + // if we reached the end, we have shift the cursor for some pixels, so that we can see the bar xD, this stretches it slightly, but it's a simple solution if ((m_scaled_text_size - cursor_middle) <= static_cast(fill_rect().width() / 2)) { final_offset += 2 * cursor_width; } From c044d28a020fa7fed30eaa682cae8ddfb0d4cf64 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Mon, 15 Apr 2024 00:29:50 +0200 Subject: [PATCH 16/19] fix compilation --- platforms/build-3ds.sh | 7 +++++-- platforms/build-switch.sh | 7 +++++-- src/platform/capabilities.hpp | 8 ++++---- src/platform/console_buttons.hpp | 12 ++++++------ src/platform/console_input.cpp | 8 ++++---- 5 files changed, 24 insertions(+), 18 deletions(-) diff --git a/platforms/build-3ds.sh b/platforms/build-3ds.sh index 68bb0829..bf636413 100755 --- a/platforms/build-3ds.sh +++ b/platforms/build-3ds.sh @@ -45,6 +45,9 @@ export ENDIANESS="little" export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard','-mtp=soft','-mword-relocations','-ffunction-sections','-fdata-sections'" +# compat flags for some POSIX functions +export EXTRA_COMPILE_FLAGS="'-D_XOPEN_SOURCE'" + export COMPILE_FLAGS="'-D_3DS','-D__3DS__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBCTRU/include','-I$PORTLIBS_PATH_3DS/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBCTRU_LIB','-fPIE','-specs=$ARCH_DEVKIT_FOLDER/$TOOL_PREFIX/lib/3dsx.specs'" @@ -86,8 +89,8 @@ sdl2-config='$BIN_DIR/bin/sdl2-config' [built-in options] c_std = 'gnu11' cpp_std = 'c++23' -c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] -cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 67365ec6..1d926c39 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -43,6 +43,9 @@ export ENDIANESS="little" export COMMON_FLAGS="'-ftls-model=local-exec','-march=armv8-a+crc+crypto','-mtune=cortex-a57','-mtp=soft','-ftls-model=local-exec','-fPIC','-ffunction-sections','-fdata-sections'" +# compat flags for some POSIX functions +export EXTRA_COMPILE_FLAGS="'-D_XOPEN_SOURCE'" + export COMPILE_FLAGS="'-D__SWITCH__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'" export LINK_FLAGS="'-L$PORTLIBS_LIB','-L$LIBNX_LIB','-fPIE','-specs=$DEVKITPRO/libnx/switch.specs'" @@ -84,8 +87,8 @@ sdl2-config='$BIN_DIR/sdl2-config' [built-in options] c_std = 'gnu11' cpp_std = 'c++23' -c_args = [$COMMON_FLAGS, $COMPILE_FLAGS] -cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS] +c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] +cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS] c_link_args = [$COMMON_FLAGS, $LINK_FLAGS] cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS] diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index baa47c60..3abe53dc 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -60,12 +60,12 @@ namespace utils { { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_PLUS }}, { static_cast(CrossPlatformAction::EXIT), { JOYCON_MINUS }}, { static_cast(CrossPlatformAction::DOWN), - { JOYCON_CROSS_DOWN, JOYCON_LDPAD_DOWN, JOYCON_RDPAD_DOWN } }, - { static_cast(CrossPlatformAction::UP), { JOYCON_CROSS_UP, JOYCON_LDPAD_UP, JOYCON_RDPAD_UP }}, + { JOYCON_DPAD_DOWN, JOYCON_LDPAD_DOWN, JOYCON_RDPAD_DOWN } }, + { static_cast(CrossPlatformAction::UP), { JOYCON_DPAD_UP, JOYCON_LDPAD_UP, JOYCON_RDPAD_UP }}, { static_cast(CrossPlatformAction::LEFT), - { JOYCON_CROSS_LEFT, JOYCON_LDPAD_LEFT, JOYCON_RDPAD_LEFT } }, + { JOYCON_DPAD_LEFT, JOYCON_LDPAD_LEFT, JOYCON_RDPAD_LEFT } }, { static_cast(CrossPlatformAction::RIGHT), - { JOYCON_CROSS_RIGHT, JOYCON_LDPAD_RIGHT, JOYCON_RDPAD_RIGHT } }, + { JOYCON_DPAD_RIGHT, JOYCON_LDPAD_RIGHT, JOYCON_RDPAD_RIGHT } }, { static_cast(CrossPlatformAction::CLOSE), { JOYCON_MINUS }}, {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, { static_cast(CrossPlatformAction::TAB), {}}, // no tab support diff --git a/src/platform/console_buttons.hpp b/src/platform/console_buttons.hpp index 3e4dbb80..9cb3e895 100644 --- a/src/platform/console_buttons.hpp +++ b/src/platform/console_buttons.hpp @@ -30,13 +30,13 @@ enum JOYCON { JOYCON_Y = BITL_REVERSE(HidNpadButton_Y), ///< Y button / Left face button //NOTE: stick buttons are not key events, but can be moved, these need separate handling - JOYCON_STICK_L = BITL(HidNpadButton_StickL), ///< Left Stick button - JOYCON_STICK_R = BITL(HidNpadButton_StickR), ///< Right Stick button + JOYCON_STICK_L = BITL_REVERSE(HidNpadButton_StickL), ///< Left Stick button + JOYCON_STICK_R = BITL_REVERSE(HidNpadButton_StickR), ///< Right Stick button JOYCON_L = BITL_REVERSE(HidNpadButton_L), ///< L button - JOYCON_R = BITL(HidNpadButton_R), ///< R button - JOYCON_ZL = BITL(HidNpadButton_ZL), ///< ZL button - JOYCON_ZR = BITL(HidNpadButton_ZR), ///< ZR button + JOYCON_R = BITL_REVERSE(HidNpadButton_R), ///< R button + JOYCON_ZL = BITL_REVERSE(HidNpadButton_ZL), ///< ZL button + JOYCON_ZR = BITL_REVERSE(HidNpadButton_ZR), ///< ZR button JOYCON_PLUS = BITL_REVERSE(HidNpadButton_Plus), ///< Plus button @@ -63,7 +63,7 @@ enum JOYCON { JOYCON_JOYCONL_SR = BITL_REVERSE(HidNpadButton_LeftSR), ///< SR button on Left Joy-Con JOYCON_JOYCONR_SL = BITL_REVERSE(HidNpadButton_RightSL), ///< SL button on Right Joy-Con - JOYCON_JOYCONR_SL = BITL_REVERSE(HidNpadButton_RightSR), ///< SR button on Right Joy-Con + JOYCON_JOYCONR_SR = BITL_REVERSE(HidNpadButton_RightSR), ///< SR button on Right Joy-Con JOYCON_VERIFICATION = BITL_REVERSE(HidNpadButton_Verification), ///< Verification diff --git a/src/platform/console_input.cpp b/src/platform/console_input.cpp index c9b160b0..76947d93 100644 --- a/src/platform/console_input.cpp +++ b/src/platform/console_input.cpp @@ -25,10 +25,10 @@ void JoystickInput::update(SimulationStep simulation_step_index) { helper::optional JoystickInput::sdl_event_to_input_event(const SDL_Event& event) const { if (event.type == SDL_JOYBUTTONDOWN) { const auto button = event.jbutton.button; - if (button == JOYCON_CROSS_LEFT) { + if (button == JOYCON_DPAD_LEFT) { return InputEvent::RotateLeftPressed; } - if (button == JOYCON_CROSS_RIGHT) { + if (button == JOYCON_DPAD_RIGHT) { return InputEvent::RotateRightPressed; } if (button == JOYCON_LDPAD_DOWN or button == JOYCON_RDPAD_DOWN) { @@ -48,10 +48,10 @@ helper::optional JoystickInput::sdl_event_to_input_event(const SDL_E } } else if (event.type == SDL_JOYBUTTONUP) { const auto button = event.jbutton.button; - if (button == JOYCON_CROSS_LEFT) { + if (button == JOYCON_DPAD_LEFT) { return InputEvent::RotateLeftReleased; } - if (button == JOYCON_CROSS_RIGHT) { + if (button == JOYCON_DPAD_RIGHT) { return InputEvent::RotateRightReleased; } if (button == JOYCON_LDPAD_DOWN or button == JOYCON_RDPAD_DOWN) { From 4661750cea6e87f16f04619bec3f5bac60daa2a1 Mon Sep 17 00:00:00 2001 From: Totto16 Date: Mon, 15 Apr 2024 00:32:00 +0200 Subject: [PATCH 17/19] fix clang format --- src/platform/capabilities.hpp | 22 +++++++++++----------- src/platform/console_buttons.hpp | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/platform/capabilities.hpp b/src/platform/capabilities.hpp index 3abe53dc..31bf07a8 100644 --- a/src/platform/capabilities.hpp +++ b/src/platform/capabilities.hpp @@ -56,9 +56,9 @@ namespace utils { #elif defined(__SWITCH__) { { static_cast(CrossPlatformAction::OK),{ JOYCON_A } }, - { static_cast(CrossPlatformAction::PAUSE), { JOYCON_PLUS }}, - { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_PLUS }}, - { static_cast(CrossPlatformAction::EXIT), { JOYCON_MINUS }}, + { static_cast(CrossPlatformAction::PAUSE), { JOYCON_PLUS }}, + { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_PLUS }}, + { static_cast(CrossPlatformAction::EXIT), { JOYCON_MINUS }}, { static_cast(CrossPlatformAction::DOWN), { JOYCON_DPAD_DOWN, JOYCON_LDPAD_DOWN, JOYCON_RDPAD_DOWN } }, { static_cast(CrossPlatformAction::UP), { JOYCON_DPAD_UP, JOYCON_LDPAD_UP, JOYCON_RDPAD_UP }}, @@ -66,16 +66,16 @@ namespace utils { { JOYCON_DPAD_LEFT, JOYCON_LDPAD_LEFT, JOYCON_RDPAD_LEFT } }, { static_cast(CrossPlatformAction::RIGHT), { JOYCON_DPAD_RIGHT, JOYCON_LDPAD_RIGHT, JOYCON_RDPAD_RIGHT } }, - { static_cast(CrossPlatformAction::CLOSE), { JOYCON_MINUS }}, - {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, - { static_cast(CrossPlatformAction::TAB), {}}, // no tab support + { static_cast(CrossPlatformAction::CLOSE), { JOYCON_MINUS }}, + {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::TAB), {}}, // no tab support }; #elif defined(__3DS__) { { static_cast(CrossPlatformAction::OK),{ JOYCON_A } }, - { static_cast(CrossPlatformAction::PAUSE), { JOYCON_Y }}, - { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_Y }}, - { static_cast(CrossPlatformAction::EXIT), { JOYCON_X }}, + { static_cast(CrossPlatformAction::PAUSE), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::UNPAUSE), { JOYCON_Y }}, + { static_cast(CrossPlatformAction::EXIT), { JOYCON_X }}, { static_cast(CrossPlatformAction::DOWN), { JOYCON_DPAD_DOWN, JOYCON_CSTICK_DOWN, JOYCON_CPAD_DOWN } }, { static_cast(CrossPlatformAction::UP), { JOYCON_DPAD_UP, JOYCON_CSTICK_UP, JOYCON_CPAD_UP }}, @@ -83,8 +83,8 @@ namespace utils { { JOYCON_DPAD_LEFT, JOYCON_CSTICK_LEFT, JOYCON_CPAD_LEFT } }, { static_cast(CrossPlatformAction::RIGHT), { JOYCON_DPAD_RIGHT, JOYCON_CSTICK_RIGHT, JOYCON_CPAD_RIGHT } }, - { static_cast(CrossPlatformAction::CLOSE), { JOYCON_X }}, - {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_SELECT }}, + { static_cast(CrossPlatformAction::CLOSE), { JOYCON_X }}, + {static_cast(CrossPlatformAction::OPEN_SETTINGS), { JOYCON_SELECT }}, { static_cast(CrossPlatformAction::TAB), {}}, // no tab support }; #else diff --git a/src/platform/console_buttons.hpp b/src/platform/console_buttons.hpp index 9cb3e895..7b9b75fa 100644 --- a/src/platform/console_buttons.hpp +++ b/src/platform/console_buttons.hpp @@ -33,10 +33,10 @@ enum JOYCON { JOYCON_STICK_L = BITL_REVERSE(HidNpadButton_StickL), ///< Left Stick button JOYCON_STICK_R = BITL_REVERSE(HidNpadButton_StickR), ///< Right Stick button - JOYCON_L = BITL_REVERSE(HidNpadButton_L), ///< L button - JOYCON_R = BITL_REVERSE(HidNpadButton_R), ///< R button - JOYCON_ZL = BITL_REVERSE(HidNpadButton_ZL), ///< ZL button - JOYCON_ZR = BITL_REVERSE(HidNpadButton_ZR), ///< ZR button + JOYCON_L = BITL_REVERSE(HidNpadButton_L), ///< L button + JOYCON_R = BITL_REVERSE(HidNpadButton_R), ///< R button + JOYCON_ZL = BITL_REVERSE(HidNpadButton_ZL), ///< ZL button + JOYCON_ZR = BITL_REVERSE(HidNpadButton_ZR), ///< ZR button JOYCON_PLUS = BITL_REVERSE(HidNpadButton_Plus), ///< Plus button From a7a94934da568a1ec4ed94a9b7edd9c5b4ccd1bc Mon Sep 17 00:00:00 2001 From: Totto16 Date: Mon, 15 Apr 2024 01:53:12 +0200 Subject: [PATCH 18/19] fix flatpak installer build --- com.github.mgerhold.OOPetris.yml | 2 +- meson.options | 4 +-- src/helper/graphic_utils.cpp | 2 +- src/meson.build | 5 ++++ tools/dependencies/meson.build | 47 +++++++++++++++++++++++++++++++- tools/install/meson.build | 7 ----- tools/options/meson.build | 1 + 7 files changed, 56 insertions(+), 12 deletions(-) diff --git a/com.github.mgerhold.OOPetris.yml b/com.github.mgerhold.OOPetris.yml index b2616c71..de6bad30 100644 --- a/com.github.mgerhold.OOPetris.yml +++ b/com.github.mgerhold.OOPetris.yml @@ -21,7 +21,7 @@ modules: config-opts: - -Dbuildtype=release - -Ddefault_library=shared - - -Dflatpak_build=true + - -Dbuild_installer=true - --libdir=lib - -Dtests=true builddir: true diff --git a/meson.options b/meson.options index df5baa71..b7888d6d 100644 --- a/meson.options +++ b/meson.options @@ -1,8 +1,8 @@ option( - 'flatpak_build', + 'build_installer', type: 'boolean', value: false, - description: 'enable flatpak build features', + description: 'build the installer, this is either a flatpak or windows exe installer or similar', ) option( diff --git a/src/helper/graphic_utils.cpp b/src/helper/graphic_utils.cpp index 4bf36507..311337e6 100644 --- a/src/helper/graphic_utils.cpp +++ b/src/helper/graphic_utils.cpp @@ -67,7 +67,7 @@ std::vector utils::supported_features() { if (!resource_path) { throw std::runtime_error{ "Failed in getting the Pref Path: " + std::string{ SDL_GetError() } }; } -// if you build in BUILD_INSTALLER mode, you have to assure that the data is there eg. music + fonts! +// if you build in BUILD_INSTALLER mode, you have to assure that the data is there e.g. music + fonts! #endif return std::filesystem::path{ std::string{ resource_path } } / "assets"; #else diff --git a/src/meson.build b/src/meson.build index d3e1b35b..b57a8dab 100644 --- a/src/meson.build +++ b/src/meson.build @@ -124,3 +124,8 @@ liboopetris_graphics_dep = declare_dependency( dependencies: graphics_lib.get('deps'), version: meson.project_version(), ) + +# setting this to strings, so += {...} gets detected as an error, if it is done after that +core_lib = 'undefined' +recordings_lib = 'undefined' +graphics_lib = 'undefined' diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build index d9b1cf08..f04f5fc3 100644 --- a/tools/dependencies/meson.build +++ b/tools/dependencies/meson.build @@ -262,7 +262,52 @@ utf8cpp_dep = dependency( ) core_lib += {'deps': [core_lib.get('deps'), utf8cpp_dep]} -is_flatpak_build = get_option('flatpak_build') + +build_installer = get_option('build_installer') + +is_flatpak_build = false + +# some sanity checks for the installer +if build_installer + if get_option('buildtype') != 'release' + error( + 'buildtype needs to be \'release\', when building the installer, but was: ' + + get_option('buildtype'), + ) + endif + + if host_machine.system() == 'linux' + if get_option('prefix') == '/app' + is_flatpak_build = true + else + error( + 'only support flatpak builds, when building the installer for linux', + ) + endif + elif host_machine.system() == 'windows' + error('windows installer is still WIP') + else + error( + 'unsuported system for building the installer: ' + host_machine.system(), + ) + + endif + +endif + + + +if is_flatpak_build + app_name = 'com.github.mgerhold.OOPetris' + core_lib += { + 'compile_args': [ + core_lib.get('compile_args'), + '-DFLATPAK_BUILD', + '-DBUILD_INSTALLER', + ], + } +endif + have_file_dialogs = false have_discord_sdk = false diff --git a/tools/install/meson.build b/tools/install/meson.build index 2fbedbd9..5c99cdd4 100644 --- a/tools/install/meson.build +++ b/tools/install/meson.build @@ -11,13 +11,6 @@ install_subdir( app_name = 'oopetris' if is_flatpak_build app_name = 'com.github.mgerhold.OOPetris' - core_lib += { - 'compile_args': [ - core_lib.get('compile_args'), - '-DFLATPAK_BUILD', - '-DBUILD_INSTALLER', - ], - } endif conf = configuration_data() diff --git a/tools/options/meson.build b/tools/options/meson.build index 09a67073..ded9695e 100644 --- a/tools/options/meson.build +++ b/tools/options/meson.build @@ -64,6 +64,7 @@ if ( get_option('buildtype') == 'debug' or get_option('buildtype') == 'debugoptimized' ) +#TODO: replace with ! NDEBUG in cpp files and remove this core_lib += { 'compile_args': [core_lib.get('compile_args'), '-DDEBUG_BUILD'], } From 3a4317810b97bce33b0b71b5531586f92054c3ea Mon Sep 17 00:00:00 2001 From: Totto16 Date: Mon, 15 Apr 2024 01:56:33 +0200 Subject: [PATCH 19/19] bump version --- meson.build | 2 +- platforms/android/app/build.gradle | 4 ++-- platforms/build-switch.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index b7546c6b..901ccdc2 100644 --- a/meson.build +++ b/meson.build @@ -11,7 +11,7 @@ project( 'b_ndebug': 'if-release', }, - version: '0.5.3', + version: '0.5.4', ) subdir('tools/options') diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle index be328c33..5beb50bf 100644 --- a/platforms/android/app/build.gradle +++ b/platforms/android/app/build.gradle @@ -69,8 +69,8 @@ android { } minSdkVersion 21 targetSdkVersion 34 - versionCode 4 - versionName "0.5.3" + versionCode 5 + versionName "0.5.4" } buildTypes { release { diff --git a/platforms/build-switch.sh b/platforms/build-switch.sh index 1d926c39..2a8ad8d6 100755 --- a/platforms/build-switch.sh +++ b/platforms/build-switch.sh @@ -101,7 +101,7 @@ libnx='$LIBNX' APP_NAME = 'oopetris' APP_AUTHOR = 'coder2k' -APP_VERSION = '0.5.3' +APP_VERSION = '0.5.4' USE_NACP = true