Skip to content

Commit

Permalink
Pull request project-chip#49: fixed bugs in windows setup script, and…
Browse files Browse the repository at this point in the history
… modified other related scripts

Merge in WMN_TOOLS/matter from windows_support to silabs

Squashed commit of the following:

commit 637199bc57b72f6d0c38ac5e5fbc369313ab79d1
Author: Hussein Elsherbini <[email protected]>
Date:   Wed Aug 17 13:30:45 2022 -0400

    fixed bugs in windows setup script, and modified other related scripts
  • Loading branch information
HusseinElsherbini authored and jmartinez-silabs committed Aug 17, 2022
1 parent d49b6f1 commit efb8612
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 42 deletions.
22 changes: 2 additions & 20 deletions scripts/bootstrap.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
$_PW_BANNER = "
▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄
▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌
▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌
▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌
▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀
"

###########################################################################################
# function: Invoke-CmdScript #
# Purpose: when a batch file is invoked within a powershell script, it is started in a #
Expand Down Expand Up @@ -309,25 +302,15 @@ function bootstrap_or_activate($arguments) {
check_for_git
if ($BOOTSTRAP_NAME -eq "bootstrap.ps1" -Or $directoryInfo.count -eq 0) {
try {
git config --system core.longpaths true
git submodule update --init
}
catch {
throw "bootsrapping failed with error code $LASTEXITCODE"
}
}

"
▄ █ ▄ █ ▌
▀▀█████▀▀ ▄▓▀▀▀▄,▄▀▀▀▀▄ ╓▄▀▀▀▀▄█ ▀▀█▀▀▀▀▀█▀▀ ,▄▀▀▀▀▄ ▄▀▀
▀█▄ ▄█▀ █ █ █ ▐▌ █ █ █ .█▄▄▄▄▄▄█⌐ ▐▌
▀█▄ ▄█▀ █ █ █ ▐▌ █ █ █ █ ▐▌
▄██▀▀█ █▀▀██▄ █ █ █ ╙▀▄▄▄Φ▀█ ▀▄▄ ▀▄▄ ▀▄▄▄▄▀^ ▐▌
▀▀ █ █ ▀▀

"
New-Item -Path Env:\PW_PROJECT_ROOT -Value "$Global:PROJECT_ROOT_DIR" -ErrorAction SilentlyContinue > $null
New-Item -Path Env:\PW_ROOT -Value "$Global:PROJECT_ROOT_DIR\third_party\pigweed\repo" -ErrorAction SilentlyContinue > $null
New-Item -Path Env:\PW_ACTIVATE_SKIP_CHECKS -Value '1' -ErrorAction SilentlyContinue > $null
Expand Down Expand Up @@ -356,7 +339,6 @@ function bootstrap_or_activate($arguments) {

try {

$_PW_BANNER_FUNC = "_pw_banner"
bootstrap_or_activate $args
}
catch {
Expand Down
3 changes: 2 additions & 1 deletion scripts/examples/gn_efr32_example.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ try {
$Global:BOARD = ""
$Global:optArgs = ""
$Global:USE_WIFI = $false

$env:Path = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)

check_args $args
. "$Global:PROJECT_ROOT_DIR\scripts\bootstrap.ps1"
generate_binaries
Expand Down
55 changes: 34 additions & 21 deletions scripts/windows_setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Cflags: -I${includedir} '
###########################################################################################
function clean_up_env() {

$path = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
$path = ($path.Split(';') | Where-Object { $_ -ne "$Global:PROJECT_ROOT_DIR\dependencies\bin" }) -join ';'
$path = ($path.Split(';') | Where-Object { $_ -ne "$Global:PROJECT_ROOT_DIR\dependencies" }) -join ';'
[Environment]::SetEnvironmentVariable("Path", $path , "Machine")

if (Test-Path env:PKG_CONFIG_PATH) {

Remove-Item Env:\PKG_CONFIG_PATH
Expand Down Expand Up @@ -61,14 +66,14 @@ function install_dependencies() {
(New-Object Net.WebClient).DownloadFile($pkgConfigUrl, $pkgConfigDownloadFolder)
}
catch {
{ "Net.WebClient.DownloadFile Object method exited with error code $LASTEXITCODE" }
{ "Net.WebClient.DownloadFile Object method exited with error code $LastExitCode" }
}

try {
Expand-Archive -LiteralPath $pkgConfigDownloadFolder -DestinationPath $binFolderPath -Force | Out-Null
}
catch {
{ "error code $LASTEXITCODE" }
{ "error code $LastExitCode" }

}

Expand All @@ -80,14 +85,14 @@ function install_dependencies() {
(New-Object Net.WebClient).DownloadFile($glibUrl, $glibDownloadFolder)
}
catch {
{ "Net.WebClient.DownloadFile Object method exited with error code $LASTEXITCODE" }
{ "Net.WebClient.DownloadFile Object method exited with error code $LastExitCode" }
}

try {
Expand-Archive -LiteralPath $glibDownloadFolder -DestinationPath $binFolderPath -Force | Out-Null
}
catch {
{ "error code $LASTEXITCODE" }
{ "error code $LastExitCode" }
}


Expand All @@ -98,14 +103,14 @@ function install_dependencies() {
(New-Object Net.WebClient).DownloadFile($getTextRuntimeUrl, $getTextRuntimeDownloadFolder)
}
catch {
{ "Net.WebClient.DownloadFile Object method exited with error code $LASTEXITCODE" }
{ "Net.WebClient.DownloadFile Object method exited with error code $LastExitCode" }
}

try {
Expand-Archive -LiteralPath $getTextRuntimeDownloadFolder -DestinationPath $binFolderPath -Force | Out-Null
}
catch {
{ "error code $LASTEXITCODE" }
{ "error code $LastExitCode" }
}


Expand All @@ -116,14 +121,14 @@ function install_dependencies() {
(New-Object Net.WebClient).DownloadFile($ninjaDownloadUrl, $ninjaDownloadFolder)
}
catch {
{ "Net.WebClient.DownloadFile Object method exited with error code $LASTEXITCODE" }
{ "Net.WebClient.DownloadFile Object method exited with error code $LastExitCode" }
}

try {
Expand-Archive -LiteralPath $ninjaDownloadFolder -DestinationPath $binFolderPath -Force | Out-Null
}
catch {
{ "error code $LASTEXITCODE" }
{ "error code $LastExitCode" }
}
}
if (!(Test-Path -Path "$binFolderPath\gn.exe" -PathType Leaf)) {
Expand All @@ -132,37 +137,39 @@ function install_dependencies() {
(New-Object Net.WebClient).DownloadFile($gnDownloadUrl, $gnDownloadFolder)
}
catch {
{ "Net.WebClient.DownloadFile Object method exited with error code $LASTEXITCODE" }
{ "Net.WebClient.DownloadFile Object method exited with error code $LastExitCode" }
}

try {
Expand-Archive -LiteralPath $gnDownloadFolder -DestinationPath $binFolderPath -Force | Out-Null
}
catch {
{ "error code $LASTEXITCODE" }
{ "error code $LastExitCode" }
}
}
$a = ""
$b = ""

$env:Path = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)

foreach ($loc in ($env:Path -split ";")) {

if ($loc -eq "$Global:PROJECT_ROOT_DIR\dependencies\bin" -and $a -ne "true") {
$a = "true"
$env:Path += "$binFolderPath\bin;"

}
if ($loc -eq "$Global:PROJECT_ROOT_DIR\dependencies" -and $b -ne "true") {
$b = "true"
$env:Path += "$binFolderPath;"

}

}
if ($a -ne "true") {
$env:Path += "$binFolderPath\bin;"
$env:Path = "$binFolderPath\bin;" + "$env:Path"
}
if ($b -ne "true") {
$env:Path += "$binFolderPath;"
$env:Path = "$binFolderPath;" + "$env:Path"
}
[Environment]::SetEnvironmentVariable("Path", $env:Path , "Machine")

}

Expand Down Expand Up @@ -192,43 +199,49 @@ function install_openssl() {

generate_pc_file $opensslInstallPath
}
$env:PKG_CONFIG_PATH += "$Global:PROJECT_ROOT_DIR\dependencies\pkg_config;"
[System.Environment]::SetEnvironmentVariable('PKG_CONFIG_PATH', "$Global:PROJECT_ROOT_DIR\dependencies\pkg_config;", "Machine")
return
}
try {
(New-Object Net.WebClient).DownloadFile($openssl_install_url, $opensslDownloadFolder)
}
catch {
{ "Net.WebClient.DownloadFile Object method exited with error code $LASTEXITCODE" }
{ "Net.WebClient.DownloadFile Object method exited with error code $LastExitCode" }
}
try {
& $opensslDownloadFolder /passive InstallAllUsers=0 PrependPath=1 Include_test=0 TargetDir=$opensslInstallPath | Out-Null
}
catch {
{ "Openssl installer exited with error code $LASTEXITCODE" }
{ "Openssl installer exited with error code $LastExitCode" }
}

generate_pc_file $opensslInstallPath
$env:PKG_CONFIG_PATH += "$Global:PROJECT_ROOT_DIR\dependencies\pkg_config;"
[System.Environment]::SetEnvironmentVariable('PKG_CONFIG_PATH', "$Global:PROJECT_ROOT_DIR\dependencies\pkg_config;", "Machine")


}

function setup() {

New-Item -Path "$Global:PROJECT_ROOT_DIR\dependencies" -ItemType Directory -ErrorAction SilentlyContinue > $null
New-Item -Path "$Global:PROJECT_ROOT_DIR\dependencies\pkg_config" -ItemType Directory -ErrorAction SilentlyContinue > $null
New-Item -Path Env:\PKG_CONFIG_PATH -Value "$PKG_CONFIG_PATH" -ErrorAction SilentlyContinue > $null

}


try {

$Global:PROJECT_ROOT_DIR = (Split-Path -Path $PSScriptRoot)

if ($($args[0]) -eq "--setup") {

setup
install_dependencies
install_openssl

$env:path -split ";"
}
elseif ($($args[0]) -eq "--cleanup") {

clean_up_env
}
else {
Expand Down

0 comments on commit efb8612

Please sign in to comment.