require 'mkmf' require 'fileutils' IS_DARWIN = RUBY_PLATFORM =~ /darwin/ have_library('pthread') have_library('objc') if IS_DARWIN $CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall" $CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g" $CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic" $CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN $CPPFLAGS += " -std=c++0x" $CPPFLAGS += " -fpermissive" $CPPFLAGS += " -fno-omit-frame-pointer" $CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN MAC_OS_VERSION = begin if IS_DARWIN # note, RUBY_PLATFORM is hardcoded on compile, it can not be trusted # sw_vers can be trusted so use it `sw_vers -productVersion`.to_f rescue 0.0 else 0.0 end end $LDFLAGS.insert 0, MAC_OS_VERSION < 10.14 ? " -stdlib=libstdc++ " : " -stdlib=libc++ " if IS_DARWIN if ENV['CXX'] puts "SETTING CXX" CONFIG['CXX'] = ENV['CXX'] end CXX11_TEST = < true "LD_LIBRARY_PATH='#{File.expand_path('gemdir')}:#{ENV['LD_LIBRARY_PATH']}" end def libv8_gem_name is_musl = false begin is_musl = !!(File.read('/proc/self/maps') =~ /ld-musl-x86_64/) rescue; end is_musl ? 'libv8-alpine' : 'libv8' end LIBV8_VERSION = '6.7.288.46.1' libv8_rb = Dir.glob('**/libv8.rb').first FileUtils.mkdir_p('gemdir') unless libv8_rb gem_name = libv8_gem_name puts "Will try downloading #{gem_name} gem, version #{LIBV8_VERSION}" `#{fixup_libtinfo} gem install --version '= #{LIBV8_VERSION}' --install-dir gemdir #{gem_name}` unless $?.success? warn <