mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Allow variants to define an initVariant() function that is called at startup.
See #2080
This commit is contained in:
parent
11e02db954
commit
40270306e0
@ -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[] {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user