1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 18:05:33 +02:00

Commit for Leo Treggiari:

Handles Managed Build System projects that fail to open or convert, for example, because the tool-chain that the project uses is not installed.
When a project configuration is removed, cleans the configuration output.
Edits for some of the externalized strings.
This commit is contained in:
Sean Evoy 2004-11-08 20:12:46 +00:00
parent cf5df1e48f
commit b7c36f5113
14 changed files with 216 additions and 67 deletions

View file

@ -733,7 +733,8 @@ public class ManagedBuildCoreTests20 extends TestCase {
private void addManagedBuildNature (IProject project) {
// Create the buildinformation object for the project
ManagedBuildManager.createBuildInfo(project);
IManagedBuildInfo info = ManagedBuildManager.createBuildInfo(project);
info.setValid(true);
// Add the managed build nature
try {

View file

@ -272,13 +272,21 @@ public interface IManagedBuildInfo {
public boolean isHeaderFile(String ext);
/**
* gets the read only status of Managed Build Info
* Gets the read only status of Managed Build Info
*
* @return <code>true</code> if Managed Build Info is read only
* otherwise returns <code>false</code>
*/
public boolean isReadOnly();
/**
* Gets the "valid" status of Managed Build Info. Managed Build Info is invalid
* if the loading of, or conversion to, the Managed Build Info failed.
*
* @return <code>true</code> if Managed Build Info is valid,
* otherwise returns <code>false</code>
*/
public boolean isValid();
/**
* Answers whether the receiver has been changed and requires the
@ -314,11 +322,18 @@ public interface IManagedBuildInfo {
public boolean setDefaultConfiguration(String configName);
/**
* Set the dirty flag for the build model to the value of the argument.
* Sets the dirty flag for the build model to the value of the argument.
*
* @param isDirty
*/
public void setDirty(boolean isDirty);
/**
* Sets the valid flag for the build model to the value of the argument.
*
* @param isValid
*/
public void setValid(boolean isValid);
/**
* Sets the ManagedProject associated with this build info

View file

@ -95,7 +95,10 @@ public interface ITool extends IBuildObject {
public IOption getOptionById(String id);
/**
* Answers the options that may be customized for this tool.
* Returns the complete list of options that are available for this tool.
* The list is a merging of the options specified for this tool with the
* options of its superclasses. The lowest option instance in the hierarchy
* takes precedence.
*
* @return IOption[]
*/

View file

@ -79,6 +79,10 @@ import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -807,7 +811,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
ManagedBuildInfo buildInfo = (ManagedBuildInfo) getBuildInfo(project);
// Save the build info
if (buildInfo != null && !buildInfo.isReadOnly() && (force == true || buildInfo.isDirty())) {
if (buildInfo != null &&
!buildInfo.isReadOnly() &&
buildInfo.isValid() &&
(force == true || buildInfo.isDirty())) {
// For post-2.0 projects, there will be a version
String projectVersion = buildInfo.getVersion();
if (projectVersion != null) {
@ -1158,8 +1165,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
}
}
} catch (Exception e) {
buildInfo = null;
// TODO: Issue an error message that the managed build project file (.cdtbuild) is invalid
throw e;
}
try {
@ -1198,8 +1204,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
try{
UpdateManagedProjectManager.updateProject(project,buildInfo);
} catch(CoreException e){
//TODO: error occured while updating the project,
//handle error, log error or display the message
throw e;
}
}
project.setSessionProperty(buildInfoProperty, buildInfo);
@ -1207,6 +1212,8 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
} catch (Exception e) {
throw e;
}
buildInfo.setValid(true);
return buildInfo;
}
@ -1529,7 +1536,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
*
* @param resource The resource the build information is associated with
*/
public static void createBuildInfo(IResource resource) {
public static ManagedBuildInfo createBuildInfo(IResource resource) {
ManagedBuildInfo buildInfo = new ManagedBuildInfo(resource);
try {
// Associate the build info with the project for the duration of the session
@ -1538,6 +1545,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
// There is no point in keeping the info around if it isn't associated with the project
buildInfo = null;
}
return buildInfo;
}
private static IManagedConfigElementProvider createConfigProvider(
@ -1673,7 +1681,28 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
try {
buildInfo = loadBuildInfo(project);
} catch (Exception e) {
// TODO: Issue error reagarding not being able to load the project file (.cdtbuild)
// Issue error regarding not being able to load the project file (.cdtbuild)
if (buildInfo == null) {
buildInfo = createBuildInfo(project);
}
buildInfo.setValid(false);
// Display error message
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if(window == null){
IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows();
window = windows[0];
}
final Shell shell = window.getShell();
final String exceptionMsg = e.getMessage();
shell.getDisplay().syncExec( new Runnable() {
public void run() {
MessageDialog.openError(shell,
ManagedMakeMessages.getResourceString("ManagedBuildManager.error.open_failed_title"), //$NON-NLS-1$
ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.open_failed", //$NON-NLS-1$
exceptionMsg));
}
} );
}
try {

View file

@ -222,7 +222,11 @@ public class GeneratedMakefileBuilder extends ACBuilder {
outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
return referencedProjects;
}
if (!info.isValid()) {
outputError(getProject().getName(), "Build information is not valid"); //$NON-NLS-1$
return referencedProjects;
}
// Create a makefile generator for the build
IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration());
generator.initialize(getProject(), info, monitor);
@ -283,6 +287,10 @@ public class GeneratedMakefileBuilder extends ACBuilder {
outputError(getProject().getName(), "Build information was not found"); //$NON-NLS-1$
return;
}
if (!info.isValid()) {
outputError(getProject().getName(), "Build information is not valid"); //$NON-NLS-1$
return;
}
IPath buildDirPath = getProject().getLocation().append(info.getConfigurationName());
IWorkspace workspace = CCorePlugin.getWorkspace();
IContainer buildDir = workspace.getRoot().getContainerForLocation(buildDirPath);

View file

@ -72,6 +72,7 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
private IConfiguration defaultConfig;
private String defaultConfigId;
private boolean isDirty;
private boolean isValid = false;
private IResource owner;
private boolean rebuildNeeded;
private String version;
@ -390,31 +391,33 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
if (location == null) {
location = new Path("."); //$NON-NLS-1$
}
IPath root = location.addTrailingSeparator().append(config.getName());
ITool[] tools = config.getFilteredTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
// The tool checks out for this project, get its options
IOption[] opts = tool.getOptions();
for (int j = 0; j < opts.length; j++) {
IOption option = opts[j];
try {
if (option.getValueType() == IOption.INCLUDE_PATH) {
// Get all the user-defined paths from the option as absolute paths
String[] userPaths = option.getIncludePaths();
for (int index = 0; index < userPaths.length; ++index) {
IPath userPath = new Path(userPaths[index]);
if (userPath.isAbsolute()) {
paths.add(userPath.toOSString());
} else {
IPath absPath = root.addTrailingSeparator().append(userPath);
paths.add(absPath.makeAbsolute().toOSString());
if (config != null) {
IPath root = location.addTrailingSeparator().append(config.getName());
ITool[] tools = config.getFilteredTools();
for (int i = 0; i < tools.length; i++) {
ITool tool = tools[i];
// The tool checks out for this project, get its options
IOption[] opts = tool.getOptions();
for (int j = 0; j < opts.length; j++) {
IOption option = opts[j];
try {
if (option.getValueType() == IOption.INCLUDE_PATH) {
// Get all the user-defined paths from the option as absolute paths
String[] userPaths = option.getIncludePaths();
for (int index = 0; index < userPaths.length; ++index) {
IPath userPath = new Path(userPaths[index]);
if (userPath.isAbsolute()) {
paths.add(userPath.toOSString());
} else {
IPath absPath = root.addTrailingSeparator().append(userPath);
paths.add(absPath.makeAbsolute().toOSString());
}
}
}
} catch (BuildException e) {
// TODO: report error
continue;
}
} catch (BuildException e) {
// TODO: report error
continue;
}
}
}
@ -670,9 +673,27 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
// Check if the project is dirty
return managedProject.isDirty();
if (managedProject != null) {
return managedProject.isDirty();
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isValid()
*/
public boolean isValid() {
// If the info has been flagged as valid, answer true
return isValid;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isReadOnly()
*/
public boolean isReadOnly(){
return isReadOnly;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#isHeaderFile(java.lang.String)
*/
@ -773,8 +794,11 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
* @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setDefaultConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
*/
public void setDefaultConfiguration(IConfiguration configuration) {
// TODO: This is probably wrong. I'll bet we don't handle the case where all configs are deleted...
// But, at least, our UI does not allow the last config to be deleted.
// Sanity
if (configuration == null) return;
if (!configuration.equals(getDefaultConfiguration())) {
// Save it
defaultConfig = configuration;
@ -814,6 +838,23 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setValid(boolean)
*/
public void setValid(boolean isValid) {
// Reset the valid status
this.isValid = isValid;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setReadOnly(boolean)
*/
public void setReadOnly(boolean readOnly){
if(!readOnly && isReadOnly)
setDirty(true);
isReadOnly = readOnly;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#setRebuildState(boolean)
*/
@ -932,14 +973,4 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo {
}
return targetList;
}
public void setReadOnly(boolean readOnly){
if(!readOnly && isReadOnly)
setDirty(true);
isReadOnly = readOnly;
}
public boolean isReadOnly(){
return isReadOnly;
}
}

View file

@ -22,7 +22,13 @@ import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -231,16 +237,56 @@ public class ManagedProject extends BuildObject implements IManagedProject {
* @see org.eclipse.cdt.managedbuilder.core.IManagedProject#removeConfiguration(java.lang.String)
*/
public void removeConfiguration(String id) {
// Remove the specified configuration from the list and map
Iterator iter = getConfigurationList().listIterator();
while (iter.hasNext()) {
IConfiguration config = (IConfiguration)iter.next();
if (config.getId().equals(id)) {
getConfigurationList().remove(config);
getConfigurationMap().remove(id);
break;
}
final String removeId = id;
IWorkspaceRunnable remover = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
// Remove the specified configuration from the list and map
Iterator iter = getConfigurationList().listIterator();
while (iter.hasNext()) {
IConfiguration config = (IConfiguration)iter.next();
if (config.getId().equals(removeId)) {
// TODO: For now we clean the entire project. This may be overkill, but
// it avoids a problem with leaving the configuration output directory
// around and having the outputs try to be used by the makefile generator code.
IResource proj = config.getOwner();
IManagedBuildInfo info = null;
if (proj instanceof IProject) {
info = ManagedBuildManager.getBuildInfo(proj);
}
IConfiguration currentConfig = null;
boolean isCurrent = true;
if (info != null) {
currentConfig = info.getDefaultConfiguration();
if (!currentConfig.getId().equals(removeId)) {
info.setDefaultConfiguration(config);
isCurrent = false;
}
}
((IProject)proj).build(IncrementalProjectBuilder.CLEAN_BUILD, monitor);
getConfigurationList().remove(config);
getConfigurationMap().remove(removeId);
if (info != null) {
if (!isCurrent) {
info.setDefaultConfiguration(currentConfig);
} else {
// If the current default config is the one being removed, reset the default config
String[] configs = info.getConfigurationNames();
if (configs.length > 0) {
info.setDefaultConfiguration(configs[0]);
}
}
}
break;
}
}
}
};
try {
ResourcesPlugin.getWorkspace().run( remover, null );
}
catch( CoreException e ) {}
setDirty(true);
}

View file

@ -39,6 +39,8 @@ ManagedBuildManager.error.null_owner=addTarget: null owner
ManagedBuildManager.error.owner_not_project=addTarget: owner not project
ManagedBuildManager.error.manifest.version.error=The version of plugin file is higher than version of the build system
ManagedBuildManager.error.project.version.error=The version of the project is higher than the build system
ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error.\n\n{0}\n\nManaged Make functionality will not be available for this project.
# Makefile Generator Messages
MakefileGenerator.message.start.file=Building file:

View file

@ -533,7 +533,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator {
if (info.buildsFileType(ext)) {
// look for the extension in the map
StringBuffer bufferForExtension = new StringBuffer();
bufferForExtension.append(extensionToRuleStringMap.get(ext).toString());
if (extensionToRuleStringMap.containsKey(ext)) {
bufferForExtension.append(extensionToRuleStringMap.get(ext).toString());
}
if(bufferForExtension != null &&
!getOutputExtensions().contains(bufferForExtension.toString())) {

View file

@ -12,31 +12,33 @@
UpdateManagedProject20.0=Backing up the settings file for {0}
UpdateManagedProject20.1=Updating build settings for project {0}
UpdateManagedProject20.10=No configurations were found for project {0}
UpdateManagedProject20.11=Build exception occured while creating managed project {0} : {1}
UpdateManagedProject20.11=Build exception occurred while creating Managed Make project {0} : {1}
UpdateManagedProject20.2=convertConfiguration: Configuration {0} was not found
UpdateManagedProject20.3=convertToolRef: Tool ID attribute does not exist
UpdateManagedProject20.4=convertToolRef: Toolchain does not contain tools
UpdateManagedProject20.5=convertToolRef: Parent not found for tool {0}
UpdateManagedProject20.6=convertOptionRef: option ID attribute does not exist
UpdateManagedProject20.7=convertOptionRef: option {0} not found
UpdateManagedProject20.8=convertOptionRef: BuildException occured: {0}
UpdateManagedProject20.8=convertOptionRef: BuildException occurred: {0}
UpdateManagedProject20.9=Project type {0} not found
UpdateManagedProject20.invalid_build_info=The Managed Make information for the project is not valid.
UpdateManagedProject12.0=Backing up the settings file for {0}
UpdateManagedProject12.1=Updating build settings for project {0}
UpdateManagedProject12.2=configuration {0} not found
UpdateManagedProject12.3=Parent not found for option {0}
UpdateManagedProject12.4=option {0} not found
UpdateManagedProject12.5=convertOptionRef: BuildException occured: {0}
UpdateManagedProject12.5=convertOptionRef: BuildException occurred: {0}
UpdateManagedProject12.6=Project type {0} not found
UpdateManagedProject12.7=No configurations were found for project {0}
UpdateManagedProject12.8=Build exception occured while creating managed project {0} : {1}
UpdateManagedProject12.8=Build exception occurred while creating Managed Make project {0} : {1}
UpdateManagedProject12.9=Toolchain does not contain tools
UpdateManagedProject12.10=Parent not found for tool {0}
UpdateManagedProject12.11=tool {0} not found
UpdateManagedProject12.invalid_build_info=The Managed Make information for the project is not valid.
UpdateManagedProjectManager.0=Backup File Already Exists
UpdateManagedProjectManager.1=A backup file {0} already exists for the project {1}.\n Do you want to convert the project anyway?
UpdateManagedProjectManager.2=The update operation has been cancelled.\n The build system will not be able to read the project settings until you update the project.
UpdateManagedProjectManager.3=Update Managed Builder Project
UpdateManagedProjectManager.3=Update Managed Make Project
UpdateManagedProjectManager.4=The project {0} build settings are stored in a format that is no longer supported (version {1}).\n\nWould you like to convert it to the newer version ({2})?\n\nNOTE: Converted projects can no longer be loaded by previous versions of the Managed Build System.\nIf you select "No", project settings will be available in readonly mode.
UpdateManagedProjectManager.5=Managed project conversion FAILED: \n ManagedBuildManager version {0} is not equivalent to ManagedProject version {1} (project ID = {2})
UpdateManagedProjectManager.5=Managed Make project conversion failed: \n Managed Build System version {0} is not equivalent to the Managed Make project version {1} (project ID = {2})
UpdateManagedProjectManager.6=the project .cdtbuild file does not exist

View file

@ -4,7 +4,7 @@
#########################################
# ------- Project Update Messages -------
ManagedBuilderStartup.update.20x.title=Update Managed Builder Project
ManagedBuilderStartup.update.20x.title=Update Managed Make Project
ManagedBuilderStartup.update.20x.message=The project {0} has been detected in your workspace.\n Its build settings are stored in a format that is no longer supported.\n Would you like to convert them now?
# ------- NewProjectCreationPluginPage-------
@ -54,7 +54,7 @@ BuildPropertyPage.tip.addconf=Add configurations for the platform
BuildPropertyPage.tip.remconf=Remove configurations for the platform
BuildPropertyPage.manage.title=Manage
BuildPropertyPage.error.Unknown_tree_element=Unknown type of element in tree of type {0}
BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be upgraded.
BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be displayed.
BuildPropertyPage.defaults.title=Reset Configuration Tools
BuildPropertyPage.defaults.message=This action will reset all of the tools in the selected configuration to their default settings.\n\nDo you want to proceed?
BuildPropertyPage.changes.save.title=Apply Configuration Changes
@ -87,6 +87,7 @@ ResourceBuildPropertyPage.selection.configuration.all=All configurations
ResourceBuildPropertyPage.label.ToolTree=Tools
ResourceBuildPropertyPage.label.ToolOptions=Options
ResourceBuildPropertyPage.label.NotMBSFile=The project is closed or the file is not contained within a Managed Make project.
ResourceBuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be displayed.
# ----------- Entry Dialog -----------
BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid

View file

@ -141,6 +141,7 @@ public class BuildPropertyPage extends PropertyPage implements IWorkbenchPropert
invalidInfo.setFont(parent.getFont());
invalidInfo.setText(ManagedBuilderUIMessages.getResourceString("BuildPropertyPage.error.version_low")); //$NON-NLS-1$
invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_CENTER, true, true));
noDefaultAndApplyButton();
return;
}
projectTypes = ManagedBuildManager.getDefinedProjectTypes();

View file

@ -152,6 +152,9 @@ public class ResourceBuildPropertyPage extends PropertyPage implements
invalidInfo.setFont(composite.getFont());
invalidInfo.setText(ManagedBuilderUIMessages.getResourceString("ResourceBuildPropertyPage.error.version_low")); //$NON-NLS-1$
invalidInfo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING,GridData.VERTICAL_ALIGN_CENTER, true, true));
noContentOnPage = true;
noDefaultAndApplyButton();
return;
}
// Add a config selection area

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderHelpContextIds;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIMessages;
import org.eclipse.cdt.managedbuilder.internal.ui.ManagedBuilderUIPlugin;
@ -122,8 +123,9 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
// Add the ManagedProject to the project
IManagedProject newManagedProject = null;
IManagedBuildInfo info = null;
try {
ManagedBuildManager.createBuildInfo(newProject);
info = ManagedBuildManager.createBuildInfo(newProject);
IProjectType parent = projectConfigurationPage.getSelectedProjectType();
newManagedProject = ManagedBuildManager.createManagedProject(newProject, parent);
if (newManagedProject != null) {
@ -168,7 +170,10 @@ public class NewManagedProjectWizard extends NewCProjectWizard {
// Save the build options
monitor.subTask(ManagedBuilderUIMessages.getResourceString(MSG_SAVE));
ManagedBuildManager.saveBuildInfo(newProject, true);
if (info != null) {
info.setValid(true);
ManagedBuildManager.saveBuildInfo(newProject, true);
}
monitor.done();
}