forked from keymanapp/lexical-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·101 lines (84 loc) · 2.44 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
#!/bin/bash
# Build lexical models
# Set sensible script defaults:
# set -e: Terminate script if a command returns an error
set -e
# set -u: Terminate script if an unset variable is used
set -u
#
# This script is built with commands available to Git Bash on Windows. (mingw32)
#
function display_usage {
echo "Usage: $0 [-t(est)|-b(uild)|-c(lean)] [-no-npm] [-s] [target]"
echo " -t || -test Runs tests on models"
echo " -b || -build Creates compiled models"
echo " -c || -clean Cleans intermediate and output files"
echo " -no-npm Skip all npm steps"
echo " -s Quiet build"
echo " target The specific model(s) to build, e.g. release or release/example/en.template"
echo " If omitted, builds all models"
exit 1
}
#
# Define paths
#
MODELROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Master json schema is from https://api.keyman.com/schemas/model_info.json
MODELINFO_SCHEMA_JSON="$MODELROOT/tools/model_info.source.json"
MODELINFO_SCHEMA_DIST_JSON="$MODELROOT/tools/model_info.distribution.json"
. "$MODELROOT/resources/util.sh"
. "$MODELROOT/resources/compile.sh"
#. "$MODELROOT/resources/validate.sh"
#. "$MODELROOT/resources/merge.sh"
#
# Build parameters
#
# Default is validate model_info, build models
#
parse_args "$@"
if [[ "$DO_NPM" = true ]]; then
# Check if Node.JS/npm is installed.
type npm >/dev/null ||\
die "Build environment setup error detected! Please ensure Node.js is installed!"
#
# Pull dependencies
#
echo "Dependencies check"
npm install --no-optional
fi
#
# Select action
#
if [ "$DO_BUILD" = false ]; then
ACTION_VERB=Testing
elif [[ ! -z "$FLAG_CLEAN" ]]; then
ACTION_VERB=Cleaning
else
ACTION_VERB=Building
fi
#
# Collect filenames
#
MODEL_INFO_PATHS="$MODELROOT"/*/*/*/*.model_info
MODEL_INFOS=($MODEL_INFO_PATHS)
MODEL_INFOS=`printf -- '%s\n' "${MODEL_INFOS[@]}"`
#
# Run build
#
if [[ "$TARGET" ]]; then
if [[ "$TARGET" == */* ]] && [[ (-d "$TARGET") ]]; then
group=$(cut -d / -f 1 <<< "$TARGET")
echo "--- Only building $group $TARGET ---"
build_model $group "$TARGET"
elif [[ "$TARGET" == "release" ]] || [[ "$TARGET" == "experimental" ]] || [[ "$TARGET" == "sample" ]]; then
# Assuming release|experimental
echo "--- Only building $TARGET ---"
build_models "$TARGET"
else
display_usage
fi
else
build_models release
build_models experimental
fi
# todo copy multi-folder approach from keyboards repo