diff options
| author | xq114 <[email protected]> | 2021-11-06 15:30:38 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2021-11-06 15:30:38 +0800 |
| commit | 2ed6222d854d03441d24314595cae550b4b842e0 (patch) | |
| tree | 7f70ab2b7bcb21efbd9e857553265978e5aa3142 | |
| parent | 95dea5af25edb9f1eda15ad8412342e26ef39525 (diff) | |
improve env config
| -rw-r--r-- | scripts/register-virtualenvs.sh | 1 | ||||
| -rwxr-xr-x | scripts/xrepo.bat | 4 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 8 | ||||
| -rw-r--r-- | xmake/scripts/xrepo-hook.psm1 | 5 |
4 files changed, 17 insertions, 1 deletions
diff --git a/scripts/register-virtualenvs.sh b/scripts/register-virtualenvs.sh index 8518060f8..cf067d040 100644 --- a/scripts/register-virtualenvs.sh +++ b/scripts/register-virtualenvs.sh @@ -47,6 +47,7 @@ function xrepo { unset XMAKE_PROMPT_BACKUP unset XMAKE_ENV_BACKUP fi + "$XMAKE_EXE" lua private.xrepo.action.env.info config $bnd || return 1 local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt $bnd)" || return 1 if [ -z "${prompt+x}" ]; then return 1 diff --git a/scripts/xrepo.bat b/scripts/xrepo.bat index 82180398a..0416d4a10 100755 --- a/scripts/xrepo.bat +++ b/scripts/xrepo.bat @@ -81,6 +81,10 @@ exit /B 1 ) else ( setlocal EnableDelayedExpansion + %XMAKE_EXE% lua private.xrepo.action.env.info config %3 + if !errorlevel! neq 0 ( + exit /B !errorlevel! + ) @%XMAKE_EXE% lua --quiet private.xrepo.action.env.info prompt %3 1>nul if !errorlevel! neq 0 ( echo error: environment not found^^! diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index 18b59c0e6..07709b7bd 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -381,7 +381,13 @@ function info(key, bnd) elseif key == "envfile" then print(os.tmpfile()) elseif key == "config" then - if not bnd and os.isfile(os.projectfile()) then + local boundenv = _get_boundenv({bind = bnd}) + local has_envfile = (boundenv and os.isfile(boundenv)) and true or false + if has_envfile or os.isfile(os.projectfile()) then + if has_envfile then + _enter_project({enteronly = true}) + table.insert(project.rcfiles(), boundenv) + end task.run("config", {target = "all"}, {disable_dump = true}) end elseif key:startswith("script.") then diff --git a/xmake/scripts/xrepo-hook.psm1 b/xmake/scripts/xrepo-hook.psm1 index 2210f10ef..2a2c24c05 100644 --- a/xmake/scripts/xrepo-hook.psm1 +++ b/xmake/scripts/xrepo-hook.psm1 @@ -33,6 +33,11 @@ function Enter-XrepoEnvironment { $activateCommand = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env.info script.powershell | Out-String); } else { + & $Env:XMAKE_EXE lua private.xrepo.action.env.info config $bnd; + if (-not $?) { + Exit 1; + } + $xmakeColorTermBackup, $Env:XMAKE_COLORTERM = $Env:XMAKE_COLORTERM, "nocolor"; $xrepoPrompt = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env.info prompt $bnd | Out-String); $Env:XMAKE_COLORTERM = $xmakeColorTermBackup; |
