Skip to content

Commit d6163a4

Browse files
authored
Merge pull request #220 from OpenBrickProtocolFoundation/add_meson_checks
Add meson format checks
2 parents 7045e48 + cdea6c4 commit d6163a4

File tree

32 files changed

+277
-324
lines changed

32 files changed

+277
-324
lines changed

.github/workflows/meson.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Meson Checks CI
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
workflow_dispatch:
8+
9+
jobs:
10+
meson_format:
11+
name: Run Meson Format Checks
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: '0'
17+
18+
- name: Check Files
19+
uses: Totto16/meson-format-action@1
20+
with:
21+
format-file: ./meson.format
22+
only-git-files: true
23+
24+
## TODO: use mesonlint from
25+
## https://github.com/JCWasmx86/mesonlsp
26+
## once it is maitained again
27+
# meson_lint:
28+
# name: Run Meson Lint Checks

meson.format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
max_line_length = 100
2+
end_of_line = 'lf'
3+
insert_final_newline = true
4+
sort_files = true
5+
kwargs_force_multiline = true
6+
no_single_comma_function = true

src/executables/game/meson.build

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
main_files += files(
2-
'application.cpp',
3-
'application.hpp',
4-
'main.cpp',
5-
'parser.cpp',
6-
'parser.hpp',
7-
)
1+
main_files += files('application.cpp', 'application.hpp', 'main.cpp', 'parser.cpp', 'parser.hpp')

src/executables/meson.build

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,20 @@ if build_application
4646
endif
4747

4848
if not fs.exists(APP_ROMFS)
49-
error(
50-
'APP_ROMFS should exist, but doesn\'t: \''
51-
+ APP_ROMFS
52-
+ '\'',
53-
)
49+
error('APP_ROMFS should exist, but doesn\'t: \''
50+
+ APP_ROMFS + '\'')
5451
endif
5552

5653
if not APP_ROMFS.endswith('/')
5754
APP_ROMFS = APP_ROMFS + '/'
5855
endif
5956

6057
emscripten_link_args += [
61-
'--preload-file', APP_ROMFS + '@/assets/',
58+
'--preload-file',
59+
APP_ROMFS + '@/assets/',
6260
# based on: https://github.com/emscripten-core/emscripten/blob/main/src/shell_minimal.html
63-
'--shell-file', meson.project_source_root() / 'platforms' / 'emscripten' / 'shell_file.html',
61+
'--shell-file',
62+
meson.project_source_root() / 'platforms' / 'emscripten' / 'shell_file.html',
6463
]
6564

6665
endif
@@ -85,7 +84,9 @@ if build_application
8584

8685
oopetris_html = executable(
8786
emscripten_name,
88-
objects: oopetris_js.extract_all_objects(recursive: true),
87+
objects: oopetris_js.extract_all_objects(
88+
recursive: true
89+
),
8990
dependencies: emscripten_deps,
9091
link_args: emscripten_link_args,
9192
override_options: emscripten_options,
@@ -94,12 +95,15 @@ if build_application
9495
link_depends: [oopetris_js],
9596
)
9697

97-
python3 = find_program('python3', required: false)
98+
python3 = find_program(
99+
'python3',
100+
required: false,
101+
)
98102

99103
if python3.found()
100104

101105
server_py = files(
102-
meson.project_source_root() / 'platforms' / 'emscripten' / 'server.py',
106+
meson.project_source_root() / 'platforms' / 'emscripten' / 'server.py'
103107
)
104108

105109
dest_path = meson.project_build_root() / 'src' / 'executables'
@@ -112,7 +116,10 @@ if build_application
112116

113117
endif
114118

115-
wasm_validate_exe = find_program('wasm-validate', required: false)
119+
wasm_validate_exe = find_program(
120+
'wasm-validate',
121+
required: false,
122+
)
116123

117124
if wasm_validate_exe.found()
118125

@@ -123,7 +130,6 @@ if build_application
123130
wasm_validate_exe,
124131
args: ['--enable-threads', wasm_file],
125132
depends: [oopetris_js, oopetris_html],
126-
127133
)
128134
endif
129135

@@ -170,7 +176,7 @@ if build_application
170176
makensis = find_program('makensis')
171177

172178
nsis_script = files(
173-
meson.project_source_root() / 'tools' / 'installer' / 'setup.nsi',
179+
meson.project_source_root() / 'tools' / 'installer' / 'setup.nsi'
174180
)
175181

176182
run_target(
@@ -184,9 +190,7 @@ if build_application
184190
+ meson.project_source_root(),
185191
'-DPROJECT_BUILD_DIR=' + meson.project_build_root(),
186192
'-DDYNAMIC_LIBRARIES_DIR='
187-
+ (
188-
meson.project_build_root() / 'dynamic_libraries' / get_option('bindir')
189-
),
193+
+ (meson.project_build_root() / 'dynamic_libraries' / get_option('bindir')),
190194
nsis_script,
191195
],
192196
depends: [oopetris_exe, oopetris_recordings_utility_exe],

src/executables/platforms/3ds/meson.build

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,9 @@ _3ds_deps = _3ds_options[2]
66

77
# libraries
88

9-
_3ds_dependencies = [
10-
'flac',
11-
'freetype2',
12-
'ogg',
13-
'ogg',
14-
'opus',
15-
'opusfile',
16-
'vorbisidec',
17-
'zlib',
18-
]
19-
20-
_3ds_dependencies_native = [
21-
'bz2',
22-
'ctru',
23-
'mad',
24-
'mikmod',
25-
'modplug',
26-
'png16',
27-
'SDL2main',
28-
]
9+
_3ds_dependencies = ['flac', 'freetype2', 'ogg', 'ogg', 'opus', 'opusfile', 'vorbisidec', 'zlib']
10+
11+
_3ds_dependencies_native = ['bz2', 'ctru', 'mad', 'mikmod', 'modplug', 'png16', 'SDL2main']
2912

3013
_3ds_library_dirs = meson.get_external_property('library_dirs', [''])
3114
if _3ds_library_dirs.length() == 0
@@ -64,9 +47,7 @@ _3ds_elf_file = build_target(
6447
target_type: 'executable',
6548
)
6649

67-
use_smdh = ['true', 'True', '1', true].contains(
68-
meson.get_external_property('USE_SMDH', ''),
69-
)
50+
use_smdh = ['true', 'True', '1', true].contains(meson.get_external_property('USE_SMDH', ''))
7051

7152
_3dsxtool = find_program('3dsxtool')
7253

@@ -125,11 +106,8 @@ if use_smdh
125106
endif
126107

127108
if not fs.exists(APP_SMALL_ICON)
128-
error(
129-
'APP_SMALL_ICON should exist, but doesn\'t: \''
130-
+ APP_SMALL_ICON
131-
+ '\'',
132-
)
109+
error('APP_SMALL_ICON should exist, but doesn\'t: \''
110+
+ APP_SMALL_ICON + '\'')
133111
endif
134112

135113
SMDH_FLAGS += APP_SMALL_ICON

src/executables/platforms/switch/meson.build

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,7 @@ switch_dependencies = [
2121
'zlib',
2222
]
2323

24-
switch_dependencies_native = [
25-
'bz2',
26-
'drm_nouveau',
27-
'modplug',
28-
'nx',
29-
'png16',
30-
'SDL2main',
31-
]
24+
switch_dependencies_native = ['bz2', 'drm_nouveau', 'modplug', 'nx', 'png16', 'SDL2main']
3225

3326
foreach dep : switch_dependencies
3427
switch_deps += dependency(
@@ -67,9 +60,7 @@ switch_elf_file = build_target(
6760
target_type: 'executable',
6861
)
6962

70-
use_nacp = ['true', 'True', '1', true].contains(
71-
meson.get_external_property('USE_NACP', ''),
72-
)
63+
use_nacp = ['true', 'True', '1', true].contains(meson.get_external_property('USE_NACP', ''))
7364

7465
elf2nro = find_program('elf2nro')
7566
# executable input elf file, output nro file

src/executables/platforms/windows/meson.build

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ minor_version = version_arr[1].to_int()
66
patch_version = version_arr[2].to_int()
77

88
rc_conf = configuration_data(
9-
{
10-
'OOPETRIS_VERSION': meson.project_version(),
11-
'OOPETRIS_NAME': oopetris_name,
12-
'OOPETRIS_AUTHOR': oopetris_author,
13-
'OOPETRIS_MAJOR_VERSION': major_version,
14-
'OOPETRIS_MINOR_VERSION': minor_version,
15-
'OOPETRIS_PATCH_VERSION': patch_version,
16-
'PROJECT_SOURCE_DIR': meson.project_source_root().replace('\\', '/'),
17-
},
9+
{
10+
'OOPETRIS_VERSION': meson.project_version(),
11+
'OOPETRIS_NAME': oopetris_name,
12+
'OOPETRIS_AUTHOR': oopetris_author,
13+
'OOPETRIS_MAJOR_VERSION': major_version,
14+
'OOPETRIS_MINOR_VERSION': minor_version,
15+
'OOPETRIS_PATCH_VERSION': patch_version,
16+
'PROJECT_SOURCE_DIR': meson.project_source_root().replace('\\', '/'),
17+
}
1818
)
1919

2020
oopetris_win_rc = configure_file(
21-
input: 'oopetris.rc.in',
22-
output: 'oopetris.rc',
23-
configuration: rc_conf,
21+
input: 'oopetris.rc.in',
22+
output: 'oopetris.rc',
23+
configuration: rc_conf,
2424
)
2525

2626
oopetris_resource_windows = windows.compile_resources(oopetris_win_rc)
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
recordings_main_files += files(
2-
'command_line_arguments.hpp',
3-
'main.cpp',
4-
)
1+
recordings_main_files += files('command_line_arguments.hpp', 'main.cpp')

src/libs/core/game/meson.build

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
core_src_files += files(
2-
'mino.cpp',
3-
'mino_stack.cpp',
4-
'tetromino_type.cpp',
5-
)
1+
core_src_files += files('mino.cpp', 'mino_stack.cpp', 'tetromino_type.cpp')
62

7-
_header_files = files(
8-
'grid_properties.hpp',
9-
'mino.hpp',
10-
'mino_stack.hpp',
11-
'tetromino_type.hpp',
12-
)
3+
_header_files = files('grid_properties.hpp', 'mino.hpp', 'mino_stack.hpp', 'tetromino_type.hpp')
134

145
core_header_files += _header_files
156

src/libs/core/hash-library/meson.build

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
core_src_files += files(
2-
'sha256.cpp',
3-
)
1+
core_src_files += files('sha256.cpp')
42

5-
_header_files = files(
6-
'sha256.h',
7-
)
3+
_header_files = files('sha256.h')
84

95
core_header_files += _header_files
106

0 commit comments

Comments
 (0)