From 540081c73806ba023583d4900618ac7a5ecba9f1 Mon Sep 17 00:00:00 2001 From: Aleksandr Mezin Date: Fri, 1 Dec 2023 19:34:15 +0200 Subject: [PATCH] [WIP] Meson build system https://github.com/ddterm/gnome-shell-extension-ddterm/issues/648 --- .github/workflows/build.yml | 29 +- .github/workflows/check-po.yml | 40 +- .github/workflows/pot.yml | 9 +- .gitignore | 16 +- Makefile | 461 ------------------ ...zin.ddterm => com.github.amezin.ddterm.in} | 2 +- bin/meson.build | 16 + ddterm/app/icons/meson.build | 13 + ddterm/app/meson.build | 38 ++ ddterm/meson.build | 38 ++ ddterm/pref/meson.build | 33 ++ ddterm/pref/test/meson.build | 18 + ddterm/pref/ui/gtk3/meson.build | 27 + ddterm/pref/{glade => ui/gtk4}/3to4-fixup.xsl | 0 ddterm/pref/ui/gtk4/meson.build | 35 ++ ddterm/pref/ui/meson.build | 23 + ddterm/pref/{glade => ui}/prefs-animation.ui | 0 ddterm/pref/{glade => ui}/prefs-behavior.ui | 0 ddterm/pref/{glade => ui}/prefs-colors.ui | 0 ddterm/pref/{glade => ui}/prefs-command.ui | 0 .../pref/{glade => ui}/prefs-compatibility.ui | 0 ddterm/pref/{glade => ui}/prefs-panel-icon.ui | 0 .../pref/{glade => ui}/prefs-position-size.ui | 0 ddterm/pref/{glade => ui}/prefs-scrolling.ui | 0 ddterm/pref/{glade => ui}/prefs-shortcuts.ui | 0 ddterm/pref/{glade => ui}/prefs-tabs.ui | 0 ddterm/pref/{glade => ui}/prefs-text.ui | 0 ddterm/shell/meson.build | 24 + ddterm/util/meson.build | 11 + locale/LINGUAS | 12 + {po => locale}/README.md | 0 {po => locale}/cs.po | 0 {po => locale}/ddterm@amezin.github.com.pot | 0 {po => locale}/de.po | 0 {po => locale}/el.po | 0 {po => locale}/es.po | 0 {po => locale}/fr.po | 0 {po => locale}/id.po | 0 {po => locale}/it.po | 0 locale/meson.build | 114 +++++ {po => locale}/nb_NO.po | 0 {po => locale}/pl.po | 0 {po => locale}/pt.po | 0 {po => locale}/ru.po | 0 locale/update.py | 31 ++ {po => locale}/zh_CN.po | 0 meson.build | 180 +++++++ metadata.json.in | 8 +- package.json | 4 + po/remove-potcdate.sin | 19 - po/update-pot.sh | 26 - schemas/meson.build | 32 ++ tools/meson-cwd.py | 28 ++ 53 files changed, 729 insertions(+), 558 deletions(-) delete mode 100755 Makefile rename bin/{com.github.amezin.ddterm => com.github.amezin.ddterm.in} (79%) create mode 100644 bin/meson.build create mode 100644 ddterm/app/icons/meson.build create mode 100644 ddterm/app/meson.build create mode 100644 ddterm/meson.build create mode 100644 ddterm/pref/meson.build create mode 100644 ddterm/pref/test/meson.build create mode 100644 ddterm/pref/ui/gtk3/meson.build rename ddterm/pref/{glade => ui/gtk4}/3to4-fixup.xsl (100%) create mode 100644 ddterm/pref/ui/gtk4/meson.build create mode 100644 ddterm/pref/ui/meson.build rename ddterm/pref/{glade => ui}/prefs-animation.ui (100%) rename ddterm/pref/{glade => ui}/prefs-behavior.ui (100%) rename ddterm/pref/{glade => ui}/prefs-colors.ui (100%) rename ddterm/pref/{glade => ui}/prefs-command.ui (100%) rename ddterm/pref/{glade => ui}/prefs-compatibility.ui (100%) rename ddterm/pref/{glade => ui}/prefs-panel-icon.ui (100%) rename ddterm/pref/{glade => ui}/prefs-position-size.ui (100%) rename ddterm/pref/{glade => ui}/prefs-scrolling.ui (100%) rename ddterm/pref/{glade => ui}/prefs-shortcuts.ui (100%) rename ddterm/pref/{glade => ui}/prefs-tabs.ui (100%) rename ddterm/pref/{glade => ui}/prefs-text.ui (100%) create mode 100644 ddterm/shell/meson.build create mode 100644 ddterm/util/meson.build create mode 100644 locale/LINGUAS rename {po => locale}/README.md (100%) rename {po => locale}/cs.po (100%) rename {po => locale}/ddterm@amezin.github.com.pot (100%) rename {po => locale}/de.po (100%) rename {po => locale}/el.po (100%) rename {po => locale}/es.po (100%) rename {po => locale}/fr.po (100%) rename {po => locale}/id.po (100%) rename {po => locale}/it.po (100%) create mode 100644 locale/meson.build rename {po => locale}/nb_NO.po (100%) rename {po => locale}/pl.po (100%) rename {po => locale}/pt.po (100%) rename {po => locale}/ru.po (100%) create mode 100755 locale/update.py rename {po => locale}/zh_CN.po (100%) create mode 100644 meson.build delete mode 100644 po/remove-potcdate.sin delete mode 100755 po/update-pot.sh create mode 100644 schemas/meson.build create mode 100644 tools/meson-cwd.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2bf4a8660..d028256f7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,11 +44,11 @@ jobs: - name: Install JS dependencies id: npm - run: npm ci + run: npm install if: ${{ always() && steps.checkout.conclusion == 'success' }} - name: Lint JS code - run: make "ESLINT_OPTS=--format .github/eslint-formatter.js" lint + run: npm run-script lint -- --format .github/eslint-formatter.js if: ${{ always() && steps.npm.conclusion == 'success' }} - name: Pre-create pip cache directory @@ -75,15 +75,22 @@ jobs: run: echo "::add-matcher::.github/problem-matchers/generic.json" if: ${{ always() && steps.checkout.conclusion == 'success' }} + - id: meson-setup + name: Prepare build directory + run: meson setup build + if: ${{ always() && steps.checkout.conclusion == 'success' }} + - name: Compile GSettings schemas - run: make schemas 2>&1 | tee schemas.log + run: ninja -j1 validate-schemas 2>&1 | tee schemas.log + working-directory: build shell: bash - if: ${{ always() && steps.checkout.conclusion == 'success' }} + if: ${{ always() && steps.meson-setup.conclusion == 'success' }} - name: Validate Gtk .ui files - run: xvfb-run make gtk-builder-validate 2>&1 | tee gtk-builder.log + run: xvfb-run ninja -j1 validate-pref-ui 2>&1 | tee gtk-builder.log + working-directory: build shell: bash - if: ${{ always() && steps.checkout.conclusion == 'success' }} + if: ${{ always() && steps.meson-setup.conclusion == 'success' }} - name: Ensure Python requirements .txt files are in sync with .in files run: | @@ -102,7 +109,7 @@ jobs: if: ${{ always() && steps.checkout.conclusion == 'success' }} - name: Upload reports to Testspace - run: testspace --verbose eslint.xml "*.log{lint}" + run: testspace --verbose eslint.xml "build/*.log{lint}" if: ${{ always() && steps.setup_testspace.outcome == 'success' }} pack: @@ -119,13 +126,17 @@ jobs: - name: Enable generic error matcher run: echo "::add-matcher::.github/problem-matchers/generic.json" + - name: Prepare build directory + run: meson setup build + - name: Build extension package - run: xvfb-run make ONLY_RELEASE_LOCALES=true pack + run: xvfb-run ninja -j1 pack + working-directory: build - name: Upload extension package as artifact id: upload uses: actions/upload-artifact@v3 with: name: pack - path: "*.shell-extension.zip" + path: "build/*.shell-extension.zip" if-no-files-found: error diff --git a/.github/workflows/check-po.yml b/.github/workflows/check-po.yml index 4ff71dcbc..c73af3438 100644 --- a/.github/workflows/check-po.yml +++ b/.github/workflows/check-po.yml @@ -4,35 +4,21 @@ on: env: FORCE_COLOR: 1 - PIP_DISABLE_PIP_VERSION_CHECK: 1 jobs: configure: runs-on: ubuntu-latest outputs: - pofiles: ${{ steps.generate.outputs.pofiles }} + linguas: ${{ steps.generate.outputs.linguas }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Generate .po file list + - name: Read language list id: generate - shell: python - run: | - import json - import os - import pathlib - import uuid - - delimiter = f'ghadelimiter_{uuid.uuid4()}' - value = json.dumps([str(p) for p in pathlib.Path('.').glob('po/*.po')]) - - with open(os.environ['GITHUB_OUTPUT'], 'a') as fp: - print(f'pofiles<<{delimiter}', file=fp) - print(value, file=fp) - print(delimiter, file=fp) + run: echo "linguas=$(jq -Rcn '[inputs]' locale/LINGUAS)" >>$GITHUB_OUTPUT check: needs: configure @@ -44,7 +30,7 @@ jobs: strategy: fail-fast: false matrix: - pofile: ${{ fromJson(needs.configure.outputs.pofiles) }} + lang: ${{ fromJson(needs.configure.outputs.linguas) }} steps: - name: Checkout @@ -53,22 +39,26 @@ jobs: - run: git config --global --replace-all safe.directory "$GITHUB_WORKSPACE" - - name: Enable gettext stats problem matcher - run: echo "::add-matcher::.github/problem-matchers/gettext-stats.json" - - name: Enable generic problem matcher run: echo "::add-matcher::.github/problem-matchers/generic.json" + - name: Prepare build directory + run: meson setup build + if: ${{ always() && steps.checkout.conclusion == 'success' }} + + - name: Enable gettext stats problem matcher + run: echo "::add-matcher::.github/problem-matchers/gettext-stats.json" + - name: Compile translation - run: make msgfmt/${{ matrix.pofile }} 2>&1 | tee $GITHUB_STEP_SUMMARY + run: ninja -j1 -v msgfmt-${{ matrix.lang }} 2>&1 | tee $GITHUB_STEP_SUMMARY shell: bash + working-directory: build - name: Disable gettext stats problem matcher run: echo "::remove-matcher owner=gettext-stats::" - name: Ensure .po file is in sync with .pot - run: | - touch po/*.pot # Make sure .pot won't be re-generated - make msgcmp/${{ matrix.pofile }} 2>&1 + run: ninja -j1 --quiet msgcmp-${{ matrix.lang }} 2>&1 shell: bash + working-directory: build if: ${{ always() && steps.checkout.conclusion == 'success' }} diff --git a/.github/workflows/pot.yml b/.github/workflows/pot.yml index 936c002e9..f6fb7d3a6 100644 --- a/.github/workflows/pot.yml +++ b/.github/workflows/pot.yml @@ -12,7 +12,7 @@ on: - master env: - PO_FILES: po/*.po po/*.pot + PO_FILES: locale/*.po locale/*.pot jobs: pot: @@ -33,8 +33,13 @@ jobs: - name: Enable generic error matcher run: echo "::add-matcher::.github/problem-matchers/generic.json" + - name: Prepare build directory + run: meson setup build + if: ${{ always() && steps.checkout.conclusion == 'success' }} + - name: Update .pot files - run: po/update-pot.sh + run: ninja -j1 pot + working-directory: build - name: Check if there are any changes id: diff diff --git a/.gitignore b/.gitignore index 4042a243b..525d1943b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,10 @@ *~ -/node_modules/ -# Makefile output -/*.shell-extension.zip -/ddterm/pref/ui/ -/ddterm/com.github.amezin.ddterm.desktop -/ddterm/com.github.amezin.ddterm.service -/metadata.json -/schemas/gschemas.compiled -/locale/ -/tmp/ -/revision.txt +/node_modules/* +!/node_modules/meson.build +!/node_modules/.bin +/node_modules/.bin/* +!/node_modules/.bin/meson.build # do-in-docker.sh/do-in-podman.sh /.container-home/ diff --git a/Makefile b/Makefile deleted file mode 100755 index 1532d2c0e..000000000 --- a/Makefile +++ /dev/null @@ -1,461 +0,0 @@ -#!/usr/bin/env -S make -f - -# See docs/BUILD.md - -SHELL := /bin/bash - -EXTENSION_UUID := ddterm@amezin.github.com - -TRUE_VALUES := yes YES true TRUE on ON 1 -is-true = $(filter 1,$(words $(filter $(TRUE_VALUES),$(1)))) - -all: -.PHONY: all - -find-tool = $(or $(shell command -v $(1)),tool-not-found/$(1)) - -define tool-not-found-message -$* not found and is required. -You could use do-in-docker.sh or do-in-podman.sh to avoid installing build dependencies. -Please check docs/BUILD.md -endef - -tool-not-found/%: - $(error $(tool-not-found-message)) - -CLEAN := -TRANSLATABLE_SOURCES := -PACK_CONTENT := - -# Git revision file - -ifeq ($(file $@ - -else - -revision.txt: revision.txt.in - cat $< >$@ - -endif - -CLEAN += revision.txt -PACK_CONTENT += revision.txt - -# GSettings schemas - -SCHEMAS := $(wildcard schemas/*.gschema.xml) -SCHEMAS_COMPILED := schemas/gschemas.compiled - -GLIB_COMPILE_SCHEMAS := $(call find-tool,glib-compile-schemas) - -$(SCHEMAS_COMPILED): $(SCHEMAS) $(GLIB_COMPILE_SCHEMAS) - $(GLIB_COMPILE_SCHEMAS) --strict $(dir $@) - -CLEAN += $(SCHEMAS_COMPILED) -PACK_CONTENT += $(SCHEMAS) - -schemas: $(SCHEMAS_COMPILED) -.PHONY: schemas -all: schemas - -# Locales - -LOCALES_RELEASE := \ - po/cs.po \ - po/de.po \ - po/el.po \ - po/fr.po \ - po/it.po \ - po/nb_NO.po \ - po/pl.po \ - po/pt.po \ - po/ru.po \ - po/zh_CN.po - -LOCALES_ALL := $(wildcard po/*.po) - -ONLY_RELEASE_LOCALES := no - -ifeq ($(call is-true,$(ONLY_RELEASE_LOCALES)),1) -LOCALES := $(LOCALES_RELEASE) -else -LOCALES := $(LOCALES_ALL) -endif - -LOCALE_SOURCE_PATTERN := po/%.po -LOCALE_COMPILED_PATTERN := locale/%/LC_MESSAGES/$(EXTENSION_UUID).mo -LOCALES_COMPILED := $(patsubst $(LOCALE_SOURCE_PATTERN),$(LOCALE_COMPILED_PATTERN),$(LOCALES)) - -MSGFMT := $(call find-tool,msgfmt) - -$(LOCALES_COMPILED): $(LOCALE_COMPILED_PATTERN): $(LOCALE_SOURCE_PATTERN) $(MSGFMT) - mkdir -p $(dir $@) - $(MSGFMT) --check --strict --statistics -o $@ $< - -$(addprefix msgfmt/,$(LOCALES)): msgfmt/$(LOCALE_SOURCE_PATTERN): $(LOCALE_COMPILED_PATTERN) - -CLEAN += $(LOCALES_COMPILED) -PACK_CONTENT += $(LOCALES_COMPILED) - -locales msgfmt: $(LOCALES_COMPILED) -.PHONY: locales msgfmt - -# Glade UI - -PREFS_GLADE_UI := $(wildcard ddterm/pref/glade/*.ui) -PREFS_GLADE_UI_PATTERN := ddterm/pref/glade/%.ui -TRANSLATABLE_SOURCES += $(APP_GLADE_UI) $(PREFS_GLADE_UI) - -ddterm/pref/ui: - mkdir -p $@ - -# Gtk 3 .ui - -GTK_BUILDER_TOOL := $(call find-tool,gtk-builder-tool) - -ddterm/pref/ui/gtk3: | ddterm/pref/ui - mkdir -p $@ - -PREFS_UI_GTK3_PATTERN := ddterm/pref/ui/gtk3/%.ui -PREFS_UI_GTK3 := $(patsubst $(PREFS_GLADE_UI_PATTERN),$(PREFS_UI_GTK3_PATTERN),$(PREFS_GLADE_UI)) - -$(PREFS_UI_GTK3): $(PREFS_UI_GTK3_PATTERN): $(PREFS_GLADE_UI_PATTERN) $(GTK_BUILDER_TOOL) | ddterm/pref/ui/gtk3 - $(GTK_BUILDER_TOOL) simplify $< >$@ - -GTK3_GENERATED_UI := $(APP_UI) $(PREFS_UI_GTK3) -GTK3_HANDCRAFTED_UI := ddterm/app/menus.ui -GTK3_UI := $(GTK3_GENERATED_UI) $(GTK3_HANDCRAFTED_UI) - -CLEAN += $(GTK3_GENERATED_UI) -PACK_CONTENT += $(GTK3_UI) -TRANSLATABLE_SOURCES += $(GTK3_HANDCRAFTED_UI) - -# Gtk 4 .ui - -GTK4_BUILDER_TOOL := $(call find-tool,gtk4-builder-tool) -XSLTPROC := $(call find-tool,xsltproc) - -ddterm/pref/ui/gtk4 ddterm/pref/ui/gtk4/3to4-fixup ddterm/pref/ui/gtk4/3to4: - mkdir -p $@ - -ddterm/pref/ui/gtk4/3to4-fixup ddterm/pref/ui/gtk4/3to4: | ddterm/pref/ui/gtk4 - -PREFS_UI_3TO4_FIXUP_PATTERN := ddterm/pref/ui/gtk4/3to4-fixup/%.ui -PREFS_UI_3TO4_FIXUP := $(patsubst $(PREFS_GLADE_UI_PATTERN),$(PREFS_UI_3TO4_FIXUP_PATTERN),$(PREFS_GLADE_UI)) - -$(PREFS_UI_3TO4_FIXUP): $(PREFS_UI_3TO4_FIXUP_PATTERN): $(PREFS_GLADE_UI_PATTERN) ddterm/pref/glade/3to4-fixup.xsl $(XSLTPROC) | ddterm/pref/ui/gtk4/3to4-fixup - $(XSLTPROC) ddterm/pref/glade/3to4-fixup.xsl $< >$@ - -PREFS_UI_3TO4_PATTERN := ddterm/pref/ui/gtk4/3to4/%.ui -PREFS_UI_3TO4 := $(patsubst $(PREFS_UI_3TO4_FIXUP_PATTERN),$(PREFS_UI_3TO4_PATTERN),$(PREFS_UI_3TO4_FIXUP)) - -$(PREFS_UI_3TO4): $(PREFS_UI_3TO4_PATTERN): $(PREFS_UI_3TO4_FIXUP_PATTERN) $(GTK4_BUILDER_TOOL) | ddterm/pref/ui/gtk4/3to4 - $(GTK4_BUILDER_TOOL) simplify --3to4 $< >$@ - -PREFS_UI_GTK4_PATTERN := ddterm/pref/ui/gtk4/%.ui -PREFS_UI_GTK4 := $(patsubst $(PREFS_UI_3TO4_PATTERN),$(PREFS_UI_GTK4_PATTERN),$(PREFS_UI_3TO4)) - -$(PREFS_UI_GTK4): $(PREFS_UI_GTK4_PATTERN): $(PREFS_UI_3TO4_PATTERN) $(GTK4_BUILDER_TOOL) | ddterm/pref/ui/gtk4 - $(GTK4_BUILDER_TOOL) simplify $< >$@ - -CLEAN += $(PREFS_UI_3TO4_FIXUP) $(PREFS_UI_3TO4) $(PREFS_UI_GTK4) - -GTK4_UI := $(PREFS_UI_GTK4) - -PACK_CONTENT += $(GTK4_UI) - -# metadata.json - -# Prevent people from trying to feed source archives to 'gnome-extensions install'. -# https://github.com/ddterm/gnome-shell-extension-ddterm/issues/61 - -metadata.json: metadata.json.in - cp $< $@ - -PACK_CONTENT += metadata.json -CLEAN += metadata.json - -# JS sources - -JS_SOURCE_WILDCARDS := \ - *.js \ - ddterm/*.js \ - ddterm/app/*.js \ - ddterm/backport/*.js \ - ddterm/pref/*.js \ - ddterm/shell/*.js \ - ddterm/util/*.js \ - misc/*.js \ - -JS_SOURCES := $(wildcard $(JS_SOURCE_WILDCARDS)) -LAUNCHER := bin/com.github.amezin.ddterm -EXECUTABLES := $(LAUNCHER) ddterm/app/dependencies-notification.js - -TRANSLATABLE_SOURCES += $(JS_SOURCES) -PACK_CONTENT += $(EXECUTABLES) $(filter-out $(EXECUTABLES),$(JS_SOURCES)) - -# package - -PACK_CONTENT += \ - ddterm/app/style.css \ - ddterm/app/dependencies.json \ - $(wildcard ddterm/app/icons/*) \ - ddterm/com.github.amezin.ddterm.Extension.xml \ - ddterm/com.github.amezin.ddterm.HeapDump.xml \ - ddterm/com.github.amezin.ddterm.desktop.in \ - ddterm/com.github.amezin.ddterm.service.in \ - LICENSE \ - -PACK_CONTENT := $(sort $(PACK_CONTENT)) - -build: $(PACK_CONTENT) -.PHONY: build - -ZIP := $(call find-tool,zip) - -EXTENSION_PACK := $(EXTENSION_UUID).shell-extension.zip -$(EXTENSION_PACK): $(PACK_CONTENT) $(ZIP) - $(RM) $@ - $(ZIP) -y -nw $@ -- $(PACK_CONTENT) - -pack: $(EXTENSION_PACK) -.PHONY: pack - -all: pack -CLEAN += $(EXTENSION_PACK) - -# install/uninstall package - user - -user-install: $(EXTENSION_PACK) develop-uninstall - gnome-extensions install -f $< - -user-uninstall: develop-uninstall - gnome-extensions uninstall $(EXTENSION_UUID) - -.PHONY: user-install user-uninstall - -# install/uninstall package - system-wide - -# https://www.gnu.org/software/make/manual/html_node/Command-Variables.html -INSTALL := install -INSTALL_PROGRAM := $(INSTALL) -INSTALL_DATA := $(INSTALL) -m 644 - -# https://www.gnu.org/software/make/manual/html_node/Directory-Variables.html -prefix := /usr -exec_prefix := $(prefix) -datarootdir := $(prefix)/share -datadir := $(datarootdir) -bindir := $(exec_prefix)/bin - -extensiondir := $(datadir)/gnome-shell/extensions - -SYS_INSTALLED_EXTENSION_DIR := $(extensiondir)/$(EXTENSION_UUID) -SYS_INSTALLED_CONTENT := $(addprefix $(SYS_INSTALLED_EXTENSION_DIR)/,$(PACK_CONTENT) $(SCHEMAS_COMPILED)) -SYS_INSTALLED_DESKTOP_ENTRY := $(datadir)/applications/com.github.amezin.ddterm.desktop -SYS_INSTALLED_DBUS_SERVICE := $(datadir)/dbus-1/services/com.github.amezin.ddterm.service -SYS_INSTALLED_EXECUTABLES := $(addprefix $(SYS_INSTALLED_EXTENSION_DIR)/,$(EXECUTABLES)) -SYS_INSTALLED_LAUNCHER := $(filter %$(LAUNCHER),$(SYS_INSTALLED_EXECUTABLES)) -SYS_INSTALLED_LAUNCHER_SYMLINK := $(bindir)/$(notdir $(LAUNCHER)) -SYS_INSTALLED_ALL := \ - $(SYS_INSTALLED_CONTENT) \ - $(SYS_INSTALLED_DESKTOP_ENTRY) \ - $(SYS_INSTALLED_DBUS_SERVICE) \ - $(SYS_INSTALLED_LAUNCHER_SYMLINK) \ - -SYS_INSTALLED_DIRS := $(sort $(dir $(SYS_INSTALLED_ALL))) - -$(addprefix $(DESTDIR),$(SYS_INSTALLED_DIRS)): - mkdir -p $@ - -installdirs: $(addprefix $(DESTDIR),$(SYS_INSTALLED_DIRS)) - -$(addprefix $(DESTDIR),$(SYS_INSTALLED_CONTENT)): $(DESTDIR)$(SYS_INSTALLED_EXTENSION_DIR)/%: % | installdirs - $(INSTALL) $< $@ - -$(addprefix $(DESTDIR),$(SYS_INSTALLED_CONTENT)): INSTALL := $(INSTALL_DATA) -$(addprefix $(DESTDIR),$(SYS_INSTALLED_EXECUTABLES)): INSTALL := $(INSTALL_PROGRAM) - -CONFIGURED_DESKTOP_ENTRY := ddterm/com.github.amezin.ddterm.desktop -CONFIGURED_DBUS_SERVICE := ddterm/com.github.amezin.ddterm.service - -$(CONFIGURED_DESKTOP_ENTRY) $(CONFIGURED_DBUS_SERVICE): - sed -e 's:@LAUNCHER@:$(SYS_INSTALLED_LAUNCHER):g' $< >$@ - -$(CONFIGURED_DESKTOP_ENTRY): ddterm/com.github.amezin.ddterm.desktop.in -$(CONFIGURED_DBUS_SERVICE): ddterm/com.github.amezin.ddterm.service.in - -CLEAN += $(CONFIGURED_DESKTOP_ENTRY) $(CONFIGURED_DBUS_SERVICE) - -$(addprefix $(DESTDIR),$(SYS_INSTALLED_DESKTOP_ENTRY) $(SYS_INSTALLED_DBUS_SERVICE)): | installdirs - $(INSTALL_DATA) $< $@ - -$(addprefix $(DESTDIR),$(SYS_INSTALLED_DESKTOP_ENTRY)): $(CONFIGURED_DESKTOP_ENTRY) -$(addprefix $(DESTDIR),$(SYS_INSTALLED_DBUS_SERVICE)): $(CONFIGURED_DBUS_SERVICE) - -$(addprefix $(DESTDIR),$(SYS_INSTALLED_LAUNCHER_SYMLINK)): | installdirs - ln -s $(SYS_INSTALLED_LAUNCHER) $@ - -system-install: $(addprefix $(DESTDIR),$(SYS_INSTALLED_ALL)) - -system-uninstall: - $(RM) $(addprefix $(DESTDIR),$(SYS_INSTALLED_ALL)) - $(RM) -r $(addprefix $(DESTDIR),$(SYS_INSTALLED_FULL_PREFIX)) - -.PHONY: system-install system-uninstall installdirs - -# System/user install autodetect - -ifneq ($(DESTDIR),) -INSTALL_FLAVOR := system -else ifeq ($(shell id -u),0) -INSTALL_FLAVOR := system -else -INSTALL_FLAVOR := user -endif - -install: $(INSTALL_FLAVOR)-install -uninstall: $(INSTALL_FLAVOR)-uninstall - -.PHONY: install uninstall - -# develop/symlink install - -DEVELOP_SYMLINK := $(HOME)/.local/share/gnome-shell/extensions/$(EXTENSION_UUID) - -develop: build - mkdir -p "$(dir $(DEVELOP_SYMLINK))" - @if [[ -e "$(DEVELOP_SYMLINK)" && ! -L "$(DEVELOP_SYMLINK)" ]]; then \ - echo "$(DEVELOP_SYMLINK) exists and is not a symlink, not overwriting"; exit 1; \ - fi - if [[ "$(abspath .)" != "$(abspath $(DEVELOP_SYMLINK))" ]]; then \ - ln -snf "$(abspath .)" "$(DEVELOP_SYMLINK)"; \ - fi - -develop-uninstall: - if [[ -L "$(DEVELOP_SYMLINK)" ]]; then \ - unlink "$(DEVELOP_SYMLINK)"; \ - fi - -.PHONY: develop develop-uninstall - -# clean - -clean: - $(RM) $(CLEAN) - -.PHONY: clean - -# .ui validation - -GTK3_VALIDATE_UI := $(addprefix gtk-builder-validate/,$(GTK3_UI)) - -$(GTK3_VALIDATE_UI): gtk-builder-validate/%: % $(GTK_BUILDER_TOOL) - $(GTK_BUILDER_TOOL) validate $< - -.PHONY: $(GTK3_VALIDATE_UI) - -GTK4_VALIDATE_UI := $(addprefix gtk-builder-validate/,$(GTK4_UI)) - -$(GTK4_VALIDATE_UI): gtk-builder-validate/%: % $(GTK4_BUILDER_TOOL) - $(GTK4_BUILDER_TOOL) validate $< - -.PHONY: $(GTK4_VALIDATE_UI) - -gtk-builder-validate: $(GTK3_VALIDATE_UI) $(GTK4_VALIDATE_UI) - -all: gtk-builder-validate -.PHONY: gtk-builder-validate - -# Translation helpers - -POT_FILE := po/$(EXTENSION_UUID).pot -XGETTEXT := $(call find-tool,xgettext) - -$(POT_FILE): $(TRANSLATABLE_SOURCES) $(XGETTEXT) - $(XGETTEXT) \ - --from-code=UTF-8 \ - --default-domain=$(EXTENSION_UUID) \ - --package-name=ddterm \ - --output=$@ \ - $(sort $(TRANSLATABLE_SOURCES)) - -pot: $(POT_FILE) -.PHONY: pot - -MSGCMP_GOALS := $(addprefix msgcmp/, $(LOCALES)) -MSGCMP_FLAGS := --use-untranslated --use-fuzzy -MSGCMP := $(call find-tool,msgcmp) - -$(MSGCMP_GOALS): msgcmp/%: % $(POT_FILE) $(MSGCMP) - $(MSGCMP) $(MSGCMP_FLAGS) $< $(POT_FILE) - -msgcmp: $(MSGCMP_GOALS) - -msgcmp-strict: override MSGCMP_FLAGS := -msgcmp-strict: $(MSGCMP_GOALS) - -.PHONY: msgcmp msgcmp-strict $(MSGCMP_GOALS) - -MSGMERGE_GOALS := $(addprefix msgmerge/, $(LOCALES)) -MSGMERGE_FLAGS := --no-fuzzy-matching --update -MSGMERGE := $(call find-tool,msgmerge) - -$(MSGMERGE_GOALS): msgmerge/%: % $(POT_FILE) $(MSGMERGE) - $(MSGMERGE) $(MSGMERGE_FLAGS) $< $(POT_FILE) - -msgmerge: $(MSGMERGE_GOALS) - -msgmerge-fuzzy: override MSGMERGE_FLAGS := --update --previous -msgmerge-fuzzy: $(MSGMERGE_GOALS) - -.PHONY: msgmerge $(MSGMERGE_GOALS) - -# ESLint - -ESLINT_CMD := node_modules/.bin/eslint -ESLINT_OPTS := -NPM_INSTALLED += $(ESLINT_CMD) - -lint/eslintrc-gjs.yml: - curl -o $@ 'https://gitlab.gnome.org/GNOME/gnome-shell/-/raw/39ed7f83fd97a5a3f688d77adb73e00fd24b7bfe/lint/eslintrc-gjs.yml' - -lint: $(ESLINT_CMD) lint/eslintrc-gjs.yml - $< $(ESLINT_OPTS) . - -.PHONY: lint -all: lint - -# Automagic 'npm install' - -NPM_INSTALL := yes - -ifeq ($(call is-true,$(NPM_INSTALL)),1) - -$(NPM_INSTALLED): node_modules/.package-lock.json -NPM := $(call find-tool,npm) - -node_modules/.package-lock.json: package.json package-lock.json $(NPM) - $(NPM) install - -npm: node_modules/.package-lock.json -.PHONY: npm - -endif - -# Various helpers - -prefs enable disable reset info show: - gnome-extensions $@ $(EXTENSION_UUID) - -.PHONY: prefs enable disable reset info show - -toggle quit begin-subscription-leak-check end-subscription-leak-check: - gapplication action com.github.amezin.ddterm $@ - -.PHONY: toggle quit begin-subscription-leak-check end-subscription-leak-check diff --git a/bin/com.github.amezin.ddterm b/bin/com.github.amezin.ddterm.in similarity index 79% rename from bin/com.github.amezin.ddterm rename to bin/com.github.amezin.ddterm.in index b127fbca2..2b934deb2 100755 --- a/bin/com.github.amezin.ddterm +++ b/bin/com.github.amezin.ddterm.in @@ -10,4 +10,4 @@ then PATH="$bindir${PATH:+:${PATH}}" fi -exec gjs -m "${bindir%/*}/ddterm/app/main.js" "$@" +exec "@GJS@" -m "${bindir%/*}/ddterm/app/main.js" "$@" diff --git a/bin/meson.build b/bin/meson.build new file mode 100644 index 000000000..de0360602 --- /dev/null +++ b/bin/meson.build @@ -0,0 +1,16 @@ +pack += configure_file( + input: 'com.github.amezin.ddterm.in', + output: '@BASENAME@', + configuration: gjs_config, + install: true, + install_dir: extension_dir / 'bin', + install_mode: 'rwxr-xr-x' +) + +launcher_installed = extension_dir / 'bin' / 'com.github.amezin.ddterm' + +install_symlink( + 'com.github.amezin.ddterm', + pointing_to: launcher_installed, + install_dir: bindir, +) diff --git a/ddterm/app/icons/meson.build b/ddterm/app/icons/meson.build new file mode 100644 index 000000000..f1163f76b --- /dev/null +++ b/ddterm/app/icons/meson.build @@ -0,0 +1,13 @@ +icon_files = files( + 'quotation-symbolic.svg', + 'regex-symbolic.svg', + 'uppercase-symbolic.svg', +) + +foreach icon_file : icon_files + pack += fs.copyfile( + icon_file, + install: true, + install_dir: extension_dir / 'ddterm' / 'app' / 'icons', + ) +endforeach diff --git a/ddterm/app/meson.build b/ddterm/app/meson.build new file mode 100644 index 000000000..ab96ae49a --- /dev/null +++ b/ddterm/app/meson.build @@ -0,0 +1,38 @@ +app_js_files = files( + 'accellabel.js', + 'application.js', + 'appwindow.js', + 'dependencies-notification.js', + 'dependencies.js', + 'gtktheme.js', + 'heapdump.js', + 'init.js', + 'main.js', + 'meta.js', + 'notebook.js', + 'pcre2.js', + 'prefsdialog.js', + 'search.js', + 'settings.js', + 'tablabel.js', + 'tcgetpgrp.js', + 'terminal.js', + 'terminalpage.js', + 'terminalsettings.js', + 'urldetect.js', + 'urldetect_patterns.js', + 'waitstatus.js' +) + +potfiles += app_js_files +potfiles += files('menus.ui') + +foreach app_file : app_js_files + files('dependencies.json', 'menus.ui', 'style.css') + pack += fs.copyfile( + app_file, + install: true, + install_dir: extension_dir / 'ddterm' / 'app', + ) +endforeach + +subdir('icons') diff --git a/ddterm/meson.build b/ddterm/meson.build new file mode 100644 index 000000000..337fd8f81 --- /dev/null +++ b/ddterm/meson.build @@ -0,0 +1,38 @@ +ddterm_files = files( + 'com.github.amezin.ddterm.desktop.in', + 'com.github.amezin.ddterm.Extension.xml', + 'com.github.amezin.ddterm.HeapDump.xml', + 'com.github.amezin.ddterm.service.in', +) + +foreach ddterm_file : ddterm_files + pack += fs.copyfile( + ddterm_file, + install: true, + install_dir: extension_dir / 'ddterm', + ) +endforeach + +launcher_config = configuration_data() +launcher_config.set('LAUNCHER', launcher_installed) + +configure_file( + input: 'com.github.amezin.ddterm.desktop.in', + output: '@BASENAME@', + configuration: launcher_config, + install: true, + install_dir: applications_dir, +) + +configure_file( + input: 'com.github.amezin.ddterm.service.in', + output: '@BASENAME@', + configuration: launcher_config, + install: true, + install_dir: dbus_service_dir, +) + +subdir('app') +subdir('pref') +subdir('shell') +subdir('util') diff --git a/ddterm/pref/meson.build b/ddterm/pref/meson.build new file mode 100644 index 000000000..6e4c6a2a5 --- /dev/null +++ b/ddterm/pref/meson.build @@ -0,0 +1,33 @@ +pref_files = files( + 'adw.js', + 'animation.js', + 'behavior.js', + 'colors.js', + 'command.js', + 'compatibility.js', + 'panelicon.js', + 'positionsize.js', + 'scrolling.js', + 'shortcuts.js', + 'tabs.js', + 'text.js', + 'util.js', + 'widget.js', +) + +potfiles += pref_files + +pref_copy_files = [] + +foreach pref_file : pref_files + pref_copy_files += fs.copyfile( + pref_file, + install: true, + install_dir: extension_dir / 'ddterm' / 'pref', + ) +endforeach + +pack += pref_copy_files + +subdir('ui') +subdir('test') diff --git a/ddterm/pref/test/meson.build b/ddterm/pref/test/meson.build new file mode 100644 index 000000000..c3b22d240 --- /dev/null +++ b/ddterm/pref/test/meson.build @@ -0,0 +1,18 @@ +pref_test_common_files = [ + fs.copyfile('common.js'), + pref_copy_files, + schema_copy, + schemas_compiled, +] + +run_target( + 'pref-gtk3-test', + command: [gjs, '-m', fs.copyfile('gtk3.js')], + depends: [pref_test_common_files, pref_ui_gtk3_files] +) + +run_target( + 'pref-gtk4-test', + command: [gjs, '-m', fs.copyfile('gtk4.js')], + depends: [pref_test_common_files, pref_ui_gtk4_files] +) diff --git a/ddterm/pref/ui/gtk3/meson.build b/ddterm/pref/ui/gtk3/meson.build new file mode 100644 index 000000000..d3272ccd1 --- /dev/null +++ b/ddterm/pref/ui/gtk3/meson.build @@ -0,0 +1,27 @@ +gtk3_builder_tool = find_program('gtk-builder-tool') + +pref_ui_gtk3_files = [] + +foreach pref_ui_file: pref_ui_files + pref_ui_gtk3_files += custom_target( + command: [gtk3_builder_tool, 'simplify', '@INPUT@'], + input: pref_ui_file, + output: '@PLAINNAME@', + capture: true, + install: true, + install_dir: extension_dir / 'ddterm' / 'pref' / 'ui' / 'gtk3', + ) +endforeach + +pack += pref_ui_gtk3_files + +pref_ui_gtk3_validate_targets = [] + +foreach pref_ui_file: pref_ui_gtk3_files + pref_ui_gtk3_validate_targets += run_target( + 'validate-pref-ui-gtk3-' + fs.name(pref_ui_file.full_path()), + command: [gtk3_builder_tool, 'validate', pref_ui_file], + ) +endforeach + +pref_ui_gtk3_validate_target = alias_target('validate-pref-ui-gtk3', pref_ui_gtk3_validate_targets) diff --git a/ddterm/pref/glade/3to4-fixup.xsl b/ddterm/pref/ui/gtk4/3to4-fixup.xsl similarity index 100% rename from ddterm/pref/glade/3to4-fixup.xsl rename to ddterm/pref/ui/gtk4/3to4-fixup.xsl diff --git a/ddterm/pref/ui/gtk4/meson.build b/ddterm/pref/ui/gtk4/meson.build new file mode 100644 index 000000000..cfa9f98c5 --- /dev/null +++ b/ddterm/pref/ui/gtk4/meson.build @@ -0,0 +1,35 @@ +gtk4_builder_tool = find_program('gtk4-builder-tool') +xsltproc = find_program('xsltproc') + +pref_ui_gtk4_files = [] + +foreach pref_ui_file: pref_ui_files + fixup = custom_target( + command: [xsltproc, files('3to4-fixup.xsl'), '@INPUT@'], + input: pref_ui_file, + output: fs.stem(pref_ui_file) + '.fixup.ui', + capture: true, + ) + + pref_ui_gtk4_files += custom_target( + command: [gtk4_builder_tool, 'simplify', '--3to4', '@INPUT@'], + input: fixup, + output: fs.name(pref_ui_file), + capture: true, + install: true, + install_dir: extension_dir / 'ddterm' / 'pref' / 'ui' / 'gtk4', + ) +endforeach + +pack += pref_ui_gtk4_files + +pref_ui_gtk4_validate_targets = [] + +foreach pref_ui_file: pref_ui_gtk4_files + pref_ui_gtk4_validate_targets += run_target( + 'validate-pref-ui-gtk4-' + fs.name(pref_ui_file.full_path()), + command: [gtk4_builder_tool, 'validate', pref_ui_file], + ) +endforeach + +pref_ui_gtk4_validate_target = alias_target('validate-pref-ui-gtk4', pref_ui_gtk4_validate_targets) diff --git a/ddterm/pref/ui/meson.build b/ddterm/pref/ui/meson.build new file mode 100644 index 000000000..a74bfb89e --- /dev/null +++ b/ddterm/pref/ui/meson.build @@ -0,0 +1,23 @@ +pref_ui_files = files( + 'prefs-animation.ui', + 'prefs-behavior.ui', + 'prefs-colors.ui', + 'prefs-command.ui', + 'prefs-compatibility.ui', + 'prefs-panel-icon.ui', + 'prefs-position-size.ui', + 'prefs-scrolling.ui', + 'prefs-shortcuts.ui', + 'prefs-tabs.ui', + 'prefs-text.ui', +) + +potfiles += pref_ui_files + +subdir('gtk3') +subdir('gtk4') + +check_targets += alias_target( + 'validate-pref-ui', + [pref_ui_gtk3_validate_target, pref_ui_gtk4_validate_target] +) diff --git a/ddterm/pref/glade/prefs-animation.ui b/ddterm/pref/ui/prefs-animation.ui similarity index 100% rename from ddterm/pref/glade/prefs-animation.ui rename to ddterm/pref/ui/prefs-animation.ui diff --git a/ddterm/pref/glade/prefs-behavior.ui b/ddterm/pref/ui/prefs-behavior.ui similarity index 100% rename from ddterm/pref/glade/prefs-behavior.ui rename to ddterm/pref/ui/prefs-behavior.ui diff --git a/ddterm/pref/glade/prefs-colors.ui b/ddterm/pref/ui/prefs-colors.ui similarity index 100% rename from ddterm/pref/glade/prefs-colors.ui rename to ddterm/pref/ui/prefs-colors.ui diff --git a/ddterm/pref/glade/prefs-command.ui b/ddterm/pref/ui/prefs-command.ui similarity index 100% rename from ddterm/pref/glade/prefs-command.ui rename to ddterm/pref/ui/prefs-command.ui diff --git a/ddterm/pref/glade/prefs-compatibility.ui b/ddterm/pref/ui/prefs-compatibility.ui similarity index 100% rename from ddterm/pref/glade/prefs-compatibility.ui rename to ddterm/pref/ui/prefs-compatibility.ui diff --git a/ddterm/pref/glade/prefs-panel-icon.ui b/ddterm/pref/ui/prefs-panel-icon.ui similarity index 100% rename from ddterm/pref/glade/prefs-panel-icon.ui rename to ddterm/pref/ui/prefs-panel-icon.ui diff --git a/ddterm/pref/glade/prefs-position-size.ui b/ddterm/pref/ui/prefs-position-size.ui similarity index 100% rename from ddterm/pref/glade/prefs-position-size.ui rename to ddterm/pref/ui/prefs-position-size.ui diff --git a/ddterm/pref/glade/prefs-scrolling.ui b/ddterm/pref/ui/prefs-scrolling.ui similarity index 100% rename from ddterm/pref/glade/prefs-scrolling.ui rename to ddterm/pref/ui/prefs-scrolling.ui diff --git a/ddterm/pref/glade/prefs-shortcuts.ui b/ddterm/pref/ui/prefs-shortcuts.ui similarity index 100% rename from ddterm/pref/glade/prefs-shortcuts.ui rename to ddterm/pref/ui/prefs-shortcuts.ui diff --git a/ddterm/pref/glade/prefs-tabs.ui b/ddterm/pref/ui/prefs-tabs.ui similarity index 100% rename from ddterm/pref/glade/prefs-tabs.ui rename to ddterm/pref/ui/prefs-tabs.ui diff --git a/ddterm/pref/glade/prefs-text.ui b/ddterm/pref/ui/prefs-text.ui similarity index 100% rename from ddterm/pref/glade/prefs-text.ui rename to ddterm/pref/ui/prefs-text.ui diff --git a/ddterm/shell/meson.build b/ddterm/shell/meson.build new file mode 100644 index 000000000..d0aae650c --- /dev/null +++ b/ddterm/shell/meson.build @@ -0,0 +1,24 @@ +shell_files = files( + 'appcontrol.js', + 'dbusapi.js', + 'extension.js', + 'geometry.js', + 'install.js', + 'notifications.js', + 'panelicon.js', + 'sd_journal.js', + 'service.js', + 'subprocess.js', + 'windowmatch.js', + 'wm.js', +) + +potfiles += shell_files + +foreach shell_file : shell_files + pack += fs.copyfile( + shell_file, + install: true, + install_dir: extension_dir / 'ddterm' / 'shell', + ) +endforeach diff --git a/ddterm/util/meson.build b/ddterm/util/meson.build new file mode 100644 index 000000000..a5d133d28 --- /dev/null +++ b/ddterm/util/meson.build @@ -0,0 +1,11 @@ +util_files = files( + 'displayconfig.js', +) + +foreach util_file : util_files + pack += fs.copyfile( + util_file, + install: true, + install_dir: extension_dir / 'ddterm' / 'util', + ) +endforeach diff --git a/locale/LINGUAS b/locale/LINGUAS new file mode 100644 index 000000000..fd3c32e28 --- /dev/null +++ b/locale/LINGUAS @@ -0,0 +1,12 @@ +cs +de +el +es +fr +id +it +nb_NO +pl +pt +ru +zh_CN diff --git a/po/README.md b/locale/README.md similarity index 100% rename from po/README.md rename to locale/README.md diff --git a/po/cs.po b/locale/cs.po similarity index 100% rename from po/cs.po rename to locale/cs.po diff --git a/po/ddterm@amezin.github.com.pot b/locale/ddterm@amezin.github.com.pot similarity index 100% rename from po/ddterm@amezin.github.com.pot rename to locale/ddterm@amezin.github.com.pot diff --git a/po/de.po b/locale/de.po similarity index 100% rename from po/de.po rename to locale/de.po diff --git a/po/el.po b/locale/el.po similarity index 100% rename from po/el.po rename to locale/el.po diff --git a/po/es.po b/locale/es.po similarity index 100% rename from po/es.po rename to locale/es.po diff --git a/po/fr.po b/locale/fr.po similarity index 100% rename from po/fr.po rename to locale/fr.po diff --git a/po/id.po b/locale/id.po similarity index 100% rename from po/id.po rename to locale/id.po diff --git a/po/it.po b/locale/it.po similarity index 100% rename from po/it.po rename to locale/it.po diff --git a/locale/meson.build b/locale/meson.build new file mode 100644 index 000000000..b68993879 --- /dev/null +++ b/locale/meson.build @@ -0,0 +1,114 @@ +i18n = import('i18n') +languages = [] + +foreach line: fs.read('LINGUAS').split('\n') + line = line.strip() + if not line.startswith('#') + foreach language: line.split() + if language != '' + languages += language + endif + endforeach + endif +endforeach + +gettext_targets = i18n.gettext( + gettext_domain, + languages: languages, + install: true, + install_dir: extension_dir / 'locale' +) + +pack += gettext_targets[0] + +alias_target('locales', gettext_targets[0]) + +potfiles_rel = [] + +if meson.version().version_compare('>=1.3.0') + foreach potfile: potfiles + potfiles_rel += fs.relative_to(potfile, meson.project_source_root()) + endforeach +else + foreach potfile: potfiles + potfiles_rel += run_command( + 'realpath', + '--relative-to=@SOURCE_ROOT@', + potfile, + capture: true, + check: true, + ).stdout().strip(['\n']) + endforeach +endif + +xgettext_tool = find_program('xgettext', required: false, disabler: true) + +pot_target = custom_target( + command: [ + xgettext_tool, + '--from-code=UTF-8', + '--package-name=ddterm', + '--output=@OUTPUT@', + '--sort-by-file', + '-D', '@SOURCE_ROOT@', + potfiles_rel + ], + input: potfiles, + output: f'@gettext_domain@.pot', +) + +pot_update_target = run_target( + 'pot', + command: [files('update.py'), '@CURRENT_SOURCE_DIR@' / f'@gettext_domain@.pot', pot_target] +) + +msgmerge_tool = find_program('msgmerge', required: false, disabler: true) +msgmerge_targets = [] + +foreach language: languages + msgmerge_targets += run_target( + f'msgmerge-@language@', + command: [ + msgmerge_tool, + '--update', + '--previous', + '@CURRENT_SOURCE_DIR@' / f'@language@.po', + '@CURRENT_SOURCE_DIR@' / f'@gettext_domain@.pot', + ] + ) +endforeach + +alias_target('msgmerge', msgmerge_targets) + +msgcmp_tool = find_program('msgcmp', required: false, disabler: true) +msgfmt_tool = find_program('msgfmt', required: false, disabler: true) + +msgcmp_targets = [] +msgfmt_targets = [] + +foreach language: languages + msgcmp_targets += run_target( + f'msgcmp-@language@', + command: [ + msgcmp_tool, + '--use-untranslated', + '--use-fuzzy', + '@CURRENT_SOURCE_DIR@' / f'@language@.po', + '@CURRENT_SOURCE_DIR@' / f'@gettext_domain@.pot', + ], + ) + + msgfmt_targets += run_target( + f'msgfmt-@language@', + command: [ + msgfmt_tool, + '--check', + '-o', '/dev/null', + '-v', + '@CURRENT_SOURCE_DIR@' / f'@language@.po', + ], + ) +endforeach + +check_targets += alias_target('msgcmp', msgcmp_targets) +check_targets += alias_target('msgfmt', msgfmt_targets) diff --git a/po/nb_NO.po b/locale/nb_NO.po similarity index 100% rename from po/nb_NO.po rename to locale/nb_NO.po diff --git a/po/pl.po b/locale/pl.po similarity index 100% rename from po/pl.po rename to locale/pl.po diff --git a/po/pt.po b/locale/pt.po similarity index 100% rename from po/pt.po rename to locale/pt.po diff --git a/po/ru.po b/locale/ru.po similarity index 100% rename from po/ru.po rename to locale/ru.po diff --git a/locale/update.py b/locale/update.py new file mode 100755 index 000000000..a916340c8 --- /dev/null +++ b/locale/update.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import argparse +import pathlib +import re + + +POTCDATE_LINE_RE = re.compile(r'^"POT-Creation-Date: .*\\n"' + '\n$', re.MULTILINE) + + +def strip_potcdate(data): + return POTCDATE_LINE_RE.sub('', data, count=1) + + +def run(target, source): + source_data = source.read_text(encoding='utf-8') + target_data = target.read_text(encoding='utf-8') if target.exists() else '' + + if strip_potcdate(source_data) != strip_potcdate(target_data): + target.write_text(source_data, encoding='utf-8') + + +def cli(): + parser = argparse.ArgumentParser() + parser.add_argument('target', type=pathlib.Path) + parser.add_argument('source', type=pathlib.Path) + run(**vars(parser.parse_args())) + + +if __name__ == '__main__': + cli() diff --git a/po/zh_CN.po b/locale/zh_CN.po similarity index 100% rename from po/zh_CN.po rename to locale/zh_CN.po diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..7b0c47fe6 --- /dev/null +++ b/meson.build @@ -0,0 +1,180 @@ +project( + 'ddterm', + version: '49', + meson_version: '>= 1.0.0', + license: 'GPL3+', + default_options: ['prefix=/usr'], +) + +gjs_version_required = '>=1.78.0' + +fs = import('fs') +gnome = import('gnome') + +uuid = 'ddterm@amezin.github.com' +gettext_domain = uuid +settings_schema = 'com.github.amezin.ddterm' + +prefix = get_option('prefix') +bindir = prefix / get_option('bindir') +datadir = prefix / get_option('datadir') + +extension_dir = datadir / 'gnome-shell' / 'extensions' / uuid +schema_dir = datadir / 'glib-2.0' / 'schemas' +applications_dir = datadir / 'applications' +dbus_service_dir = datadir / 'dbus-1' / 'services' + +metadata = configuration_data() +metadata.set('version', meson.project_version()) +metadata.set_quoted('uuid', uuid) +metadata.set_quoted('gettext_domain', gettext_domain) +metadata.set_quoted('settings_schema', settings_schema) + +pack = [] +potfiles = [] +check_targets = [] + +pack += fs.copyfile( + 'extension.js', + install: true, + install_dir: extension_dir +) + +pack += fs.copyfile( + 'prefs.js', + install: true, + install_dir: extension_dir +) + +pack += fs.copyfile('LICENSE') + +pack += configure_file( + input: 'metadata.json.in', + output: '@BASENAME@', + configuration: metadata, + install: true, + install_dir: extension_dir, +) + +if fs.read('revision.txt.in').strip() == '$Format:%H$' + git = find_program('git') + + pack += custom_target( + command: [ + git, + '-C', '@CURRENT_SOURCE_DIR@', + '--git-dir', '.git', + 'rev-parse', 'HEAD' + ], + capture: true, + output: 'revision.txt', + build_always_stale: true, + install: true, + install_dir: extension_dir, + ) +else + pack += fs.copyfile( + 'revision.txt.in', + 'revision.txt', + install: true, + install_dir: extension_dir, + ) +endif + +gjs_dep = dependency( + 'gjs-1.0', + version: gjs_version_required, + method: 'pkg-config', + required: false +) + +gjs = find_program( + ['gjs', gjs_dep.get_variable('gjs_console', default_value: 'gjs')], + dirs: [gjs_dep.get_variable('bindir', default_value: bindir)], + version: gjs_version_required, +) + +gjs_config = configuration_data() +gjs_config.set('GJS', gjs.full_path()) + +gio_dep = dependency( + 'gio-2.0', + method: 'pkg-config', + required: false, +) + +subdir('bin') +subdir('schemas') +subdir('ddterm') +subdir('locale') + +gnome.post_install( + glib_compile_schemas: true, + update_desktop_database: true, +) + +zip = find_program('zip', required: false, disabler: true) + +pack_target = custom_target( + command: [zip, '-y', '-nw', '-', '--', '@INPUT@'], + capture: true, + input: pack, + output: f'@uuid@.shell-extension.zip', + build_by_default: true, +) + +alias_target('pack', pack_target) + +extensions_tool = find_program('gnome-extensions', required: false, disabler: true) + +run_target( + 'user-install', + command: [extensions_tool, 'install', '-f', pack_target], +) + +run_target('user-uninstall', command: [extensions_tool, 'uninstall', uuid]) + +foreach target: ['prefs', 'enable', 'disable', 'reset'] + run_target(target, command: [extensions_tool, target, uuid]) +endforeach + +gapplication_tool = find_program( + 'gapplication', + dirs: [gio_dep.get_variable('bindir', default_value: bindir)], + required: false, + disabler: true, +) + +foreach target: ['toggle', 'quit'] + run_target(target, command: [gapplication_tool, 'action', 'com.github.amezin.ddterm', target]) +endforeach + +npm_tool = find_program('npm', required: false, disabler: true) + +npm_install = custom_target( + command: [ + 'tools/meson-cwd.py', + '--cwd', '@CURRENT_SOURCE_DIR@', + '--stamp', '@OUTPUT@', + '--', + npm_tool, 'install', + ], + output: 'npm.installed', + depend_files: files('package.json', 'package-lock.json', 'tools/meson-cwd.py'), + console: true, + build_by_default: false, +) + +check_targets += run_target( + 'eslint', + command: [npm_tool, 'exec', '--', 'eslint', '@CURRENT_SOURCE_DIR@'], + depends: npm_install, +) + +run_target( + 'eslint-fix', + command: [npm_tool, 'exec', '--', 'eslint', '--fix', '@CURRENT_SOURCE_DIR@'], + depends: npm_install, +) + +alias_target('check', check_targets) diff --git a/metadata.json.in b/metadata.json.in index b1acf82af..e5613f75c 100644 --- a/metadata.json.in +++ b/metadata.json.in @@ -1,12 +1,12 @@ { "name": "ddterm", "description": "Another drop down terminal extension for GNOME Shell. With tabs. Works on Wayland natively", - "uuid": "ddterm@amezin.github.com", - "gettext-domain": "ddterm@amezin.github.com", - "settings-schema": "com.github.amezin.ddterm", + "uuid": @uuid@, + "gettext-domain": @gettext_domain@, + "settings-schema": @settings_schema@, "shell-version": [ "45" ], - "version": 49, + "version": @version@, "url": "https://github.com/ddterm/gnome-shell-extension-ddterm" } diff --git a/package.json b/package.json index 7941847f0..d1ce84f55 100644 --- a/package.json +++ b/package.json @@ -6,5 +6,9 @@ "eslint-formatter-checkstyle": "^8.40.0", "eslint-formatter-stylish": "^8.40.0", "eslint-plugin-jsdoc": "46.9.0" + }, + "scripts": { + "lint": "eslint .", + "lint:fix": "eslint --fix ." } } diff --git a/po/remove-potcdate.sin b/po/remove-potcdate.sin deleted file mode 100644 index 2436c49e7..000000000 --- a/po/remove-potcdate.sin +++ /dev/null @@ -1,19 +0,0 @@ -# Sed script that remove the POT-Creation-Date line in the header entry -# from a POT file. -# -# The distinction between the first and the following occurrences of the -# pattern is achieved by looking at the hold space. -/^"POT-Creation-Date: .*"$/{ -x -# Test if the hold space is empty. -s/P/P/ -ta -# Yes it was empty. First occurrence. Remove the line. -g -d -bb -:a -# The hold space was nonempty. Following occurrences. Do nothing. -x -:b -} diff --git a/po/update-pot.sh b/po/update-pot.sh deleted file mode 100755 index 8a4da3514..000000000 --- a/po/update-pot.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -SCRIPT_DIR=$(CDPATH="" cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) -MAKEFILE_DIR="$SCRIPT_DIR/.." - -remove_potcdate() { - sed -f "$SCRIPT_DIR/remove-potcdate.sin" "$@" -} - -set -ex - -# Update .pot file(s), but keep existing POT-Creation-Date if nothing else changed - -for POTFILE in "$SCRIPT_DIR"/*.pot -do - mv "$POTFILE" "$POTFILE~" # backup - make -C "$MAKEFILE_DIR" "$(realpath --relative-to="$MAKEFILE_DIR" "$POTFILE")" - # Compare ignoring POT-Creation-Date - if diff <(remove_potcdate "$POTFILE~") <(remove_potcdate "$POTFILE") - then - mv "$POTFILE~" "$POTFILE" # restore old file if no changes - exit 0 - fi -done - -make -C "$MAKEFILE_DIR" msgmerge-fuzzy diff --git a/schemas/meson.build b/schemas/meson.build new file mode 100644 index 000000000..bf958f072 --- /dev/null +++ b/schemas/meson.build @@ -0,0 +1,32 @@ +schema = files(f'@settings_schema@.gschema.xml') + +glib_compile_schemas_tool = find_program( + [ + 'glib-compile-schemas', + gio_dep.get_variable('glib_compile_schemas', default_value: 'glib-compile-schemas') + ], + dirs: [gio_dep.get_variable('bindir', default_value: bindir)], + required: false, + disabler: true, +) + +schemas_compiled = custom_target( + command: [ + glib_compile_schemas_tool, + '--strict', + '--targetdir=@OUTDIR@', + '@CURRENT_SOURCE_DIR@' + ], + input: schema, + output: 'gschemas.compiled', +) + +check_targets += alias_target('schemas', schemas_compiled) + +schema_copy = fs.copyfile( + schema, + install: true, + install_dir: schema_dir +) + +pack += schema_copy diff --git a/tools/meson-cwd.py b/tools/meson-cwd.py new file mode 100644 index 000000000..5d0a23ca5 --- /dev/null +++ b/tools/meson-cwd.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import argparse +import pathlib +import subprocess +import sys + + +def run(cwd, command, stamp): + result = subprocess.run(command, cwd=cwd) + + if result.returncode == 0 and stamp: + stamp.touch() + + sys.exit(result.returncode) + + +def cli(): + parser = argparse.ArgumentParser() + parser.add_argument('--cwd', type=pathlib.Path, default=pathlib.Path.cwd()) + parser.add_argument('--stamp', type=pathlib.Path) + parser.add_argument('command', nargs='+') + + run(**vars(parser.parse_args())) + + +if __name__ == '__main__': + cli()