-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
98 lines (82 loc) · 3.63 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# SPDX-FileCopyrightText: Simon Schneegans <[email protected]>
# SPDX-License-Identifier: MIT
SHELL := /bin/bash
# We define these here to make the makefile easier to port to another extension.
NAME := flypie
DOMAIN := schneegans.github.com
ZIP_NAME := $(NAME)@$(DOMAIN).zip
# Some of the recipes below depend on some of these files.
JS_FILES = $(shell find -type f -and \( -name "*.js" \))
UI_FILES = $(shell find -type f -and \( -name "*.ui" \))
RESOURCE_FILES = $(shell find resources -mindepth 2 -type f)
LOCALES_PO = $(wildcard po/*.po)
LOCALES_MO = $(patsubst po/%.po,locale/%/LC_MESSAGES/$(NAME).mo,$(LOCALES_PO))
# These files will be included in the extension zip file.
ZIP_CONTENT = $(JS_FILES) $(LOCALES_MO) resources/$(NAME).gresource \
schemas/org.gnome.shell.extensions.$(NAME).gschema.xml \
presets metadata.json LICENSE
# These five recipes can be invoked by the user.
.PHONY: zip install uninstall pot clean test
# The zip recipes only bundles the extension without installing it.
zip: $(ZIP_NAME)
# The install recipes creates the extension zip and installs it.
install: $(ZIP_NAME)
gnome-extensions install "$(ZIP_NAME)" --force
@echo "Extension installed successfully! Now restart the Shell ('Alt'+'F2', then 'r')."
# This uninstalls the previously installed extension.
uninstall:
gnome-extensions uninstall "$(NAME)@$(DOMAIN)"
# Use gettext to generate a translation template file.
pot: $(JS_FILES) $(UI_FILES)
@echo "Generating '$(NAME).pot'..."
@xgettext --from-code=UTF-8 \
--add-comments=Translators \
--copyright-holder="Simon Schneegans" \
--package-name="$(NAME)" \
--output=po/$(NAME).pot \
$(JS_FILES) $(UI_FILES)
# This removes all temporary files created with the other recipes.
clean:
rm -rf $(ZIP_NAME) \
resources/$(NAME).gresource \
resources/$(NAME).gresource.xml \
schemas/gschemas.compiled \
locale
test:
@ for version in 39 ; do \
for session in "gnome-xsession" "gnome-wayland-nested" ; do \
echo ; \
echo "Running Tests on Fedora $$version ($$session)." ; \
echo ; \
./tests/run-test.sh -s $$session -v $$version ; \
done \
done
# This bundles the extension and checks whether it is small enough to be uploaded to
# extensions.gnome.org. We do not use "gnome-extensions pack" for this, as this is not
# readily available on the GitHub runners.
$(ZIP_NAME): $(ZIP_CONTENT)
@echo "Packing zip file..."
@rm --force $(ZIP_NAME)
@zip -r $(ZIP_NAME) -- $(ZIP_CONTENT)
@#Check if the zip size is too big to be uploaded
@SIZE=$$(unzip -Zt $(ZIP_NAME) | awk '{print $$3}') ; \
if [[ $$SIZE -gt 5242880 ]]; then \
echo "ERROR! The extension is too big to be uploaded to" \
"the extensions website, keep it smaller than 5 MB!"; \
exit 1; \
fi
# Compiles the gresource file from the gresources.xml.
resources/$(NAME).gresource: resources/$(NAME).gresource.xml
@echo "Compiling resources..."
@glib-compile-resources --sourcedir="resources" --generate resources/$(NAME).gresource.xml
# Generates the gresources.xml based on all files in the resources subdirectory.
resources/$(NAME).gresource.xml: $(RESOURCE_FILES)
@echo "Creating resources xml..."
@FILES=$$(find "resources" -mindepth 2 -type f -printf "%P\n" | xargs -i echo "<file>{}</file>") ; \
echo "<?xml version='1.0' encoding='UTF-8'?><gresources><gresource> $$FILES </gresource></gresources>" \
> resources/$(NAME).gresource.xml
# Compiles all *.po files to *.mo files.
locale/%/LC_MESSAGES/$(NAME).mo: po/%.po
@echo "Compiling $@"
@mkdir -p locale/$*/LC_MESSAGES
@msgfmt -c -o $@ $<