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

Generate Win32 version string based on build no, git tag or fallback to changelog #1730

Merged
merged 27 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1662678
fixed line endings
DRSDavidSoft Mar 28, 2018
a85cd81
added version resources and manifest.
DRSDavidSoft Mar 28, 2018
dc9e385
add cmder manifest file
DRSDavidSoft Mar 28, 2018
96736fe
added version.rc2.sample
DRSDavidSoft Mar 28, 2018
f4321bb
add functions to get version and generate rc
DRSDavidSoft Mar 28, 2018
eaf7048
add automatic version creation
DRSDavidSoft Mar 28, 2018
249f7b9
add build flags; use spaces
DRSDavidSoft Mar 28, 2018
f8359fc
add verbose version info
DRSDavidSoft Mar 28, 2018
018bf45
add version string handler
DRSDavidSoft Mar 28, 2018
57a28f1
add template for version string
DRSDavidSoft Mar 28, 2018
3aeca3c
add required block to else statement
DRSDavidSoft Mar 28, 2018
ae473ec
add escaped quotes handling
DRSDavidSoft Mar 28, 2018
2bc17c4
renamed app.manifest
DRSDavidSoft Mar 28, 2018
1dadade
replaces spaces to tabs
DRSDavidSoft Mar 28, 2018
cb4d95e
added build number, removed duplicated manifest
DRSDavidSoft Mar 28, 2018
2f3f1d4
specified custom manifest file
DRSDavidSoft Mar 28, 2018
236aefe
add build version string
DRSDavidSoft Mar 28, 2018
c817df2
add build version str; fix padding
DRSDavidSoft Mar 28, 2018
624deec
minor edit – added a character to the verbose output
DRSDavidSoft Mar 28, 2018
93d2c42
respect powershell naming convention
DRSDavidSoft Mar 28, 2018
3965852
clean before build
DRSDavidSoft Mar 28, 2018
b36b8a4
new version handle logic
DRSDavidSoft Mar 30, 2018
502129d
minor fix
DRSDavidSoft Mar 30, 2018
5c3f46f
fix git detection statement
DRSDavidSoft Mar 30, 2018
7d04ded
add appveyor message
DRSDavidSoft Mar 30, 2018
d656919
replace tabs to spaces
DRSDavidSoft Mar 30, 2018
94e7c24
minor typo fix
DRSDavidSoft Mar 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion launcher/CmderLauncher.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -61,6 +61,9 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<Manifest>
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
<ResourceCompile>
<PreprocessorDefinitions>_USING_V110_SDK71_;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
Expand All @@ -84,6 +87,9 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<Manifest>
<AdditionalManifestFiles>src/app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
<PostBuildEvent>
<Command>copy $(TargetPath) $(SolutionDir)..\$(TargetFileName)</Command>
</PostBuildEvent>
Expand Down
Binary file modified launcher/src/Resource.rc
Binary file not shown.
54 changes: 54 additions & 0 deletions launcher/src/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">

<!-- Project description definition -->
<description>Cmder Console Emulator</description>

<!-- Project dependency definition -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>

<!-- Win32 User Account Control definition -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<!-- Required for appcompat behaviour -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>

<!-- Add dpi awareness -->
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true/pm</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>

</assembly>
27 changes: 27 additions & 0 deletions launcher/src/version.rc2.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

/**
* WARNING: do NOT modify this file! the content of this file should be
* automatically genereted before AppVeyor builds using the
* respective .ps1 Powershell scripts.
*
*/

/////////////////////////////////////////////////////////////////////////////
// Define the version numbers and build information manually here:

#define CMDER_MAJOR_VERSION {Cmder-Major-Version}
#define CMDER_MINOR_VERSION {Cmder-Minor-Version}
#define CMDER_REVISION_VERSION {Cmder-Revision-Version}
#define CMDER_BUILD_VERSION {Cmder-Build-Version}
#define CMDER_VERSION_STR {Cmder-Version-Str}

#define CMDER_PRODUCT_NAME_STR "Cmder"
#define CMDER_FILE_DESCRIPTION_STR "Cmder: Lovely Console Emulator."
#define CMDER_INTERNAL_NAME_STR "Cmder"
#define CMDER_ORIGINAL_FILENAME_STR "Cmder.exe"
#define CMDER_COMPANY_NAME_STR "Samuel Vasko"
#define CMDER_COPYRIGHT_YEAR_STR "2016"

#define CMDER_DEBUGFLAG 0x0L // set to 0x1L to enable debug mode
#define CMDER_BUILDFLAGS 0x0L
/////////////////////////////////////////////////////////////////////////////
7 changes: 7 additions & 0 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ $ErrorActionPreference = "Stop"
Push-Location -Path $saveTo
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json

# Get the version string
$Version = Get-Version-Str ($PSScriptRoot + '\..\' + 'CHANGELOG.md')

# Check for requirements
Ensure-Exists $sourcesPath
Ensure-Executable "7z"
Expand Down Expand Up @@ -116,10 +119,14 @@ Pop-Location

if($Compile) {
Push-Location -Path $launcher
Create-RC $Version ($launcher + '\src\version.rc2');
msbuild CmderLauncher.vcxproj /p:configuration=Release
if ($LastExitCode -ne 0) {
throw "msbuild failed to build the executable."
}
else {
Write-Verbose "successfully built Cmder v$Version!"
}
Pop-Location
} else {
Write-Warning "You are not building a launcher, Use -Compile"
Expand Down
41 changes: 41 additions & 0 deletions scripts/utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,47 @@ function Digest-Hash($path) {
return Invoke-Expression "md5sum $path"
}

function Get-Version-Str($file) {
DRSDavidSoft marked this conversation as resolved.
Show resolved Hide resolved

# Define the regular expression to match the version string from changelog
[regex]$regex = '^## \[(?<version>[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$';

# Find the first match of the version string which means the latest version
$version = Select-String -Path $file -Pattern $regex | Select-Object -First 1 | % { $_.Matches.Groups[1].Value }

return $version
}

function Create-RC($string, $path) {

$version = $string + '.0.0.0.0' # padding for version string

if ( !(Test-Path "$path.sample") ) {
throw "Invalid path provided for resources file."
}

$resource = Get-Content -Path "$path.sample"
$pattern = @( "Cmder-Major-Version", "Cmder-Minor-Version", "Cmder-Revision-Version", "Cmder-Build-Version" )
$index = 0

# Replace all non-numeric characters to dots and split to array
$version = $version -replace '[^0-9]+','.' -split '\.'

foreach ($fragment in $version) {
if ( !$fragment ) { break }
elseif ($index -le $pattern.length) {
$resource = $resource.Replace( "{" + $pattern[$index++] + "}", $fragment )
}
}

# Add the version string
$resource = $resource.Replace( "{Cmder-Version-Str}", '"' + $string + '"' )

# Write the results
Set-Content -Path $path -Value $resource

}

function Register-Cmder() {
[CmdletBinding()]
Param
Expand Down