Skip to content

Commit

Permalink
support libyaml from homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
dreyks committed Feb 8, 2022
1 parent cbdbc6e commit 5c8146b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 9 additions & 7 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ build_package_standard_build() {

if [ "$package_var_name" = "RUBY" ]; then
use_homebrew_readline || use_freebsd_pkg ||true
use_homebrew_yaml || true
fi

( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then
Expand Down Expand Up @@ -1022,17 +1023,18 @@ locate_llvm() {
}

needs_yaml() {
[[ "$RUBY_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]] &&
! use_homebrew_yaml
}

use_homebrew_yaml() {
local libdir="$(brew --prefix libyaml 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "ruby-build: using libyaml from homebrew"
package_option ruby configure --with-libyaml-dir="$libdir"
else
return 1
if [[ "$RUBY_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]]; then
local libdir="$(brew --prefix libyaml 2>/dev/null || true)"
if [ -d "$libdir" ]; then
echo "ruby-build: using libyaml from homebrew"
package_option ruby configure --with-libyaml-dir="$libdir"
else
return 1
fi
fi
}

Expand Down
10 changes: 6 additions & 4 deletions test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ OUT
mkdir -p "$brew_libdir"

stub uname '-s : echo Linux'
stub brew "--prefix libyaml : echo '$brew_libdir'" false
stub brew false "--prefix libyaml : echo '$brew_libdir'"
stub_make_install

install_fixture definitions/needs-yaml
run_inline_definition <<DEF
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
DEF
assert_success

unstub uname
Expand All @@ -209,7 +211,7 @@ OUT
readline_libdir="$TMP/homebrew-readline"
mkdir -p "$readline_libdir"

stub brew "--prefix readline : echo '$readline_libdir'"
stub brew "--prefix readline : echo '$readline_libdir'" false
stub_make_install

run_inline_definition <<DEF
Expand All @@ -230,7 +232,7 @@ OUT
@test "readline is not linked from Homebrew when explicitly defined" {
cached_tarball "ruby-2.0.0"

stub brew
stub brew false
stub_make_install

export RUBY_CONFIGURE_OPTS='--with-readline-dir=/custom'
Expand Down

0 comments on commit 5c8146b

Please sign in to comment.