diff options
author | Jonah Graham | 2018-11-20 11:20:42 -0500 |
---|---|---|
committer | Jonah Graham | 2018-11-22 16:47:02 -0500 |
commit | 170e654b4796bad1453ae85a427b97317d67a69a (patch) | |
tree | 6ca9b8a8fedd5fd25f97eb79c408312e256ff981 /build/org.eclipse.cdt.autotools.core/src | |
parent | 35996a5c5ca5c254959ba48241eaada6dbf8628d (diff) | |
download | org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.gz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.tar.xz org.eclipse.cdt-170e654b4796bad1453ae85a427b97317d67a69a.zip |
Bug 540373: Cleanup: Format & Remove trailing whitespace
This was done by selecting all projects in Eclipse then
Source -> Clean Up... -> choosing:
- Format source code
- Remove trailing white spaces on all lines
and completing the wizard
Change-Id: I63685372c6bcc67719bcf145123bcb72e5b00394
Diffstat (limited to 'build/org.eclipse.cdt.autotools.core/src')
32 files changed, 721 insertions, 809 deletions
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java index e3c856841b..5b9a8ccdc5 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java @@ -39,7 +39,7 @@ import org.eclipse.core.runtime.jobs.Job; public class AutotoolsNewProjectNature implements IProjectNature { - public static final String AUTOTOOLS_NATURE_ID = "org.eclipse.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$ + public static final String AUTOTOOLS_NATURE_ID = "org.eclipse.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$ public static final String OLD_AUTOTOOLS_NATURE_ID = "org.eclipse.linuxtools.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$ public static final String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".genmakebuilder"; //$NON-NLS-1$ /** @@ -49,7 +49,7 @@ public class AutotoolsNewProjectNature implements IProjectNature { public static final String OLD_AUTOTOOLS_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.genmakebuilder"; //$NON-NLS-1$ private IProject project; - + @Override public void configure() throws CoreException { addAutotoolsBuilder(project, new NullProgressMonitor()); @@ -59,17 +59,17 @@ public class AutotoolsNewProjectNature implements IProjectNature { public void deconfigure() throws CoreException { // TODO remove builder from here } - + @Override public IProject getProject() { return project; } - + @Override public void setProject(IProject project) { this.project = project; } - + /** * Add the Autotools builder to the project * @param project @@ -80,7 +80,7 @@ public class AutotoolsNewProjectNature implements IProjectNature { // Add the builder to the project IProjectDescription description = project.getDescription(); ICommand[] commands = description.getBuildSpec(); - if(checkEquals(commands,getBuildCommandsList(description, commands))){ + if (checkEquals(commands, getBuildCommandsList(description, commands))) { return; } final ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRoot(); @@ -101,21 +101,21 @@ public class AutotoolsNewProjectNature implements IProjectNature { //Other pieces of wizard might have contributed new builder commands; //need to make sure we are using the most recent ones ICommand[] currentCommands = prDescription.getBuildSpec(); - ICommand[] newCommands = getBuildCommandsList(prDescription, currentCommands); - if(!checkEquals(currentCommands,newCommands)){ + ICommand[] newCommands = getBuildCommandsList(prDescription, currentCommands); + if (!checkEquals(currentCommands, newCommands)) { prDescription.setBuildSpec(newCommands); proj.setDescription(prDescription, new NullProgressMonitor()); } restoreAutoBuild(workspace); } - + protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException { IWorkspaceDescription workspaceDesc = workspace.getDescription(); savedAutoBuildingValue = workspaceDesc.isAutoBuilding(); workspaceDesc.setAutoBuilding(false); workspace.setDescription(workspaceDesc); } - + protected final void restoreAutoBuild(IWorkspace workspace) throws CoreException { IWorkspaceDescription workspaceDesc = workspace.getDescription(); workspaceDesc.setAutoBuilding(savedAutoBuildingValue); @@ -134,21 +134,19 @@ public class AutotoolsNewProjectNature implements IProjectNature { backgroundJob.schedule(); } - static boolean checkEquals(ICommand[] commands, - ICommand[] newCommands) { - if (newCommands.length != commands.length){ + static boolean checkEquals(ICommand[] commands, ICommand[] newCommands) { + if (newCommands.length != commands.length) { + return false; + } + for (int j = 0; j < commands.length; ++j) { + if (!commands[j].getBuilderName().equals(newCommands[j].getBuilderName())) { return false; } - for (int j = 0; j < commands.length; ++j) { - if (!commands[j].getBuilderName().equals(newCommands[j].getBuilderName())) { - return false; - } - } - return true; + } + return true; } - static ICommand[] getBuildCommandsList(IProjectDescription description, - ICommand[] commands) { + static ICommand[] getBuildCommandsList(IProjectDescription description, ICommand[] commands) { ArrayList<ICommand> commandList = new ArrayList<>(); // Make sure the Autotools Configuration builder just precedes the Common Builder @@ -164,8 +162,7 @@ public class AutotoolsNewProjectNature implements IProjectNature { } // Make sure that the Autotools builder precedes the Managed builder // or the Remote Synchronized builder. - if (command.getBuilderName().equals(BUILDER_ID) || - command.getBuilderName().equals(REMOTE_BUILDER_ID)) { + if (command.getBuilderName().equals(BUILDER_ID) || command.getBuilderName().equals(REMOTE_BUILDER_ID)) { // add Autotools Configuration builder just before builder ICommand newCommand = description.newCommand(); newCommand.setBuilderName(AutotoolsConfigurationBuilder.BUILDER_ID); @@ -179,7 +176,7 @@ public class AutotoolsNewProjectNature implements IProjectNature { /** * Utility method for adding an autotools nature to a project. - * + * * @param proj the project to add the autotools nature to. * @param monitor a progress monitor to indicate the duration of the operation, or * <code>null</code> if progress reporting is not required. @@ -190,7 +187,7 @@ public class AutotoolsNewProjectNature implements IProjectNature { /** * Utility method for adding a nature to a project. - * + * * @param proj the project to add the nature to. * @param natureId the id of the nature to assign to the project * @param monitor a progress monitor to indicate the duration of the operation, or @@ -209,13 +206,13 @@ public class AutotoolsNewProjectNature implements IProjectNature { description.setNatureIds(newNatures); project.setDescription(description, monitor); } - + /** * Utility method to remove the autotools nature from a project. - * + * * @param project to remove the autotools nature from - * @param mon progress monitor to indicate the duration of the operation, or - * <code>null</code> if progress reporting is not required. + * @param mon progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. * @throws CoreException */ public static void removeAutotoolsNature(IProject project, IProgressMonitor mon) throws CoreException { @@ -224,10 +221,10 @@ public class AutotoolsNewProjectNature implements IProjectNature { /** * Utility method to remove the old autotools nature from a project. - * + * * @param project to remove the old autotools nature from - * @param mon progress monitor to indicate the duration of the operation, or - * <code>null</code> if progress reporting is not required. + * @param mon progress monitor to indicate the duration of the operation, or + * <code>null</code> if progress reporting is not required. * @throws CoreException */ public static void removeOldAutotoolsNature(IProject project, IProgressMonitor mon) throws CoreException { @@ -236,7 +233,7 @@ public class AutotoolsNewProjectNature implements IProjectNature { /** * Utility method for removing a project nature from a project. - * + * * @param proj the project to remove the nature from * @param natureId the nature id to remove * @param monitor a progress monitor to indicate the duration of the operation, or diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsPlugin.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsPlugin.java index 5e1bd024b2..ebd8552df2 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsPlugin.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsPlugin.java @@ -44,7 +44,7 @@ public class AutotoolsPlugin extends AbstractUIPlugin { //The shared instance. private static AutotoolsPlugin plugin; private ResourceBundle resourceBundle; - + public static final String PLUGIN_ID = "org.eclipse.cdt.autotools.core"; //$NON-NLS-1$ public static final String AUTOTOOLS_PROJECT_TYPE_ID = "org.eclipse.linuxtools.cdt.autotools.core.projectType"; //$NON-NLS-1$ @@ -65,7 +65,7 @@ public class AutotoolsPlugin extends AbstractUIPlugin { public static String getPluginId() { return PLUGIN_ID; } - + public static String getUniqueIdentifier() { if (getDefault() == null) { // If the default instance is not yet initialized, @@ -94,7 +94,7 @@ public class AutotoolsPlugin extends AbstractUIPlugin { /** * Return the OSGi service with the given service interface. - * + * * @param service service interface * @return the specified service or null if it's not registered * @since 1.5 @@ -108,7 +108,7 @@ public class AutotoolsPlugin extends AbstractUIPlugin { /** * Returns the string from the plugin's resource bundle, * or 'key' if not found. - * + * * @param key the message key * @return the resource bundle message */ @@ -124,13 +124,13 @@ public class AutotoolsPlugin extends AbstractUIPlugin { /** * Returns the string from the plugin's resource bundle, * or 'key' if not found. - * + * * @param key the message key * @param args an array of substituition strings * @return the resource bundle message */ public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getResourceString(key), (Object[])args); + return MessageFormat.format(getResourceString(key), (Object[]) args); } /** @@ -187,15 +187,14 @@ public class AutotoolsPlugin extends AbstractUIPlugin { /** * Return set of Autotool configuration options for a given build configuration id. - * + * * @param project existing autotools project * @param cfgId configuration id * @return a copy of Autotools configurations for the given configuration id * @throws CoreException if project is not valid Autotools project or cfgId does not exist * @since 1.2 */ - public Map<String, IAutotoolsOption> getAutotoolCfgOptions(IProject project, - String cfgId) throws CoreException { + public Map<String, IAutotoolsOption> getAutotoolCfgOptions(IProject project, String cfgId) throws CoreException { return AutotoolsConfigurationManager.getInstance().getAutotoolsCfgOptions(project, cfgId); } @@ -206,11 +205,11 @@ public class AutotoolsPlugin extends AbstractUIPlugin { * @param cfgId configuation id * @param options set of updated Autotool configuration options * @throws CoreException if project is not valid Autotools project or cfgId does not exist - * + * * @since 1.2 */ - public void updateAutotoolCfgOptions(IProject project, String cfgId, - Map<String,IAutotoolsOption> options) throws CoreException { + public void updateAutotoolCfgOptions(IProject project, String cfgId, Map<String, IAutotoolsOption> options) + throws CoreException { AutotoolsConfigurationManager.getInstance().updateAutotoolCfgOptions(project, cfgId, options); } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/IAutotoolsOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/IAutotoolsOption.java index 38952e9275..4eb3ec6ce9 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/IAutotoolsOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/IAutotoolsOption.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.autotools.core; import org.eclipse.core.runtime.CoreException; - /** * @since 1.2 */ diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsConfigurationBuilder.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsConfigurationBuilder.java index 3727bb34be..ff95543133 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsConfigurationBuilder.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsConfigurationBuilder.java @@ -43,24 +43,23 @@ public class AutotoolsConfigurationBuilder extends ACBuilder { public static final String BUILDER_ID = AutotoolsPlugin.getPluginId() + "." + BUILDER_NAME; //$NON-NLS-1$ public static final String OLD_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.core.genmakebuilderV2"; //$NON-NLS-1$ - private static final String BUILD_STOPPED="AutotoolsMakefileBuilder.message.stopped"; //$NON-NLS-1$ + private static final String BUILD_STOPPED = "AutotoolsMakefileBuilder.message.stopped"; //$NON-NLS-1$ private AutotoolsNewMakeGenerator generator; public AutotoolsConfigurationBuilder() { super(); generator = new AutotoolsNewMakeGenerator(); } - - protected boolean isCdtProjectCreated(IProject project){ + + protected boolean isCdtProjectCreated(IProject project) { ICProjectDescription des = CoreModel.getDefault().getProjectDescription(project, false); return des != null && !des.isCdtProjectCreating(); } @Override - protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) - throws CoreException { + protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); - if(!isCdtProjectCreated(project)) + if (!isCdtProjectCreated(project)) return project.getReferencedProjects(); boolean bPerformBuild = true; @@ -110,7 +109,7 @@ public class AutotoolsConfigurationBuilder extends ACBuilder { checkCancel(monitor); return getProject().getReferencedProjects(); } - + @Override protected void clean(IProgressMonitor monitor) { IProject project = getProject(); @@ -118,15 +117,17 @@ public class AutotoolsConfigurationBuilder extends ACBuilder { if (shouldBuild(CLEAN_BUILD, info)) { IConfiguration icfg = info.getDefaultConfiguration(); if (icfg instanceof IMultiConfiguration) { - IMultiConfiguration mcfg = (IMultiConfiguration)icfg; - IConfiguration[] cfgs = (IConfiguration[])mcfg.getItems(); + IMultiConfiguration mcfg = (IMultiConfiguration) icfg; + IConfiguration[] cfgs = (IConfiguration[]) mcfg.getItems(); for (int i = 0; i < cfgs.length; ++i) { - IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, icfg.getName()); + IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, + icfg.getName()); cfg.setDirty(true); } } else { - IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, icfg.getName()); - cfg.setDirty(true); // Mark Configuration dirty so next build will do full reconfigure + IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, + icfg.getName()); + cfg.setDirty(true); // Mark Configuration dirty so next build will do full reconfigure } } } @@ -134,16 +135,15 @@ public class AutotoolsConfigurationBuilder extends ACBuilder { protected MultiStatus performMakefileGeneration(IProject project, IManagedBuildInfo info, IProgressMonitor monitor) { MultiStatus result; - + try { generator.initialize(project, info, monitor); result = generator.regenerateMakefiles(false); } catch (CoreException e) { String errMsg = AutotoolsPlugin.getResourceString("MakeGenerator.didnt.generate"); //$NON-NLS-1$ - result = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, - errMsg, e); + result = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, errMsg, e); } - + return result; } @@ -160,18 +160,17 @@ public class AutotoolsConfigurationBuilder extends ACBuilder { IBuilder builder = null; if (cfg != null) { builder = cfg.getEditableBuilder(); - switch (kind) { - case IncrementalProjectBuilder.AUTO_BUILD : - return builder.isAutoBuildEnable(); - case IncrementalProjectBuilder.INCREMENTAL_BUILD : // now treated as the same! - case IncrementalProjectBuilder.FULL_BUILD : - return builder.isFullBuildEnabled() | builder.isIncrementalBuildEnabled() ; - case IncrementalProjectBuilder.CLEAN_BUILD : - return builder.isCleanBuildEnabled(); - } + switch (kind) { + case IncrementalProjectBuilder.AUTO_BUILD: + return builder.isAutoBuildEnable(); + case IncrementalProjectBuilder.INCREMENTAL_BUILD: // now treated as the same! + case IncrementalProjectBuilder.FULL_BUILD: + return builder.isFullBuildEnabled() | builder.isIncrementalBuildEnabled(); + case IncrementalProjectBuilder.CLEAN_BUILD: + return builder.isCleanBuildEnabled(); + } } return true; } } - diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsEnvironmentVariableSupplier.java index e5f99bd78d..ad37a2f565 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsEnvironmentVariableSupplier.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsEnvironmentVariableSupplier.java @@ -41,12 +41,14 @@ public class AutotoolsEnvironmentVariableSupplier implements IConfigurationEnvir private static boolean isVar(String name) { // Windows has case insensitive env var names - return Platform.getOS().equals(Platform.OS_WIN32) ? name.equalsIgnoreCase(VerboseEnvironmentVariable.VERBOSE_VAR_NAME) + return Platform.getOS().equals(Platform.OS_WIN32) + ? name.equalsIgnoreCase(VerboseEnvironmentVariable.VERBOSE_VAR_NAME) : name.equals(VerboseEnvironmentVariable.VERBOSE_VAR_NAME); } private static IBuildEnvironmentVariable create() { - return new VerboseEnvironmentVariable(VERBOSE_VAR_NAME, VERBOSE_VAR_VALUE, IEnvironmentVariable.ENVVAR_PREPEND, null); + return new VerboseEnvironmentVariable(VERBOSE_VAR_NAME, VERBOSE_VAR_VALUE, + IEnvironmentVariable.ENVVAR_PREPEND, null); } } 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 12da41efb9..9d765ee3a8 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 @@ -98,10 +98,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { public static final String MAKEFILE_CVS = "Makefile.cvs"; //$NON-NLS-1$ public static final String SETTINGS_FILE_NAME = ".cdtconfigure"; //$NON-NLS-1$ public static final String SHELL_COMMAND = "sh"; //$NON-NLS-1$ - + public static final String AUTOGEN_TOOL_ID = "autogen"; //$NON-NLS-1$ public static final String CONFIGURE_TOOL_ID = "configure"; //$NON-NLS-1$ - + public static final String GENERATED_TARGET = AutotoolsPlugin.PLUGIN_ID + ".generated.MakeTarget"; //$NON-NLS-1$ private static final String MAKE_TARGET_KEY = MakeCorePlugin.getUniqueIdentifier() + ".buildtargets"; //$NON-NLS-1$ @@ -120,7 +120,6 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { public static final String RUN_IN_CONFIGURE_LAUNCHER = "org.eclipse.cdt.autotools.core.property.launchAutotoolsInContainer"; //$NON-NLS-1$ - private IProject project; private IProgressMonitor monitor; @@ -134,14 +133,13 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { private ICConfigurationDescription cdesc; private IAConfiguration toolsCfg; private IBuilder builder; - + private ICommandLauncher localCommandLauncher = new CommandLauncher(); /** * @since 2.0 */ - public MultiStatus generateMakefiles() - throws CoreException { + public MultiStatus generateMakefiles() throws CoreException { return regenerateMakefiles(false); } @@ -156,16 +154,15 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { buildDir = buildDirectory.toString(); srcDir = a.getConfigToolDirectory(); try { - String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValue(srcDir, "", null, + String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValue(srcDir, "", null, IBuildMacroProvider.CONTEXT_CONFIGURATION, c); srcDir = resolved; } catch (BuildMacroException e) { // do nothing } } - - public void initialize(IProject project, IManagedBuildInfo info, - IProgressMonitor monitor) { + + public void initialize(IProject project, IManagedBuildInfo info, IProgressMonitor monitor) { this.project = project; ICProjectDescription pdesc = CCorePlugin.getDefault().getProjectDescription(project); this.cdesc = pdesc.getActiveConfiguration(); @@ -179,7 +176,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { public IProject getProject() { return project; } - + /** * @since 2.0 */ @@ -198,7 +195,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { * Check whether the build has been cancelled. Cancellation requests * propagated to the caller by throwing * <code>OperationCanceledException</code>. - * + * * @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException() */ protected void checkCancel() { @@ -211,7 +208,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { * Return or create the makefile needed for the build. If we are creating * the resource, set the derived bit to true so the CM system ignores the * contents. If the resource exists, respect the existing derived setting. - * + * * @param makefilePath * @return IFile */ @@ -245,7 +242,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { /** * Create a directory. - * + * * @param boolean * @return whether the directory was created */ @@ -266,8 +263,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { return rc; } - - private void refresh() throws CoreException{ + + private void refresh() throws CoreException { IRemoteResource remRes = getProject().getAdapter(IRemoteResource.class); if (remRes != null) { remRes.refresh(SubMonitor.convert(monitor)); @@ -289,49 +286,37 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { public MultiStatus reconfigure() throws CoreException { return regenerateMakefiles(true); } - + public MultiStatus regenerateMakefiles(boolean reconfigure) throws CoreException { MultiStatus status = null; if (cfg instanceof IMultiConfiguration) { - IMultiConfiguration mfcg = (IMultiConfiguration)cfg; + IMultiConfiguration mfcg = (IMultiConfiguration) cfg; Object[] objs = mfcg.getItems(); for (int i = 0; i < objs.length; ++i) { - IConfiguration icfg = (IConfiguration)objs[i]; + IConfiguration icfg = (IConfiguration) objs[i]; Status rc = regenerateMakefiles(icfg, reconfigure); if (!rc.isOK()) { - if(status == null){ - status = new MultiStatus( - AutotoolsPlugin.getUniqueIdentifier(), - IStatus.ERROR, - "", - null); + if (status == null) { + status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, "", null); } - status.add(rc); + status.add(rc); } } } else { Status rc = regenerateMakefiles(cfg, reconfigure); if (!rc.isOK()) { - if(status == null){ - status = new MultiStatus( - AutotoolsPlugin.getUniqueIdentifier(), - IStatus.ERROR, - "", - null); + if (status == null) { + status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), IStatus.ERROR, "", null); } - status.add(rc); + status.add(rc); } } - if(status == null){ - status = new MultiStatus( - ManagedBuilderCorePlugin.getUniqueIdentifier(), - IStatus.OK, - "", - null); + if (status == null) { + status = new MultiStatus(ManagedBuilderCorePlugin.getUniqueIdentifier(), IStatus.OK, "", null); } return status; } - + private Status regenerateMakefiles(IConfiguration icfg, boolean reconfigure) throws CoreException { MultiStatus status; int rc = IStatus.OK; @@ -342,9 +327,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { checkCancel(); // Synchronize the Autotools configurations with the Project Description - AutotoolsConfigurationManager.getInstance().syncConfigurations(getProject()); + AutotoolsConfigurationManager.getInstance().syncConfigurations(getProject()); toolsCfg = AutotoolsConfigurationManager.getInstance().getConfiguration(getProject(), icfg.getId()); - + initializeBuildConfigDirs(icfg, toolsCfg); ICommandLauncher configureLauncher = CommandLauncherManager.getInstance().getCommandLauncher(project); @@ -357,21 +342,19 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } } - // Create the top-level directory for the build output if (!createDirectory(buildDir)) { rc = IStatus.ERROR; errMsg = AutotoolsPlugin.getFormattedString("MakeGenerator.createdir.error", //$NON-NLS-1$ - new String[] {buildDir}); - status = new MultiStatus(AutotoolsPlugin - .getUniqueIdentifier(), rc, errMsg, null); + new String[] { buildDir }); + status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), rc, errMsg, null); } checkCancel(); // Get a build console for the project IConsole console = CCorePlugin.getDefault().getConsole("org.eclipse.cdt.autotools.ui.configureConsole"); //$NON-NLS-1$ boolean consoleStart = true; - + // Make sure there's a monitor to cancel the build if (monitor == null) { monitor = new NullProgressMonitor(); @@ -414,8 +397,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } makeargs[makeargs.length - 1] = target; rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd, - getProjectLocation(), - makeargs, + getProjectLocation(), makeargs, AutotoolsPlugin.getResourceString("MakeGenerator.clean.topdir"), //$NON-NLS-1$ errMsg, console, consoleStart); consoleStart = false; @@ -440,7 +422,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } catch (CoreException ce) { // do nothing } - + if (cleanDelete != null && cleanDelete.equals(AutotoolsPropertyConstants.TRUE)) buildLocation.toFile().delete(); else { @@ -450,7 +432,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { IPath makeCmd = builder.getBuildCommand(); String target = null; try { - target = getProject().getPersistentProperty(AutotoolsPropertyConstants.CLEAN_MAKE_TARGET); + target = getProject() + .getPersistentProperty(AutotoolsPropertyConstants.CLEAN_MAKE_TARGET); } catch (CoreException ce) { // do nothing } @@ -464,9 +447,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } makeargs[makeargs.length - 1] = target; rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd, - buildLocation, - makeargs, - AutotoolsPlugin.getFormattedString("MakeGenerator.clean.builddir", new String[]{buildDir}), //$NON-NLS-1$ + buildLocation, makeargs, + AutotoolsPlugin.getFormattedString("MakeGenerator.clean.builddir", //$NON-NLS-1$ + new String[] { buildDir }), errMsg, console, consoleStart); consoleStart = false; } @@ -479,7 +462,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // do nothing } } - + List<String> configureEnvs = new ArrayList<>(); List<String> configureCmdParms = new ArrayList<>(); IPath configurePath = getConfigurePath(configureEnvs, configureCmdParms); @@ -487,25 +470,24 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { List<String> autogenEnvs = new ArrayList<>(); List<String> autogenCmdParms = new ArrayList<>(); IPath autogenPath = getAutogenPath(autogenEnvs, autogenCmdParms); - + // Check if we have a config.status (meaning configure has already run). - if (!needFullConfigure && configStatus != null && configStatus.exists()) { - // If no corresponding Makefile in the same build location, then we - // can simply run config.status again to ensure the top level Makefile has been + if (!needFullConfigure && configStatus != null && configStatus.exists()) { + // If no corresponding Makefile in the same build location, then we + // can simply run config.status again to ensure the top level Makefile has been // created. if (makefile == null || !makefile.exists()) { rc = runScript(configureLauncher, configfile, buildLocation, null, - AutotoolsPlugin.getFormattedString("MakeGenerator.run.config.status", new String[]{buildDir}), //$NON-NLS-1$ + AutotoolsPlugin.getFormattedString("MakeGenerator.run.config.status", //$NON-NLS-1$ + new String[] { buildDir }), errMsg, console, null, consoleStart); consoleStart = false; } } // Look for configure and configure from scratch else if (configurePath.toFile().exists()) { - rc = runScript(configureLauncher, configurePath, - buildLocation, - configArgs, - AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[]{buildDir}), //$NON-NLS-1$ + rc = runScript(configureLauncher, configurePath, buildLocation, configArgs, + AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[] { buildDir }), //$NON-NLS-1$ errMsg, console, configureEnvs, consoleStart); consoleStart = false; if (rc != IStatus.ERROR) { @@ -517,7 +499,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } } // If no configure, look for autogen.sh which may create configure and - // possibly even run it. + // possibly even run it. else if (autogenPath.toFile().exists()) { // Remove the existing config.status file since we use it // to figure out if configure was run. @@ -527,7 +509,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { String[] autogenArgs = getAutogenArgs(autogenCmdParms); rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, autogenPath, autogenPath.removeLastSegments(1), autogenArgs, - AutotoolsPlugin.getFormattedString("MakeGenerator.autogen.sh", new String[]{buildDir}), //$NON-NLS-1$ + AutotoolsPlugin.getFormattedString("MakeGenerator.autogen.sh", new String[] { buildDir }), //$NON-NLS-1$ errMsg, console, autogenEnvs, consoleStart); consoleStart = false; if (rc != IStatus.ERROR) { @@ -543,25 +525,25 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { if (!configurePath.toFile().exists()) { // no configure script either...try running autoreconf String[] reconfArgs = new String[1]; - String reconfCmd = project.getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL); + String reconfCmd = project + .getPersistentProperty(AutotoolsPropertyConstants.AUTORECONF_TOOL); if (reconfCmd == null) reconfCmd = DEFAULT_AUTORECONF; IPath reconfCmdPath = new Path(reconfCmd); reconfArgs[0] = "-i"; //$NON-NLS-1$ rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath, - getSourcePath(), - reconfArgs, - AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$ + getSourcePath(), reconfArgs, + AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", //$NON-NLS-1$ + new String[] { buildDir }), errMsg, console, null, consoleStart); consoleStart = false; refresh(); } // Check if configure generated and if yes, run it. if (rc != IStatus.ERROR && configurePath.toFile().exists()) { - rc = runScript(configureLauncher, configurePath, - buildLocation, - configArgs, - AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[]{buildDir}), //$NON-NLS-1$ + rc = runScript(configureLauncher, configurePath, buildLocation, configArgs, + AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$ + new String[] { buildDir }), errMsg, console, configureEnvs, false); if (rc != IStatus.ERROR) { File makefileFile = buildLocation.append(MAKEFILE).toFile(); @@ -576,15 +558,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } } } - // If nothing this far, look for a Makefile.cvs file which needs to be run. + // If nothing this far, look for a Makefile.cvs file which needs to be run. else if (makefileCvsExists()) { String[] makeargs = new String[1]; IPath makeCmd = builder.getBuildCommand(); makeargs[0] = "-f" + getMakefileCVSPath().toOSString(); //$NON-NLS-1$ rc = runCommand(runInCfgLauncher ? configureLauncher : localCommandLauncher, makeCmd, - getProjectLocation().append(buildDir), - makeargs, - AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[]{buildDir}), //$NON-NLS-1$ + getProjectLocation().append(buildDir), makeargs, + AutotoolsPlugin.getFormattedString("MakeGenerator.makefile.cvs", new String[] { buildDir }), //$NON-NLS-1$ errMsg, console, consoleStart); consoleStart = false; if (rc != IStatus.ERROR) { @@ -596,7 +577,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { .equals(configureLauncher.getClass().getName())) { rc = runScript(configureLauncher, configurePath, buildLocation, configArgs, AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$ - new String[] { buildDir }), errMsg, console, configureEnvs, false); + new String[] { buildDir }), + errMsg, console, configureEnvs, false); } } if (rc != IStatus.ERROR) { @@ -614,19 +596,17 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { IPath reconfCmdPath = new Path(reconfCmd); reconfArgs[0] = "-i"; //$NON-NLS-1$ rc = runScript(runInCfgLauncher ? configureLauncher : localCommandLauncher, reconfCmdPath, - getSourcePath(), - reconfArgs, - AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[]{buildDir}), //$NON-NLS-1$ + getSourcePath(), reconfArgs, + AutotoolsPlugin.getFormattedString("MakeGenerator.autoreconf", new String[] { buildDir }), //$NON-NLS-1$ errMsg, console, null, consoleStart); consoleStart = false; // Check if configure generated and if yes, run it. if (rc != IStatus.ERROR) { refresh(); if (configurePath.toFile().exists()) { - rc = runScript(configureLauncher, configurePath, - buildLocation, - configArgs, - AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", new String[]{buildDir}), //$NON-NLS-1$ + rc = runScript(configureLauncher, configurePath, buildLocation, configArgs, + AutotoolsPlugin.getFormattedString("MakeGenerator.gen.makefile", //$NON-NLS-1$ + new String[] { buildDir }), errMsg, console, configureEnvs, false); if (rc != IStatus.ERROR) { File makefileFile = buildLocation.append(MAKEFILE).toFile(); @@ -638,7 +618,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } } } - // If we didn't create a Makefile, consider that an error. + // If we didn't create a Makefile, consider that an error. if (makefile == null || !makefile.exists()) { rc = IStatus.ERROR; errMsg = AutotoolsPlugin.getResourceString("MakeGenerator.didnt.generate"); //$NON-NLS-1$ @@ -649,15 +629,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { rc = IStatus.ERROR; } finally { // getGenerationProblems().clear(); - status = new MultiStatus(AutotoolsPlugin - .getUniqueIdentifier(), rc, errMsg, null); + status = new MultiStatus(AutotoolsPlugin.getUniqueIdentifier(), rc, errMsg, null); if (rc != IStatus.OK) - status.add(new Status ( - rc, - AutotoolsPlugin.getUniqueIdentifier(), - 0, - errMsg, - null)); + status.add(new Status(rc, AutotoolsPlugin.getUniqueIdentifier(), 0, errMsg, null)); } return status; } @@ -675,13 +649,13 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { Pattern p2 = Pattern.compile("(\\w+[=]'.*?'\\s+)\\w+.*"); Pattern p3 = Pattern.compile("(\\w+[=][^\\s]+\\s+)\\w+.*"); Pattern p4 = Pattern.compile("\\w+\\s+(\\w+[=]\\\".*?\\\"\\s*)+.*"); - Pattern p5 = Pattern.compile("\\w+\\s+(\\w+[=]'.*?'\\s*)+.*"); + Pattern p5 = Pattern.compile("\\w+\\s+(\\w+[=]'.*?'\\s*)+.*"); Pattern p6 = Pattern.compile("\\w+\\s+(\\w+[=][^\\s]+).*"); boolean finished = false; while (!finished) { Matcher m1 = p1.matcher(command); if (m1.matches()) { - command = command.replaceFirst("\\w+[=]\\\".*?\\\"","").trim(); + command = command.replaceFirst("\\w+[=]\\\".*?\\\"", "").trim(); String s = m1.group(1).trim(); envVars.add(s.replaceAll("\\\"", "")); } else { @@ -698,7 +672,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } else { Matcher m4 = p4.matcher(command); if (m4.matches()) { - command = command.replaceFirst("\\w+[=]\\\".*?\\\"","").trim(); + command = command.replaceFirst("\\w+[=]\\\".*?\\\"", "").trim(); String s = m4.group(1).trim(); envVars.add(s.replaceAll("\\\"", "")); } else { @@ -707,7 +681,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { command = command.replaceFirst("\\w+[=]'.*?'", "").trim(); String s = m5.group(1).trim(); envVars.add(s.replaceAll("'", "")); - } else { + } else { Matcher m6 = p6.matcher(command); if (m6.matches()) { command = command.replaceFirst("\\w+[=][^\\s+]+", "").trim(); @@ -723,7 +697,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } return command; } - + /** * Strip a configure option of VAR=VALUE pairs and add * them to a list of environment variables. @@ -740,7 +714,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { while (!finished) { Matcher m1 = p1.matcher(str); if (m1.matches()) { - str = str.replaceFirst("\\w+[=]\\\".*?\\\"","").trim(); + str = str.replaceFirst("\\w+[=]\\\".*?\\\"", "").trim(); String s = m1.group(1).trim(); envVars.add(s.replaceAll("\\\"", "")); } else { @@ -766,12 +740,12 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { private IPath getProjectLocation() { return project.getLocation(); } - - private IPath getBuildPath(){ - return new Path(this.buildDir); + + private IPath getBuildPath() { + return new Path(this.buildDir); } - - private IPath getSourcePath(){ + + private IPath getSourcePath() { IPath sourcePath; if (srcDir.isEmpty()) sourcePath = getProjectLocation(); @@ -784,14 +758,14 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } return sourcePath; } - + protected IPath getConfigurePath(List<String> envVars, List<String> cmdParms) { IPath configPath; IConfigureOption configOption = toolsCfg.getOption(CONFIGURE_TOOL_ID); String command = "configure"; //$NON-NLS-1$ if (configOption != null) command = stripEnvVars(configOption.getValue().trim(), envVars); - + String[] tokens = command.split("\\s"); if (tokens.length > 1) { command = tokens[0]; @@ -811,7 +785,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { makefileCVSPath = getSourcePath().append(MAKEFILE_CVS); return makefileCVSPath; } - + protected boolean makefileCvsExists() { IPath makefileCVSPath = getMakefileCVSPath(); return makefileCVSPath.toFile().exists(); @@ -830,11 +804,11 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { for (int i = 1; i < tokens.length; ++i) cmdParms.add(tokens[i]); } - + autogenPath = getSourcePath().append(command); return autogenPath; } - + private String[] getAutogenArgs(List<String> cmdParms) { // Get the arguments to be passed to config from build model List<String> autogenArgs = toolsCfg.getToolArgs(AUTOGEN_TOOL_ID); @@ -851,45 +825,40 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // Run a command or executable (e.g. make). private int runCommand(ICommandLauncher commandLauncher, IPath commandPath, IPath runPath, String[] args, - String jobDescription, String errMsg, - IConsole console, boolean consoleStart) throws CoreException, NullPointerException, IOException { + String jobDescription, String errMsg, IConsole console, boolean consoleStart) + throws CoreException, NullPointerException, IOException { int rc = IStatus.OK; - + removeAllMarkers(project); - + String[] configTargets = args; if (args == null) configTargets = new String[0]; - + for (int i = 0; i < configTargets.length; ++i) { // try to resolve the build macros in any argument - try{ - String resolved = - ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( - configTargets[i], - "", //$NON-NLS-1$ - " ", //$NON-NLS-1$ - IBuildMacroProvider.CONTEXT_CONFIGURATION, - cfg); + try { + String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( + configTargets[i], "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg); configTargets[i] = resolved; } catch (BuildMacroException e) { } } - + String[] msgs = new String[2]; msgs[0] = commandPath.toString(); msgs[1] = project.getName(); - monitor.subTask(AutotoolsPlugin.getFormattedString( - "MakeGenerator.make.message", msgs)); //$NON-NLS-1$ - + monitor.subTask(AutotoolsPlugin.getFormattedString("MakeGenerator.make.message", msgs)); //$NON-NLS-1$ StringBuilder buf = new StringBuilder(); // Launch command - main invocation if (consoleStart) console.start(project); - + try (ConsoleOutputStream consoleOutStream = console.getOutputStream()) { String[] consoleHeader = new String[3]; @@ -908,14 +877,13 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { ICommandLauncher launcher = new RemoteCommandLauncher(commandLauncher); launcher.setProject(project); // Set the environment - IEnvironmentVariable variables[] = - CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true); + IEnvironmentVariable variables[] = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, + true); String[] env = null; ArrayList<String> envList = new ArrayList<>(); if (variables != null) { for (int i = 0; i < variables.length; i++) { - envList.add(variables[i].getName() - + "=" + variables[i].getValue()); //$NON-NLS-1$ + envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$ } env = envList.toArray(new String[envList.size()]); } @@ -1013,19 +981,19 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // Write message on the console consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); - + // // Generate any error markers that the build has discovered // monitor.subTask(ManagedMakeMessages // .getResourceString(MARKERS)); // epm.reportProblems(); } - + // If we have an error and no specific error markers, use the default error marker. if (rc == IStatus.ERROR && !hasMarkers(project)) { addMarker(project, -1, errMsg, SEVERITY_ERROR_BUILD, null); } - + return rc; } @@ -1038,24 +1006,19 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { ByteArrayOutputStream out = new ByteArrayOutputStream(); // Fix Bug 423192 - use environment variables when checking the Win OS Type using // a shell command as the path to sh may be specified there - IEnvironmentVariable variables[] = - CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true); + IEnvironmentVariable variables[] = CCorePlugin.getDefault().getBuildEnvironmentManager() + .getVariables(cdesc, true); String[] env = new String[0]; ArrayList<String> envList = new ArrayList<>(); if (variables != null) { for (int i = 0; i < variables.length; i++) { - envList.add(variables[i].getName() - + "=" + variables[i].getValue()); //$NON-NLS-1$ + envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$ } env = envList.toArray(new String[envList.size()]); } - launcher.execute( - new Path(SHELL_COMMAND), //$NON-NLS-1$ - new String[] { "-c", "echo $OSTYPE" }, //$NON-NLS-1$ //$NON-NLS-2$ - env, - buildLocation, - SubMonitor.convert(monitor)); + launcher.execute(new Path(SHELL_COMMAND), new String[] { "-c", "echo $OSTYPE" }, //$NON-NLS-1$ //$NON-NLS-2$ + env, buildLocation, SubMonitor.convert(monitor)); if (launcher.waitAndRead(out, out) == ICommandLauncher.OK) winOSType = out.toString().trim(); } catch (CoreException e) { @@ -1063,68 +1026,67 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } } return winOSType; - } + } - // Get OS name either remotely or locally, depending on the project - private String getOSName() { + // Get OS name either remotely or locally, depending on the project + private String getOSName() { IRemoteResource remRes = getProject().getAdapter(IRemoteResource.class); - if (remRes != null) { - URI uri = remRes.getActiveLocationURI(); - IRemoteServicesManager remoteServiceManager = AutotoolsPlugin.getService(IRemoteServicesManager.class); - IRemoteConnectionType connectionType = remoteServiceManager.getConnectionType(uri); - if (connectionType != null) { - IRemoteConnection conn = connectionType.getConnection(uri); - if (conn != null) { - if (!conn.isOpen()) { - try { + if (remRes != null) { + URI uri = remRes.getActiveLocationURI(); + IRemoteServicesManager remoteServiceManager = AutotoolsPlugin.getService(IRemoteServicesManager.class); + IRemoteConnectionType connectionType = remoteServiceManager.getConnectionType(uri); + if (connectionType != null) { + IRemoteConnection conn = connectionType.getConnection(uri); + if (conn != null) { + if (!conn.isOpen()) { + try { conn.open(SubMonitor.convert(monitor)); } catch (RemoteConnectionException e) { // Ignore and return platform OS } - } - + } + if (conn.isOpen()) { return conn.getProperty(IRemoteConnection.OS_NAME_PROPERTY); } - } - } - } - return Platform.getOS(); - } - - // Get the path string. We add a Win check to handle MingW. - // For MingW, we would rather represent C:\a\b as /C/a/b which - // doesn't cause Makefile to choke. For Cygwin we use /cygdrive/C/a/b - private String getPathString(IPath path) { - String s = path.toString(); - if (getOSName().equals(Platform.OS_WIN32)) { - if (getWinOSType().equals("cygwin")) { - s = s.replaceAll("^([a-zA-Z]):", "/cygdrive/$1"); - } else { - s = s.replaceAll("^([a-zA-Z]):", "/$1"); - } - } - return s; - } - - // Fix any escape characters in sh -c command arguments - private String fixEscapeChars(String s) { - s = s.replaceAll("\\\\", "\\\\\\\\"); - s = s.replaceAll("\\(", "\\\\("); - s = s.replaceAll("\\)", "\\\\)"); - return s; - } - - // Run an autotools script (e.g. configure, autogen.sh, config.status). + } + } + } + return Platform.getOS(); + } + + // Get the path string. We add a Win check to handle MingW. + // For MingW, we would rather represent C:\a\b as /C/a/b which + // doesn't cause Makefile to choke. For Cygwin we use /cygdrive/C/a/b + private String getPathString(IPath path) { + String s = path.toString(); + if (getOSName().equals(Platform.OS_WIN32)) { + if (getWinOSType().equals("cygwin")) { + s = s.replaceAll("^([a-zA-Z]):", "/cygdrive/$1"); + } else { + s = s.replaceAll("^([a-zA-Z]):", "/$1"); + } + } + return s; + } + + // Fix any escape characters in sh -c command arguments + private String fixEscapeChars(String s) { + s = s.replaceAll("\\\\", "\\\\\\\\"); + s = s.replaceAll("\\(", "\\\\("); + s = s.replaceAll("\\)", "\\\\)"); + return s; + } + + // Run an autotools script (e.g. configure, autogen.sh, config.status). private int runScript(ICommandLauncher commandLauncher, IPath commandPath, IPath runPath, String[] args, - String jobDescription, String errMsg, - IConsole console, List<String> additionalEnvs, boolean consoleStart) - throws CoreException, NullPointerException, IOException { + String jobDescription, String errMsg, IConsole console, List<String> additionalEnvs, boolean consoleStart) + throws CoreException, NullPointerException, IOException { int rc = IStatus.OK; boolean removePWD = false; - + removeAllMarkers(project); // We want to run the script via the shell command. So, we add the command @@ -1134,41 +1096,37 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { if (args == null) configTargets = new String[1]; else { - configTargets = new String[args.length+1]; + configTargets = new String[args.length + 1]; System.arraycopy(args, 0, configTargets, 1, args.length); } - configTargets[0] = getPathString(commandPath); - - // Fix for bug #343879 - String osName = getOSName(); - if (osName.equals(Platform.OS_WIN32) - || osName.equals(Platform.OS_MACOSX)) - removePWD = true; - - // Fix for bug #343731 and bug #371277 - // Always use sh -c for executing autotool scripts which should - // work on all Linux POSIX compliant shells including bash, dash, as - // well as Windows and Mac OSX. - String command = null; - for (String arg : configTargets) { - // TODO check for spaces in args - if (command == null) - command = arg; - else - command += " " + arg; - } - configTargets = new String[] { "-c", command }; - - for (int i = 0; i < configTargets.length; ++i) { + configTargets[0] = getPathString(commandPath); + + // Fix for bug #343879 + String osName = getOSName(); + if (osName.equals(Platform.OS_WIN32) || osName.equals(Platform.OS_MACOSX)) + removePWD = true; + + // Fix for bug #343731 and bug #371277 + // Always use sh -c for executing autotool scripts which should + // work on all Linux POSIX compliant shells including bash, dash, as + // well as Windows and Mac OSX. + String command = null; + for (String arg : configTargets) { + // TODO check for spaces in args + if (command == null) + command = arg; + else + command += " " + arg; + } + configTargets = new String[] { "-c", command }; + + for (int i = 0; i < configTargets.length; ++i) { // try to resolve the build macros in any argument - try{ - String resolved = - ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( - configTargets[i], - "", //$NON-NLS-1$ - " ", //$NON-NLS-1$ - IBuildMacroProvider.CONTEXT_CONFIGURATION, - cfg); + try { + String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat( + configTargets[i], "", //$NON-NLS-1$ + " ", //$NON-NLS-1$ + IBuildMacroProvider.CONTEXT_CONFIGURATION, cfg); // strip any env-var settings from options // fix for bug #356278 if (resolved.length() > 0 && resolved.charAt(0) != '-') @@ -1177,20 +1135,18 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } catch (BuildMacroException e) { } } - + String[] msgs = new String[2]; msgs[0] = commandPath.toString(); msgs[1] = project.getName(); - monitor.subTask(AutotoolsPlugin.getFormattedString( - "MakeGenerator.make.message", msgs)); //$NON-NLS-1$ - + monitor.subTask(AutotoolsPlugin.getFormattedString("MakeGenerator.make.message", msgs)); //$NON-NLS-1$ StringBuilder buf = new StringBuilder(); // Launch command - main invocation if (consoleStart) console.start(project); - + try (ConsoleOutputStream consoleOutStream = console.getOutputStream()) { String[] consoleHeader = new String[3]; @@ -1205,13 +1161,12 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // Display command-line environment variables that have been stripped by us // because launch showCommand won't do this. if (additionalEnvs != null && additionalEnvs.size() > 0) { - buf.append(AutotoolsPlugin - .getResourceString("MakeGenerator.commandline.envvars")); + buf.append(AutotoolsPlugin.getResourceString("MakeGenerator.commandline.envvars")); buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ buf.append("\t"); for (int i = 0; i < additionalEnvs.size(); ++i) { String envvar = additionalEnvs.get(i); - buf.append(envvar.replaceFirst("(\\w+=)(.*)"," $1\"$2\"")); + buf.append(envvar.replaceFirst("(\\w+=)(.*)", " $1\"$2\"")); } buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1223,8 +1178,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { ICommandLauncher launcher = new RemoteCommandLauncher(commandLauncher); launcher.setProject(project); // Set the environment - IEnvironmentVariable variables[] = - CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true); + IEnvironmentVariable variables[] = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, + true); String[] env = null; ArrayList<String> envList = new ArrayList<>(); if (variables != null) { @@ -1240,11 +1195,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // configure to try and link a file to itself (e.g. projects with a GnuMakefile) and // obliterate the contents. Thus, we remove the trailing separator to be safe. if (variables[i].getName().equals("PWD")) { //$NON-NLS-1$ - if (value.charAt(value.length()-1) == IPath.SEPARATOR) - value = value.substring(0, value.length() - 1); + if (value.charAt(value.length() - 1) == IPath.SEPARATOR) + value = value.substring(0, value.length() - 1); } - envList.add(variables[i].getName() - + "=" + value); //$NON-NLS-1$ + envList.add(variables[i].getName() + "=" + value); //$NON-NLS-1$ } } if (additionalEnvs != null) @@ -1354,25 +1308,26 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // .getResourceString(MARKERS)); // epm.reportProblems(); } - + // If we have an error and no specific error markers, use the default error marker. if (rc == IStatus.ERROR && !hasMarkers(project)) { addMarker(project, -1, errMsg, SEVERITY_ERROR_BUILD, null); } - + return rc; } - + private ICStorageElement createTargetElement(ICStorageElement parent, IMakeTarget target) { ICStorageElement targetElem = parent.createChild(TARGET_ELEMENT); targetElem.setAttribute(TARGET_ATTR_NAME, target.getName()); targetElem.setAttribute(TARGET_ATTR_ID, target.getTargetBuilderID()); targetElem.setAttribute(TARGET_ATTR_PATH, target.getContainer().getProjectRelativePath().toString()); ICStorageElement elem = targetElem.createChild(TARGET_COMMAND); - elem.setValue(target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, builder.getBuildCommand().toOSString())); + elem.setValue( + target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, builder.getBuildCommand().toOSString())); String targetAttr = target.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null); - if ( targetAttr != null) { + if (targetAttr != null) { elem = targetElem.createChild(TARGET_ARGUMENTS); elem.setValue(targetAttr); } @@ -1394,10 +1349,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { return targetElem; } - + /** * This output method saves the information into the .cdtproject metadata file. - * + * * @param doc * @throws CoreException */ @@ -1417,21 +1372,21 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { //Save the results descriptor.saveProjectData(); } - + protected static class MakeTargetComparator implements Comparator<Object> { @Override public int compare(Object a, Object b) { - IMakeTarget make1 = (IMakeTarget)a; - IMakeTarget make2 = (IMakeTarget)b; + IMakeTarget make1 = (IMakeTarget) a; + IMakeTarget make2 = (IMakeTarget) b; return make1.getName().compareToIgnoreCase(make2.getName()); } - + } /** * This method parses the given Makefile and produces MakeTargets for all targets so the * end-user can access them from the MakeTargets popup-menu. - * + * * @param makefileFile the Makefile to parse * @throws CoreException */ @@ -1439,16 +1394,15 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // We don't bother if the Makefile wasn't created. if (makefileFile == null || !makefileFile.exists()) return; - + checkCancel(); if (monitor == null) monitor = new NullProgressMonitor(); - String statusMsg = AutotoolsPlugin.getResourceString("MakeGenerator.refresh.MakeTargets"); //$NON-NLS-1$ + String statusMsg = AutotoolsPlugin.getResourceString("MakeGenerator.refresh.MakeTargets"); //$NON-NLS-1$ monitor.subTask(statusMsg); - - IMakeTargetManager makeTargetManager = - MakeCorePlugin.getDefault().getTargetManager(); - + + IMakeTargetManager makeTargetManager = MakeCorePlugin.getDefault().getTargetManager(); + IMakefile makefile = MakeCorePlugin.createMakefile(makefileFile.toURI(), false, null); ITargetRule[] targets = makefile.getTargetRules(); ITarget target = null; @@ -1467,16 +1421,15 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { IPath buildCommand = buildInfo.getBuildCommand(); String defaultBuildCommand = buildCommand.toString(); String buildArguments = buildInfo.getBuildArguments(); - + // Bug #351660 - reset targets to a single dummy target so that // we will never be able to find any of the new targets we are about to // create and thus avoid an extraneous event notification on a change to // the MakeTarget. The dummy target should have an invalid name for // a normal make target. - IMakeTarget dummyTarget = makeTargetManager.createTarget( - project, "\ndummyTarget\n", targetBuildID); //$NON-NLS-1$ - makeTargetManager.setTargets(project, new IMakeTarget[]{dummyTarget}); - + IMakeTarget dummyTarget = makeTargetManager.createTarget(project, "\ndummyTarget\n", targetBuildID); //$NON-NLS-1$ + makeTargetManager.setTargets(project, new IMakeTarget[] { dummyTarget }); + for (int i = 0; i < targets.length; i++) { target = targets[i].getTarget(); String targetName = target.toString(); @@ -1487,8 +1440,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { // existing MakeTarget will cause events to occur on every // modification whereas a new MakeTarget not yet added will // not cause this delay. - IMakeTarget makeTarget = makeTargetManager.createTarget( - project, targetName, targetBuildID); + IMakeTarget makeTarget = makeTargetManager.createTarget(project, targetName, targetBuildID); makeTarget.setContainer(project); makeTarget.setStopOnError(isStopOnError); makeTarget.setRunAllBuilders(false); @@ -1497,18 +1449,16 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, defaultBuildCommand); makeTarget.setBuildAttribute(GENERATED_TARGET, "true"); //$NON-NLS-1$ - makeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, - targetName); + makeTarget.setBuildAttribute(IMakeTarget.BUILD_TARGET, targetName); //TODO: should this be raw build directory in macro form? - makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, - buildDir); + makeTarget.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, buildDir); makeTargets.put(makeTarget.getName(), makeTarget); } catch (CoreException e) { // Duplicate target. Ignore. } } - + IMakeTarget[] makeTargetArray = new IMakeTarget[makeTargets.size()]; Collection<IMakeTarget> values = makeTargets.values(); List<IMakeTarget> valueList = new ArrayList<>(values); @@ -1539,11 +1489,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { return !(targetName.endsWith("-am") //$NON-NLS-1$ || targetName.endsWith("PROGRAMS") //$NON-NLS-1$ || targetName.endsWith("-generic") //$NON-NLS-1$ - || (targetName.indexOf('$') >= 0) - || (targetName.charAt(0) == '.') + || (targetName.indexOf('$') >= 0) || (targetName.charAt(0) == '.') || targetName.equals(targetName.toUpperCase())); } - + // Turn the string into an array. private String[] makeArray(String string) { string = string.trim(); @@ -1563,9 +1512,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { } } if (c == ' ' && !inComment) { - if (buffer.length() > 0){ + if (buffer.length() > 0) { String str = buffer.toString().trim(); - if(str.length() > 0){ + if (str.length() > 0) { aList.add(str); } } @@ -1575,9 +1524,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator { buffer.append(c); } } - if (buffer.length() > 0){ + if (buffer.length() > 0) { String str = buffer.toString().trim(); - if(str.length() > 0){ + if (str.length() > 0) { aList.add(str); } } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java index 89ed11d016..11379609c8 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsProblemMarkerInfo.java @@ -24,16 +24,12 @@ import org.eclipse.core.runtime.IPath; */ public class AutotoolsProblemMarkerInfo { - public static enum Type{ - PACKAGE, - HEADER, - PROG, + public static enum Type { + PACKAGE, HEADER, PROG, /** * @since 1.2 */ - LIB, - FILE, - GENERIC + LIB, FILE, GENERIC } private ProblemMarkerInfo marker; @@ -42,18 +38,19 @@ public class AutotoolsProblemMarkerInfo { this(file, -1, description, severity, null, null, name, type); } - public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName, Type type) { + public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, + String variableName, Type type) { this(file, lineNumber, description, severity, variableName, null, null, type); } - public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName, - IPath externalPath, String libraryInfo, Type type) { + public AutotoolsProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, + String variableName, IPath externalPath, String libraryInfo, Type type) { this.marker = new ProblemMarkerInfo(file, lineNumber, description, severity, variableName, externalPath); marker.setAttribute(IAutotoolsMarker.MARKER_PROBLEM_TYPE, type.name()); marker.setAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, libraryInfo); - marker.setType (IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER); + marker.setType(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER); } public ProblemMarkerInfo getMarker() { @@ -64,7 +61,7 @@ public class AutotoolsProblemMarkerInfo { return marker.getAttribute(IAutotoolsMarker.MARKER_PROBLEM_TYPE); } - public String getLibraryInfo(){ + public String getLibraryInfo() { return marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO); } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsPropertyConstants.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsPropertyConstants.java index 948e11ea8a..314e7ecf23 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsPropertyConstants.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsPropertyConstants.java @@ -16,24 +16,25 @@ package org.eclipse.cdt.internal.autotools.core; import org.eclipse.cdt.autotools.core.AutotoolsPlugin; import org.eclipse.core.runtime.QualifiedName; - public class AutotoolsPropertyConstants { - + static final String PREFIX = AutotoolsPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$ static final String PREFIX_COMPAT = "org.eclipse.linuxtools.cdt.autotools."; //$NON-NLS-1$ public static final String AUTOMAKE_VERSION_STRING = "AutoconfEditorAutomakeVersion"; //$NON-NLS-1$ public static final QualifiedName AUTOMAKE_VERSION = new QualifiedName(PREFIX, AUTOMAKE_VERSION_STRING); - public static final QualifiedName AUTOMAKE_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT, AUTOMAKE_VERSION_STRING); + public static final QualifiedName AUTOMAKE_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT, + AUTOMAKE_VERSION_STRING); public static final String AUTOCONF_VERSION_STRING = "AutoconfEditorAutoconfVersion"; //$NON-NLS-1$ public static final QualifiedName AUTOCONF_VERSION = new QualifiedName(PREFIX, AUTOCONF_VERSION_STRING); - public static final QualifiedName AUTOCONF_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT, AUTOCONF_VERSION_STRING); + public static final QualifiedName AUTOCONF_VERSION_COMPAT = new QualifiedName(PREFIX_COMPAT, + AUTOCONF_VERSION_STRING); public static final String AUTOCONF_MACRO_VERSIONING = "AutoconfEditorMacroVersioning"; //$NON-NLS-1$ public static final QualifiedName AUTOCONF_TOOL = new QualifiedName(PREFIX, "AutoconfToolPath"); //$NON-NLS-1$ public static final QualifiedName AUTOMAKE_TOOL = new QualifiedName(PREFIX, "AutomakeToolPath"); //$NON-NLS-1$ - public static final QualifiedName ACLOCAL_TOOL = new QualifiedName(PREFIX, "AclocalToolPath"); //$NON-NLS-1$ - public static final QualifiedName AUTOHEADER_TOOL = new QualifiedName(PREFIX, "AutoheaderToolPath"); //$NON-NLS-1$ - public static final QualifiedName AUTORECONF_TOOL = new QualifiedName(PREFIX, "AutoreconfToolPath"); //$NON-NLS-1$ - public static final QualifiedName LIBTOOLIZE_TOOL = new QualifiedName(PREFIX, "LibtoolizePath"); //$NON-NLS-1$ + public static final QualifiedName ACLOCAL_TOOL = new QualifiedName(PREFIX, "AclocalToolPath"); //$NON-NLS-1$ + public static final QualifiedName AUTOHEADER_TOOL = new QualifiedName(PREFIX, "AutoheaderToolPath"); //$NON-NLS-1$ + public static final QualifiedName AUTORECONF_TOOL = new QualifiedName(PREFIX, "AutoreconfToolPath"); //$NON-NLS-1$ + public static final QualifiedName LIBTOOLIZE_TOOL = new QualifiedName(PREFIX, "LibtoolizePath"); //$NON-NLS-1$ public static final QualifiedName CLEAN_DELETE = new QualifiedName(PREFIX, "CleanDelete"); //$NON-NLS-1$ public static final QualifiedName CLEAN_MAKE_TARGET = new QualifiedName(PREFIX, "CleanMakeTarget"); //$NON-NLS-1$ public static final QualifiedName SCANNER_USE_MAKE_W = new QualifiedName(PREFIX, "ScannerUseMakeW"); @@ -41,7 +42,7 @@ public class AutotoolsPropertyConstants { public static final QualifiedName OPEN_INCLUDE = new QualifiedName(PREFIX, "IncludeResourceMapping"); //$NON-NLS-1$ public static final QualifiedName OPEN_INCLUDE_P = new QualifiedName(PREFIX, "PersistentIncludeResourceMapping"); //$NON-NLS-1$ public static final QualifiedName SCANNER_INFO_DIRTY = new QualifiedName(PREFIX, "ScannerInfoDirty"); // $NON-NLSp-1$ - + public static final String[] fACVersions = { "2.13", "2.59", "2.61", "2.67", "2.68" }; //$NON-NLS-1$ public static final String AC_VERSION_2_13 = fACVersions[0]; public static final String AC_VERSION_2_59 = fACVersions[1]; @@ -49,12 +50,12 @@ public class AutotoolsPropertyConstants { public static final String AC_VERSION_2_67 = fACVersions[3]; public static final String AC_VERSION_2_68 = fACVersions[4]; public static final String LATEST_AC_VERSION = fACVersions[fACVersions.length - 1]; - - public static final String[] fAMVersions = {"1.4-p6", "1.9.5", "1.9.6", "1.11.1"}; //$NON-NLS-1$ + + public static final String[] fAMVersions = { "1.4-p6", "1.9.5", "1.9.6", "1.11.1" }; //$NON-NLS-1$ public static final String LATEST_AM_VERSION = fAMVersions[fAMVersions.length - 1]; - + public static final String CLEAN_MAKE_TARGET_DEFAULT = "distclean"; //$NON-NLS-1$ - + public static final String TRUE = "true"; //$NON-NLS-1$ public static final String FALSE = "false"; //$NON-NLS-1$ } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java index 7eecc54642..5873edf923 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java @@ -36,43 +36,39 @@ import org.eclipse.core.runtime.Path; // which is similar to the CDT one. public class ErrorParser extends MarkerGenerator implements IErrorParser { public static final String ID = AutotoolsPlugin.PLUGIN_ID + ".errorParser"; //$NON-NLS-1$ - private Pattern pkgconfigError = - Pattern.compile(".*?(configure:\\s+error:\\s+Package requirements\\s+\\((.*?)\\)\\s+were not met).*"); //$NON-NLS-1$ - private Pattern genconfigError = - Pattern.compile(".*?configure:\\s+error:\\s+(.*)"); //$NON-NLS-1$ - private Pattern checkingFail = - Pattern.compile("checking for (.*)\\.\\.\\. no"); //$NON-NLS-1$ + private Pattern pkgconfigError = Pattern + .compile(".*?(configure:\\s+error:\\s+Package requirements\\s+\\((.*?)\\)\\s+were not met).*"); //$NON-NLS-1$ + private Pattern genconfigError = Pattern.compile(".*?configure:\\s+error:\\s+(.*)"); //$NON-NLS-1$ + private Pattern checkingFail = Pattern.compile("checking for (.*)\\.\\.\\. no"); //$NON-NLS-1$ - private Pattern changingConfigDirectory = - Pattern.compile("Configuring in (.*)"); //$NON-NLS-1$ + private Pattern changingConfigDirectory = Pattern.compile("Configuring in (.*)"); //$NON-NLS-1$ private IPath buildDir; private IPath sourcePath; private IProject project; - public ErrorParser(){ + public ErrorParser() { } - + public ErrorParser(IPath sourcePath, IPath buildPath) { this.buildDir = buildPath; this.sourcePath = sourcePath; } @Override - public boolean processLine(String line, - org.eclipse.cdt.core.ErrorParserManager eoParser) { + public boolean processLine(String line, org.eclipse.cdt.core.ErrorParserManager eoParser) { if (this.project == null) this.project = eoParser.getProject(); if (this.buildDir == null) this.buildDir = new Path(eoParser.getWorkingDirectoryURI().getPath()); - + if (this.sourcePath == null) this.sourcePath = eoParser.getProject().getLocation(); AutotoolsProblemMarkerInfo marker = processLine(line); - if ( marker != null){ + if (marker != null) { // Check to see if addProblemMarker exists. try { Method method = eoParser.getClass().getMethod("addProblemMarker", ProblemMarkerInfo.class); @@ -92,9 +88,9 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { public boolean processLine(String line, ErrorParserManager eoParser) { if (this.project == null) this.project = eoParser.getProject(); - + AutotoolsProblemMarkerInfo marker = processLine(line); - if ( marker != null){ + if (marker != null) { eoParser.addProblemMarker(marker); return true; } @@ -103,9 +99,9 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { public AutotoolsProblemMarkerInfo processLine(String line) { Matcher m; - + m = changingConfigDirectory.matcher(line); - if(m.matches()){ + if (m.matches()) { // set configuration directory. this.buildDir = this.buildDir.append(m.group(1)); this.sourcePath = this.sourcePath.append(m.group(1)); @@ -114,22 +110,24 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { m = pkgconfigError.matcher(line); if (m.matches()) { - return new AutotoolsProblemMarkerInfo(getProject(), -1, m.group(1), SEVERITY_ERROR_BUILD, null, null, m.group(2), AutotoolsProblemMarkerInfo.Type.PACKAGE); + return new AutotoolsProblemMarkerInfo(getProject(), -1, m.group(1), SEVERITY_ERROR_BUILD, null, null, + m.group(2), AutotoolsProblemMarkerInfo.Type.PACKAGE); } - + m = genconfigError.matcher(line); if (m.matches()) { return new AutotoolsProblemMarkerInfo(getProject(), -1, m.group(1), SEVERITY_ERROR_BUILD, null, AutotoolsProblemMarkerInfo.Type.GENERIC); } - + m = checkingFail.matcher(line); if (m.matches()) { // We know that there is a 'checking for ...' fail. // Find the log file containing this check AutotoolsProblemMarkerInfo.Type type = getCheckType(m.group(1)); if (type != null) - return new AutotoolsProblemMarkerInfo(getProject(), "Missing " + type + " " + m.group(1), SEVERITY_INFO, m.group(1), type); + return new AutotoolsProblemMarkerInfo(getProject(), "Missing " + type + " " + m.group(1), SEVERITY_INFO, + m.group(1), type); } return null; @@ -139,7 +137,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { * Given the name of the filed check object, look for it in the log file * file and then examine the configure script to figure out what the type of * the check was. - * + * * @param name * @return */ @@ -191,7 +189,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { /** * Check the log file for the check for the given name and return the line * number in configure where the check occurs. - * + * * @param name * @return */ @@ -201,8 +199,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { if (!file.exists()) return -1; try (LineNumberReader reader = new LineNumberReader(new FileReader(file))) { - Pattern errorPattern = - Pattern.compile("configure:(\\d+): checking for " + name); //$NON-NLS-1$ + Pattern errorPattern = Pattern.compile("configure:(\\d+): checking for " + name); //$NON-NLS-1$ String line; while ((line = reader.readLine()) != null) { Matcher m = errorPattern.matcher(line); @@ -215,7 +212,7 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { } return -1; } - + @Override public IProject getProject() { return this.project; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParserManager.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParserManager.java index 490fb7db3b..f536e1b8ed 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParserManager.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParserManager.java @@ -7,13 +7,13 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) * James Blackburn (Broadcom) - Bug 247838 * Andrew Gvozdev (Quoin Inc) - * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation + * Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation *******************************************************************************/ package org.eclipse.cdt.internal.autotools.core; @@ -37,11 +37,11 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.URIUtil; /** - * The purpose of ErrorParserManager is to delegate the work of error parsing + * The purpose of ErrorParserManager is to delegate the work of error parsing * build output to {@link IErrorParser}s, assist in finding {@link IResource}s, and * help create appropriate error/warning/info markers to be displayed * by the Problems view. - * + * * @noextend This class is not intended to be subclassed by clients. */ @SuppressWarnings("restriction") @@ -51,7 +51,7 @@ public class ErrorParserManager extends OutputStream { * as key/value pair with key="org.eclipse.cdt.core.errorOutputParser" * @deprecated since CDT 4.0. */ - + /** * Delimiter for error parsers presented in one string. * @since 5.2 @@ -59,7 +59,7 @@ public class ErrorParserManager extends OutputStream { public static final char ERROR_PARSER_DELIMITER = ';'; private int nOpens; - private int lineCounter=0; + private int lineCounter = 0; private final IProject fProject; private final MarkerGenerator fMarkerGenerator; @@ -74,10 +74,9 @@ public class ErrorParserManager extends OutputStream { private OutputStream outputStream; private final StringBuilder currentLine = new StringBuilder(); - /** * Constructor. - * + * * @param project - project being built. * @param markerGenerator - marker generator able to create markers. */ @@ -85,12 +84,11 @@ public class ErrorParserManager extends OutputStream { this(project, project.getLocationURI(), markerGenerator); } - /** * URI based constructor. - * + * * @param project - project being built. - * @param baseDirectoryURI - absolute location URI of working directory of where the build is performed. + * @param baseDirectoryURI - absolute location URI of working directory of where the build is performed. * @param markerGenerator - marker generator able to create markers. * @since 2.0 */ @@ -134,7 +132,7 @@ public class ErrorParserManager extends OutputStream { * {@link #pushDirectory} and {@link #popDirectory} are used to change working directory * from where file name is searched (see {@link #findFileInWorkspace}). * The intention is to handle make output of commands "pushd dir" and "popd". - * + * * @param dir - another directory level to keep in stack -- corresponding to 'pushd'. */ public void pushDirectory(IPath dir) { @@ -156,7 +154,7 @@ public class ErrorParserManager extends OutputStream { * {@link #pushDirectoryURI} and {@link #popDirectoryURI} are used to change working directory * from where file name is searched (see {@link #findFileInWorkspace}). * The intention is to handle make output of commands "pushd dir" and "popd". - * + * * @param dir - another directory level to keep in stack -- corresponding to 'pushd'. * @since 5.1 */ @@ -173,7 +171,7 @@ public class ErrorParserManager extends OutputStream { * {@link #pushDirectoryURI(URI)} and {@link #popDirectoryURI()} are used to change working directory * from where file name is searched (see {@link #findFileInWorkspace(IPath)}). * The intention is to handle make output of commands "pushd" and "popd". - * + * * @return previous build directory location corresponding 'popd' command. * @since 5.1 */ @@ -194,7 +192,6 @@ public class ErrorParserManager extends OutputStream { return fDirectoryStack.size(); } - /** * Parses the input and tries to generate error or warning markers */ @@ -202,7 +199,7 @@ public class ErrorParserManager extends OutputStream { String lineTrimmed = line.trim(); lineCounter++; - ProblemMarkerInfo marker=null; + ProblemMarkerInfo marker = null; for (ErrorParser parser : fErrorParsers.values()) { ErrorParser curr = parser; @@ -217,7 +214,7 @@ public class ErrorParserManager extends OutputStream { } // standard behavior (pre 5.1) is to trim the line String lineToParse = lineTrimmed; - if ((types & IErrorParser2.KEEP_UNTRIMMED) !=0 ) { + if ((types & IErrorParser2.KEEP_UNTRIMMED) != 0) { // untrimmed lines lineToParse = line; } @@ -228,11 +225,11 @@ public class ErrorParserManager extends OutputStream { // It should not stop parsing of the rest of output. try { consume = curr.processLine(lineToParse, this); - } catch (Exception e){ + } catch (Exception e) { AutotoolsPlugin.log(e); } finally { if (fErrors.size() > 0) { - if (marker==null) + if (marker == null) marker = fErrors.get(0); fErrors.clear(); } @@ -240,12 +237,12 @@ public class ErrorParserManager extends OutputStream { if (consume) break; - } + } outputLine(line, marker); } - - /** - * Conditionally output line to outputStream. If stream + + /** + * Conditionally output line to outputStream. If stream * supports error markers, use it, otherwise use conventional stream */ private void outputLine(String line, ProblemMarkerInfo marker) { @@ -256,12 +253,12 @@ public class ErrorParserManager extends OutputStream { try { if (marker != null) { if (outputStream instanceof IErrorMarkeredOutputStream) { - IErrorMarkeredOutputStream mos = (IErrorMarkeredOutputStream)outputStream; + IErrorMarkeredOutputStream mos = (IErrorMarkeredOutputStream) outputStream; mos.write(l, marker); } } byte[] b = l.getBytes(); - outputStream.write(b, 0, b.length); + outputStream.write(b, 0, b.length); } catch (IOException e) { AutotoolsPlugin.log(e); } @@ -275,10 +272,9 @@ public class ErrorParserManager extends OutputStream { return lineCounter; } - /** * Add marker to the list of error markers. - * + * * @param file - resource to add the new marker. * @param lineNumber - line number of the error. * @param desc - description of the error. @@ -292,7 +288,7 @@ public class ErrorParserManager extends OutputStream { /** * Add marker to the list of error markers. - * + * * @param file - resource to add the new marker. * @param lineNumber - line number of the error. * @param desc - description of the error. @@ -304,19 +300,19 @@ public class ErrorParserManager extends OutputStream { * @param varName - variable name. * @param externalPath - external path pointing to a file outside the workspace. */ - public void generateExternalMarker(IResource file, int lineNumber, String desc, int severity, - String varName, IPath externalPath, String libraryInfo, AutotoolsProblemMarkerInfo.Type type) { - AutotoolsProblemMarkerInfo problemMarkerInfo = - new AutotoolsProblemMarkerInfo(file, lineNumber, desc, severity, varName, externalPath, libraryInfo, type); + public void generateExternalMarker(IResource file, int lineNumber, String desc, int severity, String varName, + IPath externalPath, String libraryInfo, AutotoolsProblemMarkerInfo.Type type) { + AutotoolsProblemMarkerInfo problemMarkerInfo = new AutotoolsProblemMarkerInfo(file, lineNumber, desc, severity, + varName, externalPath, libraryInfo, type); addProblemMarker(problemMarkerInfo); } /** * Add the given marker to the list of error markers. - * - * @param problemMarkerInfo - The marker to be added + * + * @param problemMarkerInfo - The marker to be added */ - public void addProblemMarker(AutotoolsProblemMarkerInfo problemMarkerInfo){ + public void addProblemMarker(AutotoolsProblemMarkerInfo problemMarkerInfo) { fErrors.add(problemMarkerInfo.getMarker()); fMarkerGenerator.addMarker(problemMarkerInfo); } @@ -332,7 +328,7 @@ public class ErrorParserManager extends OutputStream { /** * Method setOutputStream. * Note: you have to close this stream explicitly - * don't rely on ErrorParserManager.close(). + * don't rely on ErrorParserManager.close(). * @param os - output stream */ public void setOutputStream(OutputStream os) { @@ -340,9 +336,9 @@ public class ErrorParserManager extends OutputStream { } /** - * Method getOutputStream. + * Method getOutputStream. * Note: you have to close this stream explicitly - * don't rely on ErrorParserManager.close(). + * don't rely on ErrorParserManager.close(). * @return OutputStream */ public OutputStream getOutputStream() { @@ -352,8 +348,8 @@ public class ErrorParserManager extends OutputStream { /** * @see java.io.OutputStream#close() - * Note: don't rely on this method to close underlying OutputStream, - * close it explicitly + * Note: don't rely on this method to close underlying OutputStream, + * close it explicitly */ @Override public synchronized void close() { @@ -393,7 +389,7 @@ public class ErrorParserManager extends OutputStream { // This method examines contents of currentLine buffer // if it contains whole line this line is checked by error - // parsers (processLine method). + // parsers (processLine method). // If flush is true rest of line is checked by error parsers. private void checkLine(boolean flush) { String buffer = currentLine.toString(); @@ -401,8 +397,8 @@ public class ErrorParserManager extends OutputStream { while ((i = buffer.indexOf('\n')) != -1) { String line = buffer.substring(0, i); // get rid of any trailing '\r' - if (line.endsWith("\r")) //$NON-NLS-1$ - line=line.substring(0,line.length()-1); + if (line.endsWith("\r")) //$NON-NLS-1$ + line = line.substring(0, line.length() - 1); processLine(line); previousLine = line; buffer = buffer.substring(i + 1); // skip the \n and advance @@ -418,32 +414,29 @@ public class ErrorParserManager extends OutputStream { } } - /** - * Converts a location {@link IPath} to an {@link URI}. Contrary to - * {@link URIUtil#toURI(IPath)} this method does not assume that the path belongs - * to local file system. - * - * The returned URI uses the scheme and authority of the current working directory - * as returned by {@link #getWorkingDirectoryURI()} - * + * Converts a location {@link IPath} to an {@link URI}. Contrary to + * {@link URIUtil#toURI(IPath)} this method does not assume that the path belongs + * to local file system. + * + * The returned URI uses the scheme and authority of the current working directory + * as returned by {@link #getWorkingDirectoryURI()} + * * @param path - the path to convert to URI. * @return URI * @since 5.1 */ private URI toURI(IPath path) { -// try { - URI baseURI = getWorkingDirectoryURI(); - String uriString = path.toString(); - - // On Windows "C:/folder/" -> "/C:/folder/" - if (path.isAbsolute() && uriString.charAt(0) != IPath.SEPARATOR) - uriString = IPath.SEPARATOR + uriString; - - return EFSExtensionManager.getDefault().createNewURIFromPath(baseURI, uriString); - } + // try { + URI baseURI = getWorkingDirectoryURI(); + String uriString = path.toString(); + // On Windows "C:/folder/" -> "/C:/folder/" + if (path.isAbsolute() && uriString.charAt(0) != IPath.SEPARATOR) + uriString = IPath.SEPARATOR + uriString; + return EFSExtensionManager.getDefault().createNewURIFromPath(baseURI, uriString); + } /** * @param ids - array of error parser IDs @@ -451,9 +444,9 @@ public class ErrorParserManager extends OutputStream { * @since 5.2 */ public static String toDelimitedString(String[] ids) { - String result=""; //$NON-NLS-1$ + String result = ""; //$NON-NLS-1$ for (String id : ids) { - if (result.length()==0) { + if (result.length() == 0) { result = id; } else { result += ERROR_PARSER_DELIMITER + id; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MakeMessages.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MakeMessages.java index 0ec99d68e2..b949e8c523 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MakeMessages.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MakeMessages.java @@ -19,7 +19,7 @@ import java.util.ResourceBundle; public class MakeMessages { - private static final String RESOURCE_BUNDLE= MakeMessages.class.getName(); + private static final String RESOURCE_BUNDLE = MakeMessages.class.getName(); private static ResourceBundle fgResourceBundle; static { try { @@ -28,10 +28,10 @@ public class MakeMessages { fgResourceBundle = null; } } - + private MakeMessages() { } - + public static String getString(String key) { try { return fgResourceBundle.getString(key); @@ -41,10 +41,10 @@ public class MakeMessages { return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ } } - + /** * Gets a string from the resource bundle and formats it with the argument - * + * * @param key the string used to get the bundle value, must not be null */ public static String getFormattedString(String key, Object arg) { @@ -53,7 +53,7 @@ public class MakeMessages { /** * Gets a string from the resource bundle and formats it with arguments - */ + */ public static String getFormattedString(String key, Object[] args) { return MessageFormat.format(getString(key), args); } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerGenerator.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerGenerator.java index cc4feaf4fa..67d36217f7 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerGenerator.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerGenerator.java @@ -69,15 +69,14 @@ public abstract class MarkerGenerator { if (errorVar != null) { marker.setAttribute(IAutotoolsMarker.MARKER_VARIABLE, errorVar); } - } - catch (CoreException e) { + } catch (CoreException e) { AutotoolsPlugin.log(e.getStatus()); } } - + public abstract IProject getProject(); - + public boolean hasMarkers(IResource file) { IMarker[] markers; try { @@ -94,14 +93,15 @@ public abstract class MarkerGenerator { public void addMarker(AutotoolsProblemMarkerInfo autotoolsMarker) { ProblemMarkerInfo info = autotoolsMarker.getMarker(); - + try { - IResource markerResource = info.file ; - if (markerResource==null) { + IResource markerResource = info.file; + if (markerResource == null) { markerResource = getProject(); } - IMarker[] cur = markerResource.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true, IResource.DEPTH_ONE); -// IMarker[] cur = markerResource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE); + IMarker[] cur = markerResource.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true, + IResource.DEPTH_ONE); + // IMarker[] cur = markerResource.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_ONE); /* * Try to find matching markers and don't put in duplicates */ @@ -110,14 +110,15 @@ public abstract class MarkerGenerator { int line = ((Integer) cur[i].getAttribute(IMarker.LOCATION)).intValue(); int sev = ((Integer) cur[i].getAttribute(IMarker.SEVERITY)).intValue(); String mesg = (String) cur[i].getAttribute(IMarker.MESSAGE); - if (line == info.lineNumber && sev == mapMarkerSeverity(info.severity) && mesg.equals(info.description)) { + if (line == info.lineNumber && sev == mapMarkerSeverity(info.severity) + && mesg.equals(info.description)) { return; } } } IMarker marker = markerResource.createMarker(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER); -// IMarker marker = markerResource.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER); + // IMarker marker = markerResource.createMarker(ICModelMarker.C_MODEL_PROBLEM_MARKER); marker.setAttribute(IMarker.LOCATION, info.lineNumber); marker.setAttribute(IMarker.MESSAGE, info.description); marker.setAttribute(IMarker.SEVERITY, mapMarkerSeverity(info.severity)); @@ -133,36 +134,34 @@ public abstract class MarkerGenerator { // Add all other client defined attributes. Map<String, String> attributes = info.getAttributes(); - if (attributes != null){ + if (attributes != null) { for (Entry<String, String> entry : attributes.entrySet()) { marker.setAttribute(entry.getKey(), entry.getValue()); } } - - } - catch (CoreException e) { + } catch (CoreException e) { AutotoolsPlugin.log(e.getStatus()); } } private int mapMarkerSeverity(int severity) { switch (severity) { - case SEVERITY_ERROR_BUILD : - case SEVERITY_ERROR_RESOURCE : - return IMarker.SEVERITY_ERROR; - case SEVERITY_INFO : - return IMarker.SEVERITY_INFO; - case SEVERITY_WARNING : - return IMarker.SEVERITY_WARNING; + case SEVERITY_ERROR_BUILD: + case SEVERITY_ERROR_RESOURCE: + return IMarker.SEVERITY_ERROR; + case SEVERITY_INFO: + return IMarker.SEVERITY_INFO; + case SEVERITY_WARNING: + return IMarker.SEVERITY_WARNING; } return IMarker.SEVERITY_ERROR; } - + /** * Removes the IMarkers for the project specified in the argument if the * project exists, and is open. - * + * * @param project */ public void removeAllMarkers(IProject project) { @@ -175,7 +174,7 @@ public abstract class MarkerGenerator { IMarker[] markers; try { markers = project.findMarkers(IAutotoolsMarker.AUTOTOOLS_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); -// markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); + // markers = project.findMarkers(ICModelMarker.C_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); } catch (CoreException e) { // Handled just about every case in the sanity check return; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerResolutionGenerator.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerResolutionGenerator.java index 0a13639615..d96f16371d 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerResolutionGenerator.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/MarkerResolutionGenerator.java @@ -21,11 +21,11 @@ public class MarkerResolutionGenerator implements IMarkerResolutionGenerator { @Override public IMarkerResolution[] getResolutions(IMarker marker) { -// System.out.println("in marker resolution, library info is " + marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, "")); -// String libraryInfo = marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, null); -// if (libraryInfo != null) { -// return new IMarkerResolution[] {new PkgconfigErrorResolution(libraryInfo)}; -// }; + // System.out.println("in marker resolution, library info is " + marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, "")); + // String libraryInfo = marker.getAttribute(IAutotoolsMarker.MARKER_LIBRARY_INFO, null); + // if (libraryInfo != null) { + // return new IMarkerResolution[] {new PkgconfigErrorResolution(libraryInfo)}; + // }; return new IMarkerResolution[0]; } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java index e3699a0eda..8fb79eb627 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java @@ -31,11 +31,11 @@ import org.eclipse.ui.IMarkerResolution; public class PkgconfigErrorResolution implements IMarkerResolution { private static class ConsoleOutputStream extends OutputStream { - + protected StringBuffer fBuffer; - + public ConsoleOutputStream() { - fBuffer= new StringBuffer(); + fBuffer = new StringBuffer(); } public synchronized String readBuffer() { @@ -50,16 +50,16 @@ public class PkgconfigErrorResolution implements IMarkerResolution { ascii[0] = (byte) c; fBuffer.append(new String(ascii)); } - - @Override + + @Override public synchronized void write(byte[] b, int off, int len) { - fBuffer.append(new String(b, off, len)); - } + fBuffer.append(new String(b, off, len)); + } } - + private static final String PKG_UPDATE_MSG = "UpdatePackage.msg"; //$NON-NLS-1$ private String pkgName; - + public PkgconfigErrorResolution(String pkgconfigRequirement) { // Get the pkgconfig package name from the requirement message. Pattern p = Pattern.compile("(.*?)[\\s,>,<,=].*"); @@ -68,10 +68,10 @@ public class PkgconfigErrorResolution implements IMarkerResolution { pkgName = m.group(1); } } - + @Override public String getLabel() { - return AutotoolsPlugin.getFormattedString(PKG_UPDATE_MSG, new String[] {pkgName}); + return AutotoolsPlugin.getFormattedString(PKG_UPDATE_MSG, new String[] { pkgName }); } @Override @@ -85,23 +85,20 @@ public class PkgconfigErrorResolution implements IMarkerResolution { // Note, that we won't have any pkgconfig path settings from the configure call // so we can't handle the situation where the user doesn't have pkgconfig files // stored in the usual place. - IPath pkgconfigPath = - new Path("/usr/lib/pkgconfig").append(pkgName+".pc"); //$NON-NLS-1$ //$NON-NLS-2$ + IPath pkgconfigPath = new Path("/usr/lib/pkgconfig").append(pkgName + ".pc"); //$NON-NLS-1$ //$NON-NLS-2$ // Get a launcher for the config command RemoteCommandLauncher launcher = new RemoteCommandLauncher(); IPath commandPath = new Path("rpm"); //$NON-NLS-1$ - String[] commandArgs = - new String[] {"-q", //$NON-NLS-1$ + String[] commandArgs = new String[] { "-q", //$NON-NLS-1$ "--queryformat", //$NON-NLS-1$ "%{NAME}", //$NON-NLS-1$ "--whatprovides", //$NON-NLS-1$ - pkgconfigPath.toOSString()}; + pkgconfigPath.toOSString() }; try { // Use CDT launcher to run rpm to query the package that provides // the pkgconfig .pc file for the package in question. ConsoleOutputStream output = new ConsoleOutputStream(); - Process proc = launcher.execute(commandPath, commandArgs, null, - new Path("."), new NullProgressMonitor()); + Process proc = launcher.execute(commandPath, commandArgs, null, new Path("."), new NullProgressMonitor()); if (proc != null) { try { // Close the input of the process since we will never write to @@ -109,8 +106,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution { proc.getOutputStream().close(); } catch (IOException e) { } - if (launcher.waitAndRead(output, output, new NullProgressMonitor()) - != ICommandLauncher.OK) { + if (launcher.waitAndRead(output, output, new NullProgressMonitor()) != ICommandLauncher.OK) { AutotoolsPlugin.logErrorMessage(launcher.getErrorMessage()); } else { String result = output.readBuffer(); @@ -118,7 +114,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution { System.out.println("need to execute update of " + result); } } - + } catch (CoreException e) { e.printStackTrace(); } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/VersionComparator.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/VersionComparator.java index 52f8786f8c..b980ec8dfc 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/VersionComparator.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/VersionComparator.java @@ -20,9 +20,9 @@ public class VersionComparator { * Compare two version numbers if * return -1 if v1 is older than v2 0 if they are the same and +1 * if v1 is newer than v2 - * + * * Version numbers are expected to be in the format x.y.z... - * + * * So: * VersionComparator.compare("1.0", "1.2") return -1 * VersionComparator.compare("1.5", "1.2") returns 1 @@ -33,28 +33,28 @@ public class VersionComparator { public static int compare(String v1, String v2) { String[] v1digits = v1.split("\\."); String[] v2digits = v2.split("\\."); - + for (int i = 0; i < v1digits.length && i < v2digits.length; i++) { int d1 = Integer.valueOf(v1digits[i]); int d2 = Integer.valueOf(v2digits[i]); - + if (d1 < d2) return -1; - + if (d1 > d2) return 1; } - + // At this point all digits have the same value // so the version with the longer string wins - + if (v1digits.length < v2digits.length) return -1; - + if (v1digits.length > v2digits.length) return 1; return 0; } - + } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AbstractConfigurationOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AbstractConfigurationOption.java index 92e6c6c89f..38916f0d45 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AbstractConfigurationOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AbstractConfigurationOption.java @@ -25,13 +25,13 @@ public abstract class AbstractConfigurationOption implements IConfigureOption { public AbstractConfigurationOption(String name, AutotoolsConfiguration cfg) { this(name, name, cfg); } - + public AbstractConfigurationOption(String name, String msgName, AutotoolsConfiguration cfg) { this.name = name; this.msgName = msgName; this.cfg = cfg; } - + @Override public String getDescription() { return ConfigureMessages.getConfigureDescription(msgName); @@ -45,7 +45,7 @@ public abstract class AbstractConfigurationOption implements IConfigureOption { public String getMsgName() { return msgName; } - + @Override public String getName() { return name; @@ -54,7 +54,7 @@ public abstract class AbstractConfigurationOption implements IConfigureOption { public AutotoolsConfiguration getCfg() { return cfg; } - + @Override public List<String> getParameters() { List<String> parameters = new ArrayList<>(); @@ -62,7 +62,7 @@ public abstract class AbstractConfigurationOption implements IConfigureOption { parameters.add(getParameter()); return parameters; } - + public String getParameterName() { return "--" + getName(); } @@ -71,12 +71,12 @@ public abstract class AbstractConfigurationOption implements IConfigureOption { public boolean isCategory() { return false; } - + @Override public boolean isFlag() { return false; } - + @Override public boolean isFlagValue() { return false; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java index 570747bfd0..6e3ce526df 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfiguration.java @@ -30,7 +30,6 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; - public class AutotoolsConfiguration implements IAConfiguration { public static class Option { @@ -39,24 +38,24 @@ public class AutotoolsConfiguration implements IAConfiguration { private String superClassId; private int type; private String defaultValue; - + public Option(String name, int type) { this(name, name, type); } - + public Option(String name, String transformedName, int type) { this.name = name; this.transformedName = transformedName; this.type = type; } - + public Option(String name, String transformedName, String defaultValue, int type) { this.name = name; this.transformedName = transformedName; this.type = type; this.defaultValue = defaultValue; } - + public Option(String name, String transformedName, String defaultValue, String superClassId, int type) { this.name = name; this.transformedName = transformedName; @@ -68,15 +67,15 @@ public class AutotoolsConfiguration implements IAConfiguration { public String getName() { return name; } - + public int getType() { return type; } - + public String getDefaultValue() { return defaultValue; } - + public String getSuperClassId() { return superClassId; } @@ -84,64 +83,66 @@ public class AutotoolsConfiguration implements IAConfiguration { public String getDescription() { return ConfigureMessages.getConfigureDescription(transformedName); } - + public String getToolTip() { return ConfigureMessages.getConfigureTip(transformedName); } } - + // Configure options and categories. List below is ordered. // All options following a category are children of that category // in a tree view, up to the next category. private static Option[] configOpts = new Option[] { - new Option(AutotoolsOptionConstants.TOOL_CONFIGURE, IConfigureOption.TOOL), - new Option(AutotoolsOptionConstants.CATEGORY_GENERAL, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_CONFIGDIR, IConfigureOption.INTERNAL), - new Option(AutotoolsOptionConstants.OPT_CACHE_FILE, "cache_file", IConfigureOption.STRING), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.OPT_HELP, IConfigureOption.BIN), - new Option(AutotoolsOptionConstants.OPT_NO_CREATE, "no_create", IConfigureOption.BIN), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.OPT_QUIET, IConfigureOption.BIN), - new Option(AutotoolsOptionConstants.OPT_VERSION, IConfigureOption.BIN), - new Option(AutotoolsOptionConstants.CATEGORY_PLATFORM, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_HOST, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_BUILD, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_TARGET, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.CATEGORY_DIRECTORIES, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_PREFIX, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_EXEC_PREFIX, "exec_prefix", IConfigureOption.STRING), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.OPT_LIBDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_BINDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_SBINDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_INCLUDEDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_DATADIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_SYSCONFDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_INFODIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_MANDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_SRCDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_LOCALSTATEDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_SHAREDSTATEDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_LIBEXECDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.OPT_OLDINCLUDEDIR, IConfigureOption.STRING), - new Option(AutotoolsOptionConstants.CATEGORY_FILENAMES, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX, "program_prefix", IConfigureOption.STRING), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX, "program_suffix", IConfigureOption.STRING), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME, "program_transform_name", IConfigureOption.STRING), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.CATEGORY_ENVVAR, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_ENVVAR, IConfigureOption.ENVVAR), - new Option(AutotoolsOptionConstants.CATEGORY_FEATURES, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE, "enable_maintainer_mode", IConfigureOption.BIN), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.FLAG_CFLAGS, "cflags", AutotoolsOptionConstants.FLAG_CFLAGS_FLAGS, IConfigureOption.FLAG), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG, "cflags_debug", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$ - new Option(AutotoolsOptionConstants.OPT_CFLAGS_GPROF, "cflags_gprof", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$ - new Option(AutotoolsOptionConstants.OPT_CFLAGS_GCOV, "cflags_gcov", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$ - new Option(AutotoolsOptionConstants.OPT_USER, IConfigureOption.MULTIARG), - new Option(AutotoolsOptionConstants.TOOL_AUTOGEN, "autogen", "autogen.sh", IConfigureOption.TOOL), //$NON-NLS-1$ - new Option(AutotoolsOptionConstants.CATEGORY_OPTIONS, IConfigureOption.CATEGORY), - new Option(AutotoolsOptionConstants.OPT_AUTOGENOPTS, IConfigureOption.MULTIARG), - }; - + new Option(AutotoolsOptionConstants.TOOL_CONFIGURE, IConfigureOption.TOOL), + new Option(AutotoolsOptionConstants.CATEGORY_GENERAL, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_CONFIGDIR, IConfigureOption.INTERNAL), + new Option(AutotoolsOptionConstants.OPT_CACHE_FILE, "cache_file", IConfigureOption.STRING), //$NON-NLS-1$ + new Option(AutotoolsOptionConstants.OPT_HELP, IConfigureOption.BIN), + new Option(AutotoolsOptionConstants.OPT_NO_CREATE, "no_create", IConfigureOption.BIN), //$NON-NLS-1$ + new Option(AutotoolsOptionConstants.OPT_QUIET, IConfigureOption.BIN), + new Option(AutotoolsOptionConstants.OPT_VERSION, IConfigureOption.BIN), + new Option(AutotoolsOptionConstants.CATEGORY_PLATFORM, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_HOST, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_BUILD, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_TARGET, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.CATEGORY_DIRECTORIES, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_PREFIX, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_EXEC_PREFIX, "exec_prefix", IConfigureOption.STRING), //$NON-NLS-1$ + new Option(AutotoolsOptionConstants.OPT_LIBDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_BINDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_SBINDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_INCLUDEDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_DATADIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_SYSCONFDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_INFODIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_MANDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_SRCDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_LOCALSTATEDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_SHAREDSTATEDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_LIBEXECDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.OPT_OLDINCLUDEDIR, IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.CATEGORY_FILENAMES, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX, "program_prefix", IConfigureOption.STRING), //$NON-NLS-1$ + new Option(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX, "program_suffix", IConfigureOption.STRING), //$NON-NLS-1$ + new Option(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME, "program_transform_name", //$NON-NLS-1$ + IConfigureOption.STRING), + new Option(AutotoolsOptionConstants.CATEGORY_ENVVAR, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_ENVVAR, IConfigureOption.ENVVAR), + new Option(AutotoolsOptionConstants.CATEGORY_FEATURES, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE, "enable_maintainer_mode", //$NON-NLS-1$ + IConfigureOption.BIN), + new Option(AutotoolsOptionConstants.FLAG_CFLAGS, "cflags", AutotoolsOptionConstants.FLAG_CFLAGS_FLAGS, //$NON-NLS-1$ + IConfigureOption.FLAG), + new Option(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG, "cflags_debug", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$ + new Option(AutotoolsOptionConstants.OPT_CFLAGS_GPROF, "cflags_gprof", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$ + new Option(AutotoolsOptionConstants.OPT_CFLAGS_GCOV, "cflags_gcov", IConfigureOption.FLAGVALUE), //$NON-NLS-1$ //$NON-NLS-2$ + new Option(AutotoolsOptionConstants.OPT_USER, IConfigureOption.MULTIARG), + new Option(AutotoolsOptionConstants.TOOL_AUTOGEN, "autogen", "autogen.sh", IConfigureOption.TOOL), //$NON-NLS-1$ + new Option(AutotoolsOptionConstants.CATEGORY_OPTIONS, IConfigureOption.CATEGORY), + new Option(AutotoolsOptionConstants.OPT_AUTOGENOPTS, IConfigureOption.MULTIARG), }; + private static Option[] toolList; - + private String id; private boolean isDirty; private boolean isParmsDirty; @@ -156,7 +157,7 @@ public class AutotoolsConfiguration implements IAConfiguration { public AutotoolsConfiguration(IProject project, String name) { this(project, name, true); } - + private AutotoolsConfiguration(IProject project, String name, boolean initialize) { this.id = name; this.project = project; @@ -165,7 +166,7 @@ public class AutotoolsConfiguration implements IAConfiguration { initConfigOptions(); isParmsDirty = true; } - + private void initConfigOptions() { // Put configure options in hash map. Ignore categories. ArrayList<Option> tools = new ArrayList<>(); @@ -214,8 +215,8 @@ public class AutotoolsConfiguration implements IAConfiguration { "org.eclipse.linuxtools.cdt.autotools.core.buildType.debug")) { //$NON-NLS-1$ defaultValue = "CFLAGS='-g -O0'"; //$NON-NLS-1$ try { - if (project.hasNature(CCProjectNature.CC_NATURE_ID)) - defaultValue += " CXXFLAGS='-g -O0'"; //$NON-NLS-1$ + if (project.hasNature(CCProjectNature.CC_NATURE_ID)) + defaultValue += " CXXFLAGS='-g -O0'"; //$NON-NLS-1$ } catch (CoreException e) { // do nothing } @@ -244,9 +245,8 @@ public class AutotoolsConfiguration implements IAConfiguration { configOptions.put(opt.name, f); break; case IConfigureOption.FLAGVALUE: - FlagValueConfigureOption fv - = new FlagValueConfigureOption(opt.name, opt.transformedName, - this, ConfigureMessages.getParameter(opt.transformedName)); + FlagValueConfigureOption fv = new FlagValueConfigureOption(opt.name, opt.transformedName, this, + ConfigureMessages.getParameter(opt.transformedName)); if (defaultValue != null) fv.setValue(defaultValue); lastFlag.addChild(opt.name); @@ -262,7 +262,7 @@ public class AutotoolsConfiguration implements IAConfiguration { } toolList = tools.toArray(new Option[tools.size()]); } - + public static Option[] getOptionList() { return configOpts.clone(); } @@ -276,8 +276,7 @@ public class AutotoolsConfiguration implements IAConfiguration { for (int j = i + 1; j < configOpts.length; ++j) { Option o = configOpts[j]; int type = o.getType(); - if (type != IConfigureOption.CATEGORY && - type != IConfigureOption.TOOL) + if (type != IConfigureOption.CATEGORY && type != IConfigureOption.TOOL) options.add(o); else return options.toArray(new Option[options.size()]); @@ -290,17 +289,17 @@ public class AutotoolsConfiguration implements IAConfiguration { options.add(o); else if (type == IConfigureOption.TOOL) return options.toArray(new Option[options.size()]); - } + } } } } return options.toArray(new Option[options.size()]); } - + public static Option[] getTools() { return toolList.clone(); } - + @Override public IConfigureOption getOption(String name) { return configOptions.get(name); @@ -310,7 +309,7 @@ public class AutotoolsConfiguration implements IAConfiguration { public IAConfiguration copy() { return copy(this.id); } - + @Override public IAConfiguration copy(String newId) { AutotoolsConfiguration cfg = new AutotoolsConfiguration(project, newId, false); @@ -325,29 +324,29 @@ public class AutotoolsConfiguration implements IAConfiguration { cfg.setDirty(true); // we are cloning with a new id, treat it as never built/dirty return cfg; } - + @Override public String getId() { return id; } - + @Override public boolean isDirty() { return isDirty; } - + @Override public void setDirty(boolean value) { isDirty = value; if (isDirty) isParmsDirty = true; } - + @Override public Map<String, IConfigureOption> getOptions() { return configOptions; } - + @Override public String getToolParameters(String name) { StringBuilder buf = new StringBuilder(); @@ -404,7 +403,7 @@ public class AutotoolsConfiguration implements IAConfiguration { } } } - + @Override public void setConfigToolDirectory(String configToolDirectory) { setOption("configdir", configToolDirectory); diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java index 8e9d2a363e..c86e682eb0 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsConfigurationManager.java @@ -64,10 +64,10 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; public class AutotoolsConfigurationManager implements IResourceChangeListener { - + public static final String CFG_FILE_NAME = ".autotools"; //$NON-NLS-1$ private static final String CFG_CANT_SAVE = "Configure.Error.NoProjectToSave"; //$NON-NLS-1$ - + /** * @since 1.2 */ @@ -80,18 +80,18 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { private static AutotoolsConfigurationManager instance; private static Random rand = new Random(); - + private boolean isSyncing; - + private static Map<String, Map<String, IAConfiguration>> configs; private static Map<String, Map<String, IAConfiguration>> tmpConfigs; - + private AutotoolsConfigurationManager() { configs = new HashMap<>(); tmpConfigs = new HashMap<>(); ResourcesPlugin.getWorkspace().addResourceChangeListener(this); } - + public static AutotoolsConfigurationManager getInstance() { if (instance == null) { instance = new AutotoolsConfigurationManager(); @@ -102,7 +102,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { public synchronized IAConfiguration createDefaultConfiguration(String id) { return new AutotoolsConfiguration(id); } - + public synchronized IAConfiguration createDefaultConfiguration(IProject project, String id) { return new AutotoolsConfiguration(project, id); } @@ -130,15 +130,14 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { } return cfg; } - - + public synchronized boolean isConfigurationAlreadySaved(IProject project, ICConfigurationDescription cfgd) { Map<String, IAConfiguration> cfgs = getSavedConfigs(project); if (cfgs != null) return cfgs.get(cfgd.getId()) != null; return false; } - + public synchronized void addConfiguration(IProject project, IAConfiguration cfg) { String projectName = project.getName(); Map<String, IAConfiguration> cfgs = getSavedConfigs(project); @@ -149,7 +148,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { cfgs.put(cfg.getId(), cfg); saveConfigs(project); } - + public synchronized boolean isSyncing() { return isSyncing; } @@ -157,15 +156,15 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { private synchronized void setSyncing(boolean value) { isSyncing = value; } - - /** + + /** * Synchronize the current set of configurations for the project with the * Autotools saved configuration data. This is required when configuration * management occurs outside of the Autotools Configure Settings page in the * Property menu. - * + * * @param project to synchronize configurations for - * + * */ public synchronized void syncConfigurations(IProject project) { setSyncing(true); @@ -182,14 +181,15 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { clearTmpConfigurations(project); replaceProjectConfigurations(project, newCfgList); } - + public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs) { String projectName = project.getName(); configs.put(projectName, cfgs); saveConfigs(project); } - public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs, ICConfigurationDescription[] cfgds) { + public synchronized void replaceProjectConfigurations(IProject project, Map<String, IAConfiguration> cfgs, + ICConfigurationDescription[] cfgds) { String projectName = project.getName(); configs.put(projectName, cfgs); saveConfigs(project, cfgds); @@ -223,8 +223,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { cfgId = cfgIdNode.getNodeValue(); else if (nameNode != null) { String cfgName = nameNode.getNodeValue(); - ICConfigurationDescription cfgd = - CoreModel.getDefault().getProjectDescription(project).getConfigurationByName(cfgName); + ICConfigurationDescription cfgd = CoreModel.getDefault().getProjectDescription(project) + .getConfigurationByName(cfgName); if (cfgd != null) cfgId = cfgd.getId(); else @@ -254,7 +254,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { NamedNodeMap optionAttrs2 = flagChild.getAttributes(); Node id2 = optionAttrs2.getNamedItem("id"); //$NON-NLS-1$ Node value = optionAttrs2.getNamedItem("value"); //$NON-NLS-1$ - cfg.setOption(id2.getNodeValue(), value.getNodeValue()); + cfg.setOption(id2.getNodeValue(), value.getNodeValue()); } } } @@ -276,7 +276,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { } public synchronized IAConfiguration getTmpConfiguration(IProject p, ICConfigurationDescription cfgd) { - Map <String, IAConfiguration> list = getTmpConfigs(p); + Map<String, IAConfiguration> list = getTmpConfigs(p); IAConfiguration acfg = list.get(cfgd.getId()); if (acfg != null) { return acfg; @@ -289,7 +289,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { /** * Clone a configuration and put it on the tmp list if it is not already a saved configuration * and not already on the tmp list. - * + * * @param p project * @param oldId the id of the old configuration to clone * @param cfgd the configuration descriptor for the clone @@ -298,7 +298,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { public synchronized boolean cloneCfg(IProject p, String oldId, ICConfigurationDescription cfgd) { if (isConfigurationAlreadySaved(p, cfgd)) return true; - Map <String, IAConfiguration> tmpList = getTmpConfigs(p); + Map<String, IAConfiguration> tmpList = getTmpConfigs(p); String newId = cfgd.getId(); // Don't bother if the new configuration is already on the tmp list IAConfiguration cfg = tmpList.get(newId); @@ -307,7 +307,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { // Otherwise, try and find the old id to copy the configuration from // or punt if not found IAConfiguration oldCfg = null; - Map <String, IAConfiguration> savedList = getSavedConfigs(p); + Map<String, IAConfiguration> savedList = getSavedConfigs(p); if (savedList != null) oldCfg = savedList.get(oldId); if (oldCfg != null) { @@ -325,25 +325,26 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { } private Map<String, IAConfiguration> getTmpConfigs(IProject p) { - Map <String, IAConfiguration> tmpList = tmpConfigs.get(p.getName()); + Map<String, IAConfiguration> tmpList = tmpConfigs.get(p.getName()); if (tmpList == null) { tmpList = new HashMap<>(); tmpConfigs.put(p.getName(), tmpList); } return tmpList; } - + public synchronized void clearTmpConfigurations(IProject p) { tmpConfigs.remove(p.getName()); } public synchronized void saveConfigs(IProject project) { synchronized (project) { - ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project).getConfigurations(); + ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(project) + .getConfigurations(); saveConfigs(project, cfgds); } } - + private void syncNameField(ICConfigurationDescription cfgd) { IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd); String id = cfgd.getId(); @@ -353,8 +354,8 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { for (int j = 0; j < tools.length; ++j) { ITool tool = tools[j]; if (tool.getName().equals("configure")) { //$NON-NLS-1$ - IOption option = - tool.getOptionBySuperClassId("org.eclipse.linuxtools.cdt.autotools.core.option.configure.name"); //$NON-NLS-1$ + IOption option = tool + .getOptionBySuperClassId("org.eclipse.linuxtools.cdt.autotools.core.option.configure.name"); //$NON-NLS-1$ IHoldsOptions h = tool; try { IOption optionToSet = h.getOptionToSet(option, false); @@ -365,16 +366,16 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { } } } - + private String xmlEscape(String value) { - value = value.replaceAll("\\&", "&"); //$NON-NLS-1$ //$NON-NLS-2$ - value = value.replaceAll("\\\"", """); //$NON-NLS-1$ //$NON-NLS-2$ - value = value.replaceAll("\\\'", "'"); //$NON-NLS-1$ //$NON-NLS-2$ - value = value.replaceAll("\\<", "<"); //$NON-NLS-1$ //$NON-NLS-2$ - value = value.replaceAll("\\>", ">"); //$NON-NLS-1$ //$NON-NLS-2$ + value = value.replaceAll("\\&", "&"); //$NON-NLS-1$ //$NON-NLS-2$ + value = value.replaceAll("\\\"", """); //$NON-NLS-1$ //$NON-NLS-2$ + value = value.replaceAll("\\\'", "'"); //$NON-NLS-1$ //$NON-NLS-2$ + value = value.replaceAll("\\<", "<"); //$NON-NLS-1$ //$NON-NLS-2$ + value = value.replaceAll("\\>", ">"); //$NON-NLS-1$ //$NON-NLS-2$ return value; } - + private void saveConfigs(IProject project, ICConfigurationDescription[] cfgds) { try { String projectName = project.getName(); @@ -435,7 +436,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { AutotoolsPlugin.log(e); } } - + // Perform apply of configuration changes. This rewrites out the current known list of configurations // with any changes currently that have been made to them. If a configuration has been renamed, but this // has not yet been confirmed by the end-user, then only the changes to the configuration are made. The @@ -445,11 +446,11 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IResource res = root.findMember(projectName, false); if (res == null || res.getType() != IResource.PROJECT) { - AutotoolsPlugin.logErrorMessage(ConfigureMessages.getFormattedString(CFG_CANT_SAVE, - new String[]{projectName})); + AutotoolsPlugin.logErrorMessage( + ConfigureMessages.getFormattedString(CFG_CANT_SAVE, new String[] { projectName })); return; } - IProject project = (IProject)res; + IProject project = (IProject) res; IPath output = project.getLocation().append(CFG_FILE_NAME); File f = output.toFile(); if (!f.exists()) @@ -472,7 +473,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { savedIds.add(id); IAConfiguration cfg = getTmpConfiguration(project, cfgd); cfgs.put(id, cfg); // add to list in case we have a new configuration not yet added to Project Description - p.println("<configuration id=\"" + id + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ + p.println("<configuration id=\"" + id + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ for (int j = 0; j < optionList.length; ++j) { Option option = optionList[j]; IConfigureOption opt = cfg.getOption(option.getName()); @@ -491,12 +492,13 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { // A remaining id won't appear in our savedIds list. if (!savedIds.contains(id)) { IAConfiguration cfg = i.getValue(); - p.println("<configuration id=\"" + id + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ + p.println("<configuration id=\"" + id + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ for (int j = 0; j < optionList.length; ++j) { Option option = optionList[j]; IConfigureOption opt = cfg.getOption(option.getName()); if (!opt.isCategory()) - p.println("<option id=\"" + option.getName() + "\" value=\"" + opt.getValue() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + p.println("<option id=\"" + option.getName() + "\" value=\"" + opt.getValue() //$NON-NLS-1$//$NON-NLS-2$ + + "\"/>"); //$NON-NLS-1$ } p.println("</configuration>"); //$NON-NLS-1$ } @@ -508,7 +510,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { AutotoolsPlugin.log(e); } } - + public synchronized Map<String, IAConfiguration> getConfigurations(IProject project) { Map<String, IAConfiguration> list = getSavedConfigs(project); if (list == null) { @@ -517,7 +519,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { } return list; } - + @Override public synchronized void resourceChanged(IResourceChangeEvent event) { IResource res = event.getResource(); @@ -547,17 +549,16 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { } } } - + private static class AutotoolsOption implements IAutotoolsOption { - + private IConfigureOption option; private final static String UNMODIFIABLE_CONFIG_OPTION = "CfgOptions.Unmodifiable.Option"; //$NON-NLS-1$ - public AutotoolsOption(IConfigureOption option) { this.option = option; } - + @Override public int getType() { return option.getType(); @@ -582,7 +583,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { @Override public void setValue(String value) throws CoreException { if (!canUpdate()) { - throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, + throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(UNMODIFIABLE_CONFIG_OPTION))); } synchronized (option) { @@ -596,9 +597,9 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { return option.getValue(); } } - + } - + private String createDummyId() { for (;;) { String id = "TEMP_" + rand.nextInt(); @@ -606,25 +607,25 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { return id; } } - + /** * @since 1.2 */ - public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions(IProject project, - String cfgId) throws CoreException { - + public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions(IProject project, String cfgId) + throws CoreException { + // Verify project is valid Autotools project if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) { - throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, + throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT))); } - + // Verify configuration id is valid - ICConfigurationDescription cfgd = - CoreModel.getDefault().getProjectDescription(project).getConfigurationById(cfgId); + ICConfigurationDescription cfgd = CoreModel.getDefault().getProjectDescription(project) + .getConfigurationById(cfgId); IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd); if (icfg == null) { - throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, + throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID))); } @@ -637,30 +638,30 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator(); i.hasNext();) { Map.Entry<String, IConfigureOption> entry = i.next(); String name = entry.getKey(); - IAutotoolsOption configOption = - new AutotoolsOption(entry.getValue().copy((AutotoolsConfiguration)dummyCfg)); + IAutotoolsOption configOption = new AutotoolsOption( + entry.getValue().copy((AutotoolsConfiguration) dummyCfg)); options.put(name, configOption); } return options; } - + /** * @since 1.2 */ public synchronized void updateAutotoolCfgOptions(IProject project, String cfgId, - Map<String,IAutotoolsOption> options) throws CoreException { - + Map<String, IAutotoolsOption> options) throws CoreException { + // Verify project is valid Autotools project if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) { - throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, + throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT))); } - + // Verify configuration id is valid IAConfiguration cfg = findCfg(project, cfgId); if (cfg == null) { - throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, + throw new CoreException(new Status(IStatus.ERROR, AutotoolsPlugin.PLUGIN_ID, ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID))); } @@ -674,7 +675,7 @@ public class AutotoolsConfigurationManager implements IResourceChangeListener { cfgOption.setValue(option.getValue()); } } - + // Save changes saveConfigs(project); } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsOptionValueHandler.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsOptionValueHandler.java index 266abb7173..53249c96f2 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsOptionValueHandler.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/AutotoolsOptionValueHandler.java @@ -28,9 +28,8 @@ import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; -public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler - implements IOptionApplicability { - +public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler implements IOptionApplicability { + public static final String DEFAULT_BUILD_DIR = "build"; //$NON-NLS-1$ public static final String CONFIGURE_TOOL_ID = "org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure"; //$NON-NLS-1$ public static final String BUILD_DIR_OPTION_ID = "org.eclipse.linuxtools.cdt.autotools.core.option.configure.builddir"; //$NON-NLS-1$ @@ -41,25 +40,21 @@ public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler //FIXME: Use holder to set option value, not the "option" parameter @Override - public boolean handleValue(IBuildObject buildObject, - IHoldsOptions holder, - IOption option, - String extraArgument, int event) - { + public boolean handleValue(IBuildObject buildObject, IHoldsOptions holder, IOption option, String extraArgument, + int event) { // Get the current value of the build dir option. - String value = (String)option.getValue(); + String value = (String) option.getValue(); - if (buildObject instanceof IConfiguration && - (event == IManagedOptionValueHandler.EVENT_OPEN)) { -// SortedSet<Integer> nums = new TreeSet<Integer>(); - IConfiguration configuration = (IConfiguration)buildObject; + if (buildObject instanceof IConfiguration && (event == IManagedOptionValueHandler.EVENT_OPEN)) { + // SortedSet<Integer> nums = new TreeSet<Integer>(); + IConfiguration configuration = (IConfiguration) buildObject; ICConfigurationDescription cfgd = ManagedBuildManager.getDescriptionForConfiguration(configuration); if (option.getName().equals("Name") && cfgd != null) { String cfgId = cfgd.getId(); if (!value.isEmpty() && !value.equals(cfgId)) { // we have a cloned configuration and we know that the // clonee's name is the value of the option - IProject project = (IProject)configuration.getManagedProject().getOwner(); + IProject project = (IProject) configuration.getManagedProject().getOwner(); String autoName = null; String autoNameTemplate = null; // Check if we are supposed to automatically name the build directory for any @@ -71,8 +66,8 @@ public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler // ignore } if (autoName == null || autoName.equals(AutotoolsPropertyConstants.TRUE)) { - autoNameTemplate = "${workspace_loc:/" + project.getName() + //$NON-NLS-1$ - "}/build-" + fixName(configuration.getName()); //$NON-NLS-1$ + autoNameTemplate = "${workspace_loc:/" + project.getName() + //$NON-NLS-1$ + "}/build-" + fixName(configuration.getName()); //$NON-NLS-1$ IBuilder cfgBuilder = configuration.getEditableBuilder(); cfgBuilder.setBuildPath(autoNameTemplate); } @@ -93,35 +88,31 @@ public class AutotoolsOptionValueHandler extends ManagedOptionValueHandler } } } - + // The event was not handled, thus return false return true; } - + private String fixName(String cfgName) { // Replace whitespace with underscores. return cfgName.replaceAll("\\s", "_"); } - + // IOptionApplicability methods - + @Override - public boolean isOptionEnabled(IBuildObject configuration, - IHoldsOptions holder, IOption option) { + public boolean isOptionEnabled(IBuildObject configuration, IHoldsOptions holder, IOption option) { return true; } @Override - public boolean isOptionUsedInCommandLine(IBuildObject configuration, - IHoldsOptions holder, IOption option) { + public boolean isOptionUsedInCommandLine(IBuildObject configuration, IHoldsOptions holder, IOption option) { return false; } @Override - public boolean isOptionVisible(IBuildObject configuration, - IHoldsOptions holder, IOption option) { + public boolean isOptionVisible(IBuildObject configuration, IHoldsOptions holder, IOption option) { return true; } - } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/BinConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/BinConfigureOption.java index 63b322405f..c9025e9488 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/BinConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/BinConfigureOption.java @@ -16,7 +16,7 @@ package org.eclipse.cdt.internal.autotools.core.configure; public class BinConfigureOption extends AbstractConfigurationOption { private boolean value; - + public BinConfigureOption(String name, AutotoolsConfiguration cfg) { super(name, cfg); } @@ -29,25 +29,25 @@ public class BinConfigureOption extends AbstractConfigurationOption { super(name, cfg); this.value = value; } - + @Override public boolean isParmSet() { return value; } - + @Override public String getParameter() { - if (isParmSet()) - return getParameterName(); - else - return ""; //$NON-NLS-1$ + if (isParmSet()) + return getParameterName(); + else + return ""; //$NON-NLS-1$ } @Override public String getValue() { return Boolean.toString(value); } - + @Override public void setValue(String value) { boolean oldValue = this.value; @@ -58,7 +58,7 @@ public class BinConfigureOption extends AbstractConfigurationOption { if (this.value != oldValue) cfg.setDirty(true); } - + @Override public IConfigureOption copy(AutotoolsConfiguration config) { return new BinConfigureOption(name, config, value); diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureMessages.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureMessages.java index 602e403f78..b3d6d86678 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureMessages.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureMessages.java @@ -20,8 +20,7 @@ import java.util.ResourceBundle; public class ConfigureMessages { private static final String BUNDLE_NAME = ConfigureMessages.class.getName(); - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle - .getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); private ConfigureMessages() { } @@ -29,7 +28,7 @@ public class ConfigureMessages { public static String getConfigureDescription(String name) { return getString("Option.configure." + name); //$NON-NLS-11$ } - + public static String getConfigureTip(String name) { return getString("Option.configure." + name + ".tip"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -37,10 +36,11 @@ public class ConfigureMessages { public static String getParameter(String name) { return getString("Option.configure." + name + ".parm"); //$NON-NLS-1$ //$NON-NLS-2$ } + /** * Returns the string from the resource bundle, * or 'key' if not found. - * + * * @param key the message key * @return the resource bundle message */ @@ -51,17 +51,17 @@ public class ConfigureMessages { return '!' + key + '!'; } } - + /** * Returns the formatted string from the resource bundle, * or 'key' if not found. - * + * * @param key the message key * @param args an array of substituition strings * @return the resource bundle message */ public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), (Object[])args); + return MessageFormat.format(getString(key), (Object[]) args); } } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureOptionCategory.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureOptionCategory.java index 9008a923b3..9fbdc8f9ee 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureOptionCategory.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureOptionCategory.java @@ -18,11 +18,11 @@ import java.util.ArrayList; public class ConfigureOptionCategory implements IConfigureOption { private String name; - + public ConfigureOptionCategory(String name) { this.name = name; } - + @Override public IConfigureOption copy(AutotoolsConfiguration config) { return new ConfigureOptionCategory(name); @@ -47,7 +47,7 @@ public class ConfigureOptionCategory implements IConfigureOption { public ArrayList<String> getParameters() { return new ArrayList<>(); } - + @Override public String getToolTip() { return ""; @@ -77,12 +77,12 @@ public class ConfigureOptionCategory implements IConfigureOption { public boolean isMultiArg() { return false; } - + @Override public boolean isFlag() { return false; } - + @Override public boolean isFlagValue() { return false; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureTool.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureTool.java index ce078801c0..0ada7f2f0a 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureTool.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/ConfigureTool.java @@ -18,7 +18,7 @@ import java.util.ArrayList; public class ConfigureTool extends AbstractConfigurationOption { private String value; - + public ConfigureTool(String name, AutotoolsConfiguration cfg) { super(name, cfg); this.value = name; @@ -33,12 +33,12 @@ public class ConfigureTool extends AbstractConfigurationOption { super(name, cfg); this.value = value; } - + @Override public String getValue() { return value; } - + @Override public void setValue(String newValue) { if (!newValue.equals(value)) { @@ -51,17 +51,17 @@ public class ConfigureTool extends AbstractConfigurationOption { public boolean isParmSet() { return false; } - + @Override public String getParameter() { return ""; //$NON-NLS-1$ } - + @Override public ArrayList<String> getParameters() { return new ArrayList<>(); } - + @Override public IConfigureOption copy(AutotoolsConfiguration config) { return new ConfigureTool(name, config, value); diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java index a83babaaf8..a4a175fcd7 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagConfigureOption.java @@ -21,23 +21,23 @@ public class FlagConfigureOption extends AbstractConfigurationOption { private String value; private ArrayList<String> children = new ArrayList<>(); - + public FlagConfigureOption(String name, AutotoolsConfiguration cfg) { super(name, cfg); this.value = name; } - + public FlagConfigureOption(String name, String msgName, AutotoolsConfiguration cfg) { super(name, msgName, cfg); this.value = name; } - + private FlagConfigureOption(String name, AutotoolsConfiguration cfg, String value, ArrayList<String> children) { super(name, cfg); this.value = value; this.children = new ArrayList<>(children); } - + @Override public String getParameter() { StringBuilder parms = new StringBuilder(); @@ -56,7 +56,7 @@ public class FlagConfigureOption extends AbstractConfigurationOption { IConfigureOption o = cfg.getOption(fvname); if (o.isParmSet()) { if (o instanceof IFlagConfigureValueOption) { - parm.append(separator).append(((IFlagConfigureValueOption)o).getFlags()); + parm.append(separator).append(((IFlagConfigureValueOption) o).getFlags()); separator = " "; //$NON-NLS-1$ haveParm = true; } @@ -75,7 +75,7 @@ public class FlagConfigureOption extends AbstractConfigurationOption { public String getParameterName() { return getName(); } - + @Override public boolean isParmSet() { for (int i = 0; i < children.size(); ++i) { @@ -106,18 +106,18 @@ public class FlagConfigureOption extends AbstractConfigurationOption { public int getType() { return FLAG; } - + @Override public boolean isFlag() { return true; } - + public void addChild(String name) { children.add(name); } - + public List<String> getChildren() { return children; } - + } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagValueConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagValueConfigureOption.java index 2880d7f4ba..8346f5595f 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagValueConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/FlagValueConfigureOption.java @@ -18,15 +18,13 @@ import java.util.ArrayList; public class FlagValueConfigureOption extends BinConfigureOption implements IFlagConfigureValueOption { private String flags; - - public FlagValueConfigureOption(String name, String msgName, AutotoolsConfiguration cfg, - String flags) { + + public FlagValueConfigureOption(String name, String msgName, AutotoolsConfiguration cfg, String flags) { super(name, msgName, cfg); this.flags = flags; } - - private FlagValueConfigureOption(String name, AutotoolsConfiguration cfg, String value, - String flags) { + + private FlagValueConfigureOption(String name, AutotoolsConfiguration cfg, String value, String flags) { super(name, cfg); this.setValue(value); this.flags = flags; @@ -36,7 +34,7 @@ public class FlagValueConfigureOption extends BinConfigureOption implements IFla public ArrayList<String> getParameters() { return new ArrayList<>(); } - + @Override public String getParameter() { return ""; @@ -61,5 +59,5 @@ public class FlagValueConfigureOption extends BinConfigureOption implements IFla public boolean isFlagValue() { return true; } - + } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IConfigureOption.java index cec09c5f38..f069d84266 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IConfigureOption.java @@ -18,7 +18,7 @@ import java.util.List; import org.eclipse.cdt.autotools.core.IAutotoolsOption; public interface IConfigureOption { - + int CATEGORY = IAutotoolsOption.CATEGORY; int BIN = IAutotoolsOption.BIN; int STRING = IAutotoolsOption.STRING; diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IFlagConfigureValueOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IFlagConfigureValueOption.java index 8f26d9043b..816242373d 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IFlagConfigureValueOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/IFlagConfigureValueOption.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.internal.autotools.core.configure; public interface IFlagConfigureValueOption { - + String getFlags(); } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/InternalConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/InternalConfigureOption.java index c7969c1692..e2b337542b 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/InternalConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/InternalConfigureOption.java @@ -16,28 +16,27 @@ package org.eclipse.cdt.internal.autotools.core.configure; public class InternalConfigureOption extends AbstractConfigurationOption { private String value; - + public InternalConfigureOption(String name, AutotoolsConfiguration cfg) { super(name, cfg); this.value = ""; //$NON-NLS-1$ } - + public InternalConfigureOption(String name, String msgName, AutotoolsConfiguration cfg) { super(name, msgName, cfg); this.value = ""; //$NON-NLS-1$ } - - private InternalConfigureOption(String name, AutotoolsConfiguration cfg, - String value) { + + private InternalConfigureOption(String name, AutotoolsConfiguration cfg, String value) { super(name, cfg); this.value = value; } - + @Override public String getValue() { return value; } - + @Override public void setValue(String newValue) { if (!newValue.equals(value)) { @@ -50,12 +49,12 @@ public class InternalConfigureOption extends AbstractConfigurationOption { public boolean isParmSet() { return false; } - + @Override public String getParameter() { return ""; } - + @Override public IConfigureOption copy(AutotoolsConfiguration config) { return new InternalConfigureOption(name, config, value); diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/MultiArgConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/MultiArgConfigureOption.java index c7325bdd47..ca446b5888 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/MultiArgConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/MultiArgConfigureOption.java @@ -16,34 +16,32 @@ package org.eclipse.cdt.internal.autotools.core.configure; import java.util.ArrayList; import java.util.List; - public class MultiArgConfigureOption extends AbstractConfigurationOption { private String value; private List<String> userArgs; private boolean isDirty; - + public MultiArgConfigureOption(String name, AutotoolsConfiguration cfg) { super(name, cfg); this.value = ""; //$NON-NLS-1$ } - + public MultiArgConfigureOption(String name, String msgName, AutotoolsConfiguration cfg) { super(name, msgName, cfg); this.value = ""; //$NON-NLS-1$ } - - private MultiArgConfigureOption(String name, AutotoolsConfiguration cfg, - String value) { + + private MultiArgConfigureOption(String name, AutotoolsConfiguration cfg, String value) { super(name, cfg); this.value = value; } - + @Override public String getValue() { return value; } - + @Override public void setValue(String newValue) { if (!newValue.equals(value)) { @@ -57,17 +55,17 @@ public class MultiArgConfigureOption extends AbstractConfigurationOption { public boolean isParmSet() { return value.length() > 0; } - + @Override public boolean isMultiArg() { return true; } - + @Override public String getParameter() { return value; } - + @Override public List<String> getParameters() { // May be multiple user-specified options in which case we diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/StringConfigureOption.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/StringConfigureOption.java index eed04726ee..747269c184 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/StringConfigureOption.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/configure/StringConfigureOption.java @@ -13,32 +13,30 @@ *******************************************************************************/ package org.eclipse.cdt.internal.autotools.core.configure; - public class StringConfigureOption extends AbstractConfigurationOption { private String value; - + public StringConfigureOption(String name, AutotoolsConfiguration cfg) { super(name, cfg); this.value = ""; //$NON-NLS-1$ } - + public StringConfigureOption(String name, String msgName, AutotoolsConfiguration cfg) { super(name, msgName, cfg); this.value = ""; //$NON-NLS-1$ } - - private StringConfigureOption(String name, AutotoolsConfiguration cfg, - String value) { + + private StringConfigureOption(String name, AutotoolsConfiguration cfg, String value) { super(name, cfg); this.value = value; } - + @Override public String getValue() { return value; } - + @Override public void setValue(String newValue) { if (!newValue.equals(value)) { @@ -51,14 +49,14 @@ public class StringConfigureOption extends AbstractConfigurationOption { public boolean isParmSet() { return value.length() > 0; } - + @Override public String getParameter() { if (isParmSet()) return getParameterName() + "=" + getValue(); //$NON-NLS-1$ return ""; } - + @Override public IConfigureOption copy(AutotoolsConfiguration config) { return new StringConfigureOption(name, config, value); diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/NewAutotoolsProject.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/NewAutotoolsProject.java index 1335470b70..3ec23fe38f 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/NewAutotoolsProject.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/NewAutotoolsProject.java @@ -40,7 +40,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; - /** * Creates a new Project in the workspace. */ @@ -48,19 +47,20 @@ public class NewAutotoolsProject extends ProcessRunner { protected boolean savedAutoBuildingValue; protected ProjectCreatedActions pca; protected IManagedBuildInfo info; - + public NewAutotoolsProject() { pca = new ProjectCreatedActions(); } - + @Override - public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException { + public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) + throws ProcessFailureException { String projectName = args[0].getSimpleValue(); String location = args[1].getSimpleValue(); String artifactExtension = args[2].getSimpleValue(); String isCProjectValue = args[3].getSimpleValue(); boolean isCProject = Boolean.valueOf(isCProjectValue).booleanValue(); - + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { @@ -85,7 +85,7 @@ public class NewAutotoolsProject extends ProcessRunner { info = pca.createProject(monitor, CCorePlugin.DEFAULT_INDEXER, isCProject); AutotoolsNewProjectNature.addAutotoolsNature(project, monitor); - + // For each IConfiguration, create a corresponding Autotools Configuration IConfiguration[] cfgs = pca.getConfigs(); for (int i = 0; i < cfgs.length; ++i) { @@ -115,13 +115,13 @@ public class NewAutotoolsProject extends ProcessRunner { workspaceDesc.setAutoBuilding(false); workspace.setDescription(workspaceDesc); } - + protected final void restoreAutoBuild(IWorkspace workspace) throws CoreException { IWorkspaceDescription workspaceDesc = workspace.getDescription(); workspaceDesc.setAutoBuilding(savedAutoBuildingValue); workspace.setDescription(workspaceDesc); } - + /** * setOptionValue * @param config @@ -134,7 +134,8 @@ public class NewAutotoolsProject extends ProcessRunner { if (!option.isExtensionElement()) { option.setValue(val); } else { - IOption newOption = config.getToolChain().createOption(option, option.getId() + "." + ManagedBuildManager.getRandomNumber(), option.getName(), false); //$NON-NLS-1$ + IOption newOption = config.getToolChain().createOption(option, + option.getId() + "." + ManagedBuildManager.getRandomNumber(), option.getName(), false); //$NON-NLS-1$ newOption.setValue(val); } } diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/SetAutotoolsStringOptionValue.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/SetAutotoolsStringOptionValue.java index ce65e082f6..403b7d5763 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/SetAutotoolsStringOptionValue.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/wizards/SetAutotoolsStringOptionValue.java @@ -43,13 +43,13 @@ public class SetAutotoolsStringOptionValue extends ProcessRunner { workspace.setDescription(workspaceDesc); } catch (CoreException e) {//ignore } - + ProcessArgument[][] resourcePathObjects = args[1].getComplexArrayValue(); - for(int i=0; i<resourcePathObjects.length; i++) { + for (int i = 0; i < resourcePathObjects.length; i++) { ProcessArgument[] resourcePathObject = resourcePathObjects[i]; String id = resourcePathObject[0].getSimpleValue(); String value = resourcePathObject[1].getSimpleValue(); - setOptionValue(projectHandle, id, value); + setOptionValue(projectHandle, id, value); } workspaceDesc.setAutoBuilding(autoBuilding); @@ -58,16 +58,15 @@ public class SetAutotoolsStringOptionValue extends ProcessRunner { } catch (CoreException e) {//ignore } } - + private void setOptionValue(IProject projectHandle, String id, String value) { AutotoolsConfigurationManager.getInstance().syncConfigurations(projectHandle); - ICConfigurationDescription[] cfgds = - CoreModel.getDefault().getProjectDescription(projectHandle).getConfigurations(); + ICConfigurationDescription[] cfgds = CoreModel.getDefault().getProjectDescription(projectHandle) + .getConfigurations(); if (cfgds != null && cfgds.length >= 1) { - IAConfiguration iaConfig = - AutotoolsConfigurationManager.getInstance().getConfiguration(projectHandle, - cfgds[0].getId()); + IAConfiguration iaConfig = AutotoolsConfigurationManager.getInstance().getConfiguration(projectHandle, + cfgds[0].getId()); iaConfig.setOption(id, value); } } |