diff --git a/install_linux.sh b/install_linux.sh new file mode 100755 index 00000000..88e615af --- /dev/null +++ b/install_linux.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +RTT_PYTHON=python + +for p_cmd in python3 python; do + $p_cmd --version >/dev/null 2>&1 || continue + RTT_PYTHON=$p_cmd + break +done + +$RTT_PYTHON --version 2 > /dev/null || { + echo "Python not installed. Please install Python before running the installation script." + exit 1 +} + +if ! [ -x "$(command -v gcc)" ]; then + echo "Installing gcc." + sudo apt install gcc +fi + +if ! [ -x "$(command -v git)" ]; then + echo "Installing git." + sudo apt install git +fi + +if [ $(dpkg-query -W -f='${Status}' libncurses5-dev 2>/dev/null | grep -c "ok installed") -eq 0 ]; then + echo "Installing ncurses." + sudo apt install libncurses5-dev +fi + +$RTT_PYTHON -m pip list > /dev/null || { + echo "Installing pip." + sudo apt install python3-pip +} + +if ! [ -x "$(command -v scons)" ]; then + echo "Installing scons." + sudo apt install scons +fi + +./touch_env.sh diff --git a/install_macos.sh b/install_macos.sh new file mode 100755 index 00000000..7c48b96e --- /dev/null +++ b/install_macos.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +RTT_PYTHON=python + +for p_cmd in python3 python; do + $p_cmd --version >/dev/null 2>&1 || continue + RTT_PYTHON=$p_cmd + break +done + +$RTT_PYTHON --version 2 > /dev/null || { + echo "Python not installed. Please install Python before running the installation script." + exit 1 +} + +if ! [ -x "$(command -v brew)" ]; then + echo "Installing Homebrew." + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +if ! [ -x "$(command -v git)" ]; then + echo "Installing git." + brew install git +fi + +brew list ncurses > /dev/null || { + echo "Installing ncurses." + brew install ncurses +} + +$RTT_PYTHON -m pip list > /dev/null || { + echo "Installing pip." + $RTT_PYTHON -m ensurepip --upgrade +} + +if ! [ -x "$(command -v scons)" ]; then + echo "Installing scons." + $RTT_PYTHON -m pip install scons +fi + +./touch_env.sh diff --git a/touch_env.sh b/touch_env.sh new file mode 100755 index 00000000..06dc864d --- /dev/null +++ b/touch_env.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +DEFAULT_RTT_PACKAGE_URL=https://github.com/RT-Thread/packages.git +# you can change the package url by defining RTT_PACKAGE_URL, ex: +# export RTT_PACKAGE_URL=https://github.com/Varanda-Labs/packages.git + +env_dir=$HOME/.env +if ! [ -d $env_dir ]; then + echo 1 + package_url=${RTT_PACKAGE_URL:-$DEFAULT_RTT_PACKAGE_URL} + mkdir $env_dir + mkdir $env_dir/local_pkgs + mkdir $env_dir/packages + mkdir $env_dir/tools + git clone $package_url $env_dir/packages/packages + echo 'source "$PKGS_DIR/packages/Kconfig"' > $env_dir/packages/Kconfig + git clone https://github.com/RT-Thread/env.git $env_dir/tools/scripts + echo 'export PATH=$HOME/.env/tools/scripts:$PATH' > $env_dir/env.sh +fi