Skip to content

Commit

Permalink
introduce version control by external py
Browse files Browse the repository at this point in the history
  • Loading branch information
KingfuChan committed Apr 20, 2024
1 parent 40d2631 commit 1ec57b7
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 1 deletion.
18 changes: 18 additions & 0 deletions UniSequence/BuildNumber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import time
import re

RX_BUILD = r"#define VERSION_BUILD (.+)"
RX_TIME = r"#define BUILD_TIME (.+)"

originlines = open("Version.h", 'r').readlines()
newlines = []
for l in originlines:
if (mb := re.match(RX_BUILD, l)) is not None:
bn = int(mb[1])+1
newlines.append(f"#define VERSION_BUILD {bn}\n")
elif (mt := re.match(RX_TIME, l)) is not None:
tm = time.strftime(r"%y%m%d%H%M", time.gmtime())
newlines.append(f"#define BUILD_TIME {tm}\n")
else:
newlines.append(l)
open("Version.h", 'w', newline='\r\n').writelines(newlines)
3 changes: 2 additions & 1 deletion UniSequence/UniSequence.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "Version.h"
#include "UniScreen.h"

using namespace EuroScopePlugIn;
Expand All @@ -16,7 +17,7 @@ constexpr auto SERVER_RESTFUL_TYPE_STATUS = "/status";
constexpr auto SERVER_RESTFUL_TYPE_ORDER = "/order";
constexpr auto DIVISION = "VATPRC";
constexpr auto PLUGIN_NAME = "UniSequence";
constexpr auto PLUGIN_VER = "v2.1.0";
constexpr auto PLUGIN_VER = "v" VERSION_FILE_STR;
constexpr auto PLUGIN_AUTHOR = "Ericple Garrison";
constexpr auto PLUGIN_COPYRIGHT = "AGPL-3.0 license";

Expand Down
Binary file added UniSequence/UniSequence.rc
Binary file not shown.
9 changes: 9 additions & 0 deletions UniSequence/UniSequence.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,19 @@
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>.\lib\EuroScopePlugInDll.lib</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>python BuildNumber.py</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="connection_metadata.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="lib\include\EuroScopePlugIn.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="UniScreen.h" />
<ClInclude Include="UniSequence.h" />
<ClInclude Include="Version.h" />
<ClInclude Include="websocket_endpoint.h" />
</ItemGroup>
<ItemGroup>
Expand All @@ -124,6 +129,10 @@
</ItemGroup>
<ItemGroup>
<None Include="..\README.md" />
<None Include="BuildNumber.py" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UniSequence.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
17 changes: 17 additions & 0 deletions UniSequence/UniSequence.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
<ClInclude Include="websocket_endpoint.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="UniScreen.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Version.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand All @@ -55,5 +64,13 @@
<None Include="..\README.md">
<Filter>资源文件</Filter>
</None>
<None Include="BuildNumber.py">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UniSequence.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
39 changes: 39 additions & 0 deletions UniSequence/Version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Version.h
// Revision number is used in next Release build

#pragma once

#ifndef VERSION_NUM_H
#define VERSION_NUM_H

#define STR_(s) #s
#define STR(s) STR_(s)
#define VERSION_MAJOR 2
#define VERSION_MINOR 1
#define VERSION_REVISION 0
#define BUILD_TIME 2404201809

#define VERSION_FILE VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION
#define VERSION_FILE_STR \
STR(VERSION_MAJOR) \
"." STR(VERSION_MINOR) \
"." STR(VERSION_REVISION)

#define VERSION_PRODUCT VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION,BUILD_TIME
#define VERSION_PRODUCT_STR \
STR(VERSION_MAJOR) \
"." STR(VERSION_MINOR) \
"." STR(VERSION_REVISION) \
"." STR(BUILD_TIME)

#ifdef DEBUG

#define VERSION_DISPLAY VERSION_FILE_STR "d" STR(BUILD_TIME)

#else

#define VERSION_DISPLAY VERSION_FILE_STR "r" STR(BUILD_TIME)

#endif // DEBUG

#endif // VERSION_NUM_H
14 changes: 14 additions & 0 deletions UniSequence/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by UniSequence.rc

// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
39 changes: 39 additions & 0 deletions Version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Version.h
// Revision number is used in next Release build

#pragma once

#ifndef VERSION_NUM_H
#define VERSION_NUM_H

#define STR_(s) #s
#define STR(s) STR_(s)
#define VERSION_MAJOR 3
#define VERSION_MINOR 4
#define VERSION_REVISION 0
#define BUILD_TIME 2404201803

#define VERSION_FILE VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION
#define VERSION_FILE_STR \
STR(VERSION_MAJOR) \
"." STR(VERSION_MINOR) \
"." STR(VERSION_REVISION)

#define VERSION_PRODUCT VERSION_MAJOR,VERSION_MINOR,VERSION_REVISION,BUILD_TIME
#define VERSION_PRODUCT_STR \
STR(VERSION_MAJOR) \
"." STR(VERSION_MINOR) \
"." STR(VERSION_REVISION) \
"." STR(BUILD_TIME)

#ifdef DEBUG

#define VERSION_DISPLAY VERSION_FILE_STR "d" STR(BUILD_TIME)

#else

#define VERSION_DISPLAY VERSION_FILE_STR "r" STR(BUILD_TIME)

#endif // DEBUG

#endif // VERSION_NUM_H

0 comments on commit 1ec57b7

Please sign in to comment.