diff --git a/AVRsack/BuildProject b/AVRsack/BuildProject index 830361e..3932eaf 100755 --- a/AVRsack/BuildProject +++ b/AVRsack/BuildProject @@ -50,7 +50,6 @@ def buildHeaderMap end end end - p HEADERMAP end def parseInoFiles @@ -116,30 +115,50 @@ 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 < 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 sh ("%s '%s' " % [AR, archive])+objects.map {|o| "'"+o+"'"}.join(" ") end end - -compile('sketch', #{SOURCES.map{|f| "'../../"+f+"'"}.join(', ')}) -END_RAKE - + +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