Skip to content

Commit 733cb1f

Browse files
dschojeremyd2019
authored andcommitted
uname: report msys2-runtime commit hash, too
Having just Cygwin's version in the output of `uname` is not helpful, as both MSYS2 as well as Git for Windows release intermediate versions of the MSYS2 runtime much more often than Cygwin runtime versions are released. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 381d642 commit 733cb1f

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

Diff for: winsup/configure.ac

+8-2
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,30 @@ AC_ARG_WITH([msys2-runtime-commit],
6565
case "$MSYS2_RUNTIME_COMMIT" in
6666
no)
6767
MSYS2_RUNTIME_COMMIT=
68+
MSYS2_RUNTIME_COMMIT_SHORT=
6869
MSYS2_RUNTIME_COMMIT_HEX=0
6970
;;
7071
yes|auto)
7172
if MSYS2_RUNTIME_COMMIT="$(git --git-dir="$srcdir/../.git" rev-parse HEAD)"
7273
then
73-
MSYS2_RUNTIME_COMMIT_HEX="0x$(expr "$MSYS2_RUNTIME_COMMIT" : '\(.\{,8\}\)')ull"
74+
MSYS2_RUNTIME_COMMIT_SHORT="$(expr "$MSYS2_RUNTIME_COMMIT" : '\(.\{,8\}\)')"
75+
MSYS2_RUNTIME_COMMIT_HEX="0x${MSYS2_RUNTIME_COMMIT_SHORT}ul"
7476
else
7577
AC_MSG_WARN([Could not determine msys2-runtime commit])
7678
MSYS2_RUNTIME_COMMIT=
79+
MSYS2_RUNTIME_COMMIT_SHORT=
7780
MSYS2_RUNTIME_COMMIT_HEX=0
7881
fi
7982
;;
8083
*)
8184
expr "$MSYS2_RUNTIME_COMMIT" : '@<:@0-9a-f@:>@\{6,64\}$' ||
8285
AC_MSG_ERROR([Invalid commit name: "$MSYS2_RUNTIME_COMMIT"])
83-
MSYS2_RUNTIME_COMMIT_HEX="0x$(expr "$MSYS2_RUNTIME_COMMIT" : '\(.\{,8\}\)')ull"
86+
MSYS2_RUNTIME_COMMIT_SHORT="$(expr "$MSYS2_RUNTIME_COMMIT" : '\(.\{,8\}\)')"
87+
MSYS2_RUNTIME_COMMIT_HEX="0x${MSYS2_RUNTIME_COMMIT_SHORT}ul"
8488
;;
8589
esac
90+
AC_SUBST(MSYS2_RUNTIME_COMMIT)
91+
AC_SUBST(MSYS2_RUNTIME_COMMIT_SHORT)
8692
AC_SUBST(MSYS2_RUNTIME_COMMIT_HEX)
8793

