mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Refactor exec.rb type fixes
This commit is contained in:
parent
5fed8f4210
commit
004c0a2a6c
@ -39,12 +39,12 @@ class PATH
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(block: T.proc.params(arg0: String).returns(T::Boolean)).returns(T.self_type) }
|
sig { params(block: T.proc.params(arg0: String).returns(BasicObject)).returns(T.self_type) }
|
||||||
def select(&block)
|
def select(&block)
|
||||||
self.class.new(@paths.select(&block))
|
self.class.new(@paths.select(&block))
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(block: T.proc.params(arg0: String).returns(T::Boolean)).returns(T.self_type) }
|
sig { params(block: T.proc.params(arg0: String).returns(BasicObject)).returns(T.self_type) }
|
||||||
def reject(&block)
|
def reject(&block)
|
||||||
self.class.new(@paths.reject(&block))
|
self.class.new(@paths.reject(&block))
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,6 @@ module Homebrew
|
|||||||
# Store the old environment so we can check if things were already set
|
# Store the old environment so we can check if things were already set
|
||||||
# before we start mutating it.
|
# before we start mutating it.
|
||||||
old_env = ENV.to_h
|
old_env = ENV.to_h
|
||||||
new_env = T.cast(ENV, Superenv)
|
|
||||||
|
|
||||||
# Setup Homebrew's ENV extensions
|
# Setup Homebrew's ENV extensions
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!
|
||||||
@ -46,7 +45,7 @@ module Homebrew
|
|||||||
require "formula"
|
require "formula"
|
||||||
require "formulary"
|
require "formulary"
|
||||||
|
|
||||||
new_env.deps = @dsl.entries.filter_map do |entry|
|
ENV.deps = @dsl.entries.filter_map do |entry|
|
||||||
next if entry.type != :brew
|
next if entry.type != :brew
|
||||||
|
|
||||||
Formulary.factory(entry.name)
|
Formulary.factory(entry.name)
|
||||||
@ -54,20 +53,20 @@ module Homebrew
|
|||||||
|
|
||||||
# Allow setting all dependencies to be keg-only
|
# Allow setting all dependencies to be keg-only
|
||||||
# (i.e. should be explicitly in HOMEBREW_*PATHs ahead of HOMEBREW_PREFIX)
|
# (i.e. should be explicitly in HOMEBREW_*PATHs ahead of HOMEBREW_PREFIX)
|
||||||
new_env.keg_only_deps = if ENV["HOMEBREW_BUNDLE_EXEC_ALL_KEG_ONLY_DEPS"].present?
|
ENV.keg_only_deps = if ENV["HOMEBREW_BUNDLE_EXEC_ALL_KEG_ONLY_DEPS"].present?
|
||||||
ENV.delete("HOMEBREW_BUNDLE_EXEC_ALL_KEG_ONLY_DEPS")
|
ENV.delete("HOMEBREW_BUNDLE_EXEC_ALL_KEG_ONLY_DEPS")
|
||||||
new_env.deps
|
ENV.deps
|
||||||
else
|
else
|
||||||
new_env.deps.select(&:keg_only?)
|
ENV.deps.select(&:keg_only?)
|
||||||
end
|
end
|
||||||
new_env.setup_build_environment
|
ENV.setup_build_environment
|
||||||
|
|
||||||
# Enable compiler flag filtering
|
# Enable compiler flag filtering
|
||||||
ENV.refurbish_args
|
ENV.refurbish_args
|
||||||
|
|
||||||
# Set up `nodenv`, `pyenv` and `rbenv` if present.
|
# Set up `nodenv`, `pyenv` and `rbenv` if present.
|
||||||
env_formulae = %w[nodenv pyenv rbenv]
|
env_formulae = %w[nodenv pyenv rbenv]
|
||||||
new_env.deps.each do |dep|
|
ENV.deps.each do |dep|
|
||||||
dep_name = dep.name
|
dep_name = dep.name
|
||||||
next unless env_formulae.include?(dep_name)
|
next unless env_formulae.include?(dep_name)
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Replace the formula versions from the environment variables
|
# Replace the formula versions from the environment variables
|
||||||
new_env.deps.each do |formula|
|
ENV.deps.each do |formula|
|
||||||
formula_name = formula.name
|
formula_name = formula.name
|
||||||
formula_version = Bundle.formula_versions_from_env(formula_name)
|
formula_version = Bundle.formula_versions_from_env(formula_name)
|
||||||
next unless formula_version
|
next unless formula_version
|
||||||
@ -101,12 +100,7 @@ module Homebrew
|
|||||||
rejected_opts = []
|
rejected_opts = []
|
||||||
path = PATH.new(ENV.fetch("PATH"))
|
path = PATH.new(ENV.fetch("PATH"))
|
||||||
.reject do |path_value|
|
.reject do |path_value|
|
||||||
if path_value.match?(opt)
|
rejected_opts << path_value if path_value.match?(opt)
|
||||||
rejected_opts << path_value
|
|
||||||
true
|
|
||||||
else
|
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
rejected_opts.each do |path_value|
|
rejected_opts.each do |path_value|
|
||||||
path.prepend(path_value.gsub(opt, cellar))
|
path.prepend(path_value.gsub(opt, cellar))
|
||||||
@ -217,7 +211,7 @@ module Homebrew
|
|||||||
entry: Homebrew::Bundle::Dsl::Entry,
|
entry: Homebrew::Bundle::Dsl::Entry,
|
||||||
info: T::Hash[String, T.untyped],
|
info: T::Hash[String, T.untyped],
|
||||||
service_file: Pathname,
|
service_file: Pathname,
|
||||||
conflicting_services: T::Array[T::Hash[String, T.untyped]],
|
conflicting_services: T::Array[T::Hash[String, T.anything]],
|
||||||
).void,
|
).void,
|
||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ module Homebrew
|
|||||||
sig { override.void }
|
sig { override.void }
|
||||||
def run
|
def run
|
||||||
ENV.activate_extensions!
|
ENV.activate_extensions!
|
||||||
T.cast(ENV, Superenv).deps = args.named.to_formulae if superenv?(nil)
|
ENV.deps = args.named.to_formulae if superenv?(nil)
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
|
|
||||||
shell = if args.plain?
|
shell = if args.plain?
|
||||||
|
@ -29,7 +29,9 @@ module Homebrew
|
|||||||
ENV.activate_extensions!(env: args.env)
|
ENV.activate_extensions!(env: args.env)
|
||||||
|
|
||||||
if superenv?(args.env)
|
if superenv?(args.env)
|
||||||
T.cast(ENV, Superenv).deps = Formula.installed.select { |f| f.keg_only? && f.opt_prefix.directory? }
|
ENV.deps = Formula.installed.select do |f|
|
||||||
|
f.keg_only? && f.opt_prefix.directory?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
if superenv?(args.env)
|
if superenv?(args.env)
|
||||||
|
@ -10,6 +10,10 @@ class Sorbet
|
|||||||
module Static
|
module Static
|
||||||
class ENVClass
|
class ENVClass
|
||||||
include EnvActivation
|
include EnvActivation
|
||||||
|
# NOTE: This is a bit misleading, as at most only one of these can be true
|
||||||
|
# See: EnvActivation#activate_extensions!
|
||||||
|
include Stdenv
|
||||||
|
include Superenv
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user