Use preferences in build

This commit is contained in:
Matthias Neeracher 2014-12-15 02:49:33 +01:00 committed by Matthias Neeracher
parent f26cddf8aa
commit 9512a3a910
5 changed files with 27 additions and 15 deletions

View File

@ -12,6 +12,7 @@ import Cocoa
class ASApplication: NSObject, NSApplicationDelegate {
@IBOutlet weak var themeMenu : NSMenu!
@IBOutlet weak var keyboardMenu : NSMenu!
@IBOutlet weak var preferences : ASPreferences!
func applicationWillFinishLaunching(notification: NSNotification) {
//

View File

@ -48,6 +48,7 @@ class ASBuilder {
}
func buildProject(board: String, files: ASFileTree) {
let toolChain = (NSApplication.sharedApplication().delegate as ASApplication).preferences.toolchainPath
task = NSTask()
task!.currentDirectoryPath = dir.path!
task!.launchPath = NSBundle.mainBundle().pathForResource("BuildProject", ofType: "")!
@ -78,6 +79,7 @@ class ASBuilder {
NSLog("Unable to find core %s\n", boardProp["build.core"]!)
return
}
args.append("toolchain="+toolChain)
args.append("project="+dir.lastPathComponent)
args.append("board="+board)
args.append("mcu="+boardProp["build.mcu"]!)
@ -96,9 +98,10 @@ class ASBuilder {
}
func uploadProject(board: String, programmer: String, port: String) {
let toolChain = (NSApplication.sharedApplication().delegate as ASApplication).preferences.toolchainPath
task = NSTask()
task!.currentDirectoryPath = dir.path!
task!.launchPath = "/usr/local/CrossPack-AVR/bin/avrdude"
task!.launchPath = toolChain+"/bin/avrdude"
let fileManager = NSFileManager.defaultManager()
let logURL = dir.URLByAppendingPathComponent("build/upload.log")
@ -112,8 +115,10 @@ class ASBuilder {
let progProp = ASHardware.instance().programmers[programmer]
let proto = boardProp["upload.protocol"] ?? progProp?["protocol"]
let speed = boardProp["upload.speed"] ?? progProp?["speed"]
var args = ["-v", "-v", "-v",
"-C", "/usr/local/CrossPack-AVR/etc/avrdude.conf",
let verbosity = NSUserDefaults.standardUserDefaults().integerForKey("UploadVerbosity")
var args = Array<String>(count: verbosity, repeatedValue: "-v")
args += [
"-C", toolChain+"/etc/avrdude.conf",
"-p", boardProp["build.mcu"]!, "-c", proto!, "-P", port,
"-U", "flash:w:build/"+board+"/"+dir.lastPathComponent+".hex:i"]
if speed != nil {
@ -127,9 +132,10 @@ class ASBuilder {
}
func disassembleProject(board: String) {
let toolChain = (NSApplication.sharedApplication().delegate as ASApplication).preferences.toolchainPath
task = NSTask()
task!.currentDirectoryPath = dir.path!
task!.launchPath = "/usr/local/CrossPack-AVR/bin/avr-objdump"
task!.launchPath = toolChain+"/bin/avr-objdump"
let fileManager = NSFileManager.defaultManager()
let logURL = dir.URLByAppendingPathComponent("build/disasm.log")
@ -138,8 +144,10 @@ class ASBuilder {
task!.standardOutput = logOut
task!.standardError = logOut
var args = ["-d", "-S", "build/"+board+"/"+dir.lastPathComponent+".elf"]
let cmdLine = task!.launchPath+" "+(args as NSArray).componentsJoinedByString(" ")+"\n"
let showSource = NSUserDefaults.standardUserDefaults().boolForKey("ShowSourceInDisassembly")
var args = showSource ? ["-S"] : []
args += ["-d", "build/"+board+"/"+dir.lastPathComponent+".elf"]
let cmdLine = task!.launchPath+" "+(args as NSArray).componentsJoinedByString(" ")+"\n"
logOut.writeData(cmdLine.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)!)
task!.arguments = args;
task!.launch()

View File

@ -28,7 +28,7 @@
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9aO-EG-pZd">
<rect key="frame" x="14" y="17" width="412" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="lLl-0E-bfa">
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Label" id="lLl-0E-bfa">
<font key="font" metaFont="fixedUser" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>

View File

@ -6,7 +6,7 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
<connections>
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
<outlet property="delegate" destination="Voe-Tx-rLC" id="D1w-t4-cbp"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@ -14,6 +14,7 @@
<customObject id="Voe-Tx-rLC" customClass="ASApplication" customModule="AVRsack">
<connections>
<outlet property="keyboardMenu" destination="WWD-TD-lpw" id="Tr8-cg-fXf"/>
<outlet property="preferences" destination="sor-iB-NZD" id="zad-hM-0R0"/>
<outlet property="themeMenu" destination="uKq-xh-hZD" id="xE2-Kc-819"/>
</connections>
</customObject>

View File

@ -127,13 +127,15 @@ File.open("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('')
rakeFile.print <<END_RAKE
CC = '/usr/local/CrossPack-AVR/bin/avr-gcc -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}
CCP = '/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}
LD = '/usr/local/CrossPack-AVR/bin/avr-g++ -Os -Wl,--gc-sections -mmcu=#{BUILD['mcu']}'
AR = '/usr/local/CrossPack-AVR/bin/avr-ar crs'
EEP = '/usr/local/CrossPack-AVR/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0'
HEX = '/usr/local/CrossPack-AVR/bin/avr-objcopy -O ihex -R .eeprom'
SIZE = '/usr/local/CrossPack-AVR/bin/avr-size'
TOOLCHAIN = "#{BUILD['toolchain']}"
BIN = TOOLCHAIN+"/bin/"
CC = BIN+'avr-gcc -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}
CCP = 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}
LD = BIN+'avr-g++ -Os -Wl,--gc-sections -mmcu=#{BUILD['mcu']}'
AR = BIN+'avr-ar crs'
EEP = BIN+'avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0'
HEX = BIN+'avr-objcopy -O ihex -R .eeprom'
SIZE = BIN+'avr-size'
def compile(dest, extrainc, *src)
directory dest