Merge pull request #1026 from pyenv/ruby-build-20171031

Imported recent changes from the latest ruby-build as of Oct 31, 2017
This commit is contained in:
Yamashita, Yuu 2017-11-04 06:47:44 +09:00 committed by GitHub
commit 7ab48c47fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 157 additions and 95 deletions

View file

@ -709,7 +709,7 @@ build_package_warn_unsupported() {
} >&3
}
build_package_standard() {
build_package_standard_build() {
local package_name="$1"
if [ "${MAKEOPTS+defined}" ]; then
@ -726,12 +726,11 @@ build_package_standard() {
local PACKAGE_CONFIGURE_OPTS_ARRAY="${package_var_name}_CONFIGURE_OPTS_ARRAY[@]"
local PACKAGE_MAKE_OPTS="${package_var_name}_MAKE_OPTS"
local PACKAGE_MAKE_OPTS_ARRAY="${package_var_name}_MAKE_OPTS_ARRAY[@]"
local PACKAGE_MAKE_INSTALL_OPTS="${package_var_name}_MAKE_INSTALL_OPTS"
local PACKAGE_MAKE_INSTALL_OPTS_ARRAY="${package_var_name}_MAKE_INSTALL_OPTS_ARRAY[@]"
local PACKAGE_MAKE_INSTALL_TARGET="${package_var_name}_MAKE_INSTALL_TARGET"
local PACKAGE_CFLAGS="${package_var_name}_CFLAGS"
[ "$package_var_name" = "PYTHON" ] && use_homebrew_readline || true
if [ "$package_var_name" = "PYTHON" ]; then
use_homebrew_readline || use_freebsd_pkg ||true
fi
( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then
export CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}"
@ -744,10 +743,35 @@ build_package_standard() {
) >&4 2>&1
{ "$MAKE" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} "${!PACKAGE_MAKE_OPTS_ARRAY}"
"$MAKE" "${!PACKAGE_MAKE_INSTALL_TARGET:-install}" $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}"
} >&4 2>&1
}
build_package_standard_install() {
local package_name="$1"
local package_var_name="$(capitalize "${package_name%%-*}")"
local PACKAGE_MAKE_INSTALL_OPTS="${package_var_name}_MAKE_INSTALL_OPTS"
local PACKAGE_MAKE_INSTALL_OPTS_ARRAY="${package_var_name}_MAKE_INSTALL_OPTS_ARRAY[@]"
local PACKAGE_MAKE_INSTALL_TARGET="${package_var_name}_MAKE_INSTALL_TARGET"
{ "$MAKE" "${!PACKAGE_MAKE_INSTALL_TARGET:-install}" $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}"
} >&4 2>&1
}
build_package_standard_install_with_bundled_gems() {
{ "$MAKE" update-gems
"$MAKE" extract-gems
} >&4 2>&1
build_package_standard_install "$@"
}
# Backword Compatibility for standard function
build_package_standard() {
build_package_standard_build "$@"
build_package_standard_install "$@"
}
build_package_autoconf() {
{ autoconf
} >&4 2>&1
@ -806,7 +830,7 @@ build_package_rbx() {
fi
done
RUBYOPT="-rubygems $RUBYOPT" ./configure --prefix="$PREFIX_PATH" $RUBY_CONFIGURE_OPTS "${configure_opts[@]}"
RUBYOPT="-rrubygems $RUBYOPT" ./configure --prefix="$PREFIX_PATH" $RUBY_CONFIGURE_OPTS "${configure_opts[@]}"
rake install
fix_rbx_gem_binstubs "$PREFIX_PATH"
fix_rbx_irb "$PREFIX_PATH"
@ -1245,20 +1269,21 @@ require_llvm() {
3.2 )
package_option python configure --prebuilt-name="llvm-3.2-x86_64-apple-darwin13.tar.bz2"
;;
3.5 )
3.[56] )
local llvm_config="$(locate_llvm "$llvm_version")"
if [ -n "$llvm_config" ]; then
package_option python configure --llvm-config="$llvm_config"
else
local homebrew_package="llvm@$llvm_version"
{ echo
colorize 1 "ERROR"
echo ": Rubinius will not be able to compile using Apple's LLVM-based "
echo "build tools on OS X. You will need to install LLVM 3.5 first."
echo "build tools on OS X. You will need to install LLVM $llvm_version first."
echo
colorize 1 "TO FIX THE PROBLEM"
echo ": Install Homebrew's llvm package with this"
echo -n "command: "
colorize 4 "brew tap homebrew/versions ; brew install llvm35"
colorize 4 "brew install $homebrew_package"
echo
} >&3
return 1
@ -1357,6 +1382,7 @@ needs_yaml() {
use_homebrew_yaml() {
local libdir="$(brew --prefix libyaml 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "python-build: use libyaml from homebrew"
export CPPFLAGS="-I$libdir/include ${CPPFLAGS}"
export LDFLAGS="-L$libdir/lib ${LDFLAGS}"
else
@ -1364,6 +1390,30 @@ use_homebrew_yaml() {
fi
}
use_freebsd_pkg() {
# check if FreeBSD
if [ "FreeBSD" = "$(uname -s)" ]; then
# use openssl if installed from Ports Collection
if [ -f /usr/local/include/openssl/ssl.h ]; then
package_option ruby configure --with-openssl-dir="/usr/local"
fi
# check if 11-R or later
release="$(uname -r)"
if [ "${release%%.*}" -ge 11 ]; then
# prefers readline to compile most of ruby versions
if pkg info -e readline > /dev/null; then
# use readline from Ports Collection
package_option ruby configure --with-readline-dir="/usr/local"
elif pkg info -e libedit > /dev/null; then
# use libedit from Ports Collection
package_option ruby configure --enable-libedit
package_option ruby configure --with-libedit-dir="/usr/local"
fi
fi
fi
}
has_broken_mac_readline() {
# Mac OS X 10.4 has broken readline.
# https://github.com/pyenv/pyenv/issues/23
@ -1376,6 +1426,7 @@ use_homebrew_readline() {
if ! configured_with_package_dir "python" "readline/rlconf.h"; then
local libdir="$(brew --prefix readline 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "python-build: use readline from homebrew"
export CPPFLAGS="-I$libdir/include ${CPPFLAGS}"
export LDFLAGS="-L$libdir/lib ${LDFLAGS}"
else
@ -1394,6 +1445,7 @@ has_broken_mac_openssl() {
use_homebrew_openssl() {
local ssldir="$(brew --prefix openssl 2>/dev/null || true)"
if [ -d "$ssldir" ]; then
echo "python-build: use openssl from homebrew"
export CPPFLAGS="-I$ssldir/include ${CPPFLAGS}"
export LDFLAGS="-L$ssldir/lib ${LDFLAGS}"
else
@ -1459,6 +1511,10 @@ build_package_ldflags_dirs() {
done
}
build_package_enable_shared() {
package_option python configure --enable-shared
}
build_package_auto_tcltk() {
if is_mac && [ ! -d /usr/include/X11 ]; then
if [ -d /opt/X11/include ]; then
@ -1768,7 +1824,7 @@ list_definitions() {
}
sort_versions() {
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | \
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z.\1/; s/$/.z/; G; s/\n/ /' | \
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
}
@ -1877,27 +1933,30 @@ if [ -n "$noexec" ]; then
exit 1
fi
# Work around warnings building Ruby 2.0 on Clang 2.x:
# pass -Wno-error=shorten-64-to-32 if the compiler accepts it.
#
# When we set CFLAGS, Ruby won't apply its default flags, though. Since clang
# builds 1.9.x and 2.x only, where -O3 is default, we can safely set that flag.
# Ensure it's the first flag since later flags take precedence.
#if "${CC:-cc}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then
# PYTHON_CFLAGS="-O3 -Wno-error=shorten-64-to-32 $PYTHON_CFLAGS"
## Apply following work around, if gcc is not installed.
#if [ -z "$(locate_gcc)" ]; then
# # Work around warnings building Ruby 2.0 on Clang 2.x:
# # pass -Wno-error=shorten-64-to-32 if the compiler accepts it.
# #
# # When we set CFLAGS, Ruby won't apply its default flags, though. Since clang
# # builds 1.9.x and 2.x only, where -O3 is default, we can safely set that flag.
# # Ensure it's the first flag since later flags take precedence.
# if "${CC:-cc}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then
# RUBY_CFLAGS="-O3 -Wno-error=shorten-64-to-32 $RUBY_CFLAGS"
# fi
#fi
if [ -z "$MAKE" ]; then
if [ "FreeBSD" = "$(uname -s)" ]; then
# if [ $(echo $1 | sed 's/-.*$//') = "jruby" ]; then
# export MAKE="gmake"
# else
if [ "$(echo $1 | sed 's/-.*$//')" = "jruby" ]; then
export MAKE="gmake"
else
if [ "$(uname -r | sed 's/[^[:digit:]].*//')" -lt 10 ]; then
export MAKE="gmake"
else
export MAKE="make"
fi
# fi
fi
else
export MAKE="make"
fi

View file

@ -63,17 +63,18 @@ assert_build_log() {
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
# pyenv/pyenv#1026
stub uname false false
stub uname '-s : echo Linux'
stub brew false
stub_make_install
stub_make_install
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
install_fixture definitions/needs-yaml
assert_success
unstub uname
unstub make
assert_build_log <<OUT
@ -92,18 +93,19 @@ OUT
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
# pyenv/pyenv#1026
stub uname false false
stub uname '-s : echo Linux'
stub brew false
stub_make_install
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<""
assert_success
unstub uname
unstub make
unstub patch
@ -124,18 +126,19 @@ OUT
cached_tarball "yaml-0.1.6"
cached_tarball "Python-3.6.2"
stub uname '-s : echo Linux'
stub brew false
stub_make_install
stub_make_install
stub patch ' : echo patch "$@" | sed -E "s/\.[[:alnum:]]+$/.XXX/" >> build.log'
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
# pyenv/pyenv#1026
stub uname false false
TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<"diff --git a/script.py"
assert_success
unstub uname
unstub make
unstub patch
@ -158,16 +161,17 @@ OUT
brew_libdir="$TMP/homebrew-yaml"
mkdir -p "$brew_libdir"
# pyenv/pyenv#1026
stub uname false false
stub uname '-s : echo Linux'
stub brew "--prefix libyaml : echo '$brew_libdir'" false
stub_make_install
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
install_fixture definitions/needs-yaml
assert_success
unstub uname
unstub brew
unstub make
@ -185,13 +189,12 @@ OUT
readline_libdir="$TMP/homebrew-readline"
mkdir -p "$readline_libdir"
# pyenv/pyenv#1026
stub uname false false
stub brew "--prefix readline : echo '$readline_libdir'"
stub_make_install
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
DEF
@ -216,13 +219,12 @@ OUT
mkdir -p "$readline_libdir/include/readline"
touch "$readline_libdir/include/readline/rlconf.h"
# pyenv/pyenv#1026
stub uname false false
stub brew
stub_make_install
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
export PYTHON_CONFIGURE_OPTS="CPPFLAGS=-I$readline_libdir/include LDFLAGS=-L$readline_libdir/lib"
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
@ -250,8 +252,7 @@ OUT
# yyuu/pyenv#257
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin' false
stub sysctl false
stub_make_install
@ -282,8 +283,7 @@ OUT
# yyuu/pyenv#257
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin' false
stub sysctl '-n hw.ncpu : echo 4'
stub_make_install
@ -308,16 +308,13 @@ OUT
@test "number of CPU cores is detected on FreeBSD" {
cached_tarball "Python-3.6.2"
stub uname '-s : echo FreeBSD'
# pyenv/pyenv#1026
stub uname false false
stub uname '-s : echo FreeBSD' false
stub sysctl '-n hw.ncpu : echo 1'
stub_make_install
# yyuu/pyenv#222
stub uname '-s : echo FreeBSD'
# yyuu/pyenv#257
stub uname '-s : echo FreeBSD'
export -n MAKE_OPTS
run_inline_definition <<DEF
install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.tar.gz"
@ -339,11 +336,11 @@ OUT
@test "setting PYTHON_MAKE_INSTALL_OPTS to a multi-word string" {
cached_tarball "Python-3.6.2"
stub_make_install
# pyenv/pyenv#1026
stub uname false false
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
stub_make_install
export PYTHON_MAKE_INSTALL_OPTS="DOGE=\"such wow\""
run_inline_definition <<DEF
@ -351,6 +348,7 @@ install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.
DEF
assert_success
unstub uname
unstub make
assert_build_log <<OUT
@ -364,11 +362,11 @@ OUT
@test "setting MAKE_INSTALL_OPTS to a multi-word string" {
cached_tarball "Python-3.6.2"
stub_make_install
# pyenv/pyenv#1026
stub uname false false
# yyuu/pyenv#257
stub uname '-s : echo Linux'
stub uname '-s : echo Linux'
stub_make_install
export MAKE_INSTALL_OPTS="DOGE=\"such wow\""
run_inline_definition <<DEF
@ -376,6 +374,7 @@ install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.
DEF
assert_success
unstub uname
unstub make
assert_build_log <<OUT
@ -398,15 +397,13 @@ OUT
@test "make on FreeBSD 9 defaults to gmake" {
cached_tarball "Python-3.6.2"
stub uname "-s : echo FreeBSD" "-r : echo 9.1"
stub uname "-s : echo FreeBSD" "-r : echo 9.1" false
# pyenv/pyenv#1026
stub uname false false
MAKE=gmake stub_make_install
# yyuu/pyenv#222
stub uname '-s : echo FreeBSD'
# yyuu/pyenv#257
stub uname '-s : echo FreeBSD'
MAKE= install_fixture definitions/vanilla-python
assert_success
@ -417,14 +414,28 @@ OUT
@test "make on FreeBSD 10" {
cached_tarball "Python-3.6.2"
stub uname "-s : echo FreeBSD" "-r : echo 10.0-RELEASE"
stub uname "-s : echo FreeBSD" "-r : echo 10.0-RELEASE" false
# pyenv/pyenv#1026
stub uname false false
stub_make_install
# yyuu/pyenv#222
stub uname '-s : echo FreeBSD'
MAKE= install_fixture definitions/vanilla-python
assert_success
# yyuu/pyenv#257
stub uname '-s : echo FreeBSD'
unstub uname
}
@test "make on FreeBSD 11" {
cached_tarball "Python-3.6.2"
stub uname "-s : echo FreeBSD" "-r : echo 11.0-RELEASE" false
# pyenv/pyenv#1026
stub uname false false
stub_make_install
MAKE= install_fixture definitions/vanilla-python
assert_success
@ -441,6 +452,7 @@ apply -p1 -i /my/patch.diff
exec ./configure "\$@"
CONF
stub uname '-s : echo Linux'
stub apply 'echo apply "$@" >> build.log'
stub_make_install
@ -454,6 +466,7 @@ install_package "Python-3.6.2" "http://python.org/ftp/python/3.6.2/Python-3.6.2.
DEF
assert_success
unstub uname
unstub make
unstub apply

View file

@ -8,16 +8,13 @@ export -n CC
export -n PYTHON_CONFIGURE_OPTS
@test "require_gcc on OS X 10.9" {
# yyuu/pyenv#222
stub uname '-s : echo Darwin'
# pyenv/pyenv#1026
stub uname false '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.9.5'
# yyuu/pyenv#257
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.9.5'
stub gcc '--version : echo 4.2.1'
stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1'
run_inline_definition <<DEF
require_gcc
@ -32,16 +29,13 @@ OUT
}
@test "require_gcc on OS X 10.10" {
# yyuu/pyenv#222
stub uname '-s : echo Darwin'
# pyenv/pyenv#1026
stub uname false '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
# yyuu/pyenv#257
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
stub gcc '--version : echo 4.2.1'
stub gcc '--version : echo 4.2.1' '--version : echo 4.2.1'
run_inline_definition <<DEF
require_gcc
@ -56,7 +50,7 @@ OUT
}
@test "require_gcc silences warnings" {
stub gcc '--version : echo warning >&2; echo 4.2.1'
stub gcc '--version : echo warning >&2; echo 4.2.1' '--version : echo warning >&2; echo 4.2.1'
run_inline_definition <<DEF
require_gcc
@ -69,14 +63,10 @@ DEF
mkdir -p "$INSTALL_ROOT"
cd "$INSTALL_ROOT"
# yyuu/pyenv#222
stub uname '-s : echo Darwin'
# pyenv/pyenv#1026
stub uname false '-s : echo Darwin' false '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
# yyuu/pyenv#257
stub uname '-s : echo Darwin'
stub uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
stub cc 'false'
stub brew 'false'

View file

@ -3,7 +3,7 @@ export TMP="$BATS_TEST_DIRNAME/tmp"
if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
export INSTALL_ROOT="$TMP/install"
PATH=/usr/bin:/usr/sbin:/bin/:/sbin
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
PATH="$BATS_TEST_DIRNAME/../bin:$PATH"
PATH="$TMP/bin:$PATH"
export PATH