Skip to content

Commit 1112168

Browse files
committed
fix 3ds and switch build options in the build configuration
1 parent 9e3d53c commit 1112168

File tree

6 files changed

+59
-63
lines changed

6 files changed

+59
-63
lines changed

assets/oopetris.desktop.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Version=1.0
33
Type=Application
44
Name=OOPetris
5-
Comment=A tetris clone in OOP
5+
Comment=A Tetris clone in OOP
66
Exec=oopetris
77
Icon=@APP_NAME@
88
Terminal=false

meson.build

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ project(
1414
version: '0.5.3',
1515
)
1616

17-
1817
subdir('tools/options')
1918

2019
subdir('tools/dependencies')
@@ -75,7 +74,6 @@ else
7574

7675
endif
7776

78-
7977
if get_option('tests')
8078
subdir('tests')
8179
endif

platforms/build-3ds.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export ENDIANESS="little"
4545

4646
export COMMON_FLAGS="'-march=armv6k','-mtune=mpcore','-mfloat-abi=hard', '-mtp=soft','-mword-relocations', '-ffunction-sections', '-fdata-sections'"
4747

48+
# compat flags for some POSIX functions
49+
export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'"
50+
4851
export COMPILE_FLAGS="'-D_3DS','-D__3DS__', '-isystem', '$LIBCTRU/include', '-I$PORTLIBS_PATH_3DS/include'"
4952

5053
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'
8588
8689
[built-in options]
8790
c_std = 'c11'
88-
cpp_std = 'c++20'
89-
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
90-
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
91+
cpp_std = 'c++23'
92+
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
93+
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
9194
c_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9295
cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9396
@@ -98,9 +101,9 @@ needs_exe_wrapper = true
98101
library_dirs= ['$LIBCTRU_LIB', '$PORTLIBS_LIB']
99102
libctru='$LIBCTRU'
100103
101-
APP_NAME = 'sdl_example'
102-
APP_AUTHOR = 'Totto16'
103-
APP_DESC = 'SDL Example'
104+
APP_NAME = 'oopetris'
105+
APP_AUTHOR = 'coder2k'
106+
APP_DESC = 'A Tetris clone in OOP'
104107
105108
USE_SMDH = true
106109

platforms/build-switch.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export ENDIANESS="little"
4343

4444
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'"
4545

46+
# compat flags for some POSIX functions
47+
export EXTRA_COMPILE_FLAGS="'-DNOSTYLUS','-D_XOPEN_SOURCE'"
48+
4649
export COMPILE_FLAGS="'-D__SWITCH__','-isystem','$LIBNX/include','-I$PORTLIBS_PATH_SWITCH/include'"
4750

4851
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'
8386
8487
[built-in options]
8588
c_std = 'c11'
86-
cpp_std = 'c++20'
87-
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
88-
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
89+
cpp_std = 'c++23'
90+
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
91+
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS, $EXTRA_COMPILE_FLAGS]
8992
c_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9093
cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
9194
@@ -96,9 +99,9 @@ needs_exe_wrapper = true
9699
library_dirs= ['$LIBNX_LIB', '$PORTLIBS_LIB']
97100
libnx='$LIBNX'
98101
99-
APP_NAME = 'sdl_example'
100-
APP_AUTHOR = 'Totto16'
101-
APP_VERSION = '1.0'
102+
APP_NAME = 'oopetris'
103+
APP_AUTHOR = 'coder2k'
104+
APP_VERSION = '0.5.3'
102105
103106
USE_NACP = true
104107

tools/dependencies/meson.build

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
only_allow_native_libs = false
44
if meson.is_cross_build()
5-
if host_machine.system() == 'switch'
6-
# 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
5+
if host_machine.system() == 'switch' or host_machine.system() == '3ds'
6+
# 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
77
core_lib += {
88
'compile_args': [core_lib.get('compile_args'), '-Wno-psabi'],
99
}
@@ -14,7 +14,6 @@ endif
1414

1515

1616

