Merge pull request #10374 from MikeMcQuaid/bootsnap

Add HOMEBREW_BOOTSNAP to optionally use Bootsnap
This commit is contained in:
Mike McQuaid 2021-01-21 15:31:39 +00:00 committed by GitHub
commit 7857993e07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 4 deletions

2
.gitignore vendored
View File

@ -85,6 +85,7 @@
# Ignore dependencies we don't wish to vendor
**/vendor/bundle/ruby/*/gems/ast-*/
**/vendor/bundle/ruby/*/gems/bootsnap-*/
**/vendor/bundle/ruby/*/gems/bundler-*/
**/vendor/bundle/ruby/*/gems/byebug-*/
**/vendor/bundle/ruby/*/gems/coderay-*/
@ -105,6 +106,7 @@
**/vendor/bundle/ruby/*/gems/mime-types-*/
**/vendor/bundle/ruby/*/gems/mini_portile2-*/
**/vendor/bundle/ruby/*/gems/minitest-*/
**/vendor/bundle/ruby/*/gems/msgpack-*/
**/vendor/bundle/ruby/*/gems/mustache-*/
**/vendor/bundle/ruby/*/gems/net-http-digest_auth-*/
**/vendor/bundle/ruby/*/gems/net-http-persistent-*/

View File

@ -370,6 +370,7 @@ Sorbet/FalseSigil:
- "/**/{Formula,Casks}/*.rb"
- "**/{Formula,Casks}/*.rb"
- "Homebrew/test/**/Casks/**/*.rb"
- "Homebrew/bootsnap.rb"
Sorbet/StrictSigil:
Enabled: true

View File

@ -3,6 +3,7 @@
source "https://rubygems.org"
# installed gems (should all be require: false)
gem "bootsnap", require: false if ENV["HOMEBREW_BOOTSNAP"]
gem "byebug", require: false
gem "codecov", require: false
gem "nokogiri", require: false

View File

@ -0,0 +1,20 @@
# typed: ignore
# frozen_string_literal: true
# TODO: make this `typed: true` when HOMEBREW_BOOTSNAP is enabled by
# default and/or we vendor bootsnap and the RBI file.
raise "Needs HOMEBREW_BOOTSNAP!" unless ENV["HOMEBREW_BOOTSNAP"]
require "rubygems"
require "bootsnap"
Bootsnap.setup(
cache_dir: "#{ENV["HOMEBREW_TEMP"]}/homebrew-bootsnap",
development_mode: false, # TODO: use ENV["HOMEBREW_DEVELOPER"]?,
load_path_cache: true,
autoload_paths_cache: true,
disable_trace: true,
compile_cache_iseq: true,
compile_cache_yaml: true,
)

View File

@ -1,6 +1,8 @@
# typed: false
# frozen_string_literal: true
require_relative "load_path"
require "English"
require "json"
require "json/add/exception"
@ -14,8 +16,6 @@ require "rbconfig"
RUBY_PATH = Pathname.new(RbConfig.ruby).freeze
RUBY_BIN = RUBY_PATH.dirname.freeze
require_relative "load_path"
require "rubygems"
# Only require "core_ext" here to ensure we're only requiring the minimum of
# what we need.

View File

@ -9,5 +9,9 @@ $LOAD_PATH.push HOMEBREW_LIBRARY_PATH.to_s
require "vendor/bundle/bundler/setup"
if ENV["HOMEBREW_BOOTSNAP"]
require "bootsnap"
else
$LOAD_PATH.select! { |d| Pathname(d).directory? }
$LOAD_PATH.uniq!
end