diff --git a/Makefile b/Makefile index 19e8ba7..b29056b 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,32 @@ +# The app ID to use. +# +# Use de.swsnr.turnon for the standard app ID, and de.swsnr.turnon.Devel to +# build a nightly snapshot. Other values are not supported. APPID = de.swsnr.turnon +# The destination prefix to install files to. Combines traditional DESTDIR and +# PREFIX variables; turnon does not encode the prefix into its binary and thus +# does not need to distinguish between the prefix and the destdir. +DESTPREFIX = /app +# Installation directory for locale files. +LOCALEDIR = $(DESTPREFIX)/share/locale/ + +GIT_DESCRIBE = $(shell git describe | tail -c+2) + BLUEPRINTS = $(wildcard ui/*.blp) UIDEFS = $(addsuffix .ui,$(basename $(BLUEPRINTS))) CATALOGS = $(wildcard po/*.po) -LOCALEDIR = /app/share/locale/ -GIT_DESCRIBE = $(shell git describe | tail -c+2) XGETTEXT_OPTS = \ --package-name=$(APPID) \ --foreign-user --copyright-holder "Sebastian Wiesner " \ --sort-by-file --from-code=UTF-8 --add-comments +# Extract the message template from all source files. +# +# You typically do not need to run this manually: The gettext Github workflow +# watches for changes to relevant source files, runs this target, and opens a +# pull request with the corresponding changes. +# # When changing the set of files taken into account for xgettext also update the # paths list in the gettext.yml workflow to make sure that updates to these # files are caught by the gettext workflows. @@ -29,31 +46,63 @@ pot: rm -f po/POTFILES* po/de.swsnr.turnon.rs.pot po/de.swsnr.turnon.blp.pot sed -i /POT-Creation-Date/d po/de.swsnr.turnon.pot -.PHONY: messages -messages: pot - po/%.mo: po/%.po msgfmt --output-file $@ --check $< +# Compile binary message catalogs from message catalogs .PHONY: msgfmt msgfmt: $(addsuffix .mo,$(basename $(CATALOGS))) $(LOCALEDIR)/%/LC_MESSAGES/$(APPID).mo: po/%.mo install -Dpm0644 $< $@ +# Install compiled locale message catalogs. .PHONY: install-locale install-locale: $(addprefix $(LOCALEDIR)/,$(addsuffix /LC_MESSAGES/$(APPID).mo,$(notdir $(basename $(CATALOGS))))) +# Install Turn On into $DESTPREFIX using $APPID. +# +# You must run cargo build --release before invoking this target! +.PHONY: install +install: install-locale + install -Dm0755 target/release/turnon $(DESTPREFIX)/bin/$(APPID) + install -Dm0644 -t $(DESTPREFIX)/share/icons/hicolor/scalable/apps/ resources/icons/scalable/apps/$(APPID).svg + install -Dm0644 resources/icons/symbolic/apps/de.swsnr.turnon-symbolic.svg \ + $(DESTPREFIX)/share/icons/hicolor/symbolic/apps/$(APPID)-symbolic.svg + install -Dm0644 de.swsnr.turnon.desktop $(DESTPREFIX)/share/applications/$(APPID).desktop + install -Dm0644 resources/de.swsnr.turnon.metainfo.xml $(DESTPREFIX)/share/metainfo/$(APPID).metainfo.xml + install -Dm0644 dbus-1/de.swsnr.turnon.service $(DESTPREFIX)/share/dbus-1/services/$(APPID).service + install -Dm0644 de.swsnr.turnon.search-provider.ini $(DESTPREFIX)/share/gnome-shell/search-providers/$(APPID).search-provider.ini + install -Dm0644 schemas/de.swsnr.turnon.gschema.xml $(DESTPREFIX)/share/glib-2.0/schemas/$(APPID).gschema.xml + +# Patch the current git describe version into Turn On. +.PHONY: patch-git-version +patch-git-version: + sed -i 's/^version = .*/version = "$(GIT_DESCRIBE)"/' Cargo.toml + cargo update -p turnon + +# Patch the app ID to use APPID in various files +.PHONY: patch-appid +patch-appid: + sed -i '/$(APPID)/! s/de\.swsnr\.turnon/$(APPID)/g' \ + src/config.rs \ + resources/de.swsnr.turnon.metainfo.xml.in de.swsnr.turnon.desktop.in \ + dbus-1/de.swsnr.turnon.service de.swsnr.turnon.search-provider.ini \ + schemas/de.swsnr.turnon.gschema.xml + +# Remove compiled message catalogs and other generated files. .PHONY: clean clean: rm -f po/*.mo +# Build a development flatpak without sandbox. .PHONY: flatpak-devel flatpak-devel: flatpak run org.flatpak.Builder --force-clean --user --install \ --install-deps-from=flathub --repo=repo \ builddir flatpak/de.swsnr.turnon.Devel.yaml +# Build a regular flatpak (sandboxed build) .PHONY: flatpak flatpak: flatpak run org.flatpak.Builder --force-clean --sandbox --user --install \ @@ -69,13 +118,3 @@ flatpak-lint-manifest: .PHONY: flatpak-lint-repo flatpak-lint-repo: flatpak run --command=flatpak-builder-lint org.flatpak.Builder repo repo - -.PHONY: -devel: - sed -i 's/^version = .*/version = "$(GIT_DESCRIBE)"/' Cargo.toml - cargo update -p turnon - sed -i '/de.swsnr.turnon.Devel/! s/de\.swsnr\.turnon/de.swsnr.turnon.Devel/g' \ - src/config.rs \ - resources/de.swsnr.turnon.metainfo.xml.in de.swsnr.turnon.desktop.in \ - dbus-1/de.swsnr.turnon.service de.swsnr.turnon.search-provider.ini \ - schemas/de.swsnr.turnon.gschema.xml diff --git a/flatpak/de.swsnr.turnon.Devel.yaml b/flatpak/de.swsnr.turnon.Devel.yaml index eddae71..4c5fb64 100644 --- a/flatpak/de.swsnr.turnon.Devel.yaml +++ b/flatpak/de.swsnr.turnon.Devel.yaml @@ -26,20 +26,8 @@ modules: build-args: - --share=network build-commands: - # Patch for devel version - - make devel - # Build optimized binary + # Patch version number and app ID before building our binary + - make APPID=de.swsnr.turnon.Devel patch-git-version patch-appid - cargo build --locked --release --verbose - # Install locales - - make LOCALEDIR=/app/share/locale/ APPID=de.swsnr.turnon.Devel install-locale - # Install binary, app icon, desktop file, appstream metadata, DBus service, and search provider - - install -Dm0755 target/release/turnon /app/bin/de.swsnr.turnon.Devel - - install -Dm0644 -t /app/share/icons/hicolor/scalable/apps/ resources/icons/scalable/apps/de.swsnr.turnon.Devel.svg - - install -Dm0644 resources/icons/symbolic/apps/de.swsnr.turnon-symbolic.svg /app/share/icons/hicolor/symbolic/apps/de.swsnr.turnon.Devel-symbolic.svg - - install -Dm0644 de.swsnr.turnon.desktop /app/share/applications/de.swsnr.turnon.Devel.desktop - - install -Dm0644 resources/de.swsnr.turnon.metainfo.xml /app/share/metainfo/de.swsnr.turnon.Devel.metainfo.xml - - install -Dm0644 dbus-1/de.swsnr.turnon.service /app/share/dbus-1/services/de.swsnr.turnon.Devel.service - - install -Dm0644 de.swsnr.turnon.search-provider.ini /app/share/gnome-shell/search-providers/de.swsnr.turnon.Devel.search-provider.ini - # Install settings and compile them - - install -Dm0644 schemas/de.swsnr.turnon.gschema.xml /app/share/glib-2.0/schemas/de.swsnr.turnon.Devel.gschema.xml + - make DESTPREFIX=/app APPID=de.swsnr.turnon.Devel install - glib-compile-schemas --strict /app/share/glib-2.0/schemas