Skip to content

Commit

Permalink
Versioning system with PS1 script
Browse files Browse the repository at this point in the history
  • Loading branch information
hernandp committed Jul 16, 2017
1 parent e4f17c1 commit 2109146
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
42 changes: 42 additions & 0 deletions build/verstamp.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#/*****************************************************************************
#
# CartelMania
# Copyright(C) 2017 Hernán Di Pietro
#
# This program is free software : you can redistribute it and / or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.If not, see < http://www.gnu.org/licenses/>.
#
#****************************************************************************/

# Version stamping script
#
#
# The script should stamp "revision" field with the number days elapsed from
# 1, January, 2017.
#
# Build number will be set to the minute of the day in which the build
# was made (0-1440).
#

$timespan = (new-timespan -end (get-date -year 2017 -month 1 -day 1));
$hour = Get-Date -UFormat %H;
$mins = Get-Date -UFormat %M;
$todaymins = $hour.ToInt32($Null) * 60 + $mins.Toint32($Null)

$filetext = Get-Content -Path "..\src\version.h" -ErrorAction Stop;
$build = "#define _BUILDPLACEHOLDER " + $todaymins;
$rev = "#define _REVPLACEHOLDER " + -$timespan.Days;
$filetext = $filetext -replace "#define _BUILDPLACEHOLDER [ 0-9]*$", $build;
$filetext = $filetext -replace "#define _REVPLACEHOLDER [ 0-9]*$", $rev;

Set-Content -Path "..\src\version.h" -Value $filetext -ErrorAction Stop;
Binary file modified src/CartelMania.rc
Binary file not shown.
13 changes: 13 additions & 0 deletions src/CartelMania.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PreBuildEvent>
<Command>powershell $(SolutionDir)\build\verstamp.ps1</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Version stamping</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
Expand All @@ -170,6 +176,12 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
</Link>
<PreBuildEvent>
<Command>powershell $(SolutionDir)\build\verstamp.ps1</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>Version stamping</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\pugixml\pugixml.cpp">
Expand Down Expand Up @@ -354,6 +366,7 @@
<ClInclude Include="TextFx.h" />
<ClInclude Include="GdiPEngWrapper.h" />
<ClInclude Include="TextEditToolWnd.h" />
<ClInclude Include="Version.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CartelMania.rc" />
Expand Down
3 changes: 3 additions & 0 deletions src/CartelMania.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
<ClInclude Include="AboutDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Version.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="CartelMania.rc">
Expand Down
48 changes: 48 additions & 0 deletions src/Version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once
/*****************************************************************************
CartelMania
Copyright(C) 2017 Hernán Di Pietro
This program is free software : you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see < http://www.gnu.org/licenses/>.
*****************************************************************************/

/** Version Data -- this file is processed by VerStamp.ps1 Pre-build step
on release configurations by stamping data on _REVPLACEHOLDER and
_BUILDPLACEHOLDER definitions. Do not mess this!
Initial value should be 9999,0.
The script should stamp "revision" field with year/month/day. Month
in hex (0-C), e.g: for 2017-11-30: 17B30.
Build number will be set to the minute of the day in which the build
was made (0-1440).
See verstamp.ps1 script in pre-build step for details.
**/


#define _REVPLACEHOLDER 196
#define _BUILDPLACEHOLDER 1230

// ---------------------------------------------------------------------------
#define CMANIA_VERSION_MAJOR 0
#define CMANIA_VERSION_MINOR 5
#define CMANIA_VERSION_REV _REVPLACEHOLDER
#define CMANIA_VERSION_BUILD _BUILDPLACEHOLDER
// ---------------------------------------------------------------------------

0 comments on commit 2109146

Please sign in to comment.