forked from keymanapp/keyboards
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·112 lines (94 loc) · 2.67 KB
/
build.sh
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
#!/bin/bash
#
# This script is built with commands available to Git Bash on Windows. (mingw32)
#
# This script and scripts in resources/ should be identical in the
# https://github.com/keymanapp/keyboards and
# https://github.com/keymanapp/keyboards_starter repos
#
function display_usage {
echo "Usage: $0 [-validate] [-codesign] [-start] [-s] [-d] [-c] [-w] [-t project_target] [target]"
exit 1
}
# TODO: Test on macOS as well.
# TODO: Copy the final keyboard_info.json to resources/
#
# Define paths
#
KEYBOARDROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
KMCOMP="$KEYBOARDROOT/tools/kmcomp.exe"
if [[ "${OSTYPE}" != "darwin"* ]]; then
KMCOMP_LAUNCHER=
else
KMCOMP_LAUNCHER=wine
fi
# Master json schema is from https://api.keyman.com/schemas/keyboard_info.json
KEYBOARDINFO_SCHEMA_JSON="$KEYBOARDROOT/tools/keyboard_info.source.json"
KEYBOARDINFO_SCHEMA_DIST_JSON="$KEYBOARDROOT/tools/keyboard_info.distribution.json"
. "$KEYBOARDROOT/resources/util.sh"
. "$KEYBOARDROOT/resources/compile.sh"
. "$KEYBOARDROOT/resources/validate.sh"
. "$KEYBOARDROOT/resources/merge.sh"
#
# Build parameters
#
# Default is validate keyboard_info, build keyboards, don't code-sign
#
parse_args "$@"
#
# Are we in the keyboards_starter repo?
#
if [[ -d "$KEYBOARDROOT/template" ]]; then
if [[ -d "$KEYBOARDROOT/release" ]]; then
die "This repo should not have both a /release/ folder and a /template/ folder. The /template/ folder should be present only in the keyboards_starter repo."
fi
KEYBOARDS_STARTER=1
fi
#
# Select action
#
if [ "$DO_BUILD" = false ]; then
ACTION_VERB=Validating
elif [[ ! -z "$FLAG_CLEAN" ]]; then
ACTION_VERB=Cleaning
else
ACTION_VERB=Building
fi
#
# Collect filenames
#
if [[ $KEYBOARDS_STARTER == 1 ]]; then
KEYBOARD_INFO_PATHS="$KEYBOARDROOT"/*/*/*/*/*.keyboard_info
else
KEYBOARD_INFO_PATHS="$KEYBOARDROOT"/*/*/*/*.keyboard_info
fi
KEYBOARD_INFOS=($KEYBOARD_INFO_PATHS)
KEYBOARD_INFOS=`printf -- '%s\n' "${KEYBOARD_INFOS[@]}"`
#
# Run build
#
if [[ $KEYBOARDS_STARTER == 1 ]]; then
if [[ "$TARGET" ]]; then
build_keyboard "$TARGET"
else
build_keyboards
fi
else
if [[ "$TARGET" ]]; then
if [[ "$TARGET" == */* ]] && [[ (-d "$TARGET") ]]; then
group=$(cut -d / -f 1 <<< "$TARGET")
echo "--- Only building $group $TARGET ---"
build_keyboard $group "$TARGET"
elif [[ "$TARGET" == "release" ]] || [[ "$TARGET" == "legacy" ]] || [[ "$TARGET" == "experimental" ]]; then
# Assuming release|legacy|experimental
echo "--- Only building $TARGET ---"
build_keyboards "$TARGET"
else
display_usage
fi
else
build_keyboards release
build_keyboards legacy
build_keyboards experimental
fi
fi