Merge branch 'format-meson' into 'main'

Split out libfeedback.h and check more things in CI

See merge request Librem5/feedbackd!158
This commit is contained in:
Guido Günther
2025-03-05 11:40:25 +00:00
20 changed files with 591 additions and 468 deletions
+7 -2
View File
@@ -5,6 +5,9 @@
(c-basic-offset . 2) (c-basic-offset . 2)
(display-fill-column-indicator-column . 100) (display-fill-column-indicator-column . 100)
)) ))
(rust-mode . (
(indent-tabs-mode . nil)
))
(setq auto-mode-alist (cons '("\\.ui$" . nxml-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\\.ui$" . nxml-mode) auto-mode-alist))
(nxml-mode . ( (nxml-mode . (
(indent-tabs-mode . nil) (indent-tabs-mode . nil)
@@ -13,8 +16,10 @@
(css-indent-offset . 2) (css-indent-offset . 2)
)) ))
(js-mode . ( (js-mode . (
(indent-tabs-mode . nil) (indent-tabs-mode . nil)
(js-indent-level . 2) (js-indent-level . 2)
)) ))
(meson-mode . (
(indent-tabs-mode . nil)
))
) )
+8 -7
View File
@@ -4,32 +4,33 @@ root = true
charset = utf-8 charset = utf-8
end_of_line = lf end_of_line = lf
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 100
[meson.build] [meson.build]
indent_size = 2 indent_size = 2
tab_size = 2 tab_size = 2
indent_style = space indent_style = space
[*.{c,h,h.in}] [*.{c,h,c.in,h.in}]
indent_size = 2 indent_size = 2
tab_size = 2 tab_size = 2
indent_style = space indent_style = space
max_line_length = 80
[*.css] [*.css]
indent_size = 2 indent_size = 2
tab_size = 2 tab_size = 2
indent_style = space indent_style = space
[*.xml]
indent_size = 2
tab_size = 2
indent_style = space
[*.json] [*.json]
indent_size = 2 indent_size = 2
tab_size = 2 tab_size = 2
indent_style = space indent_style = space
[*.{xml,ui}]
indent_size = 2
tab_size = 2
indent_style = space
[NEWS] [NEWS]
max_line_length = 72 max_line_length = 72
+18 -6
View File
@@ -1,12 +1,13 @@
---
include: include:
- remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/34039cd573a2df832d465bc9e4c5f543571f5241/templates/ci-fairy.yml' - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/34039cd573a2df832d465bc9e4c5f543571f5241/templates/ci-fairy.yml'
- remote: 'https://gitlab.gnome.org/guidog/meta-phosh/-/raw/f3c92e90dcc0d65322888217429b75dd101bd0d3/ci/phosh-common-jobs.yml' - remote: 'https://gitlab.gnome.org/guidog/meta-phosh/-/raw/0ed15edd821f8afacbf7a9c0f2a6266873289115/ci/phosh-common-jobs.yml'
stages: stages:
- build - build
- test - test
- style-checks - style-checks
- package - package
workflow: workflow:
rules: rules:
@@ -96,12 +97,23 @@ test:native-debian-trixie:
variables: variables:
- $PKG_ONLY == "1" - $PKG_ONLY == "1"
check-consistency:
<<: *tags
stage: test
extends: .phosh-check-consistency
format-check: format-check:
<<: *tags <<: *tags
stage: style-checks stage: style-checks
extends: .phosh-format-check extends: .phosh-format-check
allow_failure: true allow_failure: true
check-meson:
<<: *tags
stage: style-checks
extends:
- .phosh-check-meson
package:deb-debian-trixie:arm64: package:deb-debian-trixie:arm64:
tags: tags:
- librem5:arm64 - librem5:arm64
+102
View File
@@ -0,0 +1,102 @@
#!/bin/bash
#
# Copyright (C) 2024 The Phosh developers
# SPDX-License-Identifier: GPL-3.0-or-later
# Author: Guido Günther <agx@sigxcpu.org>
#
# Check if NEWS, changelog, meson and metainfo are in sync
set -e
COLOR=
if [ -n "${TERM}" ] && [ "${TERM}" != "dumb" ]; then
COLOR=1
fi
function log
{
local level="${1}"
local fd=2
local use_color
shift
if [ -n "${COLOR}" ]; then
[ "${level}" == warn ] || [ "${level}" == error ] || fd=1
! [ -t "${fd}" ] || use_color=1
if [ -n "${use_color}" ]; then
case "${level}" in
warn)
tput setaf 1
;;
error)
tput bold; tput setaf 1
;;
info)
tput setaf 2
;;
esac
fi
fi
echo "$@"
[ -z "${use_color}" ] || tput sgr0
}
if [ -f debian/changelog ]; then
log info "Fetching version from d/changelog"
VERSION=$(dpkg-parsechangelog -SVersion)
elif [ -f meson.build ]; then
log info "Fetching version from meson build file"
VERSION=$(sed -n "s/.*version\s*:\s*'\([0-9].*\)'.*/\1/p" meson.build)
else
log error "E: Don't know how to get version information"
exit 1
fi
echo "I: Checking for '${VERSION}'"
# News
if ! head -1 NEWS | grep -E -qs "\s+${VERSION}\s*$"; then
log error "E: Version ${VERSION} not in NEWS file"
if [[ "${VERSION}" =~ (~|-)dev ]]; then
log info "I: Unreleased development version, no need to check NEWS"
else
exit 1
fi
else
log info "I: Found matching news entry"
fi
# meson.build
MESON_VERSION="${VERSION/\~/.}"
if [ -f meson.build ]; then
if ! grep -qs "version\s*:\s*'$MESON_VERSION'" meson.build; then
log error "E: Version ${MESON_VERSION} not in meson.build file"
exit 1
else
log info "I: Found matching meson version entry"
fi
else
log info "I: no meson project"
fi
# appstream info
METAINFO=$(ls data/*metainfo.xml.in* 2>/dev/null || true)
if [ -z "${METAINFO}" ]; then
log warn "W: No metainfo"
exit 0
fi
if ! grep -qs "$MESON_VERSION\"" "${METAINFO}"; then
log error "E: Version ${MESON_VERSION} not in metainfo ${METAINFO}"
if [[ "${VERSION}" =~ (~|-)(alpha|beta|dev|rc) ]]; then
log info "I: Not a stable release, no metainfo is fine"
else
exit 1
fi
else
log info "I: Found matching metainfo entry"
fi
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
#
# Copyright (C) 2025 The Phosh developers
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Author: Guido Günther <agx@sigxcpu.org>
ret=0
TMPDIR=$(mktemp -d)
# We check files individually so we can print the diff:
while IFS= read -r -d '' file; do
if ! meson format -e --check-only "$file"; then
echo
echo "Meson file '${file}' needs reformat:"
meson format -e "$file" > "${TMPDIR}/meson.build"
diff -u "$file" "${TMPDIR}/meson.build"
rm -f "${TMPDIR}/meson.build"
ret=1
fi
done < <(find . -name '*.build' -print0)
if [ -n "$TMPDIR" ]; then
rmdir "${TMPDIR}"
fi
if [ $ret -ne 0 ]; then
cat <<EOF
To reformat all files run:
meson format -e --recursive --inplace
EOF
fi
exit $ret
+5 -1
View File
@@ -1,11 +1,15 @@
#!/bin/bash #!/bin/bash
#
# Copyright (C) 2024 The Phosh developers
# SPDX-License-Identifier: GPL-3.0-or-later
# Author: Guido Günther <agx@sigxcpu.org>
cd po/ || exit 1 cd po/ || exit 1
# barf on untranslated C files. Seems intltool # barf on untranslated C files. Seems intltool
# can't be told to exit with non-zero exit status # can't be told to exit with non-zero exit status
# in this case # in this case
if intltool-update -m 2>&1 | grep -E -qs '/.*\.(c|ui)'; then if intltool-update -m 2>&1 | grep -E -qs '/.*\.(c|ui|in)'; then
intltool-update -m intltool-update -m
exit 1 exit 1
fi fi
+3
View File
@@ -110,6 +110,8 @@ sp_cmt_cpp_start = add
# #
# Add or remove space between #else or #endif and a trailing comment. # Add or remove space between #else or #endif and a trailing comment.
sp_endif_cmt = add sp_endif_cmt = add
# Offset value that controls the indentation of the body of a multiline #define
pp_multiline_define_body_indent = 2
# Newlines at the start and end of the file. # Newlines at the start and end of the file.
nl_start_of_file = remove nl_start_of_file = remove
@@ -143,3 +145,4 @@ sp_before_sparen = add
# Add spaces around assignments and arithmethic operators # Add spaces around assignments and arithmethic operators
sp_assign = add sp_assign = add
sp_arith = add sp_arith = add
+5
View File
@@ -297,6 +297,11 @@ busctl call --user org.sigxcpu.Feedback /org/sigxcpu/Feedback org.sigxcpu.Feedba
The API is exported as a separate interface `org.sigxcpu.Feedback.Haptic` which is only available when The API is exported as a separate interface `org.sigxcpu.Feedback.Haptic` which is only available when
a haptic device is found. a haptic device is found.
## Getting in Touch
- Issue tracker: <https://source.puri.sm/agx/feedbackd/-/issues>
- Matrix: <https://matrix.to/#/#phosh:sigxcpu.org>
## Documentation ## Documentation
- [Libfeedback API](https://honk.sigxcpu.org/projects/feedbackd/doc/) - [Libfeedback API](https://honk.sigxcpu.org/projects/feedbackd/doc/)
+3 -14
View File
@@ -1,16 +1,5 @@
fbcli_sources = [ fbcli_sources = ['fbcli.c']
'fbcli.c',
]
fbcli_deps = [ fbcli_deps = [libfeedback_dep, gio, gio_unix]
libfeedback_dep,
gio,
gio_unix,
]
executable( executable('fbcli', fbcli_sources, dependencies: fbcli_deps, install: true)
'fbcli',
fbcli_sources,
dependencies: fbcli_deps,
install: true,
)
+66 -70
View File
@@ -4,95 +4,91 @@ namespace = 'LfbGdbus'
generated_dbus_sources = [] generated_dbus_sources = []
dbus_interfaces = [ dbus_interfaces = ['org.sigxcpu.Feedback.xml', 'org.sigxcpu.Feedback.Haptic.xml']
'org.sigxcpu.Feedback.xml',
'org.sigxcpu.Feedback.Haptic.xml',
]
generated_dbus_sources += gnome.gdbus_codegen('lfb-gdbus', generated_dbus_sources += gnome.gdbus_codegen(
sources : dbus_interfaces, 'lfb-gdbus',
object_manager : false, sources: dbus_interfaces,
docbook : 'libfeedback', object_manager: false,
interface_prefix : prefix, docbook: 'libfeedback',
install_header : true, interface_prefix: prefix,
install_dir : join_paths(get_option('includedir'), libname), install_header: true,
namespace : namespace) install_dir: join_paths(get_option('includedir'), libname),
namespace: namespace,
)
dbus_header_dir = meson.current_build_dir() dbus_header_dir = meson.current_build_dir()
dbus_inc = include_directories('.') dbus_inc = include_directories('.')
install_data(dbus_interfaces, install_dir: ifacedir) install_data(dbus_interfaces, install_dir: ifacedir)
schemas = ['org.sigxcpu.feedbackd.gschema.xml'] schemas = ['org.sigxcpu.feedbackd.gschema.xml']
compiled = gnome.compile_schemas( compiled = gnome.compile_schemas(build_by_default: true)
build_by_default: true
)
compile_schemas = find_program('glib-compile-schemas', required: false) compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found() if compile_schemas.found()
test('Validate schema file', compile_schemas, test(
args: ['--strict', '--dry-run', meson.current_source_dir()]) 'Validate schema file',
compile_schemas,
args: ['--strict', '--dry-run', meson.current_source_dir()],
)
endif endif
install_data( install_data(schemas, install_dir: 'share/glib-2.0/schemas')
schemas,
install_dir: 'share/glib-2.0/schemas'
)
if get_option('daemon') if get_option('daemon')
service_data = configuration_data() service_data = configuration_data()
service_data.set('libexecdir', libexecdir) service_data.set('libexecdir', libexecdir)
service_file = 'org.sigxcpu.Feedback.service' service_file = 'org.sigxcpu.Feedback.service'
configure_file( configure_file(
input : service_file + '.in', input: service_file + '.in',
output : service_file, output: service_file,
configuration : service_data, configuration: service_data,
install : true, install: true,
install_dir: servicedir, install_dir: servicedir,
) )
theme_json = ['default.json'] theme_json = ['default.json']
install_data( install_data(theme_json, install_dir: feedbackd_theme_dir)
theme_json,
install_dir: feedbackd_theme_dir,
)
if json_glib_validate.found() if json_glib_validate.found()
jsons = [] jsons = []
foreach theme : theme_json foreach theme : theme_json
jsons += (join_paths(meson.current_source_dir(), theme)) jsons += (join_paths(meson.current_source_dir(), theme))
endforeach endforeach
custom_target('validate-json', custom_target(
build_by_default: true, 'validate-json',
input: theme_json, build_by_default: true,
output: 'json_validate_stamp', input: theme_json,
command: [json_glib_validate.full_path()] + jsons) output: 'json_validate_stamp',
endif command: [json_glib_validate.full_path()] + jsons,
)
if get_option('udev')
install_data('90-feedbackd.rules', install_dir: udevdir)
endif
systemd_user_unit_dir = get_option('systemd_user_unit_dir')
systemd_dep = dependency('systemd', required: false)
if systemd_user_unit_dir == ''
if systemd_dep.found()
systemd_user_unit_dir = systemd_dep.get_variable('systemd_user_unit_dir')
else
systemd_user_unit_dir = prefix / libdir / 'systemd' / 'user'
endif endif
endif
# Alert slider Systemd user service if get_option('udev')
alert_slider_unit = 'fbd-alert-slider.service' install_data('90-feedbackd.rules', install_dir: udevdir)
configure_file( endif
input : alert_slider_unit + '.in',
output : alert_slider_unit,
configuration : service_data,
install : true,
install_dir : systemd_user_unit_dir,
)
endif # daemon systemd_user_unit_dir = get_option('systemd_user_unit_dir')
systemd_dep = dependency('systemd', required: false)
if systemd_user_unit_dir == ''
if systemd_dep.found()
systemd_user_unit_dir = systemd_dep.get_variable('systemd_user_unit_dir')
else
systemd_user_unit_dir = prefix / libdir / 'systemd' / 'user'
endif
endif
# Alert slider Systemd user service
alert_slider_unit = 'fbd-alert-slider.service'
configure_file(
input: alert_slider_unit + '.in',
output: alert_slider_unit,
configuration: service_data,
install: true,
install_dir: systemd_user_unit_dir,
)
endif # daemon
+3 -4
View File
@@ -34,11 +34,11 @@ capping the noisiness for each limit:
1. The currently selected profile provides the (global) upper limit for noisiness 1. The currently selected profile provides the (global) upper limit for noisiness
2. Per application settings impose another upper limit 1. Per application settings impose another upper limit
3. Per event noisiness is the last noisiness constraint 1. Per event noisiness is the last noisiness constraint
4. All feedback consistent with the resulting limit are selected 1. All feedback consistent with the resulting limit are selected
and run to provide the feedback to the user and run to provide the feedback to the user
With the above a feedback theme in YAML format could look like: With the above a feedback theme in YAML format could look like:
@@ -69,7 +69,6 @@ silent:
At the time of writing the theme format is daemon dependent. E.g. feedbackd At the time of writing the theme format is daemon dependent. E.g. feedbackd
uses a format [similar to the above in JSON](https://source.puri.sm/Librem5/feedbackd/-/blob/main/data/default.json) uses a format [similar to the above in JSON](https://source.puri.sm/Librem5/feedbackd/-/blob/main/data/default.json)
# Recommendations # Recommendations
- The silent theme should not produce any audible feedback. This includes - The silent theme should not produce any audible feedback. This includes
+50 -55
View File
@@ -1,78 +1,73 @@
if get_option('gtk_doc') if get_option('gtk_doc')
expand_content_md_files = [ expand_content_md_files = [
'overview.md', 'overview.md',
'build-howto.md', 'build-howto.md',
'initialization.md', 'initialization.md',
'Event-naming-spec-0.0.0.md', 'Event-naming-spec-0.0.0.md',
'Feedback-theme-spec-0.0.0.md', 'Feedback-theme-spec-0.0.0.md',
] ]
toml_data = configuration_data() toml_data = configuration_data()
toml_data.set('VERSION', meson.project_version()) toml_data.set('VERSION', meson.project_version())
libfeedback_toml = configure_file( libfeedback_toml = configure_file(
input: 'libfeedback.toml.in', input: 'libfeedback.toml.in',
output: 'libfeedback.toml', output: 'libfeedback.toml',
configuration: toml_data configuration: toml_data,
) )
dependency('gi-docgen', version: '>= 2021.1', dependency(
fallback: ['gi-docgen', 'dummy_dep'], 'gi-docgen',
native: true, version: '>= 2021.1',
required: get_option('gtk_doc')) fallback: ['gi-docgen', 'dummy_dep'],
native: true,
required: get_option('gtk_doc'),
)
gidocgen = find_program('gi-docgen') gidocgen = find_program('gi-docgen')
docs_dir = datadir / 'doc' docs_dir = datadir / 'doc'
custom_target('libfeedback-doc', custom_target(
input: [ libfeedback_toml, libfeedback_gir[0] ], 'libfeedback-doc',
output: 'libfeedback-0', input: [libfeedback_toml, libfeedback_gir[0]],
command: [ output: 'libfeedback-0',
gidocgen, command: [
'generate', gidocgen,
'--quiet', 'generate',
'--add-include-path=@0@'.format(meson.current_build_dir() / '../src'), '--quiet',
'--config=@INPUT0@', '--fatal-warnings',
'--output-dir=@OUTPUT@', '--add-include-path=@0@'.format(meson.current_build_dir() / '../src'),
'--no-namespace-dir', '--config=@INPUT0@',
'--content-dir=@0@'.format(meson.current_source_dir()), '--output-dir=@OUTPUT@',
'@INPUT1@', '--no-namespace-dir',
], '--content-dir=@0@'.format(meson.current_source_dir()),
depend_files: [ expand_content_md_files ], '@INPUT1@',
build_by_default: true, ],
install: true, depend_files: [expand_content_md_files],
install_dir: docs_dir, build_by_default: true,
) install: true,
install_dir: docs_dir,
)
endif endif
if get_option('man') if get_option('man')
manpages = [ manpages = [['fbcli', 1], ['fbd-theme-validate', 1], ['feedbackd', 8], ['feedback-themes', 5]]
['fbcli', 1],
['fbd-theme-validate', 1],
['feedbackd', 8],
['feedback-themes', 5],
]
rst2man = find_program('rst2man', 'rst2man.py', required: false) rst2man = find_program('rst2man', 'rst2man.py', required: false)
rst2man_flags = [ rst2man_flags = ['--syntax-highlight=none']
'--syntax-highlight=none',
]
foreach manpage: manpages foreach manpage : manpages
man_name = manpage[0] man_name = manpage[0]
man_section = manpage[1] man_section = manpage[1]
custom_target('man-@0@'.format(man_name), custom_target(
'man-@0@'.format(man_name),
input: '@0@.rst'.format(man_name), input: '@0@.rst'.format(man_name),
output: '@0@.@1@'.format(man_name, man_section), output: '@0@.@1@'.format(man_name, man_section),
command: [ command: [rst2man, rst2man_flags, '@INPUT@'],
rst2man,
rst2man_flags,
'@INPUT@',
],
capture: true, capture: true,
install: true, install: true,
install_dir: get_option('mandir') / 'man@0@'.format(man_section), install_dir: get_option('mandir') / 'man@0@'.format(man_section),
@@ -1,9 +1,12 @@
/* /*
* Copyright (C) 2020 Purism SPC * Copyright (C) 2020 Purism SPC
* 2025 The Phosh Developers
*
* SPDX-License-Identifier: LGPL-2.1+ * SPDX-License-Identifier: LGPL-2.1+
*
* Author: Guido Günther <agx@sigxcpu.org> * Author: Guido Günther <agx@sigxcpu.org>
*/ */
#include "libfeedback.h" #include "lfb-main.h"
#include "lfb-gdbus.h" #include "lfb-gdbus.h"
#include "lfb-priv.h" #include "lfb-priv.h"
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2025 The Phosh Developers
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include "lfb-gdbus.h"
#include <glib.h>
#if !defined (__LIBFEEDBACK_H_INSIDE__) && !defined (LIBFEEDBACK_COMPILATION)
#error "Only <libfeedback.h> can be included directly."
#endif
G_BEGIN_DECLS
gboolean lfb_init (const gchar *app_id, GError **error);
void lfb_uninit (void);
void lfb_set_app_id (const char *app_id);
const char *lfb_get_app_id (void);
gboolean lfb_is_initted (void);
void lfb_set_feedback_profile (const char *profile);
const char *lfb_get_feedback_profile (void);
LfbGdbusFeedback *lfb_get_proxy (void);
G_END_DECLS
+2 -9
View File
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2020 Purism SPC * Copyright (C) 2020 Purism SPC
* 2025 The Phosh Developers
* *
* SPDX-License-Identifier: LGPL-2.1+ * SPDX-License-Identifier: LGPL-2.1+
*/ */
@@ -18,14 +19,6 @@ G_BEGIN_DECLS
#include "lfb-enums.h" #include "lfb-enums.h"
#include "lfb-event.h" #include "lfb-event.h"
#include "lfb-gdbus.h" #include "lfb-gdbus.h"
#include "lfb-main.h"
gboolean lfb_init (const gchar *app_id, GError **error);
void lfb_uninit (void);
void lfb_set_app_id (const char *app_id);
const char *lfb_get_app_id (void);
gboolean lfb_is_initted (void);
void lfb_set_feedback_profile (const char *profile);
const char *lfb_get_feedback_profile (void);
LfbGdbusFeedback *lfb_get_proxy (void);
G_END_DECLS G_END_DECLS
+60 -60
View File
@@ -6,38 +6,36 @@ libfeedback_link_args = []
libfeedback_symbols_file = 'libfeedback.syms' libfeedback_symbols_file = 'libfeedback.syms'
# Check linker flags # Check linker flags
ld_version_script_arg = '-Wl,--version-script,@0@'.format(meson.current_source_dir() / libfeedback_symbols_file) ld_version_script_arg = '-Wl,--version-script,@0@'.format(
if cc.links('int main() { return 0; }', args : ld_version_script_arg, name : 'ld_supports_version_script') meson.current_source_dir() / libfeedback_symbols_file,
)
if cc.links(
'int main() { return 0; }',
args: ld_version_script_arg,
name: 'ld_supports_version_script',
)
libfeedback_link_args += [ld_version_script_arg] libfeedback_link_args += [ld_version_script_arg]
endif endif
lfb_enum_headers = files([ lfb_enum_headers = files('lfb-event.h')
'lfb-event.h', lfb_enum_sources = gnome.mkenums_simple(
]) 'lfb-enums',
lfb_enum_sources = gnome.mkenums_simple('lfb-enums', sources: lfb_enum_headers,
sources : lfb_enum_headers, install_header: true,
install_header : true,
install_dir: libfeedback_header_dir, install_dir: libfeedback_header_dir,
) )
libfeedback_headers = [ libfeedback_headers = ['libfeedback.h', 'lfb-event.h', 'lfb-main.h']
'libfeedback.h',
'lfb-event.h',
]
libfeedback_sources = [ libfeedback_sources = [
generated_dbus_sources, generated_dbus_sources,
lfb_enum_sources, lfb_enum_sources,
libfeedback_headers, libfeedback_headers,
'libfeedback.c',
'lfb-event.c', 'lfb-event.c',
'lfb-main.c',
] ]
libfeedback_deps = [ libfeedback_deps = [gio, gio_unix, glib]
gio,
gio_unix,
glib,
]
libfeedback_c_args = [ libfeedback_c_args = [
'-DG_LOG_DOMAIN="libfeedback"', '-DG_LOG_DOMAIN="libfeedback"',
@@ -49,36 +47,36 @@ libtype = 'shared_library'
libfeedback = build_target( libfeedback = build_target(
'feedback-' + apiversion, 'feedback-' + apiversion,
libfeedback_sources, libfeedback_sources,
soversion : 0, soversion: 0,
c_args : libfeedback_c_args, c_args: libfeedback_c_args,
dependencies : libfeedback_deps, dependencies: libfeedback_deps,
link_args : libfeedback_link_args, link_args: libfeedback_link_args,
install : true, install: true,
install_dir : libfeedback_libdir, install_dir: libfeedback_libdir,
target_type : libtype, target_type: libtype,
) )
libfeedback_inc = include_directories('.') libfeedback_inc = include_directories('.')
libfeedback_dep = declare_dependency( libfeedback_dep = declare_dependency(
sources : [generated_dbus_sources, lfb_enum_sources[1]], sources: [generated_dbus_sources, lfb_enum_sources[1]],
link_with : libfeedback, link_with: libfeedback,
dependencies: libfeedback_deps, dependencies: libfeedback_deps,
include_directories : libfeedback_inc, include_directories: libfeedback_inc,
) )
install_headers(libfeedback_headers, subdir : libname) install_headers(libfeedback_headers, subdir: libname)
pkgconfig = import('pkgconfig') pkgconfig = import('pkgconfig')
pkgconfig.generate( pkgconfig.generate(
libraries : [libfeedback], libraries: [libfeedback],
subdirs : libname, subdirs: libname,
version : meson.project_version(), version: meson.project_version(),
name : 'Feedback', name: 'Feedback',
filebase : 'libfeedback-@0@'.format(apiversion), filebase: 'libfeedback-@0@'.format(apiversion),
description : 'GNOME feedback library', description: 'GNOME feedback library',
requires : 'gio-2.0', requires: 'gio-2.0',
install_dir : join_paths(libfeedback_libdir, 'pkgconfig'), install_dir: join_paths(libfeedback_libdir, 'pkgconfig'),
) )
if introspection if introspection
libfeedback_gir_extra_args = [ libfeedback_gir_extra_args = [
@@ -90,29 +88,31 @@ if introspection
'--warn-all', '--warn-all',
] ]
libfeedback_gir = gnome.generate_gir(libfeedback, libfeedback_gir = gnome.generate_gir(
sources : libfeedback_sources, libfeedback,
nsversion : apiversion, sources: libfeedback_sources,
namespace : 'Lfb', nsversion: apiversion,
export_packages : 'libfeedback-@0@'.format(apiversion), namespace: 'Lfb',
symbol_prefix : 'lfb', export_packages: 'libfeedback-@0@'.format(apiversion),
identifier_prefix : 'Lfb', symbol_prefix: 'lfb',
link_with : libfeedback, identifier_prefix: 'Lfb',
includes : ['Gio-2.0'], link_with: libfeedback,
install : true, includes: ['Gio-2.0'],
install_dir_gir : girdir, install: true,
install_dir_typelib : typelibdir, install_dir_gir: girdir,
extra_args : libfeedback_gir_extra_args, install_dir_typelib: typelibdir,
fatal_warnings : true, extra_args: libfeedback_gir_extra_args,
) fatal_warnings: true,
)
if get_option('vapi') if get_option('vapi')
libfeedback_vapi = gnome.generate_vapi('libfeedback-' + apiversion, libfeedback_vapi = gnome.generate_vapi(
sources : libfeedback_gir[0], 'libfeedback-' + apiversion,
packages : ['gio-2.0'], sources: libfeedback_gir[0],
install : true, packages: ['gio-2.0'],
install_dir : vapidir, install: true,
metadata_dirs : [meson.current_source_dir()], install_dir: vapidir,
) metadata_dirs: [meson.current_source_dir()],
)
endif endif
endif endif
+36 -50
View File
@@ -1,33 +1,28 @@
project('feedbackd', 'c', project(
version : '0.7.0', 'feedbackd',
license : 'LGPLv3+', 'c',
meson_version : '>= 1.0.0', version: '0.7.0',
default_options : [ license: 'LGPLv3+',
'warning_level=1', meson_version: '>= 1.0.0',
'buildtype=debugoptimized', default_options: ['warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11'],
'c_std=gnu11',
],
) )
gio = dependency('gio-2.0', version: '>=2.50.0') gio = dependency('gio-2.0', version: '>=2.50.0')
gio_unix = dependency('gio-unix-2.0', version: '>=2.50.0') gio_unix = dependency('gio-unix-2.0', version: '>=2.50.0')
glib = dependency('glib-2.0', version: '>=2.50.0') glib = dependency('glib-2.0', version: '>=2.50.0')
udev = dependency('udev', required: false) udev = dependency('udev', required: false)
if get_option('daemon') if get_option('daemon')
gobject = dependency('gobject-2.0', version: '>=2.50.0') gobject = dependency('gobject-2.0', version: '>=2.50.0')
gmobile = dependency('gmobile', gmobile = dependency(
'gmobile',
version: '>= 0.1.0', version: '>= 0.1.0',
fallback: ['gmobile', 'gmobile_dep'], fallback: ['gmobile', 'gmobile_dep'],
default_options: [ default_options: ['examples=false', 'introspection=false', 'gtk_doc=false', 'tests=false'],
'examples=false', )
'introspection=false', gsound = dependency('gsound')
'gtk_doc=false', gudev = dependency('gudev-1.0', version: '>=232')
'tests=false', json_glib = dependency('json-glib-1.0')
]) systemd_dep = dependency('systemd', required: false)
gsound = dependency('gsound')
gudev = dependency('gudev-1.0', version: '>=232')
json_glib = dependency('json-glib-1.0')
systemd_dep = dependency('systemd', required: false)
endif endif
prefix = get_option('prefix') prefix = get_option('prefix')
@@ -51,10 +46,7 @@ endif
run_data = configuration_data() run_data = configuration_data()
run_data.set('ABS_BUILDDIR', meson.current_build_dir()) run_data.set('ABS_BUILDDIR', meson.current_build_dir())
run_data.set('ABS_SRCDIR', meson.current_source_dir()) run_data.set('ABS_SRCDIR', meson.current_source_dir())
configure_file( configure_file(input: 'run.in', output: 'run', configuration: run_data)
input: 'run.in',
output: 'run',
configuration: run_data)
gnome = import('gnome') gnome = import('gnome')
@@ -103,10 +95,7 @@ global_c_args = [
'-DFBD_VERSION="@0@"'.format(meson.project_version()), '-DFBD_VERSION="@0@"'.format(meson.project_version()),
] ]
add_project_arguments( add_project_arguments(global_c_args + cc.get_supported_arguments(test_c_args), language: 'c')
global_c_args + cc.get_supported_arguments(test_c_args),
language: 'c'
)
introspection_feature = get_option('introspection') introspection_feature = get_option('introspection')
introspection = introspection_feature.enabled() or introspection_feature.auto() introspection = introspection_feature.enabled() or introspection_feature.auto()
@@ -116,10 +105,7 @@ libname = 'libfeedback-' + apiversion
json_glib_validate = find_program('json-glib-validate', required: false) json_glib_validate = find_program('json-glib-validate', required: false)
meson.add_install_script( meson.add_install_script(join_paths('build-aux', 'post_install.py'), datadir)
join_paths('build-aux', 'post_install.py'),
datadir
)
subdir('data') subdir('data')
subdir('libfeedback') subdir('libfeedback')
@@ -129,18 +115,18 @@ subdir('tests')
subdir('doc') subdir('doc')
summary = [ summary = [
'', '',
'---------------', '---------------',
'feedbackd @0@'.format(meson.project_version()), 'feedbackd @0@'.format(meson.project_version()),
'', '',
' Daemon: @0@'.format(get_option('daemon')), ' Daemon: @0@'.format(get_option('daemon')),
' Udev rules: @0@'.format(get_option('udev')), ' Udev rules: @0@'.format(get_option('udev')),
' Documentation: @0@'.format(get_option('gtk_doc')), ' Documentation: @0@'.format(get_option('gtk_doc')),
' Manual pages: @0@'.format(get_option('man')), ' Manual pages: @0@'.format(get_option('man')),
' Introspection: @0@'.format(introspection), ' Introspection: @0@'.format(introspection),
' Vapi: @0@'.format(get_option('vapi')), ' Vapi: @0@'.format(get_option('vapi')),
' Tests: @0@'.format(get_option('tests')), ' Tests: @0@'.format(get_option('tests')),
'---------------', '---------------',
'' '',
] ]
message('\n'.join(summary)) message('\n'.join(summary))
+78 -96
View File
@@ -1,110 +1,92 @@
# Feedback daemon # Feedback daemon
if get_option('daemon') if get_option('daemon')
fbd_enum_headers = files([ fbd_enum_headers = files('fbd-event.h', 'fbd-feedback-led.h', 'fbd-feedback-vibra.h')
'fbd-event.h', fbd_enum_sources = gnome.mkenums_simple('fbd-enums', sources: fbd_enum_headers)
'fbd-feedback-led.h',
'fbd-feedback-vibra.h',
])
fbd_enum_sources = gnome.mkenums_simple('fbd-enums',
sources : fbd_enum_headers)
sources = [ sources = [
generated_dbus_sources, generated_dbus_sources,
fbd_enum_sources, fbd_enum_sources,
'fbd-error.c', 'fbd-error.c',
'fbd-dev-vibra.c', 'fbd-dev-vibra.c',
'fbd-dev-sound.c', 'fbd-dev-sound.c',
'fbd-dev-led.c', 'fbd-dev-led.c',
'fbd-dev-led-flash.c', 'fbd-dev-led-flash.c',
'fbd-dev-led-multicolor.c', 'fbd-dev-led-multicolor.c',
'fbd-dev-led-qcom.c', 'fbd-dev-led-qcom.c',
'fbd-dev-led-qcom-multicolor.c', 'fbd-dev-led-qcom-multicolor.c',
'fbd-dev-leds.c', 'fbd-dev-leds.c',
'fbd-event.c', 'fbd-event.c',
'fbd-feedback-base.c', 'fbd-feedback-base.c',
'fbd-feedback-dummy.c', 'fbd-feedback-dummy.c',
'fbd-feedback-led.c', 'fbd-feedback-led.c',
'fbd-feedback-manager.c', 'fbd-feedback-manager.c',
'fbd-feedback-profile.c', 'fbd-feedback-profile.c',
'fbd-feedback-sound.c', 'fbd-feedback-sound.c',
'fbd-feedback-theme.c', 'fbd-feedback-theme.c',
'fbd-feedback-vibra.c', 'fbd-feedback-vibra.c',
'fbd-feedback-vibra-pattern.c', 'fbd-feedback-vibra-pattern.c',
'fbd-feedback-vibra-periodic.c', 'fbd-feedback-vibra-periodic.c',
'fbd-feedback-vibra-rumble.c', 'fbd-feedback-vibra-rumble.c',
'fbd-haptic-manager.c', 'fbd-haptic-manager.c',
'fbd-theme-expander.c', 'fbd-theme-expander.c',
'fbd-udev.c', 'fbd-udev.c',
] ]
fbd_deps = [ fbd_deps = [gio, gio_unix, glib, gmobile, gobject, gsound, gudev, json_glib]
gio,
gio_unix,
glib,
gmobile,
gobject,
gsound,
gudev,
json_glib,
]
fbd_inc = [ fbd_inc = [include_directories('.'), libfeedback_inc, dbus_inc]
include_directories('.'),
libfeedback_inc,
dbus_inc,
]
fbd_lib = static_library( fbd_lib = static_library(
'fbd', 'fbd',
sources, sources,
include_directories : fbd_inc, include_directories: fbd_inc,
dependencies : fbd_deps, dependencies: fbd_deps,
c_args: '-DGMOBILE_USE_UNSTABLE_API', c_args: '-DGMOBILE_USE_UNSTABLE_API',
install : false, install: false,
) )
fbd_dep = declare_dependency( fbd_dep = declare_dependency(
sources: [generated_dbus_sources, fbd_enum_sources], sources: [generated_dbus_sources, fbd_enum_sources],
include_directories : fbd_inc, include_directories: fbd_inc,
link_with : fbd_lib, link_with: fbd_lib,
dependencies : fbd_deps, dependencies: fbd_deps,
) )
executable( executable(
'feedbackd', 'feedbackd',
sources : ['fbd.c', generated_dbus_sources[1]], sources: ['fbd.c', generated_dbus_sources[1]],
include_directories : fbd_inc, include_directories: fbd_inc,
dependencies : fbd_dep, dependencies: fbd_dep,
install : true, install: true,
install_dir: libexecdir, install_dir: libexecdir,
) )
executable( executable(
'fbd-ledctrl', 'fbd-ledctrl',
sources : ['fbd-ledctrl.c'], sources: ['fbd-ledctrl.c'],
include_directories : fbd_inc, include_directories: fbd_inc,
dependencies : [glib], dependencies: [glib],
install : true, install: true,
install_dir: libexecdir, install_dir: libexecdir,
) )
executable( executable(
'fbd-alert-slider', 'fbd-alert-slider',
sources : ['fbd-alert-slider.c'], sources: ['fbd-alert-slider.c'],
include_directories : fbd_inc, include_directories: fbd_inc,
dependencies : [glib, gio, gio_unix, gudev, libfeedback_dep], dependencies: [glib, gio, gio_unix, gudev, libfeedback_dep],
install : true, install: true,
install_dir: libexecdir, install_dir: libexecdir,
) )
executable( executable(
'fbd-theme-validate', 'fbd-theme-validate',
sources : ['fbd-theme-validate.c'], sources: ['fbd-theme-validate.c'],
include_directories : fbd_inc, include_directories: fbd_inc,
dependencies : fbd_dep, dependencies: fbd_dep,
install : true, install: true,
install_dir: bindir, install_dir: bindir,
) )
endif endif
+74 -88
View File
@@ -1,104 +1,90 @@
if get_option('tests') if get_option('tests')
umockdev_dep = dependency('umockdev-1.0') umockdev_dep = dependency('umockdev-1.0')
add_test_setup ('umockdev', add_test_setup('umockdev', exe_wrapper: 'umockdev-wrapper', is_default: true)
exe_wrapper: 'umockdev-wrapper',
is_default: true
)
test_env = environment() test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
test_env.set('G_DEBUG', 'gc-friendly,fatal-warnings') test_env.set('G_DEBUG', 'gc-friendly,fatal-warnings')
test_env.set('GSETTINGS_BACKEND', 'memory') test_env.set('GSETTINGS_BACKEND', 'memory')
test_env.set('GSETTINGS_SCHEMA_DIR', '@0@/data'.format(meson.project_build_root())) test_env.set('GSETTINGS_SCHEMA_DIR', '@0@/data'.format(meson.project_build_root()))
test_env.set('PYTHONDONTWRITEBYTECODE', 'yes') test_env.set('PYTHONDONTWRITEBYTECODE', 'yes')
test_env.set('MALLOC_CHECK_', '2') test_env.set('MALLOC_CHECK_', '2')
test_env.set('XDG_CONFIG_HOME', meson.current_source_dir() / 'data' / 'user-config') test_env.set('XDG_CONFIG_HOME', meson.current_source_dir() / 'data' / 'user-config')
test_env.set('XDG_CONFIG_DIRS', meson.current_source_dir()) test_env.set('XDG_CONFIG_DIRS', meson.current_source_dir())
# Shared library Unit tests # Shared library Unit tests
test_lfb_cflags = [ test_lfb_cflags = [
'-DTEST_APP_ID="org.sigxcpu.feedbackd_test"',
'-DLIBFEEDBACK_USE_UNSTABLE_API',
'-DTEST_DATA_DIR="@0@"'.format(join_paths(meson.current_source_dir(), 'data')),
]
test_lfb_link_args = [
'-fPIC',
]
test_lfb_deps = [
libfeedback_dep,
glib,
gio_unix,
]
lfb_tests = [
'lfb-event',
]
if get_option ('daemon')
# The integration test needs the daemon
lfb_tests += 'lfb-integration'
subdir('services')
endif
foreach test : lfb_tests
t = executable('test-@0@'.format(test),
['test-@0@.c'.format(test)],
c_args : test_lfb_cflags,
pie : true,
link_args : test_lfb_link_args,
dependencies : test_lfb_deps)
test(test, t, env: test_env)
endforeach
# Daemon Unit tests
if get_option('daemon')
test_env_fbd = test_env
test_env_fbd.set('XDG_DATA_DIRS', meson.current_source_dir() / 'data' / 'xdg-data')
test_fbd_cflags = [
'-DTEST_APP_ID="org.sigxcpu.feedbackd_test"', '-DTEST_APP_ID="org.sigxcpu.feedbackd_test"',
'-DLIBFEEDBACK_USE_UNSTABLE_API',
'-DTEST_DATA_DIR="@0@"'.format(join_paths(meson.current_source_dir(), 'data')), '-DTEST_DATA_DIR="@0@"'.format(join_paths(meson.current_source_dir(), 'data')),
] ]
test_fbd_link_args = [ test_lfb_link_args = ['-fPIC']
'-fPIC',
]
test_fbd_deps = [ test_lfb_deps = [libfeedback_dep, glib, gio_unix]
fbd_dep,
umockdev_dep,
]
# HW independent tests lfb_tests = ['lfb-event']
fbd_tests = [
'fbd-feedback-led',
'fbd-feedback-profile',
'fbd-feedback-theme',
'fbd-event',
'fbd-theme-expander',
'fbd-dev-led',
]
foreach test : fbd_tests if get_option('daemon')
t = executable('test-@0@'.format(test), # The integration test needs the daemon
['test-@0@.c'.format(test), lfb_tests += 'lfb-integration'
'testlib.c', subdir('services')
generated_dbus_sources[1]], endif
c_args : test_fbd_cflags,
pie : true,
link_args : test_fbd_link_args,
include_directories : fbd_inc,
dependencies : test_fbd_deps)
test(test, t, env : test_env_fbd)
endforeach
endif # daemon foreach test : lfb_tests
t = executable(
'test-@0@'.format(test),
['test-@0@.c'.format(test)],
c_args: test_lfb_cflags,
pie: true,
link_args: test_lfb_link_args,
dependencies: test_lfb_deps,
)
test(test, t, env: test_env)
endforeach
# Daemon Unit tests
if get_option('daemon')
test_env_fbd = test_env
test_env_fbd.set('XDG_DATA_DIRS', meson.current_source_dir() / 'data' / 'xdg-data')
test_fbd_cflags = [
'-DTEST_APP_ID="org.sigxcpu.feedbackd_test"',
'-DTEST_DATA_DIR="@0@"'.format(join_paths(meson.current_source_dir(), 'data')),
]
test_fbd_link_args = ['-fPIC']
test_fbd_deps = [fbd_dep, umockdev_dep]
# HW independent tests
fbd_tests = [
'fbd-feedback-led',
'fbd-feedback-profile',
'fbd-feedback-theme',
'fbd-event',
'fbd-theme-expander',
'fbd-dev-led',
]
foreach test : fbd_tests
t = executable(
'test-@0@'.format(test),
['test-@0@.c'.format(test), 'testlib.c', generated_dbus_sources[1]],
c_args: test_fbd_cflags,
pie: true,
link_args: test_fbd_link_args,
include_directories: fbd_inc,
dependencies: test_fbd_deps,
)
test(test, t, env: test_env_fbd)
endforeach
endif # daemon
endif endif
+1 -5
View File
@@ -2,8 +2,4 @@ service_file = 'org.sigxcpu.Feedback.service'
service_data = configuration_data() service_data = configuration_data()
service_data.set('ABS_BUILDDIR', meson.project_build_root()) service_data.set('ABS_BUILDDIR', meson.project_build_root())
configure_file( configure_file(input: service_file + '.in', output: service_file, configuration: service_data)
input : service_file + '.in',
output : service_file,
configuration : service_data
)