class Vanagon::Component::Rules
Vanagon::Component::Rules
creates all Makefile
rules for a given component.
Attributes
Public Class Methods
@param component [Vanagon::Component] The component to create rules for. @param project [Vanagon::Project] The project associated with the component. @param platform [Vanagon::Platform] The platform where this component will be built.
# File lib/vanagon/component/rules.rb, line 38 def initialize(component, project, platform) @component = component @project = project @platform = platform end
Create methods that generate Makefile
rules.
This method cuts out some of the boilerplate of creating Makefile
rules by creating methods and Makefile
objects with a common name.
@param target [Symbol] The rule target name. @param dependencies [Array<String>] An optional list of dependencies for the rule @yieldparam rule [Makefile::Rule] The generated Makefile
rule @return [void]
@!macro [attach] rule
@return [Makefile::Rule] The $1 rule
# File lib/vanagon/component/rules.rb, line 23 def self.rule(target, &block) define_method("#{target}_rule") do Makefile::Rule.new("#{component.name}-#{target}") do |rule| instance_exec(rule, &block) end end end
Public Instance Methods
Generate a top level rule to build this component.
@return [Makefile::Rule]
# File lib/vanagon/component/rules.rb, line 81 def component_rule Makefile::Rule.new(component.name) do |rule| rule.dependencies = ["#{component.name}-install"] end end
Generate a Makefile
fragment that contains all of the rules for the component. @return [String]
# File lib/vanagon/component/rules.rb, line 227 def format rules.map(&:to_s).join("\n") end
Generate all Makefile
rules for this component.
If the project has the cleanup attribute set, a cleanup rule will be included in the returned rules.
@return [Array<Makefile::Rule>]
# File lib/vanagon/component/rules.rb, line 50 def rules # rubocop:disable Metrics/AbcSize list_of_rules = [ component_rule, unpack_rule, patch_rule, configure_rule, build_rule, check_rule, install_rule, clean_rule, clobber_rule, ] if component.install_only list_of_rules = [ component_rule, install_rule, clean_rule, clobber_rule, ] end if project.cleanup list_of_rules << cleanup_rule end list_of_rules end