Add git hash to System::VERSION

I don't really plan on putting out another "release tag" anytime soon,
so the hash for the current git commit is being added to the version string
to help tell the difference between one build and the other.
This commit is contained in:
Struma 2023-05-19 08:49:32 -04:00
parent 81616ebf73
commit fa0e60b7fc
6 changed files with 95 additions and 1 deletions

View file

@ -266,7 +266,12 @@ static void mriBindingInit() {
rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest)); rb_gv_set("BTEST", rb_bool_new(shState->config().editor.battleTest));
VALUE vers = rb_utf8_str_new_cstr(MKXPZ_VERSION); #ifdef MKXPZ_BUILD_XCODE
std::string version = std::string(MKXPZ_VERSION "/") + getPlistValue("GIT_COMMIT_HASH");
VALUE vers = rb_utf8_str_new_cstr(version.c_str());
#else
VALUE vers = rb_utf8_str_new_cstr(MKXPZ_VERSION "/" MKXPZ_GIT_HASH);
#endif
rb_str_freeze(vers); rb_str_freeze(vers);
rb_define_const(mod, "VERSION", vers); rb_define_const(mod, "VERSION", vers);

View file

@ -18,6 +18,8 @@
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string> <string>$(MARKETING_VERSION)</string>
<key>GIT_COMMIT_HASH</key>
<string>81616eb</string>
<key>IFMajorVersion</key> <key>IFMajorVersion</key>
<integer>0</integer> <integer>0</integer>
<key>IFMinorVersion</key> <key>IFMinorVersion</key>

View file

@ -1894,6 +1894,7 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 3B1C23EF25A19C600075EF5D /* Build configuration list for PBXNativeTarget "Z-steam" */; buildConfigurationList = 3B1C23EF25A19C600075EF5D /* Build configuration list for PBXNativeTarget "Z-steam" */;
buildPhases = ( buildPhases = (
FE4F72FE2A179EE0004FED68 /* ShellScript */,
3B1C237025A19C600075EF5D /* Sources */, 3B1C237025A19C600075EF5D /* Sources */,
3B1C23C225A19C600075EF5D /* Frameworks */, 3B1C23C225A19C600075EF5D /* Frameworks */,
3B1C23E625A19C600075EF5D /* Resources */, 3B1C23E625A19C600075EF5D /* Resources */,
@ -1937,6 +1938,7 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 3BBE88062705A73400A574AE /* Build configuration list for PBXNativeTarget "Z-steam-universal" */; buildConfigurationList = 3BBE88062705A73400A574AE /* Build configuration list for PBXNativeTarget "Z-steam-universal" */;
buildPhases = ( buildPhases = (
FE4F72FD2A179ED5004FED68 /* ShellScript */,
3BBE87852705A73400A574AE /* Sources */, 3BBE87852705A73400A574AE /* Sources */,
3BBE87CE2705A73400A574AE /* Frameworks */, 3BBE87CE2705A73400A574AE /* Frameworks */,
3BBE87F42705A73400A574AE /* Resources */, 3BBE87F42705A73400A574AE /* Resources */,
@ -1961,6 +1963,7 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 3BC65E122584F3AD0063AFF1 /* Build configuration list for PBXNativeTarget "Z-universal" */; buildConfigurationList = 3BC65E122584F3AD0063AFF1 /* Build configuration list for PBXNativeTarget "Z-universal" */;
buildPhases = ( buildPhases = (
FE4F72FB2A179D9E004FED68 /* ShellScript */,
3BC65D8D2584F3AD0063AFF1 /* Sources */, 3BC65D8D2584F3AD0063AFF1 /* Sources */,
3BC65DDB2584F3AD0063AFF1 /* Frameworks */, 3BC65DDB2584F3AD0063AFF1 /* Frameworks */,
3BC65E0D2584F3AD0063AFF1 /* Resources */, 3BC65E0D2584F3AD0063AFF1 /* Resources */,
@ -1983,6 +1986,7 @@
isa = PBXNativeTarget; isa = PBXNativeTarget;
buildConfigurationList = 3BD2B7222565AEC0003DAD8A /* Build configuration list for PBXNativeTarget "Z-intel" */; buildConfigurationList = 3BD2B7222565AEC0003DAD8A /* Build configuration list for PBXNativeTarget "Z-intel" */;
buildPhases = ( buildPhases = (
FE4F72FC2A179ECC004FED68 /* ShellScript */,
3BD2B64C2565AEC0003DAD8A /* Sources */, 3BD2B64C2565AEC0003DAD8A /* Sources */,
3BD2B6E12565AEC0003DAD8A /* Frameworks */, 3BD2B6E12565AEC0003DAD8A /* Frameworks */,
3BD2B6F82565AEC0003DAD8A /* Resources */, 3BD2B6F82565AEC0003DAD8A /* Resources */,
@ -2093,6 +2097,77 @@
}; };
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
FE4F72FB2A179D9E004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
};
FE4F72FC2A179ECC004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
};
FE4F72FD2A179ED5004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
};
FE4F72FE2A179EE0004FED68 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nCOMMIT_HASH=`git rev-parse --short HEAD`\n/usr/libexec/PlistBuddy -c \"Set :GIT_COMMIT_HASH $COMMIT_HASH\" \"${INFOPLIST_FILE}\"\n";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */
3B1C235225A199370075EF5D /* Sources */ = { 3B1C235225A199370075EF5D /* Sources */ = {
isa = PBXSourcesBuildPhase; isa = PBXSourcesBuildPhase;

View file

@ -8,6 +8,8 @@ endif
xxd = find_program('xxd', native: true) xxd = find_program('xxd', native: true)
git_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
compilers = {'cpp': meson.get_compiler('cpp')} compilers = {'cpp': meson.get_compiler('cpp')}
global_sources = [] global_sources = []
@ -23,6 +25,7 @@ win64 = (sizeof['void*'] != sizeof['long'])
global_args += '-DMKXPZ_BUILD_MESON' global_args += '-DMKXPZ_BUILD_MESON'
global_args += '-DMKXPZ_VERSION="@0@"'.format(meson.project_version()) global_args += '-DMKXPZ_VERSION="@0@"'.format(meson.project_version())
global_args += '-DMKXPZ_GIT_HASH="@0@"'.format(git_hash)
global_args += '-DHAVE_NANOSLEEP' global_args += '-DHAVE_NANOSLEEP'
# ==================== # ====================
# Ext libs # Ext libs

View file

@ -40,6 +40,7 @@ WineHostType getRealHostType();
} }
#ifdef MKXPZ_BUILD_XCODE #ifdef MKXPZ_BUILD_XCODE
std::string getPlistValue(const char *key);
void openSettingsWindow(); void openSettingsWindow();
bool isMetalSupported(); bool isMetalSupported();
#endif #endif

View file

@ -62,3 +62,11 @@ bool isMetalSupported() {
} }
return false; return false;
} }
std::string getPlistValue(const char *key) {
NSString *hash = [[NSBundle mainBundle] objectForInfoDictionaryKey:@(key)];
if (hash != nil) {
return std::string(hash.UTF8String);
}
return "";
}