make recompile for vers/git state change minimal

Make a `version.c` with `const char*` variables to store the version
strings used by other files, to make recompiles slightly faster when the
git state changes.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-10-04 08:14:22 +00:00
parent af0de1c4b3
commit 24d83a1262
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
8 changed files with 32 additions and 18 deletions

View File

@ -809,6 +809,7 @@ set(
src/sdl/expr.cpp src/sdl/expr.cpp
src/sdl/exprNode.cpp src/sdl/exprNode.cpp
src/sdl/expr-lex.cpp src/sdl/expr-lex.cpp
src/common/version.c
) )
set( set(
@ -818,6 +819,7 @@ set(
src/sdl/inputSDL.h src/sdl/inputSDL.h
src/sdl/expr.cpp.h src/sdl/expr.cpp.h
src/sdl/exprNode.h src/sdl/exprNode.h
src/common/version_c.h
) )
set( set(

6
src/common/version.c Normal file
View File

@ -0,0 +1,6 @@
#include "version_c.h"
#include "version.h"
const char* vba_name_and_subversion = VBA_NAME_AND_SUBVERSION;
const char* vbam_version = VERSION;

8
src/common/version_c.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef VBAM_VERSION_C_H
#define VBAM_VERSION_C_H
extern const char* vba_name_and_subversion;
extern const char* vbam_version;
#endif /* VBAM_VERSION_C_H */

View File

@ -41,7 +41,7 @@
#include <time.h> #include <time.h>
#include "version.h" #include "../common/version_c.h"
#include "SDL.h" #include "SDL.h"
@ -1521,7 +1521,7 @@ void SetHomeDataDir()
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
fprintf(stdout, "%s\n", VBA_NAME_AND_SUBVERSION); fprintf(stdout, "%s\n", vba_name_and_subversion);
home = argv[0]; home = argv[0];
SetHome(home); SetHome(home);

View File

@ -17,6 +17,9 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef VBAM_VERSION_H
#define VBAM_VERSION_H
#define VBA_NAME "VisualBoyAdvance-M" #define VBA_NAME "VisualBoyAdvance-M"
#define VBA_CURRENT_VERSION "@VERSION@" #define VBA_CURRENT_VERSION "@VERSION@"
@ -46,3 +49,5 @@
#define VER_FILEVERSION_STR VERSION #define VER_FILEVERSION_STR VERSION
#define VER_FILEVERSION @WIN_VERSION@ #define VER_FILEVERSION @WIN_VERSION@
#endif /* VBAM_VERSION_H */

View File

@ -668,6 +668,7 @@ set(
cmd-evtable.h cmd-evtable.h
# icon File # icon File
xrc/vbam.xpm xrc/vbam.xpm
../common/version.c
) )
if(APPLE) if(APPLE)
@ -693,6 +694,7 @@ set(
../sdl/text.h ../sdl/text.h
# from external source with minor modifications # from external source with minor modifications
widgets/wx/checkedlistctrl.h widgets/wx/checkedlistctrl.h
../common/version_c.h
) )
set( set(

View File

@ -10,7 +10,7 @@
#include <wx/wfstream.h> #include <wx/wfstream.h>
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#include "version.h" #include "../common/version_c.h"
#include "../common/ConfigManager.h" #include "../common/ConfigManager.h"
#include "../gb/gbPrinter.h" #include "../gb/gbPrinter.h"
#include "../gba/agbprint.h" #include "../gba/agbprint.h"
@ -2723,22 +2723,14 @@ EVT_HANDLER(Translate, "Translations")
wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m")); wxLaunchDefaultBrowser(wxT("http://www.transifex.com/projects/p/vba-m"));
} }
#include "../common/version_c.h"
// was About // was About
EVT_HANDLER(wxID_ABOUT, "About...") EVT_HANDLER(wxID_ABOUT, "About...")
{ {
wxAboutDialogInfo ai; wxAboutDialogInfo ai;
ai.SetName(wxT("VisualBoyAdvance-M")); ai.SetName(wxT("VisualBoyAdvance-M"));
wxString version = wxT(""); wxString version(vbam_version);
#ifndef FINAL_BUILD
#ifndef VERSION
# define VERSION "git"
#endif
if (!version.IsEmpty())
version = version + wxT("-");
version = version + wxT(VERSION);
#endif
ai.SetVersion(version); ai.SetVersion(version);
// setting website, icon, license uses custom aboutbox on win32 & macosx // setting website, icon, license uses custom aboutbox on win32 & macosx
// but at least win32 standard about is nothing special // but at least win32 standard about is nothing special

View File

@ -5,7 +5,7 @@
#include <wx/dcbuffer.h> #include <wx/dcbuffer.h>
#include <SDL_joystick.h> #include <SDL_joystick.h>
#include "version.h" #include "../common/version_c.h"
#include "../common/ConfigManager.h" #include "../common/ConfigManager.h"
#include "../common/Patch.h" #include "../common/Patch.h"
#include "../gb/gbPrinter.h" #include "../gb/gbPrinter.h"
@ -424,9 +424,8 @@ void GameArea::SetFrameTitle()
} }
tit.append(wxT("VisualBoyAdvance-M ")); tit.append(wxT("VisualBoyAdvance-M "));
#ifndef FINAL_BUILD tit.append(vbam_version);
tit.append(_(VERSION));
#endif
#ifndef NO_LINK #ifndef NO_LINK
int playerId = GetLinkPlayerId(); int playerId = GetLinkPlayerId();