diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6afc5db1f..58c54da81 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -86,14 +86,17 @@ jobs: run: cargo clippy -p oo7 --no-default-features --features tracing,tokio,openssl_crypto -- -D warnings meson: - name: Meson (portal) + name: Meson runs-on: ubuntu-latest container: fedora:latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - name: Install dependencies - run: dnf install -y git meson gcc # no idea why the hell meson with rust project requires gcc - - name: Build + run: dnf install -y git meson gcc systemd + - name: Build (portal) working-directory: ./portal run: meson setup ./ _build --prefix /usr && ninja -C _build + - name: Build (server) + working-directory: ./server + run: meson setup ./ _build --prefix /usr && ninja -C _build diff --git a/server/data/meson.build b/server/data/meson.build new file mode 100644 index 000000000..9bf7cc306 --- /dev/null +++ b/server/data/meson.build @@ -0,0 +1,15 @@ +if systemduserunitdir != '' + configure_file( + input: 'oo7-daemon.service.in', + output: 'oo7-daemon.service', + configuration: libexecdir_conf, + install_dir: systemduserunitdir, + ) +endif + +configure_file( + input: 'org.freedesktop.secrets.service.in', + output: 'org.freedesktop.secrets.service', + configuration: libexecdir_conf, + install_dir: dbus_service_dir, +) diff --git a/server/data/oo7-daemon.service.in b/server/data/oo7-daemon.service.in new file mode 100644 index 000000000..f78a3a023 --- /dev/null +++ b/server/data/oo7-daemon.service.in @@ -0,0 +1,9 @@ +[Unit] +Description=Secret service (oo7 implementation) +[Service] +Type=simple +StandardError=journal +ExecStart=@libexecdir@/@binary@ +Restart=on-failure +[Install] +WantedBy=default.target diff --git a/server/data/org.freedesktop.secrets.service.in b/server/data/org.freedesktop.secrets.service.in new file mode 100644 index 000000000..6e1a19309 --- /dev/null +++ b/server/data/org.freedesktop.secrets.service.in @@ -0,0 +1,3 @@ +[D-BUS Service] +Name=org.freedesktop.secrets +Exec=@libexecdir@/@binary@ diff --git a/server/meson.build b/server/meson.build new file mode 100644 index 000000000..f5ce9ff9a --- /dev/null +++ b/server/meson.build @@ -0,0 +1,39 @@ +project( + 'oo7-daemon', + 'rust', + version: '0.1.0', + meson_version: '>= 0.59.0', +) + +is_devel = get_option('profile') == 'development' + +prefix = get_option('prefix') +datadir = get_option('datadir') +dbus_service_dir = get_option('dbus_service_dir') +libexecdir = get_option('libexecdir') + +build_systemd_service = get_option('systemd') +systemduserunitdir = get_option('systemduserunitdir') +if systemduserunitdir == '' + systemd = dependency('systemd', version: '>= 242', required: build_systemd_service) + if build_systemd_service.allowed() and systemd.found() + systemduserunitdir = systemd.get_variable( + pkgconfig: 'systemduserunitdir', + pkgconfig_define: ['prefix', prefix] + ) + endif +endif + +libexecdir_conf = configuration_data() +libexecdir_conf.set('binary', meson.project_name()) +libexecdir_conf.set('libexecdir', prefix / libexecdir) + +summary({ + 'prefix': prefix, + 'datadir': datadir, + 'libexecdir': libexecdir, + 'dbus_service_dir': dbus_service_dir, +}) + +subdir('data') +subdir('src') diff --git a/server/meson_options.txt b/server/meson_options.txt new file mode 100644 index 000000000..d5b481060 --- /dev/null +++ b/server/meson_options.txt @@ -0,0 +1,26 @@ +option('dbus_service_dir', + type: 'string', + description: 'Directory for D-Bus service files' +) + +option('systemd', + type: 'feature', + value: 'auto', + description: 'Enable systemd support' +) + +option('systemduserunitdir', + type: 'string', + description: 'Directory for systemd user service files' +) + +option ( + 'profile', + type: 'combo', + choices: [ + 'default', + 'development' + ], + value: 'default', + description: 'The build profile. One of "default" or "development".' +) diff --git a/server/src/meson.build b/server/src/meson.build new file mode 100644 index 000000000..a7cec560b --- /dev/null +++ b/server/src/meson.build @@ -0,0 +1,28 @@ +cargo = find_program('cargo') + +cargo_options = [] +cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] +if is_devel + rust_target = 'debug' + message('Building in debug mode') +else + cargo_options += [ '--release' ] + rust_target = 'release' + message('Building in release mode') +endif + +cargo_build = custom_target( + 'cargo-build', + build_by_default: true, + build_always_stale: true, + output: meson.project_name(), + console: true, + install: true, + install_dir: libexecdir, + command: [ + cargo, 'build', + cargo_options, + '&&', + 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', + ] +)