diff options
-rw-r--r-- | Makefile | 3 | ||||
-rwxr-xr-x | configure | 30 | ||||
-rw-r--r-- | txr.1 | 6 | ||||
-rw-r--r-- | txr.c | 12 |
4 files changed, 51 insertions, 0 deletions
@@ -329,6 +329,9 @@ opt/txr-win.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-win\" \ -DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-win$(EXE)\" dbg/txr-win.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-win-dbg\" \ -DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-win-dbg$(EXE)\" +ifneq ($(build_id_exp),) +$(call EACH_CONF,txr.o txr-win.o): TXR_CFLAGS += -DTXR_BUILD_ID=\"$(build_id_exp)\" +endif $(call EACH_CONF,txr.o txr-win.o): TXR_CFLAGS += -DEXE_SUFF=\"$(EXE)\" $(call EACH_CONF,txr.o txr-win.o): TXR_CFLAGS += -DTXR_VER=\"$(txr_ver)\" @@ -211,6 +211,7 @@ have_pkgconfig= libffi_cflags= darwin_target= android_target= +build_id= # # Parse configuration variables @@ -545,6 +546,22 @@ small-mem [$small_mem] and certain global book-keeping arrays in the generational garbage collector are smaller, resulting in more frequent collections. +build-id [$build_id] + + This option specifies the value of the build_id make variable. + The argument is GNU make syntax which calculates a string + that is inserted into the TXR executable. The string is reproduced + by reproduced using the txr --build-id. The default is that there + no build-id, and the --build-id option produces empty output. + + If the argument value "git" is given, then the value is replaced + by syntax which which takes value of the output of the command + "git describe --tags --dirty", + executed in the source directory. This is recalculated each time + the txr.c source file is compiled. + + The build_id variable can be overridden from the make command line. + ! exit 1 fi @@ -869,6 +886,19 @@ compiler_prefix := $compiler_prefix # prefix for non-compiler toolchain commands tool_prefix := $tool_prefix +# build_id +$(gitcmd='git describe --tags --dirty'; + if [ "$build_id" = "git" ] ; then + if [ $build_in_srcdir ] ; then + printf 'build_id ?= $(shell %s)\n' "$gitcmd" + else + printf 'build_id ?= $(shell cd $(top_srcdir); %s)\n' "$gitcmd" + fi + else + printf 'build_id = %s\n' "$build_id" + fi) +build_id_exp := \$(build_id) + # do we compile in syslog support? have_syslog := $have_syslog @@ -905,6 +905,12 @@ Use of \*(TX implies agreement with the liability disclaimer in the license. Prints a message on standard output which includes the program version, and then immediately causes \*(TX to terminate with a successful status. +.coIP --build-id +If \*(TX was built with an embedded build ID string, this +option prints that string. Otherwise nothing is printed. +In either case, \*(TX then immediately terminates with a successful +status. + .coIP --args The .code --args @@ -62,6 +62,9 @@ #include "txr.h" const wchli_t *version = wli(TXR_VER); +#ifdef TXR_BUILD_ID +const wchli_t *build_id = wli(TXR_BUILD_ID); +#endif wchar_t *progname; static const char *progname_u8; static val prog_path = nil, sysroot_path = nil; @@ -139,6 +142,7 @@ static void help(void) " specified version of TXR.\n" "--help Reproduce this help text.\n" "--version Display program version.\n" +"--build-id Print build ID string if compiled in.\n" "--license Display software license.\n" " Use of txr implies agreement with the disclaimer\n" " section at the bottom of the license.\n" @@ -700,6 +704,14 @@ int txr_main(int argc, char **argv) return 0; } + if (equal(opt, lit("build-id"))) { + drop_privilege(); +#ifdef TXR_BUILD_ID + format(std_output, lit("~a\n"), static_str(build_id), nao); +#endif + return 0; + } + if (equal(opt, lit("help"))) { drop_privilege(); help(); |