diff --git a/AVRsack/ASBuilder.swift b/AVRsack/ASBuilder.swift index e114ce2..1881210 100644 --- a/AVRsack/ASBuilder.swift +++ b/AVRsack/ASBuilder.swift @@ -45,6 +45,7 @@ class ASBuilder { NSLog("Unable to find core %s\n", boardProp["build.core"]) return } + args.append("project="+dir.lastPathComponent) args.append("board="+board) args.append("mcu="+boardProp["build.mcu"]) args.append("f_cpu="+boardProp["build.f_cpu"]) diff --git a/AVRsack/BuildProject b/AVRsack/BuildProject index 3932eaf..2138818 100755 --- a/AVRsack/BuildProject +++ b/AVRsack/BuildProject @@ -52,11 +52,13 @@ def buildHeaderMap end end +LIBRARIES = Rake::FileList[] +CORES = Rake::FileList[] + def parseInoFiles - $LIBRARIES = [] - $CORES = [BUILD['core_path']] + CORES.add(BUILD['core_path']) if BUILD['variant_path'] - $CORES << BUILD['variant_path'] + CORES.add(BUILD['variant_path']) end ARGV.each_index do |arg| if ARGV[arg] =~ /\.ino$/ @@ -93,6 +95,7 @@ def parseInoFiles outFile.print rest end outFile.close + FileUtils.touch outName, :mtime => File.mtime(ARGV[arg]) ARGV[arg] = outName end end @@ -104,8 +107,8 @@ end def addLibrary(header) lib = HEADERMAP[header] - if lib && !$LIBRARIES.include?(lib) - $LIBRARIES << lib + if lib && !LIBRARIES.include?(lib) + LIBRARIES.add(lib) end end @@ -116,11 +119,13 @@ parseInoFiles File.open("#{$BUILD_DIR}/Rakefile", 'w') do |rakeFile| SOURCES = Rake::FileList.new(ARGV).select {|f| f =~ /\.(c|cpp|cp|cxx|S)$/} - INCLUDES= ($CORES+$LIBRARIES).map {|l| " +\n \" -I'#{l}'\""}.join('') + INCLUDES= (CORES+LIBRARIES).map {|l| " +\n \" -I'#{l}'\""}.join('') rakeFile.print < %w[sketch.a #{LIBRARIES.pathmap("lib/%f.a").join(" ")} core.a] do |task| + sh ("%s -o %s -Wl,'-(' " % [LD, task.name])+task.prerequisites.map {|a| "'"+a+"'"}.join(" ")+" -Wl,'-)' -lm" +end +file '#{BUILD['project']}.eep' => '#{BUILD['project']}.elf' do |task| + sh "%s '%s' '%s'" % [EEP, task.prerequisites[0], task.name] +end +file '#{BUILD['project']}.hex' => '#{BUILD['project']}.elf' do |task| + sh "%s '%s' '%s'" % [HEX, task.prerequisites[0], task.name] +end +task :default => ['#{BUILD['project']}.eep', '#{BUILD['project']}.hex'] + END_RAKE - $LIBRARIES.each do |lib| - rakeFile.puts "compile_library('#{lib}')" - end - end