mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-11 08:29:19 +01:00
Various cleanups. Introduced class PreferencesMap to replace/simplify Map<String, String>.
This commit is contained in:
parent
e63c2d1429
commit
dc616601cd
@ -26,6 +26,7 @@ import java.awt.*;
|
|||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ public class Base {
|
|||||||
/** Set true if this a proper release rather than a numbered revision. */
|
/** Set true if this a proper release rather than a numbered revision. */
|
||||||
static public boolean RELEASE = false;
|
static public boolean RELEASE = false;
|
||||||
|
|
||||||
static HashMap<Integer, String> platformNames = new HashMap<Integer, String>();
|
static Map<Integer, String> platformNames = new HashMap<Integer, String>();
|
||||||
static {
|
static {
|
||||||
platformNames.put(PConstants.WINDOWS, "windows");
|
platformNames.put(PConstants.WINDOWS, "windows");
|
||||||
platformNames.put(PConstants.MACOSX, "macosx");
|
platformNames.put(PConstants.MACOSX, "macosx");
|
||||||
@ -78,19 +79,18 @@ public class Base {
|
|||||||
static private File examplesFolder;
|
static private File examplesFolder;
|
||||||
static private File librariesFolder;
|
static private File librariesFolder;
|
||||||
static private File toolsFolder;
|
static private File toolsFolder;
|
||||||
static private File hardwareFolder;
|
|
||||||
|
|
||||||
static HashSet<File> libraries;
|
static Set<File> libraries;
|
||||||
|
|
||||||
// maps imported packages to their library folder
|
// maps imported packages to their library folder
|
||||||
static HashMap<String, File> importToLibraryTable;
|
static Map<String, File> importToLibraryTable;
|
||||||
|
|
||||||
// classpath for all known libraries for p5
|
// classpath for all known libraries for p5
|
||||||
// (both those in the p5/libs folder and those with lib subfolders
|
// (both those in the p5/libs folder and those with lib subfolders
|
||||||
// found in the sketchbook)
|
// found in the sketchbook)
|
||||||
static public String librariesClassPath;
|
static public String librariesClassPath;
|
||||||
|
|
||||||
static public HashMap<String, Target> targetsTable;
|
static public Map<String, Target> targetsTable;
|
||||||
|
|
||||||
// Location for untitled items
|
// Location for untitled items
|
||||||
static File untitledFolder;
|
static File untitledFolder;
|
||||||
@ -99,10 +99,7 @@ public class Base {
|
|||||||
// static Image icon;
|
// static Image icon;
|
||||||
|
|
||||||
// int editorCount;
|
// int editorCount;
|
||||||
// Editor[] editors;
|
List<Editor> editors = Collections.synchronizedList(new ArrayList<Editor>());
|
||||||
java.util.List<Editor> editors =
|
|
||||||
Collections.synchronizedList(new ArrayList<Editor>());
|
|
||||||
// ArrayList editors = Collections.synchronizedList(new ArrayList<Editor>());
|
|
||||||
Editor activeEditor;
|
Editor activeEditor;
|
||||||
|
|
||||||
|
|
||||||
@ -956,17 +953,19 @@ public class Base {
|
|||||||
//Choose which library to add by chip platform
|
//Choose which library to add by chip platform
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//Find the current target. Get the platform, and then select the correct name and core path.
|
// Find the current target. Get the platform, and then select the
|
||||||
String platformname = this.getBoardPreferences().get("platform");
|
// correct name and core path.
|
||||||
String targetname = this.getPlatformPreferences(platformname).get("name");
|
String platformname = getBoardPreferences().get("platform");
|
||||||
String libraryPath = this.getPlatformPreferences(platformname).get("library.core.path");
|
String targetname = getPlatformPreferences(platformname)
|
||||||
|
.get("name");
|
||||||
|
String libraryPath = getPlatformPreferences(platformname).get(
|
||||||
|
"library.core.path");
|
||||||
|
|
||||||
JMenuItem platformItem = new JMenuItem(targetname);
|
JMenuItem platformItem = new JMenuItem(targetname);
|
||||||
platformItem.setEnabled(false);
|
platformItem.setEnabled(false);
|
||||||
importMenu.add(platformItem);
|
importMenu.add(platformItem);
|
||||||
importMenu.addSeparator();
|
importMenu.addSeparator();
|
||||||
addLibraries(importMenu, getCoreLibraries(libraryPath));
|
addLibraries(importMenu, getCoreLibraries(libraryPath));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1574,91 +1573,28 @@ public class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static public Map<String, String> getPlatformPreferences() {
|
static public PreferencesMap getPlatformPreferences() {
|
||||||
System.out.println("getPlatformPreferences() no arguments: start");
|
|
||||||
Target target = getTarget();
|
Target target = getTarget();
|
||||||
//if (target == null) return new LinkedHashMap();
|
Map<String, PreferencesMap> platforms = target.getPlatforms();
|
||||||
Map map = target.getPlatforms();
|
return platforms.get(Preferences.get("platform"));
|
||||||
/*
|
|
||||||
if (map == null)
|
|
||||||
{
|
|
||||||
System.err.println("Error loading platforms preference from Target");
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//if (map == null) return new LinkedHashMap();
|
|
||||||
map = (Map) map.get(Preferences.get("platform"));
|
|
||||||
//if (map == null) return new LinkedHashMap();
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get a specific platform
|
//Get a specific platform
|
||||||
static public Map<String, String> getPlatformPreferences(String platformname) {
|
static public PreferencesMap getPlatformPreferences(String platformName) {
|
||||||
if (platformname == null) {
|
if (platformName == null)
|
||||||
platformname = Preferences.get("platform");
|
platformName = Preferences.get("platform");
|
||||||
|
|
||||||
}
|
|
||||||
System.out.println("getlatformPreferences(String platformname)): start: platformname = " + platformname );
|
|
||||||
Target target = getTarget();
|
Target target = getTarget();
|
||||||
if (target == null ) {
|
Map<String, PreferencesMap> platforms = target.getPlatforms();
|
||||||
System.out.println("get target is null. trouble! ");
|
return platforms.get(platformName);
|
||||||
}
|
|
||||||
Map map = target.getPlatforms();
|
|
||||||
map = (Map) map.get(platformname);
|
|
||||||
|
|
||||||
//What if null or defaults to nonexisent platform
|
|
||||||
System.out.println("PlatformName: " + platformname);
|
|
||||||
if (map == null)
|
|
||||||
{
|
|
||||||
System.err.println("Error loading platforms preference from Target");
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public Map<String, String> bogusgetBoardPreferences() {
|
static public PreferencesMap getBoardPreferences() {
|
||||||
System.out.println("getBoardPrefences method: start");
|
|
||||||
Target target = getTarget();
|
|
||||||
if (target == null) {
|
|
||||||
System.out.println("getBoardPrefereces method: target == null");
|
|
||||||
return new LinkedHashMap();
|
|
||||||
}
|
|
||||||
Map map = target.getBoards();
|
|
||||||
if (map == null) {
|
|
||||||
System.out.println("getBoardPrefereces method: target.getBoards() == null");
|
|
||||||
return new LinkedHashMap();
|
|
||||||
}
|
|
||||||
map = (Map) map.get(Preferences.get("board"));
|
|
||||||
if (map == null) {
|
|
||||||
System.out.println("getBoardPrefereces method: Preferences.get(board) == null");
|
|
||||||
return new LinkedHashMap();
|
|
||||||
}
|
|
||||||
//Debug iterate the map
|
|
||||||
Iterator iterator = map.entrySet().iterator();
|
|
||||||
while(iterator.hasNext())
|
|
||||||
{
|
|
||||||
Map.Entry pair = (Map.Entry)iterator.next();
|
|
||||||
if (pair.getValue() == null)
|
|
||||||
{
|
|
||||||
System.out.println("KeyName: " + pair.getKey() + " val: null");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println("KeyName: " + pair.getKey() + " val" + pair.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
static public Map<String, String> getBoardPreferences() {
|
|
||||||
Target target = getTarget();
|
Target target = getTarget();
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
String board = Preferences.get("board");
|
String board = Preferences.get("board");
|
||||||
return target.getBoards().get(board);
|
return target.getBoards().get(board);
|
||||||
}
|
}
|
||||||
return new HashMap<String, String>();
|
return new PreferencesMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public File getSketchbookFolder() {
|
static public File getSketchbookFolder() {
|
||||||
|
@ -782,17 +782,16 @@ public class Preferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//get a Map of the Preferences
|
//get a Map of the Preferences
|
||||||
static public Map<String, String> getMap()
|
static public PreferencesMap getMap()
|
||||||
{
|
{
|
||||||
Map globalpreferences = new LinkedHashMap();
|
PreferencesMap globalpreferences = new PreferencesMap();
|
||||||
Enumeration e = table.keys();
|
Enumeration<String> e = table.keys();
|
||||||
|
|
||||||
while (e.hasMoreElements())
|
while (e.hasMoreElements())
|
||||||
{
|
{
|
||||||
String key = (String) e.nextElement();
|
String key = (String) e.nextElement();
|
||||||
//System.out.println("Key: " + key + "Val: " + table.get(key));
|
|
||||||
String value = (String) table.get(key);
|
String value = (String) table.get(key);
|
||||||
globalpreferences.put(key, value );
|
globalpreferences.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return globalpreferences;
|
return globalpreferences;
|
||||||
|
88
app/src/processing/app/PreferencesMap.java
Normal file
88
app/src/processing/app/PreferencesMap.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
PreferencesMap - A Map<String, String> with some useful features
|
||||||
|
to handle preferences.
|
||||||
|
Part of the Arduino project - http://www.arduino.cc/
|
||||||
|
|
||||||
|
Copyright (c) 2011 Cristian Maglie
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
$Id$
|
||||||
|
*/
|
||||||
|
package processing.app;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import processing.core.PApplet;
|
||||||
|
|
||||||
|
public class PreferencesMap extends HashMap<String, String> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a property list file and put kev/value pairs into the Map
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @throws FileNotFoundException
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void load(File file) throws FileNotFoundException, IOException {
|
||||||
|
load(new FileInputStream(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a property list stream and put key/value pairs into the Map
|
||||||
|
*
|
||||||
|
* @param input
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public void load(InputStream input) throws IOException {
|
||||||
|
String[] lines = PApplet.loadStrings(input);
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.length() == 0 || line.charAt(0) == '#')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int equals = line.indexOf('=');
|
||||||
|
if (equals != -1) {
|
||||||
|
String key = line.substring(0, equals);
|
||||||
|
String value = line.substring(equals + 1);
|
||||||
|
put(key.trim(), value.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, PreferencesMap> createFirstLevelMap() {
|
||||||
|
Map<String, PreferencesMap> res = new HashMap<String, PreferencesMap>();
|
||||||
|
for (String key : keySet()) {
|
||||||
|
int dot = key.indexOf('.');
|
||||||
|
if (dot == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String parent = key.substring(0, dot);
|
||||||
|
String child = key.substring(dot + 1);
|
||||||
|
|
||||||
|
if (!res.containsKey(parent))
|
||||||
|
res.put(parent, new PreferencesMap());
|
||||||
|
res.get(parent).put(child, get(key));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2330591567444282843L;
|
||||||
|
}
|
@ -23,18 +23,25 @@
|
|||||||
|
|
||||||
package processing.app.debug;
|
package processing.app.debug;
|
||||||
|
|
||||||
|
import static processing.app.I18n._;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import processing.app.Base;
|
import processing.app.Base;
|
||||||
|
import processing.app.PreferencesMap;
|
||||||
|
import processing.app.I18n;
|
||||||
import processing.app.Preferences;
|
import processing.app.Preferences;
|
||||||
import processing.app.Sketch;
|
import processing.app.Sketch;
|
||||||
import processing.app.SketchCode;
|
import processing.app.SketchCode;
|
||||||
import processing.core.*;
|
import processing.core.PApplet;
|
||||||
import processing.app.I18n;
|
|
||||||
import static processing.app.I18n._;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.text.MessageFormat;
|
|
||||||
|
|
||||||
|
|
||||||
public class Compiler implements MessageConsumer {
|
public class Compiler implements MessageConsumer {
|
||||||
static final String BUGS_URL =
|
static final String BUGS_URL =
|
||||||
@ -45,60 +52,54 @@ public class Compiler implements MessageConsumer {
|
|||||||
Sketch sketch;
|
Sketch sketch;
|
||||||
String buildPath;
|
String buildPath;
|
||||||
String primaryClassName;
|
String primaryClassName;
|
||||||
String platform;
|
|
||||||
String board;
|
String board;
|
||||||
|
|
||||||
boolean verbose;
|
boolean verbose;
|
||||||
|
|
||||||
RunnerException exception;
|
RunnerException exception;
|
||||||
|
|
||||||
HashMap<String, String> configPreferences;
|
|
||||||
HashMap<String, String> platformPreferences;
|
|
||||||
|
|
||||||
String avrBasePath;
|
|
||||||
String corePath;
|
|
||||||
|
|
||||||
List<File> objectFiles;
|
List<File> objectFiles;
|
||||||
ArrayList<String> includePaths;
|
|
||||||
|
|
||||||
public Compiler() { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile with avr-gcc.
|
* Compile with avr-gcc.
|
||||||
*
|
*
|
||||||
* @param sketch Sketch object to be compiled.
|
* @param _sketch Sketch object to be compiled.
|
||||||
* @param buildPath Where the temporary files live and will be built from.
|
* @param _buildPath Where the temporary files live and will be built from.
|
||||||
* @param primaryClassName the name of the combined sketch file w/ extension
|
* @param _primaryClassName the name of the combined sketch file w/ extension
|
||||||
* @return true if successful.
|
* @return true if successful.
|
||||||
* @throws RunnerException Only if there's a problem. Only then.
|
* @throws RunnerException Only if there's a problem. Only then.
|
||||||
*/
|
*/
|
||||||
public boolean compile(Sketch sketch,
|
public boolean compile(Sketch _sketch,
|
||||||
String buildPath,
|
String _buildPath,
|
||||||
String primaryClassName,
|
String _primaryClassName,
|
||||||
boolean verbose) throws RunnerException {
|
boolean _verbose) throws RunnerException {
|
||||||
this.sketch = sketch;
|
sketch = _sketch;
|
||||||
this.buildPath = buildPath;
|
buildPath = _buildPath;
|
||||||
this.primaryClassName = primaryClassName;
|
primaryClassName = _primaryClassName;
|
||||||
this.verbose = verbose;
|
verbose = _verbose;
|
||||||
objectFiles = new ArrayList<File>();
|
objectFiles = new ArrayList<File>();
|
||||||
|
|
||||||
Map<String, String> boardPreferences = Base.getBoardPreferences();
|
PreferencesMap boardPreferences = Base.getBoardPreferences();
|
||||||
|
|
||||||
//Check for null platform, and use system default if not found
|
// Check for null platform, and use system default if not found
|
||||||
platform = boardPreferences.get("platform");
|
PreferencesMap platformPreferences;
|
||||||
|
String platform = boardPreferences.get("platform");
|
||||||
if (platform == null)
|
if (platform == null)
|
||||||
{
|
platformPreferences = Base.getPlatformPreferences();
|
||||||
platformPreferences = new HashMap(Base.getPlatformPreferences());
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
platformPreferences = Base.getPlatformPreferences(platform);
|
||||||
platformPreferences = new HashMap(Base.getPlatformPreferences(platform));
|
|
||||||
|
// Merge all the global preference configuration
|
||||||
|
PreferencesMap configPreferences = new PreferencesMap();
|
||||||
|
configPreferences.putAll(Preferences.getMap());
|
||||||
|
configPreferences.putAll(platformPreferences);
|
||||||
|
configPreferences.putAll(boardPreferences);
|
||||||
|
for (String k : configPreferences.keySet()) {
|
||||||
|
if (configPreferences.get(k)==null)
|
||||||
|
configPreferences.put(k, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("////////////////////////////compiler.java is doing stuff/////////////////");
|
String avrBasePath = configPreferences.get("compiler.path");
|
||||||
//Put all the global preference configuration into one Master configpreferences
|
|
||||||
configPreferences = mergePreferences( Preferences.getMap(), platformPreferences, boardPreferences);
|
|
||||||
avrBasePath = configPreferences.get("compiler.path");
|
|
||||||
if (avrBasePath == null)
|
if (avrBasePath == null)
|
||||||
{
|
{
|
||||||
avrBasePath = Base.getAvrBasePath();
|
avrBasePath = Base.getAvrBasePath();
|
||||||
@ -118,23 +119,19 @@ public class Compiler implements MessageConsumer {
|
|||||||
Object[] Args = {basePath};
|
Object[] Args = {basePath};
|
||||||
avrBasePath = compileFormat.format( Args );
|
avrBasePath = compileFormat.format( Args );
|
||||||
System.out.println("avrBasePath:new: " + avrBasePath);
|
System.out.println("avrBasePath:new: " + avrBasePath);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this.board = configPreferences.get("board");
|
board = configPreferences.get("board");
|
||||||
if (this.board == "")
|
if (board == "")
|
||||||
{
|
board = "_UNKNOWN";
|
||||||
this.board = "_UNKNOWN";
|
|
||||||
}
|
|
||||||
|
|
||||||
String core = configPreferences.get("build.core");
|
String core = configPreferences.get("build.core");
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
RunnerException re = new RunnerException(_("No board selected; please choose a board from the Tools > Board menu."));
|
RunnerException re = new RunnerException(_("No board selected; please choose a board from the Tools > Board menu."));
|
||||||
re.hideStackTrace();
|
re.hideStackTrace();
|
||||||
throw re;
|
throw re;
|
||||||
}
|
}
|
||||||
|
|
||||||
String corePath;
|
String corePath;
|
||||||
|
|
||||||
if (core.indexOf(':') == -1) {
|
if (core.indexOf(':') == -1) {
|
||||||
Target t = Base.getTarget();
|
Target t = Base.getTarget();
|
||||||
File coreFolder = new File(new File(t.getFolder(), "cores"), core);
|
File coreFolder = new File(new File(t.getFolder(), "cores"), core);
|
||||||
@ -148,7 +145,6 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
String variant = boardPreferences.get("build.variant");
|
String variant = boardPreferences.get("build.variant");
|
||||||
String variantPath = null;
|
String variantPath = null;
|
||||||
|
|
||||||
if (variant != null) {
|
if (variant != null) {
|
||||||
if (variant.indexOf(':') == -1) {
|
if (variant.indexOf(':') == -1) {
|
||||||
Target t = Base.getTarget();
|
Target t = Base.getTarget();
|
||||||
@ -164,25 +160,25 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// 0. include paths for core + all libraries
|
// 0. include paths for core + all libraries
|
||||||
sketch.setCompilingProgress(20);
|
sketch.setCompilingProgress(20);
|
||||||
ArrayList<String> includePaths = new ArrayList<String>();
|
List<String> includePaths = new ArrayList<String>();
|
||||||
includePaths.add(corePath);
|
includePaths.add(corePath);
|
||||||
if (variantPath != null) includePaths.add(variantPath);
|
if (variantPath != null)
|
||||||
for (File file : sketch.getImportedLibraries()) {
|
includePaths.add(variantPath);
|
||||||
|
for (File file : sketch.getImportedLibraries())
|
||||||
includePaths.add(file.getPath());
|
includePaths.add(file.getPath());
|
||||||
}
|
|
||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 1. compile the sketch (already in the buildPath)
|
||||||
System.out.println("1. compileSketch");
|
System.out.println("1. compileSketch");
|
||||||
sketch.setCompilingProgress(30);
|
sketch.setCompilingProgress(30);
|
||||||
compileSketch(avrBasePath, buildPath, includePaths, configPreferences);
|
compileSketch(avrBasePath, _buildPath, includePaths, configPreferences);
|
||||||
|
|
||||||
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
// 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
|
||||||
// 2. compile the libraries, outputting .o files to:
|
// 2. compile the libraries, outputting .o files to:
|
||||||
// <buildPath>/<library>/
|
// <buildPath>/<library>/
|
||||||
//Doesn't really use configPreferences
|
//Doesn't really use configPreferences
|
||||||
System.out.println("2. compileLibraries");
|
System.out.println("2. compileLibraries");
|
||||||
sketch.setCompilingProgress(40);
|
sketch.setCompilingProgress(40);
|
||||||
compileLibraries(avrBasePath, buildPath, includePaths, configPreferences);
|
compileLibraries(avrBasePath, _buildPath, includePaths, configPreferences);
|
||||||
/*
|
/*
|
||||||
|
|
||||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||||
@ -215,7 +211,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
System.out.println("3. compileCore");
|
System.out.println("3. compileCore");
|
||||||
System.out.println("corePath: " + corePath);
|
System.out.println("corePath: " + corePath);
|
||||||
sketch.setCompilingProgress(50);
|
sketch.setCompilingProgress(50);
|
||||||
compileCore(avrBasePath, buildPath, corePath, variant, variantPath, configPreferences);
|
compileCore(avrBasePath, _buildPath, corePath, variant, variantPath, configPreferences);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -244,7 +240,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
// 4. link it all together into the .elf file
|
// 4. link it all together into the .elf file
|
||||||
sketch.setCompilingProgress(60);
|
sketch.setCompilingProgress(60);
|
||||||
System.out.println("4. compileLink");
|
System.out.println("4. compileLink");
|
||||||
compileLink(avrBasePath, buildPath, corePath, includePaths, configPreferences);
|
compileLink(avrBasePath, _buildPath, corePath, includePaths, configPreferences);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
List baseCommandLinker = new ArrayList(Arrays.asList(new String[] {
|
||||||
@ -291,7 +287,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
execAsynchronously(commandObjcopy);
|
execAsynchronously(commandObjcopy);
|
||||||
*/
|
*/
|
||||||
System.out.println("5. compileEep");
|
System.out.println("5. compileEep");
|
||||||
compileEep(avrBasePath, buildPath, includePaths, configPreferences);
|
compileEep(avrBasePath, _buildPath, includePaths, configPreferences);
|
||||||
|
|
||||||
// 6. build the .hex file
|
// 6. build the .hex file
|
||||||
sketch.setCompilingProgress(80);
|
sketch.setCompilingProgress(80);
|
||||||
@ -304,7 +300,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
execAsynchronously(commandObjcopy);
|
execAsynchronously(commandObjcopy);
|
||||||
*/
|
*/
|
||||||
System.out.println("6. compileHex");
|
System.out.println("6. compileHex");
|
||||||
compileHex(avrBasePath, buildPath, includePaths, configPreferences);
|
compileHex(avrBasePath, _buildPath, includePaths, configPreferences);
|
||||||
|
|
||||||
sketch.setCompilingProgress(90);
|
sketch.setCompilingProgress(90);
|
||||||
return true;
|
return true;
|
||||||
@ -312,10 +308,10 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
|
|
||||||
private List<File> compileFiles(String avrBasePath,
|
private List<File> compileFiles(String avrBasePath,
|
||||||
String buildPath, ArrayList<String> includePaths,
|
String buildPath, List<String> includePaths,
|
||||||
ArrayList<File> sSources,
|
List<File> sSources,
|
||||||
ArrayList<File> cSources, ArrayList<File> cppSources,
|
List<File> cSources, List<File> cppSources,
|
||||||
Map<String, String> boardPreferences)
|
PreferencesMap prefs)
|
||||||
throws RunnerException {
|
throws RunnerException {
|
||||||
|
|
||||||
List<File> objectPaths = new ArrayList<File>();
|
List<File> objectPaths = new ArrayList<File>();
|
||||||
@ -326,7 +322,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
execAsynchronously(getCommandCompilerS(avrBasePath, includePaths,
|
execAsynchronously(getCommandCompilerS(avrBasePath, includePaths,
|
||||||
file.getAbsolutePath(),
|
file.getAbsolutePath(),
|
||||||
objectPath,
|
objectPath,
|
||||||
configPreferences));
|
prefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (File file : cSources) {
|
for (File file : cSources) {
|
||||||
@ -335,11 +331,11 @@ public class Compiler implements MessageConsumer {
|
|||||||
File objectFile = new File(objectPath);
|
File objectFile = new File(objectPath);
|
||||||
File dependFile = new File(dependPath);
|
File dependFile = new File(dependPath);
|
||||||
objectPaths.add(objectFile);
|
objectPaths.add(objectFile);
|
||||||
if (is_already_compiled(file, objectFile, dependFile, boardPreferences)) continue;
|
if (is_already_compiled(file, objectFile, dependFile, prefs)) continue;
|
||||||
execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
|
execAsynchronously(getCommandCompilerC(avrBasePath, includePaths,
|
||||||
file.getAbsolutePath(),
|
file.getAbsolutePath(),
|
||||||
objectPath,
|
objectPath,
|
||||||
configPreferences));
|
prefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (File file : cppSources) {
|
for (File file : cppSources) {
|
||||||
@ -348,11 +344,11 @@ public class Compiler implements MessageConsumer {
|
|||||||
File objectFile = new File(objectPath);
|
File objectFile = new File(objectPath);
|
||||||
File dependFile = new File(dependPath);
|
File dependFile = new File(dependPath);
|
||||||
objectPaths.add(objectFile);
|
objectPaths.add(objectFile);
|
||||||
if (is_already_compiled(file, objectFile, dependFile, boardPreferences)) continue;
|
if (is_already_compiled(file, objectFile, dependFile, prefs)) continue;
|
||||||
execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
|
execAsynchronously(getCommandCompilerCPP(avrBasePath, includePaths,
|
||||||
file.getAbsolutePath(),
|
file.getAbsolutePath(),
|
||||||
objectPath,
|
objectPath,
|
||||||
configPreferences));
|
prefs));
|
||||||
}
|
}
|
||||||
|
|
||||||
return objectPaths;
|
return objectPaths;
|
||||||
@ -621,9 +617,9 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
// ///////////////////////////////////////////////////////////////////////////
|
// ///////////////////////////////////////////////////////////////////////////
|
||||||
static private String[] getCommandCompilerS(String avrBasePath,
|
static private String[] getCommandCompilerS(String avrBasePath,
|
||||||
ArrayList<String> includePaths, String sourceName, String objectName,
|
List<String> includePaths, String sourceName, String objectName,
|
||||||
HashMap<String, String> configPreferences)
|
PreferencesMap configPreferences)
|
||||||
{
|
{
|
||||||
System.out.println("getCommandCompilerS: start");
|
System.out.println("getCommandCompilerS: start");
|
||||||
String baseCommandString = configPreferences.get("recipe.cpp.o.pattern");
|
String baseCommandString = configPreferences.get("recipe.cpp.o.pattern");
|
||||||
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
||||||
@ -682,8 +678,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
//removed static
|
//removed static
|
||||||
private String[] getCommandCompilerC(String avrBasePath,
|
private String[] getCommandCompilerC(String avrBasePath,
|
||||||
ArrayList<String> includePaths, String sourceName, String objectName,
|
List<String> includePaths, String sourceName, String objectName,
|
||||||
HashMap<String, String> configPreferences)
|
PreferencesMap configPreferences)
|
||||||
{
|
{
|
||||||
System.out.println("getCommandCompilerC: start");
|
System.out.println("getCommandCompilerC: start");
|
||||||
String baseCommandString = configPreferences.get("recipe.c.o.pattern");
|
String baseCommandString = configPreferences.get("recipe.c.o.pattern");
|
||||||
@ -691,7 +687,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
//getIncludes to String
|
//getIncludes to String
|
||||||
String includes = preparePaths(includePaths);
|
String includes = preparePaths(includePaths);
|
||||||
|
|
||||||
Object[] Args = {
|
String[] args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
configPreferences.get("compiler.c.cmd"),
|
configPreferences.get("compiler.c.cmd"),
|
||||||
configPreferences.get("compiler.c.flags"),
|
configPreferences.get("compiler.c.flags"),
|
||||||
@ -699,13 +695,13 @@ public class Compiler implements MessageConsumer {
|
|||||||
configPreferences.get("build.mcu"),
|
configPreferences.get("build.mcu"),
|
||||||
configPreferences.get("build.f_cpu"),
|
configPreferences.get("build.f_cpu"),
|
||||||
configPreferences.get("software"),
|
configPreferences.get("software"),
|
||||||
Base.REVISION,
|
"" + Base.REVISION,
|
||||||
includes,
|
includes,
|
||||||
sourceName,
|
sourceName,
|
||||||
objectName
|
objectName
|
||||||
};
|
};
|
||||||
|
|
||||||
String command = compileFormat.format( Args );
|
String command = compileFormat.format(args);
|
||||||
String[] commandArray = command.split("\\|");
|
String[] commandArray = command.split("\\|");
|
||||||
return commandArray;
|
return commandArray;
|
||||||
}
|
}
|
||||||
@ -743,8 +739,8 @@ public class Compiler implements MessageConsumer {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static private String[] getCommandCompilerCPP(String avrBasePath,
|
static private String[] getCommandCompilerCPP(String avrBasePath,
|
||||||
ArrayList<String> includePaths, String sourceName, String objectName,
|
List<String> includePaths, String sourceName, String objectName,
|
||||||
HashMap<String, String> configPreferences)
|
PreferencesMap configPreferences)
|
||||||
{
|
{
|
||||||
System.out.println("getCommandCompilerCPP: start");
|
System.out.println("getCommandCompilerCPP: start");
|
||||||
String baseCommandString = configPreferences.get("recipe.cpp.o.pattern");
|
String baseCommandString = configPreferences.get("recipe.cpp.o.pattern");
|
||||||
@ -752,7 +748,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
//getIncludes to String
|
//getIncludes to String
|
||||||
String includes = preparePaths(includePaths);
|
String includes = preparePaths(includePaths);
|
||||||
|
|
||||||
Object[] Args = {
|
String[] args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
configPreferences.get("compiler.cpp.cmd"),
|
configPreferences.get("compiler.cpp.cmd"),
|
||||||
configPreferences.get("compiler.cpp.flags"),
|
configPreferences.get("compiler.cpp.flags"),
|
||||||
@ -760,13 +756,13 @@ public class Compiler implements MessageConsumer {
|
|||||||
configPreferences.get("build.mcu"),
|
configPreferences.get("build.mcu"),
|
||||||
configPreferences.get("build.f_cpu"),
|
configPreferences.get("build.f_cpu"),
|
||||||
configPreferences.get("software"),
|
configPreferences.get("software"),
|
||||||
Base.REVISION,
|
"" + Base.REVISION,
|
||||||
includes,
|
includes,
|
||||||
sourceName,
|
sourceName,
|
||||||
objectName
|
objectName
|
||||||
};
|
};
|
||||||
|
|
||||||
String command = compileFormat.format( Args );
|
String command = compileFormat.format(args);
|
||||||
String[] commandArray = command.split("\\|");
|
String[] commandArray = command.split("\\|");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -803,15 +799,15 @@ public class Compiler implements MessageConsumer {
|
|||||||
return (new File(path)).list(onlyHFiles);
|
return (new File(path)).list(onlyHFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ArrayList<File> findFilesInPath(String path, String extension,
|
static public List<File> findFilesInPath(String path, String extension,
|
||||||
boolean recurse) {
|
boolean recurse) {
|
||||||
System.out.println("findFilesInPath: " + path);
|
System.out.println("findFilesInPath: " + path);
|
||||||
return findFilesInFolder(new File(path), extension, recurse);
|
return findFilesInFolder(new File(path), extension, recurse);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public ArrayList<File> findFilesInFolder(File folder, String extension,
|
static public List<File> findFilesInFolder(File folder, String extension,
|
||||||
boolean recurse) {
|
boolean recurse) {
|
||||||
ArrayList<File> files = new ArrayList<File>();
|
List<File> files = new ArrayList<File>();
|
||||||
|
|
||||||
if (folder.listFiles() == null) return files;
|
if (folder.listFiles() == null) return files;
|
||||||
|
|
||||||
@ -831,17 +827,18 @@ public class Compiler implements MessageConsumer {
|
|||||||
|
|
||||||
|
|
||||||
// 1. compile the sketch (already in the buildPath)
|
// 1. compile the sketch (already in the buildPath)
|
||||||
void compileSketch(String avrBasePath, String buildPath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
void compileSketch(String avrBasePath, String buildPath,
|
||||||
|
List<String> includePaths, PreferencesMap configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
System.out.println("compileSketch: start");
|
System.out.println("compileSketch: start");
|
||||||
System.out.println("includePaths: ");
|
System.out.println("includePaths: ");
|
||||||
for (int i = 0; i < includePaths.size(); i++) {
|
for (int i = 0; i < includePaths.size(); i++) {
|
||||||
System.out.println("-I" + (String) includePaths.get(i));
|
System.out.println("-I" + (String) includePaths.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
//logger.debug("compileSketch: start");
|
//logger.debug("compileSketch: start");
|
||||||
this.objectFiles.addAll(compileFiles(avrBasePath, buildPath, includePaths,
|
objectFiles.addAll(compileFiles(avrBasePath, buildPath, includePaths,
|
||||||
findFilesInPath(buildPath, "S", false),
|
findFilesInPath(buildPath, "S", false),
|
||||||
findFilesInPath(buildPath, "c", false),
|
findFilesInPath(buildPath, "c", false),
|
||||||
findFilesInPath(buildPath, "cpp", false),
|
findFilesInPath(buildPath, "cpp", false),
|
||||||
@ -851,11 +848,11 @@ public class Compiler implements MessageConsumer {
|
|||||||
// 2. compile the libraries, outputting .o files to:
|
// 2. compile the libraries, outputting .o files to:
|
||||||
// <buildPath>/<library>/
|
// <buildPath>/<library>/
|
||||||
void compileLibraries (String avrBasePath, String buildPath,
|
void compileLibraries (String avrBasePath, String buildPath,
|
||||||
ArrayList<String> includePaths,
|
List<String> includePaths,
|
||||||
HashMap<String, String> configPreferences)
|
PreferencesMap configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
System.out.println("compileLibraries: start");
|
System.out.println("compileLibraries: start");
|
||||||
|
|
||||||
for (File libraryFolder : sketch.getImportedLibraries()) {
|
for (File libraryFolder : sketch.getImportedLibraries()) {
|
||||||
System.out.println("libraryFolder: " + libraryFolder);
|
System.out.println("libraryFolder: " + libraryFolder);
|
||||||
@ -894,20 +891,19 @@ public class Compiler implements MessageConsumer {
|
|||||||
// collecting them into the core.a library file.
|
// collecting them into the core.a library file.
|
||||||
void compileCore (String avrBasePath, String buildPath,
|
void compileCore (String avrBasePath, String buildPath,
|
||||||
String corePath, String variant, String variantPath,
|
String corePath, String variant, String variantPath,
|
||||||
HashMap<String, String> configPreferences)
|
PreferencesMap configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
System.out.println("compileCore(...) start");
|
System.out.println("compileCore(...) start");
|
||||||
|
|
||||||
ArrayList<String> includePaths = new ArrayList();
|
List<String> includePaths = new ArrayList<String>();
|
||||||
includePaths.add(corePath); //include core path only
|
includePaths.add(corePath); //include core path only
|
||||||
if (variantPath != null) includePaths.add(variantPath);
|
if (variantPath != null) includePaths.add(variantPath);
|
||||||
|
|
||||||
//debug includePaths
|
//debug includePaths
|
||||||
System.out.println("includePaths: ");
|
System.out.println("includePaths: ");
|
||||||
for (int i = 0; i < includePaths.size(); i++) {
|
for (int i = 0; i < includePaths.size(); i++)
|
||||||
System.out.println("-I" + (String) includePaths.get(i));
|
System.out.println("-I" + (String) includePaths.get(i));
|
||||||
}
|
|
||||||
|
|
||||||
String baseCommandString = configPreferences.get("recipe.ar.pattern");
|
String baseCommandString = configPreferences.get("recipe.ar.pattern");
|
||||||
String commandString = "";
|
String commandString = "";
|
||||||
@ -926,7 +922,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
//List commandAR = new ArrayList(baseCommandAR);
|
//List commandAR = new ArrayList(baseCommandAR);
|
||||||
//commandAR = commandAR + file.getAbsolutePath();
|
//commandAR = commandAR + file.getAbsolutePath();
|
||||||
|
|
||||||
Object[] Args = {
|
String[] args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
configPreferences.get("compiler.ar.cmd"),
|
configPreferences.get("compiler.ar.cmd"),
|
||||||
configPreferences.get("compiler.ar.flags"),
|
configPreferences.get("compiler.ar.flags"),
|
||||||
@ -936,20 +932,18 @@ public class Compiler implements MessageConsumer {
|
|||||||
//objectName
|
//objectName
|
||||||
file.getAbsolutePath()
|
file.getAbsolutePath()
|
||||||
};
|
};
|
||||||
System.out.println("compileCore(...) substitute");
|
System.out.println("compileCore(...) substitute");
|
||||||
|
|
||||||
commandString = compileFormat.format( Args );
|
commandString = compileFormat.format(args);
|
||||||
String[] commandArray = commandString.split("\\|");
|
String[] commandArray = commandString.split("\\|");
|
||||||
execAsynchronously(commandArray);
|
execAsynchronously(commandArray);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. link it all together into the .elf file
|
// 4. link it all together into the .elf file
|
||||||
void compileLink(String avrBasePath, String buildPath,
|
void compileLink(String avrBasePath, String buildPath,
|
||||||
String corePath, ArrayList<String> includePaths,
|
String corePath, List<String> includePaths,
|
||||||
HashMap<String, String> configPreferences)
|
PreferencesMap configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
// For atmega2560, need --relax linker option to link larger
|
// For atmega2560, need --relax linker option to link larger
|
||||||
@ -969,7 +963,7 @@ public class Compiler implements MessageConsumer {
|
|||||||
}
|
}
|
||||||
System.out.println("objectFileList: " + objectFileList);
|
System.out.println("objectFileList: " + objectFileList);
|
||||||
|
|
||||||
Object[] Args = {
|
String[] args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
configPreferences.get("compiler.c.elf.cmd"),
|
configPreferences.get("compiler.c.elf.cmd"),
|
||||||
configPreferences.get("compiler.c.elf.flags")+optRelax,
|
configPreferences.get("compiler.c.elf.flags")+optRelax,
|
||||||
@ -983,128 +977,59 @@ public class Compiler implements MessageConsumer {
|
|||||||
corePath,
|
corePath,
|
||||||
configPreferences.get("ldscript"),
|
configPreferences.get("ldscript"),
|
||||||
};
|
};
|
||||||
commandString = compileFormat.format( Args );
|
commandString = compileFormat.format(args);
|
||||||
String[] commandArray = commandString.split("\\|");
|
String[] commandArray = commandString.split("\\|");
|
||||||
execAsynchronously(commandArray);
|
execAsynchronously(commandArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
// 5. extract EEPROM data (from EEMEM directive) to .eep file.
|
||||||
void compileEep (String avrBasePath, String buildPath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
void compileEep (String avrBasePath, String buildPath,
|
||||||
|
List<String> includePaths, PreferencesMap configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
//logger.debug("compileEep: start");
|
//logger.debug("compileEep: start");
|
||||||
String baseCommandString = configPreferences.get("recipe.objcopy.eep.pattern");
|
String baseCommandString = configPreferences.get("recipe.objcopy.eep.pattern");
|
||||||
String commandString = "";
|
String commandString = "";
|
||||||
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
||||||
String objectFileList = "";
|
|
||||||
|
|
||||||
Object[] Args = {
|
String[] args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
configPreferences.get("compiler.objcopy.cmd"),
|
configPreferences.get("compiler.objcopy.cmd"),
|
||||||
configPreferences.get("compiler.objcopy.eep.flags"),
|
configPreferences.get("compiler.objcopy.eep.flags"),
|
||||||
buildPath + File.separator + primaryClassName,
|
buildPath + File.separator + primaryClassName,
|
||||||
buildPath + File.separator + primaryClassName
|
buildPath + File.separator + primaryClassName
|
||||||
};
|
};
|
||||||
commandString = compileFormat.format( Args );
|
commandString = compileFormat.format(args);
|
||||||
String[] commandArray = commandString.split("\\|");
|
String[] commandArray = commandString.split("\\|");
|
||||||
execAsynchronously(commandArray);
|
execAsynchronously(commandArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. build the .hex file
|
// 6. build the .hex file
|
||||||
void compileHex (String avrBasePath, String buildPath, ArrayList<String> includePaths, HashMap<String, String> configPreferences)
|
void compileHex (String avrBasePath, String buildPath,
|
||||||
|
List<String> includePaths, PreferencesMap configPreferences)
|
||||||
throws RunnerException
|
throws RunnerException
|
||||||
{
|
{
|
||||||
//logger.debug("compileHex: start");
|
//logger.debug("compileHex: start");
|
||||||
String baseCommandString = configPreferences.get("recipe.objcopy.hex.pattern");
|
String baseCommandString = configPreferences.get("recipe.objcopy.hex.pattern");
|
||||||
String commandString = "";
|
String commandString = "";
|
||||||
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
MessageFormat compileFormat = new MessageFormat(baseCommandString);
|
||||||
String objectFileList = "";
|
|
||||||
|
|
||||||
Object[] Args = {
|
String[] args = {
|
||||||
avrBasePath,
|
avrBasePath,
|
||||||
configPreferences.get("compiler.elf2hex.cmd"),
|
configPreferences.get("compiler.elf2hex.cmd"),
|
||||||
configPreferences.get("compiler.elf2hex.flags"),
|
configPreferences.get("compiler.elf2hex.flags"),
|
||||||
buildPath + File.separator + primaryClassName,
|
buildPath + File.separator + primaryClassName,
|
||||||
buildPath + File.separator + primaryClassName
|
buildPath + File.separator + primaryClassName
|
||||||
};
|
};
|
||||||
commandString = compileFormat.format( Args );
|
commandString = compileFormat.format(args);
|
||||||
String[] commandArray = commandString.split("\\|");
|
String[] commandArray = commandString.split("\\|");
|
||||||
execAsynchronously(commandArray);
|
execAsynchronously(commandArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
//merge all the preferences file in the correct order of precedence
|
private static String preparePaths(List<String> includePaths) {
|
||||||
HashMap mergePreferences(Map Preferences, Map platformPreferences, Map boardPreferences)
|
|
||||||
{
|
|
||||||
HashMap _map = new HashMap();
|
|
||||||
|
|
||||||
Iterator iterator = Preferences.entrySet().iterator();
|
|
||||||
|
|
||||||
while(iterator.hasNext())
|
|
||||||
{
|
|
||||||
Map.Entry pair = (Map.Entry)iterator.next();
|
|
||||||
if (pair.getValue() == null)
|
|
||||||
{
|
|
||||||
_map.put(pair.getKey(), "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_map.put(pair.getKey(), pair.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//logger.debug("Done: Preferences");
|
|
||||||
|
|
||||||
iterator = platformPreferences.entrySet().iterator();
|
|
||||||
|
|
||||||
while(iterator.hasNext())
|
|
||||||
{
|
|
||||||
Map.Entry pair = (Map.Entry)iterator.next();
|
|
||||||
|
|
||||||
if (pair.getValue() == null)
|
|
||||||
{
|
|
||||||
_map.put(pair.getKey(), "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_map.put(pair.getKey(), pair.getValue());
|
|
||||||
}
|
|
||||||
//System.out.println(pair.getKey() + " = " + pair.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.out.println("Done: platformPreferences");
|
|
||||||
iterator = boardPreferences.entrySet().iterator();
|
|
||||||
|
|
||||||
while(iterator.hasNext())
|
|
||||||
{
|
|
||||||
Map.Entry pair = (Map.Entry)iterator.next();
|
|
||||||
|
|
||||||
if (pair.getValue() == null)
|
|
||||||
{
|
|
||||||
_map.put(pair.getKey(), "");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_map.put(pair.getKey(), pair.getValue());
|
|
||||||
}
|
|
||||||
//System.out.println(pair.getKey() + " = " + pair.getValue());
|
|
||||||
}
|
|
||||||
//System.out.println("Done: boardPreferences");
|
|
||||||
|
|
||||||
|
|
||||||
return _map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String preparePaths(ArrayList<String> includePaths) {
|
|
||||||
//getIncludes to String
|
|
||||||
//logger.debug("Start: Prepare paths");
|
|
||||||
String includes = "";
|
String includes = "";
|
||||||
for (int i = 0; i < includePaths.size(); i++)
|
for (String p : includePaths)
|
||||||
{
|
includes += " -I" + p + "|";
|
||||||
includes = includes + (" -I" + (String) includePaths.get(i)) + "|";
|
|
||||||
}
|
|
||||||
//logger.debug("Paths prepared: " + includes);
|
|
||||||
return includes;
|
return includes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,122 +1,105 @@
|
|||||||
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Target - represents a hardware platform
|
Target - represents a hardware platform
|
||||||
Part of the Arduino project - http://www.arduino.cc/
|
Part of the Arduino project - http://www.arduino.cc/
|
||||||
|
|
||||||
Copyright (c) 2009 David A. Mellis
|
Copyright (c) 2009 David A. Mellis
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
$Id$
|
$Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package processing.app.debug;
|
package processing.app.debug;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import processing.app.Preferences;
|
import processing.app.PreferencesMap;
|
||||||
//import processing.app.Base;
|
|
||||||
|
|
||||||
public class Target {
|
public class Target {
|
||||||
private String name;
|
private String name;
|
||||||
private File folder;
|
private File folder;
|
||||||
private Map boards;
|
private Map<String, PreferencesMap> boards;
|
||||||
private Map programmers;
|
private Map<String, PreferencesMap> programmers;
|
||||||
private Map platforms;
|
private Map<String, PreferencesMap> platforms;
|
||||||
|
|
||||||
public Target(String name, File folder) {
|
public Target(String _name, File _folder) {
|
||||||
System.out.println("Target: constructor start, name: " + name);
|
System.out.println("Target: constructor start, name: " + _name);
|
||||||
this.name = name;
|
name = _name;
|
||||||
this.folder = folder;
|
folder = _folder;
|
||||||
this.boards = new LinkedHashMap();
|
boards = new HashMap<String, PreferencesMap>();
|
||||||
this.programmers = new LinkedHashMap();
|
programmers = new HashMap<String, PreferencesMap>();
|
||||||
this.platforms = new LinkedHashMap();
|
platforms = new HashMap<String, PreferencesMap>();
|
||||||
|
|
||||||
File boardsFile = new File(folder, "boards.txt");
|
|
||||||
try {
|
|
||||||
if (boardsFile.exists()) {
|
|
||||||
Map boardPreferences = new LinkedHashMap();
|
|
||||||
Preferences.load(new FileInputStream(boardsFile), boardPreferences);
|
|
||||||
for (Object k : boardPreferences.keySet()) {
|
|
||||||
String key = (String) k;
|
|
||||||
String board = key.substring(0, key.indexOf('.'));
|
|
||||||
if (!boards.containsKey(board)) boards.put(board, new HashMap());
|
|
||||||
((Map) boards.get(board)).put(
|
|
||||||
key.substring(key.indexOf('.') + 1),
|
|
||||||
boardPreferences.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error loading boards from " + boardsFile + ": " + e);
|
|
||||||
|
|
||||||
}
|
try {
|
||||||
|
File boardsFile = new File(_folder, "boards.txt");
|
||||||
|
if (boardsFile.exists()) {
|
||||||
|
PreferencesMap boardPreferences = new PreferencesMap();
|
||||||
|
boardPreferences.load(boardsFile);
|
||||||
|
boards = boardPreferences.createFirstLevelMap();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error loading boards from boards.txt: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
File platformsFile = new File(folder,"platforms.txt");
|
try {
|
||||||
try
|
File platformsFile = new File(_folder, "platforms.txt");
|
||||||
{
|
if (platformsFile.exists()) {
|
||||||
if(platformsFile.exists()){
|
PreferencesMap platformPreferences = new PreferencesMap();
|
||||||
Map platformPreferences = new LinkedHashMap();
|
platformPreferences.load(platformsFile);
|
||||||
Preferences.load(new FileInputStream(platformsFile), platformPreferences);
|
platforms = platformPreferences.createFirstLevelMap();
|
||||||
for(Object k : platformPreferences.keySet())
|
}
|
||||||
{
|
} catch (Exception e) {
|
||||||
String key=(String) k;
|
System.err.println("Error loading platforms from platform.txt: "
|
||||||
String platform=key.substring(0,key.indexOf('.'));
|
+ e);
|
||||||
if (!platforms.containsKey(platform)) platforms.put(platform, new HashMap());
|
}
|
||||||
((Map) platforms.get(platform)).put(key.substring(key.indexOf('.') + 1),platformPreferences.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error loading platforms from " +
|
|
||||||
platformsFile + ": " + e);
|
|
||||||
//System.exit(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
File programmersFile = new File(folder, "programmers.txt");
|
try {
|
||||||
try {
|
File programmersFile = new File(_folder, "programmers.txt");
|
||||||
if (programmersFile.exists()) {
|
if (programmersFile.exists()) {
|
||||||
Map programmerPreferences = new LinkedHashMap();
|
PreferencesMap prefs = new PreferencesMap();
|
||||||
Preferences.load(new FileInputStream(programmersFile), programmerPreferences);
|
prefs.load(programmersFile);
|
||||||
for (Object k : programmerPreferences.keySet()) {
|
programmers = prefs.createFirstLevelMap();
|
||||||
String key = (String) k;
|
}
|
||||||
String programmer = key.substring(0, key.indexOf('.'));
|
} catch (Exception e) {
|
||||||
if (!programmers.containsKey(programmer)) programmers.put(programmer, new HashMap());
|
System.err
|
||||||
((Map) programmers.get(programmer)).put(
|
.println("Error loading programmers from programmers.txt: "
|
||||||
key.substring(key.indexOf('.') + 1),
|
+ e);
|
||||||
programmerPreferences.get(key));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error loading programmers from " +
|
|
||||||
programmersFile + ": " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() { return name; }
|
|
||||||
public File getFolder() { return folder; }
|
|
||||||
public Map<String, Map<String, String>> getBoards() {
|
|
||||||
return boards;
|
|
||||||
}
|
|
||||||
public Map<String, Map<String, String>> getProgrammers() {
|
|
||||||
return programmers;
|
|
||||||
}
|
|
||||||
public Map<String, Map<String, String>> getPlatforms() {
|
|
||||||
return platforms;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFolder() {
|
||||||
|
return folder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, PreferencesMap> getBoards() {
|
||||||
|
return boards;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, PreferencesMap> getProgrammers() {
|
||||||
|
return programmers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, PreferencesMap> getPlatforms() {
|
||||||
|
return platforms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user