Skip to content

Commit

Permalink
Update to mini_portile2 v2.8.4
Browse files Browse the repository at this point in the history
This pulls in flavorjones/mini_portile#130.
We no longer need to write custom logic for finding the right
compilers and setting CMake variables for cross-compilation.
  • Loading branch information
stanhu authored and mudge committed Jul 25, 2023
1 parent d950a29 commit 371cdd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 56 deletions.
56 changes: 1 addition & 55 deletions ext/re2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))

REQUIRED_MINI_PORTILE_VERSION = "~> 2.8.3" # keep this version in sync with the one in the gemspec
REQUIRED_MINI_PORTILE_VERSION = "~> 2.8.4" # keep this version in sync with the one in the gemspec

RE2_HELP_MESSAGE = <<~HELP
USAGE: ruby #{$0} [options]
Expand Down Expand Up @@ -82,59 +82,6 @@ def target_host
host.gsub(/i386/, "i686")
end

def find_compiler(compilers)
compilers.find { |binary| find_executable(binary) }
end

# configure automatically searches for the right compiler based on the
# `--host` parameter. However, we don't have that feature with
# cmake. Search for the right compiler for the target architecture using
# some basic heruistics.
# See https://github.com/flavorjones/mini_portile/issues/128.
def find_c_and_cxx_compilers(host)
c_compiler = ENV["CC"]
cxx_compiler = ENV["CXX"]

if darwin?
c_compiler ||= 'clang'
cxx_compiler ||='clang++'
else
c_compiler ||= 'gcc'
cxx_compiler ||= 'g++'
end

c_platform_compiler = "#{host}-#{c_compiler}"
cxx_platform_compiler = "#{host}-#{cxx_compiler}"
c_compiler = find_compiler([c_platform_compiler, c_compiler])
cxx_compiler = find_compiler([cxx_platform_compiler, cxx_compiler])

[c_compiler, cxx_compiler]
end

def cmake_system_name
if darwin?
'Darwin'
elsif windows?
'Windows'
elsif freebsd?
'FreeBSD'
else
'Linux'
end
end

def cmake_compile_flags(host)
c_compiler, cxx_compiler = find_c_and_cxx_compilers(host)

# needed to ensure cross-compilation with CMake targets the right CPU and compilers
[
"-DCMAKE_SYSTEM_PROCESSOR=#{RbConfig::CONFIG['target_cpu']}",
"-DCMAKE_SYSTEM_NAME=#{cmake_system_name}",
"-DCMAKE_C_COMPILER=#{c_compiler}",
"-DCMAKE_CXX_COMPILER=#{cxx_compiler}"
]
end

#
# main
#
Expand Down Expand Up @@ -260,7 +207,6 @@ def process_recipe(name, version)
# ensures pkg-config and installed libraries will be in lib, not lib64
'-DCMAKE_INSTALL_LIBDIR=lib'
]
recipe.configure_options += cmake_compile_flags(recipe.host)

yield recipe

Expand Down
2 changes: 1 addition & 1 deletion re2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Gem::Specification.new do |s|
s.add_development_dependency "rake-compiler", "~> 1.2.1"
s.add_development_dependency "rake-compiler-dock", "~> 1.3.0"
s.add_development_dependency("rspec", "~> 3.2")
s.add_runtime_dependency("mini_portile2", "~> 2.8.3") # keep version in sync with extconf.rb
s.add_runtime_dependency("mini_portile2", "~> 2.8.4") # keep version in sync with extconf.rb
end

0 comments on commit 371cdd9

Please sign in to comment.