Class: Bake::Options
Instance Attribute Summary collapse
-
#analyze ⇒ Object
Returns the value of attribute analyze.
-
#build_config ⇒ Object
Returns the value of attribute build_config.
-
#cc2j_filename ⇒ Object
readonly
String.
-
#clean ⇒ Object
readonly
Boolean.
-
#clobber ⇒ Object
readonly
Boolean.
-
#consoleOutput_fullnames ⇒ Object
readonly
Returns the value of attribute consoleOutput_fullnames.
-
#consoleOutput_visualStudio ⇒ Object
readonly
Returns the value of attribute consoleOutput_visualStudio.
-
#conversion_info ⇒ Object
readonly
Boolean.
-
#debug ⇒ Object
readonly
Boolean.
-
#docu ⇒ Object
readonly
Boolean.
-
#eclipseOrder ⇒ Object
Returns the value of attribute eclipseOrder.
-
#envToolchain ⇒ Object
Returns the value of attribute envToolchain.
-
#exclude_filter ⇒ Object
readonly
String List.
-
#filename ⇒ Object
readonly
String.
-
#include_filter ⇒ Object
readonly
String List.
-
#linkOnly ⇒ Object
readonly
Boolean.
-
#lint ⇒ Object
readonly
Boolean.
-
#lint_max ⇒ Object
readonly
Fixnum.
-
#lint_min ⇒ Object
readonly
Fixnum.
-
#main_dir ⇒ Object
readonly
String.
-
#main_project_name ⇒ Object
readonly
String.
-
#no_autodir ⇒ Object
readonly
Boolean.
-
#nocache ⇒ Object
Returns the value of attribute nocache.
-
#prepro ⇒ Object
readonly
Boolean.
-
#project ⇒ Object
readonly
String.
-
#rebuild ⇒ Object
readonly
Boolean.
-
#roots ⇒ Object
readonly
String List.
-
#show_includes ⇒ Object
readonly
Boolean.
-
#show_includes_and_defines ⇒ Object
readonly
Boolean.
-
#socket ⇒ Object
readonly
Fixnum.
-
#stopOnFirstError ⇒ Object
readonly
Boolean.
-
#threads ⇒ Object
readonly
Fixnum.
-
#vars ⇒ Object
readonly
map.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
- #check_valid_dir(dir) ⇒ Object
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #parse_options ⇒ Object
- #set_build_config(config) ⇒ Object
- #set_build_config_default(config) ⇒ Object
- #set_main_dir(dir) ⇒ Object
- #set_root(dir) ⇒ Object
- #set_set(str) ⇒ Object
- #set_threads(num) ⇒ Object
Methods inherited from Parser
#add_default, #add_option, #parse_internal
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 |
# File 'lib/bake/options/options.rb', line 31 def initialize(argv) super(argv) @conversion_info = false @envToolchain = false @analyze = false @eclipseOrder = false @showConfigs = false @consoleOutput_fullnames = false @consoleOutput_visualStudio = false @prepro = false @stopOnFirstError = false @verbose = 1 @vars = {} @build_config = "" @main_dir = nil @project = nil @filename = nil @cc2j_filename = nil @clean = false @clobber = false @lint = false @docu = false @debug = false @rebuild = false @nocache = false @show_includes = false @show_includes_and_defines = false @linkOnly = false @no_autodir = false @threads = 8 @lint_min = 0 @lint_max = -1 @roots = [] @socket = 0 @include_filter = [] @exclude_filter = [] @def_roots = [] @main_project_name = "" add_default(Proc.new{ |x| set_build_config_default(x) }) add_option(Option.new("-m",true) { |x| set_main_dir(x) }) add_option(Option.new("-b",true) { |x| set_build_config(x) }) add_option(Option.new("-p",true) { |x| @project = x;}) add_option(Option.new("-f",true) { |x| @filename = x.gsub(/[\\]/,'/') }) add_option(Option.new("-c",false) { @clean = true }) add_option(Option.new("-a",true) { |x| Bake.formatter.setColorScheme(x.to_sym) }) add_option(Option.new("-w",true) { |x| set_root(x) }) add_option(Option.new("-r",false) { @stopOnFirstError = true }) add_option(Option.new("--rebuild",false) { @rebuild = true }) add_option(Option.new("--prepro",false) { @prepro = true }) add_option(Option.new("--link_only",false) { @linkOnly = true; }) add_option(Option.new("--no_autodir",false) { @no_autodir = true }) add_option(Option.new("--lint",false) { @lint = true }) add_option(Option.new("--lint_min",true) { |x| @lint_min = String === x ? x.to_i : x }) add_option(Option.new("--lint_max",true) { |x| @lint_max = String === x ? x.to_i : x }) add_option(Option.new("--create",true) { |x| Bake::Create.proj(x) }) add_option(Option.new("--conversion_info",false) { @conversion_info = true }) add_option(Option.new("--docu",false) { @docu = true }) add_option(Option.new("-v0",false) { @verbose = 0 }) add_option(Option.new("-v1",false) { @verbose = 1 }) add_option(Option.new("-v2",false) { @verbose = 2 }) add_option(Option.new("-v3",false) { @verbose = 3 }) add_option(Option.new("--debug",false) { @debug = true }) add_option(Option.new("--set",true) { |x| set_set(x) }) add_option(Option.new("--clobber",false) { @clobber = true; @clean = true }) add_option(Option.new("--ignore_cache",false) { @nocache = true }) add_option(Option.new("--threads",true) { |x| set_threads(x) }) add_option(Option.new("--socket",true) { |x| @socket = String === x ? x.to_i : x }) add_option(Option.new("--toolchain_info",true) { |x| ToolchainInfo.showToolchain(x) }) add_option(Option.new("--toolchain_names",false) { ToolchainInfo.showToolchainList }) add_option(Option.new("--include_filter",true) { |x| @include_filter << x }) add_option(Option.new("--exclude_filter",true) { |x| @exclude_filter << x }) add_option(Option.new("--show_abs_paths",false) { @consoleOutput_fullnames = true }) add_option(Option.new("--visualStudio",false) { @consoleOutput_visualStudio = true }) add_option(Option.new("-h",false) { Bake::Usage.show }) add_option(Option.new("--help",false) { Bake::Usage.show }) add_option(Option.new("--show_include_paths",false) { @show_includes = true }) add_option(Option.new("--show_incs_and_defs",false) { @show_includes_and_defines = true }) add_option(Option.new("--show_license",false) { License.show }) add_option(Option.new("--show_doc",false) { Doc.show }) add_option(Option.new("--doc",false) { Doc.deprecated }) add_option(Option.new("--version",false) { ExitHelper.exit(0) }) add_option(Option.new("--show_configs",false) { @showConfigs = true }) add_option(Option.new("--writeCC2J",true) { |x| @cc2j_filename = x.gsub(/[\\]/,'/') }) end |
Instance Attribute Details
#analyze ⇒ Object
Returns the value of attribute analyze.
21 22 23 |
# File 'lib/bake/options/options.rb', line 21 def analyze @analyze end |
#build_config ⇒ Object
Returns the value of attribute build_config.
21 22 23 |
# File 'lib/bake/options/options.rb', line 21 def build_config @build_config end |
#cc2j_filename ⇒ Object (readonly)
String
22 23 24 |
# File 'lib/bake/options/options.rb', line 22 def cc2j_filename @cc2j_filename end |
#clean ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def clean @clean end |
#clobber ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def clobber @clobber end |
#consoleOutput_fullnames ⇒ Object (readonly)
Returns the value of attribute consoleOutput_fullnames.
28 29 30 |
# File 'lib/bake/options/options.rb', line 28 def consoleOutput_fullnames @consoleOutput_fullnames end |
#consoleOutput_visualStudio ⇒ Object (readonly)
Returns the value of attribute consoleOutput_visualStudio.
28 29 30 |
# File 'lib/bake/options/options.rb', line 28 def consoleOutput_visualStudio @consoleOutput_visualStudio end |
#conversion_info ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def conversion_info @conversion_info end |
#debug ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def debug @debug end |
#docu ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def docu @docu end |
#eclipseOrder ⇒ Object
Returns the value of attribute eclipseOrder.
21 22 23 |
# File 'lib/bake/options/options.rb', line 21 def eclipseOrder @eclipseOrder end |
#envToolchain ⇒ Object
Returns the value of attribute envToolchain.
21 22 23 |
# File 'lib/bake/options/options.rb', line 21 def envToolchain @envToolchain end |
#exclude_filter ⇒ Object (readonly)
String List
23 24 25 |
# File 'lib/bake/options/options.rb', line 23 def exclude_filter @exclude_filter end |
#filename ⇒ Object (readonly)
String
22 23 24 |
# File 'lib/bake/options/options.rb', line 22 def filename @filename end |
#include_filter ⇒ Object (readonly)
String List
23 24 25 |
# File 'lib/bake/options/options.rb', line 23 def include_filter @include_filter end |
#linkOnly ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def linkOnly @linkOnly end |
#lint ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def lint @lint end |
#lint_max ⇒ Object (readonly)
Fixnum
25 26 27 |
# File 'lib/bake/options/options.rb', line 25 def lint_max @lint_max end |
#lint_min ⇒ Object (readonly)
Fixnum
25 26 27 |
# File 'lib/bake/options/options.rb', line 25 def lint_min @lint_min end |
#main_dir ⇒ Object (readonly)
String
22 23 24 |
# File 'lib/bake/options/options.rb', line 22 def main_dir @main_dir end |
#main_project_name ⇒ Object (readonly)
String
22 23 24 |
# File 'lib/bake/options/options.rb', line 22 def main_project_name @main_project_name end |
#no_autodir ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def no_autodir @no_autodir end |
#nocache ⇒ Object
Returns the value of attribute nocache.
21 22 23 |
# File 'lib/bake/options/options.rb', line 21 def nocache @nocache end |
#prepro ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def prepro @prepro end |
#project ⇒ Object (readonly)
String
22 23 24 |
# File 'lib/bake/options/options.rb', line 22 def project @project end |
#rebuild ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def rebuild @rebuild end |
#roots ⇒ Object (readonly)
String List
23 24 25 |
# File 'lib/bake/options/options.rb', line 23 def roots @roots end |
#show_includes ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def show_includes @show_includes end |
#show_includes_and_defines ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def show_includes_and_defines @show_includes_and_defines end |
#socket ⇒ Object (readonly)
Fixnum
25 26 27 |
# File 'lib/bake/options/options.rb', line 25 def socket @socket end |
#stopOnFirstError ⇒ Object (readonly)
Boolean
24 25 26 |
# File 'lib/bake/options/options.rb', line 24 def stopOnFirstError @stopOnFirstError end |
#threads ⇒ Object (readonly)
Fixnum
25 26 27 |
# File 'lib/bake/options/options.rb', line 25 def threads @threads end |
#vars ⇒ Object (readonly)
map
26 27 28 |
# File 'lib/bake/options/options.rb', line 26 def vars @vars end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
27 28 29 |
# File 'lib/bake/options/options.rb', line 27 def verbose @verbose end |
Instance Method Details
#check_valid_dir(dir) ⇒ Object
202 203 204 205 206 207 208 209 210 211 |
# File 'lib/bake/options/options.rb', line 202 def check_valid_dir(dir) if not File.exists?(dir) Bake.formatter.printError("Error: Directory #{dir} does not exist") ExitHelper.exit(1) end if not File.directory?(dir) Bake.formatter.printError("Error: #{dir} is not a directory") ExitHelper.exit(1) end end |
#parse_options ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/bake/options/options.rb', line 125 def () parse_internal(false) set_main_dir(Dir.pwd) if @main_dir.nil? @roots = @def_roots if @roots.length == 0 if @project if @project.split(',').length > 2 Bake.formatter.printError("Error: only one comma allowed for -p") ExitHelper.exit(1) end end if @conversion_info if @rebuild Bake.formatter.printError("Error: --conversion_info and --rebuild not allowed at the same time") ExitHelper.exit(1) end if @clean Bake.formatter.printError("Error: --conversion_info and -c not allowed at the same time") ExitHelper.exit(1) end if @prepro Bake.formatter.printError("Error: --conversion_info and --prepro not allowed at the same time") ExitHelper.exit(1) end if @linkOnly Bake.formatter.printError("Error: --conversion_info and --linkOnly not allowed at the same time") ExitHelper.exit(1) end if @lint Bake.formatter.printError("Error: --conversion_info and --lint not allowed at the same time") ExitHelper.exit(1) end if @docu Bake.formatter.printError("Error: --conversion_info and --docu not allowed at the same time") ExitHelper.exit(1) end if not @project Bake.formatter.printError("Error: --conversion_info must be used with -p") ExitHelper.exit(1) end end if @linkOnly if @rebuild Bake.formatter.printError("Error: --link_only and --rebuild not allowed at the same time") ExitHelper.exit(1) end if @clean Bake.formatter.printError("Error: --link_only and -c not allowed at the same time") ExitHelper.exit(1) end if @prepro Bake.formatter.printError("Error: --link_only and --prepro not allowed at the same time") ExitHelper.exit(1) end end if @prepro if @rebuild Bake.formatter.printError("Error: --prepro and --rebuild not allowed at the same time") ExitHelper.exit(1) end if @clean Bake.formatter.printError("Error: --prepro and -c not allowed at the same time") ExitHelper.exit(1) end end if @lint and @docu Bake.formatter.printError("Error: --lint and --docu not allowed at the same time") ExitHelper.exit(1) end ConfigNames.show if @showConfigs end |
#set_build_config(config) ⇒ Object
220 221 222 223 224 225 226 |
# File 'lib/bake/options/options.rb', line 220 def set_build_config(config) if not @build_config.empty? Bake.formatter.printError("Error: Cannot set build config '#{config}', because build config is already set to '#{@build_config}'") ExitHelper.exit(1) end @build_config = config end |
#set_build_config_default(config) ⇒ Object
213 214 215 216 217 218 |
# File 'lib/bake/options/options.rb', line 213 def set_build_config_default(config) index = config.index('-') return false if (index != nil and index == 0) set_build_config(config) return true end |
#set_main_dir(dir) ⇒ Object
228 229 230 231 232 233 |
# File 'lib/bake/options/options.rb', line 228 def set_main_dir(dir) check_valid_dir(dir) @main_dir = File.(dir.gsub(/[\\]/,'/')) @main_project_name = File::basename(@main_dir) @def_roots = calc_def_roots(@main_dir) end |
#set_root(dir) ⇒ Object
235 236 237 238 239 |
# File 'lib/bake/options/options.rb', line 235 def set_root(dir) check_valid_dir(dir) r = File.(dir.gsub(/[\\]/,'/')) @roots << r if not @roots.include?r end |
#set_set(str) ⇒ Object
249 250 251 252 253 254 255 256 |
# File 'lib/bake/options/options.rb', line 249 def set_set(str) ar = str.split("=") if not str.include?"=" or ar[0].length == 0 Bake.formatter.printError("Error: --set must be followed by key=value") ExitHelper.exit(1) end @vars[ar[0]] = ar[1..-1].join("=") end |
#set_threads(num) ⇒ Object
241 242 243 244 245 246 247 |
# File 'lib/bake/options/options.rb', line 241 def set_threads(num) @threads = String === num ? num.to_i : num if @threads <= 0 Bake.formatter.printError("Error: number of threads must be > 0") ExitHelper.exit(1) end end |