Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
223 lines (205 loc) · 9.4 KB
/
Copy pathmeson.build
File metadata and controls
223 lines (205 loc) · 9.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
project('uenv', ['cpp'],
default_options : [
'cpp_std=c++20',
'default_library=static',
'werror=true',
'warning_level=3',
],
version: files('VERSION'),
meson_version: '>=1.4')
version = meson.project_version()
uenv_slurm_plugin = get_option('slurm_plugin')
uenv_cli = get_option('cli')
uenv_squashfs_mount = get_option('squashfs_mount')
conf_data = configuration_data()
add_global_arguments('-Wno-missing-field-initializers', language : 'cpp')
# fixes warnings generated when building curl and sqlite3
# that started to occur with gcc 15.2.1
# Note that we only apply this to C, so it should not be applied to the C++ code
add_global_arguments('-Wno-discarded-qualifiers', language : 'c')
# configure the dependencies
# use meson wrap to provide the dependencies, because the 'default_library=static' option
# will be propogated to each dependency, for a statically linked executable.
cli11_dep = subproject('cli11', default_options: ['werror=false', 'warning_level=0']).get_variable('CLI11_dep')
fmt_dep = subproject('fmt', default_options: ['werror=false', 'warning_level=0']).get_variable('fmt_dep')
json_dep = subproject('nlohmann_json', default_options: ['werror=false', 'warning_level=0']).get_variable('nlohmann_json_dep')
spdlog_dep = subproject('spdlog', default_options: ['werror=false', 'warning_level=0','std_format=disabled','external_fmt=enabled']).get_variable('spdlog_dep')
sqlite3_dep = subproject('sqlite3', default_options: ['werror=false', 'warning_level=0']).get_variable('sqlite3_dep')
toml_base = subproject('tomlplusplus', default_options: ['werror=false', 'warning_level=0', 'build_lib=false']).get_variable('tomlplusplus_dep')
toml_dep = declare_dependency(
dependencies: toml_base,
compile_args: ['-DTOML_EXCEPTIONS=0', '-DTOML_HEADER_ONLY=0'],
)
# zlib: needed for gzip handling in the native OCI registry client
# Built before curl so override_dependency('zlib') is in place for when curl is configured
zlib_dep = subproject('zlib', default_options: ['warning_level=0', 'werror=false', 'default_library=static']).get_variable('zlib_dep')
# openssl: the TLS backend for curl, and the SHA-256 implementation used by
# src/util/sha.cpp - libcrypto's is an order of magnitude faster than a portable
# C one, which matters because hashing bounds image push and pull.
# Configured before curl so override_dependency('openssl') is in place for when
# curl is configured; curl consumes it by name, we take libcrypto by hand.
# Unlike every other subproject this one is not a meson build - it drives
# OpenSSL's own Configure + make (see subprojects/packagefiles/openssl/), so
# warning_level/werror/default_library would have nothing to apply to.
libcrypto_dep = subproject('openssl').get_variable('libcrypto_dep')
# Every curl feature is pinned explicitly. Almost all of them default to 'auto',
# which means they switch on wherever the build host happens to have the dev
# package installed - the binary we ship would then have runtime dependencies
# that vary with the machine it was built on. Nothing here is left to chance.
subproject('curl',
default_options: [
'werror=false', 'warning_level=0',
'tests=disabled', 'unittests=disabled', 'tool=disabled',
'libuv=disabled', # only used by curl's own tests, and only in debug builds
# TLS, via the vendored static openssl configured above
'ssl=enabled', 'openssl=enabled',
# the three features uenv actually relies on:
# ipv6 - registries that only publish a AAAA record
# asynchdns - threaded resolver, so the connect/total timeouts can
# interrupt a hung DNS lookup
# libz - Content-Encoding: gzip, via the vendored static zlib
'ipv6=enabled', 'asynchdns=enabled', 'libz=enabled',
# everything else off. uenv speaks HTTP/1.1 over http(s) and nothing
# else - see CURLOPT_PROTOCOLS_STR in src/util/curl.cpp - and
# authenticates with Basic plus its own Authorization: Bearer header,
# so none of the protocol, auth or name-resolution extras below are
# reachable at runtime. They can be turned back on individually if a
# feature ever needs one.
'http2=disabled', 'brotli=disabled', 'zstd=disabled',
'psl=disabled', 'idn=disabled', 'gsasl=disabled',
'gss-api=disabled', 'ntlm=disabled', 'tls-srp=disabled',
'alt-svc=disabled', 'hsts=disabled', 'unixsockets=disabled',
'ssh=disabled', 'ldap=disabled', 'ldaps=disabled', 'rtmp=disabled',
'dict=disabled', 'ftp=disabled', 'gopher=disabled', 'imap=disabled',
'mqtt=disabled', 'pop3=disabled', 'rtsp=disabled', 'smb=disabled',
'smtp=disabled', 'telnet=disabled', 'tftp=disabled',
])
curl_dep = dependency('libcurl', required: true)
# libarchive: used by the native OCI registry client to pack/unpack directories
libarchive_dep = subproject('libarchive',
default_options: [
'warning_level=0', 'werror=false', 'default_library=static',
'progs=[]', 'tests=disabled', 'regex=disabled',
'zlib=enabled',
'bz2lib=disabled', 'libb2=disabled', 'lz4=disabled', 'zstd=disabled',
'lzma=disabled', 'lzo2=disabled', 'iconv=disabled', 'cng=disabled',
'openssl=disabled', 'xml2=disabled', 'expat=disabled',
'xattr=disabled', 'acl=disabled',
]).get_variable('libarchive_dep')
barkeep_dep = declare_dependency(
include_directories: 'extern/barkeep',
compile_args: ['-DBARKEEP_ENABLE_FMT_FORMAT'],
)
libmount_dep = dependency('mount')
# the lib dependency is all of the common funtionality shared between the CLI
# and the slurm plugin.
lib_src = [
'src/site/site.cpp',
'src/uenv/elastic.cpp',
'src/uenv/env.cpp',
'src/uenv/log.cpp',
'src/uenv/meta.cpp',
'src/uenv/mount.cpp',
'src/oci/auth.cpp',
'src/oci/client.cpp',
'src/oci/digest.cpp',
'src/oci/manifest.cpp',
'src/oci/parse.cpp',
'src/oci/pull.cpp',
'src/oci/push.cpp',
'src/oci/reference.cpp',
'src/oci/tag.cpp',
'src/oci/types.cpp',
'src/oci/util.cpp',
'src/uenv/parse.cpp',
'src/uenv/print.cpp',
'src/uenv/repository.cpp',
'src/uenv/settings.cpp',
'src/uenv/telemetry.cpp',
'src/uenv/uenv.cpp',
'src/util/archive.cpp',
'src/util/color.cpp',
'src/util/curl.cpp',
'src/util/envvars.cpp',
'src/util/fs.cpp',
'src/util/lex.cpp',
'src/util/lustre.cpp',
'src/util/parse.cpp',
'src/util/semver.cpp',
'src/util/sha.cpp',
'src/util/shell.cpp',
'src/util/signal.cpp',
'src/util/strings.cpp',
'src/util/subprocess.cpp',
'src/util/toml.cpp',
'src/util/url.cpp',
]
lib_inc = include_directories('src')
lib_uenv = static_library(
'uenv',
lib_src,
include_directories: lib_inc,
dependencies: [curl_dep, zlib_dep, libcrypto_dep, libarchive_dep, sqlite3_dep, fmt_dep, spdlog_dep, json_dep, barkeep_dep, toml_dep],
)
uenv_dep = declare_dependency(
link_with: lib_uenv,
dependencies: [curl_dep, zlib_dep, libcrypto_dep, libarchive_dep, sqlite3_dep, fmt_dep, spdlog_dep, json_dep, barkeep_dep, libmount_dep, toml_dep],
include_directories: lib_inc
)
subdir('src/uenv')
# the uenv executable
if uenv_cli
cli_src = [
'src/cli/add_remove.cpp',
'src/cli/config.cpp',
'src/cli/copy.cpp',
'src/cli/delete.cpp',
'src/cli/find.cpp',
'src/cli/help.cpp',
'src/cli/image.cpp',
'src/cli/inspect.cpp',
'src/cli/ls.cpp',
'src/cli/pull.cpp',
'src/cli/push.cpp',
'src/cli/repo.cpp',
'src/cli/run.cpp',
'src/cli/start.cpp',
'src/cli/status.cpp',
'src/cli/uenv.cpp',
'src/cli/util.cpp',
'src/cli/build.cpp',
'src/cli/completion.cpp',
]
xxd = find_program('xxd', required : true)
completion_bash_dep = custom_target(
'completion-bash-dep',
input: 'src/cli/completion.bash',
output: 'completion.bash.h',
command: [xxd, '-i', '-n', 'completion_bash_main', '@INPUT@', '@OUTPUT@'])
cli = executable('uenv',
sources: cli_src + completion_bash_dep,
dependencies: [uenv_dep, sqlite3_dep, fmt_dep, spdlog_dep, cli11_dep, barkeep_dep],
c_args: [
'-DVERSION="@0@"'.format(version),
],
install: true)
meson.add_install_script('./meson-scripts/install-bash-completion.sh')
endif
if uenv_slurm_plugin
slurm_version = get_option('slurm_version')
subdir('src/slurm')
endif
if uenv_squashfs_mount
squashfs_mount = executable('squashfs-mount',
sources: ['src/squashfs-mount/squashfs-mount.cpp'],
dependencies: [uenv_dep, fmt_dep, cli11_dep],
c_args: [
'-DVERSION="@0@"'.format(version),
],
install_mode: ['rwsr-xr-x', 'root', 'root'],
install: true)
endif
if get_option('tests').enabled()
catch_dep = subproject('catch2', default_options: ['werror=false', 'warning_level=0', 'tests=false']).get_variable('catch2_with_main_dep')
subdir('test')
endif