1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Allow variants to define an initVariant() function that is called at startup.

See #2080
This commit is contained in:
Cristian Maglie 2014-06-19 19:49:47 +02:00
parent 11e02db954
commit 40270306e0
2 changed files with 28 additions and 12 deletions

View File

@ -186,19 +186,28 @@ public class Compiler implements MessageConsumer {
includePaths.remove(includePaths.size() - 1); includePaths.remove(includePaths.size() - 1);
} }
// 3. compile the core, outputting .o files to <buildPath> and then // 3. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file. // collecting them into the core.a library file.
sketch.setCompilingProgress(50); sketch.setCompilingProgress(50);
includePaths.clear(); includePaths.clear();
includePaths.add(corePath); // include path for core only includePaths.add(corePath); // include path for core only
if (variantPath != null) includePaths.add(variantPath); if (variantPath != null)
List<File> coreObjectFiles = includePaths.add(variantPath);
compileFiles(avrBasePath, buildPath, includePaths, List<File> coreObjectFiles = compileFiles( //
findFilesInPath(corePath, "S", true), avrBasePath, buildPath, includePaths, //
findFilesInPath(corePath, "c", true), findFilesInPath(corePath, "S", true), //
findFilesInPath(corePath, "cpp", true), findFilesInPath(corePath, "c", true), //
boardPreferences); 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"; String runtimeLibraryName = buildPath + File.separator + "core.a";
List baseCommandAR = new ArrayList(Arrays.asList(new String[] { List baseCommandAR = new ArrayList(Arrays.asList(new String[] {

View File

@ -19,10 +19,17 @@
#include <Arduino.h> #include <Arduino.h>
// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }
int main(void) int main(void)
{ {
init(); init();
initVariant();
#if defined(USBCON) #if defined(USBCON)
USBDevice.attach(); USBDevice.attach();
#endif #endif