17-
1817
sdl2_dep = dependency(
1918
'sdl2',
2019
'SDL2',
@@ -77,7 +76,7 @@ if mpg123_dep.found()
7776
sdl2_mixer_flags += {'mpg123': 'enabled'}
7877
sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT'
7978
else
80-
mpg123_dep = cpp.find_library('mpg123', required: only_allow_native_libs)
79+
mpg123_dep = cpp.find_library('mpg123', required: false)
8180
if mpg123_dep.found()
8281
sdl2_mixer_flags += {'mpg123': 'enabled'}
8382
sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT'
@@ -87,7 +86,6 @@ else
8786
endif
8887

8988

90-
9189
sdl2_mixer_dep = dependency(
9290
'sdl2_mixer',
9391
'SDL2_mixer',
@@ -100,58 +98,49 @@ graphics_lib += {
10098
'compile_args': [graphics_lib.get('compile_args'), sdl2_mixer_defines],
10199
}
102100

103-
if (meson.is_cross_build() and host_machine.system() == 'switch')
104-
105-
fmt_lib = dependency(
106-
'fmt',
107-
required: false,
108-
allow_fallback: false,
109-
)
110-
111-
if fmt_lib.found()
112-
core_lib += {'deps': [core_lib.get('deps'), fmt_lib]}
113-
else
114-
115-
fmt_header_only_dep = dependency(
116-
'fmt_header_only',
117-
required: true,
118-
allow_fallback: true,
119-
default_options: {'default_library': 'static'},
120-
)
101+
fmt_use_header_only = false
121102

122-
meson.override_dependency('fmt', fmt_header_only_dep)
103+
if (
104+
meson.is_cross_build()
105+
and (host_machine.system() == 'switch'
106+
or host_machine.system() == '3ds')
107+
)
108+
fmt_use_header_only = true
109+
# clang with libc++ creates some really long and confusing linker errors, so just use the header only library
110+
elif cpp.get_id() == 'clang' and build_with_libcpp
111+
fmt_use_header_only = true
112+
endif
123113

124-
core_lib += {'deps': [core_lib.get('deps'), fmt_header_only_dep]}
125-
endif
126114

115+
if fmt_use_header_only
116+
fmt_header_only_dep = dependency(
117+
'fmt_header_only',
118+
required: true,
119+
allow_fallback: true,
120+
)
121+
meson.override_dependency('fmt', fmt_header_only_dep)
122+
fmt_dep = fmt_header_only_dep
127123
else
124+
fmt_dep = dependency('fmt', required: true, allow_fallback: true)
125+
endif
128126

129-
# clang with libc++ creates some really long and confusing linker errors, so just use the header only library
130-
if cpp.get_id() == 'clang' and build_with_libcpp
131-
fmt_dep = dependency(
132-
'fmt_header_only',
133-
required: true,
134-
allow_fallback: true,
135-
default_options: {'default_library': 'static'},
136-
)
137-
meson.override_dependency('fmt', fmt_dep)
138-
else
139-
fmt_dep = dependency(
140-
'fmt',
141-
required: true,
142-
)
143-
endif
144-
127+
core_lib += {'deps': [core_lib.get('deps'), fmt_dep]}
145128

146-
core_lib += {'deps': [core_lib.get('deps'), fmt_dep]}
147-
endif
148129

149130
spdlog_dep = dependency(
150131
'spdlog',
151132
required: true,
152133
default_options: {'tests': 'disabled'},
153134
)
154-
graphics_lib += {'deps': [graphics_lib.get('deps'), spdlog_dep]}
135+
graphics_lib += {
136+
'deps': [graphics_lib.get('deps'), spdlog_dep],
137+
}
138+
139+
if (meson.is_cross_build() and host_machine.system() == '3ds')
140+
graphics_lib += {
141+
'compile_args': [graphics_lib.get('compile_args'), '-DSPDLOG_NO_TLS'],
142+
}
143+
endif
155144

156145
nlohmann_json_dep = dependency(
157146
'nlohmann_json',
@@ -221,7 +210,11 @@ core_lib += {'deps': [core_lib.get('deps'), argparse_dep]}
221210
online_multiplayer_supported = true
222211

223212

224-
if meson.is_cross_build() and host_machine.system() == 'switch'
213+
if (
214+
meson.is_cross_build()
215+
and (host_machine.system() == 'switch'
216+
or host_machine.system() == '3ds')
217+
)
225218
online_multiplayer_supported = false
226219
core_lib += {
227220
'compile_args': [
@@ -275,7 +268,6 @@ endif
275268
discord_sdk_dep = dependency(
276269
'discord-game-sdk',
277270
required: not meson.is_cross_build(),
278-
default_options: {'clang_libcpp': 'disabled'},
279271
)
280272
if discord_sdk_dep.found()
281273
have_discord_sdk = true

tools/install/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
## TODO: only install needed ones, since sometimes we only need e.g. flacs or mp3 and no icons etc.
33
## install assets
44
install_subdir(
5-
'assets',
5+
meson.project_source_root() / 'assets',
66
install_dir: 'share/oopetris',
77
exclude_files: ['oopetris.desktop.in', 'OOPetris.svg', 'recordings.magic'],
88
exclude_directories: ['icon'],

0 commit comments

Comments
 (0)