@@ -93,72 +93,72 @@ public boolean compile(Sketch sketch,
93
93
94
94
List <File > objectFiles = new ArrayList <File >();
95
95
96
- List includePaths = new ArrayList ();
97
- includePaths . add ( corePath );
98
-
99
- String runtimeLibraryName = buildPath + File . separator + "core.a" ;
100
-
101
- // 1. compile the core, outputting .o files to <buildPath> and then
102
- // collecting them into the core.a library file.
103
-
104
- List < File > coreObjectFiles =
105
- compileFiles ( avrBasePath , buildPath , includePaths ,
106
- findFilesInPath ( corePath , "S" , true ),
107
- findFilesInPath ( corePath , "c" , true ) ,
108
- findFilesInPath (corePath , "cpp " , true ),
109
- boardPreferences );
110
-
111
- List baseCommandAR = new ArrayList ( Arrays . asList ( new String [] {
112
- avrBasePath + "avr-ar" ,
113
- "rcs" ,
114
- runtimeLibraryName
115
- }));
116
-
117
- for ( File file : coreObjectFiles ) {
118
- List commandAR = new ArrayList ( baseCommandAR );
119
- commandAR . add ( file . getAbsolutePath ());
120
- execAsynchronously ( commandAR );
121
- }
122
-
123
- // 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
124
-
125
- // use library directories as include paths for all libraries
126
- for ( File file : sketch . getImportedLibraries ()) {
127
- includePaths . add ( file . getPath () );
128
- }
129
-
130
- for ( File libraryFolder : sketch . getImportedLibraries ()) {
131
- File outputFolder = new File ( buildPath , libraryFolder . getName ());
132
- File utilityFolder = new File ( libraryFolder , "utility" );
133
- createFolder ( outputFolder );
134
- // this library can use includes in its utility/ folder
135
- includePaths . add ( utilityFolder . getAbsolutePath ());
136
- objectFiles . addAll (
137
- compileFiles ( avrBasePath , outputFolder . getAbsolutePath (), includePaths ,
138
- findFilesInFolder ( libraryFolder , "S" , false ),
139
- findFilesInFolder ( libraryFolder , "c" , false ),
140
- findFilesInFolder ( libraryFolder , "cpp" , false ),
141
- boardPreferences ));
142
- outputFolder = new File ( outputFolder , "utility" );
143
- createFolder ( outputFolder );
144
- objectFiles . addAll (
145
- compileFiles (avrBasePath , outputFolder . getAbsolutePath () , includePaths ,
146
- findFilesInFolder ( utilityFolder , "S" , false ),
147
- findFilesInFolder ( utilityFolder , "c" , false ),
148
- findFilesInFolder ( utilityFolder , "cpp" , false ),
149
- boardPreferences ) );
150
- // other libraries should not see this library's utility/ folder
151
- includePaths . remove ( includePaths . size () - 1 ) ;
152
- }
153
-
154
- // 3. compile the sketch (already in the buildPath)
155
-
156
- objectFiles . addAll (
157
- compileFiles ( avrBasePath , buildPath , includePaths ,
158
- findFilesInPath ( buildPath , "S" , false ),
159
- findFilesInPath ( buildPath , "c" , false ),
160
- findFilesInPath ( buildPath , "cpp" , false ),
161
- boardPreferences ));
96
+ // 0. include paths for core + all libraries
97
+
98
+ List includePaths = new ArrayList ();
99
+ includePaths . add ( corePath ) ;
100
+ for ( File file : sketch . getImportedLibraries ()) {
101
+ includePaths . add ( file . getPath ());
102
+ }
103
+
104
+ // 1. compile the sketch (already in the buildPath)
105
+
106
+ objectFiles . addAll (
107
+ compileFiles ( avrBasePath , buildPath , includePaths ,
108
+ findFilesInPath (buildPath , "S " , false ),
109
+ findFilesInPath ( buildPath , "c" , false ),
110
+ findFilesInPath ( buildPath , "cpp" , false ),
111
+ boardPreferences ));
112
+
113
+ // 2. compile the libraries, outputting .o files to: <buildPath>/<library>/
114
+
115
+ for ( File libraryFolder : sketch . getImportedLibraries ()) {
116
+ File outputFolder = new File ( buildPath , libraryFolder . getName ());
117
+ File utilityFolder = new File ( libraryFolder , "utility" );
118
+ createFolder ( outputFolder );
119
+ // this library can use includes in its utility/ folder
120
+ includePaths . add ( utilityFolder . getAbsolutePath () );
121
+ objectFiles . addAll (
122
+ compileFiles ( avrBasePath , outputFolder . getAbsolutePath (), includePaths ,
123
+ findFilesInFolder ( libraryFolder , "S" , false ),
124
+ findFilesInFolder ( libraryFolder , "c" , false ),
125
+ findFilesInFolder ( libraryFolder , "cpp" , false ),
126
+ boardPreferences ));
127
+ outputFolder = new File ( outputFolder , "utility" );
128
+ createFolder ( outputFolder );
129
+ objectFiles . addAll (
130
+ compileFiles ( avrBasePath , outputFolder . getAbsolutePath (), includePaths ,
131
+ findFilesInFolder ( utilityFolder , "S" , false ),
132
+ findFilesInFolder ( utilityFolder , "c" , false ),
133
+ findFilesInFolder ( utilityFolder , "cpp" , false ),
134
+ boardPreferences ));
135
+ // other libraries should not see this library's utility/ folder
136
+ includePaths . remove ( includePaths . size () - 1 );
137
+ }
138
+
139
+ // 3. compile the core, outputting .o files to <buildPath> and then
140
+ // collecting them into the core.a library file.
141
+
142
+ includePaths . clear ( );
143
+ includePaths . add ( corePath ); // include path for core only
144
+ List < File > coreObjectFiles =
145
+ compileFiles (avrBasePath , buildPath , includePaths ,
146
+ findFilesInPath ( corePath , "S" , true ),
147
+ findFilesInPath ( corePath , "c" , true ),
148
+ findFilesInPath ( corePath , "cpp" , true ),
149
+ boardPreferences );
150
+
151
+ String runtimeLibraryName = buildPath + File . separator + "core.a" ;
152
+ List baseCommandAR = new ArrayList ( Arrays . asList ( new String [] {
153
+ avrBasePath + "avr-ar" ,
154
+ "rcs" ,
155
+ runtimeLibraryName
156
+ }));
157
+ for ( File file : coreObjectFiles ) {
158
+ List commandAR = new ArrayList ( baseCommandAR );
159
+ commandAR . add ( file . getAbsolutePath ());
160
+ execAsynchronously ( commandAR );
161
+ }
162
162
163
163
// 4. link it all together into the .elf file
164
164
0 commit comments