2021-02-02 11:52:13 +00:00
|
|
|
# typed: false
|
2021-01-21 12:34:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-02-25 15:59:17 +00:00
|
|
|
homebrew_bootsnap_enabled = !ENV["HOMEBREW_NO_BOOTSNAP"] && ENV["HOMEBREW_BOOTSNAP"]
|
|
|
|
|
|
|
|
# portable ruby doesn't play nice with bootsnap
|
|
|
|
# Can't use .exclude? here because we haven't required active_support yet.
|
|
|
|
homebrew_bootsnap_enabled &&= !ENV["HOMEBREW_RUBY_PATH"].to_s.include?("/vendor/portable-ruby/") # rubocop:disable Rails/NegateInclude
|
|
|
|
|
|
|
|
homebrew_bootsnap_enabled &&= if ENV["HOMEBREW_MACOS_VERSION"]
|
|
|
|
# Apple Silicon doesn't play nice with bootsnap
|
|
|
|
ENV["HOMEBREW_PROCESSOR"] == "Intel" &&
|
|
|
|
# we need some development tools to build bootsnap native code
|
|
|
|
(File.directory?("/Applications/Xcode.app") || File.directory?("/Library/Developer/CommandLineTools"))
|
2021-02-24 16:49:06 +00:00
|
|
|
else
|
|
|
|
File.executable?("/usr/bin/clang") || File.executable?("/usr/bin/gcc")
|
|
|
|
end
|
|
|
|
|
2021-02-25 15:59:17 +00:00
|
|
|
if homebrew_bootsnap_enabled
|
2021-02-02 11:50:44 +00:00
|
|
|
begin
|
|
|
|
require "bootsnap"
|
|
|
|
rescue LoadError
|
2021-02-05 15:43:55 +00:00
|
|
|
unless ENV["HOMEBREW_BOOTSNAP_RETRY"]
|
2021-02-25 15:59:17 +00:00
|
|
|
Homebrew.install_bundler_gems!(only_warn_on_failure: true)
|
2021-01-21 16:31:35 +00:00
|
|
|
|
2021-02-05 15:43:55 +00:00
|
|
|
ENV["HOMEBREW_BOOTSNAP_RETRY"] = "1"
|
|
|
|
exec ENV["HOMEBREW_BREW_FILE"], *ARGV
|
|
|
|
end
|
2021-01-21 16:31:35 +00:00
|
|
|
end
|
|
|
|
|
2021-02-02 11:50:44 +00:00
|
|
|
ENV.delete("HOMEBREW_BOOTSNAP_RETRY")
|
2021-01-21 12:34:04 +00:00
|
|
|
|
2021-02-05 15:43:55 +00:00
|
|
|
if defined?(Bootsnap)
|
|
|
|
cache = ENV["HOMEBREW_CACHE"] || ENV["HOMEBREW_DEFAULT_CACHE"]
|
|
|
|
# Can't use .blank? here because we haven't required active_support yet.
|
|
|
|
raise "Needs HOMEBREW_CACHE or HOMEBREW_DEFAULT_CACHE!" if cache.nil? || cache.empty? # rubocop:disable Rails/Blank
|
|
|
|
|
|
|
|
Bootsnap.setup(
|
|
|
|
cache_dir: cache,
|
|
|
|
load_path_cache: true,
|
|
|
|
compile_cache_iseq: true,
|
|
|
|
compile_cache_yaml: true,
|
|
|
|
)
|
|
|
|
else
|
|
|
|
$stderr.puts "Error: HOMEBREW_BOOTSNAP could not `require \"bootsnap\"`!\n\n"
|
|
|
|
end
|
2021-02-02 11:50:44 +00:00
|
|
|
end
|