8894
AC_ARG_ENABLE(debugging,

Diff for: winsup/cygwin/Makefile.am

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ if TARGET_X86_64
1717
COMMON_CFLAGS+=-mcmodel=small
1818
endif
1919

20-
VERSION_CFLAGS = -DMSYS2_RUNTIME_COMMIT_HEX="@MSYS2_RUNTIME_COMMIT_HEX@"
20+
VERSION_CFLAGS = -DMSYS2_RUNTIME_COMMIT="\"@MSYS2_RUNTIME_COMMIT@\""
21+
VERSION_CFLAGS += -DMSYS2_RUNTIME_COMMIT_SHORT="\"@MSYS2_RUNTIME_COMMIT_SHORT@\""
22+
VERSION_CFLAGS += -DMSYS2_RUNTIME_COMMIT_HEX="@MSYS2_RUNTIME_COMMIT_HEX@"
2123
COMMON_CFLAGS += $(VERSION_CFLAGS)
2224

2325
AM_CFLAGS=$(cflags_common) $(COMMON_CFLAGS)
@@ -452,7 +454,7 @@ uname_version.c: .FORCE
452454
version.cc: scripts/mkvers.sh include/cygwin/version.h winver.rc $(src_files)
453455
@echo "Making version.cc and winver.o";\
454456
export CC="$(CC)";\
455-
/bin/sh $(word 1,$^) $(word 2,$^) $(word 3,$^) $(WINDRES) $(CFLAGS)
457+
/bin/sh $(word 1,$^) $(word 2,$^) $(word 3,$^) $(WINDRES) $(CFLAGS) $(VERSION_CFLAGS)
456458

457459
winver.o: version.cc
458460

Diff for: winsup/cygwin/scripts/mkvers.sh

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ incfile="$1"; shift
1616
rcfile="$1"; shift
1717
windres="$1"; shift
1818
iflags=
19+
msys2_runtime_commit=
1920
# Find header file locations
2021
while [ -n "$*" ]; do
2122
case "$1" in
@@ -26,6 +27,9 @@ while [ -n "$*" ]; do
2627
shift
2728
iflags="$iflags -I$1"
2829
;;
30+
-DMSYS2_RUNTIME_COMMIT=*)
31+
msys2_runtime_commit="${1#*=}"
32+
;;
2933
esac
3034
shift
3135
done
@@ -168,6 +172,10 @@ then
168172
cvs_tag="$(echo $wv_cvs_tag | sed -e 's/-branch.*//')"
169173
cygwin_ver="$cygwin_ver-$cvs_tag"
170174
fi
175+
if [ -n "$msys2_runtime_commit" ]
176+
then
177+
cygwin_ver="$cygwin_ver-$msys2_runtime_commit"
178+
fi
171179

172180
echo "Version $cygwin_ver"
173181
set -$- $builddate

Diff for: winsup/cygwin/uname.cc

+9-7
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,19 @@ uname_x (struct utsname *name)
9191
#pragma GCC diagnostic push
9292
#pragma GCC diagnostic ignored "-Wformat-truncation="
9393
#ifdef CYGPORT_RELEASE_INFO
94-
snprintf (name->release, _UTSNAME_LENGTH, "%s.%s",
95-
__XSTRING (CYGPORT_RELEASE_INFO), name->machine);
94+
snprintf (name->release, _UTSNAME_LENGTH, "%s-%s.%s",
95+
__XSTRING (CYGPORT_RELEASE_INFO), MSYS2_RUNTIME_COMMIT_SHORT, name->machine);
9696
#else
9797
extern const char *uname_dev_version;
9898
if (uname_dev_version && uname_dev_version[0])
99-
snprintf (name->release, _UTSNAME_LENGTH, "%s.%s",
100-
uname_dev_version, name->machine);
99+
snprintf (name->release, _UTSNAME_LENGTH, "%s-%s.%s",
100+
uname_dev_version, MSYS2_RUNTIME_COMMIT_SHORT, name->machine);
101101
else
102-
__small_sprintf (name->release, "%d.%d.%d-api-%d.%s",
102+
__small_sprintf (name->release, "%d.%d.%d-%s-api-%d.%s",
103103
cygwin_version.dll_major / 1000,
104104
cygwin_version.dll_major % 1000,
105105
cygwin_version.dll_minor,
106+
MSYS2_RUNTIME_COMMIT_SHORT,
106107
cygwin_version.api_minor,
107108
name->machine);
108109
#endif
@@ -145,14 +146,15 @@ uname (struct utsname *in_name)
145146
cygwin_gethostname (name->nodename, sizeof (name->nodename) - 1);
146147

147148
/* Cygwin dll release */
148-
__small_sprintf (name->release, "%d.%d.%d(%d.%d/%d/%d)",
149+
__small_sprintf (name->release, "%d.%d.%d(%d.%d/%d/%d/%s)",
149150
cygwin_version.dll_major / 1000,
150151
cygwin_version.dll_major % 1000,
151152
cygwin_version.dll_minor,
152153
cygwin_version.api_major,
153154
cygwin_version.api_minor,
154155
cygwin_version.shared_data,
155-
cygwin_version.mount_registry);
156+
cygwin_version.mount_registry,
157+
MSYS2_RUNTIME_COMMIT_SHORT);
156158

157159
/* Cygwin "version" aka build date */
158160
strcpy (name->version, cygwin_version.dll_build_date);

0 commit comments

Comments
 (0)