1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Apply CMake changes from Bug 530673 to Meson

- Fix issue with Meson and changing toolchains since
  Meson is based on CMake plug-ins
- Cleaned up add and remove of toolchain files and handling of when
  a toolchain changes for a config

Change-Id: I147a30454c69e3d8d86fc50c561a1667ddfb5df3
This commit is contained in:
Jeff Johnston 2018-02-14 12:37:55 -05:00
parent 3405063203
commit e31e23bb4e
6 changed files with 36 additions and 17 deletions

View file

@ -18,6 +18,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherManager; import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
@ -26,6 +27,7 @@ import org.eclipse.cdt.core.build.CBuildConfiguration;
import org.eclipse.cdt.core.build.ICBuildCommandLauncher; import org.eclipse.cdt.core.build.ICBuildCommandLauncher;
import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.model.ICModelMarker; import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.meson.core.Activator; import org.eclipse.cdt.meson.core.Activator;
import org.eclipse.cdt.meson.core.IMesonConstants; import org.eclipse.cdt.meson.core.IMesonConstants;
@ -91,6 +93,10 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
} }
} }
public IMesonToolChainFile getToolChainFile() {
return toolChainFile;
}
private boolean isLocal() throws CoreException { private boolean isLocal() throws CoreException {
IToolChain toolchain = getToolChain(); IToolChain toolchain = getToolChain();
return Platform.getOS().equals(toolchain.getProperty(IToolChain.ATTR_OS)) return Platform.getOS().equals(toolchain.getProperty(IToolChain.ATTR_OS))
@ -315,5 +321,4 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
} }
} }

View file

@ -41,7 +41,7 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv
} }
@Override @Override
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { public synchronized ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) { if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
IToolChain toolChain = null; IToolChain toolChain = null;
@ -69,7 +69,19 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv
// No valid combinations // No valid combinations
return null; return null;
} }
return new MesonBuildConfiguration(config, name); MesonBuildConfiguration mesonConfig = new MesonBuildConfiguration(config, name);
IMesonToolChainFile tcFile = mesonConfig.getToolChainFile();
IToolChain toolChain = mesonConfig.getToolChain();
if (toolChain == null || tcFile == null) {
// config not complete?
return null;
}
if (!toolChain.equals(tcFile.getToolChain())) {
// toolchain changed
return new MesonBuildConfiguration(config, name, tcFile.getToolChain(), tcFile,
mesonConfig.getLaunchMode());
}
return mesonConfig;
} }
@Override @Override
@ -90,6 +102,7 @@ public class MesonBuildConfigurationProvider implements ICBuildConfigurationProv
Collection<IMesonToolChainFile> files = manager.getToolChainFilesMatching(properties); Collection<IMesonToolChainFile> files = manager.getToolChainFilesMatching(properties);
if (!files.isEmpty()) { if (!files.isEmpty()) {
file = files.iterator().next(); file = files.iterator().next();
toolChain = file.getToolChain();
} }
} }

View file

@ -215,7 +215,7 @@ public class MesonToolChainManager implements IMesonToolChainManager {
SafeRunner.run(new ISafeRunnable() { SafeRunner.run(new ISafeRunnable() {
@Override @Override
public void run() throws Exception { public void run() throws Exception {
listener.handleCMakeToolChainEvent(event); listener.handleMesonToolChainEvent(event);
} }
@Override @Override

View file

@ -14,6 +14,6 @@ package org.eclipse.cdt.meson.core;
*/ */
public interface IMesonToolChainListener { public interface IMesonToolChainListener {
void handleCMakeToolChainEvent(MesonToolChainEvent event); void handleMesonToolChainEvent(MesonToolChainEvent event);
} }

View file

@ -104,11 +104,11 @@ public class MesonPreferencePage extends PreferencePage implements IWorkbenchPre
WizardDialog dialog = new WizardDialog(getShell(), wizard); WizardDialog dialog = new WizardDialog(getShell(), wizard);
if (dialog.open() == Window.OK) { if (dialog.open() == Window.OK) {
IMesonToolChainFile file = wizard.getNewFile(); IMesonToolChainFile file = wizard.getNewFile();
if (filesToRemove.containsKey(file.getPath())) { IMesonToolChainFile oldFile = manager.getToolChainFile(file.getPath());
filesToRemove.remove(file.getPath()); if (oldFile != null) {
} else { filesToRemove.put(oldFile.getPath(), oldFile);
filesToAdd.put(file.getPath(), file);
} }
filesToAdd.put(file.getPath(), file);
updateTable(); updateTable();
} }
} }
@ -166,27 +166,27 @@ public class MesonPreferencePage extends PreferencePage implements IWorkbenchPre
files.put(file.getPath(), file); files.put(file.getPath(), file);
} }
for (IMesonToolChainFile file : filesToAdd.values()) {
files.put(file.getPath(), file);
}
for (IMesonToolChainFile file : filesToRemove.values()) { for (IMesonToolChainFile file : filesToRemove.values()) {
files.remove(file.getPath()); files.remove(file.getPath());
} }
for (IMesonToolChainFile file : filesToAdd.values()) {
files.put(file.getPath(), file);
}
return files; return files;
} }
@Override @Override
public boolean performOk() { public boolean performOk() {
for (IMesonToolChainFile file : filesToAdd.values()) {
manager.addToolChainFile(file);
}
for (IMesonToolChainFile file : filesToRemove.values()) { for (IMesonToolChainFile file : filesToRemove.values()) {
manager.removeToolChainFile(file); manager.removeToolChainFile(file);
} }
for (IMesonToolChainFile file : filesToAdd.values()) {
manager.addToolChainFile(file);
}
filesToAdd.clear(); filesToAdd.clear();
filesToRemove.clear(); filesToRemove.clear();

View file

@ -113,6 +113,7 @@ public class NewMesonToolChainFilePage extends WizardPage {
IMesonToolChainFile file = manager.newToolChainFile(Paths.get(pathText.getText())); IMesonToolChainFile file = manager.newToolChainFile(Paths.get(pathText.getText()));
IToolChain tc = toolchains[tcCombo.getSelectionIndex()]; IToolChain tc = toolchains[tcCombo.getSelectionIndex()];
file.setProperty(ICBuildConfiguration.TOOLCHAIN_TYPE, tc.getTypeId()); file.setProperty(ICBuildConfiguration.TOOLCHAIN_TYPE, tc.getTypeId());
file.setProperty(ICBuildConfiguration.TOOLCHAIN_ID, tc.getId()); file.setProperty(ICBuildConfiguration.TOOLCHAIN_ID, tc.getId());