From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 890AA381ECA3; Wed, 7 Dec 2022 20:30:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 890AA381ECA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670445046; bh=zm29QDesA1/hJD3BhmYAUQQMhFWEE9cxbp3Ysob6ISQ=; h=From:To:Subject:Date:From; b=PJUGbhpeVnyMIY69bYU5XhwqAXS6+oHysKzhdSqGlqbPo/NYhoUIdCqHynRL3MRP8 e14G0rhuZrVJR+KuEaG9BFNxvlzBMWkHtsIuDJkNY9M6lP7EWjMydEAlmOT6Qz5D8R GaVbIEnLkTdLU7UL9J67o/FyBC8IE2uttufLYikQ= 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: uname: generate default release string from git as well X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 792b1c6a6d4acee79e1287369498f6ad8e75c1bf X-Git-Newrev: 97eb64b909bc0a47b3159ae7f7ef2060e4bb8d54 Message-Id: <20221207203046.890AA381ECA3@sourceware.org> Date: Wed, 7 Dec 2022 20:30:46 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D97eb64b909b= c0a47b3159ae7f7ef2060e4bb8d54 commit 97eb64b909bc0a47b3159ae7f7ef2060e4bb8d54 Author: Corinna Vinschen AuthorDate: Wed Dec 7 21:14:27 2022 +0100 Commit: Corinna Vinschen CommitDate: Wed Dec 7 21:30:23 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);