Chain build and upload
This commit is contained in:
parent
f8d5e6d9a4
commit
9ca39e0cb9
|
@ -11,6 +11,24 @@ import Foundation
|
|||
class ASBuilder {
|
||||
var dir = NSURL()
|
||||
var task : NSTask?
|
||||
var continuation: (()->())?
|
||||
var termination : AnyObject?
|
||||
|
||||
init() {
|
||||
termination = NSNotificationCenter.defaultCenter().addObserverForName(NSTaskDidTerminateNotification,
|
||||
object: nil, queue: nil, usingBlock:
|
||||
{ (notification: NSNotification!) in
|
||||
if notification.object as? NSTask == self.task && self.task!.terminationStatus == 0 {
|
||||
if let cont = self.continuation {
|
||||
self.continuation = nil
|
||||
cont()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
func finalize() {
|
||||
NSNotificationCenter.defaultCenter().removeObserver(termination!)
|
||||
}
|
||||
|
||||
func setProjectURL(url: NSURL) {
|
||||
dir = url.URLByDeletingLastPathComponent!.standardizedURL!
|
||||
|
@ -92,8 +110,12 @@ class ASBuilder {
|
|||
let speed = boardProp["upload.speed"] ?? progProp?["speed"]
|
||||
var args = ["-v", "-v", "-v", "-v", "-D",
|
||||
"-C", "/usr/local/CrossPack-AVR/etc/avrdude.conf",
|
||||
"-p", boardProp["build.mcu"], "-c", proto!, "-P", port, "-b", speed!,
|
||||
"-p", boardProp["build.mcu"]!, "-c", proto!, "-P", port,
|
||||
"-U", "flash:w:build/"+board+"/"+dir.lastPathComponent+".hex:i"]
|
||||
if speed != nil {
|
||||
args.append("-b")
|
||||
args.append(speed!)
|
||||
}
|
||||
task!.arguments = args;
|
||||
task!.launch()
|
||||
}
|
||||
|
|
|
@ -8,28 +8,13 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
class ASPropertyEntry {
|
||||
private var storage = [String: String]()
|
||||
subscript(key: String) -> String {
|
||||
get {
|
||||
if let value = storage[key] {
|
||||
return value
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
set (newValue) {
|
||||
storage[key] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typealias ASPropertyEntry = [String: String]
|
||||
typealias ASProperties = [String: ASPropertyEntry]
|
||||
|
||||
extension NSMenu {
|
||||
func addSortedChoices(choices:[ASPropertyEntry], target: AnyObject, selector: Selector) {
|
||||
for choice in choices.sorted({ $0["name"] < $1["name"] }) {
|
||||
let item = self.addItemWithTitle(choice["name"], action: selector, keyEquivalent: "")
|
||||
let item = self.addItemWithTitle(choice["name"]!, action: selector, keyEquivalent: "")
|
||||
item?.target = target
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +112,7 @@ class ASHardware {
|
|||
menu.addItem(NSMenuItem.separatorItem())
|
||||
var seen = [String: Bool]()
|
||||
for prop in choices.values {
|
||||
seen[prop["provenience"]] = true
|
||||
seen[prop["provenience"]!] = true
|
||||
}
|
||||
var sortedKeys = [String](seen.keys)
|
||||
sortedKeys.sort { $0 < $1 }
|
||||
|
|
|
@ -447,9 +447,12 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
|||
return NSSet(objects: "port", "board", "programmer")
|
||||
}
|
||||
|
||||
@IBAction func uploadProject(AnyObject) {
|
||||
selectNode(files.uploadLog)
|
||||
builder.uploadProject(board, programmer:programmer, port:port)
|
||||
@IBAction func uploadProject(sender: AnyObject) {
|
||||
builder.continuation = {
|
||||
self.selectNode(self.files.uploadLog)
|
||||
self.builder.uploadProject(self.board, programmer:self.programmer, port:self.port)
|
||||
}
|
||||
buildProject(sender)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user