From 37ec92c72e39795c4510d5196f79ea7dc0c7c2f6 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sun, 16 Sep 2018 13:34:49 +0200 Subject: [PATCH] versioning script --- .gitignore | 1 + PanoPainter.rc | Bin 3264 -> 5144 bytes data/layout.xml | 2 +- engine.vcxproj | 12 ++++++++---- engine.vcxproj.filters | 9 +++++++++ engine/app_layout.cpp | 7 +++++++ engine/main.cpp | 11 +++++++---- engine/pch.h | 2 ++ engine/version.cpp | 11 +++++++++++ engine/version.h | 9 +++++++++ scripts/pre-build.py | 43 +++++++++++++++++++++++++++++++++++++++++ 11 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 engine/version.cpp create mode 100644 engine/version.h create mode 100644 scripts/pre-build.py diff --git a/.gitignore b/.gitignore index c54bd13..e9f7710 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ PanoPainter.aps panopainter-log.txt *.pano frames/ +engine/version.gen.h diff --git a/PanoPainter.rc b/PanoPainter.rc index 4c4255c65c19a39bb84d05e7b519f1641909b18a..d1bb1e7ef920414cf66a6be8d84ff8b5b4f153bc 100644 GIT binary patch literal 5144 zcmdUzTW?xN5Xa}aQoq9%za(m8n`}^;* zoO9qnWzq+#)nU)>&dknz=J5CD3%f99*EY0Ao7>bDJWsY{ufyKLR`y^cRwetE;cQ@i zoAAupUo!XDn==b<#oHtAj+LklZ3fJ_eQjTH%Y~oM*qv}X0=nm63p@Dd_PZ54v@p*+ z+>^%>?RR!#Eo)NeV*e&zku)6)mPK)1byJDx#d%RyfoZg7s#o1XEy=?3F z2`x=+jQmTqBR#Z{`d5ByNL@ls>7&B_Yo2Y3{JRbQ@cIpSS^b}$#v(_-J67mQp7ey= z$N5Ioe589?bL7rp-3jqG!cq%-z}X9IK4BH(u*F-5%7wkm@q$GvriNZ$-(+H|2gP^x z9;#-`h%Togs)Gkemi-=}_~;Y1N zxJRTZ$AqCAk(Y0Fy)D}4w6aQ?8*!+0oE@I>NVS=4cG5B=r_NhZ^~jNxrmWNlsCTI0 zH_kr#-eKjd)eMLS-yNu9P&J>gVV7V!uVHl?sz46N8AF-w(Py-w=f?SUny*ml#=xkn zSb!P$Ua%G?s-xmZIHEdYs5|*{eL7|iwNV_`$XPYAo%#qx)S(gK4#A|)3LDukq)`J3rvM7&_bWmru5pNvNX|Y_9X5L+W}D{>sPj5 z9M*V6Rtitid!?fbyoFwwT2LY{WvS+4MC$K-WvRm5H5H~sWpGgcWN+}xx~Hz3mDCi~ zz6$l|jvSihGochH6gT*NJZ*uV4#Quj;MK+G)+|O7{sQf{@Tl>2jgx4rO}Bdkhglwy z^H5E*Q1Ryc%AnfYM6c3J0S=bfTM;(ELPI3$W2XtcPPcM(KD8JJS*nuc(!Tc+ec(5n z^%I=D$`w!J+`*3OfTe>1e5+HQ5$_Wsy}>+&|DytT|^^w%pd8 z^69{PLLd5lv?#p>kBz#@&RNUUfggCvve69d$gc)ekR^1~`337`Pt@s_eCPQZxr+AP zv+iuJ?~wmWrf5B_(th!!vfXgc6i-@FgO)p*%X&i=)_Kmv%k#V-OXYZ9Ncy~JyWO2^ z>~_%Ie51)@azWNF+E7!pF0hZjVA7GK%p5X>{G&)8sw|lHxrE!~P3Qajw*Tf!>U3)K zHYbuk{e*gU=sS70Z{4POI%`QLZsPo<|Cs1I;_yEvQJ1HqgKbX4;eLOgkeSp6@BTls IYj;ul2X{ - + diff --git a/engine.vcxproj b/engine.vcxproj index 1e510a9..c63041d 100644 --- a/engine.vcxproj +++ b/engine.vcxproj @@ -119,8 +119,7 @@ true - - + python .\scripts\pre-build.py debug @@ -163,8 +162,7 @@ true - - + python .\scripts\pre-build.py release @@ -230,6 +228,10 @@ + + NotUsing + NotUsing + NotUsing @@ -336,6 +338,8 @@ + + diff --git a/engine.vcxproj.filters b/engine.vcxproj.filters index b681c9b..bb72dac 100644 --- a/engine.vcxproj.filters +++ b/engine.vcxproj.filters @@ -249,6 +249,9 @@ Source Files\ui + + Source Files + @@ -440,6 +443,12 @@ Header Files\ui + + Header Files + + + Header Files + diff --git a/engine/app_layout.cpp b/engine/app_layout.cpp index 8e13fe6..1f9429c 100644 --- a/engine/app_layout.cpp +++ b/engine/app_layout.cpp @@ -632,6 +632,13 @@ void App::initLayout() init_menu_layer(); init_menu_timelapse(); + // set version string + if (auto* version_label = layout[main_id]->find("version")) + { + version_label->set_text(g_version); + } + + if (auto* menu_entry = layout[main_id]->find("menu-about")) { menu_entry->on_click = [=](Node*) { diff --git a/engine/main.cpp b/engine/main.cpp index 624ed79..2301410 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -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; } diff --git a/engine/pch.h b/engine/pch.h index f9526b7..b21f7de 100644 --- a/engine/pch.h +++ b/engine/pch.h @@ -1,5 +1,7 @@ //#pragma once +#include "version.h" + #define USE_VBO 1 #define USE_SAMPLER 1 diff --git a/engine/version.cpp b/engine/version.cpp new file mode 100644 index 0000000..b49c6da --- /dev/null +++ b/engine/version.cpp @@ -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); diff --git a/engine/version.h b/engine/version.h new file mode 100644 index 0000000..6f70250 --- /dev/null +++ b/engine/version.h @@ -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; diff --git a/scripts/pre-build.py b/scripts/pre-build.py new file mode 100644 index 0000000..ab5b492 --- /dev/null +++ b/scripts/pre-build.py @@ -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)