From 7b36c6fd2f1cdf68592a8299e38ebbabd708ce05 Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Thu, 7 Mar 2013 14:26:14 +1030 Subject: [PATCH] build: query git for version info and print consistently for each util Signed-off-by: Kevin Shanahan --- Makefile | 10 ++++++--- bspinfo/bspinfo.c | 7 +++++-- bsputil/bsputil.c | 9 +++++--- include/common/cmdlib.h | 3 +++ light/light.c | 18 +++++++--------- qbsp/qbsp.c | 46 +++++++++++++++++++++-------------------- vis/vis.c | 27 +++++++----------------- 7 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Makefile b/Makefile index 4eeefa58..5d8f4138 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,10 @@ OPTIMIZED_CFLAGS ?= Y# Enable compiler optimisations (if DEBUG != Y) TARGET_OS ?= $(HOST_OS) # ============================================================================ +TYRUTILS_RELEASE := v0.5 +TYRUTILS_VERSION := $(shell \ + git describe 2> /dev/null || printf '%s' $(TYRUTILS_RELEASE)) + SYSNAME := $(shell uname -s) TOPDIR := $(shell pwd) @@ -203,14 +207,15 @@ APPS = \ all: $(patsubst %,$(BIN_DIR)/%,$(APPS)) -COMMON_CPPFLAGS := -I$(TOPDIR)/include -DLINUX $(DPTHREAD) +COMMON_CPPFLAGS := -DTYRUTILS_VERSION=$(TYRUTILS_VERSION) +COMMON_CPPFLAGS += -I$(TOPDIR)/include -DLINUX $(DPTHREAD) ifeq ($(DEBUG),Y) COMMON_CPPFLAGS += -DDEBUG else COMMON_CPPFLAGS += -DNDEBUG endif -$(BUILD_DIR)/qbsp/%.o: CPPFLAGS = $(COMMON_CPPFLAGS) -DDOUBLEVEC_T -DQBSP_VERSION=$(QBSP_VERSION) +$(BUILD_DIR)/qbsp/%.o: CPPFLAGS = $(COMMON_CPPFLAGS) -DDOUBLEVEC_T $(BUILD_DIR)/common/%.o: CPPFLAGS = $(COMMON_CPPFLAGS) $(BUILD_DIR)/light/%.o: CPPFLAGS = $(COMMON_CPPFLAGS) $(BUILD_DIR)/vis/%.o: CPPFLAGS = $(COMMON_CPPFLAGS) @@ -298,7 +303,6 @@ $(BIN_DIR)/$(BIN_PFX)bsputil$(EXT): $(patsubst %,$(BUILD_DIR)/%,$(BSPUTIL_OBJS)) # Qbsp # ######## -QBSP_VERSION = 0.4 QBSP_OBJECTS = \ brush.o \ bspfile.o \ diff --git a/bspinfo/bspinfo.c b/bspinfo/bspinfo.c index 03f437be..d18f116a 100644 --- a/bspinfo/bspinfo.c +++ b/bspinfo/bspinfo.c @@ -27,8 +27,11 @@ main(int argc, char **argv) int i; char source[1024]; - if (argc == 1) - Error("usage: bspinfo bspfile [bspfiles]"); + printf("---- bspinfo / TyrUtils " stringify(TYRUTILS_VERSION) " ----\n"); + if (argc == 1) { + printf("usage: bspinfo bspfile [bspfiles]"); + exit(1); + } for (i = 1; i < argc; i++) { printf("---------------------\n"); diff --git a/bsputil/bsputil.c b/bsputil/bsputil.c index 10ba35be..22ec06dc 100644 --- a/bsputil/bsputil.c +++ b/bsputil/bsputil.c @@ -101,9 +101,12 @@ main(int argc, char **argv) char source[1024]; FILE *f; - if (argc == 1) - Error("usage: bsputil [--extract-entities] [--extract-textures] " - "bspfile"); + printf("---- bsputil / TyrUtils " stringify(TYRUTILS_VERSION) " ----\n"); + if (argc == 1) { + printf("usage: bsputil [--extract-entities] [--extract-textures] " + "bspfile"); + exit(1); + } strcpy(source, argv[argc - 1]); DefaultExtension(source, ".bsp"); diff --git a/include/common/cmdlib.h b/include/common/cmdlib.h index f47b47c2..94396c61 100644 --- a/include/common/cmdlib.h +++ b/include/common/cmdlib.h @@ -28,6 +28,9 @@ #include #include +#define stringify__(x) #x +#define stringify(x) stringify__(x) + typedef enum { false, true } qboolean; typedef unsigned char byte; diff --git a/light/light.c b/light/light.c index 84b4d045..e9176ff1 100644 --- a/light/light.c +++ b/light/light.c @@ -186,11 +186,7 @@ main(int argc, const char **argv) char source[1024]; init_log("light.log"); - logprint("----- TyrLight v0.99e -----\n" -#if 0 - "** Beta version " __DATE__ " " __TIME__ "\n" -#endif - ); + logprint("---- light / TyrUtils " stringify(TYRUTILS_VERSION) " ----\n"); numthreads = GetDefaultThreads(); @@ -229,16 +225,18 @@ main(int argc, const char **argv) break; } + if (i != argc - 1) { + printf("usage: light [-threads num] [-light num] [-extra|-extra4]\n" + " [-dist n] [-range n] [-gate n] [-lit] " + " [-compress] [-nominlimit] bspfile\n"); + exit(1); + } + if (numthreads > 1) logprint("running with %d threads\n", numthreads); if (colored) logprint(".lit colored light output requested on command line.\n"); - if (i != argc - 1) - Error("usage: light [-threads num] [-light num] [-extra|-extra4]\n" - " [-dist n] [-range n] [-gate n] [-lit] [-compress]\n" - " [-nominlimit] bspfile\n"); - start = I_FloatTime(); strcpy(source, argv[i]); diff --git a/qbsp/qbsp.c b/qbsp/qbsp.c index bd03d38f..622eae8f 100644 --- a/qbsp/qbsp.c +++ b/qbsp/qbsp.c @@ -24,7 +24,8 @@ #include "qbsp.h" #include "wad.h" -static const char *IntroString = "TyrQBSP v" stringify(QBSP_VERSION) "\n\n"; +static const char *IntroString = + "---- qbsp / TyrUtils " stringify(TYRUTILS_VERSION) " ----\n"; // command line flags options_t options; @@ -345,27 +346,28 @@ PrintOptions static void PrintOptions(void) { - printf("QBSP performs geometric level processing of Quake .MAP files to create\n"); - printf("Quake .BSP files.\n\n"); - printf("qbsp [options] sourcefile [destfile]\n\n"); - printf("Options:\n"); - printf(" -nofill Doesn't perform outside filling\n"); - printf(" -noclip Doesn't build clip hulls\n"); - printf(" -onlyents Only updates .MAP entities\n"); - printf(" -verbose Print out more .MAP information\n"); - printf(" -noverbose Print out almost no information at all\n"); - printf(" -splitspecial Doesn't combine sky and water faces into one large face\n"); - printf(" -transwater Computes portal information for transparent water\n"); - printf(" -transsky Computes portal information for transparent sky\n"); - printf(" -oldaxis Uses original QBSP texture alignment algorithm\n"); - printf(" -bspleak Creates a .POR file, used in the BSP editor for leaky maps\n"); - printf(" -oldleak Create an old-style QBSP .PTS file (default is new style)\n"); - printf(" -nopercent Prevents output of percent completion information\n"); - printf(" -leakdist [n] Space between leakfile points (default 2)\n"); - printf(" -subdivide [n] Use different texture subdivision (default 240)\n"); - printf(" -wadpath Search this directory for wad files\n"); - printf(" sourcefile .MAP file to process\n"); - printf(" destfile .BSP file to output\n"); + printf("\n" + "qbsp performs geometric level processing of Quake .MAP files to create\n" + "Quake .BSP files.\n\n" + "qbsp [options] sourcefile [destfile]\n\n" + "Options:\n" + " -nofill Doesn't perform outside filling\n" + " -noclip Doesn't build clip hulls\n" + " -onlyents Only updates .MAP entities\n" + " -verbose Print out more .MAP information\n" + " -noverbose Print out almost no information at all\n" + " -splitspecial Doesn't combine sky and water faces into one large face\n" + " -transwater Computes portal information for transparent water\n" + " -transsky Computes portal information for transparent sky\n" + " -oldaxis Uses original QBSP texture alignment algorithm\n" + " -bspleak Creates a .POR file, used in the BSP editor for leaky maps\n" + " -oldleak Create an old-style QBSP .PTS file (default is new style)\n" + " -nopercent Prevents output of percent completion information\n" + " -leakdist [n] Space between leakfile points (default 2)\n" + " -subdivide [n] Use different texture subdivision (default 240)\n" + " -wadpath Search this directory for wad files\n" + " sourcefile .MAP file to process\n" + " destfile .BSP file to output\n"); exit(1); } diff --git a/vis/vis.c b/vis/vis.c index 810f7723..67009a09 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -1156,27 +1156,14 @@ int main(int argc, char **argv) { int i, bsp_version; - qboolean credits = false; init_log("vis.log"); - logprint("---- TyrVis v1.0 ---- " -#if 0 - "(Beta version " __DATE__ " " __TIME__ ")" -#endif - "\n"); + logprint("---- vis / TyrUtils " stringify(TYRUTILS_VERSION) " ----\n"); numthreads = GetDefaultThreads(); for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-credits")) { - logprint("Original source supplied no obligation by iD Software " - "12th September 96\n" - "Modification by Antony Suter, TeamFortress Software " - "\n" - "Additional Modification by Kevin Shanahan, Aka " - "Tyrann \n"); - credits = true; - } else if (!strcmp(argv[i], "-threads")) { + if (!strcmp(argv[i], "-threads")) { numthreads = atoi(argv[i + 1]); i++; } else if (!strcmp(argv[i], "-fast")) { @@ -1198,11 +1185,11 @@ main(int argc, char **argv) break; } - if (i == argc && credits) - return 0; - else if (i != argc - 1) - Error("usage: vis [-threads #] [-level 0-4] [-fast] [-v|-vv] " - "[-credits] bspfile"); + if (i != argc - 1) { + printf("usage: vis [-threads #] [-level 0-4] [-fast] [-v|-vv] " + "[-credits] bspfile"); + exit(1); + } logprint("running with %d threads\n", numthreads);