Skip to content

Commit

Permalink
Search Homebrew's prefix on Apple Silicon
Browse files Browse the repository at this point in the history
GitHub: #50

To make installation easier for users of Homebrew on Apple Silicon, add
/opt/homebrew to the default paths searched when trying to find the
underlying re2 library.  While doing so, add an extra fallback to /usr
(instead of only searching /usr/local).

Note we still search /usr/local first to avoid accidentally changing
behaviour for existing users (e.g. suddenly compiling against a
different version of re2 in /usr).
  • Loading branch information
mudge committed Mar 12, 2021
1 parent cfaffc0 commit 56ca0f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ Ruby header files installed such as those provided by the [ruby-dev][] package
on Debian and Ubuntu.

You can then install the library via RubyGems with `gem install re2` or `gem
install re2 -- --with-re2-dir=/opt/local/re2` if re2 is not installed in the
default location of `/usr/local/`.
install re2 -- --with-re2-dir=/path/to/re2/prefix` if re2 is not installed in
any of the following default locations:

* `/usr/local`
* `/opt/homebrew`
* `/usr`

Documentation
-------------
Expand Down
14 changes: 13 additions & 1 deletion ext/re2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
RbConfig::CONFIG["CXX"] = ENV["CXX"]
end

incl, lib = dir_config("re2", "/usr/local/include", "/usr/local/lib")
HEADER_DIRS = [
"/usr/local/include",
"/opt/homebrew/include",
"/usr/include"
].freeze

LIB_DIRS = [
"/usr/local/lib",
"/opt/homebrew/lib",
"/usr/lib"
].freeze

dir_config("re2", HEADER_DIRS, LIB_DIRS)

$CFLAGS << " -Wall -Wextra -funroll-loops"

Expand Down

0 comments on commit 56ca0f6

Please sign in to comment.