Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build system and development instructions #800

Merged
merged 6 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,14 @@ sudo apt install \
gstreamer1.0-plugins-ugly \
libgirepository1.0-dev \
libgstreamer1.0-0 \
libgtk-3-dev \
libgtk-4-dev \
libadwaita-1-dev
pip \
python-gi-cairo \
python3-gst-1.0 \
python3-venv

sudo add-apt-repository ppa:apandada1/libhandy-1
sudo apt update
sudo apt install libhandy-1-0 libhandy-1-dev
```
rdbende marked this conversation as resolved.
Show resolved Hide resolved

In case of issues with the `libhandy` installation, please refer to our [GitHub build script](.github/workflows/build.yml) on an alternative source of the library packages.

### UI development

[Glade](https://glade.gnome.org/) is the GUI tool we have been using for generating and managing application [windows and widgets](data/ui/).

## Source code

```bash
Expand Down Expand Up @@ -75,7 +66,7 @@ pip install \
Let's assume you wish to build the application under the `build/` directory and install the binaries under `app/`:

```bash
meson --prefix=$(pwd)/app ./build
meson setup --prefix=$(pwd)/app ./build

ninja -C build install
```
Expand Down Expand Up @@ -103,4 +94,4 @@ Please note, every time you make code changes, you need to execute `ninja -C bui

```bash
python -m pytest
```
```
4 changes: 2 additions & 2 deletions data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif
desktop_file = i18n.merge_file(
input: meson.project_name() + '.desktop',
output: meson.project_name() + '.desktop',
po_dir: join_paths(meson.source_root(), 'po', 'extra'),
po_dir: join_paths(meson.current_source_dir(), 'po', 'extra'),
type: 'desktop',
install: true,
install_dir: join_paths(get_option('datadir'), 'applications')
Expand All @@ -33,7 +33,7 @@ endif
appstream_file = i18n.merge_file(
input: meson.project_name() + '.appdata.xml',
output: meson.project_name() + '.appdata.xml',
po_dir: join_paths(meson.source_root(), 'po', 'extra'),
po_dir: join_paths(meson.current_source_dir(), 'po', 'extra'),
install: true,
install_dir: join_paths(get_option('datadir'), 'metainfo')
)
Expand Down
41 changes: 21 additions & 20 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
project('com.github.geigi.cozy', version: '1.2.1')
project('com.github.geigi.cozy', version: '1.2.1', meson_version: '>= 0.59.0')

python = import('python3')
python = import('python')
i18n = import('i18n')
gnome = import('gnome')

message('Looking for dependencies')
python_bin = python.find_python()
python_bin = python.find_installation('python3')
if not python_bin.found()
error('No valid python3 binary found')
else
message('Found python3 binary')
endif

dependency('glib-2.0')
dependency('libadwaita-1', version: '>= 1.0.0')
dependency('libadwaita-1', version: '>= 1.4.0')

# from https://github.com/AsavarTzeth/pulseeffects/blob/master/meson.build
# Support Debian non-standard python paths
# Fallback to Meson python3 module if command fails
# Fallback to Meson python module if command fails
message('Getting python install path')
py3_purelib = ''
r = run_command(python_bin.path(), '-c', 'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix=""))')
r = run_command(
python_bin.full_path(),
'-c',
'from distutils.sysconfig import get_python_lib; print(get_python_lib(prefix=""))',
check: false,
)

if r.returncode() != 0
py3_purelib = python.sysconfig_path('purelib')
py3_purelib = python_bin.get_path('purelib')
if not py3_purelib.endswith('site-packages')
error('Cannot find python install path')
endif
Expand All @@ -37,7 +43,7 @@ python3_required_modules = ['distro', 'peewee', 'mutagen', 'gi']
foreach p : python3_required_modules
# Source: https://docs.python.org/3/library/importlib.html#checking-if-a-module-can-be-imported
script = 'import importlib.util; import sys; exit(1) if importlib.util.find_spec(\''+ p +'\') is None else exit(0)'
if run_command(python_bin, '-c', script).returncode() != 0
if run_command(python_bin, '-c', script, check: false).returncode() != 0
error('Required Python3 module \'' + p + '\' not found')
endif
endforeach
Expand All @@ -50,10 +56,10 @@ conf.set('PACKAGE_URL', 'https://github.com/geigi/cozy')
conf.set('DATA_DIR', DATA_DIR)
conf.set('LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale'))
conf.set('PYTHON_DIR', python_dir)
conf.set('PYTHON_EXEC_DIR', join_paths(get_option('prefix'), python.sysconfig_path('stdlib')))
conf.set('PYTHON_EXEC_DIR', join_paths(get_option('prefix'), python_bin.get_path('stdlib')))
conf.set('libexecdir', LIBEXEC_DIR)
conf.set('VERSION', meson.project_version())
conf.set('PYTHON', python_bin.path())
conf.set('PYTHON', python_bin.full_path())
conf.set('INSTALLED', 'true')

subdir('data')
Expand Down Expand Up @@ -88,13 +94,8 @@ configure_file(
install_dir: python_dir + '/cozy/report'
)

if meson.version().version_compare('>=0.57.0')
gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
)
else
meson.add_install_script('meson/post_install_legacy.py')
endif

meson.add_install_script('meson/post_install_desktop_database.py')
gnome.post_install(
glib_compile_schemas: true,
gtk_update_icon_cache: true,
update_desktop_database: true,
)
11 changes: 0 additions & 11 deletions meson/post_install_desktop_database.py

This file was deleted.

16 changes: 0 additions & 16 deletions meson/post_install_legacy.py

This file was deleted.

2 changes: 1 addition & 1 deletion po/extra/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
i18n.gettext('extra',
args: [
'--directory=' + meson.source_root(),
'--directory=' + meson.current_source_dir(),
'--from-code=UTF-8'
],
preset: 'glib',
Expand Down
2 changes: 1 addition & 1 deletion po/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
i18n.gettext(meson.project_name(),
args: [
'--directory=' + meson.source_root(),
'--directory=' + meson.current_source_dir(),
'--from-code=UTF-8'
],
preset: 'glib'
Expand Down