Skip to content

Commit 01916fc

Browse files
committed
chore(build): Improvements to build scripts
1 parent 34b2b01 commit 01916fc

File tree

6 files changed

+45
-42
lines changed

6 files changed

+45
-42
lines changed

Makefile

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,14 @@ sources = src/*.ts *.css
2828
all: depcheck compile
2929

3030
clean:
31-
rm -rf _build schemas/gschemas.compiled target
32-
33-
transpile: $(sources) clean
34-
tsc
35-
for proj in $(PROJECTS); do tsc --p src/$${proj}; done
31+
rm -rf _build target
3632

3733
# Configure local settings on system
3834
configure:
39-
if ! command -v gnome-extensions >/dev/null; then \
40-
echo 'You must install gnome-extensions to configure or enable via this script' \
41-
'(`gnome-shell` on Debian systems, `gnome-extensions` on openSUSE systems.)'; \
42-
exit 1; \
43-
fi
4435
sh scripts/configure.sh
4536

46-
convert: transpile
47-
sh scripts/transpile.sh
48-
49-
compile: convert metadata.json schemas
50-
rm -rf _build
51-
mkdir -p _build
52-
cp -r metadata.json icons schemas target/*.js *.css _build
53-
for proj in $(PROJECTS); do \
54-
mkdir -p _build/$${proj}; \
55-
cp -r target/$${proj}/*.js _build/$${proj}; \
56-
done
37+
compile: $(sources) clean
38+
env PROJECTS="$(PROJECTS)" sh scripts/transpile.sh
5739

5840
# Rebuild, install, reconfigure local settings, restart shell, and listen to journalctl logs
5941
debug: depcheck compile install install-system76-plugins configure enable restart-shell listen
@@ -75,7 +57,7 @@ disable:
7557
listen:
7658
journalctl -o cat -n 0 -f "$$(which gnome-shell)" | grep -v warning
7759

78-
local-install: depcheck compile install configure restart-shell enable
60+
local-install: depcheck compile install install-system76-plugins configure enable restart-shell
7961

8062
install:
8163
rm -rf $(INSTALLBASE)/$(INSTALLNAME)
@@ -107,12 +89,5 @@ update-repository:
10789
git reset --hard origin/master
10890
git clean -fd
10991

110-
schemas: schemas/gschemas.compiled
111-
touch $@
112-
113-
schemas/gschemas.compiled: schemas/*.gschema.xml
114-
glib-compile-schemas schemas
115-
11692
zip-file: all
11793
cd _build && zip -qr "../$(UUID)_$(VERSION).zip" .
118-

scripts/configure.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ set_keybindings() {
9898
dconf write ${KEYS_GNOME_WM}/close "['<Super>q', '<Alt>F4']"
9999
}
100100

101+
if ! command -v gnome-extensions >/dev/null; then
102+
echo 'You must install gnome-extensions to configure or enable via this script'
103+
'(`gnome-shell` on Debian systems, `gnome-extensions` on openSUSE systems.)'
104+
exit 1
105+
fi
106+
101107
set_keybindings
102108

103109
# Use a window placement behavior which works better for tiling

scripts/transpile.sh

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
11
#!/bin/sh
2+
set -ex
23

3-
for file in $(find target -name '*.js'); do
4-
sed -i \
5-
-e 's#export function#function#g' \
4+
pwd=$(pwd)
5+
6+
# In goes standard JS. Out comes GJS-compatible JS
7+
transpile() {
8+
cat ${src} | sed -e 's#export function#function#g' \
69
-e 's#export var#var#g' \
710
-e 's#export const#var#g' \
811
-e 's#Object.defineProperty(exports, "__esModule", { value: true });#var exports = {};#g' \
9-
"${file}"
10-
sed -i -E 's/export class (\w+)/var \1 = class \1/g' "${file}"
11-
sed -i -E "s/import \* as (\w+) from '(\w+)'/const \1 = Me.imports.\2/g" "${file}"
12-
done
12+
| sed -E 's/export class (\w+)/var \1 = class \1/g' \
13+
| sed -E "s/import \* as (\w+) from '(\w+)'/const \1 = Me.imports.\2/g" > ${dest}
14+
}
15+
16+
rm -rf _build
17+
18+
glib-compile-schemas schemas &
19+
20+
# Transpile to JavaScript
21+
22+
for proj in ${PROJECTS}; do
23+
mkdir -p _build/${proj}
24+
tsc --p src/${proj} &
25+
done
26+
27+
tsc &
28+
29+
wait
30+
31+
# Convert JS to GJS-compatible scripts
32+
33+
cp -r metadata.json icons schemas *.css _build &
34+
35+
for src in $(find target -name '*.js'); do
36+
dest=$(echo $src | sed s#target#_build#g)
37+
transpile &
38+
done
39+
40+
wait

src/color_dialog/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"es2015"
1111
],
1212
"pretty": true,
13-
"sourceMap": true,
14-
"declaration": true,
1513
"removeComments": true,
1614
"incremental": true,
1715
"noUnusedLocals": true,

src/floating_exceptions/tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"es2015"
1111
],
1212
"pretty": true,
13-
"sourceMap": true,
14-
"declaration": true,
1513
"removeComments": true,
1614
"incremental": true,
1715
},

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
"es2015"
1212
],
1313
"pretty": true,
14-
"sourceMap": true,
15-
"declaration": true,
1614
"removeComments": true,
1715
"incremental": true,
1816
"noUnusedLocals": true,

0 commit comments

Comments
 (0)