From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 4FE073848E20; Sun, 11 Dec 2022 10:46:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4FE073848E20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670755576; bh=xDov62Zyu8/P/doDVG26B0fOLuebDdV98kkyeTFWY5U=; h=From:To:Subject:Date:From; b=rTJULeSsZzIDT/kbT4+Tm9Dtx6KzWZR85uv0DP6kV76GLoRt/1QX7vy+VC37Pz2Ga LVEeUACH8uteKfXhI2YEEVDc+eLR3QnXARoFwdbawRvCQHwPswZ1+K8GaI+zm3Xcq7 MHMqOUaar1mrv0utIKkyncTfsLR8MmKNJwlQJ9Gk= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_4-branch] Cygwin: uname: generate default release string from git as well X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: b9ebb4e9a56feda98b82d760e438af6ed059cb8c X-Git-Newrev: ea0a84424c0870dc9a3f7ef3bffb0f17b9b79c1e Message-Id: <20221211104616.4FE073848E20@sourceware.org> Date: Sun, 11 Dec 2022 10:46:16 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dea0a84424c0= 870dc9a3f7ef3bffb0f17b9b79c1e commit ea0a84424c0870dc9a3f7ef3bffb0f17b9b79c1e Author: Corinna Vinschen AuthorDate: Wed Dec 7 21:14:27 2022 +0100 Commit: Corinna Vinschen CommitDate: Sun Dec 11 11:25:04 2022 +0100 Cygwin: uname: generate default release string from git as well =20 When building a release with cygport, we get uname version info from cygport, which in turn gets version info from `git describe'. =20 During development, the release info for local builds was not that helpful yet. Fix that, by creating version info from `git describe' if CYGPORT_RELEASE_INFO isn't given. Make sure to always force rebuild of the version info to pick up source file changes as well as git actions. =20 Rearrange code slightly to generate machine info first, release info after that. Use snprintf to generate release string safely. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/Makefile.am | 8 +++++++- winsup/cygwin/uname.cc | 31 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am index 8ba5ae2717b0..b1849d5a6737 100644 --- a/winsup/cygwin/Makefile.am +++ b/winsup/cygwin/Makefile.am @@ -365,7 +365,8 @@ GMON_FILES=3D \ profil.c =20 GENERATED_FILES=3D \ - sigfe.s + sigfe.s \ + uname_version.c =20 liblib_a_SOURCES=3D \ $(LIB_FILES) @@ -418,6 +419,11 @@ dirs =3D $(srcdir) $(srcdir)/fhandler $(srcdir)/lib $(= srcdir)/libc $(srcdir)/math find_src_files =3D $(wildcard $(dir)/*.[chS]) $(wildcard $(dir)/*.cc) src_files :=3D $(foreach dir,$(dirs),$(find_src_files)) =20 +uname_version.c: .FORCE + $(AM_V_GEN)cd $(srcdir) && \ + echo "const char *uname_dev_version =3D \"$$(git describe --dirty | sed -= e 's/cygwin-//')\";" > $(abs_builddir)/uname_version.c +.FORCE: + # mkvers.sh creates version.cc in the first place, winver.o always # second, so version.cc is always older than winver.o version.cc: scripts/mkvers.sh include/cygwin/version.h winver.rc $(src_fil= es) diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index e893660c6a1d..d2f93304e494 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -9,6 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" f= or details. */ =20 #include "winsup.h" +#include #include #include #include "cygwin_version.h" @@ -41,29 +42,31 @@ uname_x (struct utsname *name) memset (buf, 0, sizeof buf); cygwin_gethostname (buf, sizeof buf - 1); strncat (name->nodename, buf, sizeof (name->nodename) - 1); - /* release */ -#ifdef CYGPORT_RELEASE_INFO - stpcpy (name->release, __XSTRING (CYGPORT_RELEASE_INFO)); -#else - __small_sprintf (name->release, "%d.%d.%d-0.%d.local.", - cygwin_version.dll_major / 1000, - cygwin_version.dll_major % 1000, - cygwin_version.dll_minor, - cygwin_version.api_minor); -#endif - /* version */ - stpcpy (name->version, cygwin_version.dll_build_date); - strcat (name->version, " UTC"); /* machine */ switch (wincap.cpu_arch ()) { case PROCESSOR_ARCHITECTURE_AMD64: - strcat (name->release, strcpy (name->machine, "x86_64")); + strcpy (name->machine, "x86_64"); break; default: strcpy (name->machine, "unknown"); break; } + /* release */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-truncation=3D" +#ifdef CYGPORT_RELEASE_INFO + snprintf (name->release, _UTSNAME_LENGTH, "%s.%s", + __XSTRING (CYGPORT_RELEASE_INFO), name->machine); +#else + extern const char *uname_dev_version; + snprintf (name->release, _UTSNAME_LENGTH, "%s.%s", + uname_dev_version, name->machine); +#endif +#pragma GCC diagnostic pop + /* version */ + stpcpy (name->version, cygwin_version.dll_build_date); + strcat (name->version, " UTC"); /* domainame */ memset (buf, 0, sizeof buf); getdomainname (buf, sizeof buf - 1);