edited for drunken style code fu.
I searched for this type of functionality and ended up doing my own.
I’m creating a tool for my boss and sending him updates regularly. I got pissed off manually naming filenames with version info. and indeed maintaining a version number in the code (for title bar etc)
so…
int _tmain(int argc, _TCHAR* argv[])
{
initialiseJuce_NonGUI();
int majorInc = 0, minorInc = 0, buildInc = 0, major = 0, minor = 0, build = 0;
String file, fs;
StringArray cmdl( (const juce_wchar**) argv, argc );
for ( int i = 0; i < cmdl.size(); ++i )
{
if ( cmdl[ i ].contains( T("maj") ) )
majorInc = cmdl[ i ].getTrailingIntValue();
else if ( cmdl[ i ].contains( T("min") ) )
minorInc = cmdl[ i ].getTrailingIntValue();
else if ( cmdl[ i ].contains( T("bld") ) )
buildInc = cmdl[ i ].getTrailingIntValue();
else if ( cmdl[ i ].contains( T("file=") ) )
file = cmdl[ i ].substring( cmdl[ i ].lastIndexOf( T("=") ) + 1 );
}
File f( File::getCurrentApplicationFile().getParentDirectory().getFullPathName() + T("\\vinfo.txt") );
if ( f.existsAsFile() )
{
fs = f.loadFileAsString();
StringArray sa;
sa.addLines( fs );
major = sa[ 0 ].getTrailingIntValue();
minor = sa[ 1 ].getTrailingIntValue();
build = sa[ 2 ].getTrailingIntValue();
}
major += majorInc;
minor += minorInc;
build += buildInc;
fs = T("#define MAJORV ")
+ String( major )
+ T("\n#define MINORV ")
+ String( minor )
+ T("\n#define BUILDN ")
+ String( build )
+ T("\n");
f.deleteFile();
f.create();
f.appendText( fs );
File exe( file );
if ( exe.existsAsFile() )
{
exe.copyFileTo( File( exe.getParentDirectory().getFullPathName() + T("\\")
+ exe.getFileNameWithoutExtension()
+ String( major ) + T("_")
+ String( minor ) + T("_")
+ String( build )
+ exe.getFileExtension() ) );
}
shutdownJuce_NonGUI();
return 0;
}
I compiled this as versionburster.exe and put it in my project directory.
so in my release pre build event I have
debug pre build event I have
at the top of main.cpp
which gives me macros for MAJORV MINORV and BUILDN to use in a title bar or wherever.
then in the post-build events I have
which simply copies the output file to filenameMAJORV_MINORV_BUILDN.exe
works for me. took half an hour. might be of use to someone.
happy new year
chris
EDITED FOR STUPIDITY :lol:
