diff options
| author | ruki <[email protected]> | 2021-04-30 23:41:06 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-30 23:41:06 +0800 |
| commit | 92dae28e3b2504a38f2d941b273ba49e76beb9e8 (patch) | |
| tree | 483c8c6d150445364cbe46bb40c7d3fe99babcdc | |
| parent | 38b65439249e7de42e8a542a138ff90cccc54c37 (diff) | |
| parent | 108410d9151b2ba67b011e858576ab7efdbd2176 (diff) | |
Merge pull request #1375 from xq114/dev
improve envrionment management without xmake cache
| -rw-r--r-- | scripts/xrepo-hook.psm1 | 12 | ||||
| -rwxr-xr-x | scripts/xrepo.bat | 13 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 4 |
3 files changed, 21 insertions, 8 deletions
diff --git a/scripts/xrepo-hook.psm1 b/scripts/xrepo-hook.psm1 index 22a726b97..5874203fd 100644 --- a/scripts/xrepo-hook.psm1 +++ b/scripts/xrepo-hook.psm1 @@ -14,11 +14,17 @@ function Enter-XrepoEnvironment { begin { $script:xrepoOldEnvs = (Get-ChildItem -Path Env:); + + & $Env:XMAKE_EXE lua private.xrepo.action.env.info config; + + $xmakeColorTermBackup, $Env:XMAKE_COLORTERM = $Env:XMAKE_COLORTERM, "nocolor"; $xrepoPrompt = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info prompt | Out-String); - if (-not $?) { - Write-Host $xrepoPrompt - Exit 1 + $Env:XMAKE_COLORTERM = $xmakeColorTermBackup; + if (-not $xrepoPrompt.StartsWith("[")) { + Write-Host $xrepoPrompt; + Exit 1; } + $activateCommand = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info script.powershell | Out-String); Write-Verbose "[xrepo env script.powershell]`n$activateCommand"; diff --git a/scripts/xrepo.bat b/scripts/xrepo.bat index c1dde03fe..1a4a230ca 100755 --- a/scripts/xrepo.bat +++ b/scripts/xrepo.bat @@ -1,6 +1,5 @@ -@echo off - @set "XMAKE_EXE=xmake" + @if [%1]==[env] ( if [%2]==[quit] ( if defined XMAKE_PROMPT_BACKUP ( @@ -19,6 +18,7 @@ call %XMAKE_ENV_BACKUP% setlocal EnableDelayedExpansion if !errorlevel! neq 0 exit /B !errorlevel! + %XMAKE_EXE% lua private.xrepo.action.env.info config @%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul if !errorlevel! neq 0 ( echo error: xmake.lua not found^^! @@ -32,17 +32,20 @@ exit /B 1 ) else ( setlocal EnableDelayedExpansion + %XMAKE_EXE% lua private.xrepo.action.env.info config @%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul if !errorlevel! neq 0 ( echo error: xmake.lua not found^^! exit /B !errorlevel! ) endlocal - for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info prompt') do @set "PROMPT=%%i %PROMPT%" - set XMAKE_PROMPT_BACKUP=%PROMPT% + for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info prompt') do @( + @set "PROMPT=%%i %PROMPT%" + ) + @set XMAKE_PROMPT_BACKUP=%PROMPT% ) for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile') do @( - set "XMAKE_ENV_BACKUP=%%i.bat" + @set "XMAKE_ENV_BACKUP=%%i.bat" @"%XMAKE_EXE%" lua private.xrepo.action.env.info backup.cmd 1>"%%i.bat" ) for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile') do @( diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index 8703a726c..fbce2a566 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -268,6 +268,10 @@ function info(key) print("[%s]", path.filename(os.projectdir())) elseif key == "envfile" then print(os.tmpfile()) + elseif key == "config" then + if os.isfile(os.projectfile()) then + task.run("config", {target = "all"}, {disable_dump = true}) + end elseif key:startswith("script.") then local shell = key:match("script%.(.+)") print(_get_env_script(_package_getenvs(), shell, false)) |
