build: typed: strict
Signed-off-by: botantony <antonsm21@gmail.com>
This commit is contained in:
parent
deb6666f32
commit
89d36e0dd5
@ -1,4 +1,4 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# This script is loaded by formula_installer as a separate instance.
|
# This script is loaded by formula_installer as a separate instance.
|
||||||
@ -23,28 +23,40 @@ require "extend/pathname/write_mkpath_extension"
|
|||||||
class Build
|
class Build
|
||||||
include Utils::Output::Mixin
|
include Utils::Output::Mixin
|
||||||
|
|
||||||
attr_reader :formula, :deps, :reqs, :args
|
sig { returns(Formula) }
|
||||||
|
attr_reader :formula
|
||||||
|
|
||||||
|
sig { returns(T::Array[Dependency]) }
|
||||||
|
attr_reader :deps
|
||||||
|
|
||||||
|
sig { returns(Requirements) }
|
||||||
|
attr_reader :reqs
|
||||||
|
|
||||||
|
sig { returns(Homebrew::Cmd::InstallCmd::Args) }
|
||||||
|
attr_reader :args
|
||||||
|
|
||||||
|
sig { params(formula: Formula, options: Options, args: Homebrew::Cmd::InstallCmd::Args).void }
|
||||||
def initialize(formula, options, args:)
|
def initialize(formula, options, args:)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
@formula.build = BuildOptions.new(options, formula.options)
|
@formula.build = BuildOptions.new(options, formula.options)
|
||||||
@args = args
|
@args = T.let(args, Homebrew::Cmd::InstallCmd::Args)
|
||||||
|
@deps = T.let([], T::Array[Dependency])
|
||||||
|
@reqs = T.let(Requirements.new, Requirements)
|
||||||
|
|
||||||
if args.ignore_dependencies?
|
return if args.ignore_dependencies?
|
||||||
@deps = []
|
|
||||||
@reqs = []
|
@deps = expand_deps
|
||||||
else
|
@reqs = expand_reqs
|
||||||
@deps = expand_deps
|
|
||||||
@reqs = expand_reqs
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(dependent: Formula).returns(BuildOptions) }
|
||||||
def effective_build_options_for(dependent)
|
def effective_build_options_for(dependent)
|
||||||
args = dependent.build.used_options
|
args = dependent.build.used_options
|
||||||
args |= Tab.for_formula(dependent).used_options
|
args |= Tab.for_formula(dependent).used_options
|
||||||
BuildOptions.new(args, dependent.options)
|
BuildOptions.new(args, dependent.options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(Requirements) }
|
||||||
def expand_reqs
|
def expand_reqs
|
||||||
formula.recursive_requirements do |dependent, req|
|
formula.recursive_requirements do |dependent, req|
|
||||||
build = effective_build_options_for(dependent)
|
build = effective_build_options_for(dependent)
|
||||||
@ -54,6 +66,7 @@ class Build
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Array[Dependency]) }
|
||||||
def expand_deps
|
def expand_deps
|
||||||
formula.recursive_dependencies do |dependent, dep|
|
formula.recursive_dependencies do |dependent, dep|
|
||||||
build = effective_build_options_for(dependent)
|
build = effective_build_options_for(dependent)
|
||||||
@ -67,6 +80,7 @@ class Build
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { void }
|
||||||
def install
|
def install
|
||||||
formula_deps = deps.map(&:to_formula)
|
formula_deps = deps.map(&:to_formula)
|
||||||
keg_only_deps = formula_deps.select(&:keg_only?)
|
keg_only_deps = formula_deps.select(&:keg_only?)
|
||||||
@ -79,7 +93,7 @@ class Build
|
|||||||
ENV.activate_extensions!(env: args.env)
|
ENV.activate_extensions!(env: args.env)
|
||||||
|
|
||||||
if superenv?(args.env)
|
if superenv?(args.env)
|
||||||
superenv = T.cast(ENV, Superenv)
|
superenv = ENV
|
||||||
superenv.keg_only_deps = keg_only_deps
|
superenv.keg_only_deps = keg_only_deps
|
||||||
superenv.deps = formula_deps
|
superenv.deps = formula_deps
|
||||||
superenv.run_time_deps = run_time_deps
|
superenv.run_time_deps = run_time_deps
|
||||||
@ -192,7 +206,7 @@ class Build
|
|||||||
tab.write
|
tab.write
|
||||||
|
|
||||||
# Find and link metafiles
|
# Find and link metafiles
|
||||||
formula.prefix.install_metafiles formula.buildpath
|
formula.prefix.install_metafiles T.must(formula.buildpath)
|
||||||
formula.prefix.install_metafiles formula.libexec if formula.libexec.exist?
|
formula.prefix.install_metafiles formula.libexec if formula.libexec.exist?
|
||||||
|
|
||||||
normalize_pod2man_outputs!(formula)
|
normalize_pod2man_outputs!(formula)
|
||||||
@ -202,6 +216,7 @@ class Build
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Array[Symbol]) }
|
||||||
def detect_stdlibs
|
def detect_stdlibs
|
||||||
keg = Keg.new(formula.prefix)
|
keg = Keg.new(formula.prefix)
|
||||||
|
|
||||||
@ -211,21 +226,23 @@ class Build
|
|||||||
keg.detect_cxx_stdlibs(skip_executables: true)
|
keg.detect_cxx_stdlibs(skip_executables: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(formula: Formula).void }
|
||||||
def fixopt(formula)
|
def fixopt(formula)
|
||||||
path = if formula.linked_keg.directory? && formula.linked_keg.symlink?
|
path = if formula.linked_keg.directory? && formula.linked_keg.symlink?
|
||||||
formula.linked_keg.resolved_path
|
formula.linked_keg.resolved_path
|
||||||
elsif formula.prefix.directory?
|
elsif formula.prefix.directory?
|
||||||
formula.prefix
|
formula.prefix
|
||||||
elsif (kids = formula.rack.children).size == 1 && kids.first.directory?
|
elsif (kids = formula.rack.children).size == 1 && T.must(kids.first).directory?
|
||||||
kids.first
|
kids.first
|
||||||
else
|
else
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
Keg.new(path).optlink(verbose: args.verbose?)
|
Keg.new(T.must(path)).optlink(verbose: args.verbose?)
|
||||||
rescue
|
rescue
|
||||||
raise "#{formula.opt_prefix} not present or broken\nPlease reinstall #{formula.full_name}. Sorry :("
|
raise "#{formula.opt_prefix} not present or broken\nPlease reinstall #{formula.full_name}. Sorry :("
|
||||||
end
|
end
|
||||||
|
|
||||||
|
sig { params(formula: Formula).void }
|
||||||
def normalize_pod2man_outputs!(formula)
|
def normalize_pod2man_outputs!(formula)
|
||||||
keg = Keg.new(formula.prefix)
|
keg = Keg.new(formula.prefix)
|
||||||
keg.normalize_pod2man_outputs!
|
keg.normalize_pod2man_outputs!
|
||||||
@ -247,7 +264,7 @@ begin
|
|||||||
|
|
||||||
formula = args.named.to_formulae.first
|
formula = args.named.to_formulae.first
|
||||||
options = Options.create(args.flags_only)
|
options = Options.create(args.flags_only)
|
||||||
build = Build.new(formula, options, args:)
|
build = Build.new(T.must(formula), options, args:)
|
||||||
|
|
||||||
build.install
|
build.install
|
||||||
# Any exception means the build did not complete.
|
# Any exception means the build did not complete.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user