Class: CPPCompiler
- Inherits:
-
Object
- Object
- CPPCompiler
- Defined in:
- lib/fwi/compilers/cpp/compiler.rb
Constant Summary collapse
Instance Method Summary collapse
- #after_parse ⇒ Object
- #compile(file, lex, bitmap, options) ⇒ Object
- #on_selected ⇒ Object
- #populate_options(o) ⇒ Object
Instance Method Details
#after_parse ⇒ Object
22 |
# File 'lib/fwi/compilers/cpp/compiler.rb', line 22 def after_parse; end |
#compile(file, lex, bitmap, options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fwi/compilers/cpp/compiler.rb', line 25 def compile file, lex, bitmap, base = File.basename(file, File.extname(file)) hpp_ext = @options[:hpp_ext] cpp_ext = @options[:cpp_ext] compile_cpp = !@options[:hpp_only] hpp = GEN.gen_hpp bitmap, hpp_ext, @options[:hpp_only] hpp.each do |fn, contents| f = File.join(@options[:hpp], fn) FileUtils.mkdir_p File.("..", f) File.write(f, contents) end if compile_cpp cpp = GEN.gen_cpp bitmap, cpp_ext, hpp_ext cpp.each do |fn, contents| f = File.join(@options[:cpp], fn) FileUtils.mkdir_p File.("..", f) File.write(f, contents) end end end |
#on_selected ⇒ Object
23 |
# File 'lib/fwi/compilers/cpp/compiler.rb', line 23 def on_selected; end |
#populate_options(o) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fwi/compilers/cpp/compiler.rb', line 7 def o @options = { :hpp => ".", :cpp => ".", :hpp_ext => ".hpp", :cpp_ext => ".cpp", :hpp_only => false }; o.on("--headers [DIRECTORY]", "Directory to put Generated C++ Header Files.") { |x| @options[:hpp] = x } o.on("--sources [DIRECTORY]", "Directory to put Generated C++ Source Files.") { |x| @options[:cpp] = x } o.separator "" o.on("--header_ext [EXTENSION]", "Extension for Generated C++ Header Files. Default .hpp") { |x| @options[:hpp_ext] = x } o.on("--source_ext [EXTENSION]", "Extension for Generated C++ Source Files. Default .cpp") { |x| @options[:cpp_ext] = x } o.separator "" o.on("--header-only", "Compile as header-only") { |x| @options[:hpp_only] = true } end |