Skip to main content
summaryrefslogtreecommitdiffstats
path: root/launch
diff options
context:
space:
mode:
authorJeff Johnston2018-04-04 12:50:19 -0400
committerJeff Johnston2018-04-16 12:10:42 -0400
commit2e99babe5bfda9c9e2d5bb4f53bab74ec1bcad6d (patch)
treeb3e7d64c4ca51698316f50cfdaf9974e07bbe8f7 /launch
parent864b305ff4bec7b8389e25b27dc7f1e9b1be9320 (diff)
downloadorg.eclipse.cdt-2e99babe5bfda9c9e2d5bb4f53bab74ec1bcad6d.tar.gz
org.eclipse.cdt-2e99babe5bfda9c9e2d5bb4f53bab74ec1bcad6d.tar.xz
org.eclipse.cdt-2e99babe5bfda9c9e2d5bb4f53bab74ec1bcad6d.zip
Bug 533222 - Add Container Build support to Std Make Core Build
- add new getConsoleHeader() method to ICBuildCommandLauncher interface and ContainerCommandLauncher class - modify MakefileBuildConfigurationProvider to create build configurations based on an Image name when building for Container and as well support the linux-container os that is used for Container targets - add new IConsoleParser2 interface that extends IConsoleParser and adds new processLine method that takes a List of Job as a parameter - make CBuildConfiguration implement IConsoleParser2 and add new processLine method - modify watchProcess to recognize an IConsoleParser2 and pass a Job List then wait for all jobs to finish before calling shutdown() and possibly reindex - add new IToolChain2 interface with startBuildProcess() method - add new startBuildProcess() method to CBuildConfiguration to look for new IToolChain2 and use its startBuildProcess() method to perform the build - make ContainerGCCToolChain implement IToolChain2 and add new startBuildProcess() method to build in Container - change StandardBuildConfiguration to use startBuildProcess() to do build and clean Change-Id: Icae9a55ef6abfa1b7f611544ad591b6062c72585
Diffstat (limited to 'launch')
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncher.java33
-rw-r--r--launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/ContainerGCCToolChain.java50
2 files changed, 82 insertions, 1 deletions
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncher.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncher.java
index 53613f74c7..3a9d9d1f1f 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncher.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/docker/launcher/ContainerCommandLauncher.java
@@ -322,6 +322,33 @@ public class ContainerCommandLauncher
return fProcess;
}
+ private String calculateImageName() {
+ ICBuildConfiguration buildCfg = getBuildConfiguration();
+ String imageName = ""; //$NON-NLS-1$
+
+ if (buildCfg != null) {
+ IToolChain toolChain;
+ try {
+ toolChain = buildCfg.getToolChain();
+ } catch (CoreException e) {
+ return imageName;
+ }
+ imageName = toolChain
+ .getProperty(IContainerLaunchTarget.ATTR_IMAGE_ID);
+ } else {
+ ICConfigurationDescription cfgd = CoreModel.getDefault()
+ .getProjectDescription(fProject).getActiveConfiguration();
+ IConfiguration cfg = ManagedBuildManager
+ .getConfigurationForDescription(cfgd);
+ if (cfg == null) {
+ return imageName;
+ }
+ IOptionalBuildProperties props = cfg.getOptionalBuildProperties();
+ imageName = props.getProperty(ContainerCommandLauncher.IMAGE_ID);
+ }
+ return imageName;
+ }
+
/**
* Parse array of "ENV=value" pairs to Properties.
*/
@@ -427,6 +454,12 @@ public class ContainerCommandLauncher
}
}
+ @Override
+ public String getConsoleHeader() {
+ return NLS.bind(Messages.ContainerCommandLauncher_image_msg,
+ calculateImageName()) + NEWLINE;
+ }
+
protected void printCommandLine(OutputStream os) {
if (os != null) {
try {
diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/ContainerGCCToolChain.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/ContainerGCCToolChain.java
index c773a3204c..9d6524e43e 100644
--- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/ContainerGCCToolChain.java
+++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ui/launchbar/ContainerGCCToolChain.java
@@ -29,8 +29,10 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CommandLauncherManager;
import org.eclipse.cdt.core.ICommandLauncher;
+import org.eclipse.cdt.core.build.ICBuildCommandLauncher;
import org.eclipse.cdt.core.build.ICBuildConfiguration;
import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.build.IToolChain2;
import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
@@ -38,6 +40,7 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
+import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.docker.launcher.ContainerCommandLauncher;
import org.eclipse.cdt.docker.launcher.ContainerTargetTypeProvider;
import org.eclipse.cdt.docker.launcher.DockerLaunchUIPlugin;
@@ -48,6 +51,7 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.PlatformObject;
@@ -59,7 +63,8 @@ import org.eclipse.linuxtools.docker.ui.Activator;
*
* @since 1.2
*/
-public class ContainerGCCToolChain extends PlatformObject implements IToolChain {
+public class ContainerGCCToolChain extends PlatformObject
+ implements IToolChain, IToolChain2 {
public static final String TYPE_ID = "org.eclipse.cdt.docker.launcher.gcc"; //$NON-NLS-1$
@@ -601,4 +606,47 @@ public class ContainerGCCToolChain extends PlatformObject implements IToolChain
return result;
}
+ @Override
+ public Process startBuildProcess(ICBuildConfiguration config,
+ List<String> command, String buildDirectory,
+ IEnvironmentVariable[] envVars, IConsole console,
+ IProgressMonitor monitor) throws CoreException, IOException {
+
+ IPath cmdPath = new org.eclipse.core.runtime.Path("/usr/bin/env"); //$NON-NLS-1$
+
+ List<String> argList = new ArrayList<>();
+ for (IEnvironmentVariable var : envVars) {
+ argList.add(var.getName() + "=" + var.getValue()); //$NON-NLS-1$
+ }
+
+ argList.add("sh"); //$NON-NLS-1$
+ argList.add("-c"); //$NON-NLS-1$
+
+ StringBuffer buf = new StringBuffer();
+ for (String s : command) {
+ buf.append(s);
+ buf.append(" "); //$NON-NLS-1$
+ }
+ buf.deleteCharAt(buf.length() - 1); // remove last blank;
+ argList.add(buf.toString());
+
+ ICommandLauncher launcher = CommandLauncherManager.getInstance()
+ .getCommandLauncher(config);
+
+ launcher.setProject(config.getBuildConfiguration().getProject());
+ if (launcher instanceof ICBuildCommandLauncher) {
+ ((ICBuildCommandLauncher) launcher).setBuildConfiguration(config);
+ console.getOutputStream().write(
+ ((ICBuildCommandLauncher) launcher).getConsoleHeader());
+ }
+
+ org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(
+ buildDirectory);
+
+ Process p = launcher.execute(cmdPath, argList.toArray(new String[0]),
+ new String[0], workingDir, monitor);
+
+ return p;
+ }
+
}

Back to the top