Repository navigation
Expand file tree
/
Copy pathbuild_binary.sh
More file actions
executable file
·62 lines (55 loc) · 1.73 KB
/
Copy pathbuild_binary.sh
File metadata and controls
executable file
·62 lines (55 loc) · 1.73 KB
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
#!/usr/bin/env bash
# Compiles the generator into a single self-contained executable.
#
# The result needs no Dart SDK to run, which is what makes it usable from a
# GitHub Actions step, a Makefile, or anyone's PATH.
#
# tool/build_binary.sh # for this machine
# tool/build_binary.sh --output bin/vfg # somewhere else
# tool/build_binary.sh --target-os linux --target-arch arm64
#
# The only platforms Dart can cross compile to are the other Linux
# architectures, whatever the host is; a Windows or macOS binary has to be built
# on Windows or macOS. Naming the host's own platform is a no-op, so it is safe
# to pass the target through unconditionally.
set -euo pipefail
output=''
target_os=''
target_arch=''
while [ $# -gt 0 ]; do
case "$1" in
-o|--output) output="$2"; shift 2 ;;
--target-os) target_os="$2"; shift 2 ;;
--target-arch) target_arch="$2"; shift 2 ;;
-h|--help)
awk 'NR > 1 && /^#/ { sub(/^# ?/, ""); print; next } NR > 1 { exit }' "$0"
exit 0
;;
*) echo "$0: unknown argument $1" >&2; exit 64 ;;
esac
done
cd "$(dirname "$0")/.."
repository="$PWD"
if [ -z "$output" ]; then
suffix=''
case "${target_os:-$(uname -s)}" in
windows|MINGW*|MSYS*|CYGWIN*) suffix='.exe' ;;
esac
output="$repository/build/bin/variable_font_generator$suffix"
fi
case "$output" in
/*|[A-Za-z]:*) ;;
*) output="$PWD/$output" ;;
esac
mkdir -p "$(dirname "$output")"
arguments=(bin/variable_font_generator.dart -o "$output")
if [ -n "$target_os" ]; then
arguments+=(--target-os "$target_os")
fi
if [ -n "$target_arch" ]; then
arguments+=(--target-arch "$target_arch")
fi
cd packages/variable_font_generator
dart pub get
dart compile exe "${arguments[@]}"
echo "$output"