2020-05-13 12:00:38 +00:00
|
|
|
#!/usr/bin/env pwsh
|
2019-08-27 05:45:50 +00:00
|
|
|
$IDF_PATH = $PSScriptRoot
|
|
|
|
|
|
|
|
Write-Output "Setting IDF_PATH: $IDF_PATH"
|
|
|
|
$env:IDF_PATH=$IDF_PATH
|
|
|
|
|
|
|
|
Write-Output "Adding ESP-IDF tools to PATH..."
|
2020-05-13 12:00:38 +00:00
|
|
|
$OLD_PATH=$env:PATH.split([IO.Path]::PathSeparator) | Select-Object -Unique # array without duplicates
|
2019-08-27 05:45:50 +00:00
|
|
|
# using idf_tools.py to get $envars_array to set
|
2020-05-13 12:00:38 +00:00
|
|
|
$envars_raw = python $IDF_PATH/tools/idf_tools.py export --format key-value
|
2019-08-27 05:45:50 +00:00
|
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # if error
|
|
|
|
|
2020-05-13 12:00:38 +00:00
|
|
|
$envars_array # will be filled like:
|
2019-08-27 05:45:50 +00:00
|
|
|
# [
|
|
|
|
# [vname1, vval1], [vname2, vval2], ...
|
|
|
|
# ]
|
|
|
|
foreach ($line in $envars_raw)
|
|
|
|
{
|
|
|
|
$pair = $line.split("=") # split in name, val
|
|
|
|
$var_name = $pair[0].Trim() # trim spaces on the ends of the name
|
|
|
|
$var_val = $pair[1].Trim() # trim spaces on the ends of the val
|
|
|
|
$envars_array+=(,($var_name, $var_val))
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($pair in $envars_array) # setting the values
|
|
|
|
{
|
|
|
|
$var_name = $pair[0].Trim() # trim spaces on the ends of the name
|
|
|
|
$var_val = $pair[1].Trim() # trim spaces on the ends of the val
|
2020-05-13 12:00:38 +00:00
|
|
|
if ($var_name -eq "PATH"){
|
|
|
|
# trim "%PATH%" or "`$PATH"
|
|
|
|
if($IsWindows){
|
|
|
|
$var_val = $var_val.Trim([IO.Path]::PathSeparator + "%PATH%")
|
|
|
|
}else{
|
|
|
|
$var_val = $var_val.Trim([IO.Path]::PathSeparator + "`$PATH")
|
|
|
|
}
|
|
|
|
# apply
|
|
|
|
$env:PATH = $var_val + [IO.Path]::PathSeparator + $env:PATH
|
|
|
|
} else {
|
|
|
|
New-Item -Path "env:$var_name" -Value "$var_val"
|
|
|
|
}
|
2019-08-27 05:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#Compare Path's OLD vs. NEW
|
2020-05-13 12:00:38 +00:00
|
|
|
$NEW_PATH = $env:PATH.split([IO.Path]::PathSeparator) | Select-Object -Unique # array without duplicates
|
2019-08-27 05:45:50 +00:00
|
|
|
$dif_Path = Compare-Object -ReferenceObject $OLD_PATH -DifferenceObject $NEW_PATH -PassThru
|
|
|
|
if ($dif_Path -ne $null)
|
|
|
|
{
|
|
|
|
Write-Output $dif_Path
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Output "No directories added to PATH:"
|
|
|
|
Write-Output $OLD_PATH
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Write-Output "Checking if Python packages are up to date..."
|
|
|
|
|
|
|
|
Start-Process -Wait -NoNewWindow -FilePath "python" -Args "$IDF_PATH/tools/check_python_dependencies.py"
|
|
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } # if error
|
|
|
|
|
|
|
|
Write-Output "
|
|
|
|
Done! You can now compile ESP-IDF projects.
|
|
|
|
Go to the project directory and run:
|
|
|
|
idf.py build
|
|
|
|
|
|
|
|
"
|