66import org .eclipse .cdt .core .envvar .IEnvironmentVariable ;
77import org .eclipse .cdt .core .envvar .IEnvironmentVariableManager ;
88import org .eclipse .cdt .core .settings .model .ICConfigurationDescription ;
9+ import org .eclipse .core .resources .IProject ;
910
1011import io .sloeber .core .common .Common ;
1112import io .sloeber .core .common .Const ;
13+ import io .sloeber .core .tools .Helpers ;
1214
1315public class CompileOptions {
1416
17+
1518 private Boolean myWarningLevel = new Boolean (true );
1619 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+
2030 private static final String ENV_KEY_WARNING_LEVEL_OFF = "A.COMPILER.WARNING_FLAGS" ; //$NON-NLS-1$
2131 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
2434 + "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
2636 + "EXTRA.CPP.COMPILE" ; //$NON-NLS-1$
2737 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$
3044
3145 /**
3246 * gets the compile options stored in this configuration description. if the
@@ -50,55 +64,98 @@ public CompileOptions(ICConfigurationDescription confDesc) {
5064 this .myAlternativeSizeCommand = var .getValue ().contains (ENV_KEY_JANTJE_SIZE_COMMAND );
5165 var = contribEnv .getVariable (ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS , confDesc );
5266 if (var != null )
53- this .myAditional_C_andCPP_CompileOptions = var .getValue ();
67+ this .my_C_andCPP_CompileOptions = var .getValue ();
5468 var = contribEnv .getVariable (ENV_KEY_JANTJE_ADDITIONAL_C_COMPILE_OPTIONS , confDesc );
5569 if (var != null )
56- this .myAditional_C_CompileOptions = var .getValue ();
70+ this .my_C_CompileOptions = var .getValue ();
5771 var = contribEnv .getVariable (ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS , confDesc );
5872 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 ();
6086
6187 }
6288 }
6389
64- public boolean isMyWarningLevel () {
90+ public boolean isWarningLevel () {
6591 return this .myWarningLevel .booleanValue ();
6692 }
6793
68- public void setMyWarningLevel (boolean myWarningLevel ) {
94+ public void setWarningLevel (boolean myWarningLevel ) {
6995 this .myWarningLevel = new Boolean (myWarningLevel );
7096 }
7197
72- public boolean isMyAlternativeSizeCommand () {
98+ public boolean isAlternativeSizeCommand () {
7399 return this .myAlternativeSizeCommand ;
74100 }
75101
76- public void setMyAlternativeSizeCommand (boolean alternativeSizeCommand ) {
102+ public void setAlternativeSizeCommand (boolean alternativeSizeCommand ) {
77103 this .myAlternativeSizeCommand = alternativeSizeCommand ;
78104 }
79105
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 ;
82135 }
83136
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 ;
86139 }
87140
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 ;
90143 }
91144
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 ;
94147 }
95148
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 ;
98151 }
99152
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 ;
102159 }
103160
104161 /**
@@ -108,13 +165,18 @@ public void setMyAditional_C_andCPP_CompileOptions(String myAditional_C_andCPP_C
108165 * must be a valid configuration description
109166 */
110167 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+ }
111173 IEnvironmentVariableManager envManager = CCorePlugin .getDefault ().getBuildEnvironmentManager ();
112174 IContributedEnvironment contribEnv = envManager .getContributedEnvironment ();
113175 IEnvironmentVariable var = new EnvironmentVariable (ENV_KEY_JANTJE_WARNING_LEVEL ,
114176 this .myWarningLevel .toString ());
115177 contribEnv .addVariable (var , configuration );
116178
117- if (this .isMyWarningLevel ()) {
179+ if (this .isWarningLevel ()) {
118180 var = new EnvironmentVariable (ENV_KEY_WARNING_LEVEL_OFF , ENV_KEY_WARNING_LEVEL_ON );
119181 contribEnv .addVariable (var , configuration );
120182 }
@@ -128,14 +190,58 @@ public void save(ICConfigurationDescription configuration) {
128190 contribEnv .addVariable (var , configuration );
129191 }
130192 var = new EnvironmentVariable (ENV_KEY_JANTJE_ADDITIONAL_COMPILE_OPTIONS ,
131- this .myAditional_C_andCPP_CompileOptions );
193+ this .my_C_andCPP_CompileOptions );
132194 contribEnv .addVariable (var , configuration );
133195 var = new EnvironmentVariable (ENV_KEY_JANTJE_ADDITIONAL_CPP_COMPILE_OPTIONS ,
134- this .myAditional_CPP_CompileOptions );
196+ this .my_CPP_CompileOptions );
135197 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 );
137204 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+ }
138243
244+ return false ;
139245 }
140246
141247}
0 commit comments