add cmder slim (i.e. option for no bundled terminal)

This commit is contained in:
David Refoua 2023-11-24 21:06:55 +03:30 committed by GitHub
commit e2303b11c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 88 additions and 47 deletions

View File

@ -45,12 +45,12 @@ jobs:
- name: Build Cmder Launcher
shell: pwsh
working-directory: scripts
run: .\build.ps1 -Compile -verbose
run: .\build.ps1 -Compile -verbose -terminal all
- name: Pack the built files
shell: pwsh
working-directory: scripts
run: .\pack.ps1 -verbose -emulator all
run: .\pack.ps1 -verbose -terminal all
- name: Upload artifact (cmder_wt.zip)
uses: actions/upload-artifact@v3

View File

@ -2,7 +2,7 @@
SET CMDER_ROOT=%~dp0
set CMDER_TERMINAl=conemu
set CMDER_TERMINAL=conemu
if exist "%CMDER_ROOT%\vendor\windows-terminal\windowsterminal.exe" (
SET CMDER_TERMINAL=windows-terminal
)

View File

@ -130,6 +130,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
wchar_t userConEmuCfgPath[MAX_PATH] = { 0 };
wchar_t windowsTerminalDir[MAX_PATH] = { 0 };
wchar_t conEmuDir[MAX_PATH] = { 0 };
wchar_t winDir[MAX_PATH] = { 0 };
wchar_t emulatorPath[MAX_PATH] = { 0 };
@ -256,6 +257,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
PathCombine(windowsTerminalDir, exeDir, L"vendor\\windows-terminal");
PathCombine(conEmuDir, exeDir, L"vendor\\conemu-maximus5");
GetEnvironmentVariable(L"WINDIR", winDir, MAX_PATH);
if (PathFileExists(windowsTerminalDir))
{
@ -272,7 +274,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
// Set path to Cmder user ConEmu config file
PathCombine(userCfgPath, userConfigDirPath, L"user_windows_terminal_settings.json");
}
else
else if (PathFileExists(conEmuDir))
{
// Set path to vendored ConEmu config file
PathCombine(cfgPath, conEmuDir, L"ConEmu.xml");
@ -288,7 +290,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
}
if (PathFileExists(cpuCfgPath) || use_user_cfg == false) // config/ConEmu-%COMPUTERNAME%.xml file exists or /m was specified on command line, use machine specific config.
if (wcscmp(cpuCfgPath, L"") == 0 && (PathFileExists(cpuCfgPath) || use_user_cfg == false)) // config/ConEmu-%COMPUTERNAME%.xml file exists or /m was specified on command line, use machine specific config.
{
if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
{
@ -301,7 +303,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_teerminal_%COMPUTERNAME%_settigns.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else {
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/ConEmu-%COMPUTERNAME%.xml! Access Denied."
@ -321,7 +324,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
: L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else {
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy config/ConEmu-%COMPUTERNAME%.xml file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
@ -331,7 +335,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
}
}
}
else if (PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it.
else if (wcscmp(userCfgPath, L"") == 0 && PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it.
{
if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
{
@ -346,7 +350,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_teerminal_settigns.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
@ -367,7 +371,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
: L"Failed to copy config/user_windows_terminal_settings.json file to vendor/windows-terminal/settings/settings.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
@ -395,14 +399,14 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/user_windows_terminal_settigns.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml! Access Denied."
: L"Failed to copy vendor/conemu-maximus5/ConEmu.xml file to config/user-conemu.xml!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
}
}
else // vendor/ConEmu.xml.default config exists, copy Cmder vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml.
{
@ -415,7 +419,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
: L"Failed to copy vendor/windows-terminal_default_settings_settings.json file to vendor/windows-terminal/settings/settigns.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
@ -426,18 +430,16 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
}
}
}
else {
if (!CopyFile(defaultCfgPath, cfgPath, FALSE))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
: L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir))
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
: L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
}
}
else if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml
else if (wcscmp(cfgPath, L"") == 0 && PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml
{
if (!CopyFile(cfgPath, userCfgPath, FALSE))
{
@ -460,7 +462,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml");
}
else // '/c [path]' was specified and 'vendor/ConEmu.xml.default' config exists, copy Cmder 'vendor/ConEmu.xml.default' file to '[user specified path]/config/user_ConEmu.xml'.
else if (wcscmp(defaultCfgPath, L"") == 0) // '/c [path]' was specified and 'vendor/ConEmu.xml.default' config exists, copy Cmder 'vendor/ConEmu.xml.default' file to '[user specified path]/config/user_ConEmu.xml'.
{
if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE))
{
@ -488,10 +490,14 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
if (PathFileExists(windowsTerminalDir)) {
PathCombine(terminalPath, exeDir, L"vendor\\windows-terminal\\WindowsTerminal.exe");
}
else
else if (PathFileExists(conEmuDir))
{
PathCombine(terminalPath, exeDir, L"vendor\\conemu-maximus5\\ConEmu64.exe");
}
else
{
PathCombine(terminalPath, winDir, L"system32\\cmd.exe");
}
if (!PathFileExists(windowsTerminalDir)) {
swprintf_s(args, L"%s /Icon \"%s\"", args, icoPath);
@ -542,10 +548,14 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
if (PathFileExists(windowsTerminalDir)) {
swprintf_s(args, L"%s -p \"%s\"", args, cmderTask.c_str());
}
else
else if (PathFileExists(conEmuDir))
{
swprintf_s(args, L"%s /run {%s}", args, cmderTask.c_str());
}
else
{
swprintf_s(args, L"%s %s", args, cmderTask.c_str());
}
}
SetEnvironmentVariable(L"CMDER_ROOT", exeDir);
@ -565,14 +575,23 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
si.dwFlags = STARTF_TITLEISAPPID;
#endif
PROCESS_INFORMATION pi;
if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi)) {
// MessageBox(NULL, terminalPath, _T("Error"), MB_OK);
// MessageBox(NULL, args, _T("Error"), MB_OK);
if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi))
{
if (PathFileExists(windowsTerminalDir)) {
MessageBox(NULL, _T("Unable to create the Windows Terminal process!"), _T("Error"), MB_OK);
}
else
else if (PathFileExists(conEmuDir))
{
MessageBox(NULL, _T("Unable to create the ConEmu process!"), _T("Error"), MB_OK);
}
else
{
MessageBox(NULL, _T("Unable to create the Cmd process!"), _T("Error"), MB_OK);
}
return;
}
}
@ -704,18 +723,23 @@ cmderOptions GetOption()
int argCount;
wchar_t windowsTerminalDir[MAX_PATH] = { 0 };
wchar_t conEmuDir[MAX_PATH] = { 0 };
wchar_t vendorDir[MAX_PATH] = { 0 };
wchar_t exeDir[MAX_PATH] = { 0 };
wchar_t cmdInit[MAX_PATH] = { 0 };
GetModuleFileName(NULL, exeDir, sizeof(exeDir));
PathRemoveFileSpec(exeDir);
PathCombine(windowsTerminalDir, exeDir, L"vendor\\windows-terminal");
PathCombine(vendorDir, exeDir, L"vendor");
PathCombine(windowsTerminalDir, vendorDir, L"windows-terminal");
PathCombine(conEmuDir, vendorDir, L"ConEmu-Maximus5");
PathCombine(cmdInit, vendorDir, L"init.bat");
szArgList = CommandLineToArgvW(GetCommandLine(), &argCount);
for (int i = 1; i < argCount; i++)
{
// MessageBox(NULL, szArgList[i], L"Arglist contents", MB_OK);
if (cmderOptions.error == false) {
if (_wcsicmp(L"/c", szArgList[i]) == 0)
@ -752,26 +776,26 @@ cmderOptions GetOption()
MessageBox(NULL, szArgList[i + 1], L"/START - Folder does not exist!", MB_OK);
}
}
else if (_wcsicmp(L"/task", szArgList[i]) == 0)
else if (_wcsicmp(L"/task", szArgList[i]) == 0 || PathFileExists(windowsTerminalDir) || PathFileExists(conEmuDir))
{
cmderOptions.cmderTask = szArgList[i + 1];
i++;
}
else if (_wcsicmp(L"/title", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir))
else if (_wcsicmp(L"/title", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && PathFileExists(conEmuDir))
{
cmderOptions.cmderTitle = szArgList[i + 1];
i++;
}
else if (_wcsicmp(L"/icon", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir))
else if (_wcsicmp(L"/icon", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && PathFileExists(conEmuDir))
{
cmderOptions.cmderIcon = szArgList[i + 1];
i++;
}
else if (_wcsicmp(L"/single", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir))
else if (_wcsicmp(L"/single", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && PathFileExists(conEmuDir))
{
cmderOptions.cmderSingle = true;
}
else if (_wcsicmp(L"/m", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir))
else if (_wcsicmp(L"/m", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && PathFileExists(conEmuDir))
{
cmderOptions.cmderUserCfg = false;
}
@ -844,6 +868,13 @@ cmderOptions GetOption()
}
if (!PathFileExists(windowsTerminalDir) && !PathFileExists(conEmuDir))
{
cmderOptions.cmderTask = L"/k \"";
cmderOptions.cmderTask += cmdInit;
cmderOptions.cmderTask += L"\"";
}
if (cmderOptions.error == true)
{
wchar_t validOptions[512];

View File

@ -56,15 +56,15 @@ Param(
# Using this option will skip all downloads, if you only need to build launcher
[switch]$noVendor,
# Using this option will specify the emulator to use [all, conemu-maximus5, or windows-terminal]
[string]$emulator = 'all',
# Using this option will specify the emulator to use [none, all, conemu-maximus5, or windows-terminal]
[string]$terminal = 'all',
# Build launcher if you have MSBuild tools installed
[switch]$Compile
)
# Get the scripts and cmder root dirs we are building in.
$cmder_root = [string](Resolve-Path "$PSScriptRoot\..")
$cmder_root = Resolve-Path "$PSScriptRoot\.."
# Dot source util functions into this scope
. "$PSScriptRoot\utils.ps1"
@ -137,9 +137,11 @@ if (-not $noVendor) {
}
foreach ($s in $sources) {
if ($s.name -eq "conemu-maximus5" -and $emulator -eq "windows-terminal") {
if ($terminal -eq "none") {
return
} elseif ($s.name -eq "windows-terminal" -and $emulator -eq "conemu-maximus5") {
} elseif ($s.name -eq "conemu-maximus5" -and $terminal -eq "windows-terminal") {
return
} elseif ($s.name -eq "windows-terminal" -and $terminal -eq "conemu-maximus5") {
return
}
@ -156,8 +158,8 @@ if (-not $noVendor) {
# Make Embedded Windows Terminal Portable
if ($s.name -eq "windows-terminal") {
$windowTerminalFiles = resolve-path ($saveTo + "\" + $s.name + "\terminal*")
move-item -ErrorAction SilentlyContinue $windowTerminalFiles\* $s.name >$null
remove-item -ErrorAction SilentlyContinue $windowTerminalFiles >$null
move-item -ErrorAction SilentlyContinue $windowTerminalFiles\* $s.name >$null
remove-item -ErrorAction SilentlyContinue $windowTerminalFiles >$null
write-verbose "Making Windows Terminal Portable..."
New-Item -Type Directory -Path (Join-Path $saveTo "/windows-terminal/settings") -ErrorAction SilentlyContinue >$null
New-Item -Type File -Path (Join-Path $saveTo "/windows-terminal/.portable") -ErrorAction SilentlyContinue >$null

View File

@ -31,8 +31,8 @@ Param(
# Path to the vendor configuration source file
[string]$cmderRoot = "$PSScriptRoot\..",
# Using this option will pack artifacts for a specific included terminal emulator [all, conemu-maximus5, or windows-terminal]
[string]$emulator = 'all',
# Using this option will pack artifacts for a specific included terminal emulator [none, all, conemu-maximus5, or windows-terminal]
[string]$terminal = 'all',
# Vendor folder locaton
[string]$saveTo = "$PSScriptRoot\..\build"
@ -44,13 +44,19 @@ $cmderRoot = Resolve-Path $cmderRoot
$ErrorActionPreference = "Stop"
Ensure-Executable "7z"
if ($emulator -eq "windows-terminal") {
if ($terminal -eq "none") {
$targets = @{
"cmder_win.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win.mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
}
} elseif ($terminal -eq "windows-terminal") {
$targets = @{
"cmder_wt.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`"";
"cmder_wt.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`"";
"cmder_wt_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`"";
}
} elseif ($emulator -eq "windows-terminal") {
} elseif ($terminal -eq "windows-terminal") {
$targets = @{
"cmder.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\windows-terminal`"";
"cmder.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\windows-terminal`"";
@ -58,6 +64,9 @@ if ($emulator -eq "windows-terminal") {
}
} else {
$targets = @{
"cmder_win.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_win_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`" -xr!`"vendor\windows-terminal`"";
"cmder_wt.7z" = "-t7z -m0=lzma2 -mx=9 -mfb=64 -md=32m -ms=on -myx=7 -mqs=on -xr!`"vendor\conemu-maximus5`"";
"cmder_wt.zip" = "-mm=Deflate -mfb=128 -mpass=3 -xr!`"vendor\conemu-maximus5`"";
"cmder_wt_mini.zip" = "-xr!`"vendor\git-for-windows`" -xr!`"vendor\conemu-maximus5`"";

3
vendor/init.bat vendored
View File

@ -319,7 +319,7 @@ if exist "%CMDER_ROOT%\vendor\git-for-windows" (
goto :CONFIGURE_GIT
:FOUND_GIT
%print_debug% init.bat "Using found Git '%GIT_VERSION_USER%' from 'v%GIT_INSTALL_ROOT%..."
%print_debug% init.bat "Using found Git '%GIT_VERSION_USER%' from '%GIT_INSTALL_ROOT%..."
goto :CONFIGURE_GIT
:CONFIGURE_GIT
@ -418,7 +418,6 @@ if %max_depth% gtr 1 (
)
%print_debug% init.bat "END - bin(prepend): Env Var - PATH=%path%"
if defined CMDER_USER_BIN if defined CMDER_USER_ROOT (
%print_debug% init.bat "START - user_bin(prepend): Env Var - PATH=%path%"
if %max_depth% gtr 1 (