From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 570173842327; Sun, 11 Dec 2022 10:46:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 570173842327 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670755581; bh=h7IrU+sMmR5rKozF+VjYsLRBi52snc6WYXffJDuiF9M=; h=From:To:Subject:Date:From; b=B5uuTD47LQc2GU1h27guVCqI5teaIKDfawVbcaXyFeIbl2sxzcLXCaZ2ANUNP35zZ Ta6ZaFCqQGCRPjPrwOsQtiGh0faVi+HPocyQBvtCi9hsPIrmSwpJWy5aQ2ZRJUQppp u0yO2oUc/tvoEPYvKITENNvAEiFCJgCR7iZLjtu8= 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: fix building in non-git source dir X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: ea0a84424c0870dc9a3f7ef3bffb0f17b9b79c1e X-Git-Newrev: bfaae2d2349f2ab1a65b6828e01c335851924f0e Message-Id: <20221211104621.570173842327@sourceware.org> Date: Sun, 11 Dec 2022 10:46:21 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Dbfaae2d2349= f2ab1a65b6828e01c335851924f0e commit bfaae2d2349f2ab1a65b6828e01c335851924f0e Author: Corinna Vinschen AuthorDate: Wed Dec 7 22:22:38 2022 +0100 Commit: Corinna Vinschen CommitDate: Sun Dec 11 11:25:04 2022 +0100 Cygwin: uname: fix building in non-git source dir =20 commit 97eb64b909bc broke building outside of a git dir, because the git describe command would fail. Fix this by checking if we're in a git tree at all and just generate an empty string as version string. Use this in uname_x to generate a fallback version. =20 Fixes: 97eb64b909bc ("Cygwin: uname: generate default release string from git as well" Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/Makefile.am | 5 ++++- winsup/cygwin/uname.cc | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am index b1849d5a6737..e61f72716e10 100644 --- a/winsup/cygwin/Makefile.am +++ b/winsup/cygwin/Makefile.am @@ -421,7 +421,10 @@ 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 + echo "const char *uname_dev_version =3D \ + \"$$(git rev-parse --git-dir >/dev/null 2>&1 && \ + git describe --dirty | sed -e 's/cygwin-//')\";" \ + > $(abs_builddir)/uname_version.c .FORCE: =20 # mkvers.sh creates version.cc in the first place, winver.o always diff --git a/winsup/cygwin/uname.cc b/winsup/cygwin/uname.cc index d2f93304e494..dd4160189c3a 100644 --- a/winsup/cygwin/uname.cc +++ b/winsup/cygwin/uname.cc @@ -60,8 +60,16 @@ uname_x (struct utsname *name) __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); + if (uname_dev_version && uname_dev_version[0]) + snprintf (name->release, _UTSNAME_LENGTH, "%s.%s", + uname_dev_version, name->machine); + else + __small_sprintf (name->release, "%d.%d.%d-api-%d.%s", + cygwin_version.dll_major / 1000, + cygwin_version.dll_major % 1000, + cygwin_version.dll_minor, + cygwin_version.api_minor, + name->machine); #endif #pragma GCC diagnostic pop /* version */