From 5f08b9ade43bb1e639896181d1caae4cf86b35c9 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 17 Aug 2024 23:26:31 -0400 Subject: [PATCH] build: Remove redundant comparisons If a Meson option is typed as `boolean`, the `get_option` returns a boolean, and comparing it with `true` is redundant. Meson also errors if you try to compare across types, so it couldn't _not_ be a boolean. Also, Meson is not C, so no need for parentheses around `if` conditions. --- examples/meson.build | 6 +++--- meson.build | 14 +++++++------- src/bindings/meson.build | 4 ++-- src/bindings/wasm/meson.build | 2 +- src/loaders/meson.build | 6 +++--- src/meson.build | 6 +++--- test/meson.build | 4 ++-- tools/meson.build | 4 ++-- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index ed33e2a5..8c48a4dd 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,4 +1,4 @@ -if (lib_type == 'static') +if lib_type == 'static' compiler_flags += ['-DTVG_STATIC'] endif @@ -8,7 +8,7 @@ endif examples_dep = [dependency('sdl2')] -if (get_option('engines').contains('wg_beta')) +if get_option('engines').contains('wg_beta') examples_dep += dependency('wgpu_native') if host_machine.system() == 'darwin' add_languages('objcpp') @@ -93,7 +93,7 @@ foreach current_file : source_file endforeach -if get_option('bindings').contains('capi') == true +if get_option('bindings').contains('capi') capi_source_file = [ 'Capi.cpp' ] diff --git a/meson.build b/meson.build index 49bce72b..34bc05c3 100644 --- a/meson.build +++ b/meson.build @@ -14,7 +14,7 @@ add_project_arguments('-DEXAMPLE_DIR="@0@/examples/resources"'.format(src_dir), config_h.set_quoted('THORVG_VERSION_STRING', meson.project_version()) #Multi-Tasking -if get_option('threads') == true +if get_option('threads') config_h.set10('THORVG_THREAD_SUPPORT', true) endif @@ -100,7 +100,7 @@ endif #Vectorization simd_type = 'none' -if get_option('simd') == true +if get_option('simd') if host_machine.cpu_family().startswith('x86') config_h.set10('THORVG_AVX_VECTOR_SUPPORT', true) simd_type = 'avx' @@ -114,16 +114,16 @@ if get_option('simd') == true endif #Bindings -if get_option('bindings').contains('capi') == true +if get_option('bindings').contains('capi') config_h.set10('THORVG_CAPI_BINDING_SUPPORT', true) endif -if get_option('bindings').contains('wasm_beta') == true +if get_option('bindings').contains('wasm_beta') config_h.set10('THORVG_WASM_BINDING_SUPPORT', true) endif #Log -if get_option('log') == true +if get_option('log') config_h.set10('THORVG_LOG_ENABLED', true) endif @@ -151,11 +151,11 @@ subdir('inc') subdir('src') subdir('tools') -if get_option('examples') == true +if get_option('examples') subdir('examples') endif -if get_option('tests') == true +if get_option('tests') subdir('test') endif diff --git a/src/bindings/meson.build b/src/bindings/meson.build index 9532cb4a..d2f08ea6 100644 --- a/src/bindings/meson.build +++ b/src/bindings/meson.build @@ -1,7 +1,7 @@ -if get_option('bindings').contains('capi') == true +if get_option('bindings').contains('capi') subdir('capi') endif -if get_option('bindings').contains('wasm_beta') == true +if get_option('bindings').contains('wasm_beta') subdir('wasm') endif diff --git a/src/bindings/wasm/meson.build b/src/bindings/wasm/meson.build index cde36704..741b6997 100644 --- a/src/bindings/wasm/meson.build +++ b/src/bindings/wasm/meson.build @@ -1,4 +1,4 @@ -if (cc.get_id() == 'emscripten') +if cc.get_id() == 'emscripten' source_file = files('tvgWasmLottieAnimation.cpp') thorvg_wasm_dep = declare_dependency(include_directories : include_directories('.'), sources diff --git a/src/loaders/meson.build b/src/loaders/meson.build index ea1d9e11..e398f9db 100644 --- a/src/loaders/meson.build +++ b/src/loaders/meson.build @@ -17,7 +17,7 @@ if lottie_loader endif if png_loader - if get_option('static') == true + if get_option('static') subdir('png') else subdir('external_png') @@ -28,7 +28,7 @@ if png_loader endif if jpg_loader - if get_option('static') == true + if get_option('static') subdir('jpg') else subdir('external_jpg') @@ -39,7 +39,7 @@ if jpg_loader endif if webp_loader - if get_option('static') == true + if get_option('static') subdir('webp') else subdir('external_webp') diff --git a/src/meson.build b/src/meson.build index b13b0015..4decc72e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -3,14 +3,14 @@ override_options = [] lib_type = get_option('default_library') -if (lib_type == 'shared') +if lib_type == 'shared' compiler_flags += ['-DTVG_EXPORT', '-DTVG_BUILD'] else compiler_flags += ['-DTVG_STATIC'] endif cc = meson.get_compiler('cpp') -if (cc.get_id() == 'clang-cl') +if cc.get_id() == 'clang-cl' if simd_type == 'avx' compiler_flags += ['/clang:-mavx'] endif @@ -44,7 +44,7 @@ subdir('savers') thorvg_lib_dep = [common_dep, utils_dep, loader_dep, saver_dep] -if get_option('threads') == true and host_machine.system() != 'windows' and host_machine.system() != 'android' +if get_option('threads') and host_machine.system() != 'windows' and host_machine.system() != 'android' thread_dep = meson.get_compiler('cpp').find_library('pthread') thorvg_lib_dep += [thread_dep] endif diff --git a/test/meson.build b/test/meson.build index df5606a9..0d89fcc1 100644 --- a/test/meson.build +++ b/test/meson.build @@ -1,4 +1,4 @@ -if (lib_type == 'static') +if lib_type == 'static' compiler_flags += ['-DTVG_STATIC'] endif @@ -27,6 +27,6 @@ tests = executable('tvgUnitTests', test('Unit Tests', tests, args : ['--success']) -if get_option('bindings').contains('capi') == true +if get_option('bindings').contains('capi') subdir('capi') endif diff --git a/tools/meson.build b/tools/meson.build index 9ed8a7c5..dba414b7 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -1,4 +1,4 @@ -if (lib_type == 'static') +if lib_type == 'static' compiler_flags += ['-DTVG_STATIC'] endif @@ -12,4 +12,4 @@ endif if lottie2gif subdir('lottie2gif') -endif \ No newline at end of file +endif