Makefile

.PHONY: check install restart package translations update

PACKAGE_FILES := metadata.json contents docs/codexbar-plasma-overview.png docs/codexbar-plasma-codex.png scripts/update-widget.sh LICENSE NOTICE.md README.md

# Override on distros where Qt6 ships QML modules elsewhere (e.g. Debian/Ubuntu
# multiarch: make check QML_IMPORT_DIR=/usr/lib/x86_64-linux-gnu/qt6/qml).
QMLLINT ?= /usr/lib/qt6/bin/qmllint
QML_IMPORT_DIR ?= /usr/lib/qt6/qml
# Extra qmllint flags. CI without the Plasma QML modules sets these to downgrade
# the type/import-resolution categories that would otherwise cascade into
# failures; locally (modules present) they are no-ops, so the check stays full.
QMLLINT_FLAGS ?= --unqualified disable
QML_FILES := \
	contents/ui/main.qml \
	contents/ui/configGeneral.qml \
	contents/ui/configProviders.qml \
	contents/ui/configDisplay.qml \
	contents/ui/configAdvanced.qml \
	contents/ui/configDebug.qml \
	contents/ui/components/CompactRepresentation.qml \
	contents/ui/components/OverviewProviderRow.qml \
	contents/ui/components/ProviderAccountsPanel.qml \
	contents/ui/components/ProviderConfigRow.qml \
	contents/ui/components/ProviderHeader.qml \
	contents/ui/components/ProviderUsageRow.qml

check:
	scripts/test_feature_parity.sh
	scripts/test_refresh_nonce.sh
	scripts/test_process_lifecycle.sh
	scripts/test_ui_regressions.sh
	scripts/test_provider_icons.sh
	scripts/test_security_regressions.sh
	scripts/test_update_widget.sh
	scripts/test_theme_boundaries.sh
	scripts/test_i18n_catalog.sh
	scripts/test_cli_descriptor_contract.sh
	scripts/test_qml_hardening.sh
	$(QMLLINT) $(QMLLINT_FLAGS) -I $(QML_IMPORT_DIR) $(QML_FILES)
	xmllint --noout contents/config/main.xml
	jq . metadata.json >/dev/null
	@if command -v kpackagetool6 >/dev/null 2>&1; then \
		kpackagetool6 --appstream-metainfo . | xmllint --noout -; \
	else \
		echo "kpackagetool6 not found; skipping appstream metainfo check"; \
	fi

install:
	kpackagetool6 -t Plasma/Applet -u . || kpackagetool6 -t Plasma/Applet -i .

restart:
	systemctl --user restart plasma-plasmashell.service

update:
	scripts/update-widget.sh --install

translations:
	scripts/update_translations.sh

package:
	mkdir -p dist
	rm -f dist/codexbar-plasma.plasmoid
	@if find $(PACKAGE_FILES) -type l -print -quit | grep -q .; then \
		echo "refusing to package symlinks from PACKAGE_FILES" >&2; \
		find $(PACKAGE_FILES) -type l -print >&2; \
		exit 1; \
	fi
	@if command -v cmake >/dev/null 2>&1; then \
		cmake -E tar cf dist/codexbar-plasma.plasmoid --format=zip $(PACKAGE_FILES); \
	elif command -v zip >/dev/null 2>&1; then \
		zip -qr dist/codexbar-plasma.plasmoid $(PACKAGE_FILES); \
	elif command -v python3 >/dev/null 2>&1; then \
		python3 -m zipfile -c dist/codexbar-plasma.plasmoid $(PACKAGE_FILES); \
	else \
		echo "missing required command: cmake, zip, or python3" >&2; \
		exit 127; \
	fi