Skip to content

Commit 454448b

Browse files
committed
chore: use kmc instead of kmcomp to build test keyboards
1 parent 3a2540b commit 454448b

File tree

7 files changed

+41
-141
lines changed

7 files changed

+41
-141
lines changed

common/test/keyboards/baseline/k_017___space_mnemonic_kbd.kmn

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ c keys: [K_A][K_B][K_SPACE][K_C][K_SPACE][K_D][K_SPACE][K_D][K_E]
44
c expected: XYZ
55

66
store(&VERSION) '9.0'
7-
NAME "Alt key tests"
8-
HOTKEY "[CTRL SHIFT K_A]"
7+
store(&HOTKEY) "[CTRL SHIFT K_A]"
98
store(&mnemoniclayout) "1"
109

1110
begin Unicode > use(main)

common/test/keyboards/baseline/k_018___nul_testing.kmn

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ c Description: Tests the processing of nul in LHS of rules
33
c keys: [K_A][K_A]
44
c expected: OKa
55

6-
VERSION 9.0
7-
NAME "Nul test"
8-
HOTKEY "[CTRL SHIFT K_N]"
6+
store(&VERSION) "9.0"
7+
store(&HOTKEY) "[CTRL SHIFT K_N]"
98

10-
begin unicode > use(main)
9+
begin unicode > use(main)
1110

1211
group(Main) using keys
1312
nul + 'a' > 'OK'

common/test/keyboards/build.sh

Lines changed: 29 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
#!/usr/bin/env bash
2-
3-
set -e
4-
set -u
5-
2+
# TODO: builder script plz
63
## START STANDARD BUILD SCRIPT INCLUDE
74
# adjust relative paths as necessary
85
THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
96
. "${THIS_SCRIPT%/*}/../../../resources/build/build-utils.sh"
10-
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
117
## END STANDARD BUILD SCRIPT INCLUDE
8+
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
129
THIS_DIR="$(dirname "$THIS_SCRIPT")"
1310

1411
display_usage() {
1512
echo "usage: build.sh [build options] [targets]"
1613
echo
1714
echo "Build options:"
18-
echo " --clean, -c Clean instead of build"
1915
echo " --debug, -d Debug build"
2016
echo " --silent, -s Suppress information messages"
21-
echo " --keyboard, -k Build only keyboards (not packages)"
2217
echo " --kmc path Specify path to kmc, defaults"
2318
echo " to developer/src/kmc/build/"
2419
echo " --zip-source Create zip file for source of each"
@@ -29,7 +24,7 @@ display_usage() {
2924

3025
for d in "$THIS_DIR/"*/; do
3126
d="$(basename "$d")"
32-
if [ "$d" != "invalid" ]; then
27+
if [ "$d" != "invalid" && "$d" != "issue"]; then
3328
echo " $d"
3429
fi
3530
done
@@ -38,14 +33,12 @@ display_usage() {
3833
exit 0
3934
}
4035

36+
readonly KMC_LAUNCHER=node
4137
QUIET=false
4238
DEBUG=false
43-
CLEAN=false
44-
KEYBOARDS_ONLY=false
45-
CUSTOM_KMCOMP=
4639
INDEX=false
4740
ZIPSOURCE=false
48-
KMCOMP="$KEYMAN_ROOT/developer/bin/kmcomp.exe"
41+
KMC="$KEYMAN_ROOT/developer/src/kmc/build/src/kmc.js"
4942
TARGETS=()
5043

5144
# Parse args
@@ -57,69 +50,28 @@ while [[ $# -gt 0 ]] ; do
5750
--help|-h|-\?)
5851
display_usage
5952
;;
60-
--clean|-c)
61-
CLEAN=true
62-
;;
6353
--debug|-d)
6454
DEBUG=true
6555
;;
6656
--silent|-s)
6757
QUIET=true
6858
;;
69-
--keyboard|-k)
70-
KEYBOARDS_ONLY=true
71-
;;
7259
--zip-source)
7360
ZIPSOURCE=true
7461
;;
7562
--index)
7663
INDEX=true
7764
;;
78-
--kmcomp)
65+
--kmc)
7966
shift
80-
KMCOMP="$1"
81-
CUSTOM_KMCOMP=true
67+
KMC="$1"
8268
;;
8369
*)
8470
TARGETS+=("$key")
8571
esac
8672
shift
8773
done
8874

