From c7bf4b0474c613f81e3724043386373d7bc7d2a3 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Fri, 27 Dec 2013 12:05:07 -0800 Subject: [PATCH] Replaced use of T4 templates with PS-based templates. TextTransform.exe is not available with Express versions of Visual Studio. --- config-win32.h.tt | 6 +++--- src/common/common.vcxproj | 6 ++++-- src/fe-gtk/fe-gtk.vcxproj | 4 +++- src/fe-gtk/hexchat.rc.tt | 4 ++-- version-template.ps1 | 12 ++++++++++++ version.include.tt | 12 ------------ win32/hexchat.props | 2 -- win32/installer/hexchat.iss.tt | 4 ++-- win32/installer/installer.vcxproj | 2 +- win32/version.txt.tt | 2 +- 10 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 version-template.ps1 delete mode 100644 version.include.tt diff --git a/config-win32.h.tt b/config-win32.h.tt index 8f21d0b1..fc1679f6 100644 --- a/config-win32.h.tt +++ b/config-win32.h.tt @@ -1,4 +1,4 @@ -<#@ include file="version.include.tt" #>#define LOCALEDIR ".\\share\\locale" +#define LOCALEDIR ".\\share\\locale" #define ENABLE_NLS #define USE_GMODULE #define USE_PLUGIN @@ -8,12 +8,12 @@ #define ISO_CODES_PREFIX ".\\" #define ISO_CODES_LOCALEDIR LOCALEDIR #define PACKAGE_NAME "hexchat" -#define PACKAGE_VERSION "<#= string.Join(".", versionParts) #>" +#define PACKAGE_VERSION "<#= [string]::Join('.', $versionParts) #>" #define HEXCHATLIBDIR ".\\plugins" #define HEXCHATSHAREDIR "." #define OLD_PERL #define GETTEXT_PACKAGE "hexchat" -#define PACKAGE_TARNAME "hexchat-<#= string.Join(".", versionParts) #>" +#define PACKAGE_TARNAME "hexchat-<#= [string]::Join('.', $versionParts) #>" #ifndef USE_IPV6 #define socklen_t int #endif diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 39c50222..720faae7 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -159,8 +159,10 @@ diff --git a/src/fe-gtk/fe-gtk.vcxproj b/src/fe-gtk/fe-gtk.vcxproj index f7341904..6b6301b2 100644 --- a/src/fe-gtk/fe-gtk.vcxproj +++ b/src/fe-gtk/fe-gtk.vcxproj @@ -100,7 +100,9 @@ diff --git a/src/fe-gtk/hexchat.rc.tt b/src/fe-gtk/hexchat.rc.tt index 87507340..2b384c49 100644 --- a/src/fe-gtk/hexchat.rc.tt +++ b/src/fe-gtk/hexchat.rc.tt @@ -1,7 +1,7 @@ -<#@ include file="..\..\version.include.tt" #>#include +#include #include "../../config-win32.h" -#define COMMA_VERSION <#= string.Join(",", versionParts) #>,0 +#define COMMA_VERSION <#= [string]::Join(',', $versionParts) #>,0 XC_ICON ICON "../../data/icons/hexchat.ico" diff --git a/version-template.ps1 b/version-template.ps1 new file mode 100644 index 00000000..18eb90d9 --- /dev/null +++ b/version-template.ps1 @@ -0,0 +1,12 @@ +param ([string] $templateFilename, [string] $outputFilename) + +$versionParts = Select-String -Path "${env:SOLUTIONDIR}configure.ac" -Pattern '^AC_INIT\(\[HexChat\],\[([^]]+)\]\)$' | Select-Object -First 1 | %{ $_.Matches[0].Groups[1].Value.Split('.') } + +[string[]] $contents = Get-Content $templateFilename -Encoding UTF8 | %{ + while ($_ -match '^(.*?)<#=(.*?)#>(.*?)$') { + $_ = $Matches[1] + $(Invoke-Expression $Matches[2]) + $Matches[3] + } + $_ +} + +[System.IO.File]::WriteAllLines($outputFilename, $contents) diff --git a/version.include.tt b/version.include.tt deleted file mode 100644 index ab77a6d9..00000000 --- a/version.include.tt +++ /dev/null @@ -1,12 +0,0 @@ -<#@ - template debug="false" hostspecific="false" language="C#" #><#@ - assembly name="System.Core" #><#@ - import namespace="System.IO" #><#@ - import namespace="System.Linq" #><#@ - import namespace="System.Text.RegularExpressions" #><# - var versionParts = File.ReadLines(Path.Combine(System.Environment.GetEnvironmentVariable("SOLUTIONDIR"), "configure.ac")) - .Select(line => Regex.Match(line, @"^AC_INIT\(\[HexChat\],\[([^]]+)\]\)$")) - .First(match => match.Success) - .Groups[1].Value - .Split('.'); -#> \ No newline at end of file diff --git a/win32/hexchat.props b/win32/hexchat.props index 3acfd913..8f5b6644 100644 --- a/win32/hexchat.props +++ b/win32/hexchat.props @@ -94,8 +94,6 @@ copy "$(HexChatBin)hcsysinfo.dll" "$(HexChatRel)\plugins" xcopy /q /s /i "$(HexChatBin)locale" "$(HexChatRel)\share\locale" xcopy /q /s /i "$(DepsRoot)\share\locale" "$(HexChatRel)\share\locale" - "%PROGRAMFILES%\Common Files\microsoft shared\TextTemplating\12.0\TextTransform.exe" - "%PROGRAMFILES(x86)%\Common Files\microsoft shared\TextTemplating\12.0\TextTransform.exe" "%PROGRAMFILES%\Inno Setup 5\iscc.exe" "%PROGRAMFILES(x86)%\Inno Setup 5\iscc.exe" diff --git a/win32/installer/hexchat.iss.tt b/win32/installer/hexchat.iss.tt index 1ba55303..74156720 100644 --- a/win32/installer/hexchat.iss.tt +++ b/win32/installer/hexchat.iss.tt @@ -1,5 +1,5 @@ -<#@ include file="..\..\version.include.tt" #>#define APPNAM "HexChat" -#define APPVER "<#= string.Join(".", versionParts) #>" +#define APPNAM "HexChat" +#define APPVER "<#= [string]::Join('.', $versionParts) #>" ; These are defined by our installer project at build time ;#define APPARCH "x64" ;#define PROJECTDIR "C:\...\hexchat\win32\installer\" diff --git a/win32/installer/installer.vcxproj b/win32/installer/installer.vcxproj index 09654ab0..0e46f373 100644 --- a/win32/installer/installer.vcxproj +++ b/win32/installer/installer.vcxproj @@ -64,7 +64,7 @@ > "$(OutDir)hexchat.iss" $(IsccPath) /dPROJECTDIR="$(ProjectDir)" /dAPPARCH="$(Platform)" "$(OutDir)hexchat.iss" diff --git a/win32/version.txt.tt b/win32/version.txt.tt index 64e50010..778db65c 100644 --- a/win32/version.txt.tt +++ b/win32/version.txt.tt @@ -1 +1 @@ -<#@ include file="..\version.include.tt" #><#= string.Join(".", versionParts) #> \ No newline at end of file +<#= [string]::Join('.', $versionParts) #> \ No newline at end of file