Class: Makefile
- Inherits:
-
Object
- Object
- Makefile
- Defined in:
- lib/rad/generators/makefile/makefile.rb
Class Method Summary collapse
-
.board_configuration(arduino_root, board_name, path_mod) ⇒ Object
match the mcu with the proper board configuration from the arduino board.txt file.
-
.compose_for_sketch(build_dir) ⇒ Object
build the sketch Makefile for the given template based on the values in its software and hardware config files.
- .hardware_params ⇒ Object
- .serial_port ⇒ Object
- .software_params ⇒ Object
Class Method Details
.board_configuration(arduino_root, board_name, path_mod) ⇒ Object
match the mcu with the proper board configuration from the arduino board.txt file
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rad/generators/makefile/makefile.rb', line 59 def board_configuration(arduino_root, board_name, path_mod) board_configuration = {} board_type = {} puts "#################################### checking boards.txt at: #{arduino_root}/hardware#{path_mod}/boards.txt for: #{board_name}" File.open("#{arduino_root}/hardware#{path_mod}/boards.txt", "r") do |infile| infile.each_line do |line| next unless line.chomp =~ /^#{board_name}\.([^=]*)=(.*)$/ # next unless line.chomp =~ /^(#{board_name})\.name/ board_configuration[$1] = $2 # board_configuration = $1 end end board_type['build.board_designation'] = board_name if board_configuration.empty? raise "#################################### no board configuration found for : #{board_name} check your hardware configuration -- type rake arduino:boards" else puts "#################################### board_configuration (per boards.txt): #{board_configuration.inspect}" end board_configuration = board_configuration.merge board_type board_configuration end |
.compose_for_sketch(build_dir) ⇒ Object
build the sketch Makefile for the given template based on the values in its software and hardware config files
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rad/generators/makefile/makefile.rb', line 8 def compose_for_sketch(build_dir) params = hardware_params.merge software_params params['serial_port'] = serial_port if params['serial_port'] == "/dev/tty.usbserial*" if @software_params['experimental'] == true @experimental_mode = true puts "#################################### running in experimental mode" if @software_params['arduino_root'] == "/Applications/arduino-0015" @software_params['arduino_root'] = "/Applications/Arduino.app/Contents/Resources/Java" end board_config = board_configuration(@software_params['arduino_root'], @hardware_params['mcu'], "/arduino") else board_config = board_configuration(@software_params['arduino_root'], @hardware_params['mcu'], "") end params = params.merge board_config params['target'] = build_dir.split("/").last params['libraries_root'] = "#{File.(RAD_ROOT)}/vendor/libraries" params['libraries'] = $load_libraries # load only libraries used # needed along with ugly hack of including another copy of twi.h in wire, when using the Wire.h library params['twi_c'] = $load_libraries.include?("Wire") ? "#{params['arduino_root']}/hardware/libraries/Wire/utility/twi.c" : "" params['asm_files'] = Dir.entries( File.(RAD_ROOT) + "/" + PROJECT_DIR_NAME ).select{|e| e =~ /\.S/} e = ERB.new File.read("#{File.dirname(__FILE__)}/#{"better_" if @experimental_mode == true}makefile.erb") File.open("#{build_dir}/Makefile", "w") do |f| f << e.result(binding) end end |
.hardware_params ⇒ Object
39 40 41 42 |
# File 'lib/rad/generators/makefile/makefile.rb', line 39 def hardware_params return @hardware_params if @hardware_params return @hardware_params = YAML.load_file( "#{RAD_ROOT}/config/hardware.yml") end |
.serial_port ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/rad/generators/makefile/makefile.rb', line 49 def serial_port usb = Dir.glob("/dev/tty.usbserial*") if usb.empty? usb = Dir.glob("/dev/tty.usbmodem*") #uno shows up as usbmodem on OS X... end puts "#################################### serial port: #{usb}" usb end |
.software_params ⇒ Object
44 45 46 47 |
# File 'lib/rad/generators/makefile/makefile.rb', line 44 def software_params return @software_params if @software_params return @software_params = YAML.load_file( "#{RAD_ROOT}/config/software.yml" ) end |