|
| 1 | +project( |
| 2 | + 'python-systemd', |
| 3 | + 'c', |
| 4 | + version: '236', |
| 5 | + license: 'LGPL-2.1-or-later', |
| 6 | + default_options: ['warning_level=2', 'c_std=c99'], |
| 7 | +) |
| 8 | + |
| 9 | +# Dependencies |
| 10 | +python = import('python').find_installation('python3', pure: false) |
| 11 | +python_dep = python.dependency() |
| 12 | + |
| 13 | +# Try to find libsystemd |
| 14 | +foreach name : [ |
| 15 | + 'libsystemd', |
| 16 | + 'libsystemd-journal', |
| 17 | + 'libsystemd-daemon', |
| 18 | + 'libsystemd-id128', |
| 19 | + 'libsystemd-login', |
| 20 | +] |
| 21 | + libsystemd_dep = dependency(name, required: false) |
| 22 | + if libsystemd_dep.found() |
| 23 | + break |
| 24 | + endif |
| 25 | +endforeach |
| 26 | + |
| 27 | +# Common compile arguments matching setup.py |
| 28 | +common_c_args = [ |
| 29 | + '-std=c99', |
| 30 | + '-Werror=implicit-function-declaration', |
| 31 | + '-DPACKAGE_VERSION="' + meson.project_version() + '"', |
| 32 | + '-DLIBSYSTEMD_VERSION=' + libsystemd_dep.version(), |
| 33 | +] |
| 34 | + |
| 35 | +# Build _journal extension module |
| 36 | +python.extension_module( |
| 37 | + '_journal', |
| 38 | + ['systemd/_journal.c', 'systemd/pyutil.c'], |
| 39 | + dependencies: [libsystemd_dep], |
| 40 | + c_args: common_c_args, |
| 41 | + install: true, |
| 42 | + subdir: 'systemd', |
| 43 | +) |
| 44 | + |
| 45 | +# Build _reader extension module |
| 46 | +python.extension_module( |
| 47 | + '_reader', |
| 48 | + ['systemd/_reader.c', 'systemd/pyutil.c', 'systemd/strv.c'], |
| 49 | + dependencies: [libsystemd_dep], |
| 50 | + c_args: common_c_args, |
| 51 | + install: true, |
| 52 | + subdir: 'systemd', |
| 53 | +) |
| 54 | + |
| 55 | +# Build _daemon extension module |
| 56 | +python.extension_module( |
| 57 | + '_daemon', |
| 58 | + ['systemd/_daemon.c', 'systemd/pyutil.c', 'systemd/util.c'], |
| 59 | + dependencies: [libsystemd_dep], |
| 60 | + c_args: common_c_args, |
| 61 | + install: true, |
| 62 | + subdir: 'systemd', |
| 63 | +) |
| 64 | + |
| 65 | +# Build id128 extension module |
| 66 | +python.extension_module( |
| 67 | + 'id128', |
| 68 | + ['systemd/id128.c', 'systemd/pyutil.c'], |
| 69 | + dependencies: [libsystemd_dep], |
| 70 | + c_args: common_c_args, |
| 71 | + install: true, |
| 72 | + subdir: 'systemd', |
| 73 | +) |
| 74 | + |
| 75 | +# Build login extension module |
| 76 | +python.extension_module( |
| 77 | + 'login', |
| 78 | + ['systemd/login.c', 'systemd/pyutil.c', 'systemd/strv.c'], |
| 79 | + dependencies: [libsystemd_dep], |
| 80 | + c_args: common_c_args, |
| 81 | + install: true, |
| 82 | + subdir: 'systemd', |
| 83 | +) |
| 84 | + |
| 85 | +# Install Python modules (matching py_modules in setup.py) |
| 86 | +python.install_sources( |
| 87 | + 'systemd/__init__.py', |
| 88 | + 'systemd/journal.py', |
| 89 | + 'systemd/daemon.py', |
| 90 | + subdir: 'systemd', |
| 91 | +) |
| 92 | + |
| 93 | +# Install test modules |
| 94 | +python.install_sources( |
| 95 | + 'systemd/test/test_daemon.py', |
| 96 | + 'systemd/test/test_journal.py', |
| 97 | + 'systemd/test/test_login.py', |
| 98 | + 'systemd/test/test_id128.py', |
| 99 | + subdir: 'systemd/test', |
| 100 | +) |
0 commit comments