178 lines
5.8 KiB
Meson
178 lines
5.8 KiB
Meson
project('yams', 'cpp', 'c',
|
|
version: '0.8.0',
|
|
default_options: [
|
|
'buildtype=release',
|
|
'warning_level=3',
|
|
'cpp_std=c++20',
|
|
'c_std=c11',
|
|
],
|
|
)
|
|
|
|
fs = import('fs')
|
|
pkg = import('pkgconfig')
|
|
|
|
# Define install prefix for runtime plugin discovery
|
|
prefix = get_option('prefix')
|
|
add_project_arguments('-DYAMS_INSTALL_PREFIX="' + prefix + '"', language: 'cpp')
|
|
|
|
if host_machine.system() == 'darwin'
|
|
add_global_link_arguments('-Wl,-no_warn_duplicate_libraries', language: 'cpp')
|
|
endif
|
|
|
|
onnx_opt = get_option('enable-onnx')
|
|
|
|
# Enforce sqlite3 FTS5 presence at configure time (configurable)
|
|
require_fts5 = get_option('require-fts5')
|
|
sqlite_dep = dependency('sqlite3', required: true)
|
|
cpp = meson.get_compiler('cpp')
|
|
|
|
# Optional LLD linker support (preferred with Clang, optional with GCC)
|
|
use_lld = get_option('use-lld')
|
|
lld_available = cpp.has_link_argument('-fuse-ld=lld')
|
|
|
|
if use_lld.enabled() and not lld_available
|
|
error('LLD linker was requested but is not available')
|
|
elif use_lld.auto() and cpp.get_id() == 'clang' and lld_available
|
|
# Auto-enable LLD with Clang
|
|
add_project_link_arguments('-fuse-ld=lld', language: 'cpp')
|
|
add_project_link_arguments('-fuse-ld=lld', language: 'c')
|
|
message('Using LLD linker (auto-enabled with Clang)')
|
|
elif use_lld.enabled() and lld_available
|
|
# Explicitly enabled
|
|
add_project_link_arguments('-fuse-ld=lld', language: 'cpp')
|
|
add_project_link_arguments('-fuse-ld=lld', language: 'c')
|
|
message('Using LLD linker (explicitly enabled)')
|
|
elif use_lld.auto() and not lld_available
|
|
message('LLD linker not available; using default linker')
|
|
endif
|
|
# Skip FTS5 runtime check when cross-compiling (can't execute target binaries on host)
|
|
if not meson.is_cross_build()
|
|
fts5_prog = cpp.run(files('meson/fts5_check.cpp'), dependencies: sqlite_dep, name: 'sqlite3 FTS5 check')
|
|
if fts5_prog.returncode() != 0
|
|
msg = 'SQLite3 built without FTS5 support. Enable FTS5 in your package manager or Conan (e.g., -o "sqlite3/*:fts5=True").'
|
|
if require_fts5
|
|
error(msg)
|
|
else
|
|
warning(msg)
|
|
endif
|
|
endif
|
|
else
|
|
message('Cross-compiling: skipping SQLite3 FTS5 runtime check (assuming Conan configured correctly)')
|
|
endif
|
|
|
|
# Boost is a core requirement (e.g., Boost.Asio for daemon communication).
|
|
# Conan's PkgConfigDeps often doesn't emit boost.pc, so prefer CMake config.
|
|
boost_dep = dependency('boost', modules: ['system', 'thread'], method: 'cmake', required: true)
|
|
meson.override_dependency('boost', boost_dep)
|
|
|
|
# --- Version header generation ---
|
|
_override_version = get_option('yams-version')
|
|
_effective_version = _override_version != '' ? _override_version : meson.project_version()
|
|
_build_timestamp = run_command('date', '-u', '+%Y-%m-%dT%H:%M:%SZ', check: true).stdout().strip()
|
|
_git_desc = ''
|
|
_git_cmd = find_program('git', required: false)
|
|
if _git_cmd.found()
|
|
# Capture short git describe (best-effort; ignore errors quietly)
|
|
_r = run_command(_git_cmd, ['describe', '--tags', '--always', '--dirty'], check: false)
|
|
if _r.returncode() == 0
|
|
_git_desc = _r.stdout().strip()
|
|
endif
|
|
endif
|
|
|
|
version_config = configuration_data()
|
|
version_config.set('YAMS_EFFECTIVE_VERSION', _effective_version)
|
|
version_config.set('YAMS_PROJECT_VERSION', meson.project_version())
|
|
version_config.set('YAMS_OVERRIDE_VERSION', _override_version)
|
|
version_config.set('YAMS_BUILD_TIMESTAMP', _build_timestamp)
|
|
version_config.set('YAMS_GIT_DESCRIBE', _git_desc)
|
|
|
|
configure_file(
|
|
output: 'version_generated.h',
|
|
install: true,
|
|
install_dir: get_option('includedir') / 'yams',
|
|
configuration: version_config,
|
|
format: 'cmake', # Simple @VAR@ substitution; header template below.
|
|
input: files('include/yams/version_generated.h.in')
|
|
)
|
|
|
|
yams_build_cli = get_option('build-cli')
|
|
yams_build_mcp = get_option('build-mcp-server')
|
|
yams_enable_tui = get_option('enable-tui')
|
|
|
|
# Install public headers under the compiler's include prefix without duplicating
|
|
# the top-level 'include' directory (was producing prefix/include/include/...).
|
|
install_subdir('include', install_dir: get_option('includedir'), strip_directory: true)
|
|
|
|
# Core libraries (ordered by dependency)
|
|
subdir('src/core')
|
|
subdir('src/crypto')
|
|
subdir('src/chunking')
|
|
subdir('src/compression')
|
|
subdir('src/storage')
|
|
subdir('src/wal')
|
|
subdir('src/manifest')
|
|
subdir('src/integrity')
|
|
subdir('src/config')
|
|
subdir('src/metadata')
|
|
subdir('src/extraction')
|
|
subdir('src/detection')
|
|
subdir('src/content')
|
|
subdir('src/downloader')
|
|
subdir('src/indexing')
|
|
subdir('src/genai')
|
|
subdir('src/vector')
|
|
subdir('src/search')
|
|
subdir('src/api')
|
|
subdir('src/ingest')
|
|
subdir('src/repair')
|
|
subdir('src/daemon/client')
|
|
subdir('src/app/services')
|
|
subdir('src/daemon')
|
|
subdir('src/mobile')
|
|
subdir('src/benchmarks')
|
|
|
|
if get_option('build-mcp-server')
|
|
subdir('src/mcp')
|
|
endif
|
|
|
|
if get_option('build-plugins')
|
|
subdir('plugins')
|
|
endif
|
|
|
|
if get_option('build-cli')
|
|
subdir('src/cli')
|
|
subdir('tools/yams-cli')
|
|
if get_option('build-mcp-server')
|
|
subdir('tools/yams-mcp')
|
|
endif
|
|
endif
|
|
|
|
# Tests (enabled by default in Debug builds)
|
|
_tests_opt = get_option('build-tests')
|
|
_buildtype = get_option('buildtype')
|
|
_tests_enabled = _tests_opt or (_buildtype == 'debug')
|
|
if _tests_enabled
|
|
subdir('tests')
|
|
endif
|
|
|
|
# Determine linker info for summary
|
|
_linker_name = 'default (ld)'
|
|
if use_lld.enabled() and lld_available
|
|
_linker_name = 'lld (forced)'
|
|
elif use_lld.auto() and cpp.get_id() == 'clang' and lld_available
|
|
_linker_name = 'lld (auto with Clang)'
|
|
elif lld_available and cpp.has_link_argument('-fuse-ld=lld')
|
|
# Check if LLD arguments were actually added
|
|
_linker_name = 'lld (available but not used)'
|
|
endif
|
|
|
|
summary({
|
|
'project': meson.project_name(),
|
|
'version': meson.project_version(),
|
|
'cpp_std': get_option('cpp_std'),
|
|
'compiler': cpp.get_id() + ' ' + cpp.version(),
|
|
'linker': _linker_name,
|
|
'build_cli': yams_build_cli,
|
|
'build_mcp_server': yams_build_mcp,
|
|
'enable_tui': yams_enable_tui,
|
|
}, section: 'YAMS Meson configuration', bool_yn: true)
|