blob: 02e1e0f33aec3fd5d7ff9a5f1d82d22c5eba732e [file] [log] [blame] [edit]
cpp_compiler = meson.get_compiler('cpp')
gpr_dep = dependency('gpr', required: false)
if not gpr_dep.found()
gpr_dep = cpp_compiler.find_library('gpr')
endif
grpc_dep = dependency('grpc', required: false)
if not grpc_dep.found()
grpc_dep = cpp_compiler.find_library('grpc')
endif
grpcpp_dep = dependency('grpc++', required: false)
if not grpcpp_dep.found()
grpcpp_dep = cpp_compiler.find_library('grpc++')
endif
grpcpp_reflect_dep = dependency('grpc++_reflection', required: false)
# Workaround for grpc++_reflection not available by pkgconfig
if not grpcpp_reflect_dep.found()
grpcpp_reflect_dep = cpp_compiler.find_library('grpc++_reflection', required: true)
endif
protobuf_dep = dependency('protobuf')
fmt_dep = dependency('fmt')
boottime_api_dep = dependency('boottime_api')
# Generate proto_generated_dep
subdir('proto')
grpcblob_cpp_args = []
# It would be nice if Meson had a standard concise way of doing this
# https://github.com/mesonbuild/meson/issues/6269
grpc_inv_suffix_val = get_option('smbios-grpc-inv-suffix')
if grpc_inv_suffix_val != ''
grpc_inv_suffix_arg = '-DGRPC_INV_SUFFIX=' + grpc_inv_suffix_val
grpcsblob_cpp_args += [
grpc_inv_suffix_arg
]
endif
grpc_blobs_lib = static_library(
'GrpcBlobTransfer',
sources: [
'smbios_callback.cc',
'biossettings_callback.cc',
'baremetal_callback.cc',
'boottime_callback.cc',
'grpc_instance.cc',
'smbios_file.cc',
'grpcblob_server.cc'
],
cpp_args: grpcblob_cpp_args,
include_directories: [
],
dependencies: [
gpr_dep,
grpc_dep,
grpcpp_dep,
grpcpp_reflect_dep,
protobuf_dep,
fmt_dep,
proto_generated_dep,
boottime_api_dep,
]
)
grpc_blobs_inc = grpc_blobs_lib.private_dir_include()
grpc_this_inc = include_directories('.')
grpc_blobs_dep = declare_dependency(
include_directories: [
grpc_blobs_inc,
grpc_this_inc
],
link_with: grpc_blobs_lib
)
cpp_args_grpchandler = []
grpcblob_handler_sources = [
'grpcblob_main.cc',
]
executable(
'grpcblobhandler',
grpcblob_handler_sources,
cpp_args: cpp_args_grpchandler,
dependencies: [
grpc_blobs_dep,
boottime_api_dep,
],
implicit_include_directories: false,
install: true,
install_dir: get_option('bindir'),
)
clang_grpc_blobs_sources = files(
'grpc_instance.cc',
'baremetal_callback.cc',
'biossettings_callback.cc',
'boottime_callback.cc',
'smbios_file.cc',
'grpcblob_main.cc',
'smbios_callback.cc',
'grpcblob_server.cc'
)
clang_grpc_blobs_headers = files(
'grpc_instance.h',
'biossettings_callback.h',
'boottime_callback.h',
'smbios_callback.h',
'smbios_file.h',
'grpcblob_server.h',
'grpcblob_defs.h',
'baremetal_callback.h'
)
clang_format_exe = find_program('clang-format', required : false)
if clang_format_exe.found()
format_files = clang_grpc_blobs_sources + clang_grpc_blobs_headers
run_target('format',
command : [clang_format_exe, '-i'] + format_files)
run_target('check-format',
command : [clang_format_exe, '--dry-run', '--Werror'] + format_files)
else
warning('clang-format not found, skipping format targets.')
endif
clang_tidy_exe = find_program('clang-tidy', required : false)
compile_db_path = join_paths(meson.project_build_root(), 'compile_commands.json')
fs = import('fs')
tidy_files = clang_grpc_blobs_sources + clang_grpc_blobs_headers
if clang_tidy_exe.found() and fs.exists(compile_db_path)
message('clang-tidy found, adding tidy and check-tidy targets.')
# Target to run clang-tidy and apply fixes
# NOTE: --fix modifies files in place. Review changes carefully.
run_target('tidy',
command : [clang_tidy_exe, '-p', meson.project_build_root(), '--fix'] + tidy_files
)
# Target to run clang-tidy for checking (e.g., CI)
# --quiet can make output less verbose, focusing on errors/warnings
run_target('check-tidy',
command : [clang_tidy_exe, '-p', meson.project_build_root(), '--warnings-as-errors=*'] + tidy_files
)
elif not clang_tidy_exe.found()
warning('clang-tidy executable not found, skipping tidy and check-tidy targets.')
elif not fs.exists(compile_db_path)
warning('compile_commands.json not found in build directory (@0@). Run meson setup/reconfigure. Skipping tidy targets.'.format(meson.project_build_root()))
endif
# Comment out flaky openbmc unit test temporarily
# subdir('test')