89-
# TODO: while this is intended to be cross platform, we
90-
# don't currently have a binary version of kmcomp available
91-
# during Linux and macOS builds, so that will need to be
92-
# manually sourced.
93-
KMCOMP_LAUNCHER=
94-
95-
if ! $CUSTOM_KMCOMP; then
96-
case "${OSTYPE}" in
97-
"cygwin")
98-
;;
99-
"msys")
100-
;;
101-
"darwin"*)
102-
# For Catalina (10.15) onwards, must use wine64
103-
base_macos_ver=10.15
104-
macos_ver=$(sw_vers -productVersion)
105-
if verlt "$macos_ver" "$base_macos_ver"; then
106-
KMCOMP_LAUNCHER=wine
107-
else
108-
# On Catalina, and later versions:
109-
# wine-4.12.1 works; wine-5.0, wine-5.7 do not.
110-
# retrieve these from:
111-
# `brew tap gcenx/wine && brew install --cask --no-quarantine wine-crossover`
112-
# may also need to `sudo spctl --master-disable`
113-
KMCOMP_LAUNCHER=wine64
114-
KMCOMP="$(dirname $KMCOMP)/kmcomp.x64.exe"
115-
fi
116-
;;
117-
*)
118-
KMCOMP_LAUNCHER=wine
119-
;;
120-
esac
121-
fi
122-
12375
# Build list of available targets from subfolders, if none specified
12476
if [ ${#TARGETS[@]} == 0 ]; then
12577
for d in "$THIS_DIR/"*/; do
@@ -132,56 +84,14 @@ fi
13284

13385
if ! $QUIET; then
13486
displayInfo "" \
135-
"CLEAN: $CLEAN" \
13687
"DEBUG: $DEBUG" \
13788
"QUIET: $QUIET" \
138-
"KEYBOARDS_ONLY: $KEYBOARDS_ONLY" \
13989
"TARGETS: ${TARGETS[@]}" \
14090
"ZIPSOURCE: $ZIPSOURCE" \
14191
"INDEX: $INDEX" \
14292
""
14393
fi
14494

145-
clean() {
146-
local kpj="$1.kpj" ss= s=
147-
if $QUIET; then
148-
ss=-ss
149-
s=-s
150-
fi
151-
pushd "$1" > /dev/null
152-
if [ -f build.sh ]; then
153-
./build.sh -c $s
154-
else
155-
$KMCOMP_LAUNCHER "$KMCOMP" -c $ss "$kpj"
156-
fi
157-
popd > /dev/null
158-
}
159-
160-
build() {
161-
local kpj="$1.kpj" d= t= ss= target= s= k=
162-
if $KEYBOARDS_ONLY; then
163-
k=-k
164-
t=-t
165-
target="$1.kmn"
166-
fi
167-
if $DEBUG; then
168-
d=-d
169-
fi
170-
if $QUIET; then
171-
s=-s
172-
ss=-ss
173-
fi
174-
# -w - treat warnings as errors, we'll force this
175-
# -cfc - check filename conventions
176-
pushd "$1" > /dev/null
177-
if [ -f build.sh ]; then
178-
./build.sh $d $k $s
179-
else
180-
$KMCOMP_LAUNCHER "$KMCOMP" $d $ss -w -cfc "$kpj" $t "$target"
181-
fi
182-
popd > /dev/null
183-
}
184-
18595
zipsource() {
18696
local target="$1"
18797
pushd "$1" > /dev/null
@@ -191,35 +101,26 @@ zipsource() {
191101

192102
###
193103

194-
for TARGET in "${TARGETS[@]}"; do
195-
if $CLEAN; then
196-
if ! $QUIET; then
197-
echo
198-
builder_heading "Cleaning target $TARGET"
199-
echo
200-
fi
201-
clean "$TARGET"
202-
else
203-
if ! $QUIET; then
204-
echo
205-
builder_heading "Building target $TARGET"
206-
echo
207-
fi
208-
build "$TARGET"
104+
d=
105+
ss=
106+
if $DEBUG; then
107+
d=-d
108+
fi
109+
if $QUIET; then
110+
ss="--log-level silent"
111+
fi
112+
$KMC_LAUNCHER "$KMC" build $d $ss -w "${TARGETS[@]}"
209113

210-
if $ZIPSOURCE; then
211-
zipsource "$TARGET"
212-
fi
114+
for TARGET in "${TARGETS[@]}"; do
115+
if $ZIPSOURCE; then
116+
zipsource "$TARGET"
213117
fi
214118
done
215119

216120
###
217121

218122
if $INDEX; then
219-
if $CLEAN; then
220-
rm -f "$THIS_DIR/index.html"
221-
else
222-
cat << EOF > "$THIS_DIR/index.html"
123+
cat << EOF > "$THIS_DIR/index.html"
223124
<!DOCTYPE html>
224125
<html>
225126
<head>
@@ -231,19 +132,18 @@ if $INDEX; then
231132
<ul>
232133
EOF
233134

234-
for TARGET in "${TARGETS[@]}"; do
235-
if $ZIPSOURCE; then
236-
echo " <li><a href='$TARGET/build/$TARGET.kmp'>$TARGET.kmp</a> (<a href='$TARGET/${TARGET}_source.zip'>source</a>)</li>" >> "$THIS_DIR/index.html"
237-
else
238-
echo " <li><a href='$TARGET/build/$TARGET.kmp'>$TARGET.kmp</a></li>" >> "$THIS_DIR/index.html"
239-
fi
240-
done
135+
for TARGET in "${TARGETS[@]}"; do
136+
if $ZIPSOURCE; then
137+
echo " <li><a href='$TARGET/build/$TARGET.kmp'>$TARGET.kmp</a> (<a href='$TARGET/${TARGET}_source.zip'>source</a>)</li>" >> "$THIS_DIR/index.html"
138+
else
139+
echo " <li><a href='$TARGET/build/$TARGET.kmp'>$TARGET.kmp</a></li>" >> "$THIS_DIR/index.html"
140+
fi
141+
done
241142

242-
cat << 'EOF' >> "$THIS_DIR/index.html"
143+
cat << 'EOF' >> "$THIS_DIR/index.html"
243144
</ul>
244145
</body>
245146
</html>
246147
EOF
247-
fi
148+
248149
fi
249-
exit 0

common/test/keyboards/obolo_chwerty_6347/source/obolo_chwerty_6347.kps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<ID>obolo_chwerty_6347</ID>
114114
<Version>1.2.1</Version>
115115
<Languages>
116-
<Language ID="ann-Latn">Obolo (Andoni)</Language>
116+
<Language ID="ann">Obolo (Andoni)</Language>
117117
</Languages>
118118
</Keyboard>
119119
</Keyboards>

common/test/keyboards/obolo_chwerty_6351/source/obolo_chwerty_6351.kps

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
<ID>obolo_chwerty_6351</ID>
114114
<Version>1.2.1</Version>
115115
<Languages>
116-
<Language ID="ann-Latn">Obolo (Andoni)</Language>
116+
<Language ID="ann">Obolo (Andoni)</Language>
117117
</Languages>
118118
</Keyboard>
119119
</Keyboards>

developer/src/kmcmplib/tests/fixtures/valid-keyboards/compile_legacy.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
echo Compiles the keyboards using the legacy kmcomp.exe
33
echo to use as baseline comparisons for kmcmplib
44
rem TODO: we'll need a binary download for kmcomp.exe
5+
rem We can use the last version available on downloads.keyman.com
6+
rem see keyboards repo for example of best way to download+extract
57
for %%d in (*.kmn) do ..\..\..\..\..\bin\kmcomp -no-compiler-version -d %%d

developer/src/test/auto/compile-supplementary-support/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# test if KS=1 is in the right files, both in debug and non-debug versions
33
#
44

5-
KMCOMP="..\..\..\..\bin\kmc.cmd" build
6-
KMCOMPD=$(KMCOMP) -d
5+
KMC="..\..\..\..\bin\kmc.cmd" build
6+
KMC_DEBUG=$(KMC) -d
77

88
test: test-nodebug test-debug
99

1010
KMN=i3317_nosupp.kmn i3317_withsupp.kmn i3317_withsupp_incontext.kmn i3317_withsupp_inmatch.kmn i3317_withsupp_innomatch.kmn i3317_withsupp_instore.kmn
1111

1212
# TODO: replace with build.sh script
1313
test-nodebug:
14-
$(KMCOMP) $(KMN)
14+
$(KMC) $(KMN)
1515
findstr /v /m "KS=1" i3317_nosupp.js
1616
findstr /m "KS=1" i3317_withsupp.js
1717
findstr /m "KS=1" i3317_withsupp_incontext.js
@@ -20,7 +20,7 @@ test-nodebug:
2020
findstr /m "KS=1" i3317_withsupp_instore.js
2121

2222
test-debug:
23-
$(KMCOMPD) $(KMN)
23+
$(KMC_DEBUG) $(KMN)
2424
findstr /v /m "KS=1" i3317_nosupp.js
2525
findstr /m "KS=1" i3317_withsupp.js
2626
findstr /m "KS=1" i3317_withsupp_incontext.js

0 commit comments

Comments
 (0)