meson support (#173)

* Move AppConsole.vala and AppGtk.vala to src directory

* Rename po files

Strip "timeshift-" prefix. This is required for the future meson
support.

* Add initial meson support

* Remove makefile

* docs/development.md: adapt the instructions to the meson build system

Bonus: break a long line.
This commit is contained in:
Yegor Yefremov 2023-05-12 15:37:54 +02:00 committed by GitHub
parent 9668beec48
commit 79ddd89891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 325 additions and 195 deletions

9
.editorconfig Normal file
View File

@ -0,0 +1,9 @@
root = true
[meson.build]
indent_size = 2
charset = utf-8
end_of_line = lf
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true

1
debian/control vendored
View File

@ -10,6 +10,7 @@ Build-Depends: debhelper-compat (= 10),
libjson-glib-dev,
libvte-2.91-dev,
libxapp-dev,
meson,
pkg-config,
help2man,
Standards-Version: 3.9.3

View File

@ -4,22 +4,27 @@ This documentation provides instructions for developing Timeshift.
## Prerequisites
- make
- meson
- help2man
- gettext
- valac
- libvte-2.91-dev
- libgee-0.8-dev
- libjson-glib-dev
- libxapp-dev
If you are using a Debian-based distribution, you can install these dependencies by running the following command in a terminal:
If you are using a Debian-based distribution, you can install these
dependencies by running the following command in a terminal:
```bash
sudo apt install make \
sudo apt install meson \
help2man \
gettext \
valac \
libvte-2.91-dev \
libgee-0.8-dev \
libjson-glib-dev
libjson-glib-dev \
libxapp-dev
```
## Building and Installing
@ -39,11 +44,12 @@ cd timeshift
### Step 3. Build Timeshift
```bash
make
meson setup -C build
meson compile -C build
```
### Step 4. Install Timeshift
```bash
sudo make install
```
sudo meson install -C build
```

16
docs/man/meson.build Normal file
View File

@ -0,0 +1,16 @@
help2man = find_program('help2man')
mans = [
['timeshift', [help2man, '--output=@OUTPUT@', timeshift]],
]
foreach man: mans
custom_target(
man[0],
output: man[0] + '.1',
command: man[1],
install: true,
install_dir: join_paths(get_option('mandir'), 'man1'),
)
endforeach

1
files/meson.build Normal file
View File

@ -0,0 +1 @@
install_data(sources : 'timeshift.json', rename : 'default.json', install_dir : '/etc/timeshift')

View File

@ -1,34 +0,0 @@
all:
cd src; make all
app-gtk:
cd src; make app-gtk
app-console:
cd src; make app-console
manpage:
cd src; make manpage
dist-release:
build-release
dist-publish:
build-update-repo-debian
build-update-repo-redhat
build-update-repo-archlinux
dist-upload:
build-upload
dist-deb:
build-deb amd64
clean:
cd src; make clean
install:
cd src; make install
uninstall:
cd src; make uninstall

48
meson.build Normal file
View File

@ -0,0 +1,48 @@
project(
'timeshift', 'vala', 'c',
version: '22.11.2',
default_options: ['c_std=c99', 'build.c_std=c99'])
dependencies = [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gtk+-3.0'),
dependency('gio-2.0'),
dependency('gio-unix-2.0'),
dependency('json-glib-1.0'),
dependency('vte-2.91'),
dependency('gee-0.8'),
meson.get_compiler('vala').find_library('posix'),
meson.get_compiler('c').find_library('m'),
]
enable_xapp = get_option('xapp')
if enable_xapp
xapp_dep = dependency('xapp')
add_project_arguments('-D', 'XAPP', language: 'vala')
dependencies += xapp_dep
endif
# Include the translations module
i18n = import('i18n')
am_cflags = [
'-fstack-protector',
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
]
add_project_arguments(am_cflags, language: 'c')
add_project_arguments('-D', 'GTK3_18', language: 'vala')
subdir('files')
subdir('src')
subdir('po')
enable_man = get_option('man')
if enable_man
subdir('docs/man')
endif
install_data(
sources: 'debian/timeshift.appdata.xml',
install_dir: join_paths(get_option('datadir'), 'metainfo')
)

2
meson_options.txt Normal file
View File

@ -0,0 +1,2 @@
option('man', type: 'boolean', value: true, description: 'build man pages using help2man')
option('xapp', type: 'boolean', value: true, description: 'enable support for xapp library')

42
po/LINGUAS Normal file
View File

@ -0,0 +1,42 @@
am
ar
az
bg
ca
cs
da
de
el
en_GB
es
et
eu
fi
fr
he
hi
hr
hu
ia
id
is
it
ja
ko
lt
nb
ne
nl
pl
pt
pt_BR
ro
ru
sk
sr
sv
tr
uk
vi
zh_CN
zh_TW

68
po/POTFILES Normal file
View File

@ -0,0 +1,68 @@
src/AppConsole.vala
src/AppGtk.vala
src/Core/AppExcludeEntry.vala
src/Core/Main.vala
src/Core/Snapshot.vala
src/Core/SnapshotRepo.vala
src/Core/Subvolume.vala
src/Utility/AppLock.vala
src/Utility/AsyncTask.vala
src/Utility/CronTab.vala
src/Utility/CryptTabEntry.vala
src/Utility/DeleteFileTask.vala
src/Utility/Device.vala
src/Utility/FileItem.vala
src/Utility/FsTabEntry.vala
src/Utility/GtkHelper.vala
src/Utility/IconManager.vala
src/Utility/LicenseText.vala
src/Utility/LinuxDistro.vala
src/Utility/MountEntry.vala
src/Utility/OSDNotify.vala
src/Utility/RsyncSpaceCheckTask.vala
src/Utility/RsyncTask.vala
src/Utility/SystemUser.vala
src/Utility/TimeoutCounter.vala
src/Utility/TeeJee.FileSystem.vala
src/Utility/TeeJee.Json.vala
src/Utility/TeeJee.Logging.vala
src/Utility/TeeJee.Misc.vala
src/Utility/TeeJee.Process.vala
src/Utility/TeeJee.System.vala
src/Utility/Gtk/CustomMessageDialog.vala
src/Utility/Gtk/TerminalWindow.vala
src/Gtk/BackupBox.vala
src/Gtk/BackupDeviceBox.vala
src/Gtk/BackupFinishBox.vala
src/Gtk/BackupWindow.vala
src/Gtk/BootOptionsBox.vala
src/Gtk/BootOptionsWindow.vala
src/Gtk/DeleteBox.vala
src/Gtk/DeleteFinishBox.vala
src/Gtk/DeleteWindow.vala
src/Gtk/EstimateBox.vala
src/Gtk/ExcludeAppsBox.vala
src/Gtk/ExcludeBox.vala
src/Gtk/ExcludeListSummaryWindow.vala
src/Gtk/ExcludeMessageWindow.vala
src/Gtk/FinishBox.vala
src/Gtk/MainWindow.vala
src/Gtk/MiscBox.vala
src/Gtk/RestoreBox.vala
src/Gtk/RestoreDeviceBox.vala
src/Gtk/RestoreExcludeBox.vala
src/Gtk/RestoreFinishBox.vala
src/Gtk/RestoreSummaryBox.vala
src/Gtk/RestoreWindow.vala
src/Gtk/RsyncLogBox.vala
src/Gtk/RsyncLogWindow.vala
src/Gtk/ScheduleBox.vala
src/Gtk/SettingsWindow.vala
src/Gtk/SetupWizardWindow.vala
src/Gtk/SnapshotBackendBox.vala
src/Gtk/SnapshotListBox.vala
src/Gtk/UsersBox.vala

6
po/meson.build Normal file
View File

@ -0,0 +1,6 @@
i18n.gettext(meson.project_name(),
args: [
'--directory=' + meson.source_root(),
'--from-code=UTF-8'
]
)

View File

@ -38,7 +38,7 @@ using TeeJee.Misc;
public Main App;
public const string AppName = "Timeshift";
public const string AppShortName = "timeshift";
public const string AppVersion = "22.11.2";
public const string AppVersion = Constants.VERSION;
public const string AppAuthor = "Tony George";
public const string AppAuthorEmail = "teejeetech@gmail.com";

View File

@ -37,7 +37,7 @@ using TeeJee.Misc;
public Main App;
public const string AppName = "Timeshift";
public const string AppShortName = "timeshift";
public const string AppVersion = "22.11.2";
public const string AppVersion = Constants.VERSION;
public const string AppAuthor = "Tony George";
public const string AppAuthorEmail = "teejeetech@gmail.com";

3
src/config.vala.in Normal file
View File

@ -0,0 +1,3 @@
namespace Constants {
public const string VERSION = "@VERSION@";
}

View File

@ -1,152 +0,0 @@
SHELL=/bin/bash
CFLAGS=--std=c99
EXECUTABLES = find msgmerge msgfmt install rm mkdir cp chmod valac help2man
CHECKEXECS := $(foreach exec,$(EXECUTABLES), $(if $(shell which $(exec)),,$(error No $(exec) found, install it)))
prefix=/usr
sysconfdir=/etc
appconfdir=$(sysconfdir)/timeshift
bindir=$(prefix)/bin
sharedir=$(prefix)/share
polkitdir=$(sharedir)/polkit-1/actions
localedir=$(sharedir)/locale
launcherdir=$(sharedir)/applications
mandir=$(sharedir)/man
man1dir=$(mandir)/man1
app_name=timeshift
app_fullname=Timeshift
# xapp -----------------------------
xapp_pkg=$(shell { ((pkg-config --exists 'xapp >= 1.0.4') >/dev/null && echo '--pkg xapp') || echo ''; } )
xapp_symbol=$(shell { ((pkg-config --exists 'xapp >= 1.0.4') >/dev/null && echo '-D XAPP') || echo ''; } )
# gtk3 -----------------------------
gtk3_version=$(shell { (pkg-config --modversion gtk+-3.0 | cut -d. -f2); } )
ifeq ($(shell { test ${gtk3_version} -gt 17 ; echo $$? ; } ), 0)
gtk3_symbol=$(shell echo '-D GTK3_18')
else
gtk3_symbol=$(shell echo '')
endif
symbols=$(shell echo "${gtk3_symbol} ${xapp_symbol}")
all: app-gtk app-console
app-gtk:
#timeshift-gtk
valac -X -D'GETTEXT_PACKAGE="${app_name}"' \
--Xcc="-lm" --Xcc="-Os" ${symbols} \
Core/*.vala Gtk/*.vala Utility/*.vala Utility/Gtk/*.vala \
-o ${app_name}-gtk \
--pkg glib-2.0 --pkg gio-unix-2.0 --pkg posix \
--pkg gee-0.8 --pkg json-glib-1.0 --pkg gio-2.0 \
--pkg gtk+-3.0 --pkg vte-2.91 $(xapp_pkg)
app-console:
#timeshift
valac -X -D'GETTEXT_PACKAGE="${app_name}"' \
--Xcc="-lm" --Xcc="-Os" ${symbols} \
Core/*.vala Utility/*.vala Utility/Gtk/*.vala Console/*.vala \
-o ${app_name} \
--pkg glib-2.0 --pkg gio-unix-2.0 --pkg posix \
--pkg gee-0.8 --pkg json-glib-1.0 --pkg gio-2.0 \
--pkg gtk+-3.0 --pkg vte-2.91 $(xapp_pkg)
manpage:
help2man -o ${app_name}.1 ./${app_name}
clean:
rm -rfv ../release/{source,i386,amd64,armel,armhf}
rm -rfv ../release/*.{run,deb}
rm -rfv *.c *.o *.mo
rm -fv ${app_name} ${app_name}-gtk
rm -fv ${app_name}.1
install: manpage
mkdir -p "$(DESTDIR)$(bindir)"
mkdir -p "$(DESTDIR)$(sharedir)"
mkdir -p "$(DESTDIR)$(mandir)"
mkdir -p "$(DESTDIR)$(man1dir)"
mkdir -p "$(DESTDIR)$(launcherdir)"
mkdir -p "$(DESTDIR)$(polkitdir)"
mkdir -p "$(DESTDIR)$(sysconfdir)"
mkdir -p "$(DESTDIR)$(appconfdir)"
mkdir -p "$(DESTDIR)$(sharedir)/${app_name}"
mkdir -p "$(DESTDIR)$(sharedir)/icons"
mkdir -p "$(DESTDIR)$(sharedir)/appdata"
mkdir -p "$(DESTDIR)$(sharedir)/metainfo"
mkdir -p "$(DESTDIR)$(sharedir)/pixmaps"
# binary
install -m 0755 ${app_name} "$(DESTDIR)$(bindir)"
install -m 0755 ${app_name}-gtk "$(DESTDIR)$(bindir)"
install -m 0755 ${app_name}-launcher "$(DESTDIR)$(bindir)"
# shared files
cp -dpr --no-preserve=ownership -t "$(DESTDIR)$(sharedir)/${app_name}" ./share/${app_name}/*
find $(DESTDIR)$(sharedir)/${app_name} -type d -exec chmod 755 {} \+
find $(DESTDIR)$(sharedir)/${app_name} -type f -exec chmod 644 {} \+
# polkit
install -m 0644 ./share/polkit-1/actions/in.teejeetech.pkexec.timeshift.policy "$(DESTDIR)$(polkitdir)"
# launcher
install -m 0755 ${app_name}-gtk.desktop "$(DESTDIR)$(launcherdir)"
# config
install -m 0644 ../files/${app_name}.json "$(DESTDIR)$(appconfdir)/default.json"
# man page
install -m 0644 ${app_name}.1 "$(DESTDIR)$(man1dir)/${app_name}.1"
# app icons
cp -dpr --no-preserve=ownership -t "$(DESTDIR)$(sharedir)/icons" ./share/icons/*
chmod --recursive 0644 $(DESTDIR)$(sharedir)/icons/hicolor/*/apps/${app_name}.png
# app icon
install -m 0755 ./share/pixmaps/${app_name}.png "$(DESTDIR)$(sharedir)/pixmaps/"
# appdata
#install -m 0644 ../debian/${app_name}.appdata.xml "$(DESTDIR)$(sharedir)/appdata"
install -m 0644 ../debian/${app_name}.appdata.xml "$(DESTDIR)$(sharedir)/metainfo"
# translations
for lang in am ar az bg ca cs da de el en_GB es et eu fi fr he hi hr hu ia id is it ja ko lt nb ne nl pl pt pt_BR ro ru sk sr sv tr uk vi zh_CN zh_TW; do \
mkdir -p "$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES"; \
msgfmt --check --verbose -o "$(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/${app_name}.mo" ../po/${app_name}-$$lang.po ; \
done
uninstall:
# binary
rm -f "$(DESTDIR)$(bindir)/${app_name}"
rm -f "$(DESTDIR)$(bindir)/${app_name}-gtk"
rm -f "$(DESTDIR)$(bindir)/${app_name}-launcher"
# shared files
rm -rf "$(DESTDIR)$(sharedir)/${app_name}"
# launcher
rm -f "$(DESTDIR)$(launcherdir)/${app_name}-gtk.desktop"
# polkit
rm -f "$(DESTDIR)$(polkitdir)/in.teejeetech.pkexec.timeshift.policy"
# man page
rm -f "$(DESTDIR)$(man1dir)/${app_name}.1"
# app icon
rm -f $(DESTDIR)$(sharedir)/icons/hicolor/*/apps/${app_name}.png
# translations
rm -f $(DESTDIR)$(localedir)/*/LC_MESSAGES/${app_name}.mo
# appdata
rm -f "$(DESTDIR)$(sharedir)/appdata/${app_name}.appdata.xml"
rm -f "$(DESTDIR)$(sharedir)/metainfo/${app_name}.appdata.xml"

114
src/meson.build Normal file
View File

@ -0,0 +1,114 @@
conf_data = configuration_data()
conf_data.set('GETTEXT_PACKAGE', meson.project_name())
conf_data.set('VERSION', meson.project_version())
config_header = configure_file(
input: 'config.vala.in',
output: 'config.vala',
configuration: conf_data
)
sources_core = files([
'Core/AppExcludeEntry.vala',
'Core/Main.vala',
'Core/Snapshot.vala',
'Core/SnapshotRepo.vala',
'Core/Subvolume.vala',
])
sources_utility = files([
'Utility/AppLock.vala',
'Utility/AsyncTask.vala',
'Utility/CronTab.vala',
'Utility/CryptTabEntry.vala',
'Utility/DeleteFileTask.vala',
'Utility/Device.vala',
'Utility/FileItem.vala',
'Utility/FsTabEntry.vala',
'Utility/GtkHelper.vala',
'Utility/IconManager.vala',
'Utility/LicenseText.vala',
'Utility/LinuxDistro.vala',
'Utility/MountEntry.vala',
'Utility/OSDNotify.vala',
'Utility/RsyncSpaceCheckTask.vala',
'Utility/RsyncTask.vala',
'Utility/SystemUser.vala',
'Utility/TimeoutCounter.vala',
'Utility/TeeJee.FileSystem.vala',
'Utility/TeeJee.Json.vala',
'Utility/TeeJee.Logging.vala',
'Utility/TeeJee.Misc.vala',
'Utility/TeeJee.Process.vala',
'Utility/TeeJee.System.vala',
'Utility/Gtk/CustomMessageDialog.vala',
'Utility/Gtk/TerminalWindow.vala',
])
sources_gtk = files([
'Gtk/BackupBox.vala',
'Gtk/BackupDeviceBox.vala',
'Gtk/BackupFinishBox.vala',
'Gtk/BackupWindow.vala',
'Gtk/BootOptionsBox.vala',
'Gtk/BootOptionsWindow.vala',
'Gtk/DeleteBox.vala',
'Gtk/DeleteFinishBox.vala',
'Gtk/DeleteWindow.vala',
'Gtk/EstimateBox.vala',
'Gtk/ExcludeAppsBox.vala',
'Gtk/ExcludeBox.vala',
'Gtk/ExcludeListSummaryWindow.vala',
'Gtk/ExcludeMessageWindow.vala',
'Gtk/FinishBox.vala',
'Gtk/MainWindow.vala',
'Gtk/MiscBox.vala',
'Gtk/RestoreBox.vala',
'Gtk/RestoreDeviceBox.vala',
'Gtk/RestoreExcludeBox.vala',
'Gtk/RestoreFinishBox.vala',
'Gtk/RestoreSummaryBox.vala',
'Gtk/RestoreWindow.vala',
'Gtk/RsyncLogBox.vala',
'Gtk/RsyncLogWindow.vala',
'Gtk/ScheduleBox.vala',
'Gtk/SettingsWindow.vala',
'Gtk/SetupWizardWindow.vala',
'Gtk/SnapshotBackendBox.vala',
'Gtk/SnapshotListBox.vala',
'Gtk/UsersBox.vala',
])
sources_app_console = files([
'AppConsole.vala',
])
sources_app_gtk = files([
'AppGtk.vala',
])
timeshift = executable('timeshift',
sources_app_console + sources_core + sources_utility,
config_header,
dependencies: dependencies,
install: true
)
executable('timeshift-gtk',
sources_app_gtk + sources_core + sources_utility + sources_gtk,
config_header,
dependencies: dependencies,
install: true
)
install_data(
sources : 'timeshift-launcher',
install_dir : get_option('bindir')
)
install_data(
sources : 'timeshift-gtk.desktop',
install_dir : join_paths(get_option('datadir'), 'applications')
)
install_subdir('share', install_dir : '')