diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java index 09593196586..1f2687866a1 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java @@ -51,6 +51,7 @@ import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.makefile.IMakefile; import org.eclipse.cdt.make.core.makefile.ITarget; import org.eclipse.cdt.make.core.makefile.ITargetRule; +import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; @@ -114,6 +115,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { private static final String TARGET = "buildTarget"; //$NON-NLS-1$ private static final String DEFAULT_AUTORECONF = "autoreconf"; //$NON-NLS-1$ + public static final String RUN_IN_CONFIGURE_LAUNCHER = "org.eclipse.cdt.autotools.core.property.launchAutotoolsInContainer"; //$NON-NLS-1$ + + private IProject project; private IProgressMonitor monitor; @@ -341,6 +345,15 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { initializeBuildConfigDirs(icfg, toolsCfg); ICommandLauncher configureLauncher = CommandLauncherManager.getInstance().getCommandLauncher(project); + IOptionalBuildProperties props = icfg.getOptionalBuildProperties(); + boolean runInCfgLauncher = false; + if (props != null) { + String runInCfgLauncherProperty = props.getProperty(RUN_IN_CONFIGURE_LAUNCHER); + if (runInCfgLauncherProperty != null) { + runInCfgLauncher = Boolean.parseBoolean(runInCfgLauncherProperty); + } + } + // Create the top-level directory for the build output if (!createDirectory(buildDir)) { @@ -397,7 +410,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { System.arraycopy(newArgs, 0, makeargs, 0, newArgs.length); } makeargs[makeargs.length - 1] = target; - rc = runCommand(localCommandLauncher, makeCmd, + rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd, getProjectLocation(), makeargs, AutotoolsPlugin.getResourceString("MakeGenerator.clean.topdir"), //$NON-NLS-1$ @@ -447,7 +460,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { System.arraycopy(newArgs, 0, makeargs, 0, newArgs.length); } makeargs[makeargs.length - 1] = target; - rc = runCommand(localCommandLauncher, makeCmd, + rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd, buildLocation, makeargs, AutotoolsPlugin.getFormattedString("MakeGenerator.clean.builddir", new String[]{buildDir}), //$NON-NLS-1$ @@ -509,7 +522,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { configStatus.delete(); // Get any user-specified arguments for autogen. String[] autogenArgs = getAutogenArgs(autogenCmdParms); - rc = runScript(localCommandLauncher, autogenPath, + rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, autogenPath, autogenPath.removeLastSegments(1), autogenArgs, AutotoolsPlugin.getFormattedString("MakeGenerator.autogen.sh", new String[]{buildDir}), //$NON-NLS-1$ errMsg, console, autogenEnvs, consoleStart); @@ -532,7 +545,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { reconfCmd = DEFAULT_AUTORECONF; IPath reconfCmdPath = new Path(reconfCmd); reconfArgs[0] = "-i"; //$NON-NLS-1$ - rc = runScript(localCommandLauncher, reconfCmdPath, + rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath, getSourcePath(), reconfArgs, AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$ @@ -565,7 +578,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { String[] makeargs = new String[1]; IPath makeCmd = builder.getBuildCommand(); makeargs[0] = "-f" + getMakefileCVSPath().toOSString(); //$NON-NLS-1$ - rc = runCommand(localCommandLauncher, makeCmd, + rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd, getProjectLocation().append(buildDir), makeargs, AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[]{buildDir}), //$NON-NLS-1$ @@ -597,7 +610,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { reconfCmd = DEFAULT_AUTORECONF; IPath reconfCmdPath = new Path(reconfCmd); reconfArgs[0] = "-i"; //$NON-NLS-1$ - rc = runScript(localCommandLauncher, reconfCmdPath, + rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath, getSourcePath(), reconfArgs, AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java index d26e6cc9643..ae18900b0e8 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/AbstractAutotoolsHandler.java @@ -20,6 +20,7 @@ import java.util.StringTokenizer; import org.eclipse.cdt.autotools.ui.AutotoolsUIPlugin; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CommandLauncher; +import org.eclipse.cdt.core.CommandLauncherManager; import org.eclipse.cdt.core.ConsoleOutputStream; import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; @@ -28,6 +29,7 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.autotools.core.AutotoolsNewMakeGenerator; +import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; @@ -300,9 +302,23 @@ public abstract class AbstractAutotoolsHandler extends AbstractHandler { ArrayList additionalEnvs = new ArrayList<>(); String strippedCommand = AutotoolsNewMakeGenerator.stripEnvVars(command, additionalEnvs); - // Get a launcher for the config command...default non-remote to use local - // commands - RemoteCommandLauncher launcher = new RemoteCommandLauncher(new CommandLauncher()); + // Get a launcher for the config command...default for non-remote is a local + // launcher, but user can override to perform all Autotool commands in a + // Container when build in Container is enabled so check optional build + // properties + IOptionalBuildProperties props = cfg.getOptionalBuildProperties(); + boolean runInContainer = false; + if (props != null) { + String runInContainerProperty = props + .getProperty(AutotoolsNewMakeGenerator.RUN_IN_CONFIGURE_LAUNCHER); + if (runInContainerProperty != null) { + runInContainer = Boolean.parseBoolean(runInContainerProperty); + } + } + ICommandLauncher fallbackLauncher = runInContainer + ? CommandLauncherManager.getInstance().getCommandLauncher(project) + : new CommandLauncher(); + RemoteCommandLauncher launcher = new RemoteCommandLauncher(fallbackLauncher); launcher.setProject(project); // Set the environment IEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider() diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java index 623a4c5acea..92d11aeb678 100644 --- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java +++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/ContainerPropertyTab.java @@ -28,6 +28,7 @@ import org.eclipse.cdt.core.settings.model.ICMultiConfigDescription; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICTargetPlatformSetting; import org.eclipse.cdt.docker.launcher.ContainerCommandLauncher; +import org.eclipse.cdt.docker.launcher.DockerLaunchUIPlugin; import org.eclipse.cdt.internal.docker.launcher.ContainerPropertyVolumesModel.MountType; import org.eclipse.cdt.managedbuilder.buildproperties.IOptionalBuildProperties; import org.eclipse.cdt.managedbuilder.core.IConfiguration; @@ -42,6 +43,9 @@ import org.eclipse.core.databinding.beans.IBeanValueProperty; import org.eclipse.core.databinding.observable.list.IObservableList; import org.eclipse.core.databinding.observable.map.IObservableMap; import org.eclipse.core.databinding.property.Properties; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.databinding.viewers.ObservableListContentProvider; import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider; import org.eclipse.jface.databinding.viewers.ViewerSupport; @@ -88,19 +92,23 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab private final static String GNU_ELF_PARSER_ID = "org.eclipse.cdt.core.GNU_ELF"; //$NON-NLS-1$ private final static String ELF_PARSER_ID = "org.eclipse.cdt.core.ELF"; //$NON-NLS-1$ + private static final String RUN_IN_CONFIGURE_LAUNCHER = "org.eclipse.cdt.autotools.core.property.launchAutotoolsInContainer"; //$NON-NLS-1$ private Combo imageCombo; private Combo connectionSelector; private Button enableButton; + private Button launchAutotoolsButton; private Button addButton; private IDockerConnection connection; private IDockerConnection[] connections; private IDockerImageListener containerTab; + private boolean isAutotoolsProject; private String connectionName; private String connectionUri = ""; //$NON-NLS-1$ private boolean initialEnabled; + private boolean initialAutotoolsLaunchEnabled; private String initialConnection; private String initialImageId; private String initialVolumes; @@ -235,6 +243,43 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab }); + createVolumeSettingsContainer(usercomp); + + try { + IProject project = iCfgd.getProjectDescription().getProject(); + IProjectNature nature = project.getNature( + "org.eclipse.cdt.autotools.core.autotoolsNatureV2"); //$NON-NLS-1$ + isAutotoolsProject = (nature != null); + if (isAutotoolsProject) { + launchAutotoolsButton = new Button(usercomp, SWT.CHECK); + launchAutotoolsButton.setText( + Messages.ContainerPropertyTab_Run_Autotools_In_Container_Msg); + launchAutotoolsButton.setToolTipText( + Messages.ContainerPropertyTab_Run_Autotools_In_Container_Tooltip); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 5; + launchAutotoolsButton.setLayoutData(gd); + initializeLaunchAutotoolsButton(); + launchAutotoolsButton + .addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + setLaunchAutotoolsEnablement( + launchAutotoolsButton.getSelection()); + } + + @Override + public void widgetDefaultSelected( + SelectionEvent e) { + // ignore + } + }); + } + } catch (CoreException e) { + DockerLaunchUIPlugin.log(e); + } + initializeEnablementButton(); enableButton.addSelectionListener(new SelectionListener() { @@ -251,7 +296,6 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab }); - createVolumeSettingsContainer(usercomp); } private void createVolumeSettingsContainer(final Composite container) { @@ -597,6 +641,23 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab } } + private void setLaunchAutotoolsEnablement(boolean enabled) { + if (iCfg instanceof IMultiConfiguration) { + IConfiguration[] cfs = (IConfiguration[]) ((IMultiConfiguration) iCfg) + .getItems(); + for (int i = 0; i < cfs.length; i++) { + IConfiguration cfg = cfs[i]; + IOptionalBuildProperties p = cfg.getOptionalBuildProperties(); + p.setProperty(RUN_IN_CONFIGURE_LAUNCHER, + Boolean.toString(launchAutotoolsButton.getSelection())); + } + } else { + IOptionalBuildProperties p = iCfg.getOptionalBuildProperties(); + p.setProperty(RUN_IN_CONFIGURE_LAUNCHER, + Boolean.toString(launchAutotoolsButton.getSelection())); + } + } + private void setImageId(String imageId) { if (iCfg instanceof IMultiConfiguration) { IConfiguration[] cfs = (IConfiguration[]) ((IMultiConfiguration) iCfg) @@ -630,6 +691,9 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab private void setControlsEnabled(boolean enabled) { imageCombo.setEnabled(enabled); connectionSelector.setEnabled(enabled); + if (isAutotoolsProject) { + launchAutotoolsButton.setEnabled(enabled); + } setVolumeControlsEnabled(new Button[] { addButton }, enabled); } @@ -646,6 +710,16 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab setControlsEnabled(initialEnabled); } + private void initializeLaunchAutotoolsButton() { + initialEnabled = false; + IOptionalBuildProperties properties = iCfg.getOptionalBuildProperties(); + String savedEnabled = properties.getProperty(RUN_IN_CONFIGURE_LAUNCHER); + if (savedEnabled != null) { + initialAutotoolsLaunchEnabled = Boolean.parseBoolean(savedEnabled); + } + launchAutotoolsButton.setSelection(initialAutotoolsLaunchEnabled); + } + private void initializeConnectionSelector() { int defaultIndex = -1; initialConnection = null; @@ -871,6 +945,8 @@ public class ContainerPropertyTab extends AbstractCBuildPropertyTab .getProperty(ContainerCommandLauncher.VOLUMES_ID); initialSelectedVolumes = properties .getProperty(ContainerCommandLauncher.SELECTED_VOLUMES_ID); + initialAutotoolsLaunchEnabled = Boolean.parseBoolean( + properties.getProperty(RUN_IN_CONFIGURE_LAUNCHER)); List providers = ((ILanguageSettingsProvidersKeeper) cfgd) .getLanguageSettingProviders(); for (ILanguageSettingsProvider provider : providers) { diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java index dc90a4e3144..ac7ec788d2e 100644 --- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java +++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/Messages.java @@ -99,6 +99,8 @@ public class Messages extends NLS { public static String ContainerPropertyTab_Title; public static String ContainerPropertyTab_Enable_Msg; + public static String ContainerPropertyTab_Run_Autotools_In_Container_Msg; + public static String ContainerPropertyTab_Run_Autotools_In_Container_Tooltip; public static String ContainerCommandLauncher_image_msg; public static String CommandLauncher_CommandCancelled; diff --git a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties index 06609d611cf..a545210b63a 100644 --- a/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties +++ b/launch/org.eclipse.cdt.docker.launcher/src/org/eclipse/cdt/internal/docker/launcher/messages.properties @@ -42,6 +42,8 @@ ContainerTab_Warning_Image_Not_Found=Docker Image: {0} is not a valid pulled ima ContainerPropertyTab_Title=Container Settings ContainerPropertyTab_Enable_Msg=Build inside Docker Image +ContainerPropertyTab_Run_Autotools_In_Container_Msg=Run all Autotools in Container +ContainerPropertyTab_Run_Autotools_In_Container_Tooltip=Run Autotool commands in the Docker Container. This may cause inconsistencies between configurations sharing generated files. HeaderPreferencePage_Connection_Label=Connection HeaderPreferencePage_Image_Label=Image