mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 11:45:38 +02:00
Initial check-in for the build environment variable support
This commit is contained in:
parent
3bdeb43cf3
commit
b1de8f55f5
49 changed files with 6024 additions and 66 deletions
|
@ -98,6 +98,16 @@
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="projectEnvironmentSupplier" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Specifies the name of the class that implements IProjectEnvironmentVariableSupplier
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
@ -318,6 +328,16 @@
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="configurationEnvironmentSupplier" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Specifies the name of the class that implements IConfigurationEnvironmentVariableSupplier
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
@ -360,6 +380,7 @@
|
||||||
<element ref="optionCategory"/>
|
<element ref="optionCategory"/>
|
||||||
<element ref="inputType"/>
|
<element ref="inputType"/>
|
||||||
<element ref="outputType"/>
|
<element ref="outputType"/>
|
||||||
|
<element ref="envVarBuildPath"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
<attribute name="id" type="string" use="required">
|
<attribute name="id" type="string" use="required">
|
||||||
<annotation>
|
<annotation>
|
||||||
|
@ -1253,6 +1274,48 @@ Version identifier for the managed build extension point. It is a string represe
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
<element name="envVarBuildPath">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Defines a set of environment variables used by a tool to represent the build paths (include paths or library paths).
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
<complexType>
|
||||||
|
<attribute name="pathType" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
The build path type. Can be one of the following: "buildpathInclude", "buildpathLibrary"
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="variableList" type="string" use="required">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
comma-separated list of the environment variable names used to store the include paths
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="pathDelimiter" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Represent the delimiter used to separate the paths. If omitted the default system delimiter will be used. That is the ":" for Unix-like systems and the ";" for Win32 systems.
|
||||||
|
If the "buildPathResolver" attribute is specified, the "pathDelimiter" is ignored
|
||||||
|
</documentation>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="buildPathResolver" type="string">
|
||||||
|
<annotation>
|
||||||
|
<documentation>
|
||||||
|
Should be set to the IBuildPathResolver interface that the tool-integrator can supply in order to provide his/her own logic of resolving the variable values to the build paths
|
||||||
|
</documentation>
|
||||||
|
<appInfo>
|
||||||
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.managedbuilder.core.IBuildPathResolver"/>
|
||||||
|
</appInfo>
|
||||||
|
</annotation>
|
||||||
|
</attribute>
|
||||||
|
</complexType>
|
||||||
|
</element>
|
||||||
|
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.section type="since"/>
|
<meta.section type="since"/>
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this interface is to be implemented by the tool-integrator to provide some specific
|
||||||
|
* logic for resolving the build path variable values to the build paths
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IBuildPathResolver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param pathType one of the IEnvVarBuildPath.BUILDPATH _xxx
|
||||||
|
* @param variableName represents the name of the variable that holds the build paths
|
||||||
|
* @param variableValue represents the value of the value specified with the
|
||||||
|
* variableName argument
|
||||||
|
* @param configuration represents configuration for which the build paths are requested
|
||||||
|
*/
|
||||||
|
String[] resolveBuildPaths(
|
||||||
|
int pathType,
|
||||||
|
String variableName,
|
||||||
|
String variableValue,
|
||||||
|
IConfiguration configuration);
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core;
|
package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
|
@ -425,4 +426,12 @@ public interface IConfiguration extends IBuildObject {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isSupported();
|
public boolean isSupported();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the implementation of the IConfigurationEnvironmentVariableSupplier provided
|
||||||
|
* by the tool-integrator or <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @return IConfigurationEnvironmentVariableSupplier
|
||||||
|
*/
|
||||||
|
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IEnvVarBuildPath {
|
||||||
|
public static final int BUILDPATH_INCLUDE = 1;
|
||||||
|
public static final int BUILDPATH_LIBRARY = 2;
|
||||||
|
|
||||||
|
public static final String BUILD_PATH_ELEMENT_NAME = "envVarBuildPath"; //$NON-NLS-1$
|
||||||
|
public static final String TYPE = "pathType"; //$NON-NLS-1$
|
||||||
|
public static final String LIST = "variableList"; //$NON-NLS-1$
|
||||||
|
public static final String PATH_DELIMITER = "pathDelimiter"; //$NON-NLS-1$
|
||||||
|
public static final String BUILD_PATH_RESOLVER = "buildPathResolver"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final String TYPE_INCLUDE = "buildpathInclude"; //$NON-NLS-1$
|
||||||
|
public static final String TYPE_LIBRARY = "buildpathLibrary"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final String NAME_SEPARATOR = ","; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return one of the ITool.BUILDPATH _xxx
|
||||||
|
*/
|
||||||
|
public int getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the array of String representing the build variable names
|
||||||
|
*/
|
||||||
|
public String[] getVariableNames();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the String representing the path delimiter used in the variables returned by
|
||||||
|
* the getVariableNames() method
|
||||||
|
*/
|
||||||
|
public String getPathDelimiter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the IBuildPathResolver interface implementation provided by the tool-integrator
|
||||||
|
* in order to specify his/her own logic of resolving the variable values to the build paths
|
||||||
|
* (see also the "Specifying the Includes and Library paths environment variables" and
|
||||||
|
* the "IBuildPathResolver" sections for more detail and for explanation why this callback
|
||||||
|
* might be needed)
|
||||||
|
*/
|
||||||
|
public IBuildPathResolver getBuildPathResolver();
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core;
|
package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents project-types in the managed build system.
|
* This class represents project-types in the managed build system.
|
||||||
* A project-type is a tool-integrator defined class of project which
|
* A project-type is a tool-integrator defined class of project which
|
||||||
|
@ -44,6 +47,7 @@ public interface IProjectType extends IBuildObject {
|
||||||
public static final String IS_ABSTRACT = "isAbstract"; //$NON-NLS-1$
|
public static final String IS_ABSTRACT = "isAbstract"; //$NON-NLS-1$
|
||||||
public static final String UNUSED_CHILDREN = "unusedChildren"; //$NON-NLS-1$
|
public static final String UNUSED_CHILDREN = "unusedChildren"; //$NON-NLS-1$
|
||||||
public static final String IS_TEST = "isTest"; //$NON-NLS-1$
|
public static final String IS_TEST = "isTest"; //$NON-NLS-1$
|
||||||
|
public static final String PROJECT_ENVIRONMENT_SUPPLIER = "projectEnvironmentSupplier"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a configuration for this project-type populated with the tools
|
* Creates a configuration for this project-type populated with the tools
|
||||||
|
@ -135,4 +139,12 @@ public interface IProjectType extends IBuildObject {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isSupported();
|
public boolean isSupported();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tool-integrator provided implementation of the project environment variable supplier
|
||||||
|
* or <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @return IProjectEnvironmentVariableSupplier
|
||||||
|
*/
|
||||||
|
public IProjectEnvironmentVariableSupplier getEnvironmentVariableSupplier();
|
||||||
}
|
}
|
||||||
|
|
|
@ -688,4 +688,11 @@ public interface ITool extends IBuildObject {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isExtensionElement();
|
public boolean isExtensionElement();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of the Environment Build Path variable descriptors
|
||||||
|
*
|
||||||
|
* @return IEnvVarBuildPath[]
|
||||||
|
*/
|
||||||
|
public IEnvVarBuildPath[] getEnvVarBuildPaths();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.core;
|
package org.eclipse.cdt.managedbuilder.core;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface represents a tool-integrator-defined, ordered set of tools
|
* This interface represents a tool-integrator-defined, ordered set of tools
|
||||||
|
@ -35,6 +38,8 @@ public interface IToolChain extends IBuildObject {
|
||||||
public static final String TARGET_TOOL = "targetTool"; //$NON-NLS-1$
|
public static final String TARGET_TOOL = "targetTool"; //$NON-NLS-1$
|
||||||
public static final String SECONDARY_OUTPUTS = "secondaryOutputs"; //$NON-NLS-1$
|
public static final String SECONDARY_OUTPUTS = "secondaryOutputs"; //$NON-NLS-1$
|
||||||
public static final String IS_TOOL_CHAIN_SUPPORTED = "isToolChainSupported"; //$NON-NLS-1$
|
public static final String IS_TOOL_CHAIN_SUPPORTED = "isToolChainSupported"; //$NON-NLS-1$
|
||||||
|
public static final String CONFIGURATION_ENVIRONMENT_SUPPLIER = "configurationEnvironmentSupplier"; //$NON-NLS-1$
|
||||||
|
|
||||||
// The attribute name for the scanner info collector
|
// The attribute name for the scanner info collector
|
||||||
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
|
public static final String SCANNER_CONFIG_PROFILE_ID = "scannerConfigDiscoveryProfileId"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -289,4 +294,12 @@ public interface IToolChain extends IBuildObject {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isSupported();
|
public boolean isSupported();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tool-integrator provided implementation of the configuration environment variable supplier
|
||||||
|
* or <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @return IConfigurationEnvironmentVariableSupplier
|
||||||
|
*/
|
||||||
|
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
import org.eclipse.cdt.core.parser.IScannerInfoChangeListener;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
|
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
|
import org.eclipse.cdt.managedbuilder.internal.core.DefaultManagedConfigElement;
|
||||||
|
@ -61,6 +63,7 @@ import org.eclipse.cdt.managedbuilder.internal.core.Target;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.TargetPlatform;
|
import org.eclipse.cdt.managedbuilder.internal.core.TargetPlatform;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
|
import org.eclipse.cdt.managedbuilder.internal.core.ToolChain;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||||
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
|
import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
|
||||||
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
||||||
|
@ -155,7 +158,18 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
private static Map buildModelListeners;
|
private static Map buildModelListeners;
|
||||||
// Random number for derived object model elements
|
// Random number for derived object model elements
|
||||||
private static Random randomNumber;
|
private static Random randomNumber;
|
||||||
|
// Environment Build Paths Change Listener
|
||||||
|
private static IEnvironmentBuildPathsChangeListener fEnvironmentBuildPathsChangeListener;
|
||||||
|
|
||||||
|
static {
|
||||||
|
getEnvironmentVariableProvider().subscribe(
|
||||||
|
fEnvironmentBuildPathsChangeListener = new IEnvironmentBuildPathsChangeListener(){
|
||||||
|
public void buildPathsChanged(IConfiguration configuration, int buildPathType){
|
||||||
|
if(buildPathType == IEnvVarBuildPath.BUILDPATH_INCLUDE)
|
||||||
|
notifyListeners(configuration,null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the next random number.
|
* Returns the next random number.
|
||||||
*
|
*
|
||||||
|
@ -576,6 +590,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
public static IManagedBuilderMakefileGenerator getBuildfileGenerator(IConfiguration config) {
|
public static IManagedBuilderMakefileGenerator getBuildfileGenerator(IConfiguration config) {
|
||||||
try {
|
try {
|
||||||
IToolChain toolChain = config.getToolChain();
|
IToolChain toolChain = config.getToolChain();
|
||||||
|
if(toolChain != null){
|
||||||
IBuilder builder = toolChain.getBuilder();
|
IBuilder builder = toolChain.getBuilder();
|
||||||
IConfigurationElement element = builder.getBuildFileGeneratorElement();
|
IConfigurationElement element = builder.getBuildFileGeneratorElement();
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
|
@ -590,6 +605,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
// Probably not defined
|
// Probably not defined
|
||||||
}
|
}
|
||||||
|
@ -650,7 +666,9 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
private static void notifyListeners(IConfiguration config, IOption option) {
|
private static void notifyListeners(IConfiguration config, IOption option) {
|
||||||
// Continue if change is something that effect the scanner
|
// Continue if change is something that effect the scanner
|
||||||
try {
|
try {
|
||||||
if (!(option.getValueType() == IOption.INCLUDE_PATH
|
//an option can be null in the case of calling this method from the environment
|
||||||
|
//build path change listener
|
||||||
|
if (option != null && !(option.getValueType() == IOption.INCLUDE_PATH
|
||||||
|| option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
|
|| option.getValueType() == IOption.PREPROCESSOR_SYMBOLS)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2024,4 +2042,13 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
public static void OutputManifestError(String message) {
|
public static void OutputManifestError(String message) {
|
||||||
System.err.println(ManagedMakeMessages.getResourceString(MANIFEST_ERROR_HEADER) + message + NEWLINE);
|
System.err.println(ManagedMakeMessages.getResourceString(MANIFEST_ERROR_HEADER) + message + NEWLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the instance of the Environment Variable Provider
|
||||||
|
*
|
||||||
|
* @return IEnvironmentVariableProvider
|
||||||
|
*/
|
||||||
|
public static IEnvironmentVariableProvider getEnvironmentVariableProvider(){
|
||||||
|
return EnvironmentVariableProvider.getDefault();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.envvar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this interface represents the given environment variable
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IBuildEnvironmentVariable{
|
||||||
|
public static final int ENVVAR_REPLACE = 1;
|
||||||
|
public static final int ENVVAR_REMOVE = 2;
|
||||||
|
public static final int ENVVAR_PREPEND = 3;
|
||||||
|
public static final int ENVVAR_APPEND = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the variable name
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the variable value
|
||||||
|
*/
|
||||||
|
public String getValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return one of the IBuildEnvironmentVariable.ENVVAR_* operation types
|
||||||
|
*/
|
||||||
|
public int getOperation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the variable can hold the list of values this method returns the String representing
|
||||||
|
* the delimiter that is used to separate values. This information is used for the following:
|
||||||
|
*
|
||||||
|
* 1. in append and prepend operations:
|
||||||
|
* If the variable already exists and contains some value the new
|
||||||
|
* value will be calculated in the following way:
|
||||||
|
* For the "prepend" operation:
|
||||||
|
* <New value> = <the value from the getValue() method><delimiter><Old value>
|
||||||
|
* For the "append" operation:
|
||||||
|
* <New value> = <Old value><delimiter><the value from the getValue() method>
|
||||||
|
*
|
||||||
|
* The Environment Variable Provider will also remove the duplicates of "sub-values"
|
||||||
|
* in the resulting value.
|
||||||
|
* For example:
|
||||||
|
* If the current value is "string1:string2:string3", the getDelimiter() method returns “:”
|
||||||
|
* and getValue() method returns "string4:string2" the new value will contain:
|
||||||
|
* For the "prepend" operation: "string4:string2:string1:string3"
|
||||||
|
* For the "append" operation: "string1:string3:string4:string2"
|
||||||
|
*
|
||||||
|
* 2. Since the environment variables are also treated as build macros the delimiter is also used
|
||||||
|
* by the BuildMacroProvider to determine the type of the macro used to represent the
|
||||||
|
* given environment variable. If the variable has the delimiter it is treated as the Text-List macro
|
||||||
|
* otherwise it is treated as the Text macro. (See Build Macro design for more details)
|
||||||
|
*
|
||||||
|
* To specify that no delimiter should be used, the getDelimiter() method should
|
||||||
|
* return null or an empty string
|
||||||
|
*/
|
||||||
|
public String getDelimiter();
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* this interface is to be implemented by the tool-integrator
|
||||||
|
* for supplying the configuration-specific environment
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IConfigurationEnvironmentVariableSupplier{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param variableName the variable mane
|
||||||
|
* @param configuration configuration
|
||||||
|
* @param provider the instance of the environment variable provider to be used for querying the
|
||||||
|
* environment variables from within the supplier. The supplier should use this provider to obtain
|
||||||
|
* the already defined environment instead of using the "default" provider returned by the
|
||||||
|
* ManagedBuildManager.getEnvironmentVariableProvider().
|
||||||
|
* The provider passed to a supplier will ignore searching the variables for the levels
|
||||||
|
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||||
|
* for the current level and will query all suppliers for the lower levels.
|
||||||
|
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
|
||||||
|
* and the provider in turn calls that supplier again. Also the supplier should not know anything
|
||||||
|
* about the environment variables defined for the higher levels.
|
||||||
|
* @return the reference to the IBuildEnvironmentVariable interface representing
|
||||||
|
* the variable of a given name
|
||||||
|
*/
|
||||||
|
IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
|
IConfiguration configuration,
|
||||||
|
IEnvironmentVariableProvider provider);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param configuration configuration
|
||||||
|
* @param provider the instance of the environment variable provider to be used for querying the
|
||||||
|
* environment variables from within the supplier. The supplier should use this provider to obtain
|
||||||
|
* the already defined environment instead of using the "default" provider returned by the
|
||||||
|
* ManagedBuildManager.getEnvironmentVariableProvider().
|
||||||
|
* The provider passed to a supplier will ignore searching the variables for the levels
|
||||||
|
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||||
|
* for the current level and will query all suppliers for the lower levels.
|
||||||
|
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
|
||||||
|
* and the provider in turn calls that supplier again. Also the supplier should not know anything
|
||||||
|
* about the environment variables defined for the higher levels.
|
||||||
|
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||||
|
*/
|
||||||
|
IBuildEnvironmentVariable[] getVariables (IConfiguration configuration,
|
||||||
|
IEnvironmentVariableProvider provider);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* listeners of the environment build path changes should implement this interface
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IEnvironmentBuildPathsChangeListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param configuration represent the configuration for which the paths were changed
|
||||||
|
* @param buildPathType set to one of
|
||||||
|
* the IEnvVarBuildPath.BUILDPATH_xxx
|
||||||
|
* (the IEnvVarBuildPath will represent the build environment variables, see also
|
||||||
|
* the "Specifying the Includes and Library paths environment variables",
|
||||||
|
* the "envVarBuildPath schema" and the "Expected CDT/MBS code changes" sections)
|
||||||
|
*/
|
||||||
|
void buildPathsChanged(IConfiguration configuration, int buildPathType);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* this interface represent the environment variable provider - the main entry-point
|
||||||
|
* to be used for querying the build environment
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IEnvironmentVariableProvider{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return the reference to the IBuildEnvironmentVariable interface representing
|
||||||
|
* the variable of a given name
|
||||||
|
* @param variableName environment variable name
|
||||||
|
* if environment variable names are case insensitive in the current OS,
|
||||||
|
* the environment variable provider will query the getVariable method of suppliers always
|
||||||
|
* passing it the uppercase variable name not depending on the case of the variableName
|
||||||
|
* passed to the IEnvironmentVariableProvider.getVariable() method. This will prevent the
|
||||||
|
* supplier from answering different values for the same variable given the names that differ
|
||||||
|
* only by case. E.g. if the current OS does not support case sensitive variables both of the
|
||||||
|
* calls below:
|
||||||
|
*
|
||||||
|
* provider.getVariable("FOO",level,includeParentContexts);
|
||||||
|
* provider.getVariable("foo",level,includeParentContexts);
|
||||||
|
*
|
||||||
|
* will result in asking suppliers for the "FOO" variable
|
||||||
|
*
|
||||||
|
* @param level could be one of the following:
|
||||||
|
* 1. IConfiguration to represent the configuration
|
||||||
|
* 2. IManagedProject to represent the managed project
|
||||||
|
* 3. IWorkspace to represent the workspace
|
||||||
|
* 4. null to represent the system environment passed to eclipse
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(
|
||||||
|
String variableName, Object level, boolean includeParentLevels);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* if environment variable names are case insensitive in the current OS,
|
||||||
|
* the environment variable provider will remove the duplicates of the variables if their names
|
||||||
|
* differ only by case
|
||||||
|
*
|
||||||
|
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(
|
||||||
|
Object level, boolean includeParentLevels);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return the String representing default system delimiter. That is the ":" for Unix-like
|
||||||
|
* systems and the ";" for Win32 systems. This method will be used by the
|
||||||
|
* tool-integrator provided variable supplier e.g. in order to concatenate the list of paths into the
|
||||||
|
* environment variable, etc.
|
||||||
|
*/
|
||||||
|
public String getDefaultDelimiter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the OS supports case sensitive variables (Unix-like systems) or false
|
||||||
|
* if it does not (Win32 systems)
|
||||||
|
*/
|
||||||
|
public boolean isVariableCaseSensitive();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is defined to be used basically by the UI classes and should not be used by the
|
||||||
|
* tool-integrator
|
||||||
|
* @return the array of the provider-internal suppliers for the given level
|
||||||
|
*/
|
||||||
|
IEnvironmentVariableSupplier[] getSuppliers(Object level);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the array of String that holds the build paths of the specified type
|
||||||
|
* @param configuration represent the configuration for which the paths were changed
|
||||||
|
* @param buildPathType can be set to one of the IEnvVarBuildPath.BUILDPATH _xxx
|
||||||
|
* (the IEnvVarBuildPath will represent the build environment variables, see also
|
||||||
|
* the "Specifying the Includes and Library paths environment variables",
|
||||||
|
* the "envVarBuildPath schema" and the "Expected CDT/MBS code changes" sections)
|
||||||
|
*/
|
||||||
|
String[] getBuildPaths(IConfiguration configuration, int buildPathType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* adds the listener that will return notifications about the include and library paths changes.
|
||||||
|
* The ManagedBuildManager will register the change listener and will notify all registered
|
||||||
|
* Scanned Info Change Listeners about the include paths change.
|
||||||
|
*/
|
||||||
|
void subscribe(
|
||||||
|
IEnvironmentBuildPathsChangeListener listener);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* removes the include and library paths change listener
|
||||||
|
*/
|
||||||
|
void unsubscribe(
|
||||||
|
IEnvironmentBuildPathsChangeListener listener);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.envvar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IEnvironmentVariableSupplier {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param name the variable mane
|
||||||
|
* @param context the context
|
||||||
|
* @return the reference to the IBuildEnvironmentVariable interface representing
|
||||||
|
* the variable of a given name
|
||||||
|
*/
|
||||||
|
IBuildEnvironmentVariable getVariable(String name, Object context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||||
|
*/
|
||||||
|
IBuildEnvironmentVariable[] getVariables(Object context);
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* this interface is to be implemented by the tool-integrator
|
||||||
|
* for supplying the project-specific environment
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IProjectEnvironmentVariableSupplier{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param variableName the variable mane
|
||||||
|
* @param project the managed project
|
||||||
|
* @param provider the instance of the environment variable provider to be used for querying the
|
||||||
|
* environment variables from within the supplier. The supplier should use this provider to obtain
|
||||||
|
* the already defined environment instead of using the "default" provider returned by the
|
||||||
|
* ManagedBuildManager.getEnvironmentVariableProvider().
|
||||||
|
* The provider passed to a supplier will ignore searching the variables for the levels
|
||||||
|
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||||
|
* for the current level and will query all suppliers for the lower levels.
|
||||||
|
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
|
||||||
|
* and the provider in turn calls that supplier again. Also the supplier should not know anything
|
||||||
|
* about the environment variables defined for the higher levels.
|
||||||
|
* @return the reference to the IBuildEnvironmentVariable interface representing
|
||||||
|
* the variable of a given name
|
||||||
|
*/
|
||||||
|
IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
|
IManagedProject project,
|
||||||
|
IEnvironmentVariableProvider provider);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param project the managed project
|
||||||
|
* @param provider the instance of the environment variable provider to be used for querying the
|
||||||
|
* environment variables from within the supplier. The supplier should use this provider to obtain
|
||||||
|
* the already defined environment instead of using the "default" provider returned by the
|
||||||
|
* ManagedBuildManager.getEnvironmentVariableProvider().
|
||||||
|
* The provider passed to a supplier will ignore searching the variables for the levels
|
||||||
|
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||||
|
* for the current level and will query all suppliers for the lower levels.
|
||||||
|
* This is done to avoid infinite loops that could be caused if the supplier calls the provider
|
||||||
|
* and the provider in turn calls that supplier again. Also the supplier should not know anything
|
||||||
|
* about the environment variables defined for the higher levels.
|
||||||
|
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||||
|
*/
|
||||||
|
IBuildEnvironmentVariable[] getVariables (IManagedProject project,
|
||||||
|
IEnvironmentVariableProvider provider);
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
|
import org.eclipse.cdt.managedbuilder.internal.core.ResourceConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -1208,6 +1210,8 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
*/
|
*/
|
||||||
public void setRebuildState(boolean rebuild) {
|
public void setRebuildState(boolean rebuild) {
|
||||||
rebuildNeeded = rebuild;
|
rebuildNeeded = rebuild;
|
||||||
|
if(rebuild)
|
||||||
|
((EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider()).checkBuildPathVariables(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -1297,4 +1301,14 @@ public class Configuration extends BuildObject implements IConfiguration {
|
||||||
addResourceConfiguration(resConfig);
|
addResourceConfiguration(resConfig);
|
||||||
return resConfig;
|
return resConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IConfiguration#getEnvironmentVariableSupplier()
|
||||||
|
*/
|
||||||
|
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
|
||||||
|
IToolChain toolChain = getToolChain();
|
||||||
|
if(toolChain != null)
|
||||||
|
return toolChain.getEnvironmentVariableSupplier();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
|
public class EnvVarBuildPath implements
|
||||||
|
IEnvVarBuildPath {
|
||||||
|
private ITool tool;
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
private String variableNames[];
|
||||||
|
private String pathDelimiter;
|
||||||
|
private IBuildPathResolver buildPathResolver;
|
||||||
|
private IConfigurationElement buildPathResolverElement;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to create an EnvVarBuildPath based on an element from the plugin
|
||||||
|
* manifest.
|
||||||
|
*
|
||||||
|
* @param element The element containing the information about the tool.
|
||||||
|
*/
|
||||||
|
public EnvVarBuildPath(ITool tool, IManagedConfigElement element) {
|
||||||
|
this.tool = tool;
|
||||||
|
loadFromManifest(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* Load the EnvVarBuildPath information from the XML element specified in the
|
||||||
|
* argument
|
||||||
|
* @param element An XML element containing the tool information
|
||||||
|
*/
|
||||||
|
protected void loadFromManifest(IManagedConfigElement element) {
|
||||||
|
|
||||||
|
setType(convertPathTypeToInt(element.getAttribute(TYPE)));
|
||||||
|
|
||||||
|
setVariableNames(element.getAttribute(LIST));
|
||||||
|
|
||||||
|
setPathDelimiter(element.getAttribute(PATH_DELIMITER));
|
||||||
|
|
||||||
|
// Store the configuration element IFF there is a build path resolver defined
|
||||||
|
String buildPathResolver = element.getAttribute(BUILD_PATH_RESOLVER);
|
||||||
|
if (buildPathResolver != null && element instanceof DefaultManagedConfigElement) {
|
||||||
|
buildPathResolverElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath#getType()
|
||||||
|
*/
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type){
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath#getVariableNames()
|
||||||
|
*/
|
||||||
|
public String[] getVariableNames() {
|
||||||
|
return variableNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariableNames(String names[]){
|
||||||
|
this.variableNames = names;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariableNames(String names){
|
||||||
|
setVariableNames(getNamesFromString(names));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getNamesFromString(String names){
|
||||||
|
if(names == null)
|
||||||
|
return null;
|
||||||
|
return names.split(NAME_SEPARATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath#getPathDelimiter()
|
||||||
|
*/
|
||||||
|
public String getPathDelimiter() {
|
||||||
|
return pathDelimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPathDelimiter(String delimiter) {
|
||||||
|
if(delimiter == null)
|
||||||
|
delimiter = ManagedBuildManager.getEnvironmentVariableProvider().getDefaultDelimiter();
|
||||||
|
this.pathDelimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int convertPathTypeToInt(String pathType){
|
||||||
|
if(pathType != null && TYPE_LIBRARY.equals(pathType))
|
||||||
|
return BUILDPATH_LIBRARY;
|
||||||
|
return BUILDPATH_INCLUDE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String convertPathTypeToString(int pathType){
|
||||||
|
switch(pathType){
|
||||||
|
case BUILDPATH_LIBRARY:
|
||||||
|
return TYPE_LIBRARY;
|
||||||
|
case BUILDPATH_INCLUDE:
|
||||||
|
default:
|
||||||
|
return TYPE_INCLUDE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath#getBuildPathResolver()
|
||||||
|
*/
|
||||||
|
public IBuildPathResolver getBuildPathResolver() {
|
||||||
|
if(buildPathResolver == null && buildPathResolverElement != null){
|
||||||
|
try {
|
||||||
|
if (buildPathResolverElement.getAttribute(BUILD_PATH_RESOLVER) != null) {
|
||||||
|
buildPathResolver = (IBuildPathResolver) buildPathResolverElement.createExecutableExtension(BUILD_PATH_RESOLVER);
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {}
|
||||||
|
}
|
||||||
|
return buildPathResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ import org.eclipse.cdt.core.resources.IConsole;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -608,17 +609,13 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
||||||
CommandLauncher launcher = new CommandLauncher();
|
CommandLauncher launcher = new CommandLauncher();
|
||||||
launcher.showCommand(true);
|
launcher.showCommand(true);
|
||||||
|
|
||||||
// Set the environmennt, some scripts may need the CWD var to be set.
|
// Set the environmennt
|
||||||
Properties props = launcher.getEnvironment();
|
IBuildEnvironmentVariable variables[] = ManagedBuildManager.getEnvironmentVariableProvider().getVariables(cfg,true);
|
||||||
props.put("CWD", workingDirectory.toOSString()); //$NON-NLS-1$
|
|
||||||
props.put("PWD", workingDirectory.toOSString()); //$NON-NLS-1$
|
|
||||||
String[] env = null;
|
String[] env = null;
|
||||||
ArrayList envList = new ArrayList();
|
ArrayList envList = new ArrayList();
|
||||||
Enumeration names = props.propertyNames();
|
if (variables != null) {
|
||||||
if (names != null) {
|
for(int i = 0; i < variables.length; i++){
|
||||||
while (names.hasMoreElements()) {
|
envList.add(variables[i].getName() + "=" + variables[i].getValue()); //$NON-NLS-1$
|
||||||
String key = (String) names.nextElement();
|
|
||||||
envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
env = (String[]) envList.toArray(new String[envList.size()]);
|
env = (String[]) envList.toArray(new String[envList.size()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,16 +30,18 @@ import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
import org.eclipse.cdt.managedbuilder.core.ITarget;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
|
||||||
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
|
||||||
|
@ -440,6 +442,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add paths specified in the environment
|
||||||
|
String envIncludePaths[] = ManagedBuildManager.getEnvironmentVariableProvider().getBuildPaths(config,IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||||
|
if(envIncludePaths != null)
|
||||||
|
paths.addAll(Arrays.asList(envIncludePaths));
|
||||||
|
|
||||||
// Answer the results as an array
|
// Answer the results as an array
|
||||||
return (String[])paths.toArray(new String[paths.size()]);
|
return (String[])paths.toArray(new String[paths.size()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,3 +80,5 @@ GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency
|
||||||
|
|
||||||
# Tool strings
|
# Tool strings
|
||||||
Tool.default.announcement=Invoking:
|
Tool.default.announcement=Invoking:
|
||||||
|
#Environment loader messages
|
||||||
|
StorableEnvironmentLoader.storeOutputStream.wrong.arguments="Wrong arguments"
|
||||||
|
|
|
@ -20,6 +20,9 @@ import org.eclipse.cdt.managedbuilder.core.IProjectType;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
|
|
||||||
public class ProjectType extends BuildObject implements IProjectType {
|
public class ProjectType extends BuildObject implements IProjectType {
|
||||||
|
|
||||||
|
@ -36,6 +39,9 @@ public class ProjectType extends BuildObject implements IProjectType {
|
||||||
private Boolean isAbstract;
|
private Boolean isAbstract;
|
||||||
private Boolean isTest;
|
private Boolean isTest;
|
||||||
private String unusedChildren;
|
private String unusedChildren;
|
||||||
|
private IConfigurationElement environmentVariableSupplierElement = null;
|
||||||
|
private IProjectEnvironmentVariableSupplier environmentVariableSupplier = null;
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
private boolean resolved = true;
|
private boolean resolved = true;
|
||||||
|
|
||||||
|
@ -122,6 +128,13 @@ public class ProjectType extends BuildObject implements IProjectType {
|
||||||
if (isTestStr != null){
|
if (isTestStr != null){
|
||||||
isTest = new Boolean("true".equals(isTestStr)); //$NON-NLS-1$
|
isTest = new Boolean("true".equals(isTestStr)); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the environmentVariableSupplier configuration element
|
||||||
|
String environmentVariableSupplier = element.getAttribute(PROJECT_ENVIRONMENT_SUPPLIER);
|
||||||
|
if(environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement){
|
||||||
|
environmentVariableSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -350,4 +363,38 @@ public class ProjectType extends BuildObject implements IProjectType {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the plugin.xml element of the projectEnvironmentSupplier extension or <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @return IConfigurationElement
|
||||||
|
*/
|
||||||
|
public IConfigurationElement getEnvironmentVariableSupplierElement(){
|
||||||
|
if (environmentVariableSupplierElement == null) {
|
||||||
|
if (superClass != null && superClass instanceof ProjectType) {
|
||||||
|
return ((ProjectType)superClass).getEnvironmentVariableSupplierElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return environmentVariableSupplierElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.build.managed.IProjectType#getEnvironmentVariableSupplier()
|
||||||
|
*/
|
||||||
|
public IProjectEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
|
||||||
|
if (environmentVariableSupplier != null) {
|
||||||
|
return environmentVariableSupplier;
|
||||||
|
}
|
||||||
|
IConfigurationElement element = getEnvironmentVariableSupplierElement();
|
||||||
|
if (element != null) {
|
||||||
|
try {
|
||||||
|
if (element.getAttribute(PROJECT_ENVIRONMENT_SUPPLIER) != null) {
|
||||||
|
environmentVariableSupplier = (IProjectEnvironmentVariableSupplier) element.createExecutableExtension(PROJECT_ENVIRONMENT_SUPPLIER);
|
||||||
|
return environmentVariableSupplier;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Vector;
|
||||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
|
@ -73,6 +74,7 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
||||||
private Map inputTypeMap;
|
private Map inputTypeMap;
|
||||||
private Vector outputTypeList;
|
private Vector outputTypeList;
|
||||||
private Map outputTypeMap;
|
private Map outputTypeMap;
|
||||||
|
private List envVarBuildPathList;
|
||||||
// Managed Build model attributes
|
// Managed Build model attributes
|
||||||
private String unusedChildren;
|
private String unusedChildren;
|
||||||
private Boolean isAbstract;
|
private Boolean isAbstract;
|
||||||
|
@ -136,6 +138,8 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
||||||
} else if (toolElement.getName().equals(ITool.OUTPUT_TYPE)) {
|
} else if (toolElement.getName().equals(ITool.OUTPUT_TYPE)) {
|
||||||
OutputType outputType = new OutputType(this, toolElement);
|
OutputType outputType = new OutputType(this, toolElement);
|
||||||
addOutputType(outputType);
|
addOutputType(outputType);
|
||||||
|
} else if (toolElement.getName().equals(IEnvVarBuildPath.BUILD_PATH_ELEMENT_NAME)){
|
||||||
|
addEnvVarBuildPath(new EnvVarBuildPath(this,toolElement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,6 +314,9 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
||||||
dependencyGeneratorElement = tool.dependencyGeneratorElement;
|
dependencyGeneratorElement = tool.dependencyGeneratorElement;
|
||||||
dependencyGenerator = tool.dependencyGenerator;
|
dependencyGenerator = tool.dependencyGenerator;
|
||||||
|
|
||||||
|
if(tool.envVarBuildPathList != null)
|
||||||
|
envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
|
||||||
|
|
||||||
// Clone the children
|
// Clone the children
|
||||||
// Note: This constructor ignores OptionCategories since they should not be
|
// Note: This constructor ignores OptionCategories since they should not be
|
||||||
// found on an non-extension tool - TODO: This may need to change!
|
// found on an non-extension tool - TODO: This may need to change!
|
||||||
|
@ -2316,4 +2323,27 @@ public class Tool extends BuildObject implements ITool, IOptionCategory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.ITool#getEnvVarBuildPaths()
|
||||||
|
*/
|
||||||
|
public IEnvVarBuildPath[] getEnvVarBuildPaths(){
|
||||||
|
if(envVarBuildPathList != null){
|
||||||
|
return (IEnvVarBuildPath[])envVarBuildPathList.toArray(
|
||||||
|
new IEnvVarBuildPath[envVarBuildPathList.size()]);
|
||||||
|
}
|
||||||
|
else if(superClass != null)
|
||||||
|
return superClass.getEnvVarBuildPaths();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addEnvVarBuildPath(IEnvVarBuildPath path){
|
||||||
|
if(path == null)
|
||||||
|
return;
|
||||||
|
if(envVarBuildPathList == null)
|
||||||
|
envVarBuildPathList = new ArrayList();
|
||||||
|
|
||||||
|
envVarBuildPathList.add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ITool;
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
import org.eclipse.cdt.managedbuilder.core.IToolChain;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IConfigurationElement;
|
import org.eclipse.core.runtime.IConfigurationElement;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
@ -59,6 +60,9 @@ public class ToolChain extends BuildObject implements IToolChain {
|
||||||
private String scannerConfigDiscoveryProfileId;
|
private String scannerConfigDiscoveryProfileId;
|
||||||
private IConfigurationElement managedIsToolChainSupportedElement = null;
|
private IConfigurationElement managedIsToolChainSupportedElement = null;
|
||||||
private IManagedIsToolChainSupported managedIsToolChainSupported = null;
|
private IManagedIsToolChainSupported managedIsToolChainSupported = null;
|
||||||
|
private IConfigurationElement environmentVariableSupplierElement = null;
|
||||||
|
private IConfigurationEnvironmentVariableSupplier environmentVariableSupplier = null;
|
||||||
|
|
||||||
// Miscellaneous
|
// Miscellaneous
|
||||||
private boolean isExtensionToolChain = false;
|
private boolean isExtensionToolChain = false;
|
||||||
private boolean isDirty = false;
|
private boolean isDirty = false;
|
||||||
|
@ -225,6 +229,9 @@ public class ToolChain extends BuildObject implements IToolChain {
|
||||||
managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
|
managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
|
||||||
managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
|
managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
|
||||||
|
|
||||||
|
environmentVariableSupplierElement = toolChain.environmentVariableSupplierElement;
|
||||||
|
environmentVariableSupplier = toolChain.environmentVariableSupplier;
|
||||||
|
|
||||||
// Clone the children
|
// Clone the children
|
||||||
if (toolChain.builder != null) {
|
if (toolChain.builder != null) {
|
||||||
int nnn = ManagedBuildManager.getRandomNumber();
|
int nnn = ManagedBuildManager.getRandomNumber();
|
||||||
|
@ -342,6 +349,12 @@ public class ToolChain extends BuildObject implements IToolChain {
|
||||||
if (managedIsToolChainSupported != null && element instanceof DefaultManagedConfigElement) {
|
if (managedIsToolChainSupported != null && element instanceof DefaultManagedConfigElement) {
|
||||||
managedIsToolChainSupportedElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
|
managedIsToolChainSupportedElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the environmentVariableSupplier configuration element
|
||||||
|
String environmentVariableSupplier = element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER);
|
||||||
|
if(environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement){
|
||||||
|
environmentVariableSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -519,6 +532,12 @@ public class ToolChain extends BuildObject implements IToolChain {
|
||||||
// TODO: issue warning?
|
// TODO: issue warning?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: environmentVariableSupplier cannot be specified in a project file because
|
||||||
|
// an IConfigurationElement is needed to load it!
|
||||||
|
if(environmentVariableSupplierElement != null) {
|
||||||
|
// TODO: issue warning?
|
||||||
|
}
|
||||||
|
|
||||||
// I am clean now
|
// I am clean now
|
||||||
isDirty = false;
|
isDirty = false;
|
||||||
}
|
}
|
||||||
|
@ -1124,4 +1143,38 @@ public class ToolChain extends BuildObject implements IToolChain {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the plugin.xml element of the configurationEnvironmentSupplier extension or <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @return IConfigurationElement
|
||||||
|
*/
|
||||||
|
public IConfigurationElement getEnvironmentVariableSupplierElement(){
|
||||||
|
if (environmentVariableSupplierElement == null) {
|
||||||
|
if (superClass != null && superClass instanceof ToolChain) {
|
||||||
|
return ((ToolChain)superClass).getEnvironmentVariableSupplierElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return environmentVariableSupplierElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getEnvironmentVariableSupplier()
|
||||||
|
*/
|
||||||
|
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
|
||||||
|
if (environmentVariableSupplier != null) {
|
||||||
|
return environmentVariableSupplier;
|
||||||
|
}
|
||||||
|
IConfigurationElement element = getEnvironmentVariableSupplierElement();
|
||||||
|
if (element != null) {
|
||||||
|
try {
|
||||||
|
if (element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER) != null) {
|
||||||
|
environmentVariableSupplier = (IConfigurationEnvironmentVariableSupplier) element.createExecutableExtension(CONFIGURATION_ENVIRONMENT_SUPPLIER);
|
||||||
|
return environmentVariableSupplier;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
|
import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
import org.eclipse.cdt.managedbuilder.core.IInputType;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
|
||||||
|
@ -1092,4 +1093,10 @@ public class ToolReference implements IToolReference {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.build.managed.ITool#getEnvVarBuildPaths()
|
||||||
|
*/
|
||||||
|
public IEnvVarBuildPath[] getEnvVarBuildPaths(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* a trivial implementation of the IBuildEnvironmentVariable
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class BuildEnvVar implements IBuildEnvironmentVariable {
|
||||||
|
protected String fName;
|
||||||
|
protected String fValue;
|
||||||
|
protected String fDelimiter;
|
||||||
|
protected int fOperation;
|
||||||
|
|
||||||
|
public BuildEnvVar(String name, String value, int op, String delimiter){
|
||||||
|
fName = name;
|
||||||
|
fOperation = op;
|
||||||
|
fValue = value;
|
||||||
|
fDelimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BuildEnvVar(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildEnvVar(String name){
|
||||||
|
this(name,null,ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildEnvVar(String name, String value){
|
||||||
|
this(name,value,ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildEnvVar(String name, String value, String delimiter){
|
||||||
|
this(name,value,ENVVAR_REPLACE,delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildEnvVar(IBuildEnvironmentVariable var){
|
||||||
|
this(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getName()
|
||||||
|
*/
|
||||||
|
public String getName(){
|
||||||
|
return fName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getValue()
|
||||||
|
*/
|
||||||
|
public String getValue(){
|
||||||
|
return fValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getOperation()
|
||||||
|
*/
|
||||||
|
public int getOperation(){
|
||||||
|
return fOperation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable#getDelimiter()
|
||||||
|
*/
|
||||||
|
public String getDelimiter(){
|
||||||
|
return fDelimiter;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default implementation of the IContextInfo used by the Environment Variable Provider
|
||||||
|
* Used to represent the Configuration, Project, Workspace and Eclipse environment contexts
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class DefaultContextInfo implements IContextInfo{
|
||||||
|
private Object fContextObject;
|
||||||
|
private IEnvironmentVariableSupplier fContextSuppliers[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructor is used to create the default context info given a context object
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
*/
|
||||||
|
public DefaultContextInfo(Object context){
|
||||||
|
fContextObject = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DefaultContextInfo(Object context, IEnvironmentVariableSupplier suppliers[]){
|
||||||
|
fContextSuppliers = suppliers;
|
||||||
|
fContextObject = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* answers the list of suppliers that should be used for the given context
|
||||||
|
*/
|
||||||
|
protected IEnvironmentVariableSupplier[] getSuppliers(Object context){
|
||||||
|
IEnvironmentVariableSupplier suppliers[];
|
||||||
|
if(context == null)
|
||||||
|
suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fEclipseSupplier};
|
||||||
|
else if(context instanceof IWorkspace)
|
||||||
|
suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fUserSupplier};
|
||||||
|
else if(context instanceof IManagedProject)
|
||||||
|
suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fUserSupplier,EnvironmentVariableProvider.fExternalSupplier};
|
||||||
|
else if(context instanceof IConfiguration)
|
||||||
|
suppliers = new IEnvironmentVariableSupplier[]{EnvironmentVariableProvider.fUserSupplier,EnvironmentVariableProvider.fExternalSupplier,EnvironmentVariableProvider.fMbsSupplier};
|
||||||
|
else
|
||||||
|
suppliers = null;
|
||||||
|
return suppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
|
||||||
|
*/
|
||||||
|
public IContextInfo getNext(){
|
||||||
|
DefaultContextInfo next = null;
|
||||||
|
if(fContextObject == null)
|
||||||
|
next = null;
|
||||||
|
else if(fContextObject instanceof IWorkspace)
|
||||||
|
next = new DefaultContextInfo(null);
|
||||||
|
else if(fContextObject instanceof IManagedProject)
|
||||||
|
next = new DefaultContextInfo(ResourcesPlugin.getWorkspace());
|
||||||
|
else if(fContextObject instanceof IConfiguration)
|
||||||
|
next = new DefaultContextInfo(((IConfiguration)fContextObject).getManagedProject());
|
||||||
|
else
|
||||||
|
next = null;
|
||||||
|
|
||||||
|
if(next != null && next.getSuppliers() == null)
|
||||||
|
next = null;
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getSuppliers()
|
||||||
|
*/
|
||||||
|
public IEnvironmentVariableSupplier[] getSuppliers(){
|
||||||
|
if(fContextSuppliers == null)
|
||||||
|
fContextSuppliers = getSuppliers(fContextObject);
|
||||||
|
return fContextSuppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSuppliers(IEnvironmentVariableSupplier suppliers[]){
|
||||||
|
fContextSuppliers = suppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getContext()
|
||||||
|
*/
|
||||||
|
public Object getContext(){
|
||||||
|
return fContextObject;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Environment Variable Supplier used to supply variables
|
||||||
|
* defined in eclipse environment
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class EclipseEnvironmentSupplier implements IEnvironmentVariableSupplier {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name, Object context) {
|
||||||
|
if(context == null){
|
||||||
|
String value = EnvironmentReader.getEnvVar(name);
|
||||||
|
if(value == null)
|
||||||
|
return null;
|
||||||
|
return new BuildEnvVar(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object context) {
|
||||||
|
if(context == null){
|
||||||
|
Properties values = EnvironmentReader.getEnvVars();
|
||||||
|
if(values == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable variables[] = new IBuildEnvironmentVariable[values.size()];
|
||||||
|
Enumeration en = values.propertyNames();
|
||||||
|
for( int i = 0; i < variables.length ; i++){
|
||||||
|
String name = (String)en.nextElement();
|
||||||
|
String value = values.getProperty(name);
|
||||||
|
variables[i] = new BuildEnvVar(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
return variables;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,114 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the "merging" functionality of environment variables
|
||||||
|
* Used by the EnvironmentVariableProvider to "merge" the sets of macros returned
|
||||||
|
* by different suppliers into one set returned to the user
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EnvVarCollector {
|
||||||
|
private Map fMap = null;
|
||||||
|
public EnvVarCollector(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds an array of environment variables to the set of variables held by this collector
|
||||||
|
* performing environment variable operations
|
||||||
|
* @param vars
|
||||||
|
*/
|
||||||
|
public void add(IBuildEnvironmentVariable vars[]){
|
||||||
|
if(vars == null)
|
||||||
|
return;
|
||||||
|
boolean isCaseInsensitive = !EnvironmentVariableProvider.getDefault().isVariableCaseSensitive();
|
||||||
|
for(int i = 0; i < vars.length; i ++) {
|
||||||
|
IBuildEnvironmentVariable var = vars[i];
|
||||||
|
String name = var.getName();
|
||||||
|
if(isCaseInsensitive)
|
||||||
|
name = name.toUpperCase();
|
||||||
|
|
||||||
|
boolean noCheck = false;
|
||||||
|
|
||||||
|
if(fMap == null){
|
||||||
|
noCheck = true;
|
||||||
|
fMap = new HashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(noCheck)
|
||||||
|
fMap.put(name,var);
|
||||||
|
else {
|
||||||
|
IBuildEnvironmentVariable prevVar = (IBuildEnvironmentVariable)fMap.remove(name);
|
||||||
|
fMap.put(name,EnvVarOperationProcessor.performOperation(prevVar,var));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of variables held by this collector
|
||||||
|
*
|
||||||
|
* @param includeRemoved true if removed variables should be included in the resulting array
|
||||||
|
* @return IBuildEnvironmentVariable[]
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] toArray(boolean includeRemoved){
|
||||||
|
if(fMap == null)
|
||||||
|
return new IBuildEnvironmentVariable[0];
|
||||||
|
Collection values = fMap.values();
|
||||||
|
List list = new ArrayList();
|
||||||
|
Iterator iter = values.iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
|
||||||
|
if(var != null &&
|
||||||
|
(includeRemoved || var.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE))
|
||||||
|
list.add(var);
|
||||||
|
}
|
||||||
|
return (IBuildEnvironmentVariable[])list.toArray(new IBuildEnvironmentVariable[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a variable of a given name held by this collector
|
||||||
|
*
|
||||||
|
* @param name a variable name
|
||||||
|
* @return IBuildEnvironmentVariable
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name){
|
||||||
|
if(fMap == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(!EnvironmentVariableProvider.getDefault().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
|
||||||
|
return (IBuildEnvironmentVariable)fMap.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of variables held by this collector
|
||||||
|
* The call to this method is equivalent of calling toArray(true)
|
||||||
|
*
|
||||||
|
* @return IBuildEnvironmentVariable[]
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(){
|
||||||
|
return toArray(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,251 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an utility class that implements environment variable operations
|
||||||
|
* functionality: append, prepend, replace and remove
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class EnvVarOperationProcessor {
|
||||||
|
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* performs the environment variable operation given an initial variable and
|
||||||
|
* a variable representing an operation to be performed
|
||||||
|
* Returns a new variable the represents the result of a performed operation
|
||||||
|
*
|
||||||
|
* @param initial the initial variable
|
||||||
|
* @param added the variable that specifies an operation to be performed on the
|
||||||
|
* initial variable value
|
||||||
|
* @return the new variable the represents the result of a performed operation
|
||||||
|
*/
|
||||||
|
static public IBuildEnvironmentVariable performOperation(IBuildEnvironmentVariable initial, IBuildEnvironmentVariable added){
|
||||||
|
if(initial == null){
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
if(added == null)
|
||||||
|
return initial;
|
||||||
|
|
||||||
|
String name = added.getName();
|
||||||
|
|
||||||
|
switch(added.getOperation()){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
return new BuildEnvVar(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:{
|
||||||
|
String delimiter = added.getDelimiter();
|
||||||
|
return new BuildEnvVar(name,
|
||||||
|
performAppend(initial.getValue(),added.getValue(),delimiter),
|
||||||
|
// IBuildEnvironmentVariable.ENVVAR_APPEND,
|
||||||
|
delimiter);
|
||||||
|
}
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:{
|
||||||
|
String delimiter = added.getDelimiter();
|
||||||
|
return new BuildEnvVar(name,
|
||||||
|
performPrepend(initial.getValue(),added.getValue(),delimiter),
|
||||||
|
// IBuildEnvironmentVariable.ENVVAR_PREPEND,
|
||||||
|
delimiter);
|
||||||
|
}
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
return new BuildEnvVar(added.getName(),added.getValue(),added.getDelimiter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* performs append or prepend given an initial String, a string to be appended/prepended and a delimiter
|
||||||
|
* Returns a String representing the result of the operation
|
||||||
|
* @param initialValue
|
||||||
|
* @param addValue
|
||||||
|
* @param delimiter
|
||||||
|
* @param prepend
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
static public String performAppendPrepend(String initialValue, String addValue, String delimiter, boolean prepend){
|
||||||
|
if(initialValue == null)
|
||||||
|
return addValue;
|
||||||
|
if(addValue == null)
|
||||||
|
return initialValue;
|
||||||
|
|
||||||
|
if(delimiter == null || "".equals(delimiter)){ //$NON-NLS-1$
|
||||||
|
return prepend ? addValue + initialValue : initialValue + addValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
List value = convertToList(initialValue, delimiter);
|
||||||
|
List added = convertToList(addValue, delimiter);
|
||||||
|
|
||||||
|
value = removeDuplicates(value, added);
|
||||||
|
|
||||||
|
if(prepend)
|
||||||
|
value.addAll(0,added);
|
||||||
|
else
|
||||||
|
value.addAll(added);
|
||||||
|
|
||||||
|
return convertToString(value, delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* performs append given an initial String, a string to be appended and a delimiter
|
||||||
|
* Returns a String representing the result of the operation
|
||||||
|
* @param initialValue
|
||||||
|
* @param addValue
|
||||||
|
* @param delimiter
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
static public String performAppend(String initialValue, String addValue, String delimiter){
|
||||||
|
return performAppendPrepend(initialValue,addValue,delimiter,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* performs prepend given an initial String, a string to be prepended and a delimiter
|
||||||
|
* Returns a String representing the result of the operation
|
||||||
|
* @param initialValue
|
||||||
|
* @param addValue
|
||||||
|
* @param delimiter
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
static public String performPrepend(String initialValue, String addValue, String delimiter){
|
||||||
|
return performAppendPrepend(initialValue,addValue,delimiter,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* performs an environment variable operation
|
||||||
|
* Returns String representing the result of the operation
|
||||||
|
* @param initialValue
|
||||||
|
* @param newValue
|
||||||
|
* @param delimiter
|
||||||
|
* @param op
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
static public String performOperation(String initialValue, String newValue, String delimiter, int op){
|
||||||
|
switch(op){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
return null;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
return performPrepend(initialValue,newValue,delimiter);
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
return performAppend(initialValue,newValue,delimiter);
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
return initialValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a given value to string using a delimiter passed to this method
|
||||||
|
* @param value
|
||||||
|
* @param delimiter
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static public List convertToList(String value, String delimiter){
|
||||||
|
List list = new ArrayList();
|
||||||
|
int delLength = delimiter.length();
|
||||||
|
int valLength = value.length();
|
||||||
|
|
||||||
|
if(delLength == 0){
|
||||||
|
list.add(value);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
int start = 0;
|
||||||
|
int stop;
|
||||||
|
while(start < valLength){
|
||||||
|
stop = value.indexOf(delimiter,start);
|
||||||
|
if(stop == -1)
|
||||||
|
stop = valLength;
|
||||||
|
String subst = value.substring(start,stop);
|
||||||
|
list.add(subst);
|
||||||
|
start = stop + delLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* removes duplicates
|
||||||
|
*/
|
||||||
|
static public List removeDuplicates(List value, List duplicates){
|
||||||
|
List list = new ArrayList();
|
||||||
|
Iterator valueIter = value.iterator();
|
||||||
|
while(valueIter.hasNext()){
|
||||||
|
String curVal = (String)valueIter.next();
|
||||||
|
boolean duplFound = false;
|
||||||
|
Iterator duplicatesIter = duplicates.iterator();
|
||||||
|
while(duplicatesIter.hasNext()){
|
||||||
|
String curDupl = (String)duplicatesIter.next();
|
||||||
|
if(curVal.equals(curDupl)){
|
||||||
|
duplFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!duplFound)
|
||||||
|
list.add(curVal);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts list to a single String using a given delimiter to separate
|
||||||
|
* the list value in the resulting String
|
||||||
|
* @param list
|
||||||
|
* @param delimiter
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
static public String convertToString(List list, String delimiter){
|
||||||
|
Iterator iter = list.iterator();
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
while(iter.hasNext()){
|
||||||
|
buffer.append((String)iter.next());
|
||||||
|
|
||||||
|
if(iter.hasNext())
|
||||||
|
buffer.append(delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* concatenetes two Strings
|
||||||
|
* Returns a resulting string
|
||||||
|
*/
|
||||||
|
static private String concatenateStrings(String str1, String str2, String delimiter){
|
||||||
|
if(str1 == null || "".equals(str1)) //$NON-NLS-1$
|
||||||
|
return str2;
|
||||||
|
if(str2 == null || "".equals(str2)) //$NON-NLS-1$
|
||||||
|
return str1;
|
||||||
|
|
||||||
|
return str1 + delimiter + str2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* normalizes the variable name. That is: removes prepended and appended spaces
|
||||||
|
* and converts the name to upper-case for Win32 systems
|
||||||
|
* @return the normalized name or <code>null</code> in case the name is not valid
|
||||||
|
*/
|
||||||
|
static public String normalizeName(String name){
|
||||||
|
if(name == null)
|
||||||
|
return null;
|
||||||
|
if("".equals(name = name.trim())) //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,513 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentBuildPathsChangeListener;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the IEnvironmentVariableProvider interface and provides all
|
||||||
|
* build environment funvtionality to the MBS
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EnvironmentVariableProvider implements
|
||||||
|
IEnvironmentVariableProvider {
|
||||||
|
private static final QualifiedName fBuildPathVarProperty = new QualifiedName(ManagedBuilderCorePlugin.getUniqueIdentifier(), "buildPathVar"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String DELIMITER_WIN32 = ";"; //$NON-NLS-1$
|
||||||
|
private static final String DELIMITER_UNIX = ":"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static EnvironmentVariableProvider fInstance = null;
|
||||||
|
private List fListeners = null;
|
||||||
|
|
||||||
|
private StoredBuildPathEnvironmentContainer fIncludeStoredBuildPathVariables;
|
||||||
|
private StoredBuildPathEnvironmentContainer fLibraryStoredBuildPathVariables;
|
||||||
|
|
||||||
|
public static final UserDefinedEnvironmentSupplier fUserSupplier = new UserDefinedEnvironmentSupplier();
|
||||||
|
public static final ExternalExtensionEnvironmentSupplier fExternalSupplier = new ExternalExtensionEnvironmentSupplier();
|
||||||
|
public static final MbsEnvironmentSupplier fMbsSupplier = new MbsEnvironmentSupplier();
|
||||||
|
public static final EclipseEnvironmentSupplier fEclipseSupplier = new EclipseEnvironmentSupplier();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used by the EnvironmentVariableProvider to calculate the build paths
|
||||||
|
* in case a tool-integrator did not provide the special logic for obtaining the build
|
||||||
|
* paths from environment variable values
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static public class DefaultBuildPathResolver implements IBuildPathResolver {
|
||||||
|
private String fDelimiter;
|
||||||
|
|
||||||
|
public DefaultBuildPathResolver(String delimiter){
|
||||||
|
fDelimiter = delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] resolveBuildPaths(int pathType, String variableName,
|
||||||
|
String variableValue, IConfiguration configuration) {
|
||||||
|
|
||||||
|
if(fDelimiter == null || "".equals(fDelimiter)) //$NON-NLS-1$
|
||||||
|
return new String[]{variableValue};
|
||||||
|
|
||||||
|
List list = EnvVarOperationProcessor.convertToList(variableValue,fDelimiter);
|
||||||
|
return (String[]) list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
EnvironmentVariableProvider(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnvironmentVariableProvider getDefault(){
|
||||||
|
if(fInstance == null)
|
||||||
|
fInstance = new EnvironmentVariableProvider();
|
||||||
|
return fInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns a variable of a given name or null
|
||||||
|
* the context information is taken from the contextInfo passed
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
|
IContextInfo contextInfo, boolean includeParentLevels){
|
||||||
|
|
||||||
|
if(contextInfo == null)
|
||||||
|
return null;
|
||||||
|
if(variableName == null || "".equals(variableName = variableName.trim())) //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
|
||||||
|
|
||||||
|
IContextInfo infos[] = getAllContextInfos(contextInfo);
|
||||||
|
variableName = adjustName(variableName);
|
||||||
|
|
||||||
|
if(!includeParentLevels){
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||||
|
boolean bVarFound = false;
|
||||||
|
for(int i = 0; i < suppliers.length; i++){
|
||||||
|
if(suppliers[i].getVariable(variableName,infos[0].getContext()) != null){
|
||||||
|
bVarFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!bVarFound)
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable variable = null;
|
||||||
|
|
||||||
|
for(int i = infos.length-1 ; i >=0 ; i-- ) {
|
||||||
|
IContextInfo info = infos[i];
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
|
||||||
|
|
||||||
|
for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
|
||||||
|
IEnvironmentVariableSupplier supplier = suppliers[j];
|
||||||
|
IBuildEnvironmentVariable var = supplier.getVariable(variableName,info.getContext());
|
||||||
|
|
||||||
|
if(var == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(variable == null)
|
||||||
|
variable = var;
|
||||||
|
else
|
||||||
|
variable = EnvVarOperationProcessor.performOperation(variable,var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(variable != null && variable.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
|
variable = null;
|
||||||
|
return variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
|
Object level, boolean includeParentLevels) {
|
||||||
|
|
||||||
|
if(variableName == null || "".equals(variableName)) //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable var = getVariable(variableName,getContextInfo(level),includeParentLevels);
|
||||||
|
if(level instanceof IConfiguration)
|
||||||
|
checkBuildPathVariable((IConfiguration)level,variableName,var);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String adjustName(String name){
|
||||||
|
if(!isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the context info that should be used for the given level
|
||||||
|
* or null if the the given level is not supported
|
||||||
|
*/
|
||||||
|
protected IContextInfo getContextInfo(Object level){
|
||||||
|
DefaultContextInfo info = new DefaultContextInfo(level);
|
||||||
|
if(info.getSuppliers() == null)
|
||||||
|
return null;
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns a list of defined variables.
|
||||||
|
* the context information is taken from the contextInfo passed
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo
|
||||||
|
*/
|
||||||
|
public EnvVarCollector getVariables(IContextInfo contextInfo,
|
||||||
|
boolean includeParentLevels) {
|
||||||
|
if(contextInfo == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
IContextInfo infos[] = getAllContextInfos(contextInfo);
|
||||||
|
HashSet set = null;
|
||||||
|
|
||||||
|
if(!includeParentLevels){
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = infos[0].getSuppliers();
|
||||||
|
set = new HashSet();
|
||||||
|
for(int i = 0; i < suppliers.length; i++){
|
||||||
|
IBuildEnvironmentVariable vars[] = suppliers[i].getVariables(infos[0].getContext());
|
||||||
|
if(vars != null){
|
||||||
|
for(int j = 0; j < vars.length; j++){
|
||||||
|
set.add(
|
||||||
|
adjustName(vars[j].
|
||||||
|
getName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(set.size() == 0)
|
||||||
|
return new EnvVarCollector();
|
||||||
|
}
|
||||||
|
|
||||||
|
EnvVarCollector envVarSet = new EnvVarCollector();
|
||||||
|
|
||||||
|
for(int i = infos.length-1 ; i >=0 ; i-- ) {
|
||||||
|
IContextInfo info = infos[i];
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
|
||||||
|
|
||||||
|
for(int j = suppliers.length-1 ; j >= 0 ; j-- ) {
|
||||||
|
IEnvironmentVariableSupplier supplier = suppliers[j];
|
||||||
|
IBuildEnvironmentVariable vars[] = null;
|
||||||
|
if(set != null){
|
||||||
|
List varList = new ArrayList();
|
||||||
|
Iterator iter = set.iterator();
|
||||||
|
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildEnvironmentVariable var = supplier.getVariable((String)iter.next(),info.getContext());
|
||||||
|
if(var != null)
|
||||||
|
varList.add(var);
|
||||||
|
}
|
||||||
|
vars = (IBuildEnvironmentVariable[])varList.toArray(new IBuildEnvironmentVariable[varList.size()]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
vars = supplier.getVariables(info.getContext());
|
||||||
|
}
|
||||||
|
envVarSet.add(vars);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return envVarSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariables()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object level,
|
||||||
|
boolean includeParentLevels) {
|
||||||
|
|
||||||
|
EnvVarCollector varSet = getVariables(getContextInfo(level),includeParentLevels);
|
||||||
|
|
||||||
|
if(level instanceof IConfiguration)
|
||||||
|
checkBuildPathVariables((IConfiguration)level,varSet);
|
||||||
|
|
||||||
|
if(varSet != null)
|
||||||
|
return varSet.toArray(false);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns an array of the IContextInfo that holds the context informations
|
||||||
|
* starting from the one passed to this method and including all subsequent parents
|
||||||
|
*/
|
||||||
|
private IContextInfo[] getAllContextInfos(IContextInfo contextInfo){
|
||||||
|
if(contextInfo == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
|
||||||
|
list.add(contextInfo);
|
||||||
|
|
||||||
|
while((contextInfo = contextInfo.getNext()) != null)
|
||||||
|
list.add(contextInfo);
|
||||||
|
|
||||||
|
return (IContextInfo[])list.toArray(new IContextInfo[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isWin32(){
|
||||||
|
String os = System.getProperty("os.name").toLowerCase(); //$NON-NLS-1$
|
||||||
|
if (os.startsWith("windows ")) //$NON-NLS-1$
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getDefaultDelimiter()
|
||||||
|
*/
|
||||||
|
public String getDefaultDelimiter() {
|
||||||
|
return isWin32() ? DELIMITER_WIN32 : DELIMITER_UNIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#isVariableCaseSensitive()
|
||||||
|
*/
|
||||||
|
public boolean isVariableCaseSensitive() {
|
||||||
|
return !isWin32();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getSuppliers()
|
||||||
|
*/
|
||||||
|
public IEnvironmentVariableSupplier[] getSuppliers(Object level) {
|
||||||
|
IContextInfo info = getContextInfo(level);
|
||||||
|
if(info != null)
|
||||||
|
return info.getSuppliers();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getBuildPaths()
|
||||||
|
*/
|
||||||
|
public String[] getBuildPaths(IConfiguration configuration,
|
||||||
|
int buildPathType) {
|
||||||
|
ITool tools[] = configuration.getFilteredTools();
|
||||||
|
List list = new ArrayList();
|
||||||
|
|
||||||
|
for(int i = 0; i < tools.length; i++){
|
||||||
|
IEnvVarBuildPath pathDescriptors[] = tools[i].getEnvVarBuildPaths();
|
||||||
|
|
||||||
|
if(pathDescriptors == null || pathDescriptors.length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for(int j = 0; j < pathDescriptors.length; j++){
|
||||||
|
IEnvVarBuildPath curPathDes = pathDescriptors[j];
|
||||||
|
if(curPathDes.getType() != buildPathType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String vars[] = curPathDes.getVariableNames();
|
||||||
|
if(vars == null || vars.length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
IBuildPathResolver pathResolver = curPathDes.getBuildPathResolver();
|
||||||
|
if(pathResolver == null){
|
||||||
|
String delimiter = curPathDes.getPathDelimiter();
|
||||||
|
if(delimiter == null)
|
||||||
|
delimiter = getDefaultDelimiter();
|
||||||
|
pathResolver = new DefaultBuildPathResolver(delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int k = 0; k < vars.length; k++){
|
||||||
|
String varName = vars[k];
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable var = getVariable(varName,configuration,true);
|
||||||
|
if(var == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String varValue = var.getValue();
|
||||||
|
String paths[] = pathResolver.resolveBuildPaths(buildPathType,varName,varValue,configuration);
|
||||||
|
if(paths != null && paths.length != 0)
|
||||||
|
list.addAll(Arrays.asList(paths));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String[])list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns a list of registered listeners
|
||||||
|
*/
|
||||||
|
private List getListeners(){
|
||||||
|
if(fListeners == null)
|
||||||
|
fListeners = new ArrayList();
|
||||||
|
return fListeners;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* notifies registered listeners
|
||||||
|
*/
|
||||||
|
private void notifyListeners(IConfiguration configuration, int buildPathType){
|
||||||
|
List listeners = getListeners();
|
||||||
|
Iterator iterator = listeners.iterator();
|
||||||
|
while(iterator.hasNext())
|
||||||
|
((IEnvironmentBuildPathsChangeListener)iterator.next()).buildPathsChanged(configuration,buildPathType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#subscribe()
|
||||||
|
*/
|
||||||
|
public synchronized void subscribe(IEnvironmentBuildPathsChangeListener listener) {
|
||||||
|
if(listener == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List listeners = getListeners();
|
||||||
|
|
||||||
|
if(!listeners.contains(listener))
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#unsubscribe()
|
||||||
|
*/
|
||||||
|
public synchronized void unsubscribe(IEnvironmentBuildPathsChangeListener listener) {
|
||||||
|
if(listener == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List listeners = getListeners();
|
||||||
|
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns true if the first passed contextInfo is the child of the second one
|
||||||
|
*/
|
||||||
|
public boolean checkParentContextRelation(IContextInfo child, IContextInfo parent){
|
||||||
|
if(child == null || parent == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
IContextInfo enumInfo = child;
|
||||||
|
do{
|
||||||
|
if(parent.getContext() == enumInfo.getContext())
|
||||||
|
return true;
|
||||||
|
}while((enumInfo = enumInfo.getNext()) != null);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* performs a check of the build path variables for the given configuration
|
||||||
|
* If the build variables are changed, the notification is sent
|
||||||
|
*/
|
||||||
|
public void checkBuildPathVariables(IConfiguration configuration){
|
||||||
|
checkBuildPathVariables(configuration,getVariables(getContextInfo(configuration),true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* performs a check of the build path variables of the specified type
|
||||||
|
* for the given configuration
|
||||||
|
* If the build variables are changed, the notification is sent
|
||||||
|
*/
|
||||||
|
public void checkBuildPathVariables(IConfiguration configuration,int buildPathType){
|
||||||
|
checkBuildPathVariables(configuration,buildPathType,getVariables(getContextInfo(configuration),true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* performs a check of the build path variables
|
||||||
|
* for the given configuration given the set of the variables
|
||||||
|
* defined for this configuration
|
||||||
|
* If the build variables are changed, the notification is sent
|
||||||
|
*/
|
||||||
|
protected void checkBuildPathVariables(IConfiguration configuration, EnvVarCollector varSet){
|
||||||
|
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_INCLUDE,varSet);
|
||||||
|
checkBuildPathVariables(configuration,IEnvVarBuildPath.BUILDPATH_LIBRARY,varSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* performs a check of whether the given variable is the build path variable
|
||||||
|
* and if true checks whether it is changed.
|
||||||
|
* In the case of it is changed all other build path variables are checked
|
||||||
|
* and notification is sent.
|
||||||
|
* If it is not changed, other build path variables are not checked
|
||||||
|
* In the case of the given variable is not the build path one, this method does nothing
|
||||||
|
*/
|
||||||
|
protected void checkBuildPathVariable(IConfiguration configuration, String varName, IBuildEnvironmentVariable var){
|
||||||
|
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_INCLUDE, varName, var);
|
||||||
|
checkBuildPathVariable(configuration, IEnvVarBuildPath.BUILDPATH_LIBRARY, varName, var);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* performs a check of whether the given variable is the build path variable
|
||||||
|
* of the specified type and if true checks whether it is changed.
|
||||||
|
* In the case of it is changed all other build path variables of that type are checked
|
||||||
|
* and notification is sent.
|
||||||
|
* If it is not changed, other build path variables are not checked
|
||||||
|
* In the case of the given variable is not the build path one, this method does nothing
|
||||||
|
*/
|
||||||
|
protected void checkBuildPathVariable(IConfiguration configuration, int buildPathType, String varName, IBuildEnvironmentVariable var){
|
||||||
|
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||||
|
if(buildPathVars == null)
|
||||||
|
return;
|
||||||
|
if(buildPathVars.isVariableChanged(varName,var,configuration)){
|
||||||
|
buildPathVars.synchronize(getVariables(getContextInfo(configuration),true),configuration);
|
||||||
|
notifyListeners(configuration, buildPathType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* performs a check of the build path variables of the specified type
|
||||||
|
* for the given configuration given the set of the variables
|
||||||
|
* defined for this configuration.
|
||||||
|
* If the build variables are changed, the notification is sent
|
||||||
|
*/
|
||||||
|
protected void checkBuildPathVariables(IConfiguration configuration, int buildPathType, EnvVarCollector varSet){
|
||||||
|
StoredBuildPathEnvironmentContainer buildPathVars = getStoredBuildPathVariables(buildPathType);
|
||||||
|
if(buildPathVars == null)
|
||||||
|
return;
|
||||||
|
if(buildPathVars.checkBuildPathChange(varSet,configuration)){
|
||||||
|
notifyListeners(configuration, buildPathType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the container of the build variables of the specified type
|
||||||
|
*/
|
||||||
|
protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
|
||||||
|
return buildPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
||||||
|
getStoredLibraryBuildPathVariables() :
|
||||||
|
getStoredIncludeBuildPathVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the container of the Include path variables
|
||||||
|
*/
|
||||||
|
protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
|
||||||
|
if(fIncludeStoredBuildPathVariables == null)
|
||||||
|
fIncludeStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_INCLUDE);
|
||||||
|
return fIncludeStoredBuildPathVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the container of the Library path variables
|
||||||
|
*/
|
||||||
|
protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
|
||||||
|
if(fLibraryStoredBuildPathVariables == null)
|
||||||
|
fLibraryStoredBuildPathVariables = new StoredBuildPathEnvironmentContainer(IEnvVarBuildPath.BUILDPATH_LIBRARY);
|
||||||
|
return fLibraryStoredBuildPathVariables;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,230 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Environment Variable Supplier used to supply variables
|
||||||
|
* defined by the tool-integrator
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class ExternalExtensionEnvironmentSupplier implements
|
||||||
|
IEnvironmentVariableSupplier {
|
||||||
|
private static final String fNonOverloadableVariables[] = new String[]{
|
||||||
|
//tool-integrators not allowed currently to override the "CWD" and "PWD" variables
|
||||||
|
EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
|
||||||
|
EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EnvironmentVariableProvider passed to the tool-integrator provided
|
||||||
|
* suppliers.
|
||||||
|
* Accepts only contexts lower than the one passed to a suppler
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
private class ExtensionEnvVarProvider extends EnvironmentVariableProvider{
|
||||||
|
private IContextInfo fStartInfo;
|
||||||
|
private Object fStartLevel;
|
||||||
|
private boolean fStartInitialized;
|
||||||
|
|
||||||
|
public ExtensionEnvVarProvider(Object level){
|
||||||
|
fStartLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider#getVariable(java.lang.String, java.lang.Object, boolean)
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
|
Object level, boolean includeParentLevels) {
|
||||||
|
if(getValidName(variableName) == null)
|
||||||
|
return null;
|
||||||
|
return super.getVariable(variableName,level,includeParentLevels);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object level, boolean includeParentLevels) {
|
||||||
|
return filterVariables(super.getVariables(level,includeParentLevels));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getContextInfo(java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected IContextInfo getContextInfo(Object level){
|
||||||
|
IContextInfo startInfo = getStartInfo();
|
||||||
|
if(level == fStartLevel)
|
||||||
|
return startInfo;
|
||||||
|
|
||||||
|
IContextInfo info = super.getContextInfo(level);
|
||||||
|
if(info == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(checkParentContextRelation(startInfo,info))
|
||||||
|
return info;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IContextInfo getStartInfo(){
|
||||||
|
if(fStartInfo == null && !fStartInitialized){
|
||||||
|
IContextInfo info = super.getContextInfo(fStartLevel);
|
||||||
|
if(info != null){
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = info.getSuppliers();
|
||||||
|
suppliers = filterValidSuppliers(suppliers);
|
||||||
|
if(suppliers != null)
|
||||||
|
fStartInfo = new DefaultContextInfo(fStartLevel,suppliers);
|
||||||
|
else
|
||||||
|
fStartInfo = info.getNext();
|
||||||
|
fStartInitialized = true;
|
||||||
|
}
|
||||||
|
fStartInitialized = true;
|
||||||
|
}
|
||||||
|
return fStartInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredBuildPathVariables(int)
|
||||||
|
*/
|
||||||
|
protected StoredBuildPathEnvironmentContainer getStoredBuildPathVariables(int buildPathType){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredIncludeBuildPathVariables()
|
||||||
|
*/
|
||||||
|
protected StoredBuildPathEnvironmentContainer getStoredIncludeBuildPathVariables(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider#getStoredLibraryBuildPathVariables()
|
||||||
|
*/
|
||||||
|
protected StoredBuildPathEnvironmentContainer getStoredLibraryBuildPathVariables(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name, Object context) {
|
||||||
|
if(context == null)
|
||||||
|
return null;
|
||||||
|
if((name = getValidName(name)) == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
else if(context instanceof IConfiguration){
|
||||||
|
IConfiguration cfg = (IConfiguration)context;
|
||||||
|
IConfigurationEnvironmentVariableSupplier supplier = cfg.getEnvironmentVariableSupplier();
|
||||||
|
if(supplier == null)
|
||||||
|
return null;
|
||||||
|
return supplier.getVariable(name,cfg,new ExtensionEnvVarProvider(context));
|
||||||
|
}
|
||||||
|
else if (context instanceof IManagedProject) {
|
||||||
|
IManagedProject project = (IManagedProject)context;
|
||||||
|
IProjectEnvironmentVariableSupplier supplier = project.getProjectType().getEnvironmentVariableSupplier();
|
||||||
|
if(supplier == null)
|
||||||
|
return null;
|
||||||
|
return supplier.getVariable(name,project,new ExtensionEnvVarProvider(context));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object context) {
|
||||||
|
if(context == null)
|
||||||
|
return null;
|
||||||
|
IBuildEnvironmentVariable variables[] = null;
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
IConfiguration cfg = (IConfiguration)context;
|
||||||
|
IConfigurationEnvironmentVariableSupplier supplier = cfg.getEnvironmentVariableSupplier();
|
||||||
|
if(supplier == null)
|
||||||
|
return null;
|
||||||
|
variables = supplier.getVariables(cfg,new ExtensionEnvVarProvider(context));
|
||||||
|
}
|
||||||
|
else if (context instanceof IManagedProject) {
|
||||||
|
IManagedProject project = (IManagedProject)context;
|
||||||
|
IProjectEnvironmentVariableSupplier supplier = project.getProjectType().getEnvironmentVariableSupplier();
|
||||||
|
if(supplier == null)
|
||||||
|
return null;
|
||||||
|
variables = supplier.getVariables(project,new ExtensionEnvVarProvider(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
return filterVariables(variables);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IEnvironmentVariableSupplier[] filterValidSuppliers(IEnvironmentVariableSupplier suppliers[]){
|
||||||
|
if(suppliers == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int i = 0, j = 0;
|
||||||
|
for(i = 0; i < suppliers.length; i++){
|
||||||
|
if(suppliers[i] == this)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(i >= suppliers.length)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
int startNum = i + 1;
|
||||||
|
|
||||||
|
|
||||||
|
IEnvironmentVariableSupplier validSuppliers[] =
|
||||||
|
new IEnvironmentVariableSupplier[suppliers.length - startNum];
|
||||||
|
|
||||||
|
for(i = startNum, j = 0; i < suppliers.length; i++, j++)
|
||||||
|
validSuppliers[j] = suppliers[i];
|
||||||
|
|
||||||
|
return validSuppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getValidName(String name){
|
||||||
|
name = EnvVarOperationProcessor.normalizeName(name);
|
||||||
|
if(name == null)
|
||||||
|
return null;
|
||||||
|
if(fNonOverloadableVariables != null){
|
||||||
|
for(int i = 0; i < fNonOverloadableVariables.length; i++){
|
||||||
|
if(name.equals(fNonOverloadableVariables[i]))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
|
||||||
|
if(variables == null || variables.length == 0)
|
||||||
|
return variables;
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable filtered[] = new IBuildEnvironmentVariable[variables.length];
|
||||||
|
int filteredNum = 0;
|
||||||
|
for(int i = 0; i < variables.length; i++){
|
||||||
|
if(getValidName(variables[i].getName()) != null)
|
||||||
|
filtered[filteredNum++] = variables[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filteredNum != filtered.length){
|
||||||
|
IBuildEnvironmentVariable vars[] = new IBuildEnvironmentVariable[filteredNum];
|
||||||
|
for(int i = 0; i < filteredNum; i++)
|
||||||
|
vars[i] = filtered[i];
|
||||||
|
filtered = vars;
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is used by the Environment Variable Provider to
|
||||||
|
* represent the given context(level) information
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public interface IContextInfo {
|
||||||
|
/**
|
||||||
|
* Returns the next lower-precedence context
|
||||||
|
*
|
||||||
|
* @return IContextInfo
|
||||||
|
*/
|
||||||
|
public IContextInfo getNext();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the array of suppliers to be used for this context
|
||||||
|
*
|
||||||
|
* @return IEnvironmentVariableSupplier[]
|
||||||
|
*/
|
||||||
|
public IEnvironmentVariableSupplier[] getSuppliers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current context
|
||||||
|
*
|
||||||
|
* @return Object
|
||||||
|
*/
|
||||||
|
public Object getContext();
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Environment Variable Supplier used to supply variables
|
||||||
|
* defined by the MBS
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class MbsEnvironmentSupplier implements IEnvironmentVariableSupplier {
|
||||||
|
private static final String fVariableNames[] = new String[]{
|
||||||
|
"CWD", //$NON-NLS-1$
|
||||||
|
"PWD" //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name, Object context) {
|
||||||
|
if(context instanceof IConfiguration)
|
||||||
|
return getConfigurationVariable(name,(IConfiguration)context);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable getConfigurationVariable(String name, IConfiguration configuration) {
|
||||||
|
IBuildEnvironmentVariable variable = null;
|
||||||
|
if("CWD".equals(name) || "PWD".equals(name)){ //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
IResource owner = configuration.getOwner();
|
||||||
|
if(owner != null){
|
||||||
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(owner);
|
||||||
|
if(info != null && configuration.equals(info.getDefaultConfiguration())){
|
||||||
|
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(configuration);
|
||||||
|
generator.initialize((IProject)owner,info,null);
|
||||||
|
|
||||||
|
IPath topBuildDir = generator.getBuildWorkingDir();
|
||||||
|
if(topBuildDir == null)
|
||||||
|
topBuildDir = new Path(info.getConfigurationName());
|
||||||
|
|
||||||
|
IPath projectLocation = owner.getLocation();
|
||||||
|
IPath workingDirectory = projectLocation.append(topBuildDir);
|
||||||
|
String value = workingDirectory.toOSString();
|
||||||
|
variable = new BuildEnvVar(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return variable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object context) {
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
List variables = new ArrayList(fVariableNames.length);
|
||||||
|
for(int i = 0; i < fVariableNames.length; i++){
|
||||||
|
IBuildEnvironmentVariable var = getConfigurationVariable(fVariableNames[i],(IConfiguration)context);
|
||||||
|
if(var != null)
|
||||||
|
variables.add(var);
|
||||||
|
}
|
||||||
|
if(variables.size() == 0)
|
||||||
|
return null;
|
||||||
|
return (IBuildEnvironmentVariable[])variables.toArray(new IBuildEnvironmentVariable[variables.size()]);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the Environment variable that could be loaded
|
||||||
|
* and stored in XML
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StorableEnvVar extends BuildEnvVar {
|
||||||
|
public static final String VARIABLE_ELEMENT_NAME = "variable"; //$NON-NLS-1$
|
||||||
|
public static final String NAME = "name"; //$NON-NLS-1$
|
||||||
|
public static final String VALUE = "value"; //$NON-NLS-1$
|
||||||
|
public static final String OPERATION = "operation"; //$NON-NLS-1$
|
||||||
|
public static final String DELIMITER = "delimiter"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public static final String REPLACE = "replace"; //$NON-NLS-1$
|
||||||
|
public static final String REMOVE = "remove"; //$NON-NLS-1$
|
||||||
|
public static final String APPEND = "append"; //$NON-NLS-1$
|
||||||
|
public static final String PREPEND = "prepend"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
public StorableEnvVar(String name, String value, int op, String delimiter){
|
||||||
|
super(name,value,op,delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorableEnvVar(String name){
|
||||||
|
this(name,null,ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorableEnvVar(String name, String value){
|
||||||
|
this(name,value,ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorableEnvVar(String name, String value, String delimiter){
|
||||||
|
this(name,value,ENVVAR_REPLACE,delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorableEnvVar(Element element){
|
||||||
|
load(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load(Element element){
|
||||||
|
fName = element.getAttribute(NAME);
|
||||||
|
|
||||||
|
fValue = element.getAttribute(VALUE);
|
||||||
|
|
||||||
|
fOperation = opStringToInt(element.getAttribute(OPERATION));
|
||||||
|
|
||||||
|
fDelimiter = element.getAttribute(DELIMITER);
|
||||||
|
if("".equals(fDelimiter))
|
||||||
|
fDelimiter = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int opStringToInt(String op){
|
||||||
|
int operation;
|
||||||
|
|
||||||
|
if(REMOVE.equals(op))
|
||||||
|
operation = ENVVAR_REMOVE;
|
||||||
|
else if(APPEND.equals(op))
|
||||||
|
operation = ENVVAR_APPEND;
|
||||||
|
else if(PREPEND.equals(op))
|
||||||
|
operation = ENVVAR_PREPEND;
|
||||||
|
else
|
||||||
|
operation = ENVVAR_REPLACE;
|
||||||
|
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String opIntToString(int op){
|
||||||
|
String operation;
|
||||||
|
|
||||||
|
if(ENVVAR_REMOVE == op)
|
||||||
|
operation = REMOVE;
|
||||||
|
else if(ENVVAR_APPEND == op)
|
||||||
|
operation = APPEND;
|
||||||
|
else if(ENVVAR_PREPEND == op)
|
||||||
|
operation = PREPEND;
|
||||||
|
else
|
||||||
|
operation = REPLACE;
|
||||||
|
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(Document doc, Element element){
|
||||||
|
if(fName != null)
|
||||||
|
element.setAttribute(NAME,fName);
|
||||||
|
|
||||||
|
if(fValue != null)
|
||||||
|
element.setAttribute(VALUE,fValue);
|
||||||
|
|
||||||
|
element.setAttribute(OPERATION,opIntToString(fOperation));
|
||||||
|
|
||||||
|
if(fDelimiter != null)
|
||||||
|
element.setAttribute(DELIMITER,fDelimiter);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,195 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the set of environment variables that could be loaded
|
||||||
|
* and stored in XML
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/public class StorableEnvironment {
|
||||||
|
public static final String ENVIRONMENT_ELEMENT_NAME = "environment"; //$NON-NLS-1$
|
||||||
|
private Map fVariables;
|
||||||
|
private boolean fIsDirty = false;
|
||||||
|
private boolean fIsChanged = false;
|
||||||
|
|
||||||
|
private Map getMap(){
|
||||||
|
if(fVariables == null)
|
||||||
|
fVariables = new HashMap();
|
||||||
|
return fVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorableEnvironment() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public StorableEnvironment(Element element) {
|
||||||
|
load(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load(Element element){
|
||||||
|
NodeList nodeList = element.getChildNodes();
|
||||||
|
for (int i = 0; i < nodeList.getLength(); ++i) {
|
||||||
|
Node node = nodeList.item(i);
|
||||||
|
if (node.getNodeName().equals(StorableEnvVar.VARIABLE_ELEMENT_NAME)) {
|
||||||
|
addVariable(new StorableEnvVar((Element)node));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fIsDirty = false;
|
||||||
|
fIsChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(Document doc, Element element){
|
||||||
|
if(fVariables != null){
|
||||||
|
Iterator iter = fVariables.values().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
StorableEnvVar var = (StorableEnvVar)iter.next();
|
||||||
|
Element varEl = doc.createElement(StorableEnvVar.VARIABLE_ELEMENT_NAME);
|
||||||
|
element.appendChild(varEl);
|
||||||
|
var.serialize(doc,varEl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fIsDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addVariable(IBuildEnvironmentVariable var){
|
||||||
|
String name = var.getName();
|
||||||
|
if(name == null)
|
||||||
|
return;
|
||||||
|
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
|
if(!provider.isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
|
||||||
|
getMap().put(name,var);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable createVariable(String name, String value, int op, String delimiter){
|
||||||
|
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
|
||||||
|
StorableEnvVar var = new StorableEnvVar(name, value, op, delimiter);
|
||||||
|
addVariable(var);
|
||||||
|
fIsDirty = true;
|
||||||
|
fIsChanged = true;
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable createVariable(String name){
|
||||||
|
return createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable createVariable(String name, String value){
|
||||||
|
return createVariable(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable createVariable(String name, String value, String delimiter){
|
||||||
|
return createVariable(name,value,IBuildEnvironmentVariable.ENVVAR_REPLACE,delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the "dirty" state of the environment.
|
||||||
|
* If the dirty state is <code>true</code>, that means that the environment
|
||||||
|
* is out of synch with the repository and the environment needs to be serialized.
|
||||||
|
* <br><br>
|
||||||
|
* The dirty state is automatically set to <code>false</code> when the environment is serialized
|
||||||
|
* by calling the serialize() method
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean isDirty(){
|
||||||
|
return fIsDirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the "dirty" state of the environment
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment#isDirty()
|
||||||
|
* @param dirty represents the new state
|
||||||
|
*/
|
||||||
|
public void setDirty(boolean dirty){
|
||||||
|
fIsDirty = dirty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the "change" state of the environment.
|
||||||
|
* The "change" state represents whether the environment was changed or not.
|
||||||
|
* This state is not reset when the serialize() method is called
|
||||||
|
* Users can use this state to monitor whether the environment was changed or not.
|
||||||
|
* This state can be reset to <code>false</code> only by calling the setChanged(false) method
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean isChanged(){
|
||||||
|
return fIsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the "change" state of the environment
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment#isChanged()
|
||||||
|
* @param changed represents the new "change" state
|
||||||
|
*/
|
||||||
|
public void setChanged(boolean changed){
|
||||||
|
fIsChanged = changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name){
|
||||||
|
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
IEnvironmentVariableProvider provider = EnvironmentVariableProvider.getDefault();
|
||||||
|
if(!provider.isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
|
||||||
|
return (IBuildEnvironmentVariable)getMap().get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(){
|
||||||
|
Collection vars = getMap().values();
|
||||||
|
|
||||||
|
return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable deleteVariable(String name){
|
||||||
|
if(name == null || "".equals(name = name.trim())) //$NON-NLS-1$
|
||||||
|
return null;
|
||||||
|
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
|
if(!provider.isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)getMap().remove(name);
|
||||||
|
if(var != null){
|
||||||
|
fIsDirty = true;
|
||||||
|
fIsChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAll(){
|
||||||
|
Map map = getMap();
|
||||||
|
if(map.size() > 0){
|
||||||
|
fIsDirty = true;
|
||||||
|
fIsChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
map.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,220 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.OutputKeys;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements the common functionality that allows
|
||||||
|
* storing and loading environment variable settings from eclipse properties
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class StorableEnvironmentLoader {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this interface represents the preference node and the preference name
|
||||||
|
* that are used for holding the environment data
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected interface ISerializeInfo{
|
||||||
|
Preferences getNode();
|
||||||
|
|
||||||
|
String getPrefName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method should return the ISerializeInfo representing the information
|
||||||
|
* of where the variable should be stored and loaded
|
||||||
|
* If the given context is not supported this method should return null
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected abstract ISerializeInfo getSerializeInfo(Object context);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* loads the stored environment for the given context
|
||||||
|
*/
|
||||||
|
protected StorableEnvironment loadEnvironment(Object context){
|
||||||
|
ISerializeInfo serializeInfo = getSerializeInfo(context);
|
||||||
|
if(serializeInfo == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
InputStream stream = loadInputStream(serializeInfo.getNode(),serializeInfo.getPrefName());
|
||||||
|
if(stream == null)
|
||||||
|
return new StorableEnvironment();
|
||||||
|
return loadEnvironmentFromStream(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* stores the given environment
|
||||||
|
*/
|
||||||
|
protected void storeEnvironment(StorableEnvironment env, Object context, boolean force) throws CoreException{
|
||||||
|
if(!env.isDirty() && !force)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ISerializeInfo serializeInfo = getSerializeInfo(context);
|
||||||
|
if(serializeInfo == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ByteArrayOutputStream stream = storeEnvironmentToStream(env);
|
||||||
|
if(stream == null)
|
||||||
|
return;
|
||||||
|
storeOutputStream(stream,serializeInfo.getNode(),serializeInfo.getPrefName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private StorableEnvironment loadEnvironmentFromStream(InputStream stream){
|
||||||
|
try{
|
||||||
|
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
InputSource inputSource = new InputSource(stream);
|
||||||
|
Document document = parser.parse(inputSource);
|
||||||
|
Element rootElement = document.getDocumentElement();
|
||||||
|
|
||||||
|
if(!StorableEnvironment.ENVIRONMENT_ELEMENT_NAME.equals(rootElement.getNodeName()))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new StorableEnvironment(rootElement);
|
||||||
|
}
|
||||||
|
catch(ParserConfigurationException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(SAXException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(IOException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ByteArrayOutputStream storeEnvironmentToStream(StorableEnvironment env) throws CoreException{
|
||||||
|
try{
|
||||||
|
DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder builder= factory.newDocumentBuilder();
|
||||||
|
Document document= builder.newDocument();
|
||||||
|
|
||||||
|
Element rootElement = document.createElement(StorableEnvironment.ENVIRONMENT_ELEMENT_NAME);
|
||||||
|
document.appendChild(rootElement);
|
||||||
|
env.serialize(document,rootElement);
|
||||||
|
|
||||||
|
Transformer transformer=TransformerFactory.newInstance().newTransformer();
|
||||||
|
transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
|
||||||
|
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
|
||||||
|
transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
|
||||||
|
DOMSource source = new DOMSource(document);
|
||||||
|
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
StreamResult result = new StreamResult(stream);
|
||||||
|
|
||||||
|
transformer.transform(source, result);
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
catch(ParserConfigurationException e){
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||||
|
-1,
|
||||||
|
e.getMessage(),
|
||||||
|
e));
|
||||||
|
}
|
||||||
|
catch(TransformerConfigurationException e){
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||||
|
-1,
|
||||||
|
e.getMessage(),
|
||||||
|
e));
|
||||||
|
}
|
||||||
|
catch(TransformerException e){
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||||
|
-1,
|
||||||
|
e.getMessage(),
|
||||||
|
e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream loadInputStream(Preferences node, String key){
|
||||||
|
if(node == null || key == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
String value = node.get(key,null);
|
||||||
|
if(value == null || value.length() == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
byte[] bytes;
|
||||||
|
try {
|
||||||
|
bytes = value.getBytes("UTF-8"); //$NON-NLS-1$
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
bytes = value.getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ByteArrayInputStream(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void storeOutputStream(ByteArrayOutputStream stream, Preferences node, String key) throws CoreException{
|
||||||
|
if(stream == null || node == null || key == null)
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||||
|
-1,
|
||||||
|
ManagedMakeMessages.getResourceString("StorableEnvironmentLoader.storeOutputStream.wrong.arguments"), //$NON-NLS-1$
|
||||||
|
null));
|
||||||
|
byte[] bytes= stream.toByteArray();
|
||||||
|
|
||||||
|
String val = null;
|
||||||
|
try {
|
||||||
|
val= new String(bytes, "UTF-8"); //$NON-NLS-1$
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
val= new String(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
node.put(key,val);
|
||||||
|
|
||||||
|
try{
|
||||||
|
node.flush();
|
||||||
|
}
|
||||||
|
catch(BackingStoreException e){
|
||||||
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
ManagedBuilderCorePlugin.getUniqueIdentifier(),
|
||||||
|
-1,
|
||||||
|
e.getMessage(),
|
||||||
|
e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,265 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ITool;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class holds the build path variable values and allows
|
||||||
|
* checking the stored variable values with the values of the current environment environment
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class StoredBuildPathEnvironmentContainer extends
|
||||||
|
StorableEnvironmentLoader {
|
||||||
|
public static final String NODENAME = "environment"; //$NON-NLS-1$
|
||||||
|
public static final String NODENAME_PREFIX_CFG = "buildEnvironment"; //$NON-NLS-1$
|
||||||
|
public static final String NODENAME_CFG_INCLUDE = NODENAME_PREFIX_CFG + "Include"; //$NON-NLS-1$
|
||||||
|
public static final String NODENAME_CFG_LIBRARY = NODENAME_PREFIX_CFG + "Library"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private IConfiguration fConfiguration;
|
||||||
|
private StorableEnvironment fEnvironment;
|
||||||
|
private int fPathType;
|
||||||
|
private boolean fIsVariableCaseSensitive = ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive();
|
||||||
|
|
||||||
|
public StoredBuildPathEnvironmentContainer(int pathType){
|
||||||
|
fPathType = pathType == IEnvVarBuildPath.BUILDPATH_LIBRARY ?
|
||||||
|
IEnvVarBuildPath.BUILDPATH_LIBRARY : IEnvVarBuildPath.BUILDPATH_INCLUDE;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected StorableEnvironment getEnvironment(Object context) {
|
||||||
|
StorableEnvironment env = null;
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
if(fConfiguration != null && context == fConfiguration && fEnvironment != null)
|
||||||
|
env = fEnvironment;
|
||||||
|
else {
|
||||||
|
env = loadEnvironment(context);
|
||||||
|
if(env != null){
|
||||||
|
if(fConfiguration != null && fEnvironment != null){
|
||||||
|
try{
|
||||||
|
storeEnvironment(fEnvironment,fConfiguration,false);
|
||||||
|
}catch(CoreException e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkLoadedVarNames(env,context);
|
||||||
|
|
||||||
|
fConfiguration = (IConfiguration)context;
|
||||||
|
fEnvironment = env;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean haveIdenticalValues(IBuildEnvironmentVariable var1,
|
||||||
|
IBuildEnvironmentVariable var2){
|
||||||
|
if(var1 == null)
|
||||||
|
return var2 == null || var2.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE;
|
||||||
|
if(var2 == null)
|
||||||
|
return var1 == null || var1.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE;
|
||||||
|
int op1 = var1.getOperation();
|
||||||
|
int op2 = var2.getOperation();
|
||||||
|
if(op1 == IBuildEnvironmentVariable.ENVVAR_REMOVE ||
|
||||||
|
op2 == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
|
return op1 == op2;
|
||||||
|
|
||||||
|
return maskNull(var1.getValue()).equals(maskNull(var2.getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String maskNull(String val){
|
||||||
|
return val == null ? "" : val; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkBuildPathChange(EnvVarCollector existingVariables,
|
||||||
|
IConfiguration configuration){
|
||||||
|
StorableEnvironment env = getEnvironment(configuration);
|
||||||
|
if(env == null)
|
||||||
|
return false;
|
||||||
|
IBuildEnvironmentVariable vars[] = env.getVariables();
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
IBuildEnvironmentVariable var = vars[i];
|
||||||
|
String name = var.getName();
|
||||||
|
IBuildEnvironmentVariable curVar = existingVariables != null ?
|
||||||
|
existingVariables.getVariable(name) : null;
|
||||||
|
if(!haveIdenticalValues(var,curVar)){
|
||||||
|
if(curVar == null){
|
||||||
|
env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
env.createVariable(curVar.getName(),curVar.getValue(),curVar.getOperation(),curVar.getDelimiter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
boolean changed = env.isChanged();
|
||||||
|
env.setChanged(false);
|
||||||
|
if(changed)
|
||||||
|
try{
|
||||||
|
storeEnvironment(env,configuration,false);
|
||||||
|
}catch(CoreException e){
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* checks whether the variable of a given name is the build path variable
|
||||||
|
* for the given configuration
|
||||||
|
* If it is, than performs a check and returns true if the variable was changed
|
||||||
|
* If it is not the build path variable, no check is performed and this method always
|
||||||
|
* returns false in this case
|
||||||
|
*/
|
||||||
|
public boolean isVariableChanged(String name,
|
||||||
|
IBuildEnvironmentVariable variable,
|
||||||
|
IConfiguration configuration){
|
||||||
|
StorableEnvironment env = getEnvironment(configuration);
|
||||||
|
if(env == null)
|
||||||
|
return false;
|
||||||
|
IBuildEnvironmentVariable var = env.getVariable(name);
|
||||||
|
if(var == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(haveIdenticalValues(var,variable))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* synchronizes the stored variables with the ones passed to this method
|
||||||
|
*/
|
||||||
|
public void synchronize(EnvVarCollector existingVariables,
|
||||||
|
IConfiguration configuration){
|
||||||
|
checkBuildPathChange(existingVariables,configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkLoadedVarNames(StorableEnvironment env, Object context){
|
||||||
|
String varNames[] = getBuildPathVarNames((IConfiguration)context, fPathType);
|
||||||
|
for(int i = 0; i < varNames.length; i++){
|
||||||
|
String name = varNames[i];
|
||||||
|
if(env.getVariable(name) == null)
|
||||||
|
env.createVariable(name,null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable vars[] = env.getVariables();
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
IBuildEnvironmentVariable var = vars[i];
|
||||||
|
boolean validVar = false;
|
||||||
|
for(int j = 0; j < varNames.length; j++){
|
||||||
|
String varName = varNames[j];
|
||||||
|
if(varNamesEqual(var.getName(),varName)){
|
||||||
|
validVar = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!validVar){
|
||||||
|
env.deleteVariable(var.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns true if the variable names are equal and false otherwise
|
||||||
|
*/
|
||||||
|
private boolean varNamesEqual(String name1, String name2){
|
||||||
|
return fIsVariableCaseSensitive ?
|
||||||
|
name1.equals(name2) : name1.equalsIgnoreCase(name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironmentLoader#getSerializeInfo(java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected ISerializeInfo getSerializeInfo(Object context) {
|
||||||
|
ISerializeInfo serializeInfo = null;
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
IConfiguration cfg = (IConfiguration)context;
|
||||||
|
final Preferences prefs = getConfigurationNode(cfg);
|
||||||
|
final String name = cfg.getId();
|
||||||
|
if(prefs != null && name != null)
|
||||||
|
serializeInfo = new ISerializeInfo(){
|
||||||
|
public Preferences getNode(){
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return serializeInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(boolean force) {
|
||||||
|
if(fEnvironment != null){
|
||||||
|
try{
|
||||||
|
storeEnvironment(fEnvironment,fConfiguration,force);
|
||||||
|
}catch(CoreException e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Preferences getConfigurationNode(IConfiguration cfg){
|
||||||
|
IProject project = (IProject)cfg.getOwner();
|
||||||
|
if(project == null || !project.exists())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Preferences prefNode = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
|
||||||
|
if(prefNode == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
prefNode = prefNode.node(NODENAME);
|
||||||
|
if(prefNode == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(fPathType == IEnvVarBuildPath.BUILDPATH_LIBRARY)
|
||||||
|
return prefNode.node(NODENAME_CFG_LIBRARY);
|
||||||
|
return prefNode.node(NODENAME_CFG_INCLUDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getBuildPathVarNames(IConfiguration configuration,int buildPathType){
|
||||||
|
ITool tools[] = configuration.getFilteredTools();
|
||||||
|
List list = new ArrayList();
|
||||||
|
|
||||||
|
for(int i = 0; i < tools.length; i++){
|
||||||
|
IEnvVarBuildPath pathDescriptors[] = tools[i].getEnvVarBuildPaths();
|
||||||
|
|
||||||
|
if(pathDescriptors == null || pathDescriptors.length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for(int j = 0; j < pathDescriptors.length; j++){
|
||||||
|
IEnvVarBuildPath curPathDes = pathDescriptors[j];
|
||||||
|
if(curPathDes.getType() != buildPathType)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String vars[] = curPathDes.getVariableNames();
|
||||||
|
if(vars == null || vars.length == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
list.addAll(Arrays.asList(vars));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (String[])list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,349 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.envvar;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the Environment Variable Supplier used to supply variables
|
||||||
|
* defined by a user
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
public class UserDefinedEnvironmentSupplier extends
|
||||||
|
StorableEnvironmentLoader
|
||||||
|
implements IEnvironmentVariableSupplier{
|
||||||
|
|
||||||
|
public static final String NODENAME = "environment"; //$NON-NLS-1$
|
||||||
|
public static final String PREFNAME_WORKSPACE = "workspace"; //$NON-NLS-1$
|
||||||
|
public static final String PREFNAME_PROJECT = "project"; //$NON-NLS-1$
|
||||||
|
public static final String NODENAME_CFG = "project"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String fNonOverloadableVariables[] = new String[]{
|
||||||
|
//users not allowed currently to override the "CWD" and "PWD" variables
|
||||||
|
EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
|
||||||
|
EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
private StorableEnvironment fConfigurationVariables;
|
||||||
|
private StorableEnvironment fProjectVariables;
|
||||||
|
private StorableEnvironment fWorkspaceVariables;
|
||||||
|
|
||||||
|
private IConfiguration fCurrentCfg = null;
|
||||||
|
private IManagedProject fCurrentProj = null;
|
||||||
|
|
||||||
|
protected StorableEnvironment getEnvironment(Object context){
|
||||||
|
if(context == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
StorableEnvironment env = null;
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
IConfiguration newCfg = (IConfiguration)context;
|
||||||
|
if(fCurrentCfg == newCfg && fConfigurationVariables != null){
|
||||||
|
env = fConfigurationVariables;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
env = loadEnvironment(newCfg);
|
||||||
|
if(env != null){
|
||||||
|
if(fConfigurationVariables != null)
|
||||||
|
try{
|
||||||
|
storeEnvironment(fConfigurationVariables,fCurrentCfg,false);
|
||||||
|
} catch(CoreException e){
|
||||||
|
}
|
||||||
|
fConfigurationVariables = env;
|
||||||
|
fCurrentCfg = newCfg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(context instanceof IManagedProject){
|
||||||
|
IManagedProject newProj = (IManagedProject)context;
|
||||||
|
if(fCurrentProj == newProj && fProjectVariables != null){
|
||||||
|
env = fProjectVariables;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
env = loadEnvironment(newProj);
|
||||||
|
if(env != null){
|
||||||
|
if(fProjectVariables != null)
|
||||||
|
try{
|
||||||
|
storeEnvironment(fProjectVariables,fCurrentProj,false);
|
||||||
|
} catch(CoreException e){
|
||||||
|
}
|
||||||
|
fProjectVariables = env;
|
||||||
|
fCurrentProj = newProj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(context instanceof IWorkspace){
|
||||||
|
if(fWorkspaceVariables == null)
|
||||||
|
fWorkspaceVariables = loadEnvironment(context);
|
||||||
|
env = fWorkspaceVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ISerializeInfo getSerializeInfo(Object context){
|
||||||
|
ISerializeInfo serializeInfo = null;
|
||||||
|
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
IConfiguration cfg = (IConfiguration)context;
|
||||||
|
IManagedProject project = cfg.getManagedProject();
|
||||||
|
|
||||||
|
final Preferences prefs = project != null ? getConfigurationNode(project) : null;
|
||||||
|
final String name = cfg.getId();
|
||||||
|
if(prefs != null && name != null)
|
||||||
|
serializeInfo = new ISerializeInfo(){
|
||||||
|
public Preferences getNode(){
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if(context instanceof IManagedProject){
|
||||||
|
IManagedProject proj = (IManagedProject)context;
|
||||||
|
final Preferences prefs = getProjectNode(proj);
|
||||||
|
final String name = PREFNAME_PROJECT;
|
||||||
|
if(prefs != null && name != null)
|
||||||
|
serializeInfo = new ISerializeInfo(){
|
||||||
|
public Preferences getNode(){
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if(context instanceof IWorkspace){
|
||||||
|
final Preferences prefs = getWorkspaceNode();
|
||||||
|
final String name = PREFNAME_WORKSPACE;
|
||||||
|
if(prefs != null && name != null)
|
||||||
|
serializeInfo = new ISerializeInfo(){
|
||||||
|
public Preferences getNode(){
|
||||||
|
return prefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefName(){
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return serializeInfo;
|
||||||
|
}
|
||||||
|
private Preferences getConfigurationNode(IManagedProject managedProject){
|
||||||
|
Preferences prefNode = getProjectNode(managedProject);
|
||||||
|
if(prefNode == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return prefNode.node(NODENAME_CFG);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Preferences getProjectNode(IManagedProject managedProject){
|
||||||
|
IProject project = (IProject)managedProject.getOwner();
|
||||||
|
if(!project.exists())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Preferences prefNode = new ProjectScope(project).getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
|
||||||
|
if(prefNode == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return prefNode.node(NODENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Preferences getWorkspaceNode(){
|
||||||
|
Preferences prefNode = new InstanceScope().getNode(ManagedBuilderCorePlugin.getUniqueIdentifier());
|
||||||
|
if(prefNode == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return prefNode.node(NODENAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkInexistentConfigurations(IManagedProject managedProject){
|
||||||
|
Preferences prefNode = getConfigurationNode(managedProject);
|
||||||
|
if(prefNode == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try{
|
||||||
|
String ids[] = prefNode.childrenNames();
|
||||||
|
boolean found = false;
|
||||||
|
for( int i = 0; i < ids.length; i++){
|
||||||
|
if(managedProject.getConfiguration(ids[i]) == null){
|
||||||
|
prefNode.remove(ids[i]);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found)
|
||||||
|
prefNode.flush();
|
||||||
|
}
|
||||||
|
catch(BackingStoreException e){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serialize(boolean force){
|
||||||
|
if(fConfigurationVariables != null && fCurrentCfg != null ){
|
||||||
|
try{
|
||||||
|
storeEnvironment(fConfigurationVariables,fCurrentCfg,force);
|
||||||
|
} catch(CoreException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fProjectVariables != null && fCurrentProj != null ){
|
||||||
|
try{
|
||||||
|
storeEnvironment(fProjectVariables,fCurrentProj,force);
|
||||||
|
} catch(CoreException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fWorkspaceVariables != null){
|
||||||
|
try{
|
||||||
|
storeEnvironment(fWorkspaceVariables,ResourcesPlugin.getWorkspace(),force);
|
||||||
|
} catch(CoreException e){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name, Object context) {
|
||||||
|
if(getValidName(name) == null)
|
||||||
|
return null;
|
||||||
|
StorableEnvironment env = getEnvironment(context);
|
||||||
|
if(env == null)
|
||||||
|
return null;
|
||||||
|
return env.getVariable(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables()
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object context) {
|
||||||
|
StorableEnvironment env = getEnvironment(context);
|
||||||
|
if(env == null)
|
||||||
|
return null;
|
||||||
|
return filterVariables(env.getVariables());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable createVariable(String name, String value, int op, String delimiter, Object context){
|
||||||
|
if(getValidName(name) == null)
|
||||||
|
return null;
|
||||||
|
StorableEnvironment env = getEnvironment(context);
|
||||||
|
if(env == null)
|
||||||
|
return null;
|
||||||
|
IBuildEnvironmentVariable var = env.createVariable(name,value,op,delimiter);
|
||||||
|
setRebuildStateForContext(context);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBuildEnvironmentVariable deleteVariable(String name, Object context){
|
||||||
|
StorableEnvironment env = getEnvironment(context);
|
||||||
|
if(env == null)
|
||||||
|
return null;
|
||||||
|
IBuildEnvironmentVariable var = env.deleteVariable(name);
|
||||||
|
if(var != null)
|
||||||
|
setRebuildStateForContext(context);
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteAll(Object context){
|
||||||
|
StorableEnvironment env = getEnvironment(context);
|
||||||
|
if(env == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
env.deleteAll();
|
||||||
|
setRebuildStateForContext(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setRebuildStateForContext(Object context){
|
||||||
|
if(context == null)
|
||||||
|
return;
|
||||||
|
if(context instanceof IConfiguration){
|
||||||
|
((IConfiguration)context).setRebuildState(true);
|
||||||
|
}
|
||||||
|
else if(context instanceof IManagedProject){
|
||||||
|
IConfiguration cfgs[] = ((IManagedProject)context).getConfigurations();
|
||||||
|
for(int i = 0; i < cfgs.length; i++){
|
||||||
|
cfgs[i].setRebuildState(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(context instanceof IWorkspace){
|
||||||
|
IProject projects[] = ((IWorkspace)context).getRoot().getProjects();
|
||||||
|
for(int i = 0; i < projects.length; i++){
|
||||||
|
if(ManagedBuildManager.manages(projects[i])){
|
||||||
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(projects[i]);
|
||||||
|
if(info != null){
|
||||||
|
IConfiguration cfgs[] = info.getManagedProject().getConfigurations();
|
||||||
|
for(int j = 0; j < cfgs.length; j++){
|
||||||
|
cfgs[j].setRebuildState(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getValidName(String name){
|
||||||
|
name = EnvVarOperationProcessor.normalizeName(name);
|
||||||
|
if(name == null)
|
||||||
|
return null;
|
||||||
|
if(fNonOverloadableVariables != null){
|
||||||
|
for(int i = 0; i < fNonOverloadableVariables.length; i++){
|
||||||
|
if(name.equals(fNonOverloadableVariables[i]))
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IBuildEnvironmentVariable[] filterVariables(IBuildEnvironmentVariable variables[]){
|
||||||
|
if(variables == null || variables.length == 0)
|
||||||
|
return variables;
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable filtered[] = new IBuildEnvironmentVariable[variables.length];
|
||||||
|
int filteredNum = 0;
|
||||||
|
for(int i = 0; i < variables.length; i++){
|
||||||
|
if(getValidName(variables[i].getName()) != null)
|
||||||
|
filtered[filteredNum++] = variables[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filteredNum != filtered.length){
|
||||||
|
IBuildEnvironmentVariable vars[] = new IBuildEnvironmentVariable[filteredNum];
|
||||||
|
for(int i = 0; i < filteredNum; i++)
|
||||||
|
vars[i] = filtered[i];
|
||||||
|
filtered = vars;
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -311,6 +311,8 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
|
||||||
for (int i=0; i<buildTools.length; i++) buildToolsUsed[i] = false;
|
for (int i=0; i<buildTools.length; i++) buildToolsUsed[i] = false;
|
||||||
// Initialize the tool info array
|
// Initialize the tool info array
|
||||||
gnuToolInfos = new ManagedBuildGnuToolInfo[buildTools.length];
|
gnuToolInfos = new ManagedBuildGnuToolInfo[buildTools.length];
|
||||||
|
//set the top build dir path
|
||||||
|
topBuildDir = project.getFolder(info.getConfigurationName()).getFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2003, 2004 IBM Corporation and others.
|
# Copyright (c) 2003, 2005 IBM Corporation and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Common Public License v1.0
|
# are made available under the terms of the Common Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -21,6 +21,9 @@ MngCCWizard.description=Create a new C++ project and let Eclipse create and mana
|
||||||
MngBuildProp.name=C/C++ Build
|
MngBuildProp.name=C/C++ Build
|
||||||
MngOtherProp.name= Error/Binary Parsers
|
MngOtherProp.name= Error/Binary Parsers
|
||||||
|
|
||||||
|
#The preference pages
|
||||||
|
MngBuildPref.name=Managed Build
|
||||||
|
|
||||||
#The Resource Property page
|
#The Resource Property page
|
||||||
MngResourceProp.name=C/C++ Build
|
MngResourceProp.name=C/C++ Build
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,16 @@
|
||||||
</page>
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.preferencePages">
|
||||||
|
<page
|
||||||
|
name="%MngBuildPref.name"
|
||||||
|
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||||
|
class="org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage"
|
||||||
|
id="org.eclipse.cdt.managedbuilder.ui.preferences.BuildPreferences">
|
||||||
|
</page>
|
||||||
|
</extension>
|
||||||
|
|
||||||
<!-- Managed Make Builder Tool Specifications -->
|
<!-- Managed Make Builder Tool Specifications -->
|
||||||
<extension
|
<extension
|
||||||
id="cdt.managed.build.info"
|
id="cdt.managed.build.info"
|
||||||
|
@ -115,6 +125,11 @@
|
||||||
command="gcc"
|
command="gcc"
|
||||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||||
id="cdt.managedbuild.tool.gnu.c.linker">
|
id="cdt.managedbuild.tool.gnu.c.linker">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathLibrary"
|
||||||
|
variableList="LIBRARY_PATH">
|
||||||
|
</envVarBuildPath>
|
||||||
|
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.gnu.c.linker"
|
owner="cdt.managedbuild.tool.gnu.c.linker"
|
||||||
name="%OptionCategory.General"
|
name="%OptionCategory.General"
|
||||||
|
@ -250,6 +265,10 @@
|
||||||
command="g++"
|
command="g++"
|
||||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.linker">
|
id="cdt.managedbuild.tool.gnu.cpp.linker">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathLibrary"
|
||||||
|
variableList="LIBRARY_PATH">
|
||||||
|
</envVarBuildPath>
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.gnu.cpp.linker"
|
owner="cdt.managedbuild.tool.gnu.cpp.linker"
|
||||||
name="%OptionCategory.General"
|
name="%OptionCategory.General"
|
||||||
|
@ -504,6 +523,11 @@
|
||||||
command="gcc"
|
command="gcc"
|
||||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||||
id="cdt.managedbuild.tool.macosx.c.linker">
|
id="cdt.managedbuild.tool.macosx.c.linker">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathLibrary"
|
||||||
|
variableList="LIBRARY_PATH">
|
||||||
|
</envVarBuildPath>
|
||||||
|
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.macosx.c.linker"
|
owner="cdt.managedbuild.tool.macosx.c.linker"
|
||||||
name="%OptionCategory.General"
|
name="%OptionCategory.General"
|
||||||
|
@ -618,6 +642,10 @@
|
||||||
command="g++"
|
command="g++"
|
||||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.internal.DefaultNoDependencyCalculator"
|
||||||
id="cdt.managedbuild.tool.macosx.cpp.linker">
|
id="cdt.managedbuild.tool.macosx.cpp.linker">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathLibrary"
|
||||||
|
variableList="LIBRARY_PATH">
|
||||||
|
</envVarBuildPath>
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.macosx.cpp.linker"
|
owner="cdt.managedbuild.tool.macosx.cpp.linker"
|
||||||
name="%OptionCategory.General"
|
name="%OptionCategory.General"
|
||||||
|
@ -727,6 +755,10 @@
|
||||||
natureFilter="cnature"
|
natureFilter="cnature"
|
||||||
outputs="o"
|
outputs="o"
|
||||||
outputFlag="-o">
|
outputFlag="-o">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathInclude"
|
||||||
|
variableList="CPATH,C_INCLUDE_PATH">
|
||||||
|
</envVarBuildPath>
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.gnu.c.compiler"
|
owner="cdt.managedbuild.tool.gnu.c.compiler"
|
||||||
name="%OptionCategory.Preproc"
|
name="%OptionCategory.Preproc"
|
||||||
|
@ -967,6 +999,10 @@
|
||||||
natureFilter="ccnature"
|
natureFilter="ccnature"
|
||||||
outputs="o"
|
outputs="o"
|
||||||
outputFlag="-o">
|
outputFlag="-o">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathInclude"
|
||||||
|
variableList="CPATH,CPLUS_INCLUDE_PATH">
|
||||||
|
</envVarBuildPath>
|
||||||
<optionCategory
|
<optionCategory
|
||||||
owner="cdt.managedbuild.tool.gnu.cpp.compiler"
|
owner="cdt.managedbuild.tool.gnu.cpp.compiler"
|
||||||
name="%OptionCategory.Preproc"
|
name="%OptionCategory.Preproc"
|
||||||
|
@ -1183,6 +1219,44 @@
|
||||||
</option>
|
</option>
|
||||||
</tool>
|
</tool>
|
||||||
|
|
||||||
|
<tool
|
||||||
|
id="cdt.managedbuild.tool.gnu.c.linker.cygwin"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.c.linker">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathLibrary"
|
||||||
|
variableList="LIBRARY_PATH"
|
||||||
|
buildPathResolver="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.CygwinPathResolver">
|
||||||
|
</envVarBuildPath>
|
||||||
|
</tool>
|
||||||
|
<tool
|
||||||
|
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.cpp.linker">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathLibrary"
|
||||||
|
variableList="LIBRARY_PATH"
|
||||||
|
buildPathResolver="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.CygwinPathResolver">
|
||||||
|
</envVarBuildPath>
|
||||||
|
</tool>
|
||||||
|
<tool
|
||||||
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathInclude"
|
||||||
|
variableList="CPATH,C_INCLUDE_PATH"
|
||||||
|
buildPathResolver="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.CygwinPathResolver">
|
||||||
|
</envVarBuildPath>
|
||||||
|
</tool>
|
||||||
|
<tool
|
||||||
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
||||||
|
<envVarBuildPath
|
||||||
|
pathType="buildpathInclude"
|
||||||
|
variableList="CPATH,CPLUS_INCLUDE_PATH"
|
||||||
|
buildPathResolver="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.CygwinPathResolver">
|
||||||
|
</envVarBuildPath>
|
||||||
|
</tool>
|
||||||
|
|
||||||
|
|
||||||
<projectType
|
<projectType
|
||||||
isAbstract="false"
|
isAbstract="false"
|
||||||
isTest="false"
|
isTest="false"
|
||||||
|
@ -1651,6 +1725,7 @@
|
||||||
name="%ToolChainName.Dbg"
|
name="%ToolChainName.Dbg"
|
||||||
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
||||||
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
||||||
|
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
|
||||||
id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
|
id="cdt.managedbuild.toolchain.gnu.cygwin.exe.debug">
|
||||||
<targetPlatform
|
<targetPlatform
|
||||||
id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"
|
id="cdt.managedbuild.target.gnu.platform.cygwin.exe.debug"
|
||||||
|
@ -1668,7 +1743,7 @@
|
||||||
</builder>
|
</builder>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug"
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.debug"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level"
|
id="gnu.c.compiler.cygwin.exe.debug.option.optimization.level"
|
||||||
defaultValue="gnu.c.optimization.level.none"
|
defaultValue="gnu.c.optimization.level.none"
|
||||||
|
@ -1682,7 +1757,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug"
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.debug"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level"
|
id="gnu.cpp.compiler.cygwin.exe.debug.option.optimization.level"
|
||||||
defaultValue="gnu.cpp.compiler.optimization.level.none"
|
defaultValue="gnu.cpp.compiler.optimization.level.none"
|
||||||
|
@ -1697,12 +1772,12 @@
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug"
|
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.debug"
|
||||||
outputs="exe"
|
outputs="exe"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.linker">
|
superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"
|
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.debug"
|
||||||
outputs="exe"
|
outputs="exe"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.linker">
|
superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug"
|
id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.debug"
|
||||||
|
@ -1722,6 +1797,7 @@
|
||||||
name="%ToolChainName.Rel"
|
name="%ToolChainName.Rel"
|
||||||
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
||||||
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
||||||
|
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
|
||||||
id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
|
id="cdt.managedbuild.toolchain.gnu.cygwin.exe.release">
|
||||||
<targetPlatform
|
<targetPlatform
|
||||||
id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"
|
id="cdt.managedbuild.target.gnu.platform.cygwin.exe.release"
|
||||||
|
@ -1739,7 +1815,7 @@
|
||||||
</builder>
|
</builder>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release"
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.exe.release"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.compiler.cygwin.exe.release.option.optimization.level"
|
id="gnu.c.compiler.cygwin.exe.release.option.optimization.level"
|
||||||
defaultValue="gnu.c.optimization.level.most"
|
defaultValue="gnu.c.optimization.level.most"
|
||||||
|
@ -1753,7 +1829,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release"
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.exe.release"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level"
|
id="gnu.cpp.compiler.cygwin.exe.release.option.optimization.level"
|
||||||
defaultValue="gnu.cpp.compiler.optimization.level.most"
|
defaultValue="gnu.cpp.compiler.optimization.level.most"
|
||||||
|
@ -1768,12 +1844,12 @@
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release"
|
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.exe.release"
|
||||||
outputs="exe"
|
outputs="exe"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.linker">
|
superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"
|
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.exe.release"
|
||||||
outputs="exe"
|
outputs="exe"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.linker">
|
superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release"
|
id="cdt.managedbuild.tool.gnu.assembler.cygwin.exe.release"
|
||||||
|
@ -1800,6 +1876,7 @@
|
||||||
name="%ToolChainName.Dbg"
|
name="%ToolChainName.Dbg"
|
||||||
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
||||||
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
||||||
|
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
|
||||||
id="cdt.managedbuild.toolchain.gnu.cygwin.so.debug">
|
id="cdt.managedbuild.toolchain.gnu.cygwin.so.debug">
|
||||||
<targetPlatform
|
<targetPlatform
|
||||||
id="cdt.managedbuild.target.gnu.platform.cygwin.so.debug"
|
id="cdt.managedbuild.target.gnu.platform.cygwin.so.debug"
|
||||||
|
@ -1817,7 +1894,7 @@
|
||||||
</builder>
|
</builder>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.so.debug"
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.so.debug"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.compiler.cygwin.so.debug.option.optimization.level"
|
id="gnu.c.compiler.cygwin.so.debug.option.optimization.level"
|
||||||
defaultValue="gnu.c.optimization.level.none"
|
defaultValue="gnu.c.optimization.level.none"
|
||||||
|
@ -1831,7 +1908,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.so.debug"
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.so.debug"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.compiler.cygwin.so.debug.option.optimization.level"
|
id="gnu.cpp.compiler.cygwin.so.debug.option.optimization.level"
|
||||||
defaultValue="gnu.cpp.compiler.optimization.level.none"
|
defaultValue="gnu.cpp.compiler.optimization.level.none"
|
||||||
|
@ -1846,7 +1923,7 @@
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.debug"
|
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.debug"
|
||||||
outputs="dll,a.dll"
|
outputs="dll,a.dll"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.linker">
|
superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.link.cygwin.so.debug.option.shared"
|
id="gnu.c.link.cygwin.so.debug.option.shared"
|
||||||
defaultValue="true"
|
defaultValue="true"
|
||||||
|
@ -1856,7 +1933,7 @@
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.debug"
|
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.debug"
|
||||||
outputs="dll,a.dll"
|
outputs="dll,a.dll"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.linker">
|
superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.link.cygwin.so.debug.option.shared"
|
id="gnu.cpp.link.cygwin.so.debug.option.shared"
|
||||||
defaultValue="true"
|
defaultValue="true"
|
||||||
|
@ -1881,6 +1958,7 @@
|
||||||
name="%ToolChainName.Rel"
|
name="%ToolChainName.Rel"
|
||||||
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
||||||
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
||||||
|
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
|
||||||
id="cdt.managedbuild.toolchain.gnu.cygwin.so.release">
|
id="cdt.managedbuild.toolchain.gnu.cygwin.so.release">
|
||||||
<targetPlatform
|
<targetPlatform
|
||||||
id="cdt.managedbuild.target.gnu.platform.cygwin.so.release"
|
id="cdt.managedbuild.target.gnu.platform.cygwin.so.release"
|
||||||
|
@ -1898,7 +1976,7 @@
|
||||||
</builder>
|
</builder>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.so.release"
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.so.release"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.compiler.cygwin.so.release.option.optimization.level"
|
id="gnu.c.compiler.cygwin.so.release.option.optimization.level"
|
||||||
defaultValue="gnu.c.optimization.level.most"
|
defaultValue="gnu.c.optimization.level.most"
|
||||||
|
@ -1912,7 +1990,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.so.release"
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.so.release"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.compiler.cygwin.so.release.option.optimization.level"
|
id="gnu.cpp.compiler.cygwin.so.release.option.optimization.level"
|
||||||
defaultValue="gnu.cpp.compiler.optimization.level.most"
|
defaultValue="gnu.cpp.compiler.optimization.level.most"
|
||||||
|
@ -1927,7 +2005,7 @@
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.release"
|
id="cdt.managedbuild.tool.gnu.c.linker.cygwin.so.release"
|
||||||
outputs="dll,a.dll"
|
outputs="dll,a.dll"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.linker">
|
superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.link.cygwin.so.release.option.shared"
|
id="gnu.c.link.cygwin.so.release.option.shared"
|
||||||
defaultValue="true"
|
defaultValue="true"
|
||||||
|
@ -1937,7 +2015,7 @@
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.release"
|
id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.so.release"
|
||||||
outputs="dll,a.dll"
|
outputs="dll,a.dll"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.linker">
|
superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.link.cygwin.so.release.option.shared"
|
id="gnu.cpp.link.cygwin.so.release.option.shared"
|
||||||
defaultValue="true"
|
defaultValue="true"
|
||||||
|
@ -1969,6 +2047,7 @@
|
||||||
name="%ToolChainName.Dbg"
|
name="%ToolChainName.Dbg"
|
||||||
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
||||||
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
||||||
|
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
|
||||||
id="cdt.managedbuild.toolchain.gnu.cygwin.lib.debug">
|
id="cdt.managedbuild.toolchain.gnu.cygwin.lib.debug">
|
||||||
<targetPlatform
|
<targetPlatform
|
||||||
id="cdt.managedbuild.target.gnu.platform.cygwin.lib.debug"
|
id="cdt.managedbuild.target.gnu.platform.cygwin.lib.debug"
|
||||||
|
@ -1986,7 +2065,7 @@
|
||||||
</builder>
|
</builder>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug"
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.compiler.cygwin.lib.debug.option.optimization.level"
|
id="gnu.c.compiler.cygwin.lib.debug.option.optimization.level"
|
||||||
defaultValue="gnu.c.optimization.level.none"
|
defaultValue="gnu.c.optimization.level.none"
|
||||||
|
@ -2000,7 +2079,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.debug"
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.debug"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.compiler.cygwin.lib.debug.option.optimization.level"
|
id="gnu.cpp.compiler.cygwin.lib.debug.option.optimization.level"
|
||||||
defaultValue="gnu.cpp.compiler.optimization.level.none"
|
defaultValue="gnu.cpp.compiler.optimization.level.none"
|
||||||
|
@ -2036,6 +2115,7 @@
|
||||||
name="%ToolChainName.Rel"
|
name="%ToolChainName.Rel"
|
||||||
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
scannerConfigDiscoveryProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"
|
||||||
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
isToolChainSupported="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.IsGnuCygwinToolChainSupported"
|
||||||
|
configurationEnvironmentSupplier="org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin.GnuCygwinConfigurationEnvironmentSupplier"
|
||||||
id="cdt.managedbuild.toolchain.gnu.cygwin.lib.release">
|
id="cdt.managedbuild.toolchain.gnu.cygwin.lib.release">
|
||||||
<targetPlatform
|
<targetPlatform
|
||||||
id="cdt.managedbuild.target.gnu.platform.cygwin.lib.release"
|
id="cdt.managedbuild.target.gnu.platform.cygwin.lib.release"
|
||||||
|
@ -2053,7 +2133,7 @@
|
||||||
</builder>
|
</builder>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release"
|
id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release"
|
||||||
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.c.compiler.cygwin.lib.release.option.optimization.level"
|
id="gnu.c.compiler.cygwin.lib.release.option.optimization.level"
|
||||||
defaultValue="gnu.c.optimization.level.most"
|
defaultValue="gnu.c.optimization.level.most"
|
||||||
|
@ -2067,7 +2147,7 @@
|
||||||
</tool>
|
</tool>
|
||||||
<tool
|
<tool
|
||||||
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.release"
|
id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.release"
|
||||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin">
|
||||||
<option
|
<option
|
||||||
id="gnu.cpp.compiler.cygwin.lib.release.option.optimization.level"
|
id="gnu.cpp.compiler.cygwin.lib.release.option.optimization.level"
|
||||||
defaultValue="gnu.cpp.compiler.optimization.level.most"
|
defaultValue="gnu.cpp.compiler.optimization.level.most"
|
||||||
|
|
|
@ -0,0 +1,977 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
|
||||||
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
|
||||||
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarCollector;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.UserDefinedEnvironmentSupplier;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.resource.JFaceResources;
|
||||||
|
import org.eclipse.jface.viewers.IColorProvider;
|
||||||
|
import org.eclipse.jface.viewers.IFontProvider;
|
||||||
|
import org.eclipse.jface.viewers.ITableFontProvider;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.ViewerSorter;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
import org.eclipse.swt.events.KeyListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.Font;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.FormAttachment;
|
||||||
|
import org.eclipse.swt.layout.FormData;
|
||||||
|
import org.eclipse.swt.layout.FormLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* displays the environment for the given context
|
||||||
|
*/
|
||||||
|
public class EnvironmentBlock extends AbstractCOptionPage {
|
||||||
|
/*
|
||||||
|
* String constants
|
||||||
|
*/
|
||||||
|
private static final String PREFIX = "EnvironmentBlock"; //$NON-NLS-1$
|
||||||
|
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String USER_VAR = LABEL + ".user.var"; //$NON-NLS-1$
|
||||||
|
private static final String SYSTEM_VAR = LABEL + ".system.var"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String HEADER = LABEL + ".header"; //$NON-NLS-1$
|
||||||
|
private static final String HEADER_NAME = HEADER + ".name"; //$NON-NLS-1$
|
||||||
|
private static final String HEADER_VALUE = HEADER + ".value"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String BUTTON = LABEL + ".button"; //$NON-NLS-1$
|
||||||
|
private static final String BUTTON_NEW = BUTTON + ".new"; //$NON-NLS-1$
|
||||||
|
private static final String BUTTON_EDIT = BUTTON + ".edit"; //$NON-NLS-1$
|
||||||
|
private static final String BUTTON_DELETE = BUTTON + ".delete"; //$NON-NLS-1$
|
||||||
|
private static final String BUTTON_UNDEF = BUTTON + ".undef"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String BUTTON_CHECK_SHOW_PARENT = BUTTON + ".check.chow.parent"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String VALUE_UNDEF = LABEL + ".value.undef"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String DELETE_CONFIRM_TITLE = LABEL + ".delete.confirm.title"; //$NON-NLS-1$
|
||||||
|
private static final String DELETE_CONFIRM_MESSAGE = LABEL + ".delete.confirm.message"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String DELETE_ALL_CONFIRM_TITLE = LABEL + ".delete.all.confirm.title"; //$NON-NLS-1$
|
||||||
|
private static final String DELETE_ALL_CONFIRM_MESSAGE = LABEL + ".delete.all.confirm.message"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String fHiddenVariables[] = new String[]{
|
||||||
|
//currently the "CWD" and "PWD" variables are not displayed in UI and can not be creater by a user
|
||||||
|
EnvVarOperationProcessor.normalizeName("CWD"), //$NON-NLS-1$
|
||||||
|
EnvVarOperationProcessor.normalizeName("PWD") //$NON-NLS-1$
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* button IDs
|
||||||
|
*/
|
||||||
|
private static final int IDX_BUTTON_NEW = 0;
|
||||||
|
private static final int IDX_BUTTON_EDIT = 1;
|
||||||
|
private static final int IDX_BUTTON_UNDEF = 2;
|
||||||
|
private static final int IDX_BUTTON_DELETE = 3;
|
||||||
|
|
||||||
|
//variable names deleted by a user
|
||||||
|
private HashSet fDeletedUserVariableNames;
|
||||||
|
//variables added by a user
|
||||||
|
private Map fAddedUserVariables;
|
||||||
|
//specifies whether a "delete All" button was previousely pressed
|
||||||
|
private boolean fDeleteAll = false;
|
||||||
|
//specifies whether the set of the user-defined variables was changed by a user
|
||||||
|
//and the changes are not applied to the User Variable Supplier
|
||||||
|
private boolean fModified = false;
|
||||||
|
//holds the visible state.
|
||||||
|
private boolean fVisible = false;
|
||||||
|
//specifies whether the "show parent level variables" checkbox should be created
|
||||||
|
private boolean fShowParentViewCheckBox = true;
|
||||||
|
//inexistent context
|
||||||
|
private static final Object fInexistentContext = new Object();
|
||||||
|
//the context for which the variables are displayed
|
||||||
|
private Object fContext = fInexistentContext;
|
||||||
|
//specifies whether the parent level variables should be displayed
|
||||||
|
private boolean fShowParentVariables = false;
|
||||||
|
|
||||||
|
private IContextInfo fSystemContextInfo;
|
||||||
|
private IContextInfo fCurrentContextInfo;
|
||||||
|
private IContextInfo fParentContextInfo;
|
||||||
|
private boolean fUseDefaultParentContextInfo = true;
|
||||||
|
|
||||||
|
//the user defined variable supplier
|
||||||
|
private UserDefinedEnvironmentSupplier fUserSupplier;
|
||||||
|
//editable list that displayes user-defined variables
|
||||||
|
private ListDialogField fEditableList;
|
||||||
|
//non-editable list that holds all variables other than user-defined ones
|
||||||
|
private ListDialogField fNonEditableList;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* widgets
|
||||||
|
*/
|
||||||
|
//show parent level variables check-box
|
||||||
|
private Button fShowParentButton;
|
||||||
|
//parent composite
|
||||||
|
private Composite fParent;
|
||||||
|
|
||||||
|
private class SystemContextInfo extends DefaultContextInfo{
|
||||||
|
protected SystemContextInfo(Object context){
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo#getSuppliers(java.lang.Object)
|
||||||
|
*/
|
||||||
|
protected IEnvironmentVariableSupplier[] getSuppliers(Object context){
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
|
||||||
|
if(suppliers == null || suppliers.length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List list = new ArrayList();
|
||||||
|
for(int i = 0; i < suppliers.length; i++){
|
||||||
|
if(!(suppliers[i] instanceof UserDefinedEnvironmentSupplier))
|
||||||
|
list.add(suppliers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IEnvironmentVariableSupplier[])list.toArray(new IEnvironmentVariableSupplier[list.size()]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
|
||||||
|
*/
|
||||||
|
public IContextInfo getNext(){
|
||||||
|
if(fUseDefaultParentContextInfo)
|
||||||
|
return super.getNext();
|
||||||
|
return fParentContextInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CurrentContextInfo extends DefaultContextInfo{
|
||||||
|
protected CurrentContextInfo(Object context){
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.DefaultContextInfo#getSuppliers(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public IEnvironmentVariableSupplier[] getSuppliers(Object context){
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = super.getSuppliers(context);
|
||||||
|
if(fParentContextInfo == null){
|
||||||
|
int i = 0;
|
||||||
|
}
|
||||||
|
if(suppliers == null || suppliers.length == 0)
|
||||||
|
return suppliers;
|
||||||
|
if(!(suppliers[0] instanceof UserDefinedEnvironmentSupplier))
|
||||||
|
return suppliers;
|
||||||
|
|
||||||
|
List list = new ArrayList(suppliers.length);
|
||||||
|
list.add(new UIVariableSupplier());
|
||||||
|
|
||||||
|
for(int i = 1; i < suppliers.length; i++){
|
||||||
|
list.add(suppliers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IEnvironmentVariableSupplier[])list.toArray(new IEnvironmentVariableSupplier[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.internal.envvar.IContextInfo#getNext()
|
||||||
|
*/
|
||||||
|
public IContextInfo getNext(){
|
||||||
|
if(fUseDefaultParentContextInfo)
|
||||||
|
return super.getNext();
|
||||||
|
return fParentContextInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UIVariableSupplier implements IEnvironmentVariableSupplier{
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariable(java.lang.String, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String name, Object context){
|
||||||
|
if(context != fContext)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return (IBuildEnvironmentVariable)getUserVariables().get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableSupplier#getVariables(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(Object context){
|
||||||
|
if(context != fContext)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Collection vars = getUserVariables().values();
|
||||||
|
return (IBuildEnvironmentVariable[])vars.toArray(new IBuildEnvironmentVariable[vars.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ListAdapter implements IListAdapter, IDialogFieldListener {
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#customButtonPressed(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField, int)
|
||||||
|
*/
|
||||||
|
public void customButtonPressed(ListDialogField field, int index) {
|
||||||
|
if(field == fEditableList)
|
||||||
|
handleCustomButtonPressed(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#selectionChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField)
|
||||||
|
*/
|
||||||
|
public void selectionChanged(ListDialogField field) {
|
||||||
|
handleSelectionChanged(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter#doubleClicked(org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField)
|
||||||
|
*/
|
||||||
|
public void doubleClicked(ListDialogField field) {
|
||||||
|
if (isEditable(field) && field.getSelectedElements().size() == 1)
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_EDIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener#dialogFieldChanged(org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField)
|
||||||
|
*/
|
||||||
|
public void dialogFieldChanged(DialogField field) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EnvironmentLabelProvider extends LabelProvider implements ITableLabelProvider, IFontProvider , ITableFontProvider, IColorProvider{
|
||||||
|
private boolean fUser;
|
||||||
|
public EnvironmentLabelProvider(boolean user){
|
||||||
|
fUser = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
return null; // JavaPluginImages.get(JavaPluginImages.IMG_OBJS_REFACTORING_INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public String getText(Object element) {
|
||||||
|
return getColumnText(element, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||||
|
*/
|
||||||
|
public Image getColumnImage(Object element, int columnIndex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||||
|
*/
|
||||||
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)element;
|
||||||
|
switch(columnIndex){
|
||||||
|
case 0:
|
||||||
|
return var.getName();
|
||||||
|
case 1:
|
||||||
|
if(var.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
|
return ManagedBuilderUIMessages.getResourceString(VALUE_UNDEF);
|
||||||
|
return var.getValue();
|
||||||
|
}
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Font getFont(Object element) {
|
||||||
|
return getFont(element, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object, int)
|
||||||
|
*/
|
||||||
|
public Font getFont(Object element, int columnIndex) {
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)element;
|
||||||
|
|
||||||
|
switch(columnIndex){
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if(var.getOperation() == IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
|
return JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!fUser && getUserVariable(var.getName()) != null)
|
||||||
|
return JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Color getForeground(Object element){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Color getBackground(Object element){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* constructor
|
||||||
|
*/
|
||||||
|
public EnvironmentBlock(ICOptionContainer parent, String title, boolean editable, boolean showParentViewCheckBox){
|
||||||
|
super(title);
|
||||||
|
super.setContainer(parent);
|
||||||
|
|
||||||
|
ListAdapter adapter = new ListAdapter();
|
||||||
|
|
||||||
|
if(editable){
|
||||||
|
String[] buttons= new String[] {
|
||||||
|
ManagedBuilderUIMessages.getResourceString(BUTTON_NEW),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(BUTTON_EDIT),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(BUTTON_UNDEF),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(BUTTON_DELETE),
|
||||||
|
};
|
||||||
|
|
||||||
|
fEditableList= new ListDialogField(adapter, buttons, new EnvironmentLabelProvider(true));
|
||||||
|
fEditableList.setDialogFieldListener(adapter);
|
||||||
|
|
||||||
|
String[] columnsHeaders= new String[] {
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
||||||
|
};
|
||||||
|
|
||||||
|
fEditableList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
|
||||||
|
fEditableList.setViewerSorter(new ViewerSorter());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//create non-editable list
|
||||||
|
fNonEditableList= new ListDialogField(adapter, null, new EnvironmentLabelProvider(false));
|
||||||
|
fNonEditableList.setDialogFieldListener(adapter);
|
||||||
|
|
||||||
|
String[] columnsHeaders= new String[] {
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_NAME),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(HEADER_VALUE),
|
||||||
|
};
|
||||||
|
|
||||||
|
fNonEditableList.setTableColumns(new ListDialogField.ColumnsDescription(columnsHeaders, true));
|
||||||
|
fNonEditableList.setViewerSorter(new ViewerSorter());
|
||||||
|
|
||||||
|
fShowParentViewCheckBox = showParentViewCheckBox;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the map containing the user-defined variables
|
||||||
|
*/
|
||||||
|
private Map getUserVariables(){
|
||||||
|
if(fUserSupplier == null)
|
||||||
|
return null;
|
||||||
|
Map map = new HashMap();
|
||||||
|
|
||||||
|
if(!fDeleteAll){
|
||||||
|
IBuildEnvironmentVariable vars[] = fUserSupplier.getVariables(fContext);
|
||||||
|
if(vars != null) {
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
String name = vars[i].getName();
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
map.put(name,vars[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iter = getDeletedUserVariableNames().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
map.remove((String)iter.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = getAddedUserVariables().values().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
|
||||||
|
String name = var.getName();
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
map.put(name,var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the HashSet holding the names of the user-deleted variables
|
||||||
|
*/
|
||||||
|
private HashSet getDeletedUserVariableNames(){
|
||||||
|
if(fDeletedUserVariableNames == null)
|
||||||
|
fDeletedUserVariableNames = new HashSet();
|
||||||
|
return fDeletedUserVariableNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the map holding user-created.modified variables
|
||||||
|
*/
|
||||||
|
private Map getAddedUserVariables(){
|
||||||
|
if(fAddedUserVariables == null)
|
||||||
|
fAddedUserVariables = new HashMap();
|
||||||
|
return fAddedUserVariables;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* creates a user variable
|
||||||
|
* the variables created are stored in the fAddedUserVariables Map, and are not actually added to the user supplier
|
||||||
|
* the applyUserVariables() should be called to store those variabes to the user supplier
|
||||||
|
*/
|
||||||
|
private void addUserVariable(String name, String value, int op, String delimiter){
|
||||||
|
if(!canCreate(name))
|
||||||
|
return;
|
||||||
|
fDeleteAll = false;
|
||||||
|
BuildEnvVar newVar = new BuildEnvVar(name,value,op,delimiter);
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
getDeletedUserVariableNames().remove(name);
|
||||||
|
getAddedUserVariables().put(name,newVar);
|
||||||
|
|
||||||
|
fModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* deletes a user variable
|
||||||
|
* the variables deleted are stored in the fDeletedUserVariableNames HashSet, and are not actually deleted from the user supplier
|
||||||
|
* the applyUserVariables() should be called to delete those variabes from the user supplier
|
||||||
|
*/
|
||||||
|
private void deleteUserVariable(String name){
|
||||||
|
fDeleteAll = false;
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
getAddedUserVariables().remove(name);
|
||||||
|
getDeletedUserVariableNames().add(name);
|
||||||
|
|
||||||
|
fModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* deletes all user variables
|
||||||
|
* the applyUserVariables() should be called to delete those variabes from the user supplier
|
||||||
|
*/
|
||||||
|
private void deleteAllUserVariables(){
|
||||||
|
fDeleteAll = true;
|
||||||
|
getDeletedUserVariableNames().clear();
|
||||||
|
getAddedUserVariables().clear();
|
||||||
|
|
||||||
|
fModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns whether the user variables were modified
|
||||||
|
*/
|
||||||
|
public boolean isModified(){
|
||||||
|
return fModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sets the modify state
|
||||||
|
*/
|
||||||
|
public void setModified(boolean modified){
|
||||||
|
fModified = modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns a user variable of a given name
|
||||||
|
*/
|
||||||
|
private IBuildEnvironmentVariable getUserVariable(String name){
|
||||||
|
Map vars = getUserVariables();
|
||||||
|
if(vars == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(!ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
name = name.toUpperCase();
|
||||||
|
return (IBuildEnvironmentVariable)vars.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* applies user variables.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void applyUserVariables(){
|
||||||
|
if(fUserSupplier != null){
|
||||||
|
if(fDeleteAll){
|
||||||
|
fUserSupplier.deleteAll(fContext);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Iterator iter = getDeletedUserVariableNames().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
fUserSupplier.deleteVariable((String)iter.next(),fContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
iter = getAddedUserVariables().values().iterator();
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildEnvironmentVariable var = (IBuildEnvironmentVariable)iter.next();
|
||||||
|
fUserSupplier.createVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter(),fContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
getDeletedUserVariableNames().clear();
|
||||||
|
getAddedUserVariables().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* applies user variables and asks the user supplier to serialize
|
||||||
|
*/
|
||||||
|
private void storeUserVariables(){
|
||||||
|
applyUserVariables();
|
||||||
|
if(fUserSupplier != null)
|
||||||
|
fUserSupplier.serialize(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the user variable selection was changed
|
||||||
|
*/
|
||||||
|
private void handleSelectionChanged(ListDialogField field){
|
||||||
|
if(isEditable(field)){
|
||||||
|
List selectedElements= field.getSelectedElements();
|
||||||
|
field.enableButton(IDX_BUTTON_EDIT, selectedElements.size() == 1);
|
||||||
|
field.enableButton(IDX_BUTTON_UNDEF, selectedElements.size() > 0);
|
||||||
|
field.enableButton(IDX_BUTTON_DELETE, selectedElements.size() > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* answers whether the list values can be edited
|
||||||
|
*/
|
||||||
|
private boolean isEditable(ListDialogField field) {
|
||||||
|
return field == fEditableList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when a custom button was pressed
|
||||||
|
*/
|
||||||
|
private void handleCustomButtonPressed(int index){
|
||||||
|
switch(index){
|
||||||
|
case IDX_BUTTON_NEW:{
|
||||||
|
NewEnvVarDialog dlg = new NewEnvVarDialog(fParent.getShell(),this,null);
|
||||||
|
if(dlg.open() == Dialog.OK){
|
||||||
|
IBuildEnvironmentVariable var = dlg.getDefinedVariable();
|
||||||
|
if(var != null){
|
||||||
|
addUserVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
|
||||||
|
updateValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IDX_BUTTON_EDIT:{
|
||||||
|
IBuildEnvironmentVariable vars[] = getSelectedUserVariables();
|
||||||
|
if(vars != null && vars.length == 1){
|
||||||
|
NewEnvVarDialog dlg = new NewEnvVarDialog(fParent.getShell(),this,getUserVariable(vars[0].getName()));
|
||||||
|
if(dlg.open() == Dialog.OK){
|
||||||
|
IBuildEnvironmentVariable var = dlg.getDefinedVariable();
|
||||||
|
if(var != null){
|
||||||
|
addUserVariable(var.getName(),var.getValue(),var.getOperation(),var.getDelimiter());
|
||||||
|
updateValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IDX_BUTTON_UNDEF:{
|
||||||
|
IBuildEnvironmentVariable vars[] = getSelectedUserVariables();
|
||||||
|
if(vars != null){
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
addUserVariable(vars[i].getName(),null,IBuildEnvironmentVariable.ENVVAR_REMOVE,null);
|
||||||
|
}
|
||||||
|
updateValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IDX_BUTTON_DELETE:{
|
||||||
|
IBuildEnvironmentVariable vars[] = getSelectedUserVariables();
|
||||||
|
if(vars != null && vars.length > 0){
|
||||||
|
if(MessageDialog.openQuestion(fParent.getShell(),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(DELETE_CONFIRM_TITLE),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(DELETE_CONFIRM_MESSAGE))){
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
deleteUserVariable(vars[i].getName());
|
||||||
|
}
|
||||||
|
updateValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returnes the selected user-defined variables
|
||||||
|
*/
|
||||||
|
private IBuildEnvironmentVariable[] getSelectedUserVariables(){
|
||||||
|
if(fEditableList == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
List list = fEditableList.getSelectedElements();
|
||||||
|
return (IBuildEnvironmentVariable[])list.toArray(new IBuildEnvironmentVariable[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sets the context for which the variables should be displayed
|
||||||
|
*/
|
||||||
|
public void setContext(Object context){
|
||||||
|
if(context == fContext)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fContext = context;
|
||||||
|
|
||||||
|
IEnvironmentVariableProvider provider = ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
|
IEnvironmentVariableSupplier suppliers[] = provider.getSuppliers(fContext);
|
||||||
|
if(suppliers != null && suppliers.length != 0 && suppliers[0] instanceof UserDefinedEnvironmentSupplier){
|
||||||
|
fUserSupplier = (UserDefinedEnvironmentSupplier)suppliers[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
fSystemContextInfo = new SystemContextInfo(context);
|
||||||
|
}catch(Exception e){
|
||||||
|
fSystemContextInfo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
fCurrentContextInfo = new CurrentContextInfo(context);
|
||||||
|
}catch(Exception e){
|
||||||
|
fCurrentContextInfo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentContextInfo(IContextInfo info){
|
||||||
|
fParentContextInfo = info;
|
||||||
|
fUseDefaultParentContextInfo = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetDefaultParentContextInfo(){
|
||||||
|
fUseDefaultParentContextInfo = true;
|
||||||
|
fParentContextInfo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IContextInfo getContextInfo(){
|
||||||
|
return fCurrentContextInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
if(fUserSupplier == null)
|
||||||
|
return;
|
||||||
|
storeUserVariables();
|
||||||
|
setModified(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||||
|
*/
|
||||||
|
public void performDefaults() {
|
||||||
|
if(MessageDialog.openQuestion(fParent.getShell(),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(DELETE_ALL_CONFIRM_TITLE),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(DELETE_ALL_CONFIRM_MESSAGE))){
|
||||||
|
deleteAllUserVariables();
|
||||||
|
updateValues();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* updates both user- and sytem- variables tables.
|
||||||
|
*/
|
||||||
|
public void updateValues(){
|
||||||
|
updateUserVariables();
|
||||||
|
updateSystemVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* apdates a user-defined variables table
|
||||||
|
*/
|
||||||
|
private void updateUserVariables(){
|
||||||
|
if(fEditableList == null || fContext == fInexistentContext)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fEditableList.selectFirstElement();
|
||||||
|
handleSelectionChanged(fEditableList);
|
||||||
|
|
||||||
|
List list = null;
|
||||||
|
if(fUserSupplier != null) {
|
||||||
|
Collection vars = getUserVariables().values();
|
||||||
|
Iterator iter = vars.iterator();
|
||||||
|
|
||||||
|
list = new ArrayList(vars.size());
|
||||||
|
while(iter.hasNext()){
|
||||||
|
IBuildEnvironmentVariable userVar = (IBuildEnvironmentVariable)iter.next();
|
||||||
|
IBuildEnvironmentVariable sysVar = getSystemVariable(userVar.getName(),true);
|
||||||
|
IBuildEnvironmentVariable var = EnvVarOperationProcessor.performOperation(sysVar,userVar);
|
||||||
|
if(var != null)
|
||||||
|
list.add(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(list != null)
|
||||||
|
fEditableList.setElements(list);
|
||||||
|
else
|
||||||
|
fEditableList.removeAllElements();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* apdates a system-defined variables table
|
||||||
|
*/
|
||||||
|
private void updateSystemVariables(){
|
||||||
|
if(fNonEditableList == null || fContext == fInexistentContext)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List list = null;
|
||||||
|
IBuildEnvironmentVariable vars[] = getSystemVariables(fShowParentVariables);
|
||||||
|
if(vars != null && vars.length != 0){
|
||||||
|
list = new ArrayList(vars.length);
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
list.add(vars[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(list != null)
|
||||||
|
fNonEditableList.setElements(list);
|
||||||
|
else
|
||||||
|
fNonEditableList.removeAllElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return a system variable of a given name
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getSystemVariable(String name,boolean includeParentLevels){
|
||||||
|
if(name == null)
|
||||||
|
return null;
|
||||||
|
if(fSystemContextInfo == null)
|
||||||
|
return null;
|
||||||
|
if(!canDisplay(name))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
EnvironmentVariableProvider provider = (EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
|
return provider.getVariable(name,fSystemContextInfo,includeParentLevels);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns an array of system variables
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getSystemVariables(boolean includeParentLevels){
|
||||||
|
EnvironmentVariableProvider provider = (EnvironmentVariableProvider)ManagedBuildManager.getEnvironmentVariableProvider();
|
||||||
|
EnvVarCollector variables = provider.getVariables(fSystemContextInfo,includeParentLevels);
|
||||||
|
if(variables == null)
|
||||||
|
return null;
|
||||||
|
return filterDisplayedVariables(variables.toArray(false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
|
*/
|
||||||
|
public void createControl(Composite parent) {
|
||||||
|
fParent = parent;
|
||||||
|
FormLayout layout= new FormLayout();
|
||||||
|
FormData fd;
|
||||||
|
Control buttonsControl = null;
|
||||||
|
|
||||||
|
Composite composite= new Composite(parent, SWT.NULL);
|
||||||
|
composite.setLayout(layout);
|
||||||
|
if(fEditableList != null){
|
||||||
|
Label nameLabel = new Label(composite, SWT.LEFT);
|
||||||
|
nameLabel.setFont(composite.getFont());
|
||||||
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(USER_VAR));
|
||||||
|
fd = new FormData();
|
||||||
|
fd.top = new FormAttachment(0,2);
|
||||||
|
fd.left = new FormAttachment(0,0);
|
||||||
|
nameLabel.setLayoutData(fd);
|
||||||
|
|
||||||
|
Control listControl= fEditableList.getListControl(composite);
|
||||||
|
fEditableList.getTableViewer().getTable().addKeyListener(new KeyListener(){
|
||||||
|
public void keyPressed(KeyEvent e){
|
||||||
|
if(e.keyCode == SWT.DEL)
|
||||||
|
handleCustomButtonPressed(IDX_BUTTON_DELETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyReleased(KeyEvent e){
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonsControl= fEditableList.getButtonBox(composite);
|
||||||
|
|
||||||
|
fd = new FormData();
|
||||||
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
|
fd.right = new FormAttachment(100,0);
|
||||||
|
buttonsControl.setLayoutData(fd);
|
||||||
|
|
||||||
|
fd = new FormData();
|
||||||
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
|
fd.left = new FormAttachment(0,0);
|
||||||
|
fd.right = new FormAttachment(buttonsControl,-5);
|
||||||
|
fd.bottom = new FormAttachment(50,0);
|
||||||
|
listControl.setLayoutData(fd);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Label nameLabel = new Label(composite, SWT.LEFT);
|
||||||
|
nameLabel.setFont(composite.getFont());
|
||||||
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(SYSTEM_VAR));
|
||||||
|
fd = new FormData();
|
||||||
|
if(fEditableList != null)
|
||||||
|
fd.top = new FormAttachment(50,2);
|
||||||
|
else
|
||||||
|
fd.top = new FormAttachment(0,2);
|
||||||
|
fd.left = new FormAttachment(0,0);
|
||||||
|
nameLabel.setLayoutData(fd);
|
||||||
|
|
||||||
|
|
||||||
|
if(fShowParentViewCheckBox){
|
||||||
|
// Create a "show parent levels" button
|
||||||
|
fShowParentButton = new Button(composite, SWT.CHECK);
|
||||||
|
fShowParentButton.setFont(composite.getFont());
|
||||||
|
fShowParentButton.setText(ManagedBuilderUIMessages.getResourceString(BUTTON_CHECK_SHOW_PARENT));
|
||||||
|
fd = new FormData();
|
||||||
|
fd.left = new FormAttachment(0,0);
|
||||||
|
fd.bottom = new FormAttachment(100,0);
|
||||||
|
fShowParentButton.setLayoutData(fd);
|
||||||
|
fShowParentButton.setSelection(fShowParentVariables);
|
||||||
|
fShowParentButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
fShowParentVariables = fShowParentButton.getSelection();
|
||||||
|
updateSystemVariables();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Control listControl= fNonEditableList.getListControl(composite);
|
||||||
|
fd = new FormData();
|
||||||
|
fd.top = new FormAttachment(nameLabel,0);
|
||||||
|
fd.left = new FormAttachment(0,0);
|
||||||
|
if(buttonsControl != null)
|
||||||
|
fd.right = new FormAttachment(buttonsControl,-5);
|
||||||
|
else
|
||||||
|
fd.right = new FormAttachment(100,0);
|
||||||
|
if(fShowParentButton != null)
|
||||||
|
fd.bottom = new FormAttachment(fShowParentButton,-2);
|
||||||
|
else
|
||||||
|
fd.bottom = new FormAttachment(100,0);
|
||||||
|
|
||||||
|
listControl.setLayoutData(fd);
|
||||||
|
|
||||||
|
this.setControl(composite);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
||||||
|
*/
|
||||||
|
public void setVisible(boolean visible){
|
||||||
|
fVisible = visible;
|
||||||
|
if(visible)
|
||||||
|
updateValues();
|
||||||
|
super.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* return the context for which the variables are displayed
|
||||||
|
*/
|
||||||
|
public Object getContext(){
|
||||||
|
return fContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayParentVariables(boolean display){
|
||||||
|
fShowParentVariables = display;
|
||||||
|
if(fShowParentButton != null)
|
||||||
|
fShowParentButton.setSelection(fShowParentVariables);
|
||||||
|
updateSystemVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* answers whether the given variable should be displayed in UI or not
|
||||||
|
*/
|
||||||
|
protected boolean canDisplay(String name){
|
||||||
|
return canCreate(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* answers whether the variable of a given name can be sreated
|
||||||
|
*/
|
||||||
|
public boolean canCreate(String name){
|
||||||
|
if((name = EnvVarOperationProcessor.normalizeName(name)) == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(fHiddenVariables != null){
|
||||||
|
for(int i = 0; i < fHiddenVariables.length; i++){
|
||||||
|
if(name.equals(fHiddenVariables[i]))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* filteres the names to be displayed
|
||||||
|
*/
|
||||||
|
protected IBuildEnvironmentVariable[] filterDisplayedVariables(IBuildEnvironmentVariable variables[]){
|
||||||
|
if(variables == null || variables.length == 0)
|
||||||
|
return variables;
|
||||||
|
|
||||||
|
IBuildEnvironmentVariable filtered[] = new IBuildEnvironmentVariable[variables.length];
|
||||||
|
int filteredNum = 0;
|
||||||
|
for(int i = 0; i < variables.length; i++){
|
||||||
|
if(canDisplay(variables[i].getName()))
|
||||||
|
filtered[filteredNum++] = variables[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(filteredNum != filtered.length){
|
||||||
|
IBuildEnvironmentVariable vars[] = new IBuildEnvironmentVariable[filteredNum];
|
||||||
|
for(int i = 0; i < filteredNum; i++)
|
||||||
|
vars[i] = filtered[i];
|
||||||
|
filtered = vars;
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,263 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.AbstractCOptionPage;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* displays the tab-folder. Each tab of the tab-folder
|
||||||
|
* contains the EnvironmentBlock representinf the environment
|
||||||
|
* for the given context
|
||||||
|
* Whe used in the BuildPropertyPage the tab-folder contains the following tabs:
|
||||||
|
* 1. a tab containing configuration-specific variables
|
||||||
|
* 2. a tab containing project-specific variables
|
||||||
|
*
|
||||||
|
* otherwise the tab-folder contains the following tabs:
|
||||||
|
* 1. a tab containing workspace-specific variables
|
||||||
|
* 2. a tab containing eclipse process environment variables
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class EnvironmentSetBlock extends AbstractCOptionPage {
|
||||||
|
/*
|
||||||
|
* String constants
|
||||||
|
*/
|
||||||
|
private static final String PREFIX = "EnvironmentSetBlock"; //$NON-NLS-1$
|
||||||
|
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||||
|
private static final String ENVIRONMENT_LABEL = LABEL + ".environment"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String ENVIRONMENT_GROUP_LABEL = LABEL + ".environment.group"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String TAB = LABEL + ".tab"; //$NON-NLS-1$
|
||||||
|
private static final String TAB_CONFIGURATION = TAB + ".configuration"; //$NON-NLS-1$
|
||||||
|
private static final String TAB_PROJECT = TAB + ".project"; //$NON-NLS-1$
|
||||||
|
private static final String TAB_WORKSPACE = TAB + ".workspace"; //$NON-NLS-1$
|
||||||
|
private static final String TAB_ECLIPSE = TAB + ".eclipse"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private EnvironmentTabFolder fEnvTabs;
|
||||||
|
private EnvironmentBlock fEnvBlock;
|
||||||
|
|
||||||
|
private ICOptionContainer fParentContainer;
|
||||||
|
|
||||||
|
private class EnvironmentTabFolder extends TabFolderOptionBlock{
|
||||||
|
private EnvironmentBlock fFolderTabs[];
|
||||||
|
public EnvironmentTabFolder() {
|
||||||
|
super(fParentContainer, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnvironmentBlock[] getTabs(){
|
||||||
|
return fFolderTabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
|
||||||
|
*/
|
||||||
|
protected void addTabs(){
|
||||||
|
if(fParentContainer instanceof BuildPropertyPage) {
|
||||||
|
// the EnvironmentSetBlock is used whithing the Build Property Page
|
||||||
|
// create the project and configuration tabs
|
||||||
|
fFolderTabs = new EnvironmentBlock[2];
|
||||||
|
addTab(fFolderTabs[0] = new EnvironmentBlock(fParentContainer,
|
||||||
|
ManagedBuilderUIMessages.getResourceString(TAB_CONFIGURATION),
|
||||||
|
true,
|
||||||
|
true));
|
||||||
|
addTab(fFolderTabs[1] = new EnvironmentBlock(fParentContainer,
|
||||||
|
ManagedBuilderUIMessages.getResourceString(TAB_PROJECT),
|
||||||
|
true,
|
||||||
|
true));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// the EnvironmentSetBlock is used whithing the Build Preference Page
|
||||||
|
// create the workspace and eclipse environment tabs
|
||||||
|
fFolderTabs = new EnvironmentBlock[2];
|
||||||
|
addTab(fFolderTabs[0] = new EnvironmentBlock(fParentContainer,
|
||||||
|
ManagedBuilderUIMessages.getResourceString(TAB_WORKSPACE),
|
||||||
|
true,
|
||||||
|
true));
|
||||||
|
addTab(fFolderTabs[1] = new EnvironmentBlock(fParentContainer,
|
||||||
|
ManagedBuilderUIMessages.getResourceString(TAB_ECLIPSE),
|
||||||
|
false,
|
||||||
|
false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set the appropriate context data to the tabs
|
||||||
|
*/
|
||||||
|
public void updateContexts(){
|
||||||
|
if(fFolderTabs == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(fParentContainer instanceof BuildPropertyPage){
|
||||||
|
BuildPropertyPage page = (BuildPropertyPage)fParentContainer;
|
||||||
|
if(page.getSelectedConfiguration() != null)
|
||||||
|
fFolderTabs[1].setContext(page.getSelectedConfiguration().getManagedProject());
|
||||||
|
|
||||||
|
fFolderTabs[0].setContext(page.getSelectedConfiguration());
|
||||||
|
fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fFolderTabs[1].setContext(null);
|
||||||
|
|
||||||
|
fFolderTabs[0].setContext(ResourcesPlugin.getWorkspace());
|
||||||
|
fFolderTabs[0].setParentContextInfo(fFolderTabs[1].getContextInfo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public EnvironmentSetBlock(ICOptionContainer parent){
|
||||||
|
super(ManagedBuilderUIMessages.getResourceString(ENVIRONMENT_LABEL));
|
||||||
|
super.setContainer(parent);
|
||||||
|
fParentContainer = parent;
|
||||||
|
|
||||||
|
if(fParentContainer instanceof BuildPropertyPage)
|
||||||
|
fEnvTabs = new EnvironmentTabFolder();
|
||||||
|
else {
|
||||||
|
fEnvBlock = new EnvironmentBlock(fParentContainer,
|
||||||
|
ManagedBuilderUIMessages.getResourceString(TAB_WORKSPACE),
|
||||||
|
true,
|
||||||
|
false);
|
||||||
|
fEnvBlock.displayParentVariables(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performApply(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public void performApply(IProgressMonitor monitor) throws CoreException {
|
||||||
|
EnvironmentBlock tabs[] = getAllBlocks();
|
||||||
|
if(tabs != null){
|
||||||
|
for(int i = 0; i < tabs.length; i++)
|
||||||
|
tabs[i].performApply(monitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionPage#performDefaults()
|
||||||
|
*/
|
||||||
|
public void performDefaults() {
|
||||||
|
EnvironmentBlock tab = getSelectedBlock();
|
||||||
|
if(tab != null)
|
||||||
|
tab.performDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
|
||||||
|
*/
|
||||||
|
public void setVisible(boolean visible){
|
||||||
|
if(visible)
|
||||||
|
updateValues();
|
||||||
|
super.setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
|
||||||
|
*/
|
||||||
|
public void createControl(Composite parent) {
|
||||||
|
Control ctrl = null;
|
||||||
|
if(fEnvTabs != null){
|
||||||
|
Group group = new Group(parent, SWT.NONE);
|
||||||
|
group.setFont(parent.getFont());
|
||||||
|
group.setText(ManagedBuilderUIMessages.getResourceString(ENVIRONMENT_GROUP_LABEL));
|
||||||
|
group.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
GridLayout gl = new GridLayout();
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
group.setLayout(gl);
|
||||||
|
Control tabs = fEnvTabs.createContents(group);
|
||||||
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
|
tabs.setLayoutData(gd);
|
||||||
|
ctrl = group;
|
||||||
|
}
|
||||||
|
else if(fEnvBlock != null){
|
||||||
|
fEnvBlock.createControl(parent);
|
||||||
|
ctrl = fEnvBlock.getControl();
|
||||||
|
ctrl.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
setControl(ctrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateValues(){
|
||||||
|
EnvironmentBlock tab = getSelectedBlock();
|
||||||
|
|
||||||
|
updateContexts();
|
||||||
|
if(tab != null)
|
||||||
|
tab.updateValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConfigSelectionAllowed(){
|
||||||
|
EnvironmentBlock block = getSelectedBlock();
|
||||||
|
if(block != null)
|
||||||
|
return block.getContext() instanceof IConfiguration;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isModified(){
|
||||||
|
EnvironmentBlock tabs[] = getAllBlocks();
|
||||||
|
for(int i = 0; i < tabs.length; i++){
|
||||||
|
if(tabs[i].isModified())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModified(boolean modified){
|
||||||
|
EnvironmentBlock tabs[] = getAllBlocks();
|
||||||
|
for(int i = 0; i < tabs.length; i++){
|
||||||
|
tabs[i].setModified(modified);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the selected environment block
|
||||||
|
*/
|
||||||
|
protected EnvironmentBlock getSelectedBlock(){
|
||||||
|
if(fEnvTabs != null)
|
||||||
|
return (EnvironmentBlock)fEnvTabs.getCurrentPage();
|
||||||
|
return fEnvBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns all available environment blocks
|
||||||
|
*/
|
||||||
|
protected EnvironmentBlock[] getAllBlocks(){
|
||||||
|
if(fEnvTabs != null)
|
||||||
|
return fEnvTabs.getTabs();
|
||||||
|
else if(fEnvBlock != null)
|
||||||
|
return new EnvironmentBlock[]{fEnvBlock};
|
||||||
|
return new EnvironmentBlock[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* updates the context of each EnvironmentBlock
|
||||||
|
*/
|
||||||
|
protected void updateContexts(){
|
||||||
|
if(fEnvTabs != null)
|
||||||
|
fEnvTabs.updateContexts();
|
||||||
|
else if(fEnvBlock != null)
|
||||||
|
fEnvBlock.setContext(ResourcesPlugin.getWorkspace());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Copyright (c) 2002,2004 IBM Corporation and others.
|
* Copyright (c) 2002,2005 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Common Public License v0.5
|
* are made available under the terms of the Common Public License v0.5
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,18 +12,20 @@ package org.eclipse.cdt.managedbuilder.internal.ui;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPreferencePage;
|
||||||
|
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
|
||||||
|
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
|
||||||
import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
|
import org.eclipse.cdt.ui.dialogs.BinaryParserBlock;
|
||||||
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
|
import org.eclipse.cdt.ui.dialogs.ICOptionPage;
|
||||||
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
|
import org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock;
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.BuildPropertyPage;
|
|
||||||
import org.eclipse.cdt.managedbuilder.ui.properties.ResourceBuildPropertyPage;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
import org.eclipse.swt.widgets.Control;
|
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.ui.help.WorkbenchHelp;
|
import org.eclipse.ui.help.WorkbenchHelp;
|
||||||
|
|
||||||
public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
|
@ -32,6 +34,7 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
private BuildSettingsBlock buildSettingsBlock;
|
private BuildSettingsBlock buildSettingsBlock;
|
||||||
private ErrorParserBlock errParserBlock;
|
private ErrorParserBlock errParserBlock;
|
||||||
private BinaryParserBlock binaryParserBlock;
|
private BinaryParserBlock binaryParserBlock;
|
||||||
|
private EnvironmentSetBlock environmentBlock;
|
||||||
private Object element;
|
private Object element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +48,10 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
super(resParent, false);
|
super(resParent, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ManagedBuildOptionBlock(BuildPreferencePage wspParent){
|
||||||
|
super(wspParent, false);
|
||||||
|
}
|
||||||
|
|
||||||
public BuildPropertyPage getBuildPropertyPage() {
|
public BuildPropertyPage getBuildPropertyPage() {
|
||||||
return (BuildPropertyPage)fParent;
|
return (BuildPropertyPage)fParent;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +59,11 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
public ResourceBuildPropertyPage getResourceBuildPropertyPage() {
|
public ResourceBuildPropertyPage getResourceBuildPropertyPage() {
|
||||||
return (ResourceBuildPropertyPage)fParent;
|
return (ResourceBuildPropertyPage)fParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BuildPreferencePage getBuildPreferencePage() {
|
||||||
|
return (BuildPreferencePage)fParent;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
|
* @see org.eclipse.cdt.ui.dialogs.TabFolderOptionBlock#addTabs()
|
||||||
*/
|
*/
|
||||||
|
@ -62,8 +74,11 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent));
|
addTab(buildSettingsBlock = new BuildSettingsBlock((BuildPropertyPage) fParent));
|
||||||
addTab(errParserBlock = new ErrorParserBlock());
|
addTab(errParserBlock = new ErrorParserBlock());
|
||||||
addTab(binaryParserBlock = new BinaryParserBlock());
|
addTab(binaryParserBlock = new BinaryParserBlock());
|
||||||
|
addTab(environmentBlock = new EnvironmentSetBlock((BuildPropertyPage) fParent));
|
||||||
} else if (element instanceof IFile) {
|
} else if (element instanceof IFile) {
|
||||||
addTab(toolsSettingsBlock = new ToolsSettingsBlock((ResourceBuildPropertyPage) fParent, element));
|
addTab(toolsSettingsBlock = new ToolsSettingsBlock((ResourceBuildPropertyPage) fParent, element));
|
||||||
|
} else if (element instanceof IWorkspace) {
|
||||||
|
addTab(environmentBlock = new EnvironmentSetBlock((BuildPreferencePage) fParent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,6 +98,10 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
return errParserBlock;
|
return errParserBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EnvironmentSetBlock getEnvironmentBlock() {
|
||||||
|
return environmentBlock;
|
||||||
|
}
|
||||||
|
|
||||||
public Control createContents(Composite parent, Object element) {
|
public Control createContents(Composite parent, Object element) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
Control control = super.createContents( parent );
|
Control control = super.createContents( parent );
|
||||||
|
@ -114,6 +133,8 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
// TODO
|
// TODO
|
||||||
//getBinaryParserBlock().initializeValues();
|
//getBinaryParserBlock().initializeValues();
|
||||||
}
|
}
|
||||||
|
if(getEnvironmentBlock()!= null) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateValues() {
|
public void updateValues() {
|
||||||
|
@ -131,10 +152,17 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
// TODO
|
// TODO
|
||||||
//getBinaryParserBlock().updateValues();
|
//getBinaryParserBlock().updateValues();
|
||||||
}
|
}
|
||||||
|
if(getCurrentPage() instanceof EnvironmentSetBlock) {
|
||||||
|
((EnvironmentSetBlock)getCurrentPage()).updateValues();
|
||||||
|
}
|
||||||
} else if( element instanceof IFile) {
|
} else if( element instanceof IFile) {
|
||||||
if (getToolsSettingsBlock() != null) {
|
if (getToolsSettingsBlock() != null) {
|
||||||
getToolsSettingsBlock().updateValues();
|
getToolsSettingsBlock().updateValues();
|
||||||
}
|
}
|
||||||
|
} else if(element instanceof IWorkspace) {
|
||||||
|
if(getEnvironmentBlock() != null) {
|
||||||
|
getEnvironmentBlock().updateValues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,10 +182,17 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
// TODO
|
// TODO
|
||||||
//getBinaryParserBlock().setValues();
|
//getBinaryParserBlock().setValues();
|
||||||
}
|
}
|
||||||
|
if(getEnvironmentBlock() != null) {
|
||||||
|
getEnvironmentBlock().updateValues();
|
||||||
|
}
|
||||||
} else if (element instanceof IFile) {
|
} else if (element instanceof IFile) {
|
||||||
if (getToolsSettingsBlock() != null) {
|
if (getToolsSettingsBlock() != null) {
|
||||||
getToolsSettingsBlock().updateValues();
|
getToolsSettingsBlock().updateValues();
|
||||||
}
|
}
|
||||||
|
} else if (element instanceof IWorkspace) {
|
||||||
|
if(getEnvironmentBlock() != null) {
|
||||||
|
getEnvironmentBlock().updateValues();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,10 +212,15 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
// TODO
|
// TODO
|
||||||
//getBinaryParserBlock().removeValues(id);
|
//getBinaryParserBlock().removeValues(id);
|
||||||
}
|
}
|
||||||
|
if(getEnvironmentBlock()!= null) {
|
||||||
|
}
|
||||||
} else if (element instanceof IFile) {
|
} else if (element instanceof IFile) {
|
||||||
if (getToolsSettingsBlock()!= null) {
|
if (getToolsSettingsBlock()!= null) {
|
||||||
getToolsSettingsBlock().removeValues(id);
|
getToolsSettingsBlock().removeValues(id);
|
||||||
}
|
}
|
||||||
|
} else if (element instanceof IWorkspace) {
|
||||||
|
if(getEnvironmentBlock()!= null) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,10 +239,17 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
if (getCurrentPage() instanceof BinaryParserBlock) {
|
if (getCurrentPage() instanceof BinaryParserBlock) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if(getCurrentPage() instanceof EnvironmentSetBlock) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else if( element instanceof IFile) {
|
} else if( element instanceof IFile) {
|
||||||
if (getCurrentPage() instanceof ToolsSettingsBlock) {
|
if (getCurrentPage() instanceof ToolsSettingsBlock) {
|
||||||
return toolsSettingsBlock.getPreferenceStore();
|
return toolsSettingsBlock.getPreferenceStore();
|
||||||
}
|
}
|
||||||
|
} else if (element instanceof IWorkspace) {
|
||||||
|
if(getEnvironmentBlock()!= null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -218,11 +265,18 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
// Currently, other settings are per-config, while binary parser settings are per-project
|
// Currently, other settings are per-config, while binary parser settings are per-project
|
||||||
if (tab instanceof BinaryParserBlock) {
|
if (tab instanceof BinaryParserBlock) {
|
||||||
((BuildPropertyPage)fParent).enableConfigSelection(false);
|
((BuildPropertyPage)fParent).enableConfigSelection(false);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if(element instanceof IProject) {
|
if(element instanceof IProject) {
|
||||||
|
if(tab instanceof EnvironmentSetBlock){
|
||||||
|
((BuildPropertyPage)fParent).enableConfigSelection(
|
||||||
|
((EnvironmentSetBlock)tab).isConfigSelectionAllowed());
|
||||||
|
}
|
||||||
|
else
|
||||||
((BuildPropertyPage)fParent).enableConfigSelection(true);
|
((BuildPropertyPage)fParent).enableConfigSelection(true);
|
||||||
} else if ( element instanceof IFile) {
|
} else if ( element instanceof IFile) {
|
||||||
((ResourceBuildPropertyPage)fParent).enableConfigSelection(true);
|
((ResourceBuildPropertyPage)fParent).enableConfigSelection(true);
|
||||||
|
} else if (element instanceof IWorkspace) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,6 +296,8 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
((ErrorParserBlock)tab).setDirty(b);
|
((ErrorParserBlock)tab).setDirty(b);
|
||||||
} else if (tab instanceof BinaryParserBlock) {
|
} else if (tab instanceof BinaryParserBlock) {
|
||||||
//TODO ManagedBuildSystem needs its own binary parser block
|
//TODO ManagedBuildSystem needs its own binary parser block
|
||||||
|
} else if(tab instanceof EnvironmentSetBlock) {
|
||||||
|
((EnvironmentSetBlock)tab).setModified(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,6 +318,8 @@ public class ManagedBuildOptionBlock extends TabFolderOptionBlock {
|
||||||
if (((ErrorParserBlock)tab).isDirty()) return true;
|
if (((ErrorParserBlock)tab).isDirty()) return true;
|
||||||
} else if (tab instanceof BinaryParserBlock) {
|
} else if (tab instanceof BinaryParserBlock) {
|
||||||
//TODO ManagedBuildSystem needs its own binary parser block
|
//TODO ManagedBuildSystem needs its own binary parser block
|
||||||
|
} else if(tab instanceof EnvironmentSetBlock) {
|
||||||
|
return ((EnvironmentSetBlock)tab).isModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,706 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.internal.ui;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.BuildEnvVar;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.envvar.EnvVarOperationProcessor;
|
||||||
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Event;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Listener;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the dialog used to create or edit the environment variable
|
||||||
|
*/
|
||||||
|
public class NewEnvVarDialog extends StatusDialog {
|
||||||
|
// String constants
|
||||||
|
private static final String PREFIX = "NewEnvVarDialog"; //$NON-NLS-1$
|
||||||
|
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||||
|
private static final String NAME = LABEL + ".name"; //$NON-NLS-1$
|
||||||
|
private static final String VALUE = LABEL + ".value"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String DELIMITER = LABEL + ".delimiter"; //$NON-NLS-1$
|
||||||
|
private static final String OPERATION = LABEL + ".operation"; //$NON-NLS-1$
|
||||||
|
private static final String OPERATION_REPLACE = OPERATION + ".replace"; //$NON-NLS-1$
|
||||||
|
private static final String OPERATION_PREPEND = OPERATION + ".prepend"; //$NON-NLS-1$
|
||||||
|
private static final String OPERATION_APPEND = OPERATION + ".append"; //$NON-NLS-1$
|
||||||
|
private static final String OPERATION_REMOVE = OPERATION + ".remove"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String VALUE_PREPEND = VALUE + ".prepend"; //$NON-NLS-1$
|
||||||
|
private static final String VALUE_APPEND = VALUE + ".append"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String TITLE_NEW = LABEL + ".title.new"; //$NON-NLS-1$
|
||||||
|
private static final String TITLE_EDIT = LABEL + ".title.edit"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String STATUS = LABEL + ".status"; //$NON-NLS-1$
|
||||||
|
private static final String STATUS_CANNOT_CTREATE = STATUS + ".cannot.create"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private static final String EMPTY_STRING = new String();
|
||||||
|
|
||||||
|
// The title of the dialog.
|
||||||
|
private String fTitle;
|
||||||
|
// hold the variable being edited(in the case of the "edit" mode)
|
||||||
|
private IBuildEnvironmentVariable fEditedVar;
|
||||||
|
//the environment block from which the dialog was called
|
||||||
|
private EnvironmentBlock fEnvVarBlock;
|
||||||
|
//the resulting variable. Can be accessed only when the dialog is closed
|
||||||
|
private IBuildEnvironmentVariable fResultingVar;
|
||||||
|
//the string that holds the value is used in the "replace" operation
|
||||||
|
private String fReplaceValue = null;
|
||||||
|
//the string that holds the value is used in the "append/prepend" operations
|
||||||
|
private String fAppPrepValue = null;
|
||||||
|
//specifies whether the fAppPrepValue holds the prepended or appended value
|
||||||
|
private boolean fAppPrepPrepend = true;
|
||||||
|
|
||||||
|
private String fTypedName;
|
||||||
|
|
||||||
|
// Widgets
|
||||||
|
// protected Text fVarNameEdit;
|
||||||
|
private Combo fVarNameEdit;
|
||||||
|
private Text fVarValueEdit;
|
||||||
|
private Label fDelimiterLabel;
|
||||||
|
private Text fDelimiterEdit;
|
||||||
|
private Combo fOpSelector;
|
||||||
|
private Label fOpVarValueLabel;
|
||||||
|
private Text fOpVarValueEdit;
|
||||||
|
|
||||||
|
public NewEnvVarDialog(Shell parentShell, EnvironmentBlock envBlock, IBuildEnvironmentVariable editedVar) {
|
||||||
|
super(parentShell);
|
||||||
|
if(editedVar != null)
|
||||||
|
fTitle = ManagedBuilderUIMessages.getResourceString(TITLE_EDIT);
|
||||||
|
else
|
||||||
|
fTitle = ManagedBuilderUIMessages.getResourceString(TITLE_NEW);
|
||||||
|
fEditedVar = editedVar;
|
||||||
|
fEnvVarBlock = envBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
|
protected void configureShell(Shell shell) {
|
||||||
|
super.configureShell(shell);
|
||||||
|
if (fTitle != null)
|
||||||
|
shell.setText(fTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||||
|
*/
|
||||||
|
protected Control createDialogArea(Composite parent) {
|
||||||
|
Composite comp = new Composite(parent, SWT.NULL);
|
||||||
|
comp.setFont(parent.getFont());
|
||||||
|
comp.setLayout(new GridLayout(2, false));
|
||||||
|
GridData gd = new GridData(GridData.FILL_BOTH);
|
||||||
|
comp.setLayoutData(gd);
|
||||||
|
|
||||||
|
Label nameLabel = new Label(comp, SWT.LEFT);
|
||||||
|
nameLabel.setFont(comp.getFont());
|
||||||
|
nameLabel.setText(ManagedBuilderUIMessages.getResourceString(NAME));
|
||||||
|
nameLabel.setLayoutData(new GridData());
|
||||||
|
|
||||||
|
// fVarNameEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
fVarNameEdit = new Combo(comp, SWT.SINGLE | SWT.DROP_DOWN);
|
||||||
|
fVarNameEdit.setItems(getVarNames());
|
||||||
|
fVarNameEdit.setFont(comp.getFont());
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
|
||||||
|
fVarNameEdit.setLayoutData(gd);
|
||||||
|
fVarNameEdit.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
handleVarNameModified();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fVarNameEdit.addSelectionListener(new SelectionAdapter(){
|
||||||
|
public void widgetSelected(SelectionEvent e){
|
||||||
|
handleVarNameSelection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Label valueLabel = new Label(comp, SWT.LEFT);
|
||||||
|
valueLabel.setFont(comp.getFont());
|
||||||
|
valueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE));
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
valueLabel.setLayoutData(gd);
|
||||||
|
|
||||||
|
fVarValueEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
fVarValueEdit.setFont(comp.getFont());
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 100;
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
fVarValueEdit.setLayoutData(gd);
|
||||||
|
fVarValueEdit.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
handleVarValueModified();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fDelimiterLabel = new Label(comp, SWT.LEFT);
|
||||||
|
fDelimiterLabel.setFont(comp.getFont());
|
||||||
|
fDelimiterLabel.setText(ManagedBuilderUIMessages.getResourceString(DELIMITER));
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
gd.widthHint = 100;
|
||||||
|
fDelimiterLabel.setLayoutData(gd);
|
||||||
|
|
||||||
|
fDelimiterEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
fDelimiterEdit.setFont(comp.getFont());
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
gd.widthHint = 50;
|
||||||
|
fDelimiterEdit.setLayoutData(gd);
|
||||||
|
fDelimiterEdit.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
handleDelimiterModified();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Label opLabel = new Label(comp, SWT.LEFT);
|
||||||
|
opLabel.setFont(comp.getFont());
|
||||||
|
opLabel.setText(ManagedBuilderUIMessages.getResourceString(OPERATION));
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
opLabel.setLayoutData(gd);
|
||||||
|
|
||||||
|
fOpSelector = new Combo(comp, SWT.READ_ONLY|SWT.DROP_DOWN);
|
||||||
|
gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
gd.widthHint = 70;
|
||||||
|
fOpSelector.setLayoutData(gd);
|
||||||
|
fOpSelector.setItems(new String[]{
|
||||||
|
ManagedBuilderUIMessages.getResourceString(OPERATION_REPLACE),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(OPERATION_PREPEND),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(OPERATION_APPEND),
|
||||||
|
ManagedBuilderUIMessages.getResourceString(OPERATION_REMOVE),
|
||||||
|
});
|
||||||
|
setSelectedOperation(IBuildEnvironmentVariable.ENVVAR_REPLACE);
|
||||||
|
|
||||||
|
fOpSelector.addListener(SWT.Selection, new Listener () {
|
||||||
|
public void handleEvent(Event e) {
|
||||||
|
handleOperationModified();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fOpVarValueLabel = new Label(comp, SWT.LEFT);
|
||||||
|
fOpVarValueLabel.setFont(comp.getFont());
|
||||||
|
gd = new GridData();
|
||||||
|
gd.horizontalSpan = 1;
|
||||||
|
gd.widthHint = 100;
|
||||||
|
fOpVarValueLabel.setLayoutData(gd);
|
||||||
|
fOpVarValueEdit = new Text(comp, SWT.SINGLE | SWT.BORDER);
|
||||||
|
fOpVarValueEdit.setFont(comp.getFont());
|
||||||
|
gd = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
gd.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + 50;
|
||||||
|
fOpVarValueEdit.setLayoutData(gd);
|
||||||
|
fOpVarValueEdit.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
handleOperationVarValueModified();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(fEditedVar != null){
|
||||||
|
loadVariableSettings(fEditedVar,true);
|
||||||
|
fVarNameEdit.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateWidgetState();
|
||||||
|
|
||||||
|
return comp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get the names to be displayed in the var Name combo.
|
||||||
|
*/
|
||||||
|
private String[] getVarNames(){
|
||||||
|
IBuildEnvironmentVariable vars[] = fEnvVarBlock.getSystemVariables(true);
|
||||||
|
String names[] = null;
|
||||||
|
if(vars == null || vars.length == 0)
|
||||||
|
names = new String[0];
|
||||||
|
else{
|
||||||
|
names = new String[vars.length];
|
||||||
|
for(int i = 0; i < vars.length; i++){
|
||||||
|
names[i] = vars[i].getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Collator collator = Collator.getInstance();
|
||||||
|
Arrays.sort(names, new Comparator() {
|
||||||
|
public int compare(Object a, Object b) {
|
||||||
|
String strA = ((String)a).toUpperCase();
|
||||||
|
String strB = ((String)b).toUpperCase();
|
||||||
|
return collator.compare(strA,strB);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the variable name is selected, loads all the dialog fields with the variable settings
|
||||||
|
*/
|
||||||
|
private void handleVarNameSelection(){
|
||||||
|
int index = fVarNameEdit.getSelectionIndex();
|
||||||
|
if(index == -1)
|
||||||
|
loadVariableSettings(null);
|
||||||
|
else
|
||||||
|
loadVariableSettings(fVarNameEdit.getItem(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadVariableSettings(String name){
|
||||||
|
IBuildEnvironmentVariable var = fEnvVarBlock.getSystemVariable(name,true);
|
||||||
|
if(var != null)
|
||||||
|
loadVariableSettings(var,false);
|
||||||
|
else
|
||||||
|
loadVariableSettings(name,EMPTY_STRING,IBuildEnvironmentVariable.ENVVAR_REPLACE,EMPTY_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadVariableSettings(String name,
|
||||||
|
String value,
|
||||||
|
int op,
|
||||||
|
String delimiter){
|
||||||
|
setSelectedOperation(op);
|
||||||
|
|
||||||
|
setSelectedVarName(notNull(name));
|
||||||
|
|
||||||
|
switch(op){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
fOpVarValueEdit.setText(notNull(value));
|
||||||
|
fReplaceValue = null;
|
||||||
|
fAppPrepValue = notNull(value);
|
||||||
|
fAppPrepPrepend = true;
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
fOpVarValueEdit.setText(notNull(value));
|
||||||
|
fReplaceValue = null;
|
||||||
|
fAppPrepValue = notNull(value);
|
||||||
|
fAppPrepPrepend = false;
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
fVarValueEdit.setText(notNull(value));
|
||||||
|
fReplaceValue = notNull(value);
|
||||||
|
fAppPrepValue = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
fDelimiterEdit.setText(notNull(delimiter));
|
||||||
|
|
||||||
|
updateWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* loads all the dialog fields with the variable settings
|
||||||
|
*/
|
||||||
|
private void loadVariableSettings(IBuildEnvironmentVariable var, boolean isUser){
|
||||||
|
int op = var.getOperation();
|
||||||
|
if(!isUser && op != IBuildEnvironmentVariable.ENVVAR_REMOVE)
|
||||||
|
op = IBuildEnvironmentVariable.ENVVAR_REPLACE;
|
||||||
|
|
||||||
|
loadVariableSettings(var.getName(),var.getValue(),op,var.getDelimiter());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns an empty string in the case the string passed is null.
|
||||||
|
* otherwise returns the string passed
|
||||||
|
*/
|
||||||
|
private String notNull(String str){
|
||||||
|
return str == null ? EMPTY_STRING : str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the name typed in the dialog var name edit triming spaces
|
||||||
|
*/
|
||||||
|
private String getSelectedVarName(){
|
||||||
|
return fVarNameEdit.getText().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sets the variable name to the dialog "variable name" edit control
|
||||||
|
*/
|
||||||
|
private void setSelectedVarName(String name){
|
||||||
|
if(!varNamesEqual(fVarNameEdit.getText(),name)){
|
||||||
|
fTypedName = name;
|
||||||
|
fVarNameEdit.setText(notNull(name).trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean varNamesEqual(String name1, String name2){
|
||||||
|
name1 = name1.trim();
|
||||||
|
name2 = name2.trim();
|
||||||
|
if(ManagedBuildManager.getEnvironmentVariableProvider().isVariableCaseSensitive())
|
||||||
|
return name1.equals(name2);
|
||||||
|
return name1.equalsIgnoreCase(name2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the selected operation
|
||||||
|
*/
|
||||||
|
private int getSelectedOperation(){
|
||||||
|
switch(fOpSelector.getSelectionIndex()){
|
||||||
|
case 1:
|
||||||
|
return IBuildEnvironmentVariable.ENVVAR_PREPEND;
|
||||||
|
case 2:
|
||||||
|
return IBuildEnvironmentVariable.ENVVAR_APPEND;
|
||||||
|
case 3:
|
||||||
|
return IBuildEnvironmentVariable.ENVVAR_REMOVE;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return IBuildEnvironmentVariable.ENVVAR_REPLACE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sets the selected operation
|
||||||
|
*/
|
||||||
|
private void setSelectedOperation(int op){
|
||||||
|
switch(op){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
fOpSelector.select(1);
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
fOpSelector.select(2);
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
fOpSelector.select(3);
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
fOpSelector.select(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||||
|
*/
|
||||||
|
protected void okPressed(){
|
||||||
|
String name = getSelectedVarName();
|
||||||
|
if(name != null || !EMPTY_STRING.equals(name))
|
||||||
|
fResultingVar = new BuildEnvVar(name,getSelectedVariableValue(),getSelectedOperation(),fDelimiterEdit.getText());
|
||||||
|
|
||||||
|
super.okPressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.window.Window#open()
|
||||||
|
*/
|
||||||
|
public int open(){
|
||||||
|
fResultingVar = null;
|
||||||
|
return super.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns the variable value that should be stored in the resulting variable
|
||||||
|
*/
|
||||||
|
private String getSelectedVariableValue(){
|
||||||
|
switch(getSelectedOperation()){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
return fOpVarValueEdit.getText();
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
return EMPTY_STRING;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
return fVarValueEdit.getText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this method should be called after the dialog is closed
|
||||||
|
* to obtain the created variable.
|
||||||
|
* if the variable was not created, e.g. because a user has pressed
|
||||||
|
* the cancel button this method returns null
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getDefinedVariable(){
|
||||||
|
return fResultingVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the variable name is modified
|
||||||
|
*/
|
||||||
|
private void handleVarNameModified(){
|
||||||
|
String name = getSelectedVarName();
|
||||||
|
if(fTypedName == null || !fTypedName.equals(name)){
|
||||||
|
loadVariableSettings(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the variable value is modified
|
||||||
|
*/
|
||||||
|
private void handleVarValueModified(){
|
||||||
|
switch(getSelectedOperation()){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
fAppPrepValue = fVarValueEdit.getText();
|
||||||
|
fReplaceValue = null;
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
fReplaceValue = fVarValueEdit.getText();
|
||||||
|
fAppPrepValue = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the operation is modified
|
||||||
|
*/
|
||||||
|
private void handleOperationModified(){
|
||||||
|
int op = getSelectedOperation();
|
||||||
|
String newValue = recalculateValueString();
|
||||||
|
|
||||||
|
switch(op){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
fVarValueEdit.setText(calculateAppendPrepend(
|
||||||
|
getSelectedVarName(),
|
||||||
|
newValue,
|
||||||
|
fDelimiterEdit.getText(),
|
||||||
|
true));
|
||||||
|
fVarValueEdit.setEnabled(false);
|
||||||
|
fOpVarValueEdit.setText(newValue);
|
||||||
|
fOpVarValueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE_PREPEND));
|
||||||
|
fOpVarValueLabel.setVisible(true);
|
||||||
|
fOpVarValueEdit.setVisible(true);
|
||||||
|
fDelimiterEdit.setEnabled(true);
|
||||||
|
fAppPrepPrepend = true;
|
||||||
|
fAppPrepValue = newValue;
|
||||||
|
fReplaceValue = null;
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
fVarValueEdit.setText(calculateAppendPrepend(
|
||||||
|
getSelectedVarName(),
|
||||||
|
newValue,
|
||||||
|
fDelimiterEdit.getText(),
|
||||||
|
false));
|
||||||
|
fVarValueEdit.setEnabled(false);
|
||||||
|
fOpVarValueEdit.setText(newValue);
|
||||||
|
fOpVarValueLabel.setText(ManagedBuilderUIMessages.getResourceString(VALUE_APPEND));
|
||||||
|
fOpVarValueLabel.setVisible(true);
|
||||||
|
fOpVarValueEdit.setVisible(true);
|
||||||
|
fDelimiterEdit.setEnabled(true);
|
||||||
|
fAppPrepPrepend = false;
|
||||||
|
fAppPrepValue = newValue;
|
||||||
|
fReplaceValue = null;
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
fOpVarValueLabel.setVisible(false);
|
||||||
|
fOpVarValueEdit.setVisible(false);
|
||||||
|
fDelimiterEdit.setEnabled(false);
|
||||||
|
fVarValueEdit.setText(EMPTY_STRING);
|
||||||
|
fVarValueEdit.setEnabled(false);
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
fVarValueEdit.setText(newValue);
|
||||||
|
fOpVarValueLabel.setVisible(false);
|
||||||
|
fOpVarValueEdit.setVisible(false);
|
||||||
|
fDelimiterEdit.setEnabled(true);
|
||||||
|
fVarValueEdit.setEnabled(true);
|
||||||
|
fAppPrepValue = null;
|
||||||
|
fReplaceValue = newValue;
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String recalculateValueString(){
|
||||||
|
String val = EMPTY_STRING;
|
||||||
|
|
||||||
|
switch(getSelectedOperation()){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:
|
||||||
|
if(fAppPrepValue != null)
|
||||||
|
val = fAppPrepValue;
|
||||||
|
else if(fReplaceValue != null)
|
||||||
|
val = calculateAppPrepFromReplace(fReplaceValue,fDelimiterEdit.getText(),true);
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:
|
||||||
|
if(fAppPrepValue != null)
|
||||||
|
val = fAppPrepValue;
|
||||||
|
else if(fReplaceValue != null)
|
||||||
|
val = calculateAppPrepFromReplace(fReplaceValue,fDelimiterEdit.getText(),false);
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
val = EMPTY_STRING;
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
if(fReplaceValue != null)
|
||||||
|
val = fReplaceValue;
|
||||||
|
else if(fAppPrepValue != null)
|
||||||
|
val = fReplaceValue = calculateReplaceFromAppPrep(fAppPrepValue,fDelimiterEdit.getText(),fAppPrepPrepend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String calculateAppPrepFromReplace(String replace, String delimiter, boolean prepend){
|
||||||
|
String val = replace;
|
||||||
|
IBuildEnvironmentVariable var = fEnvVarBlock.getSystemVariable(getSelectedVarName(),true);
|
||||||
|
if(var != null && var.getOperation() != IBuildEnvironmentVariable.ENVVAR_REMOVE){
|
||||||
|
String varValue = var.getValue();
|
||||||
|
if(delimiter != null && !EMPTY_STRING.equals(delimiter)){
|
||||||
|
List replaceValues = EnvVarOperationProcessor.convertToList(replace,delimiter);
|
||||||
|
List varValues = EnvVarOperationProcessor.convertToList(varValue,delimiter);
|
||||||
|
List result = EnvVarOperationProcessor.removeDuplicates(replaceValues,varValues);
|
||||||
|
val = EnvVarOperationProcessor.convertToString(result,delimiter);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(varValue != null && !EMPTY_STRING.equals(varValue)){
|
||||||
|
int index = replace.indexOf(varValue);
|
||||||
|
if(index == -1)
|
||||||
|
val = EMPTY_STRING;
|
||||||
|
else {
|
||||||
|
try{
|
||||||
|
if(index == 0)
|
||||||
|
val = replace.substring(replace.length());
|
||||||
|
else
|
||||||
|
val = replace.substring(0,index);
|
||||||
|
|
||||||
|
} catch (IndexOutOfBoundsException e){
|
||||||
|
val = EMPTY_STRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String calculateReplaceFromAppPrep(String value, String delimiter, boolean prepend){
|
||||||
|
return calculateAppendPrepend(getSelectedVarName(),value,delimiter,prepend);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* updates the state of the dialog controls
|
||||||
|
*/
|
||||||
|
private void updateWidgetState(){
|
||||||
|
handleOperationModified();
|
||||||
|
validateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* updates the variable value displayed in the dialog in case of append/prepend operation
|
||||||
|
*/
|
||||||
|
private void updateVariableValueForAppendPrepend(boolean prepend){
|
||||||
|
String name = getSelectedVarName();
|
||||||
|
if(name == null || EMPTY_STRING.equals(name))
|
||||||
|
return;
|
||||||
|
|
||||||
|
String opValue = fOpVarValueEdit.getText();
|
||||||
|
|
||||||
|
fVarValueEdit.setText(calculateAppendPrepend(name,opValue,fDelimiterEdit.getText(),prepend));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calculates the resulting variable value
|
||||||
|
*/
|
||||||
|
private String calculateAppendPrepend(String name, String opValue, String delimiter, boolean prepend){
|
||||||
|
String varValue = null;
|
||||||
|
IBuildEnvironmentVariable var = fEnvVarBlock.getSystemVariable(name,true);
|
||||||
|
if(var == null)
|
||||||
|
return opValue;
|
||||||
|
return EnvVarOperationProcessor.performAppendPrepend(var.getValue(),opValue,delimiter,prepend);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the delimiter is modified
|
||||||
|
*/
|
||||||
|
private void handleDelimiterModified(){
|
||||||
|
int op = getSelectedOperation();
|
||||||
|
switch(op){
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_PREPEND:{
|
||||||
|
String value = getSelectedVariableValue();
|
||||||
|
fVarValueEdit.setText(calculateAppendPrepend(
|
||||||
|
getSelectedVarName(),
|
||||||
|
value,
|
||||||
|
fDelimiterEdit.getText(),
|
||||||
|
true));
|
||||||
|
fAppPrepValue = value;
|
||||||
|
fReplaceValue = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_APPEND:{
|
||||||
|
String value = getSelectedVariableValue();
|
||||||
|
fVarValueEdit.setText(calculateAppendPrepend(
|
||||||
|
getSelectedVarName(),
|
||||||
|
value,
|
||||||
|
fDelimiterEdit.getText(),
|
||||||
|
false));
|
||||||
|
fAppPrepValue = value;
|
||||||
|
fReplaceValue = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REMOVE:
|
||||||
|
break;
|
||||||
|
case IBuildEnvironmentVariable.ENVVAR_REPLACE:
|
||||||
|
default:
|
||||||
|
fAppPrepValue = null;
|
||||||
|
fReplaceValue = getSelectedVariableValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called when the appended/prepended value is modified
|
||||||
|
*/
|
||||||
|
private void handleOperationVarValueModified(){
|
||||||
|
handleDelimiterModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* Update the status message and button state based on the variable name
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private void validateState() {
|
||||||
|
StatusInfo status= new StatusInfo();
|
||||||
|
String name = getSelectedVarName();
|
||||||
|
|
||||||
|
if(EMPTY_STRING.equals(name)){
|
||||||
|
// Not an error
|
||||||
|
status.setError(""); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
else if(!fEnvVarBlock.canCreate(name)){
|
||||||
|
status.setError(ManagedBuilderUIMessages.getFormattedString(STATUS_CANNOT_CTREATE, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateStatus(status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -65,6 +65,11 @@ BuildPropertyPage.unsupported.proj=The project support is not installed on the s
|
||||||
BuildPropertyPage.unsupported.config=The configuration support is not installed on the system
|
BuildPropertyPage.unsupported.config=The configuration support is not installed on the system
|
||||||
BuildPropertyPage.config.notselected=No configurations selected
|
BuildPropertyPage.config.notselected=No configurations selected
|
||||||
|
|
||||||
|
# ----------- Managed Build Preference Page -----------
|
||||||
|
BuildPreferencePage.label.Settings=Workspace Settings
|
||||||
|
BuildPreferencePage.job.rebuild=Rebuilding the Managed Projects
|
||||||
|
BuildPreferencePage.apply.internal.error=An Internal error has occured please check error log.
|
||||||
|
|
||||||
#--------------- Resource Configuration Selection Page --------------
|
#--------------- Resource Configuration Selection Page --------------
|
||||||
ResourceBuildPropertyPage.defaults.title=Reset Resource Configuration Tool
|
ResourceBuildPropertyPage.defaults.title=Reset Resource Configuration Tool
|
||||||
ResourceBuildPropertyPage.defaults.message=This action will reset all options of the tool in the current resource configuration to their default settings.\n\nDo you want to proceed?
|
ResourceBuildPropertyPage.defaults.message=This action will reset all options of the tool in the current resource configuration to their default settings.\n\nDo you want to proceed?
|
||||||
|
@ -82,6 +87,46 @@ BuildSettingsBlock.label.output.group=Build output
|
||||||
BuildSettingsBlock.label.output.name=Artifact name:
|
BuildSettingsBlock.label.output.name=Artifact name:
|
||||||
BuildSettingsBlock.label.output.extension=Artifact extension:
|
BuildSettingsBlock.label.output.extension=Artifact extension:
|
||||||
|
|
||||||
|
# ----------- Environment Set Block -----------
|
||||||
|
EnvironmentSetBlock.label.environment=Environment
|
||||||
|
EnvironmentSetBlock.label.environment.group=Environment variables
|
||||||
|
EnvironmentSetBlock.label.tab.configuration=Configuration
|
||||||
|
EnvironmentSetBlock.label.tab.project=Project
|
||||||
|
EnvironmentSetBlock.label.tab.workspace=Workspace
|
||||||
|
EnvironmentSetBlock.label.tab.eclipse=Eclipse Environment
|
||||||
|
|
||||||
|
# ----------- Environment Block -----------
|
||||||
|
EnvironmentBlock.label.header.name=Name
|
||||||
|
EnvironmentBlock.label.header.value=Value
|
||||||
|
EnvironmentBlock.label.button.new=New
|
||||||
|
EnvironmentBlock.label.button.edit=Edit
|
||||||
|
EnvironmentBlock.label.button.delete=Delete
|
||||||
|
EnvironmentBlock.label.button.undef=Undefine
|
||||||
|
EnvironmentBlock.label.value.undef=<UNDEFINED>
|
||||||
|
EnvironmentBlock.label.button.check.chow.parent=Show parent level variables
|
||||||
|
EnvironmentBlock.label.user.var=User Variables
|
||||||
|
EnvironmentBlock.label.system.var=System Variables
|
||||||
|
EnvironmentBlock.label.delete.confirm.title=Variable deletion confirmation
|
||||||
|
EnvironmentBlock.label.delete.confirm.message=Are you sure you want to delete the selected user variable(s)?
|
||||||
|
EnvironmentBlock.label.delete.all.confirm.title=Variable deletion confirmation
|
||||||
|
EnvironmentBlock.label.delete.all.confirm.message=Are you sure you want to delete all user variables?
|
||||||
|
|
||||||
|
# ----------- New Env Var Dialog -----------
|
||||||
|
NewEnvVarDialog.label.name=Name
|
||||||
|
NewEnvVarDialog.label.value=Value
|
||||||
|
NewEnvVarDialog.label.delimiter=Delimiter
|
||||||
|
NewEnvVarDialog.label.operation=Operation
|
||||||
|
NewEnvVarDialog.label.operation.replace=Replace
|
||||||
|
NewEnvVarDialog.label.operation.prepend=Prepend
|
||||||
|
NewEnvVarDialog.label.operation.append=Append
|
||||||
|
NewEnvVarDialog.label.operation.remove=Remove
|
||||||
|
NewEnvVarDialog.label.value.prepend=Prepended Value
|
||||||
|
NewEnvVarDialog.label.value.append=Appended Value
|
||||||
|
NewEnvVarDialog.label.value.undef=<UNDEFINED>
|
||||||
|
NewEnvVarDialog.label.title.new=Define a new variable
|
||||||
|
NewEnvVarDialog.label.title.edit=Edit existing variable
|
||||||
|
NewEnvVarDialog.label.status.cannot.create=The "{0}" Variable can not be created by user
|
||||||
|
|
||||||
# ------------Resource Configuration Selection Page
|
# ------------Resource Configuration Selection Page
|
||||||
ResourceBuildPropertyPage.label.ActiveResource=Active Resource configuration
|
ResourceBuildPropertyPage.label.ActiveResource=Active Resource configuration
|
||||||
ResourceBuildPropertyPage.label.ResourceSettings=Resource Configuration settings
|
ResourceBuildPropertyPage.label.ResourceSettings=Resource Configuration settings
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IBuildPathResolver;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
|
||||||
|
public class CygwinPathResolver implements IBuildPathResolver {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IBuildPathResolver#resolveBuildPaths(int, java.lang.String, java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration)
|
||||||
|
*/
|
||||||
|
public String[] resolveBuildPaths(int pathType, String variableName,
|
||||||
|
String variableValue, IConfiguration configuration) {
|
||||||
|
// TODO implement
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.toolchain.gnu.cygwin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
|
||||||
|
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
|
||||||
|
|
||||||
|
public class GnuCygwinConfigurationEnvironmentSupplier implements
|
||||||
|
IConfigurationEnvironmentVariableSupplier {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariable(java.lang.String, org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable getVariable(String variableName,
|
||||||
|
IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||||
|
// TODO implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier#getVariables(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider)
|
||||||
|
*/
|
||||||
|
public IBuildEnvironmentVariable[] getVariables(
|
||||||
|
IConfiguration configuration, IEnvironmentVariableProvider provider) {
|
||||||
|
// TODO implement
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,244 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Copyright (c) 2005 Intel Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Intel Corporation - Initial API and implementation
|
||||||
|
**********************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuildOptionBlock;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
|
||||||
|
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.dialogs.ICOptionContainer;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.resources.WorkspaceJob;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
|
import org.eclipse.core.runtime.Preferences;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
|
||||||
|
|
||||||
|
public class BuildPreferencePage extends PreferencePage
|
||||||
|
implements IWorkbenchPreferencePage, ICOptionContainer{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* String constants
|
||||||
|
*/
|
||||||
|
private static final String PREFIX = "BuildPreferencePage"; //$NON-NLS-1$
|
||||||
|
private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
|
||||||
|
private static final String SETTINGS_LABEL = LABEL + ".Settings"; //$NON-NLS-1$
|
||||||
|
private static final String REBUILD_JOB_NAME = PREFIX + ".job.rebuild"; //$NON-NLS-1$
|
||||||
|
private static final String APPLY_INTARNAL_ERROR = PREFIX + ".apply.internal.error"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bookeeping variables
|
||||||
|
*/
|
||||||
|
protected ManagedBuildOptionBlock fOptionBlock;
|
||||||
|
private boolean fRebuildNeeded = false;
|
||||||
|
|
||||||
|
public BuildPreferencePage(){
|
||||||
|
fOptionBlock = new ManagedBuildOptionBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IWorkbenchPreferencePage#init()
|
||||||
|
*/
|
||||||
|
public void init(IWorkbench workbench){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* specifies whether the rebuild of all managed projects is needed
|
||||||
|
* @see setRebuildState()
|
||||||
|
*/
|
||||||
|
protected boolean rebuildNeeded(){
|
||||||
|
return fRebuildNeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* sets the rebuild state
|
||||||
|
* When the build settings apply operation is performed
|
||||||
|
* the rebuild will not be initiated, but the rebuild state will be set to true.
|
||||||
|
* The rebuild will be initiated only when closing the preference page.
|
||||||
|
* In case the rebuild state is "true", the rebuild of all managed projects
|
||||||
|
* will be initiated both for OK or Cancel operations
|
||||||
|
*/
|
||||||
|
protected void setRebuildState(boolean rebuild){
|
||||||
|
fRebuildNeeded = rebuild;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#createContents()
|
||||||
|
*/
|
||||||
|
protected Control createContents(Composite parent) {
|
||||||
|
Composite composite = new Composite(parent, SWT.NONE);
|
||||||
|
composite.setLayout(new GridLayout());
|
||||||
|
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
|
fOptionBlock.createContents(composite,ResourcesPlugin.getWorkspace());
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.ui.dialogs.ICOptionContainer#updateContainer()
|
||||||
|
*/
|
||||||
|
public void updateContainer(){
|
||||||
|
fOptionBlock.update();
|
||||||
|
setValid(fOptionBlock.isValid());
|
||||||
|
setErrorMessage(fOptionBlock.getErrorMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public IProject getProject(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Preferences getPreferences(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#performApply()
|
||||||
|
*/
|
||||||
|
protected void performApply() {
|
||||||
|
applySettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void performDefaults() {
|
||||||
|
fOptionBlock.performDefaults();
|
||||||
|
super.performDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* apply settings
|
||||||
|
* when the Apply operation is performed, the user-modified settings are saved,
|
||||||
|
* but the rebuild of all managed projects is not initiated.
|
||||||
|
* The rebuild state is set to true instead.
|
||||||
|
* Rebuild will initiated when closing the preference page
|
||||||
|
*/
|
||||||
|
protected boolean applySettings(){
|
||||||
|
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
||||||
|
public void run(IProgressMonitor monitor) {
|
||||||
|
if(fOptionBlock.isDirty()){
|
||||||
|
fOptionBlock.performApply(monitor);
|
||||||
|
fOptionBlock.setDirty(false);
|
||||||
|
// specify that the managed projects rebuild is needed
|
||||||
|
// the rebuild will be initiated when closing the preference page
|
||||||
|
// both in the case of OK and Cancel
|
||||||
|
setRebuildState(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
IRunnableWithProgress op = new WorkspaceModifyDelegatingOperation(runnable);
|
||||||
|
|
||||||
|
try {
|
||||||
|
new ProgressMonitorDialog(getShell()).run(false, true, op);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
Throwable e1 = e.getTargetException();
|
||||||
|
ManagedBuilderUIPlugin.errorDialog(getShell(), ManagedBuilderUIMessages.getResourceString(APPLY_INTARNAL_ERROR),e1.toString(), e1); //$NON-NLS-1$
|
||||||
|
return false;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// cancelled
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#performCancel()
|
||||||
|
*/
|
||||||
|
public boolean performCancel() {
|
||||||
|
//the rebuild is needed in case the apply button was previousely pressed
|
||||||
|
if(rebuildNeeded()){
|
||||||
|
initiateRebuild();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.preference.PreferencePage#performOk()
|
||||||
|
*/
|
||||||
|
public boolean performOk() {
|
||||||
|
|
||||||
|
if(!applySettings())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(rebuildNeeded())
|
||||||
|
initiateRebuild();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* initiate the rebuild for all managed projects
|
||||||
|
*/
|
||||||
|
private void initiateRebuild(){
|
||||||
|
setRebuildState(false);
|
||||||
|
IWorkspace wsp = ResourcesPlugin.getWorkspace();
|
||||||
|
IProject projects[] = wsp.getRoot().getProjects();
|
||||||
|
List managedProjectList = new ArrayList();
|
||||||
|
for(int i = 0; i < projects.length; i++){
|
||||||
|
if(ManagedBuildManager.manages(projects[i])){
|
||||||
|
managedProjectList.add(projects[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
projects = (IProject[])managedProjectList.toArray(new IProject[managedProjectList.size()]);
|
||||||
|
final IProject projectsToBuild[] = wsp.computeProjectOrder(projects).projects;
|
||||||
|
|
||||||
|
WorkspaceJob rebuildJob = new WorkspaceJob(ManagedBuilderUIMessages.getResourceString(REBUILD_JOB_NAME)) {
|
||||||
|
public boolean belongsTo(Object family) {
|
||||||
|
return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
|
||||||
|
}
|
||||||
|
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
|
||||||
|
for(int i = 0; i < projectsToBuild.length; i++){
|
||||||
|
try{
|
||||||
|
projectsToBuild[i].build(IncrementalProjectBuilder.FULL_BUILD,monitor);
|
||||||
|
}catch(CoreException e){
|
||||||
|
//TODO:
|
||||||
|
}catch(OperationCanceledException e){
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
rebuildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory()
|
||||||
|
.buildRule());
|
||||||
|
rebuildJob.setUser(true);
|
||||||
|
rebuildJob.schedule();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue