Improve style

This commit is contained in:
Lukas Oberhuber 2022-07-30 11:10:26 +01:00
parent e46a61e181
commit cd9fe97c55
10 changed files with 29 additions and 95 deletions

View File

@ -78,13 +78,8 @@ class Build
ENV.keg_only_deps = keg_only_deps
ENV.deps = formula_deps
ENV.run_time_deps = run_time_deps
ENV.setup_build_environment(
formula: formula,
cc: args.cc,
build_bottle: args.build_bottle?,
bottle_arch: args.bottle_arch,
debug_symbols: args.debug_symbols?,
)
ENV.setup_build_environment(formula: formula, cc: args.cc, build_bottle: args.build_bottle?,
bottle_arch: args.bottle_arch, debug_symbols: args.debug_symbols?)
reqs.each do |req|
req.modify_build_environment(
env: args.env, cc: args.cc, build_bottle: args.build_bottle?, bottle_arch: args.bottle_arch,
@ -92,13 +87,8 @@ class Build
end
deps.each(&:modify_build_environment)
else
ENV.setup_build_environment(
formula: formula,
cc: args.cc,
build_bottle: args.build_bottle?,
bottle_arch: args.bottle_arch,
debug_symbols: args.debug_symbols?,
)
ENV.setup_build_environment(formula: formula, cc: args.cc, build_bottle: args.build_bottle?,
bottle_arch: args.bottle_arch, debug_symbols: args.debug_symbols?)
reqs.each do |req|
req.modify_build_environment(
env: args.env, cc: args.cc, build_bottle: args.build_bottle?, bottle_arch: args.bottle_arch,

View File

@ -41,22 +41,13 @@ module EnvActivation
_block: T.proc.returns(T.untyped),
).returns(T.untyped)
}
def with_build_environment(
env: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
debug_symbols: false,
&_block
)
def with_build_environment(env: nil, cc: nil, build_bottle: false, bottle_arch: nil, debug_symbols: false, &_block)
old_env = to_hash.dup
tmp_env = to_hash.dup.extend(EnvActivation)
T.cast(tmp_env, EnvActivation).activate_extensions!(env: env)
T.cast(tmp_env, T.any(Superenv, Stdenv))
.setup_build_environment(
cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
debug_symbols: debug_symbols
)
.setup_build_environment(cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
debug_symbols: debug_symbols)
replace(tmp_env)
begin

View File

@ -43,14 +43,8 @@ module SharedEnvExtension
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(
formula: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
testing_formula: false,
debug_symbols: false
)
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
@formula = formula
@cc = cc
@build_bottle = build_bottle

View File

@ -24,14 +24,8 @@ module Stdenv
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(
formula: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
testing_formula: false,
debug_symbols: false
)
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
super
self["HOMEBREW_ENV"] = "std"

View File

@ -58,14 +58,8 @@ module Superenv
debug_symbols: T.nilable(T::Boolean),
).void
}
def setup_build_environment(
formula: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
testing_formula: false,
debug_symbols: false
)
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
super
send(compiler)

View File

@ -2,19 +2,10 @@
# frozen_string_literal: true
module Stdenv
def setup_build_environment(
formula: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
testing_formula: false,
debug_symbols: false
)
generic_setup_build_environment(
formula: formula, cc: cc, build_bottle: build_bottle,
bottle_arch: bottle_arch, testing_formula: testing_formula,
debug_symbols: debug_symbols
)
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
generic_setup_build_environment(formula: formula, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
testing_formula: testing_formula, debug_symbols: debug_symbols)
prepend_path "CPATH", HOMEBREW_PREFIX/"include"
prepend_path "LIBRARY_PATH", HOMEBREW_PREFIX/"lib"

View File

@ -15,19 +15,10 @@ module Superenv
end
# @private
def setup_build_environment(
formula: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
testing_formula: false,
debug_symbols: false
)
generic_setup_build_environment(
formula: formula, cc: cc, build_bottle: build_bottle,
bottle_arch: bottle_arch, testing_formula: testing_formula,
debug_symbols: debug_symbols
)
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
generic_setup_build_environment(formula: formula, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
testing_formula: testing_formula, debug_symbols: debug_symbols)
self["HOMEBREW_OPTIMIZATION_LEVEL"] = "O2"
self["HOMEBREW_DYNAMIC_LINKER"] = determine_dynamic_linker_path
self["HOMEBREW_RPATH_PATHS"] = determine_rpath_paths(@formula)

View File

@ -13,9 +13,8 @@ module SharedEnvExtension
debug_symbols: false
)
generic_shared_setup_build_environment(
formula: formula, cc: cc, build_bottle: build_bottle,
bottle_arch: bottle_arch, testing_formula: testing_formula,
debug_symbols: debug_symbols
formula: formula, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
testing_formula: testing_formula, debug_symbols: debug_symbols
)
# Normalise the system Perl version used, where multiple may be available

View File

@ -18,11 +18,8 @@ module Stdenv
testing_formula: false,
debug_symbols: false
)
generic_setup_build_environment(
formula: formula, cc: cc, build_bottle: build_bottle,
bottle_arch: bottle_arch, testing_formula: testing_formula,
debug_symbols: debug_symbols
)
generic_setup_build_environment(formula: formula, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
testing_formula: testing_formula, debug_symbols: debug_symbols)
append "LDFLAGS", "-Wl,-headerpad_max_install_names"

View File

@ -85,14 +85,8 @@ module Superenv
end
# @private
def setup_build_environment(
formula: nil,
cc: nil,
build_bottle: false,
bottle_arch: nil,
testing_formula: false,
debug_symbols: false
)
def setup_build_environment(formula: nil, cc: nil, build_bottle: false, bottle_arch: nil, testing_formula: false,
debug_symbols: false)
sdk = formula ? MacOS.sdk_for_formula(formula) : MacOS.sdk
is_xcode_sdk = sdk&.source == :xcode
@ -108,9 +102,8 @@ module Superenv
end
generic_setup_build_environment(
formula: formula, cc: cc, build_bottle: build_bottle,
bottle_arch: bottle_arch, testing_formula: testing_formula,
debug_symbols: debug_symbols
formula: formula, cc: cc, build_bottle: build_bottle, bottle_arch: bottle_arch,
testing_formula: testing_formula, debug_symbols: debug_symbols
)
# Filter out symbols known not to be defined since GNU Autotools can't