forked from a7medkhalaf/azan-gnome-shell-extension
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
executable file
·147 lines (137 loc) · 4.88 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#=============================================================================
NAME=athan
UUID=$(NAME)@goodm4ven
BUILDDIR=build
INSTALL_PATH=~/.local/share/gnome-shell/extensions
#=============================================================================
default_target: all
.PHONY: clean all zip install reloadGnome check compile-schemas lint pot uninstall
clean:
@if [ -d $(BUILDDIR) ]; then \
rm -rf $(BUILDDIR); \
fi
@if [ -d po/mo ]; then \
rm -rf po/mo; \
fi
@if [ -f schemas/gschemas.compiled ]; then \
rm schemas/gschemas.compiled; \
fi
@echo "+ Clean done"
check:
@echo "Checking prerequisites..."
@command -v zip >/dev/null 2>&1 || { echo >&2 "glib-compile-schemas is not installed. Aborting."; exit 1; }
@command -v glib-compile-schemas >/dev/null 2>&1 || { echo >&2 "glib-compile-schemas is not installed. Aborting."; exit 1; }
@command -v eslint >/dev/null 2>&1 || { echo >&2 "ESLint is not installed. Aborting."; exit 1; }
@echo "Done."
# Compile the schemas if the directory exists
compile-schemas:
@if [ -d schemas ]; then \
glib-compile-schemas schemas; \
else \
echo "Warning: schemas directory does not exist. Skipping schema compilation."; \
fi
# Lint JavaScript files if the src directory exists
lint: check
@if [ -d src ]; then \
node_modules/.bin/eslint src/**/*.js; \
else \
echo "Warning: src directory does not exist. Skipping linting."; \
fi
# Build the extension
all: clean compile-schemas pot
@if [ -d src ]; then \
mkdir -p $(BUILDDIR)/$(UUID); \
cp src/*.js $(BUILDDIR)/$(UUID)/ || echo "Warning: No JS files found in src."; \
cp src/*.css $(BUILDDIR)/$(UUID)/ || echo "Warning: No CSS files found in src."; \
if [ -f src/metadata.json ]; then \
cp src/metadata.json $(BUILDDIR)/$(UUID)/; \
else \
echo "Error: metadata.json is missing."; \
exit 1; \
fi; \
else \
echo "Error: src directory does not exist. Cannot build the extension."; \
exit 1; \
fi
@if [ -d schemas ]; then \
cp -r schemas $(BUILDDIR)/$(UUID)/; \
glib-compile-schemas $(BUILDDIR)/$(UUID)/schemas; \
fi
@if [ -d po/mo ]; then \
for lang in $$(cat po/mo/LINGUAS); do \
mkdir -p $(BUILDDIR)/$(UUID)/locale/$$lang/LC_MESSAGES; \
cp po/mo/$$lang.mo $(BUILDDIR)/$(UUID)/locale/$$lang/LC_MESSAGES/$(UUID).mo || echo "Warning: Missing translation file for $$lang."; \
done; \
fi
@if [ -d .github/images ]; then \
cp -r .github/images $(BUILDDIR)/$(UUID)/images; \
else \
echo "Warning: .github/images directory does not exist. Skipping images."; \
fi
@echo "+ Build done"
# Create a ZIP file for the GNOME extension
zip: all
@if [ -d $(BUILDDIR)/$(UUID) ]; then \
cd $(BUILDDIR)/$(UUID) && \
gnome-extensions pack -f \
--extra-source=schemas \
--extra-source=schemas/gschemas.compiled \
--extra-source=locale \
--extra-source=images \
--extra-source=HijriCalendarKuwaiti.js \
--extra-source=PrayTimes.js \
--extra-source=stylesheet.css \
--out-dir=../; \
echo "+ Initial zip creation done"; \
# Move gschemas.compiled into the schemas folder inside the zip \
unzip ../$(UUID).shell-extension.zip -d ../temp_zip; \
mv ../temp_zip/gschemas.compiled ../temp_zip/schemas/; \
cd ../temp_zip && zip -r ../final_$(UUID).shell-extension.zip .; \
cd .. && rm -rf temp_zip; \
rm $(UUID).shell-extension.zip; \
mv final_$(UUID).shell-extension.zip $(UUID).shell-extension.zip; \
echo "+ Final zip file fixed"; \
else \
echo "Error: Build directory does not exist. Cannot create ZIP."; \
exit 1; \
fi
# Uninstall the extension
uninstall:
@if [ -d $(INSTALL_PATH)/$(UUID) ]; then \
rm -rf $(INSTALL_PATH)/$(UUID); \
echo "+ Uninstallation done"; \
else \
echo "Warning: Extension is not installed."; \
fi
# Install the extension
install: uninstall zip
@if [ -f $(BUILDDIR)/$(UUID).shell-extension.zip ]; then \
gnome-extensions install -f $(BUILDDIR)/$(UUID).shell-extension.zip; \
echo "+ Installation done"; \
else \
echo "Error: ZIP file does not exist. Cannot install."; \
exit 1; \
fi
# Reload GNOME Shell
reloadGnome:
@dbus-send --type=method_call --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'global.reexec_self()' || \
{ echo "Failed to reload GNOME Shell. Please restart it manually."; exit 1; }
# Update translation files if translation directory exists
pot:
@if [ -d po ]; then \
rm -f po/LINGUAS; \
for l in $$(ls po/*.po); do basename $$l .po >> po/LINGUAS; done; \
mkdir -p po/mo; \
cp po/LINGUAS po/mo/LINGUAS; \
cd po && \
for lang in $$(cat LINGUAS); do \
mv $${lang}.po $${lang}.po.old; \
msginit --no-translator --locale=$$lang --input $(UUID).pot -o $${lang}.po.new > /dev/null; \
msgmerge -N $${lang}.po.old $${lang}.po.new > $${lang}.po; \
rm $${lang}.po.old $${lang}.po.new; \
msgfmt -o mo/$${lang}.mo $${lang}.po; \
done; \
echo "+ POT file generation done"; \
else \
echo "Warning: po directory does not exist. Skipping translation updates."; \
fi