Core and libraries compile

This commit is contained in:
Matthias Neeracher 2014-11-30 23:37:17 +01:00 committed by Matthias Neeracher
parent cd62c35719
commit e17f440333

View File

@ -50,7 +50,6 @@ def buildHeaderMap
end
end
end
p HEADERMAP
end
def parseInoFiles
@ -116,21 +115,21 @@ buildHeaderMap
parseInoFiles
File.open("#{$BUILD_DIR}/Rakefile", 'w') do |rakeFile|
SOURCES = FileList.new(ARGV).select {|f| f =~ /\.(c|cpp|cp|cxx|S)$/}
SOURCES = Rake::FileList.new(ARGV).select {|f| f =~ /\.(c|cpp|cp|cxx|S)$/}
INCLUDES= ($CORES+$LIBRARIES).map {|l| " +\n \" -I'#{l}'\""}.join('')
rakeFile.print <<END_RAKE
CC = '/usr/local/CrossPack-AVR/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=#{BUILD['mcu']} -DF_CPU=#{BUILD['f_cpu']} -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=105 -I ../..'#{INCLUDES}
AR = '/usr/local/CrossPack-AVR/bin/avr-ar crsv'
LIBRARIES = [#{$LIBRARIES.map{|l| "'"+l+"'"}.join(' ')}]
def compile(dest, *src)
def compile(dest, extrainc, *src)
directory dest
archive = dest.ext('.a')
sources = Rake::FileList.new(src)
objects = sources.pathmap(dest+"/%n.o")
objects.each_index do |i|
file objects[i] => sources[i] do
sh "%s '%s' -o '%s'" % [CC, sources[i], objects[i]]
file objects[i] => [sources[i],dest] do
sh "%s %s '%s' -o '%s'" % [CC, extrainc ? "-I '"+extrainc+"'" : '', sources[i], objects[i]]
end
end
file archive => objects do
@ -138,8 +137,28 @@ def compile(dest, *src)
end
end
compile('sketch', #{SOURCES.map{|f| "'../../"+f+"'"}.join(', ')})
def compile_library(lib)
extrainc = nil
utility = lib+"/utility"
if File::exists?(utility)
extrainc = utility
end
compile(lib.pathmap('lib/%f'), extrainc, *Rake::FileList[lib+"/*.{c,cpp,cp,cxx,S}", lib+"/utility/*.{c,cpp,cp,cxx,S}"])
end
def compile_core(core,variant)
list = Rake::FileList[core+"/*.{c,cpp,cp,cxx,S}"]
list.add(variant+"/*.{c,cpp,cp,cxx,S}") if variant
compile('core', nil, list)
end
compile('sketch', nil, #{SOURCES.map{|f| "'../../"+f+"'"}.join(', ')})
compile_core(#{$CORES.map {|c| "'"+c+"'"}.join(", ")})
END_RAKE
$LIBRARIES.each do |lib|
rakeFile.puts "compile_library('#{lib}')"
end
end