Skip to content

Commit

Permalink
Handle empty plugin revision
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jul 19, 2023
1 parent 0fee30d commit 6f3186f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ bool getCursorPos(long & _x, long & _y)
static HWND hWnd = NULL;
if (hWnd == NULL) {
wchar_t caption[64];
#ifdef PLUGIN_REVISION_W
# ifdef _DEBUG
swprintf(caption, 64, L"mupen64plus: %ls debug. Revision %ls", pluginNameW, PLUGIN_REVISION_W);
# else // _DEBUG
swprintf(caption, 64, L"%s. Revision %s", pluginName, PLUGIN_REVISION);
# endif // _DEBUG
#else // PLUGIN_REVISION_W
# ifdef _DEBUG
swprintf(caption, 64, L"mupen64plus: %ls debug.", pluginNameW);
# else // _DEBUG
swprintf(caption, 64, L"%s", pluginName);
# endif // _DEBUG
#endif // PLUGIN_REVISION_W
hWnd = FindWindowExW(NULL, NULL, NULL, caption);
}
ScreenToClient(hWnd, &pt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,19 @@ bool DisplayWindowMupen64plus::_start()
}

char caption[128];
#ifdef PLUGIN_REVISION
# ifdef _DEBUG
sprintf(caption, "%s debug. Revision %s", pluginName, PLUGIN_REVISION);
# else // _DEBUG
sprintf(caption, "%s. Revision %s", pluginName, PLUGIN_REVISION);
# endif // _DEBUG
#else // PLUGIN_REVISION
# ifdef _DEBUG
sprintf(caption, "%s debug", pluginName);
# else // _DEBUG
sprintf(caption, "%s", pluginName,);
# endif // _DEBUG
#endif // PLUGIN_REVISION
CoreVideo_SetCaption(caption);

return true;
Expand Down
17 changes: 11 additions & 6 deletions src/getRevision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,27 @@ header="${OUTPUT:-./Revision.h}"

if [ "${1:-}" != --nogit ]
then
rev="\"$(git rev-parse --short HEAD)\"" || rev='""'
rev="\"$(git rev-parse --short HEAD)\"" || rev='""'
else
rev='""'
rev='""'
fi

lastrev=''
if [ -e "$header" ]
then
lastrev="$(head -n 1 "$header" 2> /dev/null | cut -d ' ' -f3)"
lastrev="$(head -n 1 "$header" 2> /dev/null | cut -d ' ' -f3)"
fi

printf '%s\n' "current revision $rev" "last build revision $lastrev"

if [ "$lastrev" != "$rev" ]
then
[ "$header" = "${header##*/}" ] || mkdir -p -- "${header%/*}"
printf '%s\n' "#define PLUGIN_REVISION $rev" \
"#define PLUGIN_REVISION_W L$rev" > "$header"
[ "$header" = "${header##*/}" ] || mkdir -p -- "${header%/*}"
if [ "x$rev" != "x" ]
then
printf '%s\n' "#define PLUGIN_REVISION $rev" \
"#define PLUGIN_REVISION_W L$rev" > "$header"
else
printf '\n' > "$header"
fi
fi

0 comments on commit 6f3186f

Please sign in to comment.