class LAAG::BuildEnvironment
Constants
- DEFAULT_FEATURES
Public Class Methods
new(library, **options)
click to toggle source
# File lib/laag/build_environment.rb, line 10 def initialize(library, **options) @library = library @options = options @enabled = Set.new @disabled = Set.new %i[enable disable].each { |s| [*options[s]].each { |f| send s, f } } self end
Public Instance Methods
autogen!()
click to toggle source
# File lib/laag/build_environment.rb, line 38 def autogen! return unless enabled?(:autogen) and file?('autogen.sh') execute! './autogen.sh' end
autoreconf!()
click to toggle source
# File lib/laag/build_environment.rb, line 33 def autoreconf! return unless enabled?(:autoreconf) and file?('configure.ac') execute! 'autoreconf', '--install' end
configure!(*arguments)
click to toggle source
# File lib/laag/build_environment.rb, line 43 def configure!(*arguments) return unless enabled?(:configure) autogen! unless file?('configure') autoreconf! unless file?('configure') return unless file?('configure') execute! './configure', configure_options(arguments) end
configure_options(arguments)
click to toggle source
# File lib/laag/build_environment.rb, line 56 def configure_options(arguments) [ ("--prefix=#{@library.install_path}" unless disabled?(:prefix)), ('--disable-dependency-tracking' unless enabled?('dependency-tracking')), ('--enable-shared' unless disabled?(:shared)), ('--enable-static' unless disabled?(:static)), ('--with-pic' unless disabled?(:pic)), *arguments ].flatten.compact.uniq end
default!(configure: [])
click to toggle source
# File lib/laag/build_environment.rb, line 67 def default!(configure: []) make!(:clean) unless disabled?('pre-clean') configure!(*configure) unless disabled?(:configure) make! unless disabled?(:build) make! :install unless disabled?(:install) make! :clean unless disabled?('post-clean') end
disable(feature)
click to toggle source
# File lib/laag/build_environment.rb, line 134 def disable(feature) feature.tap { @disabled << feature.to_s } end
disabled()
click to toggle source
# File lib/laag/build_environment.rb, line 102 def disabled @disabled - @enabled end
disabled?(feature)
click to toggle source
# File lib/laag/build_environment.rb, line 118 def disabled?(feature) disabled.include? feature.to_s end
enable(feature)
click to toggle source
Flag State Manipulation #
# File lib/laag/build_environment.rb, line 126 def enable(feature) feature.tap { @enabled << feature.to_s } end
enabled()
click to toggle source
# File lib/laag/build_environment.rb, line 106 def enabled features - disabled end
enabled?(feature)
click to toggle source
Flag State Queries #
# File lib/laag/build_environment.rb, line 114 def enabled?(feature) enabled.include? feature.to_s end
execute!(command, *arguments)
click to toggle source
# File lib/laag/build_environment.rb, line 23 def execute!(command, *arguments) STDOUT.puts ' -- ' + (commandline = [command, *arguments].flatten.map(&:to_s).join(' ')) Dir.chdir(@library.source_path) do system(commandline).tap do |success| raise "Error: '#{commandline}' failed" unless success end end end
features()
click to toggle source
Feature Flags #
# File lib/laag/build_environment.rb, line 98 def features DEFAULT_FEATURES end
file?(filename)
click to toggle source
Detection #
# File lib/laag/build_environment.rb, line 79 def file?(filename) return unless filename File.exist? File.join(@library.source_path, filename.split('/')) end
make!(*arguments, make: ENV['MAKE'] || ENV['make'] || 'make')
click to toggle source
# File lib/laag/build_environment.rb, line 51 def make!(*arguments, make: ENV['MAKE'] || ENV['make'] || 'make') return unless file?(makefile) execute! make, "-j#{make_jobs}", arguments end
make_jobs()
click to toggle source
# File lib/laag/build_environment.rb, line 88 def make_jobs @options.fetch(:make_jobs) do Etc.respond_to?(:nprocessors) ? Etc.nprocessors : '' end end
makefile()
click to toggle source
# File lib/laag/build_environment.rb, line 84 def makefile RbConfig::CONFIG['MAKEFILES'].split.find { |makefile| file? makefile } || 'Makefile' end
script(&block)
click to toggle source
# File lib/laag/build_environment.rb, line 19 def script(&block) instance_eval(&block) if block_given? end
undisable(feature)
click to toggle source
# File lib/laag/build_environment.rb, line 138 def undisable(feature) feature.tap { @disabled.delete feature.to_s } end
unenable(feature)
click to toggle source
# File lib/laag/build_environment.rb, line 130 def unenable(feature) feature.tap { @enabled.delete feature.to_s } end