-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-teensyloader.sh
executable file
·52 lines (43 loc) · 1.75 KB
/
build-teensyloader.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
#!/usr/bin/env bash
# Copyright 2024-2025 Nick Brassel (@tzarc)
# SPDX-License-Identifier: GPL-2.0-or-later
set -eEuo pipefail
this_script=$(realpath "${BASH_SOURCE[0]}")
script_dir=$(dirname "$this_script")
source "$script_dir/common.bashinc"
cd "$script_dir"
build_one_help "$@"
respawn_docker_if_needed "$@"
source_dir="$script_dir/.repos/teensyloader"
pushd "$source_dir" >/dev/null 2>&1
{ patch -f -s -p1 <"$script_dir/support/teensyloader/mods.patch"; } || true
popd >/dev/null 2>&1
for triple in "${triples[@]}"; do
echo
build_dir="$script_dir/.build/$(fn_os_arch_fromtriplet "$triple")/teensyloader"
xroot_dir="$script_dir/.xroot/$(fn_os_arch_fromtriplet "$triple")"
mkdir -p "$build_dir"
echo "Building teensyloader for $triple => $build_dir"
rm -rf "$build_dir/*"
CFLAGS="$(pkg-config --with-path="$xroot_dir/lib/pkgconfig" --static --cflags libusb) -I$script_dir/.repos/hidapi/hidapi -I$script_dir/.repos/hidapi/windows"
LDFLAGS="$(pkg-config --with-path="$xroot_dir/lib/pkgconfig" --static --libs libusb) -L$xroot_dir/lib"
pushd "$source_dir" >/dev/null 2>&1
if [ -n "$(fn_os_arch_fromtriplet $triple | grep windows)" ]; then
OS=WINDOWS
unset SDK
CFLAGS="-static $CFLAGS"
LDFLAGS="-static $LDFLAGS"
elif [ -n "$(fn_os_arch_fromtriplet $triple | grep macos)" ]; then
OS=MACOSX
SDK=/sdk
else
OS=LINUX
unset SDK
CFLAGS="-static $CFLAGS"
LDFLAGS="-static $LDFLAGS"
fi
rcmd make clean
rcmd make -j$(nproc) OBJDIR="$build_dir" CC="${triple}-gcc" OS=${OS:-} SDK=${SDK:-} CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" USE_LIBUSB=YES OUTDIR="$build_dir"
rcmd cp "$build_dir/teensy_loader_cli"* "$xroot_dir/bin"
popd >/dev/null 2>&1
done