include OnSystem
to define DSL methods
This commit is contained in:
parent
ac067eedb2
commit
a9e62b9e38
@ -92,6 +92,7 @@ module Cask
|
|||||||
]).freeze
|
]).freeze
|
||||||
|
|
||||||
extend Predicable
|
extend Predicable
|
||||||
|
include OnSystem
|
||||||
|
|
||||||
attr_reader :cask, :token
|
attr_reader :cask, :token
|
||||||
|
|
||||||
@ -319,8 +320,6 @@ module Cask
|
|||||||
@livecheckable == true
|
@livecheckable == true
|
||||||
end
|
end
|
||||||
|
|
||||||
OnSystem.setup_methods! onto: self, include_linux: false
|
|
||||||
|
|
||||||
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
||||||
define_method(klass.dsl_key) do |*args|
|
define_method(klass.dsl_key) do |*args|
|
||||||
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
|
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
|
||||||
|
@ -55,10 +55,10 @@ module OnSystem
|
|||||||
method_name.to_s.sub(/^on_/, "").to_sym
|
method_name.to_s.sub(/^on_/, "").to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(onto: Class, include_linux: T::Boolean).void }
|
sig { params(base: Class).void }
|
||||||
def setup_methods!(onto:, include_linux: true)
|
def self.included(base)
|
||||||
ARCH_OPTIONS.each do |arch|
|
ARCH_OPTIONS.each do |arch|
|
||||||
onto.define_method("on_#{arch}") do |&block|
|
base.define_method("on_#{arch}") do |&block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = true
|
||||||
|
|
||||||
return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(__method__)
|
return unless OnSystem.arch_condition_met? OnSystem.condition_from_method_name(__method__)
|
||||||
@ -71,24 +71,22 @@ module OnSystem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if include_linux
|
BASE_OS_OPTIONS.each do |base_os|
|
||||||
BASE_OS_OPTIONS.each do |base_os|
|
base.define_method("on_#{base_os}") do |&block|
|
||||||
onto.define_method("on_#{base_os}") do |&block|
|
@on_system_blocks_exist = true
|
||||||
@on_system_blocks_exist = true
|
|
||||||
|
|
||||||
return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(__method__)
|
return unless OnSystem.os_condition_met? OnSystem.condition_from_method_name(__method__)
|
||||||
|
|
||||||
@called_in_on_system_block = true
|
@called_in_on_system_block = true
|
||||||
result = block.call
|
result = block.call
|
||||||
@called_in_on_system_block = false
|
@called_in_on_system_block = false
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
MacOSVersions::SYMBOLS.each_key do |os_name|
|
MacOSVersions::SYMBOLS.each_key do |os_name|
|
||||||
onto.define_method("on_#{os_name}") do |or_condition = nil, &block|
|
base.define_method("on_#{os_name}") do |or_condition = nil, &block|
|
||||||
@on_system_blocks_exist = true
|
@on_system_blocks_exist = true
|
||||||
|
|
||||||
os_condition = OnSystem.condition_from_method_name __method__
|
os_condition = OnSystem.condition_from_method_name __method__
|
||||||
|
@ -64,12 +64,11 @@ class Formula
|
|||||||
include Utils::Shebang
|
include Utils::Shebang
|
||||||
include Utils::Shell
|
include Utils::Shell
|
||||||
include Context
|
include Context
|
||||||
|
include OnSystem
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
extend Cachable
|
extend Cachable
|
||||||
extend Predicable
|
extend Predicable
|
||||||
|
|
||||||
OnSystem.setup_methods! onto: self
|
|
||||||
|
|
||||||
# @!method inreplace(paths, before = nil, after = nil)
|
# @!method inreplace(paths, before = nil, after = nil)
|
||||||
# @see Utils::Inreplace.inreplace
|
# @see Utils::Inreplace.inreplace
|
||||||
|
|
||||||
@ -2471,6 +2470,7 @@ class Formula
|
|||||||
# The methods below define the formula DSL.
|
# The methods below define the formula DSL.
|
||||||
class << self
|
class << self
|
||||||
include BuildEnvironment::DSL
|
include BuildEnvironment::DSL
|
||||||
|
include OnSystem
|
||||||
|
|
||||||
def method_added(method)
|
def method_added(method)
|
||||||
super
|
super
|
||||||
@ -2483,8 +2483,6 @@ class Formula
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
OnSystem.setup_methods! onto: self
|
|
||||||
|
|
||||||
# The reason for why this software is not linked (by default) to
|
# The reason for why this software is not linked (by default) to
|
||||||
# {::HOMEBREW_PREFIX}.
|
# {::HOMEBREW_PREFIX}.
|
||||||
# @private
|
# @private
|
||||||
|
@ -17,8 +17,7 @@ class Resource
|
|||||||
|
|
||||||
include Context
|
include Context
|
||||||
include FileUtils
|
include FileUtils
|
||||||
|
include OnSystem
|
||||||
OnSystem.setup_methods! onto: self
|
|
||||||
|
|
||||||
attr_reader :mirrors, :specs, :using, :source_modified_time, :patches, :owner
|
attr_reader :mirrors, :specs, :using, :source_modified_time, :patches, :owner
|
||||||
attr_writer :version
|
attr_writer :version
|
||||||
|
@ -18,14 +18,13 @@ class SoftwareSpec
|
|||||||
extend T::Sig
|
extend T::Sig
|
||||||
|
|
||||||
extend Forwardable
|
extend Forwardable
|
||||||
|
include OnSystem
|
||||||
|
|
||||||
PREDEFINED_OPTIONS = {
|
PREDEFINED_OPTIONS = {
|
||||||
universal: Option.new("universal", "Build a universal binary"),
|
universal: Option.new("universal", "Build a universal binary"),
|
||||||
cxx11: Option.new("c++11", "Build using C++11 mode"),
|
cxx11: Option.new("c++11", "Build using C++11 mode"),
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
OnSystem.setup_methods! onto: self
|
|
||||||
|
|
||||||
attr_reader :name, :full_name, :owner, :build, :resources, :patches, :options, :deprecated_flags,
|
attr_reader :name, :full_name, :owner, :build, :resources, :patches, :options, :deprecated_flags,
|
||||||
:deprecated_options, :dependency_collector, :bottle_specification, :compiler_failures,
|
:deprecated_options, :dependency_collector, :bottle_specification, :compiler_failures,
|
||||||
:uses_from_macos_elements
|
:uses_from_macos_elements
|
||||||
@ -584,7 +583,7 @@ class BottleSpecification
|
|||||||
end
|
end
|
||||||
|
|
||||||
class PourBottleCheck
|
class PourBottleCheck
|
||||||
OnSystem.setup_methods! onto: self
|
include OnSystem
|
||||||
|
|
||||||
def initialize(formula)
|
def initialize(formula)
|
||||||
@formula = formula
|
@formula = formula
|
||||||
|
Loading…
x
Reference in New Issue
Block a user