From 12c6b45df222cb6e581dd697096d9237a34f43e6 Mon Sep 17 00:00:00 2001 From: tfuxu <73042332+tfuxu@users.noreply.github.com> Date: Fri, 12 Aug 2022 23:17:49 +0200 Subject: [PATCH 1/2] feat: allow users to compile builds using meson and ninja, and add a convenience shell script --- local.sh | 21 +++++++++++++++++++++ src/adwcustomizer.in | 19 +++++++++++++++---- src/meson.build | 7 +++++++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100755 local.sh diff --git a/local.sh b/local.sh new file mode 100755 index 00000000..84f335af --- /dev/null +++ b/local.sh @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +read -p "Do you want to install Python requirements? (yes, no): " answer + +if [[ "$answer" == "yes" ]]; then + pip3 install --user -r requirements.txt + pip3 install $(pwd)/monet/material_color_utilities_python-0.1.0-py3-none-any.whl +elif [[ "$answer" == "no" ]]; then + echo "Skipping requirements installation" +fi + +echo "Cleaning builddir directory" +rm -r builddir + +echo "Rebuilding" +meson builddir +meson configure builddir -Dprefix="$(pwd)/builddir/testdir" +ninja -C builddir install + +echo "Running" +ninja -C builddir run \ No newline at end of file diff --git a/src/adwcustomizer.in b/src/adwcustomizer.in index 7f88fc5f..e32c71fa 100755 --- a/src/adwcustomizer.in +++ b/src/adwcustomizer.in @@ -24,15 +24,25 @@ import signal import locale import gettext -VERSION = '@VERSION@' pkgdatadir = '@pkgdatadir@' localedir = '@localedir@' +version = '@VERSION@' + +builddir = os.environ.get('MESON_BUILD_ROOT') + +if builddir: + sys.dont_write_bytecode = True + sys.path.insert(1, os.environ['MESON_SOURCE_ROOT']) + data_dir = os.path.join(builddir, '@DATA_DIR@') + os.putenv('XDG_DATA_DIRS', '%s:%s' % (data_dir, os.getenv('XDG_DATA_DIRS', '/usr/local/share/:/usr/share/'))) sys.path.insert(1, pkgdatadir) signal.signal(signal.SIGINT, signal.SIG_DFL) +gettext.install('adwcustomizer', localedir) + locale.bindtextdomain('adwcustomizer', localedir) locale.textdomain('adwcustomizer') -gettext.install('adwcustomizer', localedir) + if __name__ == '__main__': import gi @@ -43,8 +53,9 @@ if __name__ == '__main__': gi.require_version('XdpGtk4', '1.0') from gi.repository import Gio - resource = Gio.Resource.load(os.path.join(pkgdatadir, 'adwcustomizer.gresource')) + resource = Gio.Resource.load( + os.path.join(pkgdatadir, 'adwcustomizer.gresource')) resource._register() from adwcustomizer import main - sys.exit(main.main(VERSION)) + sys.exit(main.main(version)) diff --git a/src/meson.build b/src/meson.build index d3e13293..c780de6a 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,6 +29,7 @@ python = import('python') conf = configuration_data() conf.set('PYTHON', python.find_installation('python3').full_path()) conf.set('VERSION', meson.project_version()) +conf.set('DATA_DIR', join_paths(get_option('prefix'), get_option('datadir'))) conf.set('localedir', join_paths(get_option('prefix'), get_option('localedir'))) conf.set('pkgdatadir', pkgdatadir) @@ -51,6 +52,12 @@ configure_file( }), ) +launcher = join_paths(meson.project_build_root(), 'src', meson.project_name()) + +run_target('run', + command: [launcher] +) + adwcustomizer_sources = [ '__init__.py', 'settings_schema.py', From 366f9fec3744d7bb6478a85f367411b14a12922b Mon Sep 17 00:00:00 2001 From: tfuxu <73042332+tfuxu@users.noreply.github.com> Date: Fri, 12 Aug 2022 23:18:24 +0200 Subject: [PATCH 2/2] readme: add new sections about other building processes * add version check for dependecies in meson.build --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- meson.build | 10 +++++----- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index babc0661..d5c57c36 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,46 @@ Adwaita Manager (AdwCustomizer) is a tool for customizing Libadwaita application ## Building and Installing -See `next` branch for UI rework and latest commit. +**[NOTE]** See `next` branch for UI rework and latest commits. + +## Requirements: +- Python 3 `python` +- PyGObject `python-gobject` +- Blueprint [blueprint-compiler](https://jwestman.pages.gitlab.gnome.org/blueprint-compiler/setup.html) +- GTK4 `gtk4` +- libadwaita (>= 1.2.alpha) `libadwaita` +- Meson `meson` +- Ninja `ninja` + +## Building from source: + +Install required Python libraries: +```sh +pip install -r requirements.txt +pip3 install $(pwd)/monet/material_color_utilities_python-0.1.0-py3-none-any.whl +``` + +### Global installation: +```sh +git clone https://github.com/AdwCustomizerTeam/AdwCustomizer.git +cd AdwCustomizer +meson builddir --prefix=/usr/local +sudo ninja -C builddir install +``` + +### Local build (for testing and development purposes): +```sh +git clone https://github.com/AdwCustomizerTeam/AdwCustomizer.git +cd AdwCustomizer +meson builddir +meson configure builddir -Dprefix="$(pwd)/builddir/testdir" +ninja -C builddir install +ninja -C builddir run +``` + +**[NOTE]** During testing and developement, as a convenience, you can use the `local.sh` script to quickly rebuild local builds. + +### Building using flatpak-builder: 1. Open Terminal 2. Run `git clone https://github.com/AdwCustomizerTeam/AdwCustomizer.git && cd AdwCustomizer` diff --git a/meson.build b/meson.build index e22a4fc1..a68a7c93 100644 --- a/meson.build +++ b/meson.build @@ -6,14 +6,14 @@ project('adwcustomizer', ], ) -dependency('glib-2.0') -dependency('pygobject-3.0') -dependency('libadwaita-1') - i18n = import('i18n') - gnome = import('gnome') +dependency('glib-2.0') +dependency('gtk4', version: '>= 4.5.0') +dependency('libadwaita-1', version: '>= 1.2.alpha') +dependency('pygobject-3.0', version: '>= 3.42.0') + subdir('data') subdir('src') subdir('po')