forked from Polidea/cmake-nRF5x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.sh
executable file
·70 lines (59 loc) · 2.2 KB
/
prepare.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
#!/bin/bash
set -e
source "${BASH_SOURCE%/*}/common/consts.sh"
source "${BASH_SOURCE%/*}/common/download.sh"
source "${BASH_SOURCE%/*}/common/utils.sh"
# Prepare python
invoke_py3 -m venv "${PYTHON_VENV_DIR}"
source "${PYTHON_VENV_SCRIPT}"
invoke_pip3 install -r "${PYTHON_DIR}/requirements.txt"
# List of SDKs to download
sdks=( "15.3.0" "16.0.0" )
for sdk in "${sdks[@]}"; do
if [[ ! -d "$SDKS_DIR/$sdk" ]]; then
echo "Downloading SDK $sdk..."
download_sdk "$sdk" "$SDKS_DIR/$sdk"
fi
# Clone uECC library if needed
if [[ ! -d "$SDKS_DIR/$sdk/external/micro-ecc/micro-ecc" ]]; then
echo "Cloning uECC lib into SDK ver $sdk..."
pushd "$SDKS_DIR/$sdk/external/micro-ecc"
git clone "https://github.com/kmackay/micro-ecc.git"
popd
fi
# Apply patches if needed
if [[ -d "$PATCHES_DIR/$sdk" ]]; then
sdk_patches=$(find $PATCHES_DIR/$sdk -name "*.diff")
for patch in ${sdk_patches[@]}; do
patch_dir=$(dirname $patch)
sdk_dir="${patch_dir/$PATCHES_DIR/$SDKS_DIR}"
patch_name=$(basename $patch)
patch_file="${patch_name%.diff}"
patch "$sdk_dir/$patch_file" "$patch"
done
fi
done
# Download toolchains
if [[ -d "$TOOLCHAINS_DIR/gcc" ]]; then
echo "GCC toolchain already present, skipping..."
else
download_gcc_toolchain "$TOOLCHAINS_DIR/gcc"
fi
# Check and optionally download nRF tools
if [[ "$OSTYPE" == "cygwin" ]]; then
# nRF5 Command Line Tools for Windows are available only as an .exe installer; expect the user to install them manually
echo "Running on Windows (Cygwin), checking the nRF Command Line Tools available from PATH:"
(check_binary nrfjprog); nrfjprog_found="$?"
(check_binary mergehex); mergehex_found="$?"
if [[ "$nrfjprog_found" -ne 0 ]] || [[ "$mergehex_found" -ne 0 ]]; then
echo "Some of the nRF5 Command Line Tools are missing. Please install the nRF Command Line Tools manually and then re-run this script."
exit 1
fi
else
# Download nRF tools
if [[ -d "$TOOLS_DIR/nrf" ]]; then
echo "nRF Tools already present, skipping..."
else
download_nrf_tools "$TOOLS_DIR/nrf"
fi
fi