1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-21 21:52:10 +02:00

Bug 547104 - Adding new Docker Connection causes two build dirs

- copy ChangeEvent logic from ContainerGCCToolChainProvider to
  ContainerTargetTypeProvider when a new connection is added

Change-Id: Idbdaba7d10e4590722ff442447d195a3a2485907
This commit is contained in:
Jeff Johnston 2019-05-08 18:19:34 -04:00
parent f89d6e51bc
commit 8b2c6229aa

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2018 QNX Software Systems and others.
* Copyright (c) 2017, 2019 QNX Software Systems and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.cdt.docker.launcher;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -22,7 +23,13 @@ import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager2;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.internal.docker.launcher.ui.launchbar.ContainerGCCToolChain;
import org.eclipse.cdt.internal.docker.launcher.ui.launchbar.ContainerGCCToolChainProvider;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -135,6 +142,7 @@ public class ContainerTargetTypeProvider implements ILaunchTargetProvider, IDock
checkConfigs.schedule();
try {
if (defaultTarget != null)
launchbarManager.setActiveLaunchTarget(defaultTarget);
} catch (CoreException e) {
DockerLaunchUIPlugin.log(e);
@ -168,6 +176,7 @@ public class ContainerTargetTypeProvider implements ILaunchTargetProvider, IDock
}
List<IDockerImage> images = connection.getImages();
IToolChainProvider provider = new ContainerGCCToolChainProvider();
for (IDockerImage image : images) {
if (!image.isDangling() && !image.isIntermediateImage()) {
@ -197,6 +206,35 @@ public class ContainerTargetTypeProvider implements ILaunchTargetProvider, IDock
wc.setAttribute(IContainerLaunchTarget.ATTR_IMAGE_ID, image.repoTags().get(0));
wc.save();
Map<String, String> properties = new HashMap<>();
properties.put(ILaunchTarget.ATTR_OS, ContainerTargetTypeProvider.CONTAINER_LINUX);
properties.put(ILaunchTarget.ATTR_ARCH, Platform.getOSArch());
properties.put(IContainerLaunchTarget.ATTR_CONNECTION_URI, connection.getUri());
properties.put(IContainerLaunchTarget.ATTR_IMAGE_ID, image.repoTags().get(0));
// following can be used for naming build
// configurations
properties.put(ContainerGCCToolChainProvider.CONTAINER_LINUX_CONFIG_ID,
image.repoTags().get(0).replace(':', '_'));
// .replace('/', '_'));
IToolChainManager toolChainManager = MakeCorePlugin.getService(IToolChainManager.class);
Collection<IToolChain> toolChains;
try {
toolChains = toolChainManager.getToolChainsMatching(properties);
if (toolChains.isEmpty()) {
ContainerGCCToolChain toolChain = new ContainerGCCToolChain(
"gcc-img-" + image.id().substring(0, //$NON-NLS-1$
19),
provider, properties, null);
toolChainManager.addToolChain(toolChain);
}
} catch (CoreException e) {
DockerLaunchUIPlugin.log(e);
}
}
}