@@ -69,9 +69,14 @@ public void beforeAddingSourceRules(IAutoBuildMakeRules makeRules,
69
69
makeRules .getSourceFilesToBuild ().add (sloeberInoCppFile );
70
70
}
71
71
generateAwkFile (autoBuildConfData );
72
+ generateArduinoSizeCommandFile (autoBuildConfData );
73
+
72
74
super .beforeAddingSourceRules (makeRules , autoBuildConfData );
73
75
}
74
76
77
+
78
+
79
+
75
80
@ Override
76
81
public boolean invokeBuild (IBuilder builder , int kind , String targetName , IAutoBuildConfigurationDescription autoData ,
77
82
IMarkerGenerator markerGenerator , IConsole console , IProgressMonitor monitor ) throws CoreException {
@@ -122,6 +127,33 @@ public SloeberBuilderExtension() {
122
127
// Nothing to do here
123
128
}
124
129
130
+
131
+ @ SuppressWarnings ("nls" )
132
+ private static void generateArduinoSizeCommandFile (IAutoBuildConfigurationDescription autoBuildConfData ) {
133
+ if (!isWindows ) {
134
+ return ;
135
+ }
136
+ IFile sizeCommandIFile = autoBuildConfData .getBuildFolder ().getFile ("arduino-size.bat" );
137
+ SloeberConfiguration confDesc = SloeberConfiguration .getFromAutoBuildConfDesc (autoBuildConfData );
138
+
139
+ File sizeCommandFile = sizeCommandIFile .getLocation ().toFile ();
140
+ String content = Common .getBuildEnvironmentVariable (confDesc , "sloeber.size_command.awk" , EMPTY );
141
+
142
+ try {
143
+ if (sizeCommandFile .exists ()) {
144
+ String curContent = FileUtils .readFileToString (sizeCommandFile , Charset .defaultCharset ());
145
+ if (!curContent .equals (content )) {
146
+ sizeCommandFile .delete ();
147
+ }
148
+ }
149
+ if (!sizeCommandFile .exists ()) {
150
+ FileUtils .write (sizeCommandFile , content , Charset .defaultCharset ());
151
+ }
152
+ } catch (IOException e ) {
153
+ e .printStackTrace ();
154
+ }
155
+ }
156
+
125
157
@ SuppressWarnings ("nls" )
126
158
private static void generateAwkFile (IAutoBuildConfigurationDescription autoBuildConfData ) {
127
159
IFile sizeAwkFile1 = autoBuildConfData .getBuildFolder ().getFile ("size.awk" );
@@ -144,7 +176,15 @@ private static void generateAwkFile(IAutoBuildConfigurationDescription autoBuild
144
176
awkContent += "\" }" ;
145
177
146
178
try {
147
- FileUtils .write (sizeAwkFile , awkContent , Charset .defaultCharset ());
179
+ if (sizeAwkFile .exists ()) {
180
+ String curContent = FileUtils .readFileToString (sizeAwkFile , Charset .defaultCharset ());
181
+ if (!curContent .equals (awkContent )) {
182
+ sizeAwkFile .delete ();
183
+ }
184
+ }
185
+ if (!sizeAwkFile .exists ()) {
186
+ FileUtils .write (sizeAwkFile , awkContent , Charset .defaultCharset ());
187
+ }
148
188
} catch (IOException e ) {
149
189
e .printStackTrace ();
150
190
}
0 commit comments