Class: Makeconf
- Inherits:
-
Object
- Object
- Makeconf
- Defined in:
- lib/makeconf.rb
Overview
Copyright © 2009-2011 Mark Heily <[email protected]>
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Defined Under Namespace
Constant Summary collapse
- Makeconf_Version =
0.1
- @@installer =
Installer.new
- @@makefile =
Makefile.new
- @@original_argv =
OptionParser seems to clobber this..
ARGV.clone
- @@logger =
Logger.new(STDOUT)
Class Method Summary collapse
Instance Method Summary collapse
-
#configure(project = nil) ⇒ Object
Examine the operating environment and set configuration options.
-
#initialize(options) ⇒ Makeconf
constructor
A new instance of Makeconf.
-
#log_level=(level) ⇒ Object
Adjust the log level to increase debugging output.
-
#minimum_version=(version) ⇒ Object
Check if the current version is equal to or greater than the minimum required version.
-
#project(id = 'default') ⇒ Object
TODO: support multiple projects.
- #project=(obj) ⇒ Object
Constructor Details
#initialize(options) ⇒ Makeconf
Returns a new instance of Makeconf.
147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/makeconf.rb', line 147 def initialize() raise ArgumentError unless .kind_of?(Hash) .each do |k,v| case k when :minimum_version, :log_level send(k.to_s + '=',v) else raise ArgumentError, "Unknown argument #{k}" end end @project = Project.new :id => 'default' end |
Class Method Details
.logger ⇒ Object
60 61 62 |
# File 'lib/makeconf.rb', line 60 def Makeconf.logger @@logger end |
.original_argv ⇒ Object
56 57 58 |
# File 'lib/makeconf.rb', line 56 def Makeconf.original_argv @@original_argv.clone end |
.parse_options(args = ARGV) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/makeconf.rb', line 64 def Makeconf.(args = ARGV) = true x = OptionParser.new do |opts| opts. = 'Usage: configure [options]' @@installer.(opts) @@project.(opts) # Cross-compilation options opts.separator '' opts.separator 'System types:' opts.on('--build BUILD', 'set the system type for building') do |arg| @@build = arg end opts.on('--host HOST', 'cross-compile programs to run on a different system type') do |arg| @@host = arg end opts.on('--target TARGET', 'build a compiler for cross-compiling') do |arg| @@target = arg end opts.separator '' opts.separator 'Common options:' opts.on_tail('--disable-option-checking') {} # NOOP opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end opts.on_tail('-V', '--version', 'Display version information and exit') do puts "Makeconf $Id: makeconf.rb 301 2012-11-17 16:47:04Z mheily $" exit end end # Special case: This must be processed prior to all other options if args.include? '--disable-option-checking' = false end # Parse all options, and gracefully resume when an invalid option # is provided. # loop do begin x.parse!(args) rescue OptionParser::InvalidOption => e if warn '*** ERROR *** ' + e.to_s exit 1 else warn 'WARNING: ' + e.to_s next end end break end end |
Instance Method Details
#configure(project = nil) ⇒ Object
Examine the operating environment and set configuration options
133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/makeconf.rb', line 133 def configure(project = nil) @project = project unless project.nil? @@logger.info 'Configuring the project' # FIXME: once the GUI is finished, it should just be # if Platform.is_graphical? if ENV['MAKECONF_GUI'] == 'yes' and Platform.is_graphical? ui = Makeconf::GUI.new(@project) ui.main_loop else Makeconf.configure_project(@project) end end |
#log_level=(level) ⇒ Object
Adjust the log level to increase debugging output
128 129 130 |
# File 'lib/makeconf.rb', line 128 def log_level=(level) @@logger.level = level end |
#minimum_version=(version) ⇒ Object
Check if the current version is equal to or greater than the minimum required version
162 163 164 165 166 |
# File 'lib/makeconf.rb', line 162 def minimum_version=(version) if version > 0.1 throw "This version of Makeconf is too old. Please upgrade to version #{version} or newer" end end |
#project(id = 'default') ⇒ Object
TODO: support multiple projects
169 170 171 |
# File 'lib/makeconf.rb', line 169 def project(id = 'default') @project end |
#project=(obj) ⇒ Object
173 174 175 176 |
# File 'lib/makeconf.rb', line 173 def project=(obj) #raise ArgumentError unless options.kind_of?(Project) @project = obj end |