Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for supported version of D compiler #545

Merged
merged 4 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ function setup_x32_chroot {
# Host dependencies
sudo apt-get install -qq -y ${HOST_DEPENDENCIES}
# Download DMD compiler
wget http://downloads.dlang.org/releases/2.x/2.081.1/dmd.2.081.1.linux.tar.xz
tar -xf dmd.2.081.1.linux.tar.xz
DMDVER=2.083.1
wget http://downloads.dlang.org/releases/2.x/${DMDVER}/dmd.${DMDVER}.linux.tar.xz
tar -xf dmd.${DMDVER}.linux.tar.xz
mv dmd2 dlang-${ARCH}
rm -rf dmd.2.081.1.linux.tar.xz
rm -rf dmd.${DMDVER}.linux.tar.xz
# Create chrooted environment
sudo mkdir ${CHROOT_DIR}
sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch=${CHROOT_ARCH32} ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
Expand Down
105 changes: 105 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_version_check
with_systemdsystemunitdir
with_systemduserunitdir
enable_notifications
Expand Down Expand Up @@ -1297,6 +1298,8 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-version-check Disable checks of compiler version during configure
time
--enable-notifications Enable desktop notifications via libnotify
--enable-completions Install shell completions for bash and zsh
--enable-debug Pass debug option to the compiler
Expand Down Expand Up @@ -2063,6 +2066,108 @@ case $(basename $DC) in
NOT_FOUND) as_fn_error 1 "Could not find any compatible D compiler" "$LINENO" 5
esac

vercomp () {
IFS=. read -r a0 a1 a2 aa <<EOF
$1
EOF
IFS=. read -r b0 b1 b2 bb <<EOF
$2
EOF
# leading 0 are ignored: 01 == 1, this also
# converts empty strings into 0: 1..2 == 1.0.2
a0=$(expr $a0 + 0)
a1=$(expr $a1 + 0)
a2=$(expr $a2 + 0)
b0=$(expr $b0 + 0)
b1=$(expr $b1 + 0)
b2=$(expr $b2 + 0)
#echo "$1 parsed to a=$a0 b=$a1 c=$a2 rest=$aa"
#echo "$2 parsed to a=$b0 b=$b1 c=$b2 rest=$bb"
if test $a0 -lt $b0
then
return 2
elif test $a0 -gt $b0
then
return 1
else
if test $a1 -lt $b1
then
return 2
elif test $a1 -gt $b1
then
return 1
else
if test $a2 -lt $b2
then
return 2
elif test $a2 -gt $b2
then
return 1
else
if test $aa '<' $bb
then
return 2
elif test $aa '>' $bb
then
return 1
else
return 0
fi
fi
fi
fi
}

DO_VERSION_CHECK=1
# Check whether --enable-version-check was given.
if test "${enable_version_check+set}" = set; then :
enableval=$enable_version_check;
fi

if test "x$enable_version_check" = "xno"; then :
DO_VERSION_CHECK=0
fi

if test "$DO_VERSION_CHECK" = "1"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking version of D compiler" >&5
$as_echo_n "checking version of D compiler... " >&6; }
# check for valid versions
case $(basename $DC) in
ldmd2|ldc2)
# LDC - the LLVM D compiler (1.12.0): ...
VERSION=`$DC --version`
# remove everything up to first (
VERSION=${VERSION#* (}
# remove everthing after ):
VERSION=${VERSION%%):*}
# now version should be something like L.M.N
MINVERSION=1.11.0
;;
dmd)
# DMD64 D Compiler v2.085.1\n...
VERSION=`$DC --version | tr '\n' ' '`
VERSION=${VERSION#*Compiler v}
VERSION=${VERSION%% *}
# now version should be something like L.M.N
MINVERSION=2.083.1
;;
esac

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $VERSION" >&5
$as_echo "$VERSION" >&6; }

vercomp $MINVERSION $VERSION
if test $? = 1
then
as_fn_error 1 "Compiler version insufficient, current compiler version $VERSION, minimum version $MINVERSION" "$LINENO" 5
fi
#echo "MINVERSION=$MINVERSION VERSION=$VERSION"

fi






PACKAGE_DATE="June 2019"
Expand Down
96 changes: 96 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,102 @@ case $(basename $DC) in
ldc2) DC_TYPE=ldc ;;
NOT_FOUND) AC_MSG_ERROR(Could not find any compatible D compiler, 1)
esac

dnl dash/POSIX version of version comparison
vercomp () {
IFS=. read -r a0 a1 a2 aa <<EOF
$1
EOF
IFS=. read -r b0 b1 b2 bb <<EOF
$2
EOF
# leading 0 are ignored: 01 == 1, this also
# converts empty strings into 0: 1..2 == 1.0.2
a0=$(expr $a0 + 0)
a1=$(expr $a1 + 0)
a2=$(expr $a2 + 0)
b0=$(expr $b0 + 0)
b1=$(expr $b1 + 0)
b2=$(expr $b2 + 0)
#echo "$1 parsed to a=$a0 b=$a1 c=$a2 rest=$aa"
#echo "$2 parsed to a=$b0 b=$b1 c=$b2 rest=$bb"
if test $a0 -lt $b0
then
return 2
elif test $a0 -gt $b0
then
return 1
else
if test $a1 -lt $b1
then
return 2
elif test $a1 -gt $b1
then
return 1
else
if test $a2 -lt $b2
then
return 2
elif test $a2 -gt $b2
then
return 1
else
if test $aa '<' $bb
then
return 2
elif test $aa '>' $bb
then
return 1
else
return 0
fi
fi
fi
fi
}

DO_VERSION_CHECK=1
AC_ARG_ENABLE(version-check,
AS_HELP_STRING([--disable-version-check], [Disable checks of compiler version during configure time]))
AS_IF([test "x$enable_version_check" = "xno"], DO_VERSION_CHECK=0,)

AS_IF([test "$DO_VERSION_CHECK" = "1"],
[ dnl do the version check
AC_MSG_CHECKING([version of D compiler])
# check for valid versions
case $(basename $DC) in
ldmd2|ldc2)
# LDC - the LLVM D compiler (1.12.0): ...
VERSION=`$DC --version`
# remove everything up to first (
VERSION=${VERSION#* (}
# remove everthing after ):
VERSION=${VERSION%%):*}
# now version should be something like L.M.N
MINVERSION=1.11.0
;;
dmd)
# DMD64 D Compiler v2.085.1\n...
VERSION=`$DC --version | tr '\n' ' '`
VERSION=${VERSION#*Compiler v}
VERSION=${VERSION%% *}
# now version should be something like L.M.N
MINVERSION=2.083.1
;;
esac

AC_MSG_RESULT([$VERSION])

vercomp $MINVERSION $VERSION
if test $? = 1
then
AC_MSG_ERROR([Compiler version insufficient, current compiler version $VERSION, minimum version $MINVERSION], 1)
fi
#echo "MINVERSION=$MINVERSION VERSION=$VERSION"
])



AC_SUBST([DC_TYPE])
dnl In case the environment variable DCFLAGS is set, we export it to the
dnl generated Makefile at configure run:
Expand Down