diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 4bb8f11..f1a4eb6 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,7 +5,10 @@ "includePath": [ "${workspaceFolder}/**" ], - "defines": [], + "defines": [ + "GIT_COMMIT", + "GIT_BRANCH" + ], "cStandard": "c17", "cppStandard": "gnu++17", "intelliSenseMode": "windows-gcc-x64" diff --git a/Makefile b/Makefile index c21b5f1..536d835 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ C_SOURCES = $(shell find ./ -type f -name '*.c') C_OBJECTS = $(C_SOURCES:.c=.o) -CFLAGS = -std=c17 -Wno-int-conversion +GIT_COMMIT = $(shell git rev-parse --short HEAD) +GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD) + +CFLAGS = -std=c17 -Wno-int-conversion -DGIT_COMMIT='"$(GIT_COMMIT)"' -DGIT_BRANCH='"$(GIT_BRANCH)"' LFLAGS = -lgdi32 # DBGFLAGS = -Wl,--export-all-symbols -g -O0 -ggdb3 -Wall diff --git a/gui.c b/gui.c index 6d4ebb2..173c373 100644 --- a/gui.c +++ b/gui.c @@ -191,11 +191,14 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case IDM_HELP_ABOUT: { char msg[256]; - sprintf(msg, "rpc-bridge v%s\n\n" - "Simple bridge that allows you to use Discord Rich Presence with Wine games/software.\n\n" - "Created by EnderIce2\n\n" - "Licensed under the MIT License", - VER_VERSION_STR); + snprintf(msg, sizeof(msg), + "rpc-bridge v%s\n" + " branch: %s\n" + " commit: %s\n\n" + "Simple bridge that allows you to use Discord Rich Presence with Wine games/software.\n\n" + "Created by EnderIce2\n\n" + "Licensed under the MIT License", + VER_VERSION_STR, GIT_BRANCH, GIT_COMMIT); MessageBox(NULL, msg, "About", MB_OK); break; } diff --git a/main.c b/main.c index 92d4d7d..f36fa88 100644 --- a/main.c +++ b/main.c @@ -273,38 +273,38 @@ void HandleArguments(int argc, char *argv[]) } else if (strcmp(argv[1], "--version") == 0) { - printf("%s\n", VER_VERSION_STR); + /* Already shows the version */ ExitProcess(0); } else if (strcmp(argv[1], "--help") == 0) { - printf("Usage:\n" - " %s [args]\n" - "\n" - "Arguments:\n" - " --help Show this help\n" - "\n" - " --version Show version\n" - "\n" - " --install Install service\n" - " This will copy the binary to C:\\windows\\bridge.exe and register it as a service\n" - "\n" - " --uninstall Uninstall service\n" - " This will remove the service and delete C:\\windows\\bridge.exe\n" - "\n" - " --steam Reserved for Steam\n" - " This will start the service and exit (used with bridge.sh)\n" - "\n" - " --no-service Do not run as service\n" - " (only for --steam)\n" - "\n" - " --service Reserved for service\n" - "\n" - " --rpc