mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
Now appending main() to the user's sketch in preparation for making the Arduino core a library (.a) file.
This commit is contained in:
parent
2e1776862e
commit
41d50ae572
@ -1451,7 +1451,7 @@ public class Sketch {
|
||||
// java mode, since that's required
|
||||
String className =
|
||||
preprocessor.write(bigCode.toString(), buildPath,
|
||||
suggestedClassName, codeFolderPackages);
|
||||
suggestedClassName, codeFolderPackages, target);
|
||||
if (className == null) {
|
||||
throw new RunnerException("Could not find main class");
|
||||
// this situation might be perfectly fine,
|
||||
|
@ -104,7 +104,8 @@ public class PdePreprocessor {
|
||||
//public String write(String program, String buildPath, String name,
|
||||
// String extraImports[]) throws java.lang.Exception {
|
||||
public String write(String program, String buildPath,
|
||||
String name, String codeFolderPackages[])
|
||||
String name, String codeFolderPackages[],
|
||||
Target target)
|
||||
throws java.lang.Exception {
|
||||
// if the program ends with no CR or LF an OutOfMemoryError will happen.
|
||||
// not gonna track down the bug now, so here's a hack for it:
|
||||
@ -344,7 +345,7 @@ public class PdePreprocessor {
|
||||
//emitter.print(rootNode);
|
||||
//emitter.translationUnit(parser.getAST());
|
||||
|
||||
writeFooter(stream);
|
||||
writeFooter(stream, target);
|
||||
stream.close();
|
||||
|
||||
// if desired, serialize the parse tree to an XML file. can
|
||||
@ -457,20 +458,23 @@ public class PdePreprocessor {
|
||||
*
|
||||
* @param out PrintStream to write it to.
|
||||
*/
|
||||
void writeFooter(PrintStream out) {
|
||||
//out.print("}");
|
||||
void writeFooter(PrintStream out, Target target) throws java.lang.Exception {
|
||||
// Open the file main.cxx and copy its entire contents to the bottom of the
|
||||
// generated sketch .cpp file...
|
||||
|
||||
/* if (programType == STATIC) {
|
||||
// close off draw() definition
|
||||
out.print("noLoop(); ");
|
||||
out.print("}");
|
||||
String mainFileName = target.getPath() + File.separator + "main.cxx";
|
||||
FileReader reader = null;
|
||||
reader = new FileReader(mainFileName);
|
||||
|
||||
LineNumberReader mainfile = new LineNumberReader(reader);
|
||||
|
||||
String line;
|
||||
while ((line = mainfile.readLine()) != null) {
|
||||
out.print(line + "\n");
|
||||
}
|
||||
|
||||
if (programType < JAVA) {
|
||||
// close off the class definition
|
||||
out.print("}");
|
||||
}
|
||||
*/ }
|
||||
mainfile.close();
|
||||
}
|
||||
|
||||
|
||||
static String advClassName = "";
|
||||
|
12
targets/arduino/main.cxx
Executable file
12
targets/arduino/main.cxx
Executable file
@ -0,0 +1,12 @@
|
||||
int main(void)
|
||||
{
|
||||
init();
|
||||
|
||||
setup();
|
||||
|
||||
for (;;)
|
||||
loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ void shiftOut(int dataPin, int clockPin, int bitOrder, byte val) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
void init()
|
||||
{
|
||||
// this needs to be called before setup() or some functions won't
|
||||
// work there
|
||||
@ -626,11 +626,4 @@ int main(void)
|
||||
#else
|
||||
UCSRB = 0;
|
||||
#endif
|
||||
|
||||
setup();
|
||||
|
||||
for (;;)
|
||||
loop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -66,6 +66,8 @@ extern "C"{
|
||||
typedef uint8_t boolean;
|
||||
typedef uint8_t byte;
|
||||
|
||||
void init(void);
|
||||
|
||||
void pinMode(int, int);
|
||||
void digitalWrite(int, int);
|
||||
int digitalRead(int);
|
||||
@ -74,9 +76,9 @@ void analogWrite(int, int);
|
||||
|
||||
void beginSerial(long);
|
||||
void serialWrite(unsigned char);
|
||||
int serialAvailable();
|
||||
int serialRead();
|
||||
void serialFlush();
|
||||
int serialAvailable(void);
|
||||
int serialRead(void);
|
||||
void serialFlush(void);
|
||||
void printMode(int);
|
||||
void printByte(unsigned char c);
|
||||
void printNewline();
|
||||
|
Loading…
x
Reference in New Issue
Block a user