diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 index 9d3ce8b33b030d..f9bfd5ebd9ebe4 100644 --- a/scripts/bootstrap.ps1 +++ b/scripts/bootstrap.ps1 @@ -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 # @@ -309,6 +302,7 @@ 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 { @@ -316,18 +310,7 @@ function bootstrap_or_activate($arguments) { } } - " - █ - █ - ▄ █ ▄ █ ▌ - ▀▀█████▀▀ ▄▓▀▀▀▄,▄▀▀▀▀▄ ╓▄▀▀▀▀▄█ ▀▀█▀▀▀▀▀█▀▀ ,▄▀▀▀▀▄ ▄▀▀ - ▀█▄ ▄█▀ █ █ █ ▐▌ █ █ █ .█▄▄▄▄▄▄█⌐ ▐▌ - ▀█▄ ▄█▀ █ █ █ ▐▌ █ █ █ █ ▐▌ - ▄██▀▀█ █▀▀██▄ █ █ █ ╙▀▄▄▄Φ▀█ ▀▄▄ ▀▄▄ ▀▄▄▄▄▀^ ▐▌ -▀▀ █ █ ▀▀ - -" 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 @@ -356,7 +339,6 @@ function bootstrap_or_activate($arguments) { try { - $_PW_BANNER_FUNC = "_pw_banner" bootstrap_or_activate $args } catch { diff --git a/scripts/examples/gn_efr32_example.ps1 b/scripts/examples/gn_efr32_example.ps1 index 2e6480146ce6c9..f50966a1156982 100644 --- a/scripts/examples/gn_efr32_example.ps1 +++ b/scripts/examples/gn_efr32_example.ps1 @@ -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 diff --git a/scripts/windows_setup.ps1 b/scripts/windows_setup.ps1 index 532f60c7d23f66..bc4ab757fedcd7 100644 --- a/scripts/windows_setup.ps1 +++ b/scripts/windows_setup.ps1 @@ -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 @@ -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" } } @@ -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" } } @@ -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" } } @@ -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)) { @@ -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") } @@ -192,24 +199,25 @@ 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") + } @@ -217,18 +225,23 @@ 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 {