summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-19 23:27:01 +0800
committerruki <[email protected]>2024-03-19 14:52:03 +0800
commit2d8b2fe62d4dfac8cc4e8f098f98268aa2ca7b57 (patch)
tree2e60e232cd468810caa8c75519d65e0a20bfad8e
parent1eb61cd2e7723cb0614c2723379f3a7e3023dea5 (diff)
improve xrepo script
-rwxr-xr-xscripts/srcenv.bat3
-rwxr-xr-xscripts/xrepo.bat40
-rw-r--r--scripts/xrepo.ps16
-rw-r--r--xmake/scripts/virtualenvs/register-virtualenvs.sh32
-rw-r--r--xmake/scripts/xrepo-hook.psm112
5 files changed, 48 insertions, 45 deletions
diff --git a/scripts/srcenv.bat b/scripts/srcenv.bat
index 297de4501..4c511faee 100755
--- a/scripts/srcenv.bat
+++ b/scripts/srcenv.bat
@@ -3,5 +3,6 @@ setlocal
set script_dir=%~dp0
set PATH=%script_dir%..\core\build;%cd%;%PATH%
set XMAKE_PROGRAM_DIR=%script_dir%..\xmake
+set XMAKE_PROGRAM_FILE=%script_dir%..\core\build\xmake.exe
start cmd /k cd %script_dir%..\
-endlocal \ No newline at end of file
+endlocal
diff --git a/scripts/xrepo.bat b/scripts/xrepo.bat
index ccb3e987f..c07c85fa1 100755
--- a/scripts/xrepo.bat
+++ b/scripts/xrepo.bat
@@ -1,5 +1,7 @@
@set "XMAKE_ROOTDIR=%~dp0"
-@set "XMAKE_EXE=%XMAKE_ROOTDIR%xmake.exe"
+IF NOT DEFINED XMAKE_PROGRAM_FILE (
+ @set "XMAKE_PROGRAM_FILE=%XMAKE_ROOTDIR%xmake.exe"
+)
@if [%1]==[env] (
if [%2]==[quit] (
@@ -19,11 +21,11 @@
call %XMAKE_ENV_BACKUP%
setlocal EnableDelayedExpansion
if !errorlevel! neq 0 exit /B !errorlevel!
- "%XMAKE_EXE%" lua private.xrepo.action.env.info config
+ "%XMAKE_PROGRAM_FILE%" lua private.xrepo.action.env.info config
if !errorlevel! neq 0 (
exit /B !errorlevel!
)
- @"%XMAKE_EXE%" lua --quiet private.xrepo.action.env.info prompt 1>nul
+ @"%XMAKE_PROGRAM_FILE%" lua --quiet private.xrepo.action.env.info prompt 1>nul
if !errorlevel! neq 0 (
echo error: xmake.lua not found^^!
exit /B !errorlevel!
@@ -36,31 +38,31 @@
exit /B 1
) else (
setlocal EnableDelayedExpansion
- "%XMAKE_EXE%" lua private.xrepo.action.env.info config
+ "%XMAKE_PROGRAM_FILE%" lua private.xrepo.action.env.info config
if !errorlevel! neq 0 (
exit /B !errorlevel!
)
- @"%XMAKE_EXE%" lua --quiet private.xrepo.action.env | findstr . && (
+ @"%XMAKE_PROGRAM_FILE%" lua --quiet private.xrepo.action.env | findstr . && (
echo error: corrupt xmake.lua detected in the current directory^^!
exit /B 1
)
- @"%XMAKE_EXE%" lua --quiet private.xrepo.action.env.info prompt 1>nul
+ @"%XMAKE_PROGRAM_FILE%" lua --quiet 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 --quiet private.xrepo.action.env.info prompt') do @(
+ for /f %%i in ('@"%XMAKE_PROGRAM_FILE%" lua --quiet 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 @(
+ for /f %%i in ('@"%XMAKE_PROGRAM_FILE%" lua private.xrepo.action.env.info envfile') do @(
@set "XMAKE_ENV_BACKUP=%%i.bat"
- @"%XMAKE_EXE%" lua private.xrepo.action.env.info backup.cmd 1>"%%i.bat"
+ @"%XMAKE_PROGRAM_FILE%" 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 @(
- @"%XMAKE_EXE%" lua private.xrepo.action.env.info script.cmd 1>"%%i.bat"
+ for /f %%i in ('@"%XMAKE_PROGRAM_FILE%" lua private.xrepo.action.env.info envfile') do @(
+ @"%XMAKE_PROGRAM_FILE%" lua private.xrepo.action.env.info script.cmd 1>"%%i.bat"
call "%%i.bat"
)
goto :ENDXREPO
@@ -87,29 +89,29 @@
) else (
pushd %XMAKE_ROOTDIR%
setlocal EnableDelayedExpansion
- %XMAKE_EXE% lua private.xrepo.action.env.info config %3
+ %XMAKE_PROGRAM_FILE% lua private.xrepo.action.env.info config %3
if !errorlevel! neq 0 (
popd
exit /B !errorlevel!
)
- @%XMAKE_EXE% lua --quiet private.xrepo.action.env.info prompt %3 1>nul
+ @%XMAKE_PROGRAM_FILE% lua --quiet private.xrepo.action.env.info prompt %3 1>nul
if !errorlevel! neq 0 (
popd
echo error: environment not found^^!
exit /B !errorlevel!
)
endlocal
- for /f %%i in ('@%XMAKE_EXE% lua --quiet private.xrepo.action.env.info prompt %3') do @(
+ for /f %%i in ('@%XMAKE_PROGRAM_FILE% lua --quiet private.xrepo.action.env.info prompt %3') do @(
@set "PROMPT=%%i %PROMPT%"
)
@set XMAKE_PROMPT_BACKUP=%PROMPT%
)
- for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile %3') do @(
+ for /f %%i in ('@%XMAKE_PROGRAM_FILE% lua private.xrepo.action.env.info envfile %3') do @(
@set "XMAKE_ENV_BACKUP=%%i.bat"
- @"%XMAKE_EXE%" lua --quiet private.xrepo.action.env.info backup.cmd %3 1>"%%i.bat"
+ @"%XMAKE_PROGRAM_FILE%" lua --quiet private.xrepo.action.env.info backup.cmd %3 1>"%%i.bat"
)
- for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info envfile %3') do @(
- @"%XMAKE_EXE%" lua --quiet private.xrepo.action.env.info script.cmd %3 1>"%%i.bat"
+ for /f %%i in ('@%XMAKE_PROGRAM_FILE% lua private.xrepo.action.env.info envfile %3') do @(
+ @"%XMAKE_PROGRAM_FILE%" lua --quiet private.xrepo.action.env.info script.cmd %3 1>"%%i.bat"
call "%%i.bat"
)
popd
@@ -117,6 +119,6 @@
)
)
-@call "%XMAKE_EXE%" lua private.xrepo %*
+@call "%XMAKE_PROGRAM_FILE%" lua private.xrepo %*
:ENDXREPO
diff --git a/scripts/xrepo.ps1 b/scripts/xrepo.ps1
index 74e5e4682..e897208e3 100644
--- a/scripts/xrepo.ps1
+++ b/scripts/xrepo.ps1
@@ -1,11 +1,11 @@
$script:SCRIPT_PATH = $myinvocation.mycommand.path
$script:BASE_DIR = Split-Path $SCRIPT_PATH -Parent
-$Env:XMAKE_EXE = Join-Path $BASE_DIR xmake.exe
+$Env:XMAKE_PROGRAM_FILE = Join-Path $BASE_DIR xmake.exe
if ($Args.Count -eq 0) {
# No args, just call the underlying xmake executable.
- & $Env:XMAKE_EXE lua private.xrepo;
+ & $Env:XMAKE_PROGRAM_FILE lua private.xrepo;
} else {
$Command = $Args[0];
if (($Command -eq "env") -and ($Args.Count -ge 2)) {
@@ -43,5 +43,5 @@ if ($Args.Count -eq 0) {
}
}
- & $Env:XMAKE_EXE lua private.xrepo $Args;
+ & $Env:XMAKE_PROGRAM_FILE lua private.xrepo $Args;
}
diff --git a/xmake/scripts/virtualenvs/register-virtualenvs.sh b/xmake/scripts/virtualenvs/register-virtualenvs.sh
index ac82e9b94..a2263f67a 100644
--- a/xmake/scripts/virtualenvs/register-virtualenvs.sh
+++ b/xmake/scripts/virtualenvs/register-virtualenvs.sh
@@ -19,10 +19,10 @@
#
if test "${XMAKE_ROOTDIR}"; then
- export XMAKE_EXE=${XMAKE_ROOTDIR}/xmake
+ export XMAKE_PROGRAM_FILE=${XMAKE_ROOTDIR}/xmake
else
local -i XMAKE_ROOTDIR=~/.local/bin
- export XMAKE_EXE=xmake
+ export XMAKE_PROGRAM_FILE=xmake
fi
function xrepo {
@@ -36,20 +36,20 @@ function xrepo {
unset XMAKE_PROMPT_BACKUP
unset XMAKE_ENV_BACKUP
fi
- "$XMAKE_EXE" lua private.xrepo.action.env.info config || return 1
- local currentTest="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env)" || return 1
+ "$XMAKE_PROGRAM_FILE" lua private.xrepo.action.env.info config || return 1
+ local currentTest="$("$XMAKE_PROGRAM_FILE" lua --quiet private.xrepo.action.env)" || return 1
if [ ! -z "$currentTest" ]; then
echo "error: corrupt xmake.lua detected in the current directory!"
return 1
fi
- local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt)" || return 1
+ local prompt="$("$XMAKE_PROGRAM_FILE" lua --quiet private.xrepo.action.env.info prompt)" || return 1
if [ -z "${prompt+x}" ]; then
return 1
fi
- local activateCommand="$("$XMAKE_EXE" lua private.xrepo.action.env.info script.bash)" || return 1
- export XMAKE_ENV_BACKUP="$("$XMAKE_EXE" lua private.xrepo.action.env.info envfile)"
+ local activateCommand="$("$XMAKE_PROGRAM_FILE" lua private.xrepo.action.env.info script.bash)" || return 1
+ export XMAKE_ENV_BACKUP="$("$XMAKE_PROGRAM_FILE" lua private.xrepo.action.env.info envfile)"
export XMAKE_PROMPT_BACKUP="${PS1}"
- "$XMAKE_EXE" lua private.xrepo.action.env.info backup.bash 1>"$XMAKE_ENV_BACKUP"
+ "$XMAKE_PROGRAM_FILE" lua private.xrepo.action.env.info backup.bash 1>"$XMAKE_ENV_BACKUP"
eval "$activateCommand"
PS1="${prompt} $PS1"
;;
@@ -71,29 +71,29 @@ function xrepo {
unset XMAKE_ENV_BACKUP
fi
pushd ${XMAKE_ROOTDIR} 1>/dev/null
- "$XMAKE_EXE" lua private.xrepo.action.env.info config $bnd || (popd 1>/dev/null && return 1)
- local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt $bnd)" || (popd 1>/dev/null && return 1)
+ "$XMAKE_PROGRAM_FILE" lua private.xrepo.action.env.info config $bnd || (popd 1>/dev/null && return 1)
+ local prompt="$("$XMAKE_PROGRAM_FILE" lua --quiet private.xrepo.action.env.info prompt $bnd)" || (popd 1>/dev/null && return 1)
if [ -z "${prompt+x}" ]; then
popd 1>/dev/null
echo "error: invalid environment!"
return 1
fi
- local activateCommand="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info script.bash $bnd)" || (popd 1>/dev/null && return 1)
- export XMAKE_ENV_BACKUP="$("$XMAKE_EXE" lua private.xrepo.action.env.info envfile $bnd)"
+ local activateCommand="$("$XMAKE_PROGRAM_FILE" lua --quiet private.xrepo.action.env.info script.bash $bnd)" || (popd 1>/dev/null && return 1)
+ export XMAKE_ENV_BACKUP="$("$XMAKE_PROGRAM_FILE" lua private.xrepo.action.env.info envfile $bnd)"
export XMAKE_PROMPT_BACKUP="${PS1}"
- "$XMAKE_EXE" lua --quiet private.xrepo.action.env.info backup.bash $bnd 1>"$XMAKE_ENV_BACKUP"
+ "$XMAKE_PROGRAM_FILE" lua --quiet private.xrepo.action.env.info backup.bash $bnd 1>"$XMAKE_ENV_BACKUP"
eval "$activateCommand"
popd 1>/dev/null
PS1="${prompt} $PS1"
else
- "$XMAKE_EXE" lua private.xrepo "$@"
+ "$XMAKE_PROGRAM_FILE" lua private.xrepo "$@"
fi
;;
*)
- "$XMAKE_EXE" lua private.xrepo "$@"
+ "$XMAKE_PROGRAM_FILE" lua private.xrepo "$@"
;;
esac
else
- "$XMAKE_EXE" lua private.xrepo "$@"
+ "$XMAKE_PROGRAM_FILE" lua private.xrepo "$@"
fi
}
diff --git a/xmake/scripts/xrepo-hook.psm1 b/xmake/scripts/xrepo-hook.psm1
index c0a6aad94..3782b123a 100644
--- a/xmake/scripts/xrepo-hook.psm1
+++ b/xmake/scripts/xrepo-hook.psm1
@@ -18,30 +18,30 @@ function Enter-XrepoEnvironment {
$script:xrepoOldEnvs = (Get-ChildItem -Path Env:);
if (-not $bnd) {
- & $Env:XMAKE_EXE lua private.xrepo.action.env.info config;
+ & $Env:XMAKE_PROGRAM_FILE lua private.xrepo.action.env.info config;
if (-not $?) {
Exit 1;
}
$xmakeColorTermBackup, $Env:XMAKE_COLORTERM = $Env:XMAKE_COLORTERM, "nocolor";
- $xrepoPrompt = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env.info prompt | Out-String);
+ $xrepoPrompt = (& $Env:XMAKE_PROGRAM_FILE lua --quiet private.xrepo.action.env.info prompt | Out-String);
$Env:XMAKE_COLORTERM = $xmakeColorTermBackup;
if (-not $xrepoPrompt.StartsWith("[")) {
Write-Host "error: xmake.lua not found!";
Exit 1;
}
- $activateCommand = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env.info script.powershell | Out-String);
+ $activateCommand = (& $Env:XMAKE_PROGRAM_FILE lua --quiet private.xrepo.action.env.info script.powershell | Out-String);
} else {
Push-Location $Env:XMAKE_ROOTDIR;
- & $Env:XMAKE_EXE lua private.xrepo.action.env.info config $bnd;
+ & $Env:XMAKE_PROGRAM_FILE lua private.xrepo.action.env.info config $bnd;
if (-not $?) {
Pop-Location;
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);
+ $xrepoPrompt = (& $Env:XMAKE_PROGRAM_FILE lua --quiet private.xrepo.action.env.info prompt $bnd | Out-String);
$Env:XMAKE_COLORTERM = $xmakeColorTermBackup;
if (-not $xrepoPrompt.StartsWith("[")) {
Pop-Location;
@@ -49,7 +49,7 @@ function Enter-XrepoEnvironment {
Exit 1;
}
- $activateCommand = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env.info script.powershell $bnd | Out-String);
+ $activateCommand = (& $Env:XMAKE_PROGRAM_FILE lua --quiet private.xrepo.action.env.info script.powershell $bnd | Out-String);
}
Write-Verbose "[xrepo env script.powershell]`n$activateCommand";