Class: Mkduino::ArduinoLibrary

Inherits:
Object
  • Object
show all
Defined in:
lib/mkduino.rb

Overview

Represents the files needed for a particular arduino library

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ArduinoLibrary

Returns a new instance of ArduinoLibrary.



17
18
19
20
21
# File 'lib/mkduino.rb', line 17

def initialize name
  @library_sources = []
  @name = name
  @library_includes = []
end

Instance Method Details

#add_include_path(file) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/mkduino.rb', line 32

def add_include_path file
  pn = Pathname.new(file)
  puts "!! ******** File #{file} not found ******** " unless pn.exist?
  include_dir = pn.file? ? pn.dirname : file

  @library_includes << include_dir.to_s unless @library_includes.include? include_dir.to_s
end

#add_source_file(file) ⇒ Object



27
28
29
30
31
# File 'lib/mkduino.rb', line 27

def add_source_file(file)
  pn = Pathname.new(file)
  puts "!! ******** File #{file} not found ******** " unless pn.exist?
  @library_sources << file
end

#library_nameObject



44
45
46
# File 'lib/mkduino.rb', line 44

def library_name
  "lib#{self.name}.a"
end

#linker_nameObject



40
41
42
# File 'lib/mkduino.rb', line 40

def linker_name
  self.name
end

#makefile_am_outputObject



48
49
50
51
52
53
54
55
56
# File 'lib/mkduino.rb', line 48

def makefile_am_output
  output = <<LIBRARY_OUTPUT
lib#{self.name}_a_CFLAGS=-Wall -I$(ARDUINO_VARIANTS) $(ARDUINO_COMMON_INCLUDES) $(lib#{self.name}_a_INCLUDES) -Wl,--gc-sections -ffunction-sections -fdata-sections -mmcu=$(MCU) $(F_CPU) $(ARDUINO_VERSION) -D__AVR_LIBC_DEPRECATED_ENABLE__
lib#{self.name}_a_CXXFLAGS=-Wall -I$(ARDUINO_VARIANTS) $(ARDUINO_COMMON_INCLUDES) $(lib#{self.name}_a_INCLUDES) -Wl,--gc-sections -ffunction-sections -fdata-sections -mmcu=$(MCU) $(F_CPU) $(ARDUINO_VERSION) -D__AVR_LIBC_DEPRECATED_ENABLE__
lib#{self.name}_a_SOURCES = #{@library_sources.join("\\\n                    ")}
lib#{self.name}_a_INCLUDES = -I#{@library_includes.join("\\\n                    -I")}
LIBRARY_OUTPUT
  output
end

#nameObject



23
24
25
# File 'lib/mkduino.rb', line 23

def name
  return @name.downcase
end