mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Put back enough of the Standard builder to keep our internal stuff working.
This commit is contained in:
parent
85ea990944
commit
ba02f49a64
7 changed files with 1336 additions and 10 deletions
|
@ -6,16 +6,37 @@ Bundle-Version: 4.0.0.qualifier
|
|||
Bundle-Activator: org.eclipse.cdt.make.core.MakeCorePlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
Export-Package: org.eclipse.cdt.make.core,
|
||||
org.eclipse.cdt.make.core.makefile,
|
||||
org.eclipse.cdt.make.core.makefile.gnu,
|
||||
org.eclipse.cdt.make.internal.core,
|
||||
org.eclipse.cdt.make.internal.core.makefile,
|
||||
org.eclipse.cdt.make.internal.core.makefile.gnu,
|
||||
org.eclipse.cdt.make.internal.core.makefile.posix
|
||||
Export-Package: org.eclipse.cdt.make.core;
|
||||
uses:="org.eclipse.cdt.newmake.core,
|
||||
org.osgi.framework,
|
||||
org.eclipse.cdt.managedbuilder.core,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.cdt.make.core.makefile,
|
||||
org.eclipse.core.runtime",
|
||||
org.eclipse.cdt.make.core.makefile;uses:="org.eclipse.core.resources,org.eclipse.core.runtime,org.eclipse.cdt.core",
|
||||
org.eclipse.cdt.make.core.makefile.gnu;uses:="org.eclipse.cdt.make.core.makefile",
|
||||
org.eclipse.cdt.make.internal.core;
|
||||
uses:="org.eclipse.cdt.core.settings.model,
|
||||
org.w3c.dom,
|
||||
org.eclipse.cdt.managedbuilder.core,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.cdt.make.core,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.cdt.core",
|
||||
org.eclipse.cdt.make.internal.core.makefile;uses:="org.eclipse.cdt.make.core.makefile",
|
||||
org.eclipse.cdt.make.internal.core.makefile.gnu;
|
||||
uses:="org.eclipse.cdt.make.internal.core.makefile,
|
||||
org.eclipse.cdt.make.core.makefile.gnu,
|
||||
org.eclipse.cdt.make.internal.core.makefile.posix,
|
||||
org.eclipse.cdt.core.resources,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.cdt.make.core.makefile,
|
||||
org.eclipse.cdt.core",
|
||||
org.eclipse.cdt.make.internal.core.makefile.posix;uses:="org.eclipse.cdt.make.internal.core.makefile"
|
||||
Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.core.variables;bundle-version="[3.1.100,4.0.0)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
|
||||
org.eclipse.cdt.core;bundle-version="[4.0.0,5.0.0)",
|
||||
org.eclipse.cdt.managedbuilder.core
|
||||
org.eclipse.cdt.managedbuilder.core;visibility:=reexport
|
||||
Eclipse-LazyStart: true
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.core;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public interface IMakeBuilderInfo extends IMakeCommonBuildInfo {
|
||||
|
||||
public final static String BUILD_TARGET_INCREMENTAL = ARGS_PREFIX + ".build.target.inc"; //$NON-NLS-1$
|
||||
public final static String BUILD_TARGET_AUTO = ARGS_PREFIX + ".build.target.auto"; //$NON-NLS-1$
|
||||
public final static String BUILD_TARGET_CLEAN = ARGS_PREFIX + ".build.target.clean"; //$NON-NLS-1$
|
||||
|
||||
/** @deprecated */
|
||||
public final static String BUILD_TARGET_INCREAMENTAL = BUILD_TARGET_INCREMENTAL;
|
||||
/** @deprecated */
|
||||
public final static String BUILD_TARGET_FULL = ARGS_PREFIX + ".build.target.full"; //$NON-NLS-1$
|
||||
|
||||
boolean isAutoBuildEnable();
|
||||
void setAutoBuildEnable(boolean enabled) throws CoreException;
|
||||
|
||||
String getAutoBuildTarget();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
void setAutoBuildTarget(String target) throws CoreException;
|
||||
|
||||
boolean isIncrementalBuildEnabled();
|
||||
void setIncrementalBuildEnable(boolean enabled) throws CoreException;
|
||||
|
||||
String getIncrementalBuildTarget();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
void setIncrementalBuildTarget(String target) throws CoreException;
|
||||
|
||||
boolean isFullBuildEnabled();
|
||||
void setFullBuildEnable(boolean enabled) throws CoreException;
|
||||
|
||||
String getFullBuildTarget();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
void setFullBuildTarget(String target) throws CoreException;
|
||||
|
||||
String getCleanBuildTarget();
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
void setCleanBuildTarget(String target) throws CoreException;
|
||||
|
||||
boolean isCleanBuildEnabled();
|
||||
void setCleanBuildEnable(boolean enabled) throws CoreException;
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
||||
public interface IMakeCommonBuildInfo {
|
||||
public final static String ARGS_PREFIX = MakeCorePlugin.getUniqueIdentifier();
|
||||
|
||||
public final static String BUILD_LOCATION = ARGS_PREFIX + ".build.location"; //$NON-NLS-1$
|
||||
public final static String BUILD_COMMAND = ARGS_PREFIX + ".build.command"; //$NON-NLS-1$
|
||||
public final static String BUILD_ARGUMENTS = ARGS_PREFIX + ".build.arguments"; //$NON-NLS-1$
|
||||
|
||||
void setBuildAttribute(String name, String value) throws CoreException;
|
||||
String getBuildAttribute(String name, String defaultValue);
|
||||
|
||||
IPath getBuildLocation();
|
||||
|
||||
/**
|
||||
* @deprecated - use setBuildString(BUILD_LOCATION...)
|
||||
*/
|
||||
void setBuildLocation(IPath location) throws CoreException;
|
||||
|
||||
boolean isStopOnError();
|
||||
void setStopOnError(boolean on) throws CoreException;
|
||||
|
||||
boolean isDefaultBuildCmd();
|
||||
void setUseDefaultBuildCmd(boolean on) throws CoreException;
|
||||
|
||||
IPath getBuildCommand();
|
||||
|
||||
/**
|
||||
* @deprecated - use setBuildString(BUILD_COMMAND...)
|
||||
*/
|
||||
void setBuildCommand(IPath command) throws CoreException;
|
||||
|
||||
String getBuildArguments();
|
||||
|
||||
/**
|
||||
* @deprecated - use setBuildString(BUILD_ARGUMENTS...)
|
||||
*/
|
||||
void setBuildArguments(String args) throws CoreException;
|
||||
|
||||
String[] getErrorParsers();
|
||||
void setErrorParsers(String[] parsers) throws CoreException;
|
||||
|
||||
Map getExpandedEnvironment() throws CoreException;
|
||||
|
||||
Map getEnvironment();
|
||||
void setEnvironment(Map env) throws CoreException;
|
||||
|
||||
boolean appendEnvironment();
|
||||
void setAppendEnvironment(boolean append) throws CoreException;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.core;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* @deprecated no longer used by the CDT but I need it temporarily.
|
||||
*
|
||||
*/
|
||||
public class MakeBuilder {
|
||||
|
||||
public final static String BUILDER_ID = MakeCorePlugin.getUniqueIdentifier() + ".makeBuilder"; //$NON-NLS-1$
|
||||
|
||||
}
|
|
@ -20,11 +20,10 @@ import java.util.Map;
|
|||
import java.util.StringTokenizer;
|
||||
|
||||
import org.eclipse.cdt.make.core.makefile.IMakefile;
|
||||
import org.eclipse.cdt.make.internal.core.BuildInfoFactory;
|
||||
import org.eclipse.cdt.make.internal.core.MakeTargetManager;
|
||||
import org.eclipse.cdt.make.internal.core.makefile.gnu.GNUMakefile;
|
||||
import org.eclipse.cdt.make.internal.core.makefile.posix.PosixMakefile;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.newmake.core.IMakeBuilderInfo;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
|
@ -322,4 +321,17 @@ public class MakeCorePlugin extends Plugin {
|
|||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public static IMakeBuilderInfo createBuildInfo(Preferences prefs, String builderID, boolean useDefaults) {
|
||||
return BuildInfoFactory.create(prefs, builderID, useDefaults);
|
||||
}
|
||||
|
||||
public static IMakeBuilderInfo createBuildInfo(IProject project, String builderID) throws CoreException {
|
||||
return BuildInfoFactory.create(project, builderID);
|
||||
}
|
||||
|
||||
public static IMakeBuilderInfo createBuildInfo(Map args, String builderID) {
|
||||
return BuildInfoFactory.create(args, builderID);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,540 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.internal.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.eclipse.cdt.core.ErrorParserManager;
|
||||
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
|
||||
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.cdt.make.core.MakeProjectNature;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.variables.VariablesPlugin;
|
||||
import org.eclipse.osgi.service.environment.*;
|
||||
|
||||
public class BuildInfoFactory {
|
||||
|
||||
private static final String PREFIX = MakeCorePlugin.getUniqueIdentifier();
|
||||
|
||||
static final String BUILD_COMMAND = PREFIX + ".buildCommand"; //$NON-NLS-1$
|
||||
static final String BUILD_LOCATION = PREFIX + ".buildLocation"; //$NON-NLS-1$
|
||||
static final String STOP_ON_ERROR = PREFIX + ".stopOnError"; //$NON-NLS-1$
|
||||
static final String USE_DEFAULT_BUILD_CMD = PREFIX + ".useDefaultBuildCmd"; //$NON-NLS-1$
|
||||
static final String BUILD_TARGET_AUTO = PREFIX + ".autoBuildTarget"; //$NON-NLS-1$
|
||||
static final String BUILD_TARGET_INCREMENTAL = PREFIX + ".incrementalBuildTarget"; //$NON-NLS-1$
|
||||
static final String BUILD_TARGET_FULL = PREFIX + ".fullBuildTarget"; //$NON-NLS-1$
|
||||
static final String BUILD_TARGET_CLEAN = PREFIX + ".cleanBuildTarget"; //$NON-NLS-1$
|
||||
static final String BUILD_FULL_ENABLED = PREFIX + ".enableFullBuild"; //$NON-NLS-1$
|
||||
static final String BUILD_CLEAN_ENABLED = PREFIX + ".enableCleanBuild"; //$NON-NLS-1$
|
||||
static final String BUILD_INCREMENTAL_ENABLED = PREFIX + ".enabledIncrementalBuild"; //$NON-NLS-1$
|
||||
static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild"; //$NON-NLS-1$
|
||||
static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments"; //$NON-NLS-1$
|
||||
static final String ENVIRONMENT = PREFIX + ".environment"; //$NON-NLS-1$
|
||||
static final String BUILD_APPEND_ENVIRONMENT = PREFIX + ".append_environment"; //$NON-NLS-1$
|
||||
|
||||
private abstract static class AbstractBuildInfo implements IMakeBuilderInfo {
|
||||
|
||||
public void setUseDefaultBuildCmd(boolean on) throws CoreException {
|
||||
putString(USE_DEFAULT_BUILD_CMD, new Boolean(on).toString());
|
||||
}
|
||||
|
||||
public boolean isDefaultBuildCmd() {
|
||||
if (getString(USE_DEFAULT_BUILD_CMD) == null) { // if no property
|
||||
// then default to
|
||||
// true
|
||||
return true;
|
||||
}
|
||||
return getBoolean(USE_DEFAULT_BUILD_CMD);
|
||||
}
|
||||
|
||||
public String getBuildAttribute(String name, String defaultValue) {
|
||||
String value = getString(name);
|
||||
if (value == null ) {
|
||||
if (IMakeCommonBuildInfo.BUILD_COMMAND.equals(name)) {
|
||||
value = getString(BuildInfoFactory.BUILD_COMMAND);
|
||||
} else if (IMakeCommonBuildInfo.BUILD_ARGUMENTS.equals(name)) {
|
||||
value = getString(BuildInfoFactory.BUILD_ARGUMENTS);
|
||||
} else if (IMakeCommonBuildInfo.BUILD_LOCATION.equals(name)) {
|
||||
value = getString(BuildInfoFactory.BUILD_LOCATION);
|
||||
} else if (IMakeBuilderInfo.BUILD_TARGET_AUTO.equals(name)) {
|
||||
value = getString(BuildInfoFactory.BUILD_TARGET_AUTO);
|
||||
} else if (IMakeBuilderInfo.BUILD_TARGET_CLEAN.equals(name)) {
|
||||
value = getString(BuildInfoFactory.BUILD_TARGET_CLEAN);
|
||||
} else if (IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL.equals(name)) {
|
||||
value = getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL);
|
||||
}
|
||||
}
|
||||
return value != null ? value : defaultValue != null ? defaultValue : ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public void setBuildAttribute(String name, String value) throws CoreException {
|
||||
putString(name, value);
|
||||
}
|
||||
|
||||
public Map getExpandedEnvironment() {
|
||||
Map env = getEnvironment();
|
||||
HashMap envMap = new HashMap(env.entrySet().size());
|
||||
Iterator iter = env.entrySet().iterator();
|
||||
boolean win32 = Platform.getOS().equals(Constants.OS_WIN32);
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
String key = (String)entry.getKey();
|
||||
if (win32) {
|
||||
// Win32 vars are case insensitive. Uppercase everything so
|
||||
// that (for example) "pAtH" will correctly replace "PATH"
|
||||
key = key.toUpperCase();
|
||||
}
|
||||
String value = (String)entry.getValue();
|
||||
// translate any string substitution variables
|
||||
String translated = value;
|
||||
try {
|
||||
translated = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(value, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
envMap.put(key, translated);
|
||||
}
|
||||
return envMap;
|
||||
}
|
||||
|
||||
public void setBuildCommand(IPath location) throws CoreException {
|
||||
putString(IMakeCommonBuildInfo.BUILD_COMMAND, null);
|
||||
putString(BuildInfoFactory.BUILD_COMMAND, location.toString());
|
||||
}
|
||||
|
||||
public IPath getBuildCommand() {
|
||||
if (isDefaultBuildCmd()) {
|
||||
String command = getBuildParameter("defaultCommand"); //$NON-NLS-1$
|
||||
if (command == null) {
|
||||
return new Path("make"); //$NON-NLS-1$
|
||||
}
|
||||
return new Path(command);
|
||||
}
|
||||
String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, getString(BuildInfoFactory.BUILD_COMMAND));
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return new Path(result);
|
||||
}
|
||||
|
||||
protected String getBuildParameter(String name) {
|
||||
IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES,
|
||||
ResourcesPlugin.PT_BUILDERS, getBuilderID());
|
||||
if (extension == null)
|
||||
return null;
|
||||
IConfigurationElement[] configs = extension.getConfigurationElements();
|
||||
if (configs.length == 0)
|
||||
return null;
|
||||
// The nature exists, or this builder doesn't specify a nature
|
||||
IConfigurationElement[] runElement = configs[0].getChildren("run"); //$NON-NLS-1$
|
||||
IConfigurationElement[] paramElement = runElement[0].getChildren("parameter"); //$NON-NLS-1$
|
||||
for (int i = 0; i < paramElement.length; i++) {
|
||||
if (paramElement[i].getAttribute("name").equals(name)) { //$NON-NLS-1$
|
||||
return paramElement[i].getAttribute("value"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract String getBuilderID();
|
||||
|
||||
public void setBuildLocation(IPath location) throws CoreException {
|
||||
putString(IMakeCommonBuildInfo.BUILD_LOCATION, null);
|
||||
putString(BuildInfoFactory.BUILD_LOCATION, location.toString());
|
||||
}
|
||||
|
||||
public IPath getBuildLocation() {
|
||||
String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, getString(BuildInfoFactory.BUILD_LOCATION));
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return new Path(result);
|
||||
}
|
||||
|
||||
public String getBuildArguments() {
|
||||
String result = getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, getString(BuildInfoFactory.BUILD_ARGUMENTS));
|
||||
if (result == null) {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setBuildArguments(String args) throws CoreException {
|
||||
putString(IMakeCommonBuildInfo.BUILD_ARGUMENTS, null);
|
||||
putString(BuildInfoFactory.BUILD_ARGUMENTS, args);
|
||||
}
|
||||
|
||||
public void setStopOnError(boolean enabled) throws CoreException {
|
||||
putString(STOP_ON_ERROR, new Boolean(enabled).toString());
|
||||
}
|
||||
|
||||
public boolean isStopOnError() {
|
||||
return getBoolean(STOP_ON_ERROR);
|
||||
}
|
||||
|
||||
public void setAutoBuildTarget(String target) throws CoreException {
|
||||
putString(IMakeBuilderInfo.BUILD_TARGET_AUTO, null);
|
||||
putString(BuildInfoFactory.BUILD_TARGET_AUTO, target);
|
||||
}
|
||||
|
||||
public String getAutoBuildTarget() {
|
||||
String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, getString(BuildInfoFactory.BUILD_TARGET_AUTO));
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setIncrementalBuildTarget(String target) throws CoreException {
|
||||
putString(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, null);
|
||||
putString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL, target);
|
||||
}
|
||||
|
||||
public String getIncrementalBuildTarget() {
|
||||
String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL,
|
||||
getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL));
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setFullBuildTarget(String target) throws CoreException {
|
||||
|
||||
}
|
||||
|
||||
public String getFullBuildTarget() {
|
||||
String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, getString(BuildInfoFactory.BUILD_TARGET_INCREMENTAL));
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setCleanBuildTarget(String target) throws CoreException {
|
||||
putString(IMakeBuilderInfo.BUILD_TARGET_CLEAN, null);
|
||||
putString(BuildInfoFactory.BUILD_TARGET_CLEAN, target);
|
||||
}
|
||||
|
||||
public String getCleanBuildTarget() {
|
||||
String result = getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, getString(BuildInfoFactory.BUILD_TARGET_CLEAN));
|
||||
try {
|
||||
result = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(result, false);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setAutoBuildEnable(boolean enabled) throws CoreException {
|
||||
putString(BUILD_AUTO_ENABLED, new Boolean(enabled).toString());
|
||||
}
|
||||
|
||||
public boolean isAutoBuildEnable() {
|
||||
return getBoolean(BUILD_AUTO_ENABLED);
|
||||
}
|
||||
|
||||
public void setIncrementalBuildEnable(boolean enabled) throws CoreException {
|
||||
putString(BUILD_INCREMENTAL_ENABLED, new Boolean(enabled).toString());
|
||||
}
|
||||
|
||||
public boolean isIncrementalBuildEnabled() {
|
||||
return getBoolean(BUILD_INCREMENTAL_ENABLED);
|
||||
}
|
||||
|
||||
public void setFullBuildEnable(boolean enabled) throws CoreException {
|
||||
putString(BUILD_FULL_ENABLED, new Boolean(enabled).toString());
|
||||
}
|
||||
|
||||
public boolean isFullBuildEnabled() {
|
||||
return getBoolean(BUILD_FULL_ENABLED);
|
||||
}
|
||||
|
||||
public void setCleanBuildEnable(boolean enabled) throws CoreException {
|
||||
putString(BUILD_CLEAN_ENABLED, new Boolean(enabled).toString());
|
||||
}
|
||||
|
||||
public boolean isCleanBuildEnabled() {
|
||||
return getBoolean(BUILD_CLEAN_ENABLED);
|
||||
}
|
||||
|
||||
public String[] getErrorParsers() {
|
||||
String parsers = getString(ErrorParserManager.PREF_ERROR_PARSER);
|
||||
if (parsers != null && parsers.length() > 0) {
|
||||
StringTokenizer tok = new StringTokenizer(parsers, ";"); //$NON-NLS-1$
|
||||
List list = new ArrayList(tok.countTokens());
|
||||
while (tok.hasMoreElements()) {
|
||||
list.add(tok.nextToken());
|
||||
}
|
||||
return (String[])list.toArray(new String[list.size()]);
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public void setErrorParsers(String[] parsers) throws CoreException {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < parsers.length; i++) {
|
||||
buf.append(parsers[i]).append(';');
|
||||
}
|
||||
putString(ErrorParserManager.PREF_ERROR_PARSER, buf.toString());
|
||||
}
|
||||
|
||||
public Map getEnvironment() {
|
||||
return decodeMap(getString(ENVIRONMENT));
|
||||
}
|
||||
|
||||
public void setEnvironment(Map env) throws CoreException {
|
||||
putString(ENVIRONMENT, encodeMap(env));
|
||||
}
|
||||
|
||||
public boolean appendEnvironment() {
|
||||
if (getString(BUILD_APPEND_ENVIRONMENT) != null) {
|
||||
return getBoolean(BUILD_APPEND_ENVIRONMENT);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAppendEnvironment(boolean append) throws CoreException {
|
||||
putString(BUILD_APPEND_ENVIRONMENT, new Boolean(append).toString());
|
||||
}
|
||||
|
||||
public boolean getBoolean(String property) {
|
||||
return Boolean.valueOf(getString(property)).booleanValue();
|
||||
}
|
||||
|
||||
protected Map decodeMap(String value) {
|
||||
Map map = new HashMap();
|
||||
if (value != null) {
|
||||
StringBuffer envStr = new StringBuffer(value);
|
||||
String escapeChars = "|\\"; //$NON-NLS-1$
|
||||
char escapeChar = '\\';
|
||||
try {
|
||||
while (envStr.length() > 0) {
|
||||
int ndx = 0;
|
||||
while (ndx < envStr.length()) {
|
||||
if (escapeChars.indexOf(envStr.charAt(ndx)) != -1) {
|
||||
if (envStr.charAt(ndx - 1) == escapeChar) {
|
||||
// escaped '|' - remove '\' and continue on.
|
||||
envStr.deleteCharAt(ndx - 1);
|
||||
if (ndx == envStr.length()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (envStr.charAt(ndx) == '|')
|
||||
break;
|
||||
}
|
||||
ndx++;
|
||||
}
|
||||
StringBuffer line = new StringBuffer(envStr.substring(0, ndx));
|
||||
int lndx = 0;
|
||||
while (lndx < line.length()) {
|
||||
if (line.charAt(lndx) == '=') {
|
||||
if (line.charAt(lndx - 1) == escapeChar) {
|
||||
// escaped '=' - remove '\' and continue on.
|
||||
line.deleteCharAt(lndx - 1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
lndx++;
|
||||
}
|
||||
map.put(line.substring(0, lndx), line.substring(lndx + 1));
|
||||
envStr.delete(0, ndx + 1);
|
||||
}
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
protected String encodeMap(Map values) {
|
||||
StringBuffer str = new StringBuffer();
|
||||
Iterator entries = values.entrySet().iterator();
|
||||
while (entries.hasNext()) {
|
||||
Entry entry = (Entry)entries.next();
|
||||
str.append(escapeChars((String)entry.getKey(), "=|\\", '\\')); //$NON-NLS-1$
|
||||
str.append("="); //$NON-NLS-1$
|
||||
str.append(escapeChars((String)entry.getValue(), "|\\", '\\')); //$NON-NLS-1$
|
||||
str.append("|"); //$NON-NLS-1$
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
protected String escapeChars(String string, String escapeChars, char escapeChar) {
|
||||
StringBuffer str = new StringBuffer(string);
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (escapeChars.indexOf(str.charAt(i)) != -1) {
|
||||
str.insert(i, escapeChar);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
protected abstract void putString(String name, String value) throws CoreException;
|
||||
protected abstract String getString(String property);
|
||||
}
|
||||
|
||||
private static class BuildInfoPreference extends AbstractBuildInfo {
|
||||
|
||||
private Preferences prefs;
|
||||
private String builderID;
|
||||
private boolean useDefaults;
|
||||
|
||||
BuildInfoPreference(Preferences prefs, String builderID, boolean useDefaults) {
|
||||
this.prefs = prefs;
|
||||
this.builderID = builderID;
|
||||
this.useDefaults = useDefaults;
|
||||
}
|
||||
|
||||
protected void putString(String name, String value) {
|
||||
if (useDefaults) {
|
||||
if (value != null) {
|
||||
prefs.setDefault(name, value);
|
||||
}
|
||||
} else {
|
||||
if (value == null) {
|
||||
prefs.setValue(name, prefs.getDefaultString(name));
|
||||
return;
|
||||
}
|
||||
prefs.setValue(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getString(String property) {
|
||||
if (!prefs.contains(property)) {
|
||||
return null;
|
||||
}
|
||||
if (useDefaults) {
|
||||
return prefs.getDefaultString(property);
|
||||
}
|
||||
return prefs.getString(property);
|
||||
}
|
||||
|
||||
protected String getBuilderID() {
|
||||
return builderID;
|
||||
}
|
||||
}
|
||||
|
||||
private static class BuildInfoProject extends AbstractBuildInfo {
|
||||
|
||||
private IProject project;
|
||||
private String builderID;
|
||||
private Map args;
|
||||
|
||||
BuildInfoProject(IProject project, String builderID) throws CoreException {
|
||||
this.project = project;
|
||||
this.builderID = builderID;
|
||||
ICommand builder;
|
||||
builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID);
|
||||
if (builder == null) {
|
||||
throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
|
||||
MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$
|
||||
}
|
||||
args = builder.getArguments();
|
||||
}
|
||||
|
||||
protected void putString(String name, String value) throws CoreException {
|
||||
String curValue = (String)args.get(name);
|
||||
if (curValue != null && curValue.equals(value)) {
|
||||
return;
|
||||
}
|
||||
if (value == null) {
|
||||
args.remove(name);
|
||||
} else {
|
||||
args.put(name, value);
|
||||
}
|
||||
IProjectDescription description = project.getDescription();
|
||||
ICommand builder = MakeProjectNature.getBuildSpec(description, builderID);
|
||||
builder.setArguments(args);
|
||||
builder.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, isAutoBuildEnable());
|
||||
builder.setBuilding(IncrementalProjectBuilder.FULL_BUILD, isFullBuildEnabled());
|
||||
builder.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, isIncrementalBuildEnabled());
|
||||
builder.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, isCleanBuildEnabled());
|
||||
MakeProjectNature.setBuildSpec(description, builder);
|
||||
project.setDescription(description, null);
|
||||
}
|
||||
|
||||
protected String getString(String name) {
|
||||
return (String)args.get(name);
|
||||
}
|
||||
|
||||
protected String getBuilderID() {
|
||||
return builderID;
|
||||
}
|
||||
}
|
||||
|
||||
private static class BuildInfoMap extends AbstractBuildInfo {
|
||||
|
||||
private Map args;
|
||||
private String builderID;
|
||||
|
||||
BuildInfoMap(Map args, String builderID) {
|
||||
this.args = args;
|
||||
this.builderID = builderID;
|
||||
}
|
||||
|
||||
protected void putString(String name, String value) {
|
||||
if (value == null) {
|
||||
args.remove(name);
|
||||
} else {
|
||||
args.put(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getString(String name) {
|
||||
return (String)args.get(name);
|
||||
}
|
||||
|
||||
protected String getBuilderID() {
|
||||
return builderID;
|
||||
}
|
||||
}
|
||||
|
||||
public static IMakeBuilderInfo create(Preferences prefs, String builderID, boolean useDefaults) {
|
||||
return new BuildInfoFactory.BuildInfoPreference(prefs, builderID, useDefaults);
|
||||
}
|
||||
|
||||
public static IMakeBuilderInfo create(IProject project, String builderID) throws CoreException {
|
||||
return new BuildInfoFactory.BuildInfoProject(project, builderID);
|
||||
}
|
||||
|
||||
public static IMakeBuilderInfo create(Map args, String builderID) {
|
||||
return new BuildInfoFactory.BuildInfoMap(args, builderID);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,596 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2006 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - initial API and implementation
|
||||
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.ui.dialogs;
|
||||
|
||||
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
||||
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||
import org.eclipse.cdt.make.ui.IMakeHelpContextIds;
|
||||
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.debug.ui.StringVariableSelectionDialog;
|
||||
import org.eclipse.jface.resource.JFaceResources;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.accessibility.AccessibleAdapter;
|
||||
import org.eclipse.swt.accessibility.AccessibleEvent;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
|
||||
|
||||
public class SettingsBlock extends AbstractCOptionPage {
|
||||
|
||||
private static final String PREFIX = "SettingsBlock"; //$NON-NLS-1$
|
||||
private static final String MAKE_LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||
private static final String MAKE_MESSAGE = PREFIX + ".message"; //$NON-NLS-1$
|
||||
|
||||
private static final String MAKE_SETTING_GROUP = PREFIX + ".makeSetting.group_label"; //$NON-NLS-1$
|
||||
private static final String MAKE_SETTING_STOP_ERROR = PREFIX + ".makeSetting.stopOnError"; //$NON-NLS-1$
|
||||
|
||||
private static final String MAKE_CMD_GROUP = PREFIX + ".makeCmd.group_label"; //$NON-NLS-1$
|
||||
private static final String MAKE_CMD_USE_DEFAULT = PREFIX + ".makeCmd.use_default"; //$NON-NLS-1$
|
||||
private static final String MAKE_CMD_LABEL = PREFIX + ".makeCmd.label"; //$NON-NLS-1$
|
||||
|
||||
private static final String MAKE_WORKBENCH_BUILD_GROUP = PREFIX + ".makeWorkbench.group_label"; //$NON-NLS-1$
|
||||
private static final String MAKE_WORKBENCH_BUILD_TYPE = PREFIX + ".makeWorkbench.type"; //$NON-NLS-1$
|
||||
private static final String MAKE_WORKBENCH_BUILD_TARGET = PREFIX + ".makeWorkbench.target"; //$NON-NLS-1$
|
||||
private static final String MAKE_WORKBENCH_BUILD_AUTO = PREFIX + ".makeWorkbench.auto"; //$NON-NLS-1$
|
||||
private static final String MAKE_WORKBENCH_BUILD_INCR = PREFIX + ".makeWorkbench.incremental"; //$NON-NLS-1$
|
||||
private static final String MAKE_WORKBENCH_BUILD_FULL = PREFIX + ".makeWorkbench.full"; //$NON-NLS-1$
|
||||
private static final String MAKE_WORKBENCH_BUILD_CLEAN = PREFIX + ".makeWorkbench.clean"; //$NON-NLS-1$
|
||||
|
||||
private static final String MAKE_BUILD_DIR_GROUP = PREFIX + ".makeLoc.group_label"; //$NON-NLS-1$
|
||||
private static final String MAKE_BUILD_DIR_LABEL = PREFIX + ".makeDir.label"; //$NON-NLS-1$
|
||||
private static final String MAKE_BUILD_DIR_BROWSE_FILESYSTEM = PREFIX + ".makeDir.browseFilesystem"; //$NON-NLS-1$
|
||||
private static final String MAKE_BUILD_DIR_BROWSE_WORKSPACE = PREFIX + ".makeDir.browseWorkspace"; //$NON-NLS-1$
|
||||
|
||||
private static final String MAKE_BUILD_AUTO_TARGET = PREFIX + ".makeWorkbench.autoBuildTarget"; //$NON-NLS-1$
|
||||
private static final String MAKE_BUILD_INCREMENTAL_TARGET = PREFIX + ".makeWorkbench.incrementalBuildTarget"; //$NON-NLS-1$
|
||||
private static final String MAKE_BUILD_FULL_TARGET = PREFIX + ".makeWorkbench.fullBuildTarget"; //$NON-NLS-1$
|
||||
private static final String MAKE_BUILD_CLEAN_TARGET = PREFIX + ".makeWorkbench.cleanTarget"; //$NON-NLS-1$
|
||||
|
||||
Button stopOnErrorButton;
|
||||
Button defButton;
|
||||
Text buildCommand;
|
||||
Button argumentVariablesButton;
|
||||
|
||||
Text buildLocation;
|
||||
Button locationVariablesButton;
|
||||
|
||||
Text targetIncr;
|
||||
Text targetAuto;
|
||||
Text targetClean;
|
||||
|
||||
Button incrButton;
|
||||
Button autoButton;
|
||||
Button cleanButton;
|
||||
|
||||
Button incrVariableButton;
|
||||
Button autoVariableButton;
|
||||
Button cleanVariableButton;
|
||||
|
||||
IMakeBuilderInfo fBuildInfo;
|
||||
Preferences fPrefs;
|
||||
String fBuilderID;
|
||||
|
||||
public SettingsBlock(Preferences prefs, String builderID) {
|
||||
super(MakeUIPlugin.getResourceString(MAKE_LABEL));
|
||||
setDescription(MakeUIPlugin.getResourceString(MAKE_MESSAGE));
|
||||
fPrefs = prefs;
|
||||
fBuilderID = builderID;
|
||||
}
|
||||
|
||||
protected void createSettingControls(Composite parent) {
|
||||
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1);
|
||||
stopOnErrorButton = new Button(group, SWT.CHECK);
|
||||
stopOnErrorButton.setText(MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR));
|
||||
if (fBuildInfo.isStopOnError()) {
|
||||
stopOnErrorButton.setSelection(true);
|
||||
}
|
||||
stopOnErrorButton.setEnabled(fBuildInfo.isDefaultBuildCmd());
|
||||
}
|
||||
|
||||
protected void createBuildCmdControls(Composite parent) {
|
||||
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 3;
|
||||
layout.makeColumnsEqualWidth = false;
|
||||
group.setLayout(layout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT));
|
||||
defButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
if (defButton.getSelection() == true) {
|
||||
buildCommand.setEnabled(false);
|
||||
argumentVariablesButton.setEnabled(false);
|
||||
stopOnErrorButton.setEnabled(true);
|
||||
getContainer().updateContainer();
|
||||
} else {
|
||||
buildCommand.setEnabled(true);
|
||||
argumentVariablesButton.setEnabled(true);
|
||||
stopOnErrorButton.setEnabled(false);
|
||||
getContainer().updateContainer();
|
||||
}
|
||||
}
|
||||
});
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 3;
|
||||
defButton.setLayoutData(gd);
|
||||
Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL));
|
||||
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
|
||||
((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
|
||||
buildCommand = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
|
||||
|
||||
((GridData) (buildCommand.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (buildCommand.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
buildCommand.addListener(SWT.Modify, new Listener() {
|
||||
|
||||
public void handleEvent(Event e) {
|
||||
getContainer().updateContainer();
|
||||
}
|
||||
});
|
||||
if (fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, null) != null) {
|
||||
StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_COMMAND, "")); //$NON-NLS-1$
|
||||
if (!fBuildInfo.isDefaultBuildCmd()) {
|
||||
String args = fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_ARGUMENTS, ""); //$NON-NLS-1$
|
||||
if (args != null && !args.equals("")) { //$NON-NLS-1$
|
||||
cmd.append(" "); //$NON-NLS-1$
|
||||
cmd.append(args);
|
||||
}
|
||||
}
|
||||
buildCommand.setText(cmd.toString());
|
||||
}
|
||||
argumentVariablesButton = addVariablesButton(group, buildCommand);
|
||||
if (fBuildInfo.isDefaultBuildCmd()) {
|
||||
buildCommand.setEnabled(false);
|
||||
argumentVariablesButton.setEnabled(false);
|
||||
}
|
||||
defButton.setSelection(fBuildInfo.isDefaultBuildCmd());
|
||||
}
|
||||
|
||||
protected void createWorkBenchBuildControls(Composite parent) {
|
||||
SelectionAdapter selectionAdapter = new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
targetAuto.setEnabled(autoButton.getSelection());
|
||||
autoVariableButton.setEnabled(autoButton.getSelection());
|
||||
targetIncr.setEnabled(incrButton.getSelection());
|
||||
incrVariableButton.setEnabled(incrButton.getSelection());
|
||||
targetClean.setEnabled(cleanButton.getSelection());
|
||||
cleanVariableButton.setEnabled(cleanButton.getSelection());
|
||||
getContainer().updateContainer();
|
||||
}
|
||||
|
||||
};
|
||||
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_GROUP), 1);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 3;
|
||||
layout.makeColumnsEqualWidth = false;
|
||||
group.setLayout(layout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Label label = new Label(group, SWT.NONE);
|
||||
label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TYPE));
|
||||
label = new Label(group, SWT.NONE);
|
||||
label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TARGET));
|
||||
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||
gd.horizontalSpan = 2;
|
||||
label.setLayoutData(gd);
|
||||
autoButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO));
|
||||
autoButton.addSelectionListener(selectionAdapter);
|
||||
autoButton.setSelection(fBuildInfo.isAutoBuildEnable());
|
||||
targetAuto = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
|
||||
targetAuto.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, "")); //$NON-NLS-1$
|
||||
((GridData) (targetAuto.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (targetAuto.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
addControlAccessibleListener(targetAuto, MakeUIPlugin.getResourceString(MAKE_BUILD_AUTO_TARGET));
|
||||
autoVariableButton = addVariablesButton(group, targetAuto);
|
||||
String noteTitle = MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.note"); //$NON-NLS-1$
|
||||
String noteMessage = MakeUIPlugin.getResourceString("SettingsBlock.makeWorkbench.autobuildMessage"); //$NON-NLS-1$
|
||||
Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), group, noteTitle, noteMessage);
|
||||
gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||
gd.horizontalSpan = 3;
|
||||
noteControl.setLayoutData(gd);
|
||||
incrButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR));
|
||||
incrButton.addSelectionListener(selectionAdapter);
|
||||
incrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled());
|
||||
targetIncr = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
|
||||
targetIncr.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, "")); //$NON-NLS-1$
|
||||
((GridData) (targetIncr.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (targetIncr.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
addControlAccessibleListener(targetIncr, MakeUIPlugin.getResourceString(MAKE_BUILD_INCREMENTAL_TARGET));
|
||||
incrVariableButton = addVariablesButton(group, targetIncr);
|
||||
cleanButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_CLEAN));
|
||||
cleanButton.addSelectionListener(selectionAdapter);
|
||||
cleanButton.setSelection(fBuildInfo.isCleanBuildEnabled());
|
||||
targetClean = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
|
||||
targetClean.setText(fBuildInfo.getBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, "")); //$NON-NLS-1$
|
||||
((GridData) (targetClean.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (targetClean.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
addControlAccessibleListener(targetClean, MakeUIPlugin.getResourceString(MAKE_BUILD_CLEAN_TARGET));
|
||||
cleanVariableButton = addVariablesButton(group, targetClean);
|
||||
selectionAdapter.widgetSelected(null);
|
||||
}
|
||||
|
||||
private Button addVariablesButton(Composite parent, final Text control) {
|
||||
String variablesTitle = MakeUIPlugin.getResourceString("SettingsBlock.variables"); //$NON-NLS-1$
|
||||
Button variablesButton = createPushButton(parent, variablesTitle, null);
|
||||
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
|
||||
variablesButton.setLayoutData(gd);
|
||||
variablesButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||
*/
|
||||
public void widgetSelected(SelectionEvent arg0) {
|
||||
handleVariablesButtonSelected(control);
|
||||
}
|
||||
});
|
||||
return variablesButton;
|
||||
}
|
||||
|
||||
protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
|
||||
Composite messageComposite = new Composite(composite, SWT.NONE);
|
||||
GridLayout messageLayout = new GridLayout();
|
||||
messageLayout.numColumns = 2;
|
||||
messageLayout.marginWidth = 0;
|
||||
messageLayout.marginHeight = 0;
|
||||
messageComposite.setLayout(messageLayout);
|
||||
messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
|
||||
messageComposite.setFont(font);
|
||||
|
||||
final Label noteLabel = new Label(messageComposite, SWT.BOLD);
|
||||
noteLabel.setText(title);
|
||||
noteLabel.setFont(JFaceResources.getBannerFont());
|
||||
noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
|
||||
|
||||
final IPropertyChangeListener fontListener = new IPropertyChangeListener() {
|
||||
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
if (JFaceResources.BANNER_FONT.equals(event.getProperty())) {
|
||||
noteLabel.setFont(JFaceResources.getFont(JFaceResources.BANNER_FONT));
|
||||
}
|
||||
}
|
||||
};
|
||||
JFaceResources.getFontRegistry().addListener(fontListener);
|
||||
noteLabel.addDisposeListener(new DisposeListener() {
|
||||
|
||||
public void widgetDisposed(DisposeEvent event) {
|
||||
JFaceResources.getFontRegistry().removeListener(fontListener);
|
||||
}
|
||||
});
|
||||
|
||||
Label messageLabel = new Label(messageComposite, SWT.WRAP);
|
||||
messageLabel.setText(message);
|
||||
messageLabel.setFont(font);
|
||||
return messageComposite;
|
||||
}
|
||||
public void addControlAccessibleListener(Control control, String controlName) {
|
||||
control.getAccessible().addAccessibleListener(new ControlAccessibleListener(controlName));
|
||||
}
|
||||
private class ControlAccessibleListener extends AccessibleAdapter {
|
||||
|
||||
private String controlName;
|
||||
ControlAccessibleListener(String name) {
|
||||
controlName = name;
|
||||
}
|
||||
public void getName(AccessibleEvent e) {
|
||||
e.result = controlName;
|
||||
}
|
||||
}
|
||||
protected void createBuilderWorkingDirControls(Composite parent) {
|
||||
Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_GROUP), 1);
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.numColumns = 2;
|
||||
layout.makeColumnsEqualWidth = false;
|
||||
group.setLayout(layout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_LABEL));
|
||||
((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING;
|
||||
((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false;
|
||||
buildLocation = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER);
|
||||
((GridData) (buildLocation.getLayoutData())).horizontalAlignment = GridData.FILL;
|
||||
((GridData) (buildLocation.getLayoutData())).grabExcessHorizontalSpace = true;
|
||||
buildLocation.addListener(SWT.Modify, new Listener() {
|
||||
|
||||
public void handleEvent(Event e) {
|
||||
getContainer().updateContainer();
|
||||
}
|
||||
});
|
||||
|
||||
Composite buttons = ControlFactory.createComposite(group, 4);
|
||||
layout = new GridLayout(4, false);
|
||||
layout.marginHeight = layout.marginWidth = 0;
|
||||
buttons.setLayout(layout);
|
||||
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||
gd.horizontalSpan = 2;
|
||||
buttons.setLayoutData(gd);
|
||||
|
||||
Label emptyLabel = ControlFactory.createLabel(buttons, ""); //$NON-NLS-1$
|
||||
emptyLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
Button browseWorkspace = new Button(buttons, SWT.NONE);
|
||||
browseWorkspace.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE_WORKSPACE));
|
||||
browseWorkspace.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), getContainer().getProject(), true,
|
||||
MakeUIPlugin.getResourceString("SettingsBlock.title.selectLocationToBuildFrom")); //$NON-NLS-1$
|
||||
if (dialog.open() == Window.OK) {
|
||||
Object[] selection = dialog.getResult();
|
||||
if (selection.length > 0) {
|
||||
buildLocation.setText( ((IPath)selection[0]).toOSString());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Button browseFilesystem = new Button(buttons, SWT.NONE);
|
||||
browseFilesystem.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE_FILESYSTEM));
|
||||
browseFilesystem.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
|
||||
dialog.setText(MakeUIPlugin.getResourceString("SettingsBlock.title.selectLocationToBuildFrom"));
|
||||
dialog.setFilterPath(getContainer().getProject().toString());
|
||||
String directory = dialog.open();
|
||||
if (directory != null) {
|
||||
if (directory.trim().length() > 0) {
|
||||
buildLocation.setText(directory);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buildLocation.setText(fBuildInfo.getBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, "")); //$NON-NLS-1$
|
||||
locationVariablesButton = addVariablesButton(buttons, buildLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
* A variable entry button has been pressed for the given text field. Prompt
|
||||
* the user for a variable and enter the result in the given field.
|
||||
*/
|
||||
private void handleVariablesButtonSelected(Text textField) {
|
||||
String variable = getVariable();
|
||||
if (variable != null) {
|
||||
textField.append(variable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the user to choose and configure a variable and returns the
|
||||
* resulting string, suitable to be used as an attribute.
|
||||
*/
|
||||
private String getVariable() {
|
||||
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
|
||||
dialog.open();
|
||||
return dialog.getVariableExpression();
|
||||
}
|
||||
public void createControl(Composite parent) {
|
||||
Composite composite = ControlFactory.createComposite(parent, 1);
|
||||
setControl(composite);
|
||||
|
||||
MakeUIPlugin.getDefault().getWorkbench().getHelpSystem().setHelp(getControl(), IMakeHelpContextIds.MAKE_BUILDER_SETTINGS);
|
||||
|
||||
if (fBuildInfo == null) {
|
||||
ControlFactory.createEmptySpace(composite);
|
||||
ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString("SettingsBlock.label.missingBuilderInformation")); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
|
||||
createBuildCmdControls(composite);
|
||||
createSettingControls(composite);
|
||||
createWorkBenchBuildControls(composite);
|
||||
|
||||
if (getContainer().getProject() != null) {
|
||||
createBuilderWorkingDirControls(composite);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
if (defButton != null && defButton.getSelection() != true) {
|
||||
String cmd = getBuildLine();
|
||||
if (cmd == null || cmd.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||
// Missing builder info
|
||||
if (fBuildInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (monitor == null) {
|
||||
monitor = new NullProgressMonitor();
|
||||
}
|
||||
IWorkspace workspace = MakeUIPlugin.getWorkspace();
|
||||
// To avoid multi-build
|
||||
IWorkspaceRunnable operation = new IWorkspaceRunnable() {
|
||||
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
monitor.beginTask(MakeUIPlugin.getResourceString("SettingsBlock.monitor.applyingSettings"), 1); //$NON-NLS-1$
|
||||
IMakeBuilderInfo info = null;
|
||||
if (getContainer().getProject() != null) {
|
||||
try {
|
||||
info = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
|
||||
} catch (CoreException e) {
|
||||
// disabled builder... just log it
|
||||
MakeCorePlugin.log(e);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
|
||||
}
|
||||
info.setStopOnError(isStopOnError());
|
||||
info.setUseDefaultBuildCmd(useDefaultBuildCmd());
|
||||
if (!useDefaultBuildCmd()) {
|
||||
String bldLine = getBuildLine();
|
||||
int start = 0;
|
||||
int end = -1;
|
||||
if (!bldLine.startsWith("\"")) { //$NON-NLS-1$
|
||||
end = bldLine.indexOf(' ');
|
||||
} else {
|
||||
start = 1;
|
||||
end = bldLine.indexOf('"', 1);
|
||||
}
|
||||
String path;
|
||||
if (end == -1) {
|
||||
path = bldLine;
|
||||
} else {
|
||||
path = bldLine.substring(start, end);
|
||||
}
|
||||
info.setBuildAttribute(IMakeBuilderInfo.BUILD_COMMAND, path);
|
||||
String args = ""; //$NON-NLS-1$
|
||||
if (end != -1) {
|
||||
args = bldLine.substring(end + 1);
|
||||
}
|
||||
info.setBuildAttribute(IMakeBuilderInfo.BUILD_ARGUMENTS, args);
|
||||
}
|
||||
info.setAutoBuildEnable(autoButton.getSelection());
|
||||
info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_AUTO, targetAuto.getText().trim());
|
||||
info.setIncrementalBuildEnable(incrButton.getSelection());
|
||||
info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_INCREMENTAL, targetIncr.getText().trim());
|
||||
info.setFullBuildEnable(incrButton.getSelection());
|
||||
info.setCleanBuildEnable(cleanButton.getSelection());
|
||||
info.setBuildAttribute(IMakeBuilderInfo.BUILD_TARGET_CLEAN, targetClean.getText().trim());
|
||||
if (buildLocation != null) {
|
||||
info.setBuildAttribute(IMakeBuilderInfo.BUILD_LOCATION, buildLocation.getText().trim());
|
||||
}
|
||||
}
|
||||
};
|
||||
if (getContainer().getProject() != null) {
|
||||
workspace.run(operation, monitor);
|
||||
} else {
|
||||
operation.run(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
public void performDefaults() {
|
||||
// Missing builder info
|
||||
if (fBuildInfo == null) {
|
||||
return;
|
||||
}
|
||||
IMakeBuilderInfo info;
|
||||
if (getContainer().getProject() != null) {
|
||||
info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
|
||||
} else {
|
||||
info = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, true);
|
||||
}
|
||||
if (info.isStopOnError())
|
||||
stopOnErrorButton.setSelection(true);
|
||||
else
|
||||
stopOnErrorButton.setSelection(false);
|
||||
if (info.getBuildCommand() != null) {
|
||||
StringBuffer cmd = new StringBuffer(info.getBuildCommand().toOSString());
|
||||
if (!info.isDefaultBuildCmd()) {
|
||||
String args = info.getBuildArguments();
|
||||
if (args != null && !args.equals("")) { //$NON-NLS-1$
|
||||
cmd.append(" "); //$NON-NLS-1$
|
||||
cmd.append(args);
|
||||
}
|
||||
}
|
||||
buildCommand.setText(cmd.toString());
|
||||
}
|
||||
if (info.isDefaultBuildCmd()) {
|
||||
buildCommand.setEnabled(false);
|
||||
argumentVariablesButton.setEnabled(false);
|
||||
stopOnErrorButton.setEnabled(true);
|
||||
} else {
|
||||
buildCommand.setEnabled(true);
|
||||
argumentVariablesButton.setEnabled(true);
|
||||
stopOnErrorButton.setEnabled(false);
|
||||
}
|
||||
|
||||
defButton.setSelection(info.isDefaultBuildCmd());
|
||||
|
||||
autoButton.setSelection(info.isAutoBuildEnable());
|
||||
autoVariableButton.setEnabled(info.isAutoBuildEnable());
|
||||
targetAuto.setEnabled(info.isAutoBuildEnable());
|
||||
targetAuto.setText(info.getAutoBuildTarget());
|
||||
incrButton.setSelection(info.isIncrementalBuildEnabled());
|
||||
incrVariableButton.setEnabled(info.isIncrementalBuildEnabled());
|
||||
targetIncr.setText(info.getIncrementalBuildTarget());
|
||||
targetIncr.setEnabled(info.isIncrementalBuildEnabled());
|
||||
cleanButton.setSelection(info.isCleanBuildEnabled());
|
||||
cleanVariableButton.setEnabled(info.isCleanBuildEnabled());
|
||||
targetClean.setText(info.getCleanBuildTarget());
|
||||
targetClean.setEnabled(info.isCleanBuildEnabled());
|
||||
}
|
||||
|
||||
boolean isStopOnError() {
|
||||
return stopOnErrorButton.getSelection();
|
||||
}
|
||||
|
||||
boolean useDefaultBuildCmd() {
|
||||
return defButton.getSelection();
|
||||
}
|
||||
|
||||
String getBuildLine() {
|
||||
if (buildCommand != null) {
|
||||
String cmd = buildCommand.getText();
|
||||
if (cmd != null)
|
||||
return cmd.trim();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setContainer(ICOptionContainer container) {
|
||||
super.setContainer(container);
|
||||
if (getContainer().getProject() != null) {
|
||||
try {
|
||||
fBuildInfo = MakeCorePlugin.createBuildInfo(getContainer().getProject(), fBuilderID);
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
} else {
|
||||
fBuildInfo = MakeCorePlugin.createBuildInfo(fPrefs, fBuilderID, false);
|
||||
}
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
if (!useDefaultBuildCmd()) {
|
||||
String cmd = getBuildLine();
|
||||
if (cmd == null || cmd.length() == 0) {
|
||||
return MakeUIPlugin.getResourceString("SettingsBlock.message.mustEnterBuildCommand"); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue