|
21 | 21 | import org.eclipse.cdt.core.CCorePlugin;
|
22 | 22 | import org.eclipse.cdt.core.ConsoleOutputStream;
|
23 | 23 | import org.eclipse.cdt.core.ICommandLauncher;
|
| 24 | +import org.eclipse.cdt.core.build.ICBuildConfiguration; |
| 25 | +import org.eclipse.cdt.core.build.ICBuildConfigurationManager; |
24 | 26 | import org.eclipse.cdt.core.resources.IConsole;
|
25 | 27 | import org.eclipse.cdt.jsoncdb.core.IParserPreferences;
|
26 | 28 | import org.eclipse.cdt.jsoncdb.core.IParserPreferencesAccess;
|
@@ -190,13 +192,28 @@ private String[] getEnvp(IProject project) {
|
190 | 192 | // e.g. 'C:\msys64\mingw64\bin' must be part of the PATH environment variable. That's why we need PATH here:
|
191 | 193 | // Fixes CDT #407
|
192 | 194 | try {
|
193 |
| - final String path = "PATH"; //$NON-NLS-1$ |
194 |
| - var variables = CCorePlugin.getDefault().getBuildEnvironmentManager() |
195 |
| - .getVariables(project.getActiveBuildConfig(), true); |
196 |
| - for (var variable : variables) { |
197 |
| - if (path.equalsIgnoreCase(variable.getName())) { |
198 |
| - map.put(path, variable.getValue()); |
199 |
| - break; |
| 195 | + final ICBuildConfiguration cBuildConfiguration; |
| 196 | + var active = project.getActiveBuildConfig(); |
| 197 | + if (active != null) { |
| 198 | + var manager = CCorePlugin.getService(ICBuildConfigurationManager.class); |
| 199 | + cBuildConfiguration = manager.getBuildConfiguration(active); |
| 200 | + } else { |
| 201 | + cBuildConfiguration = null; |
| 202 | + } |
| 203 | + |
| 204 | + if (cBuildConfiguration != null) { |
| 205 | + // If this project is Core Build, use its specialisation of getBuildEnvironmentManager |
| 206 | + // to get the environment. |
| 207 | + cBuildConfiguration.setBuildEnvironment(map); |
| 208 | + } else { |
| 209 | + final String path = "PATH"; //$NON-NLS-1$ |
| 210 | + var variables = CCorePlugin.getDefault().getBuildEnvironmentManager() |
| 211 | + .getVariables(project.getActiveBuildConfig(), true); |
| 212 | + for (var variable : variables) { |
| 213 | + if (path.equalsIgnoreCase(variable.getName())) { |
| 214 | + map.put(path, variable.getValue()); |
| 215 | + break; |
| 216 | + } |
200 | 217 | }
|
201 | 218 | }
|
202 | 219 | } catch (CoreException e) {
|
|
0 commit comments