-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpdateVersion.ps1
30 lines (24 loc) · 1.12 KB
/
UpdateVersion.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
param([switch] $Force)
$vcsFile = "VersionVCS.h"
$vcsOld = Get-Content -ErrorAction Ignore -Raw $vcsFile
$vcsRev = git describe --tags --long --dirty --always
$vcsNew = "#pragma once`n`n#define VCS_REVISION L""$vcsRev""`n"
if ($Force -or ($vcsOld -ne $vcsNew)) {
echo "Updating revision: $vcsRev"
[System.IO.File]::WriteAllText($vcsFile, [string]::Join("`n", $vcsNew))
}
Get-Content -Raw "$PSScriptRoot\Version.ps1" | Invoke-Expression
$hFile = "VersionNumbers.h"
$hOld = Get-Content -ErrorAction Ignore -Raw $hFile
$hNew = `
@"
#pragma once
#define FILEVERSION_TUPLE $($fileVersion[0]),$($fileVersion[1]),$($fileVersion[2]),$($fileVersion[3])
#define FILEVERSION_TEXT "$($fileVersion[0]).$($fileVersion[1]).$($fileVersion[2]).$($fileVersion[3])"
#define PRODUCTVERSION_TUPLE $($productVersion[0]),$($productVersion[1]),$($productVersion[2]),$($productVersion[3])
#define PRODUCTVERSION_TEXT "$($productVersion[0]).$($productVersion[1]).$($productVersion[2]).$($productVersion[3])"
"@
if ($Force -or ($hOld -ne $hNew)) {
echo "Updating version header"
[System.IO.File]::WriteAllText($hFile, [string]::Join("`n", $hNew))
}