Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/arduino/Arduino.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2014-06-19 21:49:47 +0400
committerCristian Maglie <c.maglie@bug.st>2014-06-19 21:49:47 +0400
commit40270306e0803d4396338310c955153c0deb9371 (patch)
tree3c88db3f5a03729db651f74573e979023acc4827
parent11e02db9541f9ac616d4a98c0eb516d13aa26e55 (diff)
Allow variants to define an initVariant() function that is called at startup.
See #2080
-rw-r--r--app/src/processing/app/debug/Compiler.java35
-rw-r--r--hardware/arduino/cores/arduino/main.cpp7
2 files changed, 29 insertions, 13 deletions
diff --git a/app/src/processing/app/debug/Compiler.java b/app/src/processing/app/debug/Compiler.java
index 14a7377c3..919da722d 100644
--- a/app/src/processing/app/debug/Compiler.java
+++ b/app/src/processing/app/debug/Compiler.java
@@ -186,19 +186,28 @@ public class Compiler implements MessageConsumer {
includePaths.remove(includePaths.size() - 1);
}
- // 3. compile the core, outputting .o files to <buildPath> and then
- // collecting them into the core.a library file.
-
- sketch.setCompilingProgress(50);
- includePaths.clear();
- includePaths.add(corePath); // include path for core only
- if (variantPath != null) includePaths.add(variantPath);
- List<File> coreObjectFiles =
- compileFiles(avrBasePath, buildPath, includePaths,
- findFilesInPath(corePath, "S", true),
- findFilesInPath(corePath, "c", true),
- findFilesInPath(corePath, "cpp", true),
- boardPreferences);
+ // 3. compile the core, outputting .o files to <buildPath> and then
+ // collecting them into the core.a library file.
+
+ sketch.setCompilingProgress(50);
+ includePaths.clear();
+ includePaths.add(corePath); // include path for core only
+ if (variantPath != null)
+ includePaths.add(variantPath);
+ List<File> coreObjectFiles = compileFiles( //
+ avrBasePath, buildPath, includePaths, //
+ findFilesInPath(corePath, "S", true), //
+ findFilesInPath(corePath, "c", true), //
+ findFilesInPath(corePath, "cpp", true), //
+ boardPreferences);
+
+ if (variantPath != null)
+ objectFiles.addAll(compileFiles( //
+ avrBasePath, buildPath, includePaths, //
+ findFilesInPath(variantPath, "S", true), //
+ findFilesInPath(variantPath, "c", true), //
+ findFilesInPath(variantPath, "cpp", true), //
+ boardPreferences));
String runtimeLibraryName = buildPath + File.separator + "core.a";
List baseCommandAR = new ArrayList(Arrays.asList(new String[] {
diff --git a/hardware/arduino/cores/arduino/main.cpp b/hardware/arduino/cores/arduino/main.cpp
index 0ad696215..091c365fc 100644
--- a/hardware/arduino/cores/arduino/main.cpp
+++ b/hardware/arduino/cores/arduino/main.cpp
@@ -19,10 +19,17 @@
#include <Arduino.h>
+// Weak empty variant initialization function.
+// May be redefined by variant files.
+void initVariant() __attribute__((weak));
+void initVariant() { }
+
int main(void)
{
init();
+ initVariant();
+
#if defined(USBCON)
USBDevice.attach();
#endif