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:
@@ -737,5 +737,87 @@ const char *msg;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Argument processing helpers - for xxmain() to share
|
||||
* and call.
|
||||
*
|
||||
* These should return TRUE if the argument matched,
|
||||
* whether the processing of the argument was
|
||||
* successful or not.
|
||||
*
|
||||
* Most of these do their thing, then after returning
|
||||
* to xxmain(), the code exits without starting a game.
|
||||
*
|
||||
*/
|
||||
|
||||
static struct early_opt earlyopts[] = {
|
||||
{ARG_DEBUG, "debug", 5, FALSE},
|
||||
{ARG_VERSION, "version", 4, TRUE},
|
||||
};
|
||||
|
||||
boolean
|
||||
argcheck(argc, argv, e_arg)
|
||||
int argc;
|
||||
char *argv[];
|
||||
enum earlyarg e_arg;
|
||||
{
|
||||
int i, idx;
|
||||
boolean match = FALSE;
|
||||
char *userea = (char *)0, *dashdash = "";
|
||||
|
||||
for (idx = 0; idx < SIZE(earlyopts); idx++) {
|
||||
if (earlyopts[idx].e == e_arg)
|
||||
break;
|
||||
}
|
||||
if ((idx >= SIZE(earlyopts)) || (argc <= 1))
|
||||
return FALSE;
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (argv[i][0] != '-')
|
||||
continue;
|
||||
if (argv[i][1] == '-') {
|
||||
userea = &argv[i][2];
|
||||
dashdash = "-";
|
||||
} else {
|
||||
userea = &argv[i][1];
|
||||
}
|
||||
match = match_optname(userea, earlyopts[idx].name,
|
||||
earlyopts[idx].minlength, earlyopts[idx].valallowed);
|
||||
if (match) break;
|
||||
}
|
||||
|
||||
if (match) {
|
||||
switch(e_arg) {
|
||||
case ARG_DEBUG:
|
||||
break;
|
||||
case ARG_VERSION: {
|
||||
boolean insert_into_pastebuf = FALSE;
|
||||
const char *extended_opt = index(userea,':');
|
||||
|
||||
if (!extended_opt)
|
||||
extended_opt = index(userea, '=');
|
||||
|
||||
if (extended_opt) {
|
||||
extended_opt++;
|
||||
if (match_optname(extended_opt, "paste",
|
||||
5, FALSE)) {
|
||||
insert_into_pastebuf = TRUE;
|
||||
} else {
|
||||
raw_printf(
|
||||
"-%sversion can only be extended with -%sversion:paste.\n",
|
||||
dashdash, dashdash);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
early_version_info(insert_into_pastebuf);
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*allmain.c*/
|
||||
|
||||
Reference in New Issue
Block a user