33
33
34
34
import java .io .*;
35
35
import java .util .*;
36
- import java .util .zip .*;
37
36
import java .text .MessageFormat ;
38
37
39
38
@@ -54,7 +53,6 @@ public class Compiler implements MessageConsumer {
54
53
RunnerException exception ;
55
54
56
55
HashMap <String , String > configPreferences ;
57
- HashMap <String , String > boardPreferences ;
58
56
HashMap <String , String > platformPreferences ;
59
57
60
58
String avrBasePath ;
@@ -84,8 +82,6 @@ public boolean compile(Sketch sketch,
84
82
this .verbose = verbose ;
85
83
objectFiles = new ArrayList <File >();
86
84
87
- // the pms object isn't used for anything but storage
88
- MessageStream pms = new MessageStream (this );
89
85
Map <String , String > boardPreferences = Base .getBoardPreferences ();
90
86
91
87
//Check for null platform, and use system default if not found
@@ -153,25 +149,20 @@ public boolean compile(Sketch sketch,
153
149
String variant = boardPreferences .get ("build.variant" );
154
150
String variantPath = null ;
155
151
156
- String pins = configPreferences .get ("build.pins" );
157
- String pinsPath = null ;
158
-
159
152
if (variant != null ) {
160
153
if (variant .indexOf (':' ) == -1 ) {
161
- Target t = Base .getTarget ();
162
- File variantFolder = new File (new File (t .getFolder (), "variants" ), variant );
163
- variantPath = variantFolder .getAbsolutePath ();
154
+ Target t = Base .getTarget ();
155
+ File variantFolder = new File (new File (t .getFolder (), "variants" ), variant );
156
+ variantPath = variantFolder .getAbsolutePath ();
164
157
} else {
165
- Target t = Base .targetsTable .get (variant .substring (0 , variant .indexOf (':' )));
166
- File variantFolder = new File (t .getFolder (), "variants" );
167
- variantFolder = new File (variantFolder , variant .substring (variant .indexOf (':' ) + 1 ));
168
- variantPath = variantFolder .getAbsolutePath ();
158
+ Target t = Base .targetsTable .get (variant .substring (0 , variant .indexOf (':' )));
159
+ File variantFolder = new File (t .getFolder (), "variants" );
160
+ variantFolder = new File (variantFolder , variant .substring (variant .indexOf (':' ) + 1 ));
161
+ variantPath = variantFolder .getAbsolutePath ();
169
162
}
170
163
}
171
164
172
-
173
165
// 0. include paths for core + all libraries
174
-
175
166
sketch .setCompilingProgress (20 );
176
167
ArrayList <String > includePaths = new ArrayList <String >();
177
168
includePaths .add (corePath );
@@ -224,7 +215,7 @@ public boolean compile(Sketch sketch,
224
215
System .out .println ("3. compileCore" );
225
216
System .out .println ("corePath: " + corePath );
226
217
sketch .setCompilingProgress (50 );
227
- compileCore (avrBasePath , buildPath , corePath , pins , pinsPath , configPreferences );
218
+ compileCore (avrBasePath , buildPath , corePath , variant , variantPath , configPreferences );
228
219
229
220
230
221
/*
@@ -859,7 +850,9 @@ void compileSketch(String avrBasePath, String buildPath, ArrayList<String> inclu
859
850
860
851
// 2. compile the libraries, outputting .o files to:
861
852
// <buildPath>/<library>/
862
- void compileLibraries (String avrBasePath , String buildPath , ArrayList <String > includePaths , HashMap <String , String > configPreferences )
853
+ void compileLibraries (String avrBasePath , String buildPath ,
854
+ ArrayList <String > includePaths ,
855
+ HashMap <String , String > configPreferences )
863
856
throws RunnerException
864
857
{
865
858
System .out .println ("compileLibraries: start" );
@@ -883,30 +876,32 @@ void compileLibraries (String avrBasePath, String buildPath, ArrayList<String> i
883
876
findFilesInFolder (libraryFolder , "S" , false ),
884
877
findFilesInFolder (libraryFolder , "c" , false ),
885
878
findFilesInFolder (libraryFolder , "cpp" , false ),
886
- boardPreferences ));
879
+ configPreferences ));
887
880
outputFolder = new File (outputFolder , "utility" );
888
881
createFolder (outputFolder );
889
882
objectFiles .addAll (
890
883
compileFiles (avrBasePath , outputFolder .getAbsolutePath (), includePaths ,
891
884
findFilesInFolder (utilityFolder , "S" , false ),
892
885
findFilesInFolder (utilityFolder , "c" , false ),
893
886
findFilesInFolder (utilityFolder , "cpp" , false ),
894
- boardPreferences ));
887
+ configPreferences ));
895
888
// other libraries should not see this library's utility/ folder
896
889
includePaths .remove (includePaths .size () - 1 );
897
890
}
898
891
}
899
892
900
893
// 3. compile the core, outputting .o files to <buildPath> and then
901
894
// collecting them into the core.a library file.
902
- void compileCore (String avrBasePath , String buildPath , String corePath , String pins , String pinsPath , HashMap <String , String > configPreferences )
895
+ void compileCore (String avrBasePath , String buildPath ,
896
+ String corePath , String variant , String variantPath ,
897
+ HashMap <String , String > configPreferences )
903
898
throws RunnerException
904
899
{
905
900
System .out .println ("compileCore(...) start" );
906
901
907
902
ArrayList <String > includePaths = new ArrayList ();
908
903
includePaths .add (corePath ); //include core path only
909
- if (pinsPath != null ) includePaths .add (pinsPath );
904
+ if (variantPath != null ) includePaths .add (variantPath );
910
905
911
906
//debug includePaths
912
907
System .out .println ("includePaths: " );
@@ -952,13 +947,15 @@ void compileCore (String avrBasePath, String buildPath, String corePath, String
952
947
}
953
948
954
949
// 4. link it all together into the .elf file
955
- void compileLink (String avrBasePath , String buildPath , String corePath , ArrayList <String > includePaths , HashMap <String , String > configPreferences )
950
+ void compileLink (String avrBasePath , String buildPath ,
951
+ String corePath , ArrayList <String > includePaths ,
952
+ HashMap <String , String > configPreferences )
956
953
throws RunnerException
957
954
{
958
955
// For atmega2560, need --relax linker option to link larger
959
956
// programs correctly.
960
957
String optRelax = "" ;
961
- if (boardPreferences .get ("build.mcu" ).equals ("atmega2560" ))
958
+ if (configPreferences .get ("build.mcu" ).equals ("atmega2560" ))
962
959
optRelax = ",--relax" ;
963
960
964
961
System .out .println ("compileLink: start" );
0 commit comments