-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall_fused_script.sh
executable file
·75 lines (63 loc) · 2.22 KB
/
install_fused_script.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
#!/usr/bin/env bash
# Project details (can be moved to a separate configuration file)
PROJECT_URL="https://github.com/rafayy769/fused-checkmate.git"
CMAKE_VERSION="3.15.4" # Update to the latest stable version
TOOLCHAIN_DIR="${HOME}/.local"
# Parse command line arguments
while getopts ":cbipth" opt; do
case "$opt" in
c) clone_repo=true ;;
b) build_deps=true ;;
i) install_cmake=true ;;
p) project_deps=true ;;
t) set_env_vars=true ;;
h)
echo "Usage: ./script.sh [-cbipt]"
echo " -c Clone the Git repository"
echo " -b Install build dependencies"
echo " -i Install CMake"
echo " -p Install toolchain and project dependencies"
echo " -t Set environment variables"
exit 0 ;;
\?)
echo "Invalid option: -$OPTARG"
exit 1 ;;
esac
done
# Default values
clone_repo="${clone_repo:-true}"
build_deps="${build_deps:-true}"
install_cmake="${install_cmake:-true}"
project_deps="${project_deps:-true}"
set_env_vars="${set_env_vars:-true}"
# Perform actions based on command line arguments
if "$clone_repo"; then
git clone "$PROJECT_URL" || exit 1
cd fused-checkmate
fi
if "$build_deps"; then
sudo apt install libboost-dev build-essential g++ ninja-build git gdb libncurses5 libncursesw5 libtinfo5 libpython2.7 || exit 1
fi
if "$install_cmake"; then
wget https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-Linux-x86_64.sh || exit 1
chmod +x cmake-$CMAKE_VERSION-Linux-x86_64.sh
sudo ./cmake-$CMAKE_VERSION-Linux-x86_64.sh --skip-license --prefix=/usr/local || exit 1
rm cmake-$CMAKE_VERSION-Linux-x86_64.sh
fi
if "$project_deps"; then
mkdir build && cd build
cmake .. -GNinja -DINSTALL_DEPENDENCIES=ON -DINSTALL_TARGET_TOOLCHAINS=ON
ninja|| exit 1
fi
if "$set_env_vars"; then
echo "** This step sets environment variables. Proceed with caution if unsure. **"
export ARM_GCC_ROOT="${TOOLCHAIN_DIR}/arm-gcc"
export MSP430_GCC_ROOT="${TOOLCHAIN_DIR}/msp430-gcc"
export MSP430_INC="${TOOLCHAIN_DIR}/msp430-inc"
export PATH="${TOOLCHAIN_DIR}/msp430-gcc/bin:$PATH"
export PATH="${TOOLCHAIN_DIR}/arm-gcc/bin:$PATH"
fi
# in fused/build
cmake .. -GNinja -DINSTALL_DEPENDENCIES=OFF
ninja
echo "Script completed."