6
6
import org .eclipse .cdt .core .envvar .IEnvironmentVariable ;
7
7
import org .eclipse .cdt .core .envvar .IEnvironmentVariableManager ;
8
8
import org .eclipse .cdt .core .settings .model .ICConfigurationDescription ;
9
+ import org .eclipse .core .resources .IProject ;
9
10
10
11
import io .sloeber .core .common .Common ;
11
12
import io .sloeber .core .common .Const ;
13
+ import io .sloeber .core .tools .Helpers ;
12
14
13
15
public class CompileOptions {
14
16
17
+
15
18
private Boolean myWarningLevel = new Boolean (true );
16
19
private boolean myAlternativeSizeCommand = false ;
17
- private String myAditional_CPP_CompileOptions = "" ; //$NON-NLS-1$
18
- private String myAditional_C_CompileOptions = "" ; //$NON-NLS-1$
19
- private String myAditional_C_andCPP_CompileOptions = "" ; //$NON-NLS-1$
20
+ private String my_CPP_CompileOptions = new String ();
21
+ private String my_C_CompileOptions = new String ();
22
+ private String my_C_andCPP_CompileOptions = new String ();
23
+ private String my_Assembly_CompileOptions = new String ();
24
+ private String my_Archive_CompileOptions = new String ();
25
+ private String my_Link_CompileOptions = new String ();
26
+ private String my_All_CompileOptions = new String ();
27
+
28
+
29
+
20
30
private static final String ENV_KEY_WARNING_LEVEL_OFF = "A.COMPILER.WARNING_FLAGS" ; //$NON-NLS-1$
21
31
private static final String ENV_KEY_WARNING_LEVEL_ON = "${A.COMPILER.WARNING_FLAGS.ALL}" ; //$NON-NLS-1$
22
- public static final String ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START + "EXTRA.COMPILE" ; //$NON-NLS-1$
23
- public static final String ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START
32
+ private static final String ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START + "EXTRA.COMPILE" ; //$NON-NLS-1$
33
+ private static final String ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START
24
34
+ "EXTRA.C.COMPILE" ; //$NON-NLS-1$
25
- public static final String ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START
35
+ private static final String ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START
26
36
+ "EXTRA.CPP.COMPILE" ; //$NON-NLS-1$
27
37
private static final String ENV_KEY_JANTJE_WARNING_LEVEL = Const .ENV_KEY_JANTJE_START + "WARNING_LEVEL" ; //$NON-NLS-1$
28
- public static final String ENV_KEY_JANTJE_SIZE_COMMAND = Const .ERASE_START + "ALT_SIZE_COMMAND" ; //$NON-NLS-1$
29
- public static final String ENV_KEY_JANTJE_SIZE_SWITCH = Const .ENV_KEY_JANTJE_START + "SIZE.SWITCH" ; //$NON-NLS-1$
38
+ private static final String ENV_KEY_JANTJE_SIZE_COMMAND = Const .ERASE_START + "ALT_SIZE_COMMAND" ; //$NON-NLS-1$
39
+ private static final String ENV_KEY_JANTJE_SIZE_SWITCH = Const .ENV_KEY_JANTJE_START + "SIZE.SWITCH" ; //$NON-NLS-1$
40
+ private static final String ENV_KEY_JANTJE_ASSEMBLY_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START + "EXTRA.ASSEMBLY" ; //$NON-NLS-1$
41
+ private static final String ENV_KEY_JANTJE_ARCHIVE_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START + "EXTRA.ARCHIVE" ; //$NON-NLS-1$
42
+ private static final String ENV_KEY_JANTJE_LINK_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START + "EXTRA.LINK" ; //$NON-NLS-1$
43
+ private static final String ENV_KEY_JANTJE_ALL_COMPILE_OPTIONS = Const .ENV_KEY_JANTJE_START + "EXTRA.ALL" ; //$NON-NLS-1$
30
44
31
45
/**
32
46
* gets the compile options stored in this configuration description. if the
@@ -50,55 +64,98 @@ public CompileOptions(ICConfigurationDescription confDesc) {
50
64
this .myAlternativeSizeCommand = var .getValue ().contains (ENV_KEY_JANTJE_SIZE_COMMAND );
51
65
var = contribEnv .getVariable (ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS , confDesc );
52
66
if (var != null )
53
- this .myAditional_C_andCPP_CompileOptions = var .getValue ();
67
+ this .my_C_andCPP_CompileOptions = var .getValue ();
54
68
var = contribEnv .getVariable (ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS , confDesc );
55
69
if (var != null )
56
- this .myAditional_C_CompileOptions = var .getValue ();
70
+ this .my_C_CompileOptions = var .getValue ();
57
71
var = contribEnv .getVariable (ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS , confDesc );
58
72
if (var != null )
59
- this .myAditional_CPP_CompileOptions = var .getValue ();
73
+ this .my_CPP_CompileOptions = var .getValue ();
74
+ var = contribEnv .getVariable (ENV_KEY_JANTJE_ASSEMBLY_COMPILE_OPTIONS , confDesc );
75
+ if (var != null )
76
+ this .my_Assembly_CompileOptions = var .getValue ();
77
+ var = contribEnv .getVariable (ENV_KEY_JANTJE_ARCHIVE_COMPILE_OPTIONS , confDesc );
78
+ if (var != null )
79
+ this .my_Archive_CompileOptions = var .getValue ();
80
+ var = contribEnv .getVariable (ENV_KEY_JANTJE_LINK_COMPILE_OPTIONS , confDesc );
81
+ if (var != null )
82
+ this .my_Link_CompileOptions = var .getValue ();
83
+ var = contribEnv .getVariable (ENV_KEY_JANTJE_ALL_COMPILE_OPTIONS , confDesc );
84
+ if (var != null )
85
+ this .my_All_CompileOptions = var .getValue ();
60
86
61
87
}
62
88
}
63
89
64
- public boolean isMyWarningLevel () {
90
+ public boolean isWarningLevel () {
65
91
return this .myWarningLevel .booleanValue ();
66
92
}
67
93
68
- public void setMyWarningLevel (boolean myWarningLevel ) {
94
+ public void setWarningLevel (boolean myWarningLevel ) {
69
95
this .myWarningLevel = new Boolean (myWarningLevel );
70
96
}
71
97
72
- public boolean isMyAlternativeSizeCommand () {
98
+ public boolean isAlternativeSizeCommand () {
73
99
return this .myAlternativeSizeCommand ;
74
100
}
75
101
76
- public void setMyAlternativeSizeCommand (boolean alternativeSizeCommand ) {
102
+ public void setAlternativeSizeCommand (boolean alternativeSizeCommand ) {
77
103
this .myAlternativeSizeCommand = alternativeSizeCommand ;
78
104
}
79
105
80
- public String getMyAditional_CPP_CompileOptions () {
81
- return this .myAditional_CPP_CompileOptions ;
106
+ public String get_CPP_CompileOptions () {
107
+ return this .my_CPP_CompileOptions ;
108
+ }
109
+
110
+ public void set_CPP_CompileOptions (String new_CPP_CompileOptions ) {
111
+ this .my_CPP_CompileOptions = new_CPP_CompileOptions ;
112
+ }
113
+
114
+ public String get_C_CompileOptions () {
115
+ return this .my_C_CompileOptions ;
116
+ }
117
+
118
+ public void set_C_CompileOptions (String new_C_CompileOptions ) {
119
+ this .my_C_CompileOptions = new_C_CompileOptions ;
120
+ }
121
+
122
+ public String get_C_andCPP_CompileOptions () {
123
+ return this .my_C_andCPP_CompileOptions ;
124
+ }
125
+
126
+ public void set_C_andCPP_CompileOptions (String new_C_andCPP_CompileOptions ) {
127
+ this .my_C_andCPP_CompileOptions = new_C_andCPP_CompileOptions ;
128
+ }
129
+ public String get_Assembly_CompileOptions () {
130
+ return this .my_Assembly_CompileOptions ;
131
+ }
132
+
133
+ public void set_Assembly_CompileOptions (String my_Assembly_CompileOptions ) {
134
+ this .my_Assembly_CompileOptions = my_Assembly_CompileOptions ;
82
135
}
83
136
84
- public void setMyAditional_CPP_CompileOptions ( String aditional_CPP_CompileOptions ) {
85
- this .myAditional_CPP_CompileOptions = aditional_CPP_CompileOptions ;
137
+ public String get_Archive_CompileOptions ( ) {
138
+ return this .my_Archive_CompileOptions ;
86
139
}
87
140
88
- public String getMyAditional_C_CompileOptions ( ) {
89
- return this .myAditional_C_CompileOptions ;
141
+ public void set_Archive_CompileOptions ( String my_Archive_CompileOptions ) {
142
+ this .my_Archive_CompileOptions = my_Archive_CompileOptions ;
90
143
}
91
144
92
- public void setMyAditional_C_CompileOptions ( String aditional_C_CompileOptions ) {
93
- this .myAditional_C_CompileOptions = aditional_C_CompileOptions ;
145
+ public String get_Link_CompileOptions ( ) {
146
+ return this .my_Link_CompileOptions ;
94
147
}
95
148
96
- public String getMyAditional_C_andCPP_CompileOptions ( ) {
97
- return this .myAditional_C_andCPP_CompileOptions ;
149
+ public void set_Link_CompileOptions ( String my_Link_CompileOptions ) {
150
+ this .my_Link_CompileOptions = my_Link_CompileOptions ;
98
151
}
99
152
100
- public void setMyAditional_C_andCPP_CompileOptions (String myAditional_C_andCPP_CompileOptions ) {
101
- this .myAditional_C_andCPP_CompileOptions = myAditional_C_andCPP_CompileOptions ;
153
+ public String get_All_CompileOptions () {
154
+ return this .my_All_CompileOptions ;
155
+ }
156
+
157
+ public void set_All_CompileOptions (String my_All_CompileOptions ) {
158
+ this .my_All_CompileOptions = my_All_CompileOptions ;
102
159
}
103
160
104
161
/**
@@ -108,13 +165,18 @@ public void setMyAditional_C_andCPP_CompileOptions(String myAditional_C_andCPP_C
108
165
* must be a valid configuration description
109
166
*/
110
167
public void save (ICConfigurationDescription configuration ) {
168
+ CompileOptions curOptions =new CompileOptions (configuration );
169
+ if (needsDirtyFlag (curOptions )) {
170
+ IProject project = configuration .getProjectDescription ().getProject ();
171
+ Helpers .setDirtyFlag (project , configuration );
172
+ }
111
173
IEnvironmentVariableManager envManager = CCorePlugin .getDefault ().getBuildEnvironmentManager ();
112
174
IContributedEnvironment contribEnv = envManager .getContributedEnvironment ();
113
175
IEnvironmentVariable var = new EnvironmentVariable (ENV_KEY_JANTJE_WARNING_LEVEL ,
114
176
this .myWarningLevel .toString ());
115
177
contribEnv .addVariable (var , configuration );
116
178
117
- if (this .isMyWarningLevel ()) {
179
+ if (this .isWarningLevel ()) {
118
180
var = new EnvironmentVariable (ENV_KEY_WARNING_LEVEL_OFF , ENV_KEY_WARNING_LEVEL_ON );
119
181
contribEnv .addVariable (var , configuration );
120
182
}
@@ -128,14 +190,58 @@ public void save(ICConfigurationDescription configuration) {
128
190
contribEnv .addVariable (var , configuration );
129
191
}
130
192
var = new EnvironmentVariable (ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS ,
131
- this .myAditional_C_andCPP_CompileOptions );
193
+ this .my_C_andCPP_CompileOptions );
132
194
contribEnv .addVariable (var , configuration );
133
195
var = new EnvironmentVariable (ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS ,
134
- this .myAditional_CPP_CompileOptions );
196
+ this .my_CPP_CompileOptions );
135
197
contribEnv .addVariable (var , configuration );
136
- var = new EnvironmentVariable (ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS , this .myAditional_C_CompileOptions );
198
+ var = new EnvironmentVariable (ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS , this .my_C_CompileOptions );
199
+ contribEnv .addVariable (var , configuration );
200
+
201
+
202
+ var = new EnvironmentVariable (ENV_KEY_JANTJE_ASSEMBLY_COMPILE_OPTIONS ,
203
+ this .my_Assembly_CompileOptions );
137
204
contribEnv .addVariable (var , configuration );
205
+ var = new EnvironmentVariable (ENV_KEY_JANTJE_ARCHIVE_COMPILE_OPTIONS ,
206
+ this .my_Archive_CompileOptions );
207
+ contribEnv .addVariable (var , configuration );
208
+ var = new EnvironmentVariable (ENV_KEY_JANTJE_LINK_COMPILE_OPTIONS ,
209
+ this .my_Link_CompileOptions );
210
+ contribEnv .addVariable (var , configuration );
211
+ var = new EnvironmentVariable (ENV_KEY_JANTJE_ALL_COMPILE_OPTIONS ,
212
+ this .my_All_CompileOptions );
213
+ contribEnv .addVariable (var , configuration );
214
+
215
+
216
+
217
+ }
218
+
219
+ private boolean needsDirtyFlag (CompileOptions curOptions ) {
220
+ // ignore myWarningLevel
221
+ //ignore myAlternativeSizeCommand
222
+ if ( !this .my_CPP_CompileOptions .equals (curOptions .get_CPP_CompileOptions ())){
223
+ return true ;
224
+ }
225
+ if ( !this .my_C_CompileOptions .equals (curOptions .get_C_CompileOptions ())){
226
+ return true ;
227
+ }
228
+ if ( !this .my_C_andCPP_CompileOptions .equals (curOptions .get_C_andCPP_CompileOptions ())){
229
+ return true ;
230
+ }
231
+ if ( !this .my_Assembly_CompileOptions .equals (curOptions .get_Assembly_CompileOptions ())){
232
+ return true ;
233
+ }
234
+ if ( !this .my_Archive_CompileOptions .equals (curOptions .get_Archive_CompileOptions ())){
235
+ return true ;
236
+ }
237
+ if ( !this .my_Link_CompileOptions .equals (curOptions .get_Link_CompileOptions ())){
238
+ return true ;
239
+ }
240
+ if ( !this .my_All_CompileOptions .equals (curOptions .get_All_CompileOptions ())){
241
+ return true ;
242
+ }
138
243
244
+ return false ;
139
245
}
140
246
141
247
}
0 commit comments