Class: Lunchbox::Tasks::Environment

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/lunchbox/tasks.rb

Constant Summary collapse

C_DIR =
File.expand_path File.join(File.dirname(__FILE__), 'native')
C_SRC =
File.join C_DIR, 'src'
C_INC =
File.join C_DIR, 'include'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEnvironment

Returns a new instance of Environment.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lunchbox/tasks.rb', line 17

def initialize
  @cpu      = nil
  @cc       = 'msp430-gcc'
  @cxx      = 'msp430-g++'
  @objdump  = 'msp430-objdump'
  @size     = 'msp430-size'
  @mspdebug = 'mspdebug'
  @src      = Rake::FileList.new
  @defines  = []

  define_tasks
end

Instance Attribute Details

#ccObject

Returns the value of attribute cc.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def cc
  @cc
end

#cpuObject

Returns the value of attribute cpu.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def cpu
  @cpu
end

#cxxObject

Returns the value of attribute cxx.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def cxx
  @cxx
end

#mspdebugObject

Returns the value of attribute mspdebug.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def mspdebug
  @mspdebug
end

#objdumpObject

Returns the value of attribute objdump.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def objdump
  @objdump
end

#sizeObject

Returns the value of attribute size.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def size
  @size
end

#srcObject

Returns the value of attribute src.



11
12
13
# File 'lib/lunchbox/tasks.rb', line 11

def src
  @src
end

Instance Method Details

#add_lib(f) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/lunchbox/tasks.rb', line 40

def add_lib f
  f = File.join(C_SRC, "#{f}.c")
  src << f

  file f

  t = Rake.application['build/main.elf']
  t.prerequisites.concat obj
  t.prerequisites.uniq!
end

#add_src(f) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/lunchbox/tasks.rb', line 30

def add_src f
  src << f

  file f

  t = Rake.application['build/main.elf']
  t.prerequisites.concat obj
  t.prerequisites.uniq!
end

#cflagsObject



67
68
69
70
71
# File 'lib/lunchbox/tasks.rb', line 67

def cflags
  incs = includes.map { |i| "-I#{i}" }.join ' '
  defines = @defines.map { |i| "-D#{i}" }.join ' '
  [incs, defines, "-Os -Wall -g -mmcu=#{E.cpu}"].join ' '
end

#hardware_uart!Object



51
52
53
# File 'lib/lunchbox/tasks.rb', line 51

def hardware_uart!
  @defines << "HW_UART"
end

#have_crystal!Object



55
56
57
# File 'lib/lunchbox/tasks.rb', line 55

def have_crystal!
  @defines << "HAVE_CRYSTAL"
end

#includesObject



63
64
65
# File 'lib/lunchbox/tasks.rb', line 63

def includes
  [ '.', C_INC ]
end

#objObject



59
60
61
# File 'lib/lunchbox/tasks.rb', line 59

def obj
  src.ext('o').pathmap("build/%f")
end