Apple, in their infinite wisdom, provide no way to programatically set preprocessor directives or compiler flags in Xcode, so the trick with the Makefile used to include the SVN revision number doesn't work. (Using svnversion)
This patch adds some #defines which mean that if the flag REVISION_FROM_FILE is set the revision is included from the file revision.h (which can be automatically generated via a script run as part of the build process).
The patch shouldn't affect other platforms. It adds #include directives for simversion.h to a couple of places where the REVISION macro is used to ensure this gets set before being used.
Edit:
revision.h would contain (auto-generated):
#ifndef REVISION
#define REVISION 5583M
#endif
And the script which produces it, which is run as a custom build phase script prior to source compilation:
REV=`svnversion -n`
echo "#ifndef REVISION" > ${PROJECT_DIR}/revision.h
echo "#define REVISION $REV" >> ${PROJECT_DIR}/revision.h
echo "#endif" >> ${PROJECT_DIR}/revision.h
At leats Darwin uses plain stanard makefiles and gcc. Did aplle really removed -Dxxx from the compiler???
You can put in -D flags, but you can't generate them as a result of a shell command.
Does this approach hold any merit? Or should I consider another way to solve this issue.
As long as we do not include an Xcode project file with the subversion, this is rather leading to confusion. I there, then this can be thought of. But if you can run scripts, your could very well append FLAGS?=-DREVISION="xyz" to config.default. But maybe I do not understand this correctly. In MSVC, you have also to specify "-DREVSIONS="1234" in the project settings, no automatism here either.
The Xcode build doesn't use the config.default file (or the Makefile) at all.
MSVC could use the same mechanism if it has the ability to run a script before building, e.g. output the revision.h file and then specify the (unchanging) -DREVISION_FROM_FILE on the command line. Indeed, the Makefile-based builds could easily do the same thing to make it consistent.
Confusion can be avoided by putting appropriate comments in the code to document the flag :) (Happy to modify to do this) (And including a dummy revision.h with revision defined to 0 would also avoid confusion).
In any case, IMO gameinfo.cc and network_file_transfer.cc should both include simversion.h to ensure that the macro only needs to be defined in one place no matter the compilation order.
MSVC also does not use the makefile. Thus in principle MSVC can create this file too, but you have to use DOS commandline tools, which make this much more difficult if not impossible.
When we support Xcode as "official" project setting (like currently MSVC), then we will also have such a mechanism. Otherwise it does not make sense at the moment.
EDIT: Ok, REVISION_FROM_FILE is now incorporated together with a script fpr MSVC
Thanks :)