4f2c7d4af2
The first version with a genuinely usable feature set (mount/run, volumes, networking, exec/kill/daemonize, and compose orchestration) -- picking a round number for it rather than continuing to increment from the original placeholder 0.0.1. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
99 lines
4.6 KiB
Meson
99 lines
4.6 KiB
Meson
project('slocker-lite', 'cpp',
|
|
version : '0.2.0',
|
|
default_options : ['warning_level=3', 'cpp_std=c++20'])
|
|
|
|
fmt_dep = dependency('fmt')
|
|
catch2_dep = dependency('catch2', required : get_option('enable_tests'))
|
|
yaml_dep = dependency('yaml-0.1')
|
|
archive_dep = dependency('libarchive')
|
|
json_dep = dependency('nlohmann_json')
|
|
spdlog_dep = dependency('spdlog')
|
|
|
|
conf_data = configuration_data()
|
|
conf_data.set_quoted('PACKAGE', meson.project_name())
|
|
conf_data.set_quoted('VERSION', meson.project_version())
|
|
conf_data.set10('ENABLE_TESTS', get_option('enable_tests'))
|
|
|
|
configure_file(output : 'config.h', configuration : conf_data)
|
|
|
|
# TEST_CASE-containing sources -- only buildable/linkable when catch2_dep is
|
|
# actually present, so kept out of the executable's sources entirely (not
|
|
# just "compiled but unused") when enable_tests is off, matching config.h's
|
|
# own ENABLE_TESTS-guarded runtime message in self_test.cpp.
|
|
test_sources = []
|
|
if get_option('enable_tests')
|
|
test_sources = [
|
|
'tests/unit/test_port_forward.cpp',
|
|
'tests/unit/test_env_spec.cpp',
|
|
'tests/unit/test_network_subnet.cpp',
|
|
'tests/unit/test_cli_args.cpp',
|
|
'tests/unit/test_compose_file.cpp',
|
|
'tests/support/fixtures.cpp',
|
|
'tests/integration/test_config_bwrap_chain.cpp',
|
|
'tests/integration/test_rootless_run.cpp',
|
|
'tests/integration/test_root_networking.cpp',
|
|
'tests/integration/test_session_cleanup.cpp',
|
|
'tests/integration/test_network_join_scenarios.cpp',
|
|
'tests/integration/test_compose_orchestrator.cpp',
|
|
]
|
|
endif
|
|
|
|
slocker_lite = executable('slocker-lite',
|
|
['src/main.cpp', 'src/cli_args.cpp', 'src/commands.cpp', 'src/self_test.cpp',
|
|
'src/process.cpp', 'src/oci_image.cpp', 'src/containers_storage.cpp',
|
|
'src/bwrap.cpp', 'src/user_spec.cpp', 'src/config_file.cpp', 'src/volume_mount.cpp',
|
|
'src/pid_file.cpp', 'src/exec_session.cpp', 'src/env_spec.cpp', 'src/daemonize.cpp',
|
|
'src/sandbox_process.cpp', 'src/session_cgroup.cpp', 'src/kill_session.cpp',
|
|
'src/network_subnet.cpp', 'src/persistent_netns.cpp', 'src/network_bridge.cpp',
|
|
'src/network_join.cpp', 'src/port_forward.cpp', 'src/network_tap_relay.cpp',
|
|
'src/network_dns.cpp', 'src/yaml_util.cpp', 'src/compose_file.cpp',
|
|
'src/compose_orchestrator.cpp'] + test_sources,
|
|
include_directories : include_directories('.', 'src', 'tests/support'),
|
|
dependencies : [fmt_dep, catch2_dep, yaml_dep, archive_dep, json_dep, spdlog_dep],
|
|
install : true)
|
|
|
|
# Bind-mounted into the sandbox by -r/--run's --user/--group handling (src/bwrap.cpp),
|
|
# so it must be dependency-free and statically linked to run regardless of what
|
|
# libc/libraries the container image itself has.
|
|
priv_drop_helper = executable('slocker-lite-priv-drop',
|
|
['src/priv_drop_helper.cpp'],
|
|
link_args : ['-static'],
|
|
install : true)
|
|
|
|
# Optional: renders docs/slocker-lite.1.scd into a real man page via scdoc
|
|
# (https://git.sr.ht/~sircmpwn/scdoc). Not a hard build requirement -- if
|
|
# scdoc isn't installed, configuration still succeeds and the man page is
|
|
# just skipped, the same "gracefully degrade when a tool is missing" policy
|
|
# already used elsewhere in this project (e.g. the vendored spdlog fallback).
|
|
scdoc_prog = find_program('scdoc', required : false)
|
|
if scdoc_prog.found()
|
|
custom_target('slocker-lite.1',
|
|
input : 'docs/slocker-lite.1.scd',
|
|
output : 'slocker-lite.1',
|
|
command : scdoc_prog,
|
|
feed : true,
|
|
capture : true,
|
|
install : true,
|
|
install_dir : join_paths(get_option('mandir'), 'man1'))
|
|
else
|
|
message('scdoc not found -- skipping man page generation (install scdoc to build docs/slocker-lite.1.scd into a man page)')
|
|
endif
|
|
|
|
fixture_tar = custom_target('oci-fixture',
|
|
output : 'fixture.tar',
|
|
command : [find_program('python3'), files('tests/gen_fixture.py'), '@OUTPUT@'])
|
|
|
|
test('test', find_program('python3'), args : [files('tests/run_test.py'), slocker_lite, fixture_tar])
|
|
|
|
# Only the categories safe to run unprivileged with no network setup --
|
|
# [integration]~[net] excludes both the rootless-network (tests_rootless_run.cpp)
|
|
# and root (test_root_networking.cpp) tests, matching how this project's
|
|
# self-tests were never part of `meson test` either. Only registered when
|
|
# enable_tests is on -- with it off there's no TEST_CASE compiled in at all
|
|
# (see test_sources above), so -t would just fail cleanly rather than have
|
|
# anything real to run here.
|
|
if get_option('enable_tests')
|
|
test('unit-tests', slocker_lite, args : ['-t', '--', '[unit]'])
|
|
test('integration-tests', slocker_lite, args : ['-t', '--', '[integration]~[net]'])
|
|
endif
|