mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 15:17:47 +00:00
add find_msvs custom command to the nu_msvs module (#881)
I changed `export-env {}` at the beginning to a custom command to avoid having `export-env` run when loading the module because: 1. I couldn't use `nu_msvs activate` because it depends on env vars being set that were hidden with `nu_msvs deactivate` 2. It seems that `export-env` executed at `use`, leaves `$env.FILE_PWD` available in the environment which I think may be a bug. So, putting it in a custom command avoids that.
This commit is contained in:
parent
92f20ff282
commit
ddbebf197d
1 changed files with 61 additions and 52 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
def --env find_msvs [] {
|
||||||
export-env {
|
export-env {
|
||||||
$env.MSVS_BASE_PATH = $env.Path
|
$env.MSVS_BASE_PATH = $env.Path
|
||||||
$env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" })
|
$env.PATH_VAR = (if "Path" in $env { "Path" } else { "PATH" })
|
||||||
|
@ -59,12 +60,20 @@ export-env {
|
||||||
# print $"MSVS_MSDK_VER: ($env.MSVS_MSDK_VER)"
|
# print $"MSVS_MSDK_VER: ($env.MSVS_MSDK_VER)"
|
||||||
# print $"MSVS_INCLUDE_PATH: ($env.MSVS_INCLUDE_PATH)"
|
# print $"MSVS_INCLUDE_PATH: ($env.MSVS_INCLUDE_PATH)"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export def --env activate [
|
export def --env activate [
|
||||||
--host (-h): string = x64, # Host architecture, must be x64 or x86 (case insensitive)
|
--host (-h): string = x64, # Host architecture, must be x64 or x86 (case insensitive)
|
||||||
--target (-t): string = x64, # Target architecture, must be x64 or x86 (case insensitive)
|
--target (-t): string = x64, # Target architecture, must be x64 or x86 (case insensitive)
|
||||||
--sdk (-s): string = latest # Version of Windows SDK, must be "latest" or a valid version string
|
--sdk (-s): string = latest # Version of Windows SDK, must be "latest" or a valid version string
|
||||||
] {
|
] {
|
||||||
|
# I changed export-env {} to a custom command to avoid having export-env run when loading the module
|
||||||
|
# because:
|
||||||
|
# 1. I couldn't use activate because it depends on env vars being set that were hidden with deactivate
|
||||||
|
# 2. It seems that export-env executed at `use`, leaves `$env.FILE_PWD` available in the environment
|
||||||
|
# which I think may be a bug. So, putting it in a custom command avoids that.
|
||||||
|
find_msvs
|
||||||
|
|
||||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue