New-Cli-Installer/meson.build

203 lines
6.4 KiB
Meson
Raw Normal View History

2021-11-26 02:34:58 +08:00
project('cachyos-installer', 'cpp',
2024-07-14 07:00:47 +08:00
version: '0.8.0',
2021-11-26 02:34:58 +08:00
license: 'GPLv3',
meson_version: '>=0.55.0',
2024-07-13 01:09:01 +08:00
default_options: ['cpp_std=c++23',
2021-11-26 02:34:58 +08:00
'buildtype=debugoptimized',
'warning_level=3',
2022-06-06 04:42:31 +08:00
'werror=false',
2021-11-26 02:34:58 +08:00
'b_ndebug=if-release'])
is_debug_build = get_option('buildtype').startswith('debug')
is_dev_environment = get_option('devenv')
2022-08-08 04:55:17 +08:00
is_tests_build = get_option('build_tests')
2024-06-26 06:48:27 +08:00
do_build_static = get_option('build_static')
2021-11-26 02:34:58 +08:00
cc = meson.get_compiler('cpp')
if cc.get_id() == 'clang'
2021-12-01 06:03:18 +08:00
specific_cc_flags = [
'-nostdlib++',
2022-01-03 05:45:54 +08:00
#'-stdlib=libc++',
#'-nodefaultlibs',
#'-fexperimental-library',
'-fstrict-vtable-pointers',
'-fexperimental-new-pass-manager',
2021-12-01 06:03:18 +08:00
]
#specific_link_flags = [
# '-stdlib=libc++',
#]
2021-12-01 06:03:18 +08:00
add_global_arguments(cc.get_supported_arguments(specific_cc_flags), language : 'cpp')
add_global_link_arguments(cc.get_supported_link_arguments(specific_link_flags), language : 'cpp')
endif
2021-11-26 02:34:58 +08:00
if is_debug_build
add_global_arguments('-D_GLIBCXX_ASSERTIONS', language : 'cpp')
add_global_arguments('-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS=1', language : 'cpp')
add_global_arguments('-D_LIBCPP_ENABLE_ASSERTIONS=1', language : 'cpp')
endif
if not is_dev_environment
add_global_arguments('-DNDEVENV', language : 'cpp')
endif
add_global_arguments('-DSPDLOG_DISABLE_DEFAULT_LOGGER', language : 'cpp')
add_global_arguments('-DSPDLOG_FMT_EXTERNAL', language : 'cpp')
2022-12-09 06:55:15 +08:00
version_commit_hash = run_command('git', 'rev-parse', '--short', 'HEAD', check: false).stdout().strip()
build_timestamp = run_command('date', '+%Y%m%d', check: true).stdout().strip()
git_version = ''
if version_commit_hash == ''
git_version = meson.project_version() + '-' + build_timestamp
else
git_version = meson.project_version() + '-' + version_commit_hash + '-' + build_timestamp
endif
add_global_arguments('-DINSTALLER_VERSION="' + git_version + '"', language : 'cpp')
2024-07-06 05:59:50 +08:00
# gucc test path
add_global_arguments('-DGUCC_TEST_DIR="' + meson.current_source_dir() + '/gucc/tests/"', language : 'cpp')
add_global_arguments('-DGUCC_TOP_DIR="' + meson.current_source_dir() + '/"', language : 'cpp')
2024-07-06 05:59:50 +08:00
2021-11-26 02:34:58 +08:00
# Common dependencies
2023-12-03 23:39:03 +08:00
spdlog = dependency('spdlog', version : ['>=1.12.0'], fallback : ['spdlog', 'spdlog_dep'])
fmt = dependency('fmt', version : ['>=10.1.0'], fallback : ['fmt', 'fmt_dep'])
ftxui = dependency('ftxui', modules : ['ftxui::screen', 'ftxui::dom', 'ftxui::component'], fallback : ['ftxui', 'ftxui_dep'])
rapidjson = dependency('rapidjson', version : ['>=1.1.0'], fallback : ['rapidjson', 'rapidjson_dep'])
2023-12-03 23:39:03 +08:00
ctre = dependency('ctre', version : ['>=3.8.0'], fallback : ['ctre', 'ctre_dep'])
tomlplusplus = dependency('tomlplusplus', version : ['>=3.4.0'], fallback : ['tomlplusplus', 'tomlplusplus_dep'], default_options: ['compile_library=false'])
2022-02-14 07:22:19 +08:00
#glibmm = dependency('glibmm-2.4', version : ['>=2.56.0'])
2024-07-11 05:13:23 +08:00
cpr = dependency('cpr', version : ['>=1.10.0'], fallback : ['cpr', 'cpr_dep'])
2022-11-19 08:19:55 +08:00
2021-11-26 02:34:58 +08:00
src_files = files(
2021-12-03 07:10:05 +08:00
'src/view.hpp',
2021-11-26 02:34:58 +08:00
'src/definitions.hpp',
'src/config.cpp', 'src/config.hpp',
2021-11-26 02:34:58 +08:00
'src/utils.cpp', 'src/utils.hpp',
2023-08-13 04:53:11 +08:00
'src/chwd_profiles.cpp', 'src/chwd_profiles.hpp',
2022-02-12 08:38:15 +08:00
'src/disk.cpp', 'src/disk.hpp',
'src/drivers.cpp', 'src/drivers.hpp',
'src/widgets.cpp', 'src/widgets.hpp',
2021-12-27 07:04:03 +08:00
'src/follow_process_log.cpp', 'src/follow_process_log.hpp',
2022-01-09 08:41:43 +08:00
'src/crypto.cpp', 'src/crypto.hpp',
'src/misc.cpp', 'src/misc.hpp',
'src/simple_tui.cpp', 'src/simple_tui.hpp',
2021-11-29 02:36:27 +08:00
'src/tui.cpp', 'src/tui.hpp',
2021-11-26 02:34:58 +08:00
'src/main.cpp',
)
possible_cc_flags = [
2021-12-01 06:03:18 +08:00
'-Wshadow',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wnon-virtual-dtor',
2021-11-26 02:34:58 +08:00
'-Wold-style-cast',
2021-12-01 06:03:18 +08:00
'-Wcast-align',
'-Wunused',
'-Woverloaded-virtual',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wpedantic', # non-standard C++
'-Wconversion', # type conversion that may lose data
'-Wsign-conversion',
2021-12-01 06:03:18 +08:00
'-Wnull-dereference',
'-Wdouble-promotion', # float to double
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wformat=2',
2021-12-01 20:42:20 +08:00
'-Wimplicit-fallthrough', # fallthrough without an explicit annotation
2021-11-26 02:34:58 +08:00
]
if cc.get_id() == 'gcc'
2021-12-01 06:03:18 +08:00
possible_cc_flags += [
'-Wmisleading-indentation',
2021-11-26 02:34:58 +08:00
2021-12-01 06:03:18 +08:00
'-Wduplicated-cond',
'-Wduplicated-branches',
'-Wlogical-op',
2021-12-01 20:42:20 +08:00
'-Wuseless-cast',
2022-06-06 04:36:15 +08:00
'-Wno-restrict',
2022-01-03 05:45:54 +08:00
2022-06-06 04:36:15 +08:00
#'-Wsuggest-attribute=cold',
2022-03-21 07:31:24 +08:00
#'-Wsuggest-attribute=format',
2022-01-03 05:45:54 +08:00
'-Wsuggest-attribute=malloc',
'-Wsuggest-attribute=noreturn',
'-Wsuggest-attribute=pure',
'-Wsuggest-final-methods',
'-Wsuggest-final-types',
'-Wdiv-by-zero',
'-Wanalyzer-double-fclose',
'-Wanalyzer-double-free',
'-Wanalyzer-malloc-leak',
'-Wanalyzer-use-after-free',
2022-11-17 06:15:20 +08:00
## some more analyzer flags
'-Wanalyzer-tainted-allocation-size',
'-Wanalyzer-use-of-uninitialized-value',
'-Wanalyzer-use-of-pointer-in-stale-stack-frame',
'-Wanalyzer-free-of-non-heap',
'-Wanalyzer-mismatching-deallocation',
'-Wanalyzer-null-dereference',
'-Wanalyzer-possible-null-dereference',
2021-12-01 06:03:18 +08:00
]
2021-11-26 02:34:58 +08:00
endif
if not is_debug_build
2021-11-26 02:34:58 +08:00
if cc.get_id() == 'gcc'
possible_cc_flags += [
'-flto',
'-fwhole-program',
2022-02-12 08:38:15 +08:00
'-fuse-linker-plugin',
2021-11-26 02:34:58 +08:00
]
else
possible_cc_flags += [
'-flto=thin',
'-fwhole-program-vtables',
2021-11-26 02:34:58 +08:00
]
endif
possible_cc_flags += ['-fdata-sections', '-ffunction-sections']
2024-06-26 06:48:27 +08:00
if do_build_static
possible_link_flags = ['-Wl,--gc-sections', '-static-libgcc', '-static-libstdc++']
endif
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'cpp')
2021-11-26 02:34:58 +08:00
endif
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'cpp')
deps = [fmt, spdlog, ftxui, rapidjson, ctre, tomlplusplus, cpr]
2022-01-03 05:45:54 +08:00
2024-06-26 06:48:27 +08:00
subdir('gucc')
2021-11-26 02:34:58 +08:00
executable(
'cachyos-installer',
src_files,
2022-01-03 05:45:54 +08:00
dependencies: deps,
2024-06-26 06:48:27 +08:00
link_with: gucc_lib,
include_directories: [include_directories('src'), include_directories('gucc/include')],
2021-11-26 02:34:58 +08:00
install: true)
2022-08-14 19:11:43 +08:00
install_data(
'src/install-repo.awk',
install_dir: '/usr/share/cachyos-installer'
)
2022-08-08 04:55:17 +08:00
if is_tests_build
subdir('tests')
endif
2021-12-27 02:42:19 +08:00
2021-11-26 02:34:58 +08:00
summary(
{
'Build type': get_option('buildtype'),
},
bool_yn: true
)
clangtidy = find_program('clang-tidy', required: false)
if clangtidy.found()
run_target(
'tidy',
command: [
clangtidy,
'-checks=*,-fuchsia-default-arguments',
'-p', meson.build_root()
] + src_files)
endif