Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build system scripts (closes #2723) #2748

Merged
merged 12 commits into from
Sep 11, 2022
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ branches:
#---------------------------------#

# Operating system (build VM template)
os: Visual Studio 2017
os: Visual Studio 2022

#---------------------------------#
# build configuration #
Expand Down
2 changes: 1 addition & 1 deletion launcher/CmderLauncher.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
Expand Down
15 changes: 8 additions & 7 deletions launcher/CmderLauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,33 @@
<ProjectGuid>{4A8485A5-B7DD-4C44-B7F6-3E2765DD0CD3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>CmderLauncher</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -95,6 +94,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<!-- <AdditionalDependencies>comctl32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> -->
</Link>
<Manifest>
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
Expand All @@ -121,6 +121,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<!-- <AdditionalDependencies>comctl32.lib;shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies> -->
</Link>
<Manifest>
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
Expand Down Expand Up @@ -176,7 +177,7 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ResourceCompile Include="src\Resource.rc">
<ResourceCompile Include="src\resource.rc">
<FileType>RC</FileType>
</ResourceCompile>
</ItemGroup>
Expand All @@ -189,4 +190,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
53 changes: 48 additions & 5 deletions launcher/src/CmderLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <iostream>

#pragma comment(lib, "Shlwapi.lib")
#pragma comment(lib, "comctl32.lib")
#pragma warning( disable : 4091 )

#ifndef UNICODE
Expand All @@ -31,6 +32,39 @@

#define FAIL_ON_ERROR(x) { DWORD ec; if ((ec = (x)) != ERROR_SUCCESS) { ShowErrorAndExit(ec, __WFUNCTION__, __LINE__); } }

void TaskDialogOpen( PCWSTR mainStr, PCWSTR contentStr )
{

HRESULT hr = NULL;

TASKDIALOGCONFIG tsk = {sizeof(tsk)};

HWND hOwner = NULL;
HINSTANCE hInstance = GetModuleHandle(NULL);
PCWSTR tskTitle = MAKEINTRESOURCE(IDS_TITLE);

tsk.hInstance = hInstance;
tsk.pszMainIcon = MAKEINTRESOURCE(IDI_CMDER);
tsk.pszWindowTitle = tskTitle;
tsk.pszMainInstruction = mainStr;
tsk.pszContent = contentStr;

TASKDIALOG_BUTTON btns[1] = {
{ IDOK, L"OK" }
};

tsk.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION|TDF_ENABLE_HYPERLINKS;
tsk.pButtons = btns;
tsk.cButtons = _countof(btns);

tsk.hwndParent = hOwner;

int selectedButtonId = IDOK;

hr = TaskDialogIndirect( &tsk, &selectedButtonId, NULL, NULL );

}

void ShowErrorAndExit(DWORD ec, const wchar_t * func, int line)
{
wchar_t * buffer;
Expand Down Expand Up @@ -164,7 +198,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
*/
if (wcscmp(userConfigDirPath, L"") == 0)
{
// No - It wasn't.
// No - It wasn't.
PathCombine(userConfigDirPath, exeDir, L"config");
}
else
Expand Down Expand Up @@ -306,7 +340,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml");
}
}
else if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
else if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
{
if (PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml
{
Expand Down Expand Up @@ -673,16 +707,25 @@ cmderOptions GetOption()
}
else
{
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n /icon [CMDER Icon Path]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
}
else
{
MessageBox(NULL, L"Unrecognized parameter.\n\nValid options:\n\n /c [CMDER User Root Path]\n\n /task [ConEmu Task Name]\n\n /icon [CMDER Icon Path]\n\n [/start [Start in Path] | [Start in Path]]\n\n /single\n\n /m\n\n /x [ConEmu extra arguments]\n\nor\n\n /register [USER | ALL]\n\nor\n\n /unregister [USER | ALL]\n", MB_TITLE, MB_OK);
cmderOptions.error = true;
}
}

}

if (cmderOptions.error == true)
{
wchar_t validOptions[512];
HMODULE hMod = GetModuleHandle(NULL);
LoadString(hMod, IDS_SWITCHES, validOptions, 512);

// display list of valid options on unrecognized parameter
TaskDialogOpen( L"Unrecognized parameter.", validOptions );
}

LocalFree(szArgList);
Expand Down Expand Up @@ -725,4 +768,4 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}

return 0;
}
}
Binary file modified launcher/src/resource.h
Binary file not shown.
1 change: 1 addition & 0 deletions launcher/src/Resource.rc → launcher/src/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "resource.h"
#include "version.rc2"
#include "strings.rc2"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 12 additions & 0 deletions launcher/src/strings.rc2
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

/////////////////////////////////////////////////////////////////////////////
// Corresponding ids should be defined in `resource.h` file.

STRINGTABLE
{
IDS_TITLE "Cmder Launcher"

IDS_SWITCHES L"Valid options:\n\n /c [CMDER User Root Path]\n /task [ConEmu Task Name]\n /icon [CMDER Icon Path]\n [/start [Start in Path] | [Start in Path]]\n /single\n /m\n /x [ConEmu extra arguments]\n\nor, either:\n /register [USER | ALL]\n /unregister [USER | ALL]"
}

/////////////////////////////////////////////////////////////////////////////
11 changes: 5 additions & 6 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,23 @@ Param(
# -whatif switch to not actually make changes

# Path to the vendor configuration source file
[string]$sourcesPath = "..\vendor\sources.json",
[string]$sourcesPath = "$PSScriptRoot\..\vendor\sources.json",

# Vendor folder location
[string]$saveTo = "..\vendor\",
[string]$saveTo = "$PSScriptRoot\..\vendor\",

# Launcher folder location
[string]$launcher = "..\launcher",
[string]$launcher = "$PSScriptRoot\..\launcher",

# Config folder location
[string]$config = "..\config",
[string]$config = "$PSScriptRoot\..\config",

# New launcher if you have MSBuild tools installed
[switch]$Compile
)

# Get the scripts and cmder root dirs we are building in.
$ScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$cmder_root = $ScriptRoot.replace("\scripts","")
$cmder_root = Resolve-Path "$PSScriptRoot\.."

# Dot source util functions into this scope
. "$PSScriptRoot\utils.ps1"
Expand Down
13 changes: 13 additions & 0 deletions vendor/bin/cmder_shell.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off

set CMDER_ROOT=%~dp0..\

if "%cmder_init%" == "1" (
"%CMDER_ROOT%\vendor\clink\clink.bat" inject -q --profile "%CMDER_ROOT%\config" --scripts "%CMDER_ROOT%\vendor"
) else (
set cmder_init=1
)

pushd %CMDER_ROOT%
call "%CMDER_ROOT%\vendor\init.bat" /f
popd