Added logic to auto embed the git URL and revision into the executable so that it can be displayed on the About dialog window.

This commit is contained in:
Matthew Budd 2020-07-11 19:52:14 -04:00
parent 9fc2d905de
commit 96df0c25e1
4 changed files with 42 additions and 3 deletions

View File

@ -2,15 +2,20 @@
OUTPUT_DIR=$1; OUTPUT_DIR=$1;
FILE="fceux_gitrev.h" FILE="fceux_git_info.cpp"
TMP_FILE="/tmp/$FILE"; TMP_FILE="/tmp/$FILE";
echo "Output File: $OUTPUT_DIR/$FILE";
GIT_URL=`git config --get remote.origin.url`; GIT_URL=`git config --get remote.origin.url`;
GIT_REV=`git rev-parse HEAD`; GIT_REV=`git rev-parse HEAD`;
echo "// fceux_gitrev.h -- DO NOT EDIT: This file is auto-generated at build" >| $TMP_FILE; echo "// fceux_gitrev.cpp -- DO NOT EDIT: This file is auto-generated at build" >| $TMP_FILE;
echo "#include \"Qt/fceux_git_info.h\" " >> $TMP_FILE;
echo "#define FCEUX_GIT_URL \"$GIT_URL\" " >> $TMP_FILE; echo "#define FCEUX_GIT_URL \"$GIT_URL\" " >> $TMP_FILE;
echo "#define FCEUX_GIT_REV \"$GIT_REV\" " >> $TMP_FILE; echo "#define FCEUX_GIT_REV \"$GIT_REV\" " >> $TMP_FILE;
echo "const char *fceu_get_git_url(void){ return FCEUX_GIT_URL; }" >> $TMP_FILE
echo "const char *fceu_get_git_rev(void){ return FCEUX_GIT_REV; }" >> $TMP_FILE
if [ -e $OUTPUT_DIR/$FILE ]; then if [ -e $OUTPUT_DIR/$FILE ]; then

View File

@ -400,7 +400,15 @@ set(SRC_DRIVERS_SDL
set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_SDL}) set(SOURCES ${SRC_CORE} ${SRC_DRIVERS_COMMON} ${SRC_DRIVERS_SDL})
add_executable( fceux ${SOURCES} ../resources.qrc ) add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp
COMMAND ${CMAKE_SOURCE_DIR}/scripts/genGitHdr.sh ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM )
set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp PROPERTY SKIP_AUTOGEN ON)
add_executable( fceux ${SOURCES} ../resources.qrc
${CMAKE_CURRENT_BINARY_DIR}/fceux_git_info.cpp)
target_link_libraries( fceux target_link_libraries( fceux
${Qt5Widgets_LIBRARIES} ${Qt5Widgets_LIBRARIES}

View File

@ -11,6 +11,7 @@
#include <QDesktopServices> #include <QDesktopServices>
//#include "Qt/icon.xpm" //#include "Qt/icon.xpm"
#include "Qt/AboutWindow.h" #include "Qt/AboutWindow.h"
#include "Qt/fceux_git_info.h"
#include "../../version.h" #include "../../version.h"
static const char *Authors[] = { static const char *Authors[] = {
@ -44,6 +45,7 @@ AboutWindow::AboutWindow(QWidget *parent)
QPixmap pm2; QPixmap pm2;
QLabel *lbl; QLabel *lbl;
QTextEdit *credits; QTextEdit *credits;
char stmp[256];
pm2 = pm.scaled( 64, 64 ); pm2 = pm.scaled( 64, 64 );
@ -78,6 +80,26 @@ AboutWindow::AboutWindow(QWidget *parent)
mainLayout->addLayout( hbox1 ); mainLayout->addLayout( hbox1 );
sprintf( stmp, "git URL: %s", fceu_get_git_url() );
hbox1 = new QHBoxLayout();
lbl = new QLabel( tr(stmp) );
hbox1->addWidget( lbl );
hbox1->setAlignment( Qt::AlignCenter );
mainLayout->addLayout( hbox1 );
sprintf( stmp, "git Revision: %s", fceu_get_git_rev() );
hbox1 = new QHBoxLayout();
lbl = new QLabel( tr(stmp) );
hbox1->addWidget( lbl );
hbox1->setAlignment( Qt::AlignCenter );
mainLayout->addLayout( hbox1 );
hbox1 = new QHBoxLayout(); hbox1 = new QHBoxLayout();
lbl = new QLabel(); lbl = new QLabel();
lbl->setText("<a href=\"http://fceux.com\">Website</a>"); lbl->setText("<a href=\"http://fceux.com\">Website</a>");

View File

@ -0,0 +1,4 @@
// fceux_git_info.h
const char *fceu_get_git_url(void);
const char *fceu_get_git_rev(void);