Skip to content

Commit e539424

Browse files
committed
Auto merge of rust-lang#25208 - lfairy:version-hash, r=brson
The code takes a prefix of the MD5 hash of the version string. Since the hash command differs across GNU and BSD platforms, we scan for the right one in the configure script. Closes rust-lang#25007
2 parents 5a341ec + 2c0db5e commit e539424

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

configure

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ probe() {
106106
T=$(command -v $P 2>&1)
107107
if [ $? -eq 0 ]
108108
then
109-
VER0=$($P --version 2>/dev/null | head -1 \
110-
| sed -e 's/[^0-9]*\([vV]\?[0-9.]\+[^ ]*\).*/\1/' )
109+
VER0=$($P --version 2>/dev/null \
110+
| grep -o '[vV]\?[0-9][0-9.][a-z0-9.-]*' | head -1 )
111111
if [ $? -eq 0 -a "x${VER0}" != "x" ]
112112
then
113113
VER="($VER0)"
@@ -711,6 +711,20 @@ else
711711
probe_need CFG_GIT git
712712
fi
713713

714+
# Use `md5sum` on GNU platforms, or `md5 -q` on BSD
715+
probe CFG_MD5 md5
716+
probe CFG_MD5SUM md5sum
717+
if [ -n "$CFG_MD5" ]
718+
then
719+
CFG_HASH_COMMAND="$CFG_MD5 -q | head -c 8"
720+
elif [ -n "$CFG_MD5SUM" ]
721+
then
722+
CFG_HASH_COMMAND="$CFG_MD5SUM | head -c 8"
723+
else
724+
err 'could not find one of: md5 md5sum'
725+
fi
726+
putvar CFG_HASH_COMMAND
727+
714728
probe CFG_CLANG clang++
715729
probe CFG_CCACHE ccache
716730
probe CFG_GCC gcc

mk/main.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ CFG_RELEASE_NUM=1.1.0
2020
# versions (section 9)
2121
CFG_PRERELEASE_VERSION=.1
2222

23-
CFG_FILENAME_EXTRA=4e7c5e5c
23+
# Append a version-dependent hash to each library, so we can install different
24+
# versions in the same place
25+
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE) | $(CFG_HASH_COMMAND))
2426

2527
ifeq ($(CFG_RELEASE_CHANNEL),stable)
2628
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"

0 commit comments

Comments
 (0)