mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-25 15:49:08 +08:00
Merge pull request #1730 from DRSDavidSoft/dev-david
Generate Win32 version string based on build no, git tag or fallback to changelog
This commit is contained in:
commit
959073ac5c
@ -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">
|
||||
@ -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>
|
||||
@ -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>
|
||||
|
Binary file not shown.
54
launcher/src/app.manifest
Normal file
54
launcher/src/app.manifest
Normal file
@ -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
launcher/src/version.rc2.sample
Normal file
27
launcher/src/version.rc2.sample
Normal file
@ -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
|
||||
/////////////////////////////////////////////////////////////////////////////
|
@ -58,12 +58,15 @@ $ScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
|
||||
$cmder_root = $ScriptRoot.replace("\scripts","")
|
||||
|
||||
# Dot source util functions into this scope
|
||||
. ".\utils.ps1"
|
||||
. "$PSScriptRoot\utils.ps1"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Push-Location -Path $saveTo
|
||||
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json
|
||||
|
||||
# Get the version string
|
||||
$version = Get-VersionStr
|
||||
|
||||
# Check for requirements
|
||||
Ensure-Exists $sourcesPath
|
||||
Ensure-Executable "7z"
|
||||
@ -116,10 +119,17 @@ Pop-Location
|
||||
|
||||
if($Compile) {
|
||||
Push-Location -Path $launcher
|
||||
msbuild CmderLauncher.vcxproj /p:configuration=Release
|
||||
Create-RC $version ($launcher + '\src\version.rc2');
|
||||
msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release
|
||||
if ($LastExitCode -ne 0) {
|
||||
throw "msbuild failed to build the executable."
|
||||
}
|
||||
else {
|
||||
Write-Verbose "successfully built Cmder v$version!"
|
||||
if ( $Env:APPVEYOR -eq 'True' ) {
|
||||
Add-AppveyorMessage -Message "Building Cmder v$version was successful." -Category Information
|
||||
}
|
||||
}
|
||||
Pop-Location
|
||||
} else {
|
||||
Write-Warning "You are not building a launcher, Use -Compile"
|
||||
|
@ -48,7 +48,7 @@ $targets = @{
|
||||
Delete-Existing "..\Version*"
|
||||
Delete-Existing "..\build\*"
|
||||
|
||||
$version = Invoke-Expression "git describe --abbrev=0 --tags"
|
||||
$version = Get-VersionStr
|
||||
(New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null
|
||||
|
||||
foreach ($t in $targets.GetEnumerator()) {
|
||||
|
@ -62,6 +62,85 @@ function Digest-Hash($path) {
|
||||
return Invoke-Expression "md5sum $path"
|
||||
}
|
||||
|
||||
function Get-VersionStr() {
|
||||
|
||||
# Clear existing variable
|
||||
if ($string) { Clear-Variable -name string }
|
||||
|
||||
# Determine if git is available
|
||||
if (Get-Command "git.exe" -ErrorAction SilentlyContinue)
|
||||
{
|
||||
|
||||
# Determine if the current diesctory is a git repository
|
||||
$GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue
|
||||
|
||||
if ( $GitPresent -eq 'true' )
|
||||
{
|
||||
$string = Invoke-Expression "git describe --abbrev=0 --tags"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Fallback used when Git is not available
|
||||
if ( -not($string) )
|
||||
{
|
||||
$string = Parse-Changelog ($PSScriptRoot + '\..\' + 'CHANGELOG.md')
|
||||
}
|
||||
|
||||
# Add build number, if AppVeyor is present
|
||||
if ( $Env:APPVEYOR -eq 'True' )
|
||||
{
|
||||
$string = $string + '.' + $Env:APPVEYOR_BUILD_NUMBER
|
||||
}
|
||||
|
||||
# Remove starting 'v' characters
|
||||
$string = $string -replace '^v+','' # normalize version string
|
||||
|
||||
return $string
|
||||
|
||||
}
|
||||
|
||||
function Parse-Changelog($file) {
|
||||
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user