Incorporate some git information into NetHack

Incorporate some git information into NetHack so that it
is potentially visible to a player. That's useful when
collecting details about the version that they are
running and, if the gitinfo is present, it can tie the
code to a specific git commit in the repository.

This modifies 'makedefs -v' to check for the presence of a data file
called dat/gitinfo.txt and if it is there, parse out its
contents, then write additional lines to include/date.h beyond
what 'makedefs -v' was previously putting in there, similar to
this sample:

      #define NETHACK_GIT_SHA "0c84e564c78e2024e562d39539376ce2e21eec8e"
      #define NETHACK_GIT_BRANCH "NetHack-3.6.0"

The contents of an appropriate dat/gitinfo.txt are as follows,
and trailing/leading whitespace is not significant:

      githash = 0c84e564c78e2024e562d39539376ce2e21eec8e
      gitbranch = NetHack-3.6.0

It also adjusts the contents of the 'v' version information to
include the additional git info when available.

Also adds some hooks DEVEL/hooksdir and a perl file to DEVEL
for simplifying and automating the deposit of dat/gitinfo.txt
so that it generally reflects the most current git commit.

DEVEL/gitinfo.pl can be used to build dat/gitinfo.txt at any
time without doing a commit, merge, or checkout.
    	perl DEVEL/gitinfo.pl

command line --version and -version support

To complement the extra information being provided in the
version by the 'v' command, this also adds support for the
following new command line arguments:
    --version
     -version            Output the NetHack version string then exit.

    --version:paste      Output the NetHack version string and also copy it to
     -version:paste      the platform's paste buffer for insertion somewhere,
                         then exit.

If the paste variation of -version is requested on a platform that
hasn't incorporated any support for the capability, it will deliver
the version info then an error message, prior to exiting.

To support the extended -version:paste variation, a port needs to:
    - provide a port-specific routine to perform
      the paste buffer copy in a port code file.
    - #define RUNTIME_PASTEBUF_SUPPORT in the include/portconf.h header file.

    --skeleton--
    void port_insert_pastebuf(buf)
    char *buf;
    {
    	/* insert code to copy the version info from buf into
    	   platform's paste buffer in a supported way */
    }

macosx and Windows have both added support for RUNTIME_PASTEBUF_SUPPORT
This commit is contained in:
nhmall
2018-01-28 22:54:08 -05:00
committed by keni
parent 5dd6c05322
commit 65655d2cee
17 changed files with 485 additions and 9 deletions

View File

@@ -422,6 +422,15 @@ E struct plinemsg_type *plinemsg_types;
E const char *ARGV0;
#endif
enum earlyarg {ARG_DEBUG, ARG_VERSION};
struct early_opt {
enum earlyarg e;
const char *name;
int minlength;
boolean valallowed;
};
#undef E
#endif /* DECL_H */

View File

@@ -26,6 +26,7 @@ E void NDECL(display_gamewindows);
E void NDECL(newgame);
E void FDECL(welcome, (BOOLEAN_P));
E time_t NDECL(get_realtime);
E boolean FDECL(argcheck, (int, char **, enum earlyarg));
/* ### apply.c ### */
@@ -2567,10 +2568,14 @@ E void FDECL(store_version, (int));
E unsigned long FDECL(get_feature_notice_ver, (char *));
E unsigned long NDECL(get_current_feature_ver);
E const char *FDECL(copyright_banner_line, (int));
E void FDECL(early_version_info, (BOOLEAN_P));
#ifdef RUNTIME_PORT_ID
E char *FDECL(get_port_id, (char *));
#endif
#ifdef RUNTIME_PASTEBUF_SUPPORT
E void FDECL(port_insert_pastebuf, (char *));
#endif
/* ### video.c ### */

View File

@@ -69,6 +69,12 @@
#define PORT_DEBUG /* include ability to debug international keyboard issues \
*/
#define RUNTIME_PORT_ID /* trigger run-time port identification for \
* identification of exe CPU architecture \
*/
#define RUNTIME_PASTEBUF_SUPPORT
#define SAFERHANGUP /* Define SAFERHANGUP to delay hangup processing \
* until the main command loop. 'safer' because it \
* avoids certain cheats and also avoids losing \
@@ -117,11 +123,6 @@ extern void FDECL(interject, (int));
#endif
#endif /* _MSC_VER */
#define RUNTIME_PORT_ID /* trigger run-time port identification for \
* identification of exe CPU architecture \
*/
/* The following is needed for prototypes of certain functions */
#if defined(_MSC_VER)
#include <process.h> /* Provides prototypes of exit(), spawn() */

View File

@@ -387,5 +387,9 @@
#endif /* LINUX */
#endif /* GNOME_GRAPHICS */
#ifdef __APPLE__
# define RUNTIME_PASTEBUF_SUPPORT
#endif
#endif /* UNIXCONF_H */
#endif /* UNIX */