mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
Currently, when we want to add unit tests for code that is compiled into an executable, we either compile the code at least twice (once for the executable, and once for each test that uses it) or we create a static library which is then used by both the executable and all the tests. Both of these options are not ideal, compiling source files more than once slows down the build for no reason and creating the intermediate static libraries takes a lot of boilerplate. Instead, let's use the extract_objects() method that meson exposes on build targets. This allows us to extract the objects corresponding to specific source files and use them in other executables. Because we define all executables upfront into a dictionary, we integrate this into the dictionary approach by adding two new fields: - 'extract' takes a list of files for which objects should be extracted. The extracted objects are stored in a dict keyed by the executable name from which they were extracted. - 'objects' takes the name of an executable from which the extracted objects should be added to the current executable. One side effect of this approach is that we can't build test executables anymore without building the main executable, so we stop building test executables unless we're also building the main executable. This allows us to switch to using subdir_done() in all of these subdirectories to skip parsing them if the corresponding component is disabled. These changes get me down from 2439 => 2403 ninja targets on a full rebuild from scratch.
115 lines
3.2 KiB
Meson
115 lines
3.2 KiB
Meson
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
if conf.get('ENABLE_IMPORTD') != 1
|
|
subdir_done()
|
|
endif
|
|
|
|
systemd_importd_sources = files(
|
|
'importd.c',
|
|
)
|
|
systemd_importd_extract_sources = files(
|
|
'import-common.c',
|
|
'import-compress.c',
|
|
'qcow2-util.c',
|
|
)
|
|
|
|
systemd_pull_sources = files(
|
|
'pull.c',
|
|
'pull-raw.c',
|
|
'pull-tar.c',
|
|
'pull-job.c',
|
|
'pull-common.c',
|
|
'curl-util.c',
|
|
)
|
|
|
|
systemd_import_sources = files(
|
|
'import.c',
|
|
'import-raw.c',
|
|
'import-tar.c',
|
|
)
|
|
|
|
systemd_import_fs_sources = files(
|
|
'import-fs.c',
|
|
)
|
|
|
|
systemd_export_sources = files(
|
|
'export.c',
|
|
'export-tar.c',
|
|
'export-raw.c',
|
|
)
|
|
|
|
common_deps = [
|
|
libbzip2,
|
|
libcurl,
|
|
libxz,
|
|
libz,
|
|
libzstd,
|
|
]
|
|
|
|
executables += [
|
|
libexec_template + {
|
|
'name' : 'systemd-importd',
|
|
'dbus' : true,
|
|
'sources' : [systemd_importd_sources, systemd_importd_extract_sources],
|
|
'extract' : systemd_importd_extract_sources,
|
|
'dependencies' : [common_deps, threads],
|
|
},
|
|
libexec_template + {
|
|
'name' : 'systemd-pull',
|
|
'public' : true,
|
|
'sources' : systemd_pull_sources,
|
|
'objects' : ['systemd-importd'],
|
|
'dependencies' : common_deps + [
|
|
libopenssl,
|
|
],
|
|
},
|
|
libexec_template + {
|
|
'name' : 'systemd-import',
|
|
'public' : true,
|
|
'sources' : systemd_import_sources,
|
|
'objects' : ['systemd-importd'],
|
|
'dependencies' : common_deps,
|
|
},
|
|
libexec_template + {
|
|
'name' : 'systemd-import-fs',
|
|
'public' : true,
|
|
'sources' : systemd_import_fs_sources,
|
|
'objects' : ['systemd-importd'],
|
|
'dependencies' : common_deps,
|
|
},
|
|
libexec_template + {
|
|
'name' : 'systemd-export',
|
|
'public' : true,
|
|
'sources' : systemd_export_sources,
|
|
'objects' : ['systemd-importd'],
|
|
'dependencies' : common_deps,
|
|
},
|
|
executable_template + {
|
|
'name' : 'importctl',
|
|
'public' : true,
|
|
'sources' : files('importctl.c'),
|
|
},
|
|
generator_template + {
|
|
'name' : 'systemd-import-generator',
|
|
'sources' : files('import-generator.c'),
|
|
},
|
|
test_template + {
|
|
'sources' : files('test-qcow2.c'),
|
|
'objects' : ['systemd-importd'],
|
|
'dependencies' : common_deps,
|
|
'conditions' : ['HAVE_ZLIB'],
|
|
'type' : 'manual',
|
|
},
|
|
]
|
|
|
|
install_data('org.freedesktop.import1.conf',
|
|
install_dir : dbuspolicydir)
|
|
install_data('org.freedesktop.import1.service',
|
|
install_dir : dbussystemservicedir)
|
|
install_data('org.freedesktop.import1.policy',
|
|
install_dir : polkitpolicydir)
|
|
|
|
install_data('import-pubring.gpg',
|
|
install_dir : libexecdir)
|
|
# TODO: shouldn't this be in pkgdatadir?
|