mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
bug 306222: Further enhancement of Save Build Console feature
Discontinue logging per configuration added in bug 294106
This commit is contained in:
parent
260dc6e8f0
commit
e7c1bd5900
9 changed files with 41 additions and 521 deletions
|
@ -9,7 +9,8 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
* Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
|
||||
* Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
|
||||
* Save build output
|
||||
* Save build output (bug 294106)
|
||||
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.core;
|
||||
|
||||
|
@ -30,7 +31,6 @@ import org.eclipse.cdt.core.ICommandLauncher;
|
|||
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||
import org.eclipse.cdt.core.resources.ACBuilder;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.cdt.internal.core.BuildOutputLogger;
|
||||
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
||||
import org.eclipse.cdt.make.internal.core.MakeMessages;
|
||||
import org.eclipse.cdt.make.internal.core.StreamMonitor;
|
||||
|
@ -218,8 +218,7 @@ public class MakeBuilder extends ACBuilder {
|
|||
}
|
||||
ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, info.getErrorParsers());
|
||||
epm.setOutputStream(cos);
|
||||
BuildOutputLogger bol = new BuildOutputLogger(getProject(), epm.getOutputStream());
|
||||
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), bol, last.intValue());
|
||||
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue());
|
||||
OutputStream stdout = streamMon;
|
||||
OutputStream stderr = streamMon;
|
||||
// Sniff console output for scanner info
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* Dmitry Kozlov (CodeSourcery) - Save build output preferences
|
||||
* Dmitry Kozlov (CodeSourcery) - Save build output preferences (bug 294106)
|
||||
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.core;
|
||||
|
||||
|
@ -631,33 +632,4 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont
|
|||
IBuildPropertyValue getBuildArtefactType();
|
||||
|
||||
void setBuildArtefactType(String id) throws BuildException;
|
||||
|
||||
/**
|
||||
* Set name of file to save build log
|
||||
* @param fileName full file name where to build log file
|
||||
* @since 7.0
|
||||
*/
|
||||
public void setBuildLogFilename(String fileName);
|
||||
|
||||
/**
|
||||
* Get name of file to which build log is saved
|
||||
* @return full filename where to save build log file
|
||||
* @since 7.0
|
||||
*/
|
||||
public String getBuildLogFilename();
|
||||
|
||||
/**
|
||||
* Set whether to save build log
|
||||
* @param saveBuildLog whether to save build log
|
||||
* @since 7.0
|
||||
*/
|
||||
public void setSavingBuildLog(boolean saveBuildLog);
|
||||
|
||||
/**
|
||||
* Test if build log saving is turned on
|
||||
* @return true if saving build log is enabled
|
||||
* @since 7.0
|
||||
*/
|
||||
public boolean isSavingBuildLog();
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
* Intel Corporation - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Dmitry Kozlov (CodeSourcery) - Build error highlighting and navigation
|
||||
* Save build output
|
||||
* Save build output (bug 294106)
|
||||
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
|
@ -43,7 +44,6 @@ import org.eclipse.cdt.core.resources.IConsole;
|
|||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.util.ListComparator;
|
||||
import org.eclipse.cdt.internal.core.BuildOutputLogger;
|
||||
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
|
||||
|
@ -908,7 +908,6 @@ public class CommonBuilder extends ACBuilder {
|
|||
ConsoleOutputStream consoleOutStream = null;
|
||||
IConsole console = null;
|
||||
OutputStream epmOutputStream = null;
|
||||
BuildOutputLogger bol = null;
|
||||
try {
|
||||
int flags = 0;
|
||||
IResourceDelta delta = getDelta(currentProject);
|
||||
|
@ -950,19 +949,10 @@ public class CommonBuilder extends ACBuilder {
|
|||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
consoleOutStream.write(buf.toString().getBytes());
|
||||
consoleOutStream.flush();
|
||||
|
||||
IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, cBS, delta, flags);
|
||||
// Hook up an error parser manager
|
||||
String[] errorParsers = builder.getErrorParsers();
|
||||
ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocationURI(), this, errorParsers);
|
||||
epm.setOutputStream(consoleOutStream);
|
||||
// This variable is necessary to ensure that the EPM stream stay open
|
||||
// until we explicitly close it. See bug#123302.
|
||||
epmOutputStream = epm.getOutputStream();
|
||||
bol = new BuildOutputLogger(getProject(), epmOutputStream);
|
||||
|
||||
bol.write(buf.toString().getBytes());
|
||||
bol.flush();
|
||||
|
||||
DescriptionBuilder dBuilder = null;
|
||||
if (!isParallel)
|
||||
|
@ -972,13 +962,21 @@ public class CommonBuilder extends ACBuilder {
|
|||
// Remove all markers for this project
|
||||
removeAllMarkers(currentProject);
|
||||
|
||||
// Hook up an error parser manager
|
||||
String[] errorParsers = builder.getErrorParsers();
|
||||
ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocationURI(), this, errorParsers);
|
||||
epm.setOutputStream(consoleOutStream);
|
||||
// This variable is necessary to ensure that the EPM stream stay open
|
||||
// until we explicitly close it. See bug#123302.
|
||||
epmOutputStream = epm.getOutputStream();
|
||||
|
||||
int status = 0;
|
||||
|
||||
long t1 = System.currentTimeMillis();
|
||||
if (isParallel)
|
||||
status = ParallelBuilder.build(des, null, null, bol, bol, monitor, resumeOnErr, buildIncrementaly);
|
||||
status = ParallelBuilder.build(des, null, null, epmOutputStream, epmOutputStream, monitor, resumeOnErr, buildIncrementaly);
|
||||
else
|
||||
status = dBuilder.build(bol, bol, monitor);
|
||||
status = dBuilder.build(epmOutputStream, epmOutputStream, monitor);
|
||||
long t2 = System.currentTimeMillis();
|
||||
|
||||
// Report either the success or failure of our mission
|
||||
|
@ -1018,9 +1016,10 @@ public class CommonBuilder extends ACBuilder {
|
|||
}
|
||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
// Write message on the console
|
||||
bol.write(buf.toString().getBytes());
|
||||
bol.flush();
|
||||
|
||||
consoleOutStream.write(buf.toString().getBytes());
|
||||
consoleOutStream.flush();
|
||||
epmOutputStream.close();
|
||||
epmOutputStream = null;
|
||||
// Generate any error markers that the build has discovered
|
||||
monitor.subTask(ManagedMakeMessages
|
||||
.getResourceString(MARKERS));
|
||||
|
@ -1030,8 +1029,8 @@ public class CommonBuilder extends ACBuilder {
|
|||
buf = new StringBuffer();
|
||||
buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName()));
|
||||
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
|
||||
bol.write(buf.toString().getBytes());
|
||||
bol.flush();
|
||||
consoleOutStream.write(buf.toString().getBytes());
|
||||
consoleOutStream.flush();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -1052,12 +1051,6 @@ public class CommonBuilder extends ACBuilder {
|
|||
}
|
||||
forgetLastBuiltState();
|
||||
} finally {
|
||||
if ( bol != null ) {
|
||||
try {
|
||||
bol.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
if(epmOutputStream != null){
|
||||
try {
|
||||
epmOutputStream.close();
|
||||
|
@ -1910,8 +1903,7 @@ public class CommonBuilder extends ACBuilder {
|
|||
}
|
||||
ErrorParserManager epm = new ErrorParserManager(currProject, workingDirectoryURI, this, builder.getErrorParsers());
|
||||
epm.setOutputStream(cos);
|
||||
BuildOutputLogger bol = new BuildOutputLogger(getProject(), epm.getOutputStream());
|
||||
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), bol, last.intValue());
|
||||
StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), epm, last.intValue());
|
||||
OutputStream stdout = streamMon;
|
||||
OutputStream stderr = streamMon;
|
||||
// Sniff console output for scanner info
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
* Contributors:
|
||||
* IBM - Initial API and implementation
|
||||
* James Blackburn (Broadcom Corp.)
|
||||
* Dmitry Kozlov (CodeSourcery) - Save build output preferences
|
||||
* Dmitry Kozlov (CodeSourcery) - Save build output preferences (bug 294106)
|
||||
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
|
@ -158,8 +159,6 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
private static final String RC_CHANGE_STATE = "rcState"; //$NON-NLS-1$
|
||||
//resource change state
|
||||
private int resourceChangeState = -1;
|
||||
private String buildLogFilename = null;
|
||||
private boolean savingBuildLog = false;
|
||||
|
||||
//Internal Builder state
|
||||
//NOTE: these are temporary properties
|
||||
|
@ -3058,33 +3057,4 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild
|
|||
public boolean isExtensionBuildObject() {
|
||||
return isExtensionElement();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setBuildLogFilename()
|
||||
*/
|
||||
public void setBuildLogFilename(String fileName) {
|
||||
buildLogFilename = fileName;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#getBuildLogFilename()
|
||||
*/
|
||||
public String getBuildLogFilename() {
|
||||
return buildLogFilename;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setSavingBuildLog()
|
||||
*/
|
||||
public void setSavingBuildLog(boolean save) {
|
||||
savingBuildLog = save;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#isSavingBuildLog()
|
||||
*/
|
||||
public boolean isSavingBuildLog() {
|
||||
return savingBuildLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* Dmitry Kozlov (CodeSourcery) - Save build output preferences
|
||||
* Dmitry Kozlov (CodeSourcery) - Save build output preferences (bug 294106)
|
||||
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.core;
|
||||
|
||||
|
@ -1254,39 +1255,4 @@ public class MultiConfiguration extends MultiItemsHolder implements
|
|||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setBuildLogFilename()
|
||||
* Multiconfiguration implementation is not provided
|
||||
* since the control is disabled in properties in this mode.
|
||||
*/
|
||||
public String getBuildLogFilename() {
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#isSavingBuildLog()
|
||||
* Multiconfiguration implementation is not provided
|
||||
* since the control is disabled in properties in this mode.
|
||||
*/
|
||||
public boolean isSavingBuildLog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setBuildLogFilename()
|
||||
* Multiconfiguration implementation is not provided
|
||||
* since the control is disabled in properties in this mode.
|
||||
*/
|
||||
public void setBuildLogFilename(String fileName) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IConfiguration#setSavingBuildLog()
|
||||
* Multiconfiguration implementation is not provided
|
||||
* since the control is disabled in properties in this mode.
|
||||
*/
|
||||
public void setSavingBuildLog(boolean saveBuildLog) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -559,22 +559,4 @@ public class TestConfiguration implements IConfiguration {
|
|||
|
||||
}
|
||||
|
||||
public String getBuildLogFilename() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isSavingBuildLog() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setBuildLogFilename(String fileName) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void setSavingBuildLog(boolean saveBuildLog) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,23 +8,18 @@
|
|||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Dmitry Kozlov (CodeSourcery) - save build output preferences
|
||||
* Dmitry Kozlov (CodeSourcery) - save build output preferences (bug 294106)
|
||||
* Andrew Gvozdev (Quoin Inc) - Saving build output implemented in different way (bug 306222)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.ui.properties;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
||||
import org.eclipse.cdt.internal.core.BuildOutputLogger;
|
||||
import org.eclipse.cdt.managedbuilder.core.IBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IMultiConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.MultiConfiguration;
|
||||
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
|
||||
import org.eclipse.cdt.ui.newui.CDTPropertyManager;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
|
@ -37,7 +32,6 @@ import org.eclipse.swt.widgets.Button;
|
|||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
@ -63,10 +57,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
private Button b_dirFile;
|
||||
private Button b_dirVars;
|
||||
private Group group_dir;
|
||||
private Text saveBuildFilename;
|
||||
private Button saveBuildFileButton;
|
||||
private Button saveBuildCheckbox;
|
||||
private Group buildOutputGroup;
|
||||
|
||||
private IBuilder bldr;
|
||||
private IConfiguration icfg;
|
||||
|
@ -133,46 +123,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
b_dirWsp = setupBottomButton(c, WORKSPACEBUTTON_NAME);
|
||||
b_dirFile = setupBottomButton(c, FILESYSTEMBUTTON_NAME);
|
||||
b_dirVars = setupBottomButton(c, VARIABLESBUTTON_NAME);
|
||||
|
||||
// Save build output group
|
||||
if ( page.isForProject() ) {
|
||||
buildOutputGroup = setupGroup(usercomp,
|
||||
Messages.getString("BuilderSettingsTab.23"), //$NON-NLS-1$
|
||||
3, GridData.FILL_HORIZONTAL);
|
||||
@SuppressWarnings("unused")
|
||||
Label l = setupLabel(buildOutputGroup, Messages.getString("BuilderSettingsTab.24"), 1, GridData.BEGINNING); //$NON-NLS-1$
|
||||
saveBuildFilename = setupText(buildOutputGroup, 1, GridData.FILL_HORIZONTAL);
|
||||
saveBuildFilename.addModifyListener(new ModifyListener() {
|
||||
public void modifyText(ModifyEvent e) {
|
||||
if ( BuildOutputLogger.canWriteToFile(saveBuildFilename.getText())) {
|
||||
saveBuildCheckbox.setEnabled(true);
|
||||
//saveBuildCheckbox.setSelection(true);
|
||||
} else {
|
||||
saveBuildCheckbox.setEnabled(false);
|
||||
saveBuildCheckbox.setSelection(false);
|
||||
}
|
||||
icfg.setBuildLogFilename(saveBuildFilename.getText());
|
||||
icfg.setSavingBuildLog(saveBuildCheckbox.getSelection());
|
||||
}} );
|
||||
saveBuildFileButton = new Button(buildOutputGroup, SWT.PUSH);
|
||||
saveBuildFileButton.setText(Messages.getString("BuilderSettingsTab.25")); //$NON-NLS-1$
|
||||
saveBuildFileButton.setData(saveBuildFilename);
|
||||
saveBuildFileButton.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
buttonVarPressed(event);
|
||||
}});
|
||||
saveBuildCheckbox = new Button(buildOutputGroup, SWT.CHECK);
|
||||
saveBuildCheckbox.setText(Messages.getString("BuilderSettingsTab.26")); //$NON-NLS-1$
|
||||
saveBuildCheckbox.setEnabled(false);
|
||||
saveBuildCheckbox.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if ( ((Control)event.widget) == saveBuildCheckbox ) {
|
||||
icfg.setSavingBuildLog(!icfg.isSavingBuildLog());
|
||||
}
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
private void setManagedBuild(boolean enable) {
|
||||
|
@ -246,30 +196,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
if (external) { // just set relatet text widget state,
|
||||
checkPressed(b_useDefault, false); // do not update
|
||||
}
|
||||
|
||||
if ( page.isForProject() ) {
|
||||
if ( page.isMultiCfg() ) {
|
||||
buildOutputGroup.setVisible(false);
|
||||
} else {
|
||||
boolean b = icfg.isSavingBuildLog();
|
||||
buildOutputGroup.setVisible(true);
|
||||
String s = icfg.getBuildLogFilename();
|
||||
if ( s != null ) {
|
||||
saveBuildFilename.setText(s);
|
||||
} else {
|
||||
saveBuildFilename.setText(""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if ( s != null && BuildOutputLogger.canWriteToFile(s) ) {
|
||||
saveBuildCheckbox.setSelection(b);
|
||||
icfg.setSavingBuildLog(b);
|
||||
} else {
|
||||
saveBuildCheckbox.setEnabled(false);
|
||||
saveBuildCheckbox.setSelection(false);
|
||||
icfg.setSavingBuildLog(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
canModify = true;
|
||||
}
|
||||
|
||||
|
@ -320,11 +246,6 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
} else if (b.equals(b_dirFile)) {
|
||||
x = getFileSystemDirDialog(usercomp.getShell(), EMPTY_STR);
|
||||
if (x != null) ((Text)b.getData()).setText(x);
|
||||
} else if (b.equals(saveBuildFileButton)) {
|
||||
FileDialog dialog = new FileDialog(usercomp.getShell(), SWT.SAVE);
|
||||
dialog.setText(FILESYSTEM_FILE_DIALOG_TITLE);
|
||||
x = dialog.open();
|
||||
if (x != null) ((Text)b.getData()).setText(x);
|
||||
} else {
|
||||
x = AbstractCPropertyTab.getVariableDialog(usercomp.getShell(), getResDesc().getConfiguration());
|
||||
if (x != null) ((Text)b.getData()).insert(x);
|
||||
|
@ -369,8 +290,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
}
|
||||
|
||||
/**
|
||||
* get make command
|
||||
* @return
|
||||
* @return make command
|
||||
*/
|
||||
private String getMC() {
|
||||
String makeCommand = bldr.getCommand();
|
||||
|
@ -381,67 +301,17 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
/**
|
||||
* Performs common settings for all controls
|
||||
* (Copy from config to widgets)
|
||||
* @param cfgd -
|
||||
*/
|
||||
@Override
|
||||
public void updateData(ICResourceDescription cfgd) {
|
||||
if (cfgd == null) return;
|
||||
icfg = getCfg(cfgd.getConfiguration());
|
||||
if (icfg.getBuildLogFilename() == null) {
|
||||
// In this case this tab is loaded for the first time,
|
||||
// and we need to populate configuration with values stored
|
||||
// in Preferences. This is horrible workaround because we need
|
||||
// to use this settings in build console which is in cdt ui,
|
||||
// hence IConfiguration is not accessible there and this values
|
||||
// have be stored separately.
|
||||
// That is why we have convention that IConfiguration have
|
||||
// buildLogFilename set to null this means that it is not loaded.
|
||||
// Otherwise it is loaded and doesn't require reloading.
|
||||
// performOk, performApply and performDefaults shouldn't never write
|
||||
// null values to Preferences to distinct this case from overs.
|
||||
//
|
||||
// To properly fix this problem without this workaround we need
|
||||
// to make IConfiguration accessible for buildconsole package
|
||||
loadBuildLogSettings(page.getProject(), icfg);
|
||||
}
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
private static void loadBuildLogSettings(IProject project, IConfiguration icfg) {
|
||||
BuildOutputLogger.SaveBuildOutputPreferences bp = BuildOutputLogger.readSaveBuildOutputPreferences(project, icfg.getName());
|
||||
icfg.setBuildLogFilename(bp.fileName);
|
||||
icfg.setSavingBuildLog(bp.isSaving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performApply(ICResourceDescription src, ICResourceDescription dst) {
|
||||
BuildBehaviourTab.apply(src, dst, page.isMultiCfg());
|
||||
BuildOutputLogger.SaveBuildOutputPreferences bp = new BuildOutputLogger.SaveBuildOutputPreferences();
|
||||
bp.fileName = icfg.getBuildLogFilename();
|
||||
bp.isSaving = icfg.isSavingBuildLog();
|
||||
BuildOutputLogger.writeSaveBuildOutputPreferences(page.getProject(), icfg.getName(), bp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performOK() {
|
||||
if ( page.isForProject() ) {
|
||||
// Saving for all configurations
|
||||
ICProjectDescription pd = CDTPropertyManager.getProjectDescription(page.getProject());
|
||||
if ( pd != null ) {
|
||||
ICConfigurationDescription cfgs[] = pd.getConfigurations();
|
||||
if ( cfgs != null ) {
|
||||
for (ICConfigurationDescription cd : cfgs) {
|
||||
IConfiguration c = ManagedBuildManager.getConfigurationForDescription(cd);
|
||||
BuildOutputLogger.SaveBuildOutputPreferences bp = new BuildOutputLogger.SaveBuildOutputPreferences();
|
||||
bp.fileName = c.getBuildLogFilename();
|
||||
bp.isSaving = c.isSavingBuildLog();
|
||||
BuildOutputLogger.writeSaveBuildOutputPreferences(page.getProject(), c.getName(), bp);
|
||||
c.setBuildLogFilename(null);
|
||||
c.setSavingBuildLog(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -470,17 +340,14 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
|
|||
|
||||
@Override
|
||||
protected void performDefaults() {
|
||||
icfg.setBuildLogFilename(""); //$NON-NLS-1$
|
||||
icfg.setSavingBuildLog(false);
|
||||
if (icfg instanceof IMultiConfiguration) {
|
||||
IConfiguration[] cfs = (IConfiguration[])((IMultiConfiguration)icfg).getItems();
|
||||
for (int i=0; i<cfs.length; i++) {
|
||||
IBuilder b = cfs[i].getEditableBuilder();
|
||||
BuildBehaviourTab.copyBuilders(b.getSuperClass(), b);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
BuildBehaviourTab.copyBuilders(bldr.getSuperClass(), bldr);
|
||||
}
|
||||
updateData(getResDesc());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,6 @@ BuilderSettingsTab.19=Build (Incremental build)
|
|||
BuilderSettingsTab.20=Clean
|
||||
BuilderSettingsTab.21=Build location
|
||||
BuilderSettingsTab.22=Build &directory:
|
||||
BuilderSettingsTab.23=Build output
|
||||
BuilderSettingsTab.24=&File location:
|
||||
BuilderSettingsTab.25=Browse
|
||||
BuilderSettingsTab.26=&Save build output to file
|
||||
BuildStepsTab.0=Command:
|
||||
BuildStepsTab.1=Description:
|
||||
BuildStepsTab.2=Pre-build steps
|
||||
|
|
|
@ -1,224 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2010 CodeSourcery and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Dmitry Kozlov (CodeSourcery) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
|
||||
/**
|
||||
* Output stream adapter saving build output in a file.
|
||||
*
|
||||
*/
|
||||
public class BuildOutputLogger extends OutputStream {
|
||||
|
||||
private static final String SAVE_CONSOLE_FILE_ID =
|
||||
CCorePlugin.PLUGIN_ID + "." + "saveBuildOutputToFile"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static final String SAVE_CONSOLE_STATE_ID =
|
||||
CCorePlugin.PLUGIN_ID + "." + "isSavingBuildOutput"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private URI fileUri;
|
||||
private BufferedOutputStream log;
|
||||
private OutputStream outputStream;
|
||||
|
||||
|
||||
public BuildOutputLogger(IProject project, OutputStream stream) {
|
||||
super();
|
||||
this.outputStream = stream;
|
||||
SaveBuildOutputPreferences bp = readSaveBuildOutputPreferences(project);
|
||||
if ( ! bp.isSaving || log != null ) return;
|
||||
|
||||
try {
|
||||
fileUri = URIUtil.toURI(bp.fileName);
|
||||
IFileStore fs = EFS.getStore(fileUri);
|
||||
OutputStream out = fs.openOutputStream(EFS.NONE, null);
|
||||
log = new BufferedOutputStream(out);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
log = null;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.io.OutputStream#write(int)
|
||||
*/
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
outputStream.write(b);
|
||||
if ( log != null ) {
|
||||
log.write(b);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.io.OutputStream#write(byte[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
outputStream.write(b);
|
||||
if ( log != null ) {
|
||||
log.write(b);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.io.OutputStream#write(byte[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
outputStream.write(b, off, len);
|
||||
if ( log != null ) {
|
||||
log.write(b, off, len);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.io.OutputStream#close()
|
||||
*/
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
if ( log != null ) {
|
||||
try {
|
||||
log.flush();
|
||||
log.close();
|
||||
log = null;
|
||||
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(fileUri);
|
||||
for (IFile file : files) {
|
||||
try {
|
||||
file.refreshLocal(IResource.DEPTH_ONE, null);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.io.OutputStream#flush()
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
outputStream.flush();
|
||||
if ( log != null ) {
|
||||
log.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public static class SaveBuildOutputPreferences {
|
||||
public String fileName;
|
||||
public boolean isSaving;
|
||||
|
||||
@Override
|
||||
public String toString() { return fileName + " " + isSaving; } //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/** Read SaveBuildOutput preferences for active configuration */
|
||||
public static SaveBuildOutputPreferences readSaveBuildOutputPreferences(IProject project) {
|
||||
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
|
||||
if ( projDesc == null ) return new SaveBuildOutputPreferences();
|
||||
ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
|
||||
return readSaveBuildOutputPreferences(project, configDesc.getName());
|
||||
}
|
||||
|
||||
/** Read SaveBuildOutput preferences for configuration, specified by name */
|
||||
public static SaveBuildOutputPreferences readSaveBuildOutputPreferences(IProject project, String configurationName) {
|
||||
SaveBuildOutputPreferences bp = new SaveBuildOutputPreferences();
|
||||
String key;
|
||||
IEclipsePreferences pref = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
|
||||
|
||||
key = getFileNameKey(project, configurationName);
|
||||
bp.fileName = pref.get(key, null);
|
||||
|
||||
key = getIsSavingKey(project, configurationName);
|
||||
bp.isSaving = pref.getBoolean(key,false);
|
||||
|
||||
if ( bp.fileName == null || ! canWriteToFile(bp.fileName)) {
|
||||
bp.isSaving = false;
|
||||
}
|
||||
return bp;
|
||||
}
|
||||
|
||||
/** Write SaveBuildOutput preferences for active configuration */
|
||||
public static void writeSaveBuildOutputPreferences(IProject project, SaveBuildOutputPreferences bp) {
|
||||
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project);
|
||||
if ( projDesc == null ) return;
|
||||
ICConfigurationDescription configDesc = projDesc.getActiveConfiguration();
|
||||
writeSaveBuildOutputPreferences(project, configDesc.getName(), bp);
|
||||
}
|
||||
|
||||
/** Write SaveBuildOutput preferences for configuration, specified by name */
|
||||
public static void writeSaveBuildOutputPreferences(IProject project, String configurationName,
|
||||
SaveBuildOutputPreferences bp) {
|
||||
try {
|
||||
String key = getFileNameKey(project,configurationName);
|
||||
IEclipsePreferences preferences = new InstanceScope().getNode(CCorePlugin.PLUGIN_ID);
|
||||
if ( bp.fileName == null || "".equals(bp.fileName)) { //$NON-NLS-1$
|
||||
preferences.remove(key);
|
||||
} else {
|
||||
preferences.put(key, bp.fileName);
|
||||
}
|
||||
key = getIsSavingKey(project,configurationName);
|
||||
preferences.putBoolean(key, bp.isSaving);
|
||||
} catch (Exception e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canWriteToFile(String fileName) {
|
||||
if ( fileName != null && fileName.length() > 0 ) {
|
||||
// Check path exists in filesystem
|
||||
File f = new File(fileName);
|
||||
if ( f.getParentFile() != null &&
|
||||
f.getParentFile().exists() &&
|
||||
f.getParentFile().isDirectory() &&
|
||||
( !f.exists() || (f.exists() && f.canWrite()) ) ) {
|
||||
// File can be written
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getFileNameKey(IProject project, String cfgName) {
|
||||
// Make this preference key to be per project
|
||||
return SAVE_CONSOLE_FILE_ID + "." + project.getName() + "." + cfgName; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public static String getIsSavingKey(IProject project, String cfgName) {
|
||||
// Make this preference key to be per project
|
||||
return SAVE_CONSOLE_STATE_ID + "." + project.getName() + "." + cfgName; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue