versioning script
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,3 +20,4 @@ PanoPainter.aps
|
||||
panopainter-log.txt
|
||||
*.pano
|
||||
frames/
|
||||
engine/version.gen.h
|
||||
|
||||
BIN
PanoPainter.rc
BIN
PanoPainter.rc
Binary file not shown.
@@ -766,7 +766,7 @@
|
||||
<button-custom id="btn-clean-memory" margin="0 20 0 0">
|
||||
<icon icon="delete" width="20"/>
|
||||
</button-custom>
|
||||
<text text="PanoPainter 0.1.2 alpha" font-face="arial" font-size="11" margin="0 10 0 0" color=".2 .5 1 1"/>
|
||||
<text id="version" text="PanoPainter" font-face="arial" font-size="11" margin="0 10 0 0" color=".2 .5 1 1"/>
|
||||
</node>
|
||||
</border>
|
||||
<!-- toolbar -->
|
||||
|
||||
@@ -119,8 +119,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
<Command>python .\scripts\pre-build.py debug</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -163,8 +162,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
<Command>python .\scripts\pre-build.py release</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -230,6 +228,10 @@
|
||||
<ClCompile Include="engine\shape.cpp" />
|
||||
<ClCompile Include="engine\texture.cpp" />
|
||||
<ClCompile Include="engine\util.cpp" />
|
||||
<ClCompile Include="engine\version.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="engine\wacom.cpp" />
|
||||
<ClCompile Include="libs\jpeg\jpgd.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
||||
@@ -336,6 +338,8 @@
|
||||
<ClInclude Include="engine\shape.h" />
|
||||
<ClInclude Include="engine\texture.h" />
|
||||
<ClInclude Include="engine\util.h" />
|
||||
<ClInclude Include="engine\version.gen.h" />
|
||||
<ClInclude Include="engine\version.h" />
|
||||
<ClInclude Include="engine\wacom.h" />
|
||||
<ClInclude Include="libs\jpeg\jpgd.h" />
|
||||
<ClInclude Include="libs\jpeg\jpge.h" />
|
||||
|
||||
@@ -249,6 +249,9 @@
|
||||
<ClCompile Include="engine\node_panel_grid.cpp">
|
||||
<Filter>Source Files\ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="engine\version.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="engine\app.h">
|
||||
@@ -440,6 +443,12 @@
|
||||
<ClInclude Include="engine\node_panel_grid.h">
|
||||
<Filter>Header Files\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="engine\version.gen.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="engine\version.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PanoPainter.rc">
|
||||
|
||||
@@ -632,6 +632,13 @@ void App::initLayout()
|
||||
init_menu_layer();
|
||||
init_menu_timelapse();
|
||||
|
||||
// set version string
|
||||
if (auto* version_label = layout[main_id]->find<NodeText>("version"))
|
||||
{
|
||||
version_label->set_text(g_version);
|
||||
}
|
||||
|
||||
|
||||
if (auto* menu_entry = layout[main_id]->find<NodeButtonCustom>("menu-about"))
|
||||
{
|
||||
menu_entry->on_click = [=](Node*) {
|
||||
|
||||
@@ -357,6 +357,9 @@ int main(int argc, char** argv)
|
||||
LOG("GL vendor: %s", glGetString(GL_VENDOR));
|
||||
LOG("GL renderer: %s", glGetString(GL_RENDERER));
|
||||
|
||||
static wchar_t window_title[512];
|
||||
swprintf_s(window_title, L"PanoPainter %s", g_version_number_w);
|
||||
|
||||
// If supported create a 3.1 context
|
||||
if (wglewIsSupported("WGL_ARB_create_context"))
|
||||
{
|
||||
@@ -388,7 +391,7 @@ int main(int argc, char** argv)
|
||||
wglDeleteContext(hRC);
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
hWnd = CreateWindow(wc.lpszClassName, L"PanoPainter 0.1.2 alpha - OpenGL 3.1", WS_OVERLAPPEDWINDOW,
|
||||
hWnd = CreateWindow(wc.lpszClassName, window_title, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, clientRect.right - clientRect.left,
|
||||
clientRect.bottom - clientRect.top, 0, 0, hInst, 0);
|
||||
|
||||
@@ -451,9 +454,9 @@ int main(int argc, char** argv)
|
||||
|
||||
if (one_sec > 1.f)
|
||||
{
|
||||
static char title[512];
|
||||
sprintf_s(title, "PanoPainter 0.1.2 alpha - OpenGL 3.1 - %d fps", frames);
|
||||
SetWindowTextA(hWnd, title);
|
||||
static wchar_t title_fps[512];
|
||||
swprintf_s(title_fps, L"%s - %d fps", window_title, frames);
|
||||
SetWindowText(hWnd, title_fps);
|
||||
one_sec = 0;
|
||||
frames = 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
//#pragma once
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#define USE_VBO 1
|
||||
#define USE_SAMPLER 1
|
||||
|
||||
|
||||
11
engine/version.cpp
Normal file
11
engine/version.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "version.h"
|
||||
#include "version.gen.h"
|
||||
#include "windows.h"
|
||||
|
||||
const char* g_version = PP_VERSION_STRING;
|
||||
const char* g_version_number = PP_VERSION_NUMBER_STRING;
|
||||
const char* g_window_title = "PanoPainter " PP_VERSION_NUMBER_STRING;
|
||||
|
||||
const wchar_t* g_version_w = TEXT(PP_VERSION_STRING);
|
||||
const wchar_t* g_version_number_w = TEXT(PP_VERSION_NUMBER_STRING);
|
||||
const wchar_t* g_window_title_w = L"PanoPainter " TEXT(PP_VERSION_NUMBER_STRING);
|
||||
9
engine/version.h
Normal file
9
engine/version.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
extern const char* g_version;
|
||||
extern const char* g_version_number;
|
||||
extern const char* g_window_title;
|
||||
|
||||
extern const wchar_t* g_version_w;
|
||||
extern const wchar_t* g_version_number_w;
|
||||
extern const wchar_t* g_window_title_w;
|
||||
43
scripts/pre-build.py
Normal file
43
scripts/pre-build.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from subprocess import Popen, PIPE, check_output
|
||||
from tempfile import mkstemp
|
||||
from shutil import move
|
||||
from os import remove, close
|
||||
import re, subprocess, sys
|
||||
|
||||
branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip().decode("utf-8")
|
||||
shorthash = check_output(["git", "log", "--pretty=format:%h", "-n 1"]).rstrip().decode("utf-8")
|
||||
revcount = len(check_output(["git", "log", "--oneline"]).split(b'\n')) - 1
|
||||
tag = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode("utf-8")
|
||||
config = sys.argv[1]
|
||||
|
||||
version = "%s.%d (%s-%s-%s)" % (tag, revcount, shorthash, branch, config)
|
||||
version_number = "%s.%d" % (tag, revcount)
|
||||
|
||||
print("Compiling version: %s" % version)
|
||||
|
||||
version_gen_h = '// AUTO GENERATED FILE - DON\'T MODIFY\n'
|
||||
version_gen_h += '#define PP_VERSION_NUMBER_STRING "%s"\n' % version_number
|
||||
version_gen_h += '#define PP_VERSION_STRING "%s"\n' % version
|
||||
f = open("engine/version.gen.h", "w")
|
||||
f.write(version_gen_h)
|
||||
|
||||
|
||||
"""
|
||||
file_path = "Setup\\Product.wxs";
|
||||
#Create temp file
|
||||
fh, abs_path = mkstemp()
|
||||
regex = re.compile(r'Version="\d+\.\d+\.\d+\.\d+"')
|
||||
with open(abs_path,'w') as new_file:
|
||||
with open(file_path) as old_file:
|
||||
for line in old_file:
|
||||
new_line = regex.sub('Version="%s"' % version, line)
|
||||
new_file.write(new_line)
|
||||
close(fh)
|
||||
#Remove original file
|
||||
remove(file_path)
|
||||
#Move new file
|
||||
move(abs_path, file_path)
|
||||
"""
|
||||
|
||||
|
||||
exit(0)
|
||||
Reference in New Issue
Block a user