1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Bug 167519 - Derived files cached in local history

This commit is contained in:
Marc-Andre Laperle 2012-03-15 21:36:11 -04:00
parent d18cb3e07c
commit a8f5e29bcb
2 changed files with 55 additions and 57 deletions

View file

@ -1,16 +1,17 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2003, 2011 IBM Corporation and others. * Copyright (c) 2003, 2012 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
* ARM Ltd. - Minor changes to echo commands * ARM Ltd. - Minor changes to echo commands
* IBM Corporation * IBM Corporation
* Anna Dushistova (Mentor Graphics) - [307244] extend visibility of fields in GnuMakefileGenerator * Anna Dushistova (Mentor Graphics) - [307244] extend visibility of fields in GnuMakefileGenerator
* James Blackburn (Broadcom Corp.) * James Blackburn (Broadcom Corp.)
* Marc-Andre Laperle
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.makegen.gnu; package org.eclipse.cdt.managedbuilder.makegen.gnu;
@ -41,7 +42,6 @@ import org.eclipse.cdt.core.settings.model.ICSourceEntry;
import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor; import org.eclipse.cdt.core.settings.model.util.IPathSettingsContainerVisitor;
import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer;
import org.eclipse.cdt.internal.core.model.Util;
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.IBuilder; import org.eclipse.cdt.managedbuilder.core.IBuilder;
@ -813,6 +813,30 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
return false; return false;
} }
private static void save(StringBuffer buffer, IFile file) throws CoreException {
String encoding = null;
try {
encoding = file.getCharset();
} catch (CoreException ce) {
// use no encoding
}
byte[] bytes = null;
if (encoding != null) {
try {
bytes = buffer.toString().getBytes(encoding);
} catch (Exception e) {
}
} else {
bytes = buffer.toString().getBytes();
}
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
// use a platform operation to update the resource contents
boolean force = true;
file.setContents(stream, force, false, null); // Don't record history
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#regenerateDependencies() * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#regenerateDependencies()
*/ */
@ -993,7 +1017,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
makeBuf.append(addSources(module)); makeBuf.append(addSources(module));
// Save the files // Save the files
Util.save(makeBuf, modMakefile); save(makeBuf, modMakefile);
} }
/** /**
@ -1053,7 +1077,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
} }
// For now, just save the buffer that was populated when the rules were created // For now, just save the buffer that was populated when the rules were created
Util.save(macroBuffer, fileHandle); save(macroBuffer, fileHandle);
} }
@ -1139,7 +1163,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
buffer.append(NEWLINE + addSubdirectories()); buffer.append(NEWLINE + addSubdirectories());
// Save the file // Save the file
Util.save(buffer, fileHandle); save(buffer, fileHandle);
} }
/** /**
@ -1170,7 +1194,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
buffer.append(targetRules); buffer.append(targetRules);
// Save the file // Save the file
Util.save(buffer, fileHandle); save(buffer, fileHandle);
} }
@ -2379,7 +2403,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Figure out the output paths // Figure out the output paths
String optDotExt = EMPTY_STRING; String optDotExt = EMPTY_STRING;
if (outputExtension != null && outputExtension.length() > 0) if (outputExtension.length() > 0)
optDotExt = DOT + outputExtension; optDotExt = DOT + outputExtension;
Vector<IPath> ruleOutputs = new Vector<IPath>(); Vector<IPath> ruleOutputs = new Vector<IPath>();
@ -3570,7 +3594,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
if (bufferLine.endsWith(":")) { //$NON-NLS-1$ if (bufferLine.endsWith(":")) { //$NON-NLS-1$
StringBuffer outBuffer = addDefaultHeader(); StringBuffer outBuffer = addDefaultHeader();
outBuffer.append(inBuffer); outBuffer.append(inBuffer);
Util.save(outBuffer, makefile); save(outBuffer, makefile);
return true; return true;
} }
} }
@ -3709,7 +3733,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Write them out to the makefile // Write them out to the makefile
if (save) { if (save) {
Util.save(outBuffer, makefile); save(outBuffer, makefile);
return true; return true;
} }
return false; return false;
@ -4280,7 +4304,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
// Make sure the folder is marked as derived so it is not added to CM // Make sure the folder is marked as derived so it is not added to CM
if (!folder.isDerived()) { if (!folder.isDerived()) {
folder.setDerived(true); folder.setDerived(true, null);
} }
} }
@ -4306,7 +4330,7 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
newFile.create(contents, false, new SubProgressMonitor(monitor, 1)); newFile.create(contents, false, new SubProgressMonitor(monitor, 1));
// Make sure the new file is marked as derived // Make sure the new file is marked as derived
if (!newFile.isDerived()) { if (!newFile.isDerived()) {
newFile.setDerived(true); newFile.setDerived(true, null);
} }
} }

View file

@ -1,21 +1,20 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2009 IBM Corporation and others. * Copyright (c) 2002, 2012 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 Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* IBM Corporation - EFS support * IBM Corporation - EFS support
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -129,31 +128,6 @@ public class Util implements ICLogConstants {
return contents; return contents;
} }
public static void save(StringBuffer buffer, IFile file)
throws CoreException {
String encoding = null;
try {
encoding = file.getCharset();
} catch (CoreException ce) {
// use no encoding
}
byte[] bytes = null;
if (encoding != null) {
try {
bytes = buffer.toString().getBytes(encoding);
} catch (Exception e) {
}
} else {
bytes = buffer.toString().getBytes();
}
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
// use a platform operation to update the resource contents
boolean force = true;
file.setContents(stream, force, true, null); // record history
}
/** /**
* Returns the given file's contents as a character array. * Returns the given file's contents as a character array.
*/ */