project('strawberry', 'cpp', version: '0.2.8', license: 'GPL-3.0-or-later', meson_version: '>=1.0.0', subproject_dir: 'third_party', default_options: [ 'cpp_std=c++23', 'warning_level=3', 'werror=false', 'optimization=2', 'b_lto=true', ] ) # One version source: meson.build. Every binary reports it (CLI `version`, status JSON, banner); # scripts/release.sh bumps it and the release lane refuses a tag that does not match. add_project_arguments('-DSTRAWBERRY_VERSION="' + meson.project_version() + '"', language: 'cpp') # Compiler setup cpp = meson.get_compiler('cpp') clang_prog = find_program('clang', required: false) # Check for ccache ccache = find_program('ccache', required: false) if ccache.found() message('Using ccache for compilation') endif # Dependencies threads_dep = dependency('threads', required: true) openssl_dep = dependency('openssl', required: true) # Header-only JSON: policy payloads on the control socket, policy/feeds state. nlohmann_json_dep = dependency('nlohmann_json', required: true) # Event store: every block is a zstd frame (compressed by default). zstd_dep = dependency('libzstd', version: '>=1.5', required: true) common_deps = [ threads_dep, openssl_dep, nlohmann_json_dep, zstd_dep, ] # Rule updater (strawberry --update-rules): HTTPS download + archive extraction. libcurl_dep = dependency('libcurl', required: false) libarchive_dep = dependency('libarchive', required: false) strawberry_updater_available = libcurl_dep.found() and libarchive_dep.found() if strawberry_updater_available updater_feature_dep = declare_dependency( compile_args: ['-DSTRAWBERRY_HAVE_UPDATER=1'], dependencies: [libcurl_dep, libarchive_dep], ) else warning('libcurl/libarchive not found: strawberry --update-rules will be unavailable') updater_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_UPDATER=0']) endif # YARA library yara_dep = dependency('yara', required: false) if not yara_dep.found() yara_dep = cpp.find_library('yara', required: false) endif if yara_dep.found() yara_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_YARA=1']) else yara_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_YARA=0']) endif # BPF dependencies libbpf_dep = dependency('libbpf', required: false) if not libbpf_dep.found() libbpf_dep = cpp.find_library('bpf', required: false) endif libbpf_headers_found = false if host_machine.system() == 'linux' libbpf_headers_found = cpp.has_header('bpf/libbpf.h') endif strawberry_libbpf_backend_available = host_machine.system() == 'linux' and libbpf_dep.found() and libbpf_headers_found and clang_prog.found() strawberry_bpf_build_object_path = join_paths(meson.project_build_root(), 'src', 'process_monitor.bpf.o') strawberry_bpf_install_object_path = join_paths(get_option('prefix'), get_option('datadir'), 'strawberry', 'process_monitor.bpf.o') if strawberry_libbpf_backend_available libbpf_feature_dep = declare_dependency( compile_args: [ '-DSTRAWBERRY_HAVE_LIBBPF=1', '-DSTRAWBERRY_BPF_OBJECT_BUILD_PATH="' + strawberry_bpf_build_object_path + '"', '-DSTRAWBERRY_BPF_OBJECT_INSTALL_PATH="' + strawberry_bpf_install_object_path + '"', ], ) else libbpf_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_LIBBPF=0']) endif # Endpoint Security (macOS): exec telemetry, exec prevention and file # watching. Building only needs the SDK; running needs root, the ES # entitlement and Full Disk Access (see src/platform/es_support.hpp). strawberry_es_available = false es_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_ENDPOINT_SECURITY=0']) if host_machine.system() == 'darwin' and get_option('enable_endpoint_security').allowed() es_lib = cpp.find_library('EndpointSecurity', required: get_option('enable_endpoint_security')) bsm_lib = cpp.find_library('bsm', required: get_option('enable_endpoint_security')) if es_lib.found() and bsm_lib.found() and cpp.has_header('EndpointSecurity/EndpointSecurity.h', args: ['-fblocks']) strawberry_es_available = true es_feature_dep = declare_dependency( compile_args: ['-DSTRAWBERRY_HAVE_ENDPOINT_SECURITY=1', '-fblocks'], dependencies: [es_lib, bsm_lib], ) endif elif get_option('enable_endpoint_security').enabled() error('enable_endpoint_security is macOS only') endif # Fuzzing: instrument the whole project so targets see coverage in the code # they call. clang only. if get_option('enable_fuzzing') if cpp.get_id() != 'clang' error('enable_fuzzing needs clang (CC=clang CXX=clang++)') endif add_project_arguments('-fsanitize=fuzzer-no-link,address,undefined', '-fno-omit-frame-pointer', '-g', language: ['c', 'cpp']) add_project_link_arguments('-fsanitize=address,undefined', language: ['c', 'cpp']) endif # Optional Tracy profiling (see include/strawberry/profiling.hpp). if get_option('enable_profiling') tracy_dep = dependency('tracy', fallback: ['tracy', 'tracy_dep'], required: true) profiling_feature_dep = declare_dependency( compile_args: ['-DTRACY_ENABLE', '-fno-omit-frame-pointer'], dependencies: [tracy_dep], ) else profiling_feature_dep = declare_dependency() endif strawberry_feature_deps = [yara_feature_dep, libbpf_feature_dep, es_feature_dep, profiling_feature_dep] strawberry_runtime_deps = common_deps + strawberry_feature_deps strawberry_yara_deps = common_deps + strawberry_feature_deps strawberry_monitor_deps = common_deps + strawberry_feature_deps if yara_dep.found() strawberry_yara_deps += yara_dep endif if libbpf_dep.found() strawberry_monitor_deps += libbpf_dep endif # Project include directories inc_dirs = include_directories('include') # Subdirectories subdir('src') # Desktop app (optional, Qt6) # DBus carries desktop notifications on Linux only (app/notifier.cpp). qt6_modules = ['Core', 'Gui', 'Widgets', 'Network'] if host_machine.system() == 'linux' qt6_modules += 'DBus' endif qt6_dep = dependency('qt6', modules: qt6_modules, required: get_option('enable_app')) if qt6_dep.found() subdir('app') endif # Agent access: MCP server (optional) if get_option('enable_mcp').allowed() subdir('mcp') endif # Tests (optional) if get_option('enable_tests') subdir('tests') endif if get_option('enable_fuzzing') subdir('fuzz') endif