Skip to content

Commit 4193bc6

Browse files
Version full inline (#552)
The full version string is now inlined in the game files and the executable itself. The macro OO_VERSION_FULL, representing the full version string (e.g. "1.93.0.7779-260224-dc76e30"), is now defined at the command line during compile time for all C and Obj-C files in the project. This allows easy access to the version string from practically everywhere. The full version string is added to the [-]-help output, as well as the main menu screen when the -showversion command line argument is used. The full version is now also printed in the log header and is now the version reported for all core world scripts. In addition to all the above, the full version string is now embedded in the core resources manifest.plist file, replacing the previous Maj.Min version format under the version key. The build type is also inlined in manifest.plist under the key debug_functionality_support, which takes a value of yes or no. yes implies a test release or snapshot build, no implies a deployment build.
1 parent 11b667a commit 4193bc6

File tree

8 files changed

+37
-11
lines changed

8 files changed

+37
-11
lines changed

GNUmakefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ ifeq ($(GNUSTEP_HOST_OS),mingw32)
1111
endif
1212
GNUSTEP_OBJ_DIR_BASENAME := $(GNUSTEP_OBJ_DIR_NAME)
1313

14+
VERSION := $(shell cat src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2)
15+
VER_MAJ := $(shell echo $(VERSION) | cut -d. -f1)
16+
VER_MIN := $(shell echo $(VERSION) | cut -d. -f2)
17+
VER_REV := $(shell echo $(VERSION) | cut -d. -f3)
18+
ifeq ($(VER_REV),)
19+
VER_REV = 0
20+
endif
21+
VER_DATE := $(shell date +%y%m%d)
22+
VER_GITREV := $(shell git rev-list --count HEAD)
23+
VER_GITHASH := $(shell git rev-parse --short=7 HEAD)
24+
VER_FULL := $(VER_MAJ).$(VER_MIN).$(VER_REV).$(VER_GITREV)-$(VER_DATE)-$(VER_GITHASH)
25+
26+
1427
ifeq ($(GNUSTEP_HOST_OS),mingw32)
1528
vpath %.rc src/SDL/OOResourcesWin
1629

@@ -104,8 +117,8 @@ endif
104117

105118
# add specific flags if building modern
106119
ifeq ($(modern),yes)
107-
ADDITIONAL_CFLAGS += -DOOLITE_MODERN_BUILD=1
108-
ADDITIONAL_OBJCFLAGS += -DOOLITE_MODERN_BUILD=1
120+
ADDITIONAL_CFLAGS += -DOOLITE_MODERN_BUILD=1 -DOO_VERSION_FULL=\"$(VER_FULL)\"
121+
ADDITIONAL_OBJCFLAGS += -DOOLITE_MODERN_BUILD=1 -DOO_VERSION_FULL=\"$(VER_FULL)\"
109122
# link time optimizations
110123
ifeq ($(lto),yes)
111124
ADDITIONAL_CFLAGS += -flto

GNUmakefile.postamble

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ POST_BUILD_ENV = \
99
GNUSTEP_HOST_CPU="$(GNUSTEP_HOST_CPU)" \
1010
MINGW_PREFIX="$(MINGW_PREFIX)" \
1111
DEBUG="$(debug)" \
12+
DEPLOYMENT_RELEASE_CONFIGURATION="$(DEPLOYMENT_RELEASE_CONFIGURATION)" \
1213
MODERN="$(modern)" \
1314
ESPEAK="$(ESPEAK)" \
1415
USE_DEPS="$(use_deps)" \
1516
STRIP_BIN="$(strip)" \
16-
STRIP="$(STRIP)"
17+
STRIP="$(STRIP)" \
18+
VER_FULL="$(VER_FULL)"
1719

1820
after-all::
1921
@$(POST_BUILD_ENV) ShellScripts/common/post_build.sh

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ release-deployment:
4141

4242
.PHONY: release-snapshot
4343
release-snapshot:
44-
$(MAKE) -f GNUmakefile SNAPSHOT_BUILD=yes VERSION_STRING=$(VER) debug=no
44+
$(MAKE) -f GNUmakefile SNAPSHOT_BUILD=yes debug=no
4545
mkdir -p AddOns && rm -rf AddOns/Basic-debug.oxp && cp -rf DebugOXP/Debug.oxp AddOns/Basic-debug.oxp
4646

4747
.PHONY: debug

src/Core/Entities/PlayerEntity.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10075,7 +10075,7 @@ - (void) setGuiToIntroFirstGo:(BOOL)justCobra
1007510075
if ([[arguments objectAtIndex:i] isEqual:@"-showversion"])
1007610076
{
1007710077
OOGUIRow ms_start = msgLine;
10078-
NSString *version = [NSString stringWithFormat:@"Version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
10078+
NSString *version = [NSString stringWithFormat:@"Version %s", OO_VERSION_FULL];
1007910079
OOGUIRow i = msgLine = [gui addLongText:version startingAtRow:ms_start align:GUI_ALIGN_CENTER];
1008010080
for (i-- ; i >= ms_start; i--)
1008110081
{

src/Core/OOLogHeader.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ void OOPrintLogHeader(void)
161161
#endif
162162

163163
NSString *versionString = nil;
164-
#if (defined (SNAPSHOT_BUILD) && defined (OOLITE_SNAPSHOT_VERSION))
165-
versionString = @"development version " OOLITE_SNAPSHOT_VERSION;
164+
#if (defined (SNAPSHOT_BUILD))
165+
versionString = @"development version " @OO_VERSION_FULL;
166166
#else
167-
versionString = [NSString stringWithFormat:@"version %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
167+
versionString = [NSString stringWithFormat:@"version %s", OO_VERSION_FULL];
168168
#endif
169169
if (versionString == nil) versionString = @"<unknown version>";
170170

src/Core/Universe.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5229,8 +5229,8 @@ - (void) drawUniverse
52295229
// should come after the HUD to avoid it being overlapped by it
52305230
[self drawMessage];
52315231

5232-
#if (defined (SNAPSHOT_BUILD) && defined (OOLITE_SNAPSHOT_VERSION))
5233-
[self drawWatermarkString:@"Development version " @OOLITE_SNAPSHOT_VERSION];
5232+
#if (defined (SNAPSHOT_BUILD))
5233+
[self drawWatermarkString:@"Development version " @OO_VERSION_FULL];
52345234
#endif
52355235

52365236
OOLog(@"universe.profile.drawHUD", @"%@", @"End HUD drawing");

src/SDL/main.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
uint32_t gDebugFlags = 0;
5050
#endif
5151

52+
// This macro is normally defined in the build command
53+
#ifndef OO_VERSION_FULL
54+
#define OO_VERSION_FULL "Undefined"
55+
#endif
56+
5257
/**
5358
* \ingroup cli
5459
* Entry point for Linux and Windows systems.
@@ -186,6 +191,7 @@ int main(int argc, char *argv[])
186191
"--xml"TABS3 TABS4"When compiling or exporting\n"TABS3 TABS4"system descriptions, use xml\n"TABS3 TABS4"format *\n"
187192
"\n"
188193
"Options marked with \"*\" are available only in Test Release configuration.\n"
194+
"Version "OO_VERSION_FULL"\n"
189195
"Built with "
190196
#if OOLITE_HAVE_CLANG
191197
"Clang version " STRINGIFY(__clang_major__) "." STRINGIFY(__clang_minor__) "." STRINGIFY(__clang_patchlevel__)

tools/mkmanifest.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ echo "{"
1818
echo " title = \"Oolite core\";"
1919
echo " identifier = \"org.oolite.oolite\";"
2020
echo " "
21-
echo " version = \"$OOLITE_VERSION\";"
21+
echo " version = \"$VER_FULL\";"
22+
if [ "$DEPLOYMENT_RELEASE_CONFIGURATION" = "yes" ]; then
23+
echo " debug_functionality_support = no;"
24+
else
25+
echo " debug_functionality_support = yes;"
26+
fi
2227
echo " required_oolite_version = \"$OOLITE_VERSION\";"
2328
echo " "
2429
echo " license = \"GPL 2+ / CC-BY-NC-SA 3.0 - see LICENSE.md for details\";"

0 commit comments

Comments
 (0)