Skip to content

Commit 082f12b

Browse files
committed
Merge remote-tracking branch 'matthijs/ide-1.5.x-platform.local.txt' into ide-1.5.x
2 parents 06d75a4 + a89f5e6 commit 082f12b

File tree

3 files changed

+40
-10
lines changed

3 files changed

+40
-10
lines changed

app/src/processing/app/debug/Compiler.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,14 @@ private PreferencesMap createBuildPreferences(String _buildPath,
197197
targetArch = targetPlatform.getId();
198198
p.put("build.arch", targetArch.toUpperCase());
199199

200-
if (!p.containsKey("compiler.path"))
200+
// Platform.txt should define its own compiler.path. For
201+
// compatibility with earlier 1.5 versions, we define a (ugly,
202+
// avr-specific) default for it, but this should be removed at some
203+
// point.
204+
if (!p.containsKey("compiler.path")) {
205+
System.err.println(_("Third-party platform.txt does not define compiler.path. Please report this to the third-party hardware maintainer."));
201206
p.put("compiler.path", Base.getAvrBasePath());
207+
}
202208

203209
// Core folder
204210
TargetPlatform tp = corePlatform;

app/src/processing/app/debug/TargetPlatform.java

+14
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,20 @@ public TargetPlatform(String _name, File _folder, TargetPackage parent)
110110
format(_("Error loading {0}"), platformsFile.getAbsolutePath()), e);
111111
}
112112

113+
// Allow overriding values in platform.txt. This allows changing
114+
// platform.txt (e.g. to use a system-wide toolchain), without
115+
// having to modify platform.txt (which, when running from git,
116+
// prevents files being marked as changed).
117+
File localPlatformsFile = new File(folder, "platform.local.txt");
118+
try {
119+
if (localPlatformsFile.exists() && localPlatformsFile.canRead()) {
120+
preferences.load(localPlatformsFile);
121+
}
122+
} catch (IOException e) {
123+
throw new TargetPlatformException(
124+
format(_("Error loading {0}"), localPlatformsFile.getAbsolutePath()), e);
125+
}
126+
113127
File progFile = new File(folder, "programmers.txt");
114128
try {
115129
if (progFile.exists() && progFile.canRead()) {

hardware/arduino/avr/platform.txt

+19-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ version=1.5.6
1212
# ---------------------
1313

1414
# Default "compiler.path" is correct, change only if you want to overidde the initial value
15-
#compiler.path={ide.path}/tools/avr/bin/..
15+
compiler.path={runtime.ide.path}/hardware/tools/avr/bin/
1616
compiler.c.cmd=avr-gcc
1717
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
1818
compiler.c.elf.flags=-Os -Wl,--gc-sections
@@ -28,32 +28,42 @@ compiler.elf2hex.flags=-O ihex -R .eeprom
2828
compiler.elf2hex.cmd=avr-objcopy
2929
compiler.ldflags=
3030
compiler.size.cmd=avr-size
31-
# this can be overriden in boards.txt
31+
32+
# This can be overriden in boards.txt
3233
build.extra_flags=
3334

35+
# These can be overridden in platform.local.txt
36+
compiler.c.extra_flags=
37+
compiler.c.elf.extra_flags=
38+
compiler.S.extra_flags=
39+
compiler.cpp.extra_flags=
40+
compiler.ar.extra_flags=
41+
compiler.objcopy.eep.extra_flags=
42+
compiler.elf2hex.extra_flags=
43+
3444
# AVR compile patterns
3545
# --------------------
3646

3747
## Compile c files
38-
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
48+
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.c.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
3949

4050
## Compile c++ files
41-
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
51+
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.cpp.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
4252

4353
## Compile S files
44-
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
54+
recipe.S.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.S.flags} -mmcu={build.mcu} -DF_CPU={build.f_cpu} -DARDUINO={runtime.ide.version} -DARDUINO_{build.board} -DARDUINO_ARCH_{build.arch} {compiler.S.extra_flags} {build.extra_flags} {includes} "{source_file}" -o "{object_file}"
4555

4656
## Create archives
47-
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{build.path}/{archive_file}" "{object_file}"
57+
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{build.path}/{archive_file}" "{object_file}"
4858

4959
## Combine gc-sections, archives, and objects
50-
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
60+
recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} {compiler.c.elf.extra_flags} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm
5161

5262
## Create eeprom
53-
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
63+
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
5464

5565
## Create hex
56-
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
66+
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
5767

5868
## Compute size
5969
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"

0 commit comments

Comments
 (0)