Skip to content

Add meson checks #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Meson Checks CI

on:
push:
branches: ['main']
pull_request:
workflow_dispatch:

jobs:
meson_format:
name: Run Meson Format Checks
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '0'

- name: Check Files
uses: Totto16/meson-format-action@1
with:
format-file: ./meson.format
only-git-files: true

## TODO: use mesonlint from
## https://github.com/JCWasmx86/mesonlsp
## once it is maitained again
# meson_lint:
# name: Run Meson Lint Checks
6 changes: 6 additions & 0 deletions meson.format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
max_line_length = 100
end_of_line = 'lf'
insert_final_newline = true
sort_files = true
kwargs_force_multiline = true
no_single_comma_function = true
8 changes: 1 addition & 7 deletions src/executables/game/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
main_files += files(
'application.cpp',
'application.hpp',
'main.cpp',
'parser.cpp',
'parser.hpp',
)
main_files += files('application.cpp', 'application.hpp', 'main.cpp', 'parser.cpp', 'parser.hpp')
36 changes: 20 additions & 16 deletions src/executables/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,20 @@ if build_application
endif

if not fs.exists(APP_ROMFS)
error(
'APP_ROMFS should exist, but doesn\'t: \''
+ APP_ROMFS
+ '\'',
)
error('APP_ROMFS should exist, but doesn\'t: \''
+ APP_ROMFS + '\'')
endif

if not APP_ROMFS.endswith('/')
APP_ROMFS = APP_ROMFS + '/'
endif

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

endif
Expand All @@ -85,7 +84,9 @@ if build_application

oopetris_html = executable(
emscripten_name,
objects: oopetris_js.extract_all_objects(recursive: true),
objects: oopetris_js.extract_all_objects(
recursive: true
),
dependencies: emscripten_deps,
link_args: emscripten_link_args,
override_options: emscripten_options,
Expand All @@ -94,12 +95,15 @@ if build_application
link_depends: [oopetris_js],
)

python3 = find_program('python3', required: false)
python3 = find_program(
'python3',
required: false,
)

if python3.found()

server_py = files(
meson.project_source_root() / 'platforms' / 'emscripten' / 'server.py',
meson.project_source_root() / 'platforms' / 'emscripten' / 'server.py'
)

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

endif

wasm_validate_exe = find_program('wasm-validate', required: false)
wasm_validate_exe = find_program(
'wasm-validate',
required: false,
)

if wasm_validate_exe.found()

Expand All @@ -123,7 +130,6 @@ if build_application
wasm_validate_exe,
args: ['--enable-threads', wasm_file],
depends: [oopetris_js, oopetris_html],

)
endif

Expand Down Expand Up @@ -170,7 +176,7 @@ if build_application
makensis = find_program('makensis')

nsis_script = files(
meson.project_source_root() / 'tools' / 'installer' / 'setup.nsi',
meson.project_source_root() / 'tools' / 'installer' / 'setup.nsi'
)

run_target(
Expand All @@ -184,9 +190,7 @@ if build_application
+ meson.project_source_root(),
'-DPROJECT_BUILD_DIR=' + meson.project_build_root(),
'-DDYNAMIC_LIBRARIES_DIR='
+ (
meson.project_build_root() / 'dynamic_libraries' / get_option('bindir')
),
+ (meson.project_build_root() / 'dynamic_libraries' / get_option('bindir')),
nsis_script,
],
depends: [oopetris_exe, oopetris_recordings_utility_exe],
Expand Down
34 changes: 6 additions & 28 deletions src/executables/platforms/3ds/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,9 @@ _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_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
Expand Down Expand Up @@ -64,9 +47,7 @@ _3ds_elf_file = build_target(
target_type: 'executable',
)

use_smdh = ['true', 'True', '1', true].contains(
meson.get_external_property('USE_SMDH', ''),
)
use_smdh = ['true', 'True', '1', true].contains(meson.get_external_property('USE_SMDH', ''))

_3dsxtool = find_program('3dsxtool')

Expand Down Expand Up @@ -125,11 +106,8 @@ if use_smdh
endif

if not fs.exists(APP_SMALL_ICON)
error(
'APP_SMALL_ICON should exist, but doesn\'t: \''
+ APP_SMALL_ICON
+ '\'',
)
error('APP_SMALL_ICON should exist, but doesn\'t: \''
+ APP_SMALL_ICON + '\'')
endif

SMDH_FLAGS += APP_SMALL_ICON
Expand Down
13 changes: 2 additions & 11 deletions src/executables/platforms/switch/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ switch_dependencies = [
'zlib',
]

switch_dependencies_native = [
'bz2',
'drm_nouveau',
'modplug',
'nx',
'png16',
'SDL2main',
]
switch_dependencies_native = ['bz2', 'drm_nouveau', 'modplug', 'nx', 'png16', 'SDL2main']

foreach dep : switch_dependencies
switch_deps += dependency(
Expand Down Expand Up @@ -67,9 +60,7 @@ switch_elf_file = build_target(
target_type: 'executable',
)

use_nacp = ['true', 'True', '1', true].contains(
meson.get_external_property('USE_NACP', ''),
)
use_nacp = ['true', 'True', '1', true].contains(meson.get_external_property('USE_NACP', ''))

elf2nro = find_program('elf2nro')
# executable input elf file, output nro file
Expand Down
24 changes: 12 additions & 12 deletions src/executables/platforms/windows/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ minor_version = version_arr[1].to_int()
patch_version = version_arr[2].to_int()

rc_conf = configuration_data(
{
'OOPETRIS_VERSION': meson.project_version(),
'OOPETRIS_NAME': oopetris_name,
'OOPETRIS_AUTHOR': oopetris_author,
'OOPETRIS_MAJOR_VERSION': major_version,
'OOPETRIS_MINOR_VERSION': minor_version,
'OOPETRIS_PATCH_VERSION': patch_version,
'PROJECT_SOURCE_DIR': meson.project_source_root().replace('\\', '/'),
},
{
'OOPETRIS_VERSION': meson.project_version(),
'OOPETRIS_NAME': oopetris_name,
'OOPETRIS_AUTHOR': oopetris_author,
'OOPETRIS_MAJOR_VERSION': major_version,
'OOPETRIS_MINOR_VERSION': minor_version,
'OOPETRIS_PATCH_VERSION': patch_version,
'PROJECT_SOURCE_DIR': meson.project_source_root().replace('\\', '/'),
}
)

oopetris_win_rc = configure_file(
input: 'oopetris.rc.in',
output: 'oopetris.rc',
configuration: rc_conf,
input: 'oopetris.rc.in',
output: 'oopetris.rc',
configuration: rc_conf,
)

oopetris_resource_windows = windows.compile_resources(oopetris_win_rc)
Expand Down
5 changes: 1 addition & 4 deletions src/executables/utility/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
recordings_main_files += files(
'command_line_arguments.hpp',
'main.cpp',
)
recordings_main_files += files('command_line_arguments.hpp', 'main.cpp')
13 changes: 2 additions & 11 deletions src/libs/core/game/meson.build
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
core_src_files += files(
'mino.cpp',
'mino_stack.cpp',
'tetromino_type.cpp',
)
core_src_files += files('mino.cpp', 'mino_stack.cpp', 'tetromino_type.cpp')

_header_files = files(
'grid_properties.hpp',
'mino.hpp',
'mino_stack.hpp',
'tetromino_type.hpp',
)
_header_files = files('grid_properties.hpp', 'mino.hpp', 'mino_stack.hpp', 'tetromino_type.hpp')

core_header_files += _header_files

Expand Down
8 changes: 2 additions & 6 deletions src/libs/core/hash-library/meson.build
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
core_src_files += files(
'sha256.cpp',
)
core_src_files += files('sha256.cpp')

_header_files = files(
'sha256.h',
)
_header_files = files('sha256.h')

core_header_files += _header_files

Expand Down
4 changes: 3 additions & 1 deletion src/libs/core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ subdir('helper')

temp = core_lib.get('compile_args')
temp += '-DOOPETRIS_LIBRARY_CORE_TYPE=' + (get_option('default_library') == 'static' ? '1' : '0')
core_lib += {'compile_args': temp}
core_lib += {
'compile_args': temp,
}
temp = 0

liboopetris_core = library(
Expand Down
4 changes: 3 additions & 1 deletion src/libs/recordings/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ subdir('utility')

temp = recordings_lib.get('compile_args')
temp += '-DOOPETRIS_LIBRARY_RECORDINGS_TYPE=' + (get_option('default_library') == 'static' ? '1' : '0')
recordings_lib += {'compile_args': temp}
recordings_lib += {
'compile_args': temp,
}
temp = 0

recordings_lib += {
Expand Down
7 changes: 1 addition & 6 deletions src/lobby/credentials/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
graphics_src_files += files(
'buffer.cpp',
'buffer.hpp',
'secret.cpp',
'secret.hpp',
)
graphics_src_files += files('buffer.cpp', 'buffer.hpp', 'secret.cpp', 'secret.hpp')
22 changes: 5 additions & 17 deletions src/lobby/meson.build
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
if online_multiplayer_system == 'curl'
graphics_src_files += files(
'curl_client.cpp',
'curl_client.hpp',
)
graphics_src_files += files('curl_client.cpp', 'curl_client.hpp')
elif online_multiplayer_system == 'httplib'
graphics_src_files += files(
'httplib_client.cpp',
'httplib_client.hpp',
)
graphics_src_files += files('httplib_client.cpp', 'httplib_client.hpp')
elif online_multiplayer_system == 'web'
graphics_src_files += files(
'web_client.cpp',
'web_client.hpp',
)
graphics_src_files += files('web_client.cpp', 'web_client.hpp')
else
error(
'Unhandled online_multiplayer_system: \''
+ online_multiplayer_system
+ '\'',
)
error('Unhandled online_multiplayer_system: \''
+ online_multiplayer_system + '\'')
endif

graphics_src_files += files(
Expand Down
7 changes: 2 additions & 5 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ if build_application
graphics_lib += {
'deps': [graphics_lib.get('deps'), liboopetris_recordings_dep],
'inc_dirs': [graphics_lib.get('inc_dirs'), include_directories('.')],
'compile_args': [
graphics_lib.get('compile_args'),
'-DOOPETRIS_LIBRARY_GRAPHICS_TYPE='
+ (get_option('default_library') == 'static' ? '1' : '0'),
],
'compile_args': [graphics_lib.get('compile_args'), '-DOOPETRIS_LIBRARY_GRAPHICS_TYPE='
+ (get_option('default_library') == 'static' ? '1' : '0')],
}

liboopetris_graphics = library(
Expand Down
5 changes: 1 addition & 4 deletions src/scenes/about_page/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
graphics_src_files += files(
'about_page.cpp',
'about_page.hpp',
)
graphics_src_files += files('about_page.cpp', 'about_page.hpp')
5 changes: 1 addition & 4 deletions src/scenes/loading_screen/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
graphics_src_files += files(
'loading_screen.cpp',
'loading_screen.hpp',
)
graphics_src_files += files('loading_screen.cpp', 'loading_screen.hpp')
5 changes: 1 addition & 4 deletions src/scenes/logo/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
graphics_src_files += files(
'logo.cpp',
'logo.hpp',
)
graphics_src_files += files('logo.cpp', 'logo.hpp')
5 changes: 1 addition & 4 deletions src/scenes/main_menu/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
graphics_src_files += files(
'main_menu.cpp',
'main_menu.hpp',
)
graphics_src_files += files('main_menu.cpp', 'main_menu.hpp')
5 changes: 1 addition & 4 deletions src/scenes/multiplayer_menu/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
graphics_src_files += files(
'multiplayer_menu.cpp',
'multiplayer_menu.hpp',
)
graphics_src_files += files('multiplayer_menu.cpp', 'multiplayer_menu.hpp')
Loading
Loading