Skip to content

Commit 9e3d53c

Browse files
committed
- add support for 3ds
- refactor meson files into smaller parts, so that the main file isn't that big - refactor switch cross file
1 parent 15741d8 commit 9e3d53c

File tree

9 files changed

+1152
-632
lines changed

9 files changed

+1152
-632
lines changed

meson.build

Lines changed: 16 additions & 596 deletions
Large diffs are not rendered by default.

platforms/3ds/meson.build

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
2+
## get the options object and "unpack" it
3+
4+
_3ds_exe_name = _3ds_options[0]
5+
_3ds_src_files = _3ds_options[1]
6+
_3ds_deps = _3ds_options[2]
7+
8+
9+
# libraries
10+
11+
_3ds_dependencies = [
12+
'flac',
13+
'freetype2',
14+
'ogg',
15+
'ogg',
16+
'opus',
17+
'opusfile',
18+
'vorbisidec',
19+
'zlib',
20+
]
21+
22+
_3ds_dependencies_native = [
23+
'bz2',
24+
'ctru',
25+
'mad',
26+
'mikmod',
27+
'modplug',
28+
'png16',
29+
'SDL2main',
30+
]
31+
32+
33+
_3ds_library_dirs = meson.get_external_property('library_dirs', [''])
34+
if _3ds_library_dirs.length() == 0
35+
error('property \'library_dirs\' has to be set!')
36+
endif
37+
38+
foreach dep : _3ds_dependencies
39+
_3ds_deps += dependency(
40+
dep,
41+
required: true,
42+
allow_fallback: false,
43+
native: false,
44+
)
45+
endforeach
46+
47+
c = meson.get_compiler('c')
48+
foreach dep : _3ds_dependencies_native
49+
_3ds_deps += c.find_library(
50+
dep,
51+
required: true,
52+
dirs: _3ds_library_dirs,
53+
)
54+
endforeach
55+
56+
57+
## compilation
58+
59+
_3ds_elf_file = build_target(
60+
_3ds_exe_name + '.elf',
61+
_3ds_src_files,
62+
dependencies: _3ds_deps,
63+
override_options: {
64+
'warning_level': '3',
65+
'werror': true,
66+
},
67+
native: false,
68+
target_type: 'executable',
69+
)
70+
71+
use_smdh = ['true', 'True', '1', true].contains(
72+
meson.get_external_property('USE_SMDH', ''),
73+
)
74+
75+
76+
_3dsxtool = find_program('3dsxtool')
77+
78+
_3DSX_FLAGS = [_3dsxtool, _3ds_elf_file.full_path(), _3ds_exe_name + '.3dsx']
79+
_3DSX_DEPS = [_3ds_elf_file]
80+
SMDH_DEPS = _3DSX_DEPS
81+
82+
fs = import('fs')
83+
84+
if use_smdh
85+
86+
smdhtool = find_program('smdhtool')
87+
SMDH_FLAGS = [smdhtool, '--create']
88+
89+
APP_NAME = meson.get_external_property('APP_NAME', _3ds_exe_name)
90+
SMDH_FLAGS += APP_NAME
91+
92+
APP_DESC = meson.get_external_property('APP_DESC', '')
93+
if APP_DESC == ''
94+
error('If USE_SMDH is set, you have to provide an APP_DESC')
95+
endif
96+
SMDH_FLAGS += APP_DESC
97+
98+
99+
APP_AUTHOR = meson.get_external_property('APP_AUTHOR', '')
100+
if APP_AUTHOR == ''
101+
error('If USE_SMDH is set, you have to provide an APP_AUTHOR')
102+
endif
103+
SMDH_FLAGS += APP_AUTHOR
104+
105+
LIBCTRU = meson.get_external_property('libctru', '')
106+
if LIBCTRU == ''
107+
error('property \'libctru\' has to be set!')
108+
endif
109+
110+
_3ds_default_icon = LIBCTRU / 'default_icon.png'
111+
112+
APP_ICON = meson.get_external_property('APP_ICON', _3ds_default_icon)
113+
114+
if not fs.is_absolute(APP_ICON)
115+
APP_ICON = meson.project_source_root() / APP_ICON
116+
endif
117+
118+
119+
if not fs.exists(APP_ICON)
120+
error('APP_ICON should exist, but doesn\'t: \'' + APP_ICON + '\'')
121+
endif
122+
123+
SMDH_FLAGS += APP_ICON
124+
125+
126+
SMDH_FLAGS += (
127+
_3ds_exe_name + '.smdh' # outfile
128+
)
129+
130+
131+
132+
APP_SMALL_ICON = meson.get_external_property('APP_SMALL_ICON', '')
133+
134+
if APP_SMALL_ICON != ''
135+
if not fs.is_absolute(APP_SMALL_ICON)
136+
APP_SMALL_ICON = meson.project_source_root() / APP_SMALL_ICON
137+
endif
138+
139+
140+
if not fs.exists(APP_SMALL_ICON)
141+
error(
142+
'APP_SMALL_ICON should exist, but doesn\'t: \'' + APP_SMALL_ICON +
143+
'\'',
144+
)
145+
endif
146+
147+
SMDH_FLAGS += APP_SMALL_ICON
148+
endif
149+
150+
151+
152+
# smdhtool --create <name> <long description> <author> <icon.png> <_3ds_exe_name>.smdh [<smallicon.png>]
153+
smdh_file = custom_target(
154+
_3ds_exe_name + '.smdh',
155+
command: SMDH_FLAGS,
156+
output: [_3ds_exe_name + '.smdh'],
157+
depends: SMDH_DEPS,
158+
)
159+
_3DSX_FLAGS += '--smdh=' + _3ds_exe_name + '.smdh'
160+
_3DSX_DEPS += smdh_file
161+
162+
endif
163+
164+
165+
166+
APP_ROMFS = meson.get_external_property('APP_ROMFS', '')
167+
168+
if APP_ROMFS != ''
169+
170+
if not fs.is_absolute(APP_ROMFS)
171+
APP_ROMFS = meson.project_source_root() / APP_ROMFS
172+
endif
173+
174+
if not fs.exists(APP_ROMFS)
175+
error('APP_ROMFS should exist, but doesn\'t: \'' + APP_ROMFS + '\'')
176+
endif
177+
178+
_3DSX_FLAGS += '--romfs=' + APP_ROMFS
179+
180+
endif
181+
182+
# 3dsxtool <_3ds_exe_name>.elf <_3ds_exe_name>.3dsx <_3DSX_FLAGS>
183+
custom_target(
184+
_3ds_exe_name + '.3dsx',
185+
command: _3DSX_FLAGS,
186+
depends: _3DSX_DEPS,
187+
output: [_3ds_exe_name + '.3dsx'],
188+
build_by_default: true,
189+
)

0 commit comments

Comments
 (0)