Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions install_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

$RTT_PYTHON = "python"

function Test-Command( [string] $CommandName ) {
(Get-Command $CommandName -ErrorAction SilentlyContinue) -ne $null
}

foreach ($p_cmd in ("python3","python")) {
cmd /c $p_cmd --version | Out-Null
if (!$?) { continue }
$RTT_PYTHON = $p_cmd
break
}

if (!(Test-Command $RTT_PYTHON)) {
echo "Python not installed. Will install python 3.11.2."
echo "Downloading Python."
wget -O Python_setup.exe https://www.python.org/ftp/python/3.11.2/python-3.11.2.exe
echo "Installing Python."
if (Test-Path -Path "D:\") {
cmd /c Python_setup.exe /quiet TargetDir=D:\Progrem\Python311 InstallAllUsers=1 PrependPath=1 Include_test=0
}
else {
cmd /c Python_setup.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
}
}

if (!(Test-Command git)) {
echo "Git not installed. Will install Git."
echo "Installing git."
winget install --id Git.Git -e --source winget
}

cmd /c $RTT_PYTHON -m pip list | Out-Null
if (!$?) {
echo "Installing pip."
cmd /c $RTT_PYTHON -m ensurepip --upgrade
}

cmd /c $RTT_PYTHON -m pip install --upgrade pip | Out-Null

if (!(Test-Command scons)) {
echo "Installing scons."
cmd /c $RTT_PYTHON -m pip install scons
}

cmd /c $RTT_PYTHON -m pip list | findstr "requests" | Out-Null
if (!$?) {
echo "Installing requests."
cmd /c $RTT_PYTHON -m pip install requests
}

$url="https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.ps1"
if ($args[0] -eq "--gitee") {
$url="https://gitee.com/RT-Thread-Mirror/env/raw/master/touch_env.ps1"
}

wget $url -O touch_env.ps1
./touch_env.ps1 $args[0]
25 changes: 25 additions & 0 deletions touch_env.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
$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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前这个功能不支持

$RTT_URL="https://github.com/RT-Thread/rt-thread.git"
$ENV_URL="https://github.com/RT-Thread/env.git"

if ($args[0] -eq "--gitee") {
echo "Using gitee service."
$DEFAULT_RTT_PACKAGE_URL="https://gitee.com/RT-Thread-Mirror/packages.git"
$RTT_URL="https://gitee.com/rtthread/rt-thread.git"
$ENV_URL="https://gitee.com/RT-Thread-Mirror/env.git"
}

$env_dir = "$HOME\.env"
if (!(Test-Path -Path $env_dir)) {
$package_url=$DEFAULT_RTT_PACKAGE_URL
mkdir $env_dir | Out-Null
mkdir $env_dir\local_pkgs | Out-Null
mkdir $env_dir\packages | Out-Null
mkdir $env_dir\tools | Out-Null
git clone $package_url $env_dir/packages/packages
echo 'source "$PKGS_DIR/packages/Kconfig"' > $env_dir/packages/Kconfig
git clone $ENV_URL $env_dir/tools/scripts
echo '$env:path="$HOME\.env\tools\scripts;$env:path"' > $env_dir/env.ps1
}