diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml new file mode 100644 index 000000000..6c024402a --- /dev/null +++ b/.github/workflows/meson.yml @@ -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 diff --git a/meson.format b/meson.format new file mode 100644 index 000000000..33b509631 --- /dev/null +++ b/meson.format @@ -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 diff --git a/src/executables/game/meson.build b/src/executables/game/meson.build index 90b4c0b25..ec78e3cda 100644 --- a/src/executables/game/meson.build +++ b/src/executables/game/meson.build @@ -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') diff --git a/src/executables/meson.build b/src/executables/meson.build index bda24c0d1..7ef21e1f7 100644 --- a/src/executables/meson.build +++ b/src/executables/meson.build @@ -46,11 +46,8 @@ 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('/') @@ -58,9 +55,11 @@ if build_application 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 @@ -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, @@ -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' @@ -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() @@ -123,7 +130,6 @@ if build_application wasm_validate_exe, args: ['--enable-threads', wasm_file], depends: [oopetris_js, oopetris_html], - ) endif @@ -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( @@ -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], diff --git a/src/executables/platforms/3ds/meson.build b/src/executables/platforms/3ds/meson.build index f8524f364..fac723630 100644 --- a/src/executables/platforms/3ds/meson.build +++ b/src/executables/platforms/3ds/meson.build @@ -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 @@ -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') @@ -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 diff --git a/src/executables/platforms/switch/meson.build b/src/executables/platforms/switch/meson.build index 7017f9fe6..26005afe0 100644 --- a/src/executables/platforms/switch/meson.build +++ b/src/executables/platforms/switch/meson.build @@ -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( @@ -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 diff --git a/src/executables/platforms/windows/meson.build b/src/executables/platforms/windows/meson.build index 5a684a93a..80c876016 100644 --- a/src/executables/platforms/windows/meson.build +++ b/src/executables/platforms/windows/meson.build @@ -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) diff --git a/src/executables/utility/meson.build b/src/executables/utility/meson.build index 997e89238..4730e7996 100644 --- a/src/executables/utility/meson.build +++ b/src/executables/utility/meson.build @@ -1,4 +1 @@ -recordings_main_files += files( - 'command_line_arguments.hpp', - 'main.cpp', -) +recordings_main_files += files('command_line_arguments.hpp', 'main.cpp') diff --git a/src/libs/core/game/meson.build b/src/libs/core/game/meson.build index c5f6f48c2..5a5dc0dcc 100644 --- a/src/libs/core/game/meson.build +++ b/src/libs/core/game/meson.build @@ -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 diff --git a/src/libs/core/hash-library/meson.build b/src/libs/core/hash-library/meson.build index df1ddcc6c..5ecf36457 100644 --- a/src/libs/core/hash-library/meson.build +++ b/src/libs/core/hash-library/meson.build @@ -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 diff --git a/src/libs/core/meson.build b/src/libs/core/meson.build index 734784155..c4a4301ff 100644 --- a/src/libs/core/meson.build +++ b/src/libs/core/meson.build @@ -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( diff --git a/src/libs/recordings/meson.build b/src/libs/recordings/meson.build index 68a6444d4..c5bb713e4 100644 --- a/src/libs/recordings/meson.build +++ b/src/libs/recordings/meson.build @@ -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 += { diff --git a/src/lobby/credentials/meson.build b/src/lobby/credentials/meson.build index 614c441b9..dfa6da826 100644 --- a/src/lobby/credentials/meson.build +++ b/src/lobby/credentials/meson.build @@ -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') diff --git a/src/lobby/meson.build b/src/lobby/meson.build index 057eca851..6e26e1ccc 100644 --- a/src/lobby/meson.build +++ b/src/lobby/meson.build @@ -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( diff --git a/src/meson.build b/src/meson.build index c06d91f6c..47b2ed75e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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( diff --git a/src/scenes/about_page/meson.build b/src/scenes/about_page/meson.build index 08a18fe8f..810e7ec10 100644 --- a/src/scenes/about_page/meson.build +++ b/src/scenes/about_page/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'about_page.cpp', - 'about_page.hpp', -) +graphics_src_files += files('about_page.cpp', 'about_page.hpp') diff --git a/src/scenes/loading_screen/meson.build b/src/scenes/loading_screen/meson.build index f21ea09a8..9a0039ed9 100644 --- a/src/scenes/loading_screen/meson.build +++ b/src/scenes/loading_screen/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'loading_screen.cpp', - 'loading_screen.hpp', -) +graphics_src_files += files('loading_screen.cpp', 'loading_screen.hpp') diff --git a/src/scenes/logo/meson.build b/src/scenes/logo/meson.build index 653584280..c9fe662a0 100644 --- a/src/scenes/logo/meson.build +++ b/src/scenes/logo/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'logo.cpp', - 'logo.hpp', -) +graphics_src_files += files('logo.cpp', 'logo.hpp') diff --git a/src/scenes/main_menu/meson.build b/src/scenes/main_menu/meson.build index 08b3c7345..430c21185 100644 --- a/src/scenes/main_menu/meson.build +++ b/src/scenes/main_menu/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'main_menu.cpp', - 'main_menu.hpp', -) +graphics_src_files += files('main_menu.cpp', 'main_menu.hpp') diff --git a/src/scenes/multiplayer_menu/meson.build b/src/scenes/multiplayer_menu/meson.build index 289b8c47e..8fe549bd2 100644 --- a/src/scenes/multiplayer_menu/meson.build +++ b/src/scenes/multiplayer_menu/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'multiplayer_menu.cpp', - 'multiplayer_menu.hpp', -) +graphics_src_files += files('multiplayer_menu.cpp', 'multiplayer_menu.hpp') diff --git a/src/scenes/online_lobby/meson.build b/src/scenes/online_lobby/meson.build index 844943186..32d2fb19d 100644 --- a/src/scenes/online_lobby/meson.build +++ b/src/scenes/online_lobby/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'online_lobby.cpp', - 'online_lobby.hpp', -) +graphics_src_files += files('online_lobby.cpp', 'online_lobby.hpp') diff --git a/src/scenes/play_select_menu/meson.build b/src/scenes/play_select_menu/meson.build index cbb80ac6d..3e5ce14ad 100644 --- a/src/scenes/play_select_menu/meson.build +++ b/src/scenes/play_select_menu/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'play_select_menu.cpp', - 'play_select_menu.hpp', -) +graphics_src_files += files('play_select_menu.cpp', 'play_select_menu.hpp') diff --git a/src/scenes/recording_selector/meson.build b/src/scenes/recording_selector/meson.build index 8678059aa..82e82662e 100644 --- a/src/scenes/recording_selector/meson.build +++ b/src/scenes/recording_selector/meson.build @@ -6,8 +6,5 @@ graphics_src_files += files( ) if have_file_dialogs - graphics_src_files += files( - 'recording_chooser.cpp', - 'recording_chooser.hpp', - ) + graphics_src_files += files('recording_chooser.cpp', 'recording_chooser.hpp') endif diff --git a/src/scenes/replay_game/meson.build b/src/scenes/replay_game/meson.build index 1a336abc0..7cfa633d6 100644 --- a/src/scenes/replay_game/meson.build +++ b/src/scenes/replay_game/meson.build @@ -1,4 +1 @@ -graphics_src_files += files( - 'replay_game.cpp', - 'replay_game.hpp', -) +graphics_src_files += files('replay_game.cpp', 'replay_game.hpp') diff --git a/src/ui/meson.build b/src/ui/meson.build index 3c896191c..f05dc3283 100644 --- a/src/ui/meson.build +++ b/src/ui/meson.build @@ -1,10 +1,4 @@ -graphics_src_files += files( - 'focusable.hpp', - 'layout.cpp', - 'layout.hpp', - 'widget.cpp', - 'widget.hpp', -) +graphics_src_files += files('focusable.hpp', 'layout.cpp', 'layout.hpp', 'widget.cpp', 'widget.hpp') subdir('components') subdir('layouts') diff --git a/subprojects/packagefiles/discord_social_sdk/meson.build b/subprojects/packagefiles/discord_social_sdk/meson.build index 4ac396c9e..5e31cf773 100644 --- a/subprojects/packagefiles/discord_social_sdk/meson.build +++ b/subprojects/packagefiles/discord_social_sdk/meson.build @@ -13,7 +13,10 @@ inc_dirs = include_directories('include') header_files = files('include' / 'cdiscord.h', 'include' / 'discordpp.h') -install_headers(header_files, subdir: 'discord') +install_headers( + header_files, + subdir: 'discord', +) lib_base_dir = '' @@ -21,9 +24,7 @@ if host_machine.system() == 'darwin' if host_machine.cpu_family() in ['aarch64', 'x86_64'] lib_base_dir = 'lib' else - error( - 'unsupported architecture for macos: ' + host_machine.cpu_family(), - ) + error('unsupported architecture for macos: ' + host_machine.cpu_family()) endif elif host_machine.system() == 'linux' @@ -58,24 +59,19 @@ elif host_machine.system() == 'linux' endif else - error( - 'unsupported architecture for linux: ' + host_machine.cpu_family(), - ) + error('unsupported architecture for linux: ' + host_machine.cpu_family()) endif elif host_machine.system() == 'windows' if host_machine.cpu_family() == 'x86_64' lib_base_dir = get_option('default_library') == 'static' ? 'bin' : 'lib' else - error( - 'unsupported architecture for windows: ' + host_machine.cpu_family(), - ) + error('unsupported architecture for windows: ' + host_machine.cpu_family()) endif else error('unsupported system: ' + host_machine.system()) endif -lib_dir = ( - lib_base_dir / (get_option('buildtype') == 'release' ? 'release' : 'debug') +lib_dir = (lib_base_dir / (get_option('buildtype') == 'release' ? 'release' : 'debug') ) c = meson.get_compiler('c') diff --git a/subprojects/packagefiles/keyutils/meson.build b/subprojects/packagefiles/keyutils/meson.build index 89d611c05..e2e0e04d3 100644 --- a/subprojects/packagefiles/keyutils/meson.build +++ b/subprojects/packagefiles/keyutils/meson.build @@ -16,9 +16,7 @@ project( inc_dirs = include_directories('.') -src_files = files( - 'keyutils.c', -) +src_files = files('keyutils.c') API_VERSON = '1.10' @@ -26,7 +24,8 @@ sh = find_program('sh') current_date = run_command( sh, - '-c', 'date -u +%F', + '-c', + 'date -u +%F', check: true, ).stdout().strip() diff --git a/tests/graphics/meson.build b/tests/graphics/meson.build index dcb377355..081221b1c 100644 --- a/tests/graphics/meson.build +++ b/tests/graphics/meson.build @@ -1,4 +1 @@ -graphics_test_src += files( - 'sdl_key.cpp', - 'tetrion_simulation.cpp', -) +graphics_test_src += files('sdl_key.cpp', 'tetrion_simulation.cpp') diff --git a/tests/utils/meson.build b/tests/utils/meson.build index adaf0f0e9..95435d7f2 100644 --- a/tests/utils/meson.build +++ b/tests/utils/meson.build @@ -1,6 +1 @@ -test_src += files( - 'files.cpp', - 'files.hpp', - 'helper.hpp', - 'printer.hpp', -) +test_src += files('files.cpp', 'files.hpp', 'helper.hpp', 'printer.hpp') diff --git a/tools/dependencies/meson.build b/tools/dependencies/meson.build index b38986304..647ac7766 100644 --- a/tools/dependencies/meson.build +++ b/tools/dependencies/meson.build @@ -46,7 +46,7 @@ if meson.is_cross_build() int main() { return 0; } - ''', + ''' ) if not can_compile @@ -67,11 +67,13 @@ if meson.is_cross_build() foreach native_dependency_tuple : map_native_dependencies native_dep_lib_name = native_dependency_tuple[0] - native_dep_name = ( - native_dependency_tuple.length() == 2 ? native_dependency_tuple[1] : native_dep_lib_name - ) + native_dep_name = (native_dependency_tuple.length() == 2 ? native_dependency_tuple[1] : native_dep_lib_name +) - native_dep = cpp.find_library(native_dep_lib_name, required: true) + native_dep = cpp.find_library( + native_dep_lib_name, + required: true, + ) if native_dep_name == 'SDL2' @@ -79,37 +81,25 @@ if meson.is_cross_build() 'SDL_MAJOR_VERSION', prefix: '#include ', ).strip('"') - assert( - major_version != '', - 'failed to get major_version from SDL_version.h', - ) + assert(major_version != '', 'failed to get major_version from SDL_version.h') minor_version = cpp.get_define( 'SDL_MINOR_VERSION', prefix: '#include ', ).strip('"') - assert( - minor_version != '', - 'failed to get minor_version from SDL_version.h', - ) + assert(minor_version != '', 'failed to get minor_version from SDL_version.h') patch_version = cpp.get_define( 'SDL_PATCHLEVEL', prefix: '#include ', ).strip('"') - assert( - patch_version != '', - 'failed to get patch_version from SDL_version.h', - ) + assert(patch_version != '', 'failed to get patch_version from SDL_version.h') native_dep_with_version = declare_dependency( dependencies: native_dep, version: major_version + '.' + minor_version + '.' + patch_version, ) - meson.override_dependency( - native_dep_name, - native_dep_with_version, - ) + meson.override_dependency(native_dep_name, native_dep_with_version) else meson.override_dependency(native_dep_name, native_dep) @@ -131,7 +121,10 @@ if meson.is_cross_build() ] foreach native_dep_name : native_dep_names - native_deps += cpp.find_library(native_dep_name, required: true) + native_deps += cpp.find_library( + native_dep_name, + required: true, + ) endforeach graphics_lib += { @@ -145,10 +138,9 @@ endif fmt_use_header_only = false -if ( - meson.is_cross_build() - and (host_machine.system() == 'switch' - or host_machine.system() == '3ds') +if (meson.is_cross_build() +and (host_machine.system() == 'switch' +or host_machine.system() == '3ds') ) fmt_use_header_only = true endif @@ -162,16 +154,24 @@ if fmt_use_header_only meson.override_dependency('fmt', fmt_header_only_dep) fmt_dep = fmt_header_only_dep else - fmt_dep = dependency('fmt', required: true, allow_fallback: true) + fmt_dep = dependency( + 'fmt', + required: true, + allow_fallback: true, + ) endif -core_lib += {'deps': [core_lib.get('deps'), fmt_dep]} +core_lib += { + 'deps': [core_lib.get('deps'), fmt_dep], +} nlohmann_json_dep = dependency( 'nlohmann_json', required: true, ) -core_lib += {'deps': [core_lib.get('deps'), nlohmann_json_dep]} +core_lib += { + 'deps': [core_lib.get('deps'), nlohmann_json_dep], +} # check std::expected support have_std_expected = cpp.compiles( @@ -192,7 +192,10 @@ if not have_std_expected message('Compiler doesn\'t support std::expected, using fallback') - tl_exp_dep = dependency('tl-expected', required: true) + tl_exp_dep = dependency( + 'tl-expected', + required: true, + ) temp = core_lib.get('compile_args') temp += '-D_USE_TL_EXPECTED' @@ -222,16 +225,23 @@ endif magic_enum_dep = dependency( 'magic_enum', required: true, - default_options: {'test': false, 'hash': true}, + default_options: { + 'test': false, + 'hash': true, + }, ) -core_lib += {'deps': [core_lib.get('deps'), magic_enum_dep]} +core_lib += { + 'deps': [core_lib.get('deps'), magic_enum_dep], +} utf8cpp_dep = dependency( 'utf8cpp', required: true, version: '>=4.0.0', ) -graphics_lib += {'deps': [graphics_lib.get('deps'), utf8cpp_dep]} +graphics_lib += { + 'deps': [graphics_lib.get('deps'), utf8cpp_dep], +} icu_dep = dependency( 'icu-uc', @@ -240,10 +250,7 @@ icu_dep = dependency( if icu_dep.found() graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_HAVE_ICU_DEP', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-D_HAVE_ICU_DEP'], 'deps': [graphics_lib.get('deps'), icu_dep], } endif @@ -271,7 +278,9 @@ if build_application sdl2_dep = dependency( 'sdl2', required: true, - default_options: {'test': false}, + default_options: { + 'test': false, + }, version: '>=2.24.0', ) sdl2main_dep = dependency( @@ -314,15 +323,24 @@ if build_application allow_fallback: true, required: false, ) - sdl2_mixer_flags = {'flac': 'enabled'} + sdl2_mixer_flags = { + 'flac': 'enabled', + } sdl2_mixer_defines = ['-DAUDIO_WITH_FLAC_SUPPORT'] if mpg123_dep.found() - sdl2_mixer_flags += {'mpg123': 'enabled'} + sdl2_mixer_flags += { + 'mpg123': 'enabled', + } sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' else - mpg123_dep = cpp.find_library('mpg123', required: false) + mpg123_dep = cpp.find_library( + 'mpg123', + required: false, + ) if mpg123_dep.found() - sdl2_mixer_flags += {'mpg123': 'enabled'} + sdl2_mixer_flags += { + 'mpg123': 'enabled', + } sdl2_mixer_defines += '-DAUDIO_WITH_MP3_SUPPORT' meson.override_dependency('mpg123', mpg123_dep) @@ -344,7 +362,9 @@ if build_application spdlog_dep = dependency( 'spdlog', required: true, - default_options: {'tests': 'disabled'}, + default_options: { + 'tests': 'disabled', + }, ) graphics_lib += { 'deps': [graphics_lib.get('deps'), spdlog_dep], @@ -352,10 +372,7 @@ if build_application if (meson.is_cross_build() and host_machine.system() == '3ds') graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-DSPDLOG_NO_TLS', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-DSPDLOG_NO_TLS'], } endif @@ -375,20 +392,14 @@ if build_application graphics_lib += { 'deps': [graphics_lib.get('deps'), cpp_httlib_dep], - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_OOPETRIS_ONLINE_SYSTEM=0', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-D_OOPETRIS_ONLINE_SYSTEM=0'], } elif meson.is_cross_build() and host_machine.system() == 'emscripten' online_multiplayer_system = 'web' graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_OOPETRIS_ONLINE_SYSTEM=1', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-D_OOPETRIS_ONLINE_SYSTEM=1'], } else @@ -404,30 +415,30 @@ if build_application graphics_lib += { 'deps': [graphics_lib.get('deps'), curl_cpp_wrapper], - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_OOPETRIS_ONLINE_SYSTEM=2', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-D_OOPETRIS_ONLINE_SYSTEM=2'], } endif - if ( - host_machine.system() == 'linux' - or (meson.is_cross_build() - and host_machine.system() == 'android') - ) + if (host_machine.system() == 'linux' +or (meson.is_cross_build() +and host_machine.system() == 'android') +) keyutils_dep = dependency( 'keyutils', required: true, allow_fallback: true, ) - graphics_lib += {'deps': [graphics_lib.get('deps'), keyutils_dep]} + graphics_lib += { + 'deps': [graphics_lib.get('deps'), keyutils_dep], + } elif host_machine.system() == 'windows' c = meson.get_compiler('c') ncrypt_dep = c.find_library('ncrypt') - graphics_lib += {'deps': [graphics_lib.get('deps'), ncrypt_dep]} + graphics_lib += { + 'deps': [graphics_lib.get('deps'), ncrypt_dep], + } endif build_installer = get_option('build_installer') @@ -438,8 +449,9 @@ if build_application if build_installer if get_option('buildtype') != 'release' error( - 'buildtype needs to be \'release\', when building the installer, but was: ' + - get_option('buildtype'), + 'buildtype needs to be \'release\', when building the installer, but was: ' + get_option( + 'buildtype' + ) ) endif @@ -447,23 +459,21 @@ if build_application if get_option('prefix') == '/app' is_flatpak_build = true else - error( - 'only support flatpak builds, when building the installer for linux', - ) + error('only support flatpak builds, when building the installer for linux') endif elif host_machine.system() == 'windows' message('Adding a windows installer target: \'windows_installer\'') else # TODO: create a proper installer for macOS : https://mesonbuild.com/Creating-OSX-packages.html - error( - 'unsupported system for building the installer: ' + host_machine.system(), - ) + error('unsupported system for building the installer: ' + host_machine.system()) endif temp = core_lib.get('compile_args') temp += '-DBUILD_INSTALLER' - core_lib += {'compile_args': temp} + core_lib += { + 'compile_args': temp, + } temp = 0 endif @@ -473,7 +483,9 @@ if build_application temp = core_lib.get('compile_args') temp += '-DFLATPAK_BUILD' - core_lib += {'compile_args': temp} + core_lib += { + 'compile_args': temp, + } temp = 0 endif @@ -491,25 +503,20 @@ if build_application if nfde_dep.found() have_file_dialogs = true graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_HAVE_FILE_DIALOGS', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-D_HAVE_FILE_DIALOGS'], 'deps': [graphics_lib.get('deps'), nfde_dep], } endif c = meson.get_compiler('c') - discord_dep_required = ( - not meson.is_cross_build() - and get_option('build_installer') - ) + discord_dep_required = (not meson.is_cross_build() +and get_option('build_installer') +) - if ( - host_machine.system() == 'linux' - and host_machine.cpu_family() == 'aarch64' - ) + if (host_machine.system() == 'linux' +and host_machine.cpu_family() == 'aarch64' +) # not supported on aarch64 linux :( discord_dep_required = false endif @@ -523,15 +530,15 @@ if build_application if discord_social_sdk_dep.found() have_discord_social_sdk = true graphics_lib += { - 'compile_args': [ - graphics_lib.get('compile_args'), - '-D_HAVE_DISCORD_SOCIAL_SDK', - ], + 'compile_args': [graphics_lib.get('compile_args'), '-D_HAVE_DISCORD_SOCIAL_SDK'], 'deps': [graphics_lib.get('deps'), discord_social_sdk_dep], } endif - argparse_dep = dependency('argparse', required: true) + argparse_dep = dependency( + 'argparse', + required: true, + ) graphic_application_deps += argparse_dep recordings_application_deps += argparse_dep diff --git a/tools/install/meson.build b/tools/install/meson.build index b141b05e2..091e5c278 100644 --- a/tools/install/meson.build +++ b/tools/install/meson.build @@ -72,7 +72,10 @@ if build_application install_tag: 'other', ) - desktop_file_validate_exe = find_program('desktop-file-validate', required: require_checks) + desktop_file_validate_exe = find_program( + 'desktop-file-validate', + required: require_checks, + ) if desktop_file_validate_exe.found() test( @@ -97,18 +100,16 @@ if build_application install_tag: 'other', ) - ascli_exe = find_program('appstreamcli', required: require_checks) + ascli_exe = find_program( + 'appstreamcli', + required: require_checks, + ) if ascli_exe.found() test( 'validate metainfo file', ascli_exe, - args: [ - 'validate', - '--no-net', - '--explain', - '--pedantic', metainfo_file, - ], + args: ['validate', '--no-net', '--explain', '--pedantic', metainfo_file], ) endif diff --git a/tools/options/meson.build b/tools/options/meson.build index 43c26c1e1..a1e40bf20 100644 --- a/tools/options/meson.build +++ b/tools/options/meson.build @@ -3,9 +3,7 @@ oopetris_name = 'OOPetris' core_lib = { 'inc_dirs': [], - 'compile_args': [ - '-DOOPETRIS_VERSION=' + meson.project_version(), - ], + 'compile_args': ['-DOOPETRIS_VERSION=' + meson.project_version()], 'deps': [], } @@ -27,12 +25,10 @@ graphics_lib = { if meson.is_cross_build() and host_machine.system() == 'serenity' temp = core_lib.get('compile_args') - temp += [ - '-D__SERENITY__', - '-DINSTALL_FILES', - '-DINSTALL_LOCATION=' + get_option('prefix'), - ] - core_lib += {'compile_args': temp} + temp += ['-D__SERENITY__', '-DINSTALL_FILES', '-DINSTALL_LOCATION=' + get_option('prefix')] + core_lib += { + 'compile_args': temp, + } temp = 0 elif meson.is_cross_build() and host_machine.system() == 'android' cpp = meson.get_compiler('cpp') @@ -42,10 +38,7 @@ elif meson.is_cross_build() and host_machine.system() == 'android' '__ANDROID_API__', prefix: '#include ', ).strip('"') - assert( - android_api != '', - 'failed to get android_api version', - ) + assert(android_api != '', 'failed to get android_api version') android_compile_args = [] android_link_args = [] @@ -63,11 +56,23 @@ elif meson.is_cross_build() and host_machine.system() == 'android' ] if not meson.is_subproject() - add_global_link_arguments(android_link_args, language: ['cpp']) - add_global_arguments(android_compile_args, language: ['cpp']) + add_global_link_arguments( + android_link_args, + language: ['cpp'], + ) + add_global_arguments( + android_compile_args, + language: ['cpp'], + ) else - add_project_link_arguments(android_link_args, language: ['cpp']) - add_project_arguments(android_compile_args, language: ['cpp']) + add_project_link_arguments( + android_link_args, + language: ['cpp'], + ) + add_project_arguments( + android_compile_args, + language: ['cpp'], + ) endif endif @@ -79,7 +84,10 @@ build_with_libcpp = false allow_tl_expected_fallback = false if cpp.get_id() == 'gcc' - add_project_arguments('-Wold-style-cast', language: ['cpp']) + add_project_arguments( + '-Wold-style-cast', + language: ['cpp'], + ) elif cpp.get_id() == 'clang' build_with_libcpp_option = get_option('clang_libcpp') @@ -91,8 +99,14 @@ elif cpp.get_id() == 'clang' build_with_libcpp = true else - cpp_lib = cpp.find_library('c++', required: false) - cppabi_lib = cpp.find_library('c++abi', required: false) + 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 @@ -109,20 +123,28 @@ elif cpp.get_id() == 'clang' core_lib += { 'compile_args': temp, - 'deps': [ - core_lib.get('deps'), - cpp.find_library('c++'), - cpp.find_library('c++abi'), - ], + 'deps': [core_lib.get('deps'), cpp.find_library('c++'), cpp.find_library('c++abi')], } temp = 0 if not meson.is_subproject() - add_global_link_arguments('-stdlib=libc++', language: ['cpp']) - add_global_arguments('-stdlib=libc++', language: ['cpp']) + add_global_link_arguments( + '-stdlib=libc++', + language: ['cpp'], + ) + add_global_arguments( + '-stdlib=libc++', + language: ['cpp'], + ) else - add_project_link_arguments('-stdlib=libc++', language: ['cpp']) - add_project_arguments('-stdlib=libc++', language: ['cpp']) + add_project_link_arguments( + '-stdlib=libc++', + language: ['cpp'], + ) + add_project_arguments( + '-stdlib=libc++', + language: ['cpp'], + ) endif