Add git sha1 info to the binary.
This commit is contained in:
parent
23010d032b
commit
6dfeeba7f9
7 changed files with 25 additions and 1 deletions
|
@ -26,6 +26,12 @@ project_config_file = configure_file(
|
||||||
output: 'config.h',
|
output: 'config.h',
|
||||||
configuration: conf
|
configuration: conf
|
||||||
)
|
)
|
||||||
|
gitrev_config_file = vcs_tag(
|
||||||
|
command: ['git', 'rev-parse', 'HEAD'],
|
||||||
|
input: 'src/git_version.h.in',
|
||||||
|
output: 'git_version.h',
|
||||||
|
fallback: 'n/a'
|
||||||
|
)
|
||||||
app_config_model = files('src/app_config.h.in')
|
app_config_model = files('src/app_config.h.in')
|
||||||
|
|
||||||
cxxopts_incl = include_directories('subprojects/cxxopts/include', '.')
|
cxxopts_incl = include_directories('subprojects/cxxopts/include', '.')
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "memcard.hpp"
|
#include "memcard.hpp"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "app_config.h"
|
#include "app_config.h"
|
||||||
|
#include "git_version.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cxxopts.hpp>
|
#include <cxxopts.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -50,6 +51,7 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
if (command.count("version")) {
|
if (command.count("version")) {
|
||||||
std::cout << PROJECT_NAME << " v" << project_ver()
|
std::cout << PROJECT_NAME << " v" << project_ver()
|
||||||
|
<< (sizeof(PROJECT_GIT_SHA1) > 1 ? " git revision " PROJECT_GIT_SHA1 : "")
|
||||||
<< " built with " COMPILER_NAME " " COMPILER_VERSION
|
<< " built with " COMPILER_NAME " " COMPILER_VERSION
|
||||||
<< '\n';
|
<< '\n';
|
||||||
std::cout << "Copyright (C) " COPYRIGHT_YEAR " Michele Santullo\n";
|
std::cout << "Copyright (C) " COPYRIGHT_YEAR " Michele Santullo\n";
|
||||||
|
|
|
@ -13,6 +13,7 @@ executable(app_name,
|
||||||
'memcard.cpp',
|
'memcard.cpp',
|
||||||
project_config_file,
|
project_config_file,
|
||||||
config_file,
|
config_file,
|
||||||
|
gitrev_config_file,
|
||||||
dependencies: [
|
dependencies: [
|
||||||
memcard_dep
|
memcard_dep
|
||||||
],
|
],
|
||||||
|
|
3
src/git_version.h.in
Normal file
3
src/git_version.h.in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define PROJECT_GIT_SHA1 "@VCS_TAG@"
|
|
@ -37,6 +37,7 @@ executable(app_name,
|
||||||
'command_line.cpp',
|
'command_line.cpp',
|
||||||
config_file,
|
config_file,
|
||||||
project_config_file,
|
project_config_file,
|
||||||
|
gitrev_config_file,
|
||||||
'run_gui.cpp',
|
'run_gui.cpp',
|
||||||
'main_window.cpp',
|
'main_window.cpp',
|
||||||
'version_window.cpp',
|
'version_window.cpp',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "version_window.hpp"
|
#include "version_window.hpp"
|
||||||
#include "app_config.h"
|
#include "app_config.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "git_version.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace mc {
|
namespace mc {
|
||||||
|
@ -28,6 +29,7 @@ VersionWindow::VersionWindow(nana::window owner) :
|
||||||
nana::form(owner, nana::size{615, 505}),
|
nana::form(owner, nana::size{615, 505}),
|
||||||
m_top_label(*this),
|
m_top_label(*this),
|
||||||
m_short_desc(*this),
|
m_short_desc(*this),
|
||||||
|
m_git_revision(*this),
|
||||||
m_repo_link_1(*this),
|
m_repo_link_1(*this),
|
||||||
m_repo_link_2(*this),
|
m_repo_link_2(*this),
|
||||||
m_main_text(*this),
|
m_main_text(*this),
|
||||||
|
@ -41,6 +43,10 @@ VersionWindow::VersionWindow(nana::window owner) :
|
||||||
m_short_desc.format(true);
|
m_short_desc.format(true);
|
||||||
m_short_desc.caption(std::string("is part of <bold>" PROJECT_NAME "</> v") + project_ver());
|
m_short_desc.caption(std::string("is part of <bold>" PROJECT_NAME "</> v") + project_ver());
|
||||||
|
|
||||||
|
if constexpr (sizeof(PROJECT_GIT_SHA1) > 1) {
|
||||||
|
m_git_revision.caption("git revision " PROJECT_GIT_SHA1);
|
||||||
|
}
|
||||||
|
|
||||||
m_repo_link_1.format(true);
|
m_repo_link_1.format(true);
|
||||||
m_repo_link_1.caption("Official source code repository is available here:");
|
m_repo_link_1.caption("Official source code repository is available here:");
|
||||||
m_repo_link_2.format(true);
|
m_repo_link_2.format(true);
|
||||||
|
@ -53,7 +59,11 @@ VersionWindow::VersionWindow(nana::window owner) :
|
||||||
m_close.events().click([this]() { this->close(); });
|
m_close.events().click([this]() { this->close(); });
|
||||||
|
|
||||||
this->div("< vert margin=10 <vert top_label fit> <max=15> <main_text min=300> <max=15> <max=35 min=25 <><close><>> >");
|
this->div("< vert margin=10 <vert top_label fit> <max=15> <main_text min=300> <max=15> <max=35 min=25 <><close><>> >");
|
||||||
(*this)["top_label"] << m_top_label << m_short_desc << m_repo_link_1 << m_repo_link_2;
|
(*this)["top_label"] << m_top_label << m_short_desc;
|
||||||
|
if constexpr (sizeof(PROJECT_GIT_SHA1) > 1) {
|
||||||
|
(*this)["top_label"] << m_git_revision;
|
||||||
|
}
|
||||||
|
(*this)["top_label"] << m_repo_link_1 << m_repo_link_2;
|
||||||
(*this)["main_text"] << m_main_text;
|
(*this)["main_text"] << m_main_text;
|
||||||
(*this)["close"] << m_close;
|
(*this)["close"] << m_close;
|
||||||
this->collocate();
|
this->collocate();
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
private:
|
private:
|
||||||
nana::label m_top_label;
|
nana::label m_top_label;
|
||||||
nana::label m_short_desc;
|
nana::label m_short_desc;
|
||||||
|
nana::label m_git_revision;
|
||||||
nana::label m_repo_link_1;
|
nana::label m_repo_link_1;
|
||||||
nana::label m_repo_link_2;
|
nana::label m_repo_link_2;
|
||||||
nana::textbox m_main_text;
|
nana::textbox m_main_text;
|
||||||
|
|
Loading…
Add table
Reference in a new issue