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);
}
// 3. compile the core, outputting .o files to <buildPath> and then
// collecting them into the core.a library file.
// 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);
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[] {

View File

@ -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