mirror of https://github.com/noisymime/Arduino.git
platforms.txt recipes now have symbolic variables instead of indexes ({0},{1},etc.)
Recipes arguments are splitted with spaces instead of |. Single argument containing spaces should be placed between "double quotes". Refactored and formatted Compiler class, removed all unused code in comments.
This commit is contained in:
parent
1b3ae5fa63
commit
abe41d805d
File diff suppressed because it is too large
Load Diff
|
@ -28,6 +28,7 @@ package processing.app.debug;
|
|||
* An exception with a line number attached that occurs
|
||||
* during either compile time or run time.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class RunnerException extends Exception /*RuntimeException*/ {
|
||||
protected String message;
|
||||
protected int codeIndex;
|
||||
|
@ -64,6 +65,10 @@ public class RunnerException extends Exception /*RuntimeException*/ {
|
|||
}
|
||||
|
||||
|
||||
public RunnerException(Exception e) {
|
||||
this(e.getMessage(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override getMessage() in Throwable, so that I can set
|
||||
* the message text outside the constructor.
|
||||
|
|
|
@ -35,6 +35,14 @@ import processing.core.PApplet;
|
|||
|
||||
public class PreferencesMap extends HashMap<String, String> {
|
||||
|
||||
public PreferencesMap(PreferencesMap prefs) {
|
||||
super(prefs);
|
||||
}
|
||||
|
||||
public PreferencesMap() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a property list file and put kev/value pairs into the Map
|
||||
*
|
||||
|
@ -67,6 +75,32 @@ public class PreferencesMap extends HashMap<String, String> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Map<String, PreferenceMap> where the keys are the first level
|
||||
* of the current mapping. E.g. the folowing mapping:<br />
|
||||
*
|
||||
* <pre>
|
||||
* Map (
|
||||
* alpha.some.keys = v1
|
||||
* alpha.other.keys = v2
|
||||
* beta.some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* will generate the following result:
|
||||
*
|
||||
* <pre>
|
||||
* alpha = Map(
|
||||
* some.keys = v1
|
||||
* other.keys = v2
|
||||
* )
|
||||
* beta = Map(
|
||||
* some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, PreferencesMap> createFirstLevelMap() {
|
||||
Map<String, PreferencesMap> res = new HashMap<String, PreferencesMap>();
|
||||
for (String key : keySet()) {
|
||||
|
@ -84,5 +118,40 @@ public class PreferencesMap extends HashMap<String, String> {
|
|||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PreferenceMap using a subtree of the current mapping. E.g.
|
||||
* with the folowing mapping:<br />
|
||||
*
|
||||
* <pre>
|
||||
* Map (
|
||||
* alpha.some.keys = v1
|
||||
* alpha.other.keys = v2
|
||||
* beta.some.keys = v3
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* a call to createSubTree("alpha") will generate the following result:
|
||||
*
|
||||
* <pre>
|
||||
* Map(
|
||||
* some.keys = v1
|
||||
* other.keys = v2
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
public PreferencesMap createSubTree(String parent) {
|
||||
PreferencesMap res = new PreferencesMap();
|
||||
parent += ".";
|
||||
int parentLen = parent.length();
|
||||
for (String key : keySet()) {
|
||||
if (key.startsWith(parent))
|
||||
res.put(key.substring(parentLen), get(key));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 2330591567444282843L;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package processing.app.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StringReplacer {
|
||||
|
||||
public static String[] formatAndSplit(String src, Map<String, String> dict)
|
||||
throws Exception {
|
||||
// Do a replace with dictionary
|
||||
src = StringReplacer.replaceFromMapping(src, dict);
|
||||
|
||||
// Split the resulting string in arguments
|
||||
return quotedSplit(src, '"', false);
|
||||
}
|
||||
|
||||
public static String[] quotedSplit(String src, char escapeChar,
|
||||
boolean acceptEmptyArguments) throws Exception {
|
||||
String quote = "" + escapeChar;
|
||||
List<String> res = new ArrayList<String>();
|
||||
String escapedArg = null;
|
||||
boolean escaping = false;
|
||||
for (String i : src.split(" ")) {
|
||||
if (!escaping) {
|
||||
if (!i.startsWith(quote)) {
|
||||
if (!i.trim().isEmpty() || acceptEmptyArguments)
|
||||
res.add(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
escaping = true;
|
||||
i = i.substring(1);
|
||||
escapedArg = "";
|
||||
}
|
||||
|
||||
if (!i.endsWith(quote)) {
|
||||
escapedArg += i + " ";
|
||||
continue;
|
||||
}
|
||||
|
||||
escapedArg += i.substring(0, i.length() - 1);
|
||||
if (!escapedArg.trim().isEmpty() || acceptEmptyArguments)
|
||||
res.add(escapedArg);
|
||||
escaping = false;
|
||||
}
|
||||
if (escaping)
|
||||
throw new Exception("Invalid quoting: no closing '" + escapeChar
|
||||
+ "' char found.");
|
||||
return res.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static String replaceFromMapping(String src, Map<String, String> map) {
|
||||
return replaceFromMapping(src, map, "{", "}");
|
||||
}
|
||||
|
||||
public static String replaceFromMapping(String src, Map<String, String> map,
|
||||
String leftDelimiter, String rightDelimiter) {
|
||||
for (String k : map.keySet()) {
|
||||
String keyword = leftDelimiter + k + rightDelimiter;
|
||||
src = src.replace(keyword, map.get(k));
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +1,22 @@
|
|||
#########Compiler Recipe#################################
|
||||
##compile c object files
|
||||
##Default.recipe, overide if overide exists, these defauls should remain the same, if you need to change them do it as an overide.
|
||||
|
||||
#default.recipe.c.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10}
|
||||
#default.recipe.cpp.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10}
|
||||
#default.recipe.ar.pattern={0}{1}|{2}|{3}{4}|{5}
|
||||
#default.recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-o|{5}{6}.elf|{7}|{8}|-L{9}|-lm
|
||||
#default.recipe.objcopy.eep.pattern={0}{1}|{2}|{3}.elf|{4}.eep
|
||||
#default.recipe.objcopy.hex.pattern={0}{1}|{2}|{3}.elf|{4}.hex
|
||||
# AVR compile variables
|
||||
# ---------------------
|
||||
|
||||
########avr compile pattern ##########
|
||||
#recipe.c.o.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-D{7=ARDUINO}={6=Base.REVISION}{7=-I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=OBJECT_NAME}
|
||||
#object name seems to have build path in it.
|
||||
recipe.c.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10}
|
||||
|
||||
|
||||
##compile cc object files
|
||||
#recipe.cc.o.pattern={0=compiler.path}{1=compiler.cc.cmd}{2=compiler.c.flags}{3=compiler.cpudef}{4=build.mcu}-DF_CPU={5=build.f_cpu}-DARDUINO={6=Base.REVISION}{-7=I/INCLUDE_PATHS} {8=SOURCE_NAME} -o{9=BUILD_PATH}{10=OBJECT_NAME}
|
||||
recipe.cpp.o.pattern={0}{1}|{2}|{3}{4}|-DF_CPU={5}|-D{6}={7}|{8}|{9}|-o|{10}
|
||||
##create archives
|
||||
#recipe.ar.pattern={0=compiler.path}{1=compiler.ar.cmd}{2=compiler.ar.flags}{3=BUILD_PATH}{4=CORE_NAME=core.a}{5=BUILD_PATH}{6=OBJECT_NAME}
|
||||
recipe.ar.pattern={0}{1}|{2}|{3}{4}|{5}
|
||||
|
||||
##combine gc-sections| archives, and objects
|
||||
#recipe.c.combine.pattern={0=compiler.path}{1=compiler.c.cmd}{2=compiler.combine.flags}{3=compiler.cpudef}{4=build.mcu} -o {5=BUILD_PATH}{6=SOURCE_NAME}.elf {7=BUILD_PATH}{8=SOURCE_NAME}.o {9=BUILD_PATH}{10=CORE_NAME=core.a} -L{11=BUILD_PATH} -lm
|
||||
#recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-o|{5}{6}.elf|{7}{8}|{9}|-L{10}|-lm
|
||||
recipe.c.combine.pattern={0}{1}|{2}|{3}{4}|-o|{5}{6}.elf|{7}|{8}|-L{9}|-lm
|
||||
|
||||
##create eeprom
|
||||
#recipe.objcopy.eep.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.eep.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.eep
|
||||
recipe.objcopy.eep.pattern={0}{1}|{2}|{3}.elf|{4}.eep
|
||||
|
||||
##create hex
|
||||
#recipe.objcopy.hex.pattern={0=compiler.path}{1=compiler.objcopy.cmd}{2=compiler.objcopy.elf.flags} {3=BUILD_PATH}{4=SOURCE_NAME}.elf {5=BUILD_PATH}{6=SOURCE_NAME}.hex
|
||||
recipe.objcopy.hex.pattern={0}{1}|{2}|{3}.elf|{4}.hex
|
||||
|
||||
|
||||
|
||||
########################################################
|
||||
name=Arduino
|
||||
#compiler.path Official default is correct, only need to change this if you want to overide the initial default
|
||||
# Default "compiler.path" is correct, change only if you want to overidde the initial value
|
||||
#compiler.path={0}/hardware/tools/avr/bin/
|
||||
compiler.c.cmd=avr-gcc
|
||||
compiler.c.flags=|-c|-g|-Os|-w|-ffunction-sections|-fdata-sections
|
||||
compiler.c.elf.flags=|-Os|-Wl,--gc-sections
|
||||
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections
|
||||
compiler.c.elf.cmd=avr-gcc
|
||||
compiler.S.flags=|-c|-g|-assembler-with-cpp
|
||||
compiler.S.flags=-c -g -assembler-with-cpp
|
||||
compiler.cpp.cmd=avr-g++
|
||||
compiler.cpp.flags=|-c|-g|-Os|-w|-fno-exceptions|-ffunction-sections|-fdata-sections
|
||||
compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections
|
||||
compiler.ar.cmd=avr-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=avr-objcopy
|
||||
compiler.objcopy.eep.flags=|-O|ihex|-j|.eeprom|--set-section-flags=.eeprom=alloc,load|--no-change-warnings|--change-section-lma|.eeprom=0
|
||||
compiler.elf2hex.flags=|-O|ihex|-R|.eeprom
|
||||
compiler.objcopy.eep.flags=-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0
|
||||
compiler.elf2hex.flags=-O ihex -R .eeprom
|
||||
compiler.elf2hex.cmd=avr-objcopy
|
||||
compiler.ldflags=
|
||||
compiler.cpudef=-mmcu=
|
||||
|
@ -62,3 +26,26 @@ compiler.define=-DARDUINO=
|
|||
library.path=./hardware/arduino/cores/arduino
|
||||
library.core.path=./libraries
|
||||
|
||||
# AVR compile patterns
|
||||
# --------------------
|
||||
|
||||
## Compile c files
|
||||
recipe.c.o.pattern={toolchain_path}{compiler.c.cmd} {compiler.c.flags} {compiler.cpudef}{build.mcu} -DF_CPU={build.f_cpu} -D{software}={ide_version} {includes} {source_file} -o {object_file}
|
||||
|
||||
## Compile c++ files
|
||||
recipe.cpp.o.pattern={toolchain_path}{compiler.cpp.cmd} {compiler.cpp.flags} {compiler.cpudef}{build.mcu} -DF_CPU={build.f_cpu} -D{software}={ide_version} {includes} {source_file} -o {object_file}
|
||||
|
||||
## Create archives
|
||||
recipe.ar.pattern={toolchain_path}{compiler.ar.cmd} {compiler.ar.flags} {build_path}{archive_file} {object_file}
|
||||
|
||||
## Combine gc-sections, archives, and objects
|
||||
recipe.c.combine.pattern={toolchain_path}{compiler.c.elf.cmd} {compiler.c.elf.flags} {compiler.cpudef}{build.mcu} -o {build_path}{project_name}.elf {object_files} {build_path}{archive_file} -L{build_path} -lm
|
||||
|
||||
## Create eeprom
|
||||
recipe.objcopy.eep.pattern={toolchain_path}{compiler.objcopy.cmd} {compiler.objcopy.eep.flags} {build_path}{project_name}.elf {build_path}{project_name}.eep
|
||||
|
||||
## Create hex
|
||||
recipe.objcopy.hex.pattern={toolchain_path}{compiler.elf2hex.cmd} {compiler.elf2hex.flags} {build_path}{project_name}.elf {build_path}{project_name}.hex
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue