diff -r bb339882c6e9 -r 0367d2db2c06 sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/builder/AnalyzeToolBuilder.java --- a/sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/builder/AnalyzeToolBuilder.java Tue Aug 24 12:10:03 2010 +0300 +++ b/sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/builder/AnalyzeToolBuilder.java Tue Aug 24 12:16:27 2010 +0300 @@ -17,6 +17,7 @@ package com.nokia.s60tools.analyzetool.builder; +import java.text.MessageFormat; import java.util.AbstractList; import java.util.ArrayList; import java.util.Iterator; @@ -33,28 +34,27 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.PlatformUI; +import org.eclipse.swt.SWT; +import com.nokia.carbide.cdt.builder.BuildArgumentsInfo; import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin; import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder; import com.nokia.carbide.cdt.builder.builder.CarbideCommandLauncher; import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo; -import com.nokia.carbide.cdt.builder.BuildArgumentsInfo; import com.nokia.s60tools.analyzetool.Activator; import com.nokia.s60tools.analyzetool.global.Constants; import com.nokia.s60tools.analyzetool.global.Util; -import com.nokia.s60tools.analyzetool.ui.CustomInputDialog; /** * Base class for AnalyzeTool builders. - * + * * This class modifies Carbide builder settings during the AnalyzeTool build. * This class can be used to built whole project or selected components with * AnalyzeTool - * + * * @author kihe - * + * */ public class AnalyzeToolBuilder extends CarbideCPPBuilder { @@ -72,7 +72,7 @@ /** * Gets shared instance of CarbideCommandLauncher. - * + * * @return CarbideCommandLauncher reference */ protected static CarbideCommandLauncher getCarbideCommandLauncher() { @@ -81,7 +81,7 @@ /** * Checks is SBS v2 build activated for the project. - * + * * @param cpi * ICarbideProjectInfo * @return True if SBS v2 build is activated otherwise False @@ -104,7 +104,6 @@ Boolean obj = (Boolean) oneMethod.invoke( CarbideBuilderPlugin.getBuildManager(), objs); return obj.booleanValue(); - } } } catch (ClassNotFoundException cnfe) { @@ -127,83 +126,14 @@ } /** - * Ask data file name from the user and after that executes atool.exe. - * - * @param monitor - * {@link IProgressMonitor} reference - * @param cpi - * {@link ICarbideProjectInfo} reference - * @param files - * Used mmp files - * - * @return COMMAND_LINE_ERROR_CODE.OK if no errors, otherwise error code - */ - private int askFileNameAndBuild(final IProgressMonitor monitor, - final ICarbideProjectInfo cpi, final List files) { - // ask for the user data file name - CustomInputDialog dialog = new CustomInputDialog( - Constants.ANALYZE_TOOL_TITLE, - Constants.DIALOG_INPUT_DATA_FILE_NAME, ""); - dialog.open(); - - //get data file name - String dataFileName = dialog.getUserInput(); - int errorCode = Constants.COMMAND_LINE_ERROR_CODE.OK.getCode(); - // user press "Cancel" - if (dataFileName == null || ("").equals(dataFileName)) { - buildCancelled(monitor, true); - } else { // if user specify data file name - errorCode = executeAtool(dataFileName, Constants.ATOOL_INST, - Constants.LOGGING_S60, files, cpi, monitor); - } - return errorCode; - } - - /** - * Ask logging mode from the user. - * - * @return User selected logging mode - */ - private String askLoggingMode() { - - IPreferenceStore store = Activator.getPreferences(); - - // logging modes - AbstractList modes = new ArrayList(); - modes.add(Constants.PREFS_EXT); - - // if fast data gathering mode is enabled => add to selection list - if( store.getBoolean(Constants.LOGGING_FAST_ENABLED ) ) { - modes.add(Constants.PREFS_EXT_FAST); - } - modes.add(Constants.PREFS_S60); - - // open selection dialog - String userSelection = Util.openSelectionDialog( - Constants.DIALOG_SELECT_LOGGING_MODE, null, modes); - - // get used logging mode for the atool.exe - // user selected logging mode can not be used straight because it is - // different in the UI and which atool.exe uses - String modeSelection = ""; - if (userSelection == Constants.PREFS_EXT) { - modeSelection = Constants.LOGGING_EXT; - } else if (userSelection == Constants.PREFS_S60) { - modeSelection = Constants.LOGGING_S60; - } else if( userSelection == Constants.PREFS_EXT_FAST) { - modeSelection = Constants.LOGGING_EXT_FAST; - } - return modeSelection; - } - - /** * Cancels AnalyzeTool build. - * + * * @param monitor * Currently running progress monitor * @param continueBuild - * False stops the whole build chain (including Carbide and other builders) - * otherwise other than AnalyzeTool builds are executed normally. + * False stops the whole build chain (including Carbide and other + * builders) otherwise other than AnalyzeTool builds are executed + * normally. */ public final void buildCancelled(final IProgressMonitor monitor, final boolean continueBuild) { @@ -221,7 +151,6 @@ // update monitor state monitor.setCanceled(true); monitor.done(); - } boolean promptMPPChange = store.getBoolean(Constants.PREFS_PROMPT_MMP); @@ -250,9 +179,9 @@ /** * Builds user selected components. - * + * * Normally this method is called from the CompileSymbianComponent - * + * * @param selectedFiles * User selected files */ @@ -278,8 +207,9 @@ // run pre steps for the build if (!runPreSteps(cmdLauncher, monitor, cpi)) { - return new Status(IStatus.OK, Constants.ANALYZE_TOOL_TITLE, - IStatus.OK, Constants.CANCELLED, null); + return new Status(IStatus.OK, + Constants.ANALYZE_TOOL_TITLE, IStatus.OK, + Constants.CANCELLED, null); } // build selected components @@ -288,7 +218,7 @@ // run post steps runPostSteps(cpi); - //after the build is finished => open the console view + // after the build is finished => open the console view Util.openConsoleView(); } finally { monitor.done(); @@ -304,15 +234,16 @@ /** * Checks that platform is ARMV5, GCEE or WINSCW - * + * * @param cpi * ICarbideProjectInfo * @return True if platform is set to ARMV5, GCCE or WINSCW otherwise False */ public final boolean checkPlatform(final ICarbideProjectInfo cpi) { String platform = cpi.getDefaultConfiguration().getPlatformString(); - if ( platform.equals(Constants.BUILD_TARGET_ARMV5) || platform.equals(Constants.BUILD_TARGET_WINSCW) - || platform.equals(Constants.BUILD_TARGET_GCEE) ) { + if (platform.equals(Constants.BUILD_TARGET_ARMV5) + || platform.equals(Constants.BUILD_TARGET_WINSCW) + || platform.equals(Constants.BUILD_TARGET_GCEE)) { return true; } return false; @@ -320,9 +251,11 @@ /** * Executes atool.exe with options. - * - * @param dataFileName - * Used data file name + * + * @param path + * log path + * @param fileName + * log file name * @param type * Type of execution. Possible types ATOOL_INST or ATOOL_UNINST * @param loggingModeCommand @@ -333,40 +266,41 @@ * ICarbideProjectInfo reference * @param monitor * Progress monitor reference - * + * * @return COMMAND_LINE_ERROR_CODE.OK if no errors, otherwise error code */ - protected final int executeAtool(final String dataFileName, + protected final int executeAtool(final String path, final String fileName, final String type, final String loggingModeCommand, final List userSelectedMmpFiles, final ICarbideProjectInfo cpi, final IProgressMonitor monitor) { // get used platform - String platform = cpi.getDefaultConfiguration().getPlatformString().toLowerCase(Locale.US); + String platform = cpi.getDefaultConfiguration().getPlatformString() + .toLowerCase(Locale.US); // get build target - String buildTarget = cpi.getDefaultConfiguration().getTargetString().toLowerCase(Locale.US); + String buildTarget = cpi.getDefaultConfiguration().getTargetString() + .toLowerCase(Locale.US); // used arguments to atool.exe AbstractList usedArguments = new ArrayList(); // which logging mode is used - if( loggingModeCommand.equalsIgnoreCase(Constants.LOGGING_EXT) ) - { - usedArguments.add(Constants.ATOOL_INST_E); - } - else if( loggingModeCommand.equalsIgnoreCase(Constants.LOGGING_EXT_FAST)) { + if (loggingModeCommand.equalsIgnoreCase(Constants.LOGGING_EXT_FAST)) { usedArguments.add(Constants.ATOOL_INST_EF); - } - else - { + } else { usedArguments.add(Constants.ATOOL_INST_I); - } + // if path is set + if (path != null && !("").equals(path)) { + usedArguments.add("-fp"); + usedArguments.add(path); + } - // if data file is set - if (dataFileName != null && !("").equals(dataFileName)) { - usedArguments.add("-f"); - usedArguments.add(dataFileName); + // if file name is set + if (fileName != null && !("").equals(fileName)) { + usedArguments.add("-f"); + usedArguments.add(fileName); + } } // if "verbose atool.exe output" is enabled @@ -376,13 +310,13 @@ // get callstack size IPreferenceStore store = Activator.getPreferences(); - if( store.getBoolean(Constants.USE_CALLSTACK_SIZE) ) { + if (store.getBoolean(Constants.USE_CALLSTACK_SIZE)) { int callstackSize = store.getInt(Constants.CALLSTACK_SIZE); usedArguments.add(Constants.CALLSTACK_SIZE_OPTION); usedArguments.add(Integer.toString(callstackSize)); } - //add build command + // add build command // if project using SBSv2 build system boolean sbsBuild = isSBSBuildActivated(cpi); if (sbsBuild) { @@ -393,8 +327,7 @@ buildCommand.append('_'); buildCommand.append(buildTarget); usedArguments.add(buildCommand.toString()); - } - else //use abld + } else // use abld { usedArguments.add("abld"); usedArguments.add("build"); @@ -407,14 +340,14 @@ // this means that call is come from CompileSymbianComponent class if (userSelectedMmpFiles != null && !userSelectedMmpFiles.isEmpty()) { - //get atool.exe command + // get atool.exe command Iterator files = userSelectedMmpFiles.iterator(); - while(files.hasNext()) { + while (files.hasNext()) { IFile file = files.next(); IPath location = file.getLocation(); String mmpFileName = getMMPFileName(location, true); - if( mmpFileName == null || ("").equals(mmpFileName)) { + if (mmpFileName == null || ("").equals(mmpFileName)) { continue; } @@ -423,18 +356,17 @@ usedArguments.add(mmpFileName); } - //now the command is ready - //execute command + // now the command is ready + // execute command // execute atool.exe via CommandLauncher class cmdLauncher.showCommand(true); String[] arguments = new String[usedArguments.size()]; - usedArguments.toArray(arguments); - errorCode = cmdLauncher.executeCommand(new Path(Util - .getAtoolInstallFolder()), arguments, - CarbideCPPBuilder.getResolvedEnvVars(cpi - .getDefaultConfiguration()), cpi - .getINFWorkingDirectory()); + usedArguments.toArray(arguments); + errorCode = cmdLauncher.executeCommand(new Path(Util + .getAtoolInstallFolder()), arguments, CarbideCPPBuilder + .getResolvedEnvVars(cpi.getDefaultConfiguration()), cpi + .getINFWorkingDirectory()); // if user press "Cancel" if (monitor.isCanceled()) { @@ -472,25 +404,23 @@ // now remove AnalyzeTool made modifications // if project contains build erros => only uninstrument mmp // file - if (CarbideCPPBuilder.projectHasBuildErrors(cpi - .getProject())) { + if (CarbideCPPBuilder.projectHasBuildErrors(cpi.getProject())) { usedArguments.set(0, Constants.ATOOL_UNINST_FAILED); } // project succesfully build => uninstrumet project runUninstrument(Constants.ATOOL_UNINST, cpi, monitor); - } // if build from bld.inf file else if (cpi.isBuildingFromInf()) { cmdLauncher.showCommand(true); + String[] arguments = new String[usedArguments.size()]; - usedArguments.toArray(arguments); - errorCode = cmdLauncher.executeCommand(new Path(Util.getAtoolInstallFolder()), - arguments, - CarbideCPPBuilder.getResolvedEnvVars(cpi - .getDefaultConfiguration()), cpi - .getINFWorkingDirectory()); + usedArguments.toArray(arguments); + errorCode = cmdLauncher.executeCommand(new Path(Util + .getAtoolInstallFolder()), arguments, CarbideCPPBuilder + .getResolvedEnvVars(cpi.getDefaultConfiguration()), cpi + .getINFWorkingDirectory()); if (mmpFiles != null) { mmpFiles.clear(); @@ -511,13 +441,13 @@ usedArguments.add(mmpFiles.get(i)); } cmdLauncher.showCommand(true); + String[] arguments = new String[usedArguments.size()]; - usedArguments.toArray(arguments); - errorCode = cmdLauncher.executeCommand(new Path(Util - .getAtoolInstallFolder()), arguments, - CarbideCPPBuilder.getResolvedEnvVars(cpi - .getDefaultConfiguration()), cpi - .getINFWorkingDirectory()); + usedArguments.toArray(arguments); + errorCode = cmdLauncher.executeCommand(new Path(Util + .getAtoolInstallFolder()), arguments, CarbideCPPBuilder + .getResolvedEnvVars(cpi.getDefaultConfiguration()), cpi + .getINFWorkingDirectory()); // if user press "Cancel" if (monitor.isCanceled()) { @@ -530,13 +460,15 @@ /** * Parses mmp file from the entered path - * @param fileLocation MMP file location with path. - * @param sbsBuild Is sbsv2 build system activated - * @return MMP file name without path. If SBSv2 is not activated the MMP - * file is returned without file extension. + * + * @param fileLocation + * MMP file location with path. + * @param sbsBuild + * Is sbsv2 build system activated + * @return MMP file name without path. If SBSv2 is not activated the MMP + * file is returned without file extension. */ - public String getMMPFileName(IPath fileLocation, boolean sbsBuild) - { + public String getMMPFileName(IPath fileLocation, boolean sbsBuild) { // because mmp file contains project related path // we need to parse mmp file name int index = Util.getLastSlashIndex(fileLocation.toString()); @@ -547,20 +479,20 @@ } // parse mmp file name - mmpFileName = fileLocation.toString().substring( - index + 1, fileLocation.toString().length()); + mmpFileName = fileLocation.toString().substring(index + 1, + fileLocation.toString().length()); - //if not using the SBS2 builds => needs to remove mmp file name extension - if( !sbsBuild && mmpFileName.endsWith(".mmp")) { - mmpFileName = mmpFileName.substring(0, mmpFileName.length()-4); + // if not using the SBS2 builds => needs to remove mmp file name + // extension + if (!sbsBuild && mmpFileName.endsWith(".mmp")) { + mmpFileName = mmpFileName.substring(0, mmpFileName.length() - 4); } return mmpFileName; } - /** * Runs AnalyzeTool build. - * + * * @param type * Type of execution. Possible types ATOOL_INST or ATOOL_UNINST * @param monitor @@ -575,20 +507,12 @@ final IProgressMonitor monitor, final ICarbideProjectInfo cpi, final List files) { - // check AnalyzeTool libraries if the AnalyzeTool libraries missing => - // creates error marker for the project and cancels build - if( !Util.checkAtoolLibs(cpi) ) - { - buildCancelled(monitor, false); - return false; - } - // get preference store IPreferenceStore store = Activator.getPreferences(); // get active logging mode String loggingMode = store.getString(Constants.LOGGING_MODE); - String s60FileNameMode = store.getString(Constants.S60_LOG_FILE_MODE); + verbose = store.getBoolean(Constants.ATOOL_VERBOSE); // possible error code from command line engine @@ -597,45 +521,51 @@ // if logging mode is set to "ask always" // ask for user used logging mode if (Constants.LOGGING_ASK_ALLWAYS.equals(loggingMode)) { - String modeSelection = askLoggingMode(); + + String[] outputMode = Util.openOutputModeDialog(); // user press "Cancel" - if (modeSelection == null || ("").equals(modeSelection)) { + if (outputMode == null) { buildCancelled(monitor, true); return false; } // if user selects S60 log file and mode // and data file must ask for user - else if (Constants.LOGGING_S60.equals(modeSelection) - && Constants.LOGGING_S60_USER_SPECIFIED - .equals(s60FileNameMode)) { - errorCode = askFileNameAndBuild(monitor, cpi, files); + else if (Constants.LOGGING_S60.equals(outputMode[0])) { + String logPath = outputMode[1]; + String logFileName = outputMode[2]; + + errorCode = executeAtool(logPath, logFileName, type, + outputMode[0], files, cpi, monitor); } else { // no need to ask data file for the user => just build - // with + // with // user selected logging mode - errorCode = executeAtool(null, type, modeSelection, files, cpi, monitor); + errorCode = executeAtool(null, null, type, outputMode[0], + files, cpi, monitor); } - } // if used logging mode is s60 // and data file name must ask for the user - else if (Constants.LOGGING_S60.equals(loggingMode) - && Constants.LOGGING_S60_USER_SPECIFIED.equals(s60FileNameMode)) { - errorCode = askFileNameAndBuild(monitor, cpi, files); + else if (Constants.LOGGING_S60.equals(loggingMode)) { + String path = store.getString(Constants.DEVICE_LOG_FILE_PATH); + String fileName = store.getString(Constants.DEVICE_LOG_FILE_NAME); + + errorCode = executeAtool(path, fileName, type, loggingMode, files, + cpi, monitor); } // build with selected mode else { - errorCode = executeAtool(null, type, loggingMode, files, cpi, monitor); + errorCode = executeAtool(null, null, type, loggingMode, files, cpi, + monitor); } - // no errors from command line engine - if( errorCode == Constants.COMMAND_LINE_ERROR_CODE.OK.getCode() ) { + if (errorCode == Constants.COMMAND_LINE_ERROR_CODE.OK.getCode()) { return true; } - // if some error code is returned from command line engine display it to user - // and cancel build + // if some error code is returned from command line engine display it to + // user and cancel build Constants.COMMAND_LINE_ERROR_CODE error = Util.getErrorCode(errorCode); Util.displayCommandLineError(error); buildCancelled(monitor, false); @@ -644,7 +574,9 @@ /** * After the built is finished set preferences back to normal. - * @param cpi ICarbideProjectInfo refernece + * + * @param cpi + * ICarbideProjectInfo refernece */ public final void runPostSteps(ICarbideProjectInfo cpi) { @@ -656,21 +588,21 @@ // try to load ProjectUIPlugin class try { - Class.forName("com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils"); + Class + .forName("com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils"); // no need to keep project files in sync // this should fix the mmp selection dialog prompt com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils .setKeepProjectsInSync(keepFilesSync); } catch (ClassNotFoundException cnte) { - //Do nothing by design + // Do nothing by design } // set builder preference to not prompt mmp file change dialog IPreferenceStore cStore = CarbideBuilderPlugin.getDefault() .getPreferenceStore(); - // add existing/default values of Carbide builder settings cStore .setValue( @@ -685,53 +617,55 @@ com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING, useConcBuild); - // try to remove -debug parameter from the build arguments list try { - //get build configuration + // get build configuration ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); - //get build arguments info + // get build arguments info BuildArgumentsInfo info = config.getBuildArgumentsInfoCopy(); - //get used platform + // get used platform String platform = config.getPlatformString(); String debug = "-debug"; String abldArgs = info.abldBuildArgs; - //if platform is set to ARMV5 or GCCE - if ( platform.contains(Constants.BUILD_TARGET_ARMV5) || platform.contains(Constants.BUILD_TARGET_GCEE)) { + // if platform is set to ARMV5 or GCCE + if (platform.contains(Constants.BUILD_TARGET_ARMV5) + || platform.contains(Constants.BUILD_TARGET_GCEE)) { - //get "-debug" string index + // get "-debug" string index int index = abldArgs.indexOf(debug); - //if abld build arguments contains only "-debug" parameter - if( abldArgs.equals(debug) ) { + // if abld build arguments contains only "-debug" parameter + if (abldArgs.equals(debug)) { info.abldBuildArgs = ""; config.setBuildArgumentsInfo(info); } - //remove just "-debug" word - else if( abldArgs.contains(debug) && index != -1 ) { - info.abldBuildArgs = abldArgs.substring(0,index) + abldArgs.substring(index+debug.length(), abldArgs.length()); + // remove just "-debug" word + else if (abldArgs.contains(debug) && index != -1) { + info.abldBuildArgs = abldArgs.substring(0, index) + + abldArgs.substring(index + debug.length(), + abldArgs.length()); config.setBuildArgumentsInfo(info); } } - }catch( java.lang.NoSuchMethodError nsme ) { - //Do nothing by design - //user might run AT with too old Carbide version - }catch( Exception e ) { + } catch (java.lang.NoSuchMethodError nsme) { + // Do nothing by design + // user might run AT with too old Carbide version + } catch (Exception e) { e.printStackTrace(); } - //after the build is finished => open the console view + // after the build is finished => open the console view Util.openConsoleView(); } /** * Checks is atool.exe available and modifies Carbide preferences. - * + * * @param launcher * Command launcher * @param monitor @@ -743,7 +677,6 @@ protected final boolean runPreSteps(final CarbideCommandLauncher launcher, final IProgressMonitor monitor, final ICarbideProjectInfo cpi) { - // set command launchers cmdLauncher = launcher; @@ -751,43 +684,48 @@ if (!Util.isAtoolAvailable()) { launcher.writeToConsole(Constants.INFO_ATOOL_NOT_AVAILABLE); buildCancelled(monitor, false); - Util.showErrorMessage(Constants.ERROR_ATOOL_NOT_AVAILABLE); + Util.showMessageDialog(Constants.CLE_VERSION_MISMATCH, + Constants.ERROR_ATOOL_NOT_AVAILABLE, SWT.ICON_ERROR); + return false; } - - // check AnalyzeTool version, 1.6.0 and forward versions is supported - String atoolVersion = Util.getAtoolVersionNumber(Util.getAtoolInstallFolder()); - int compared = Util.compareVersionNumber(atoolVersion, Constants.MIN_VERSION); - if( compared == Constants.VERSION_NUMBERS_SECOND || compared == Constants.VERSION_NUMBERS_INVALID ) { + + // check supported AnalyzeTool version + String atoolVersion = Util.getAtoolVersionNumber(Util + .getAtoolInstallFolder()); + int compared = Util.compareVersionNumber(atoolVersion, + Constants.MIN_CLE_SUPPORTED); + if (compared == Constants.VERSION_NUMBERS_SECOND + || compared == Constants.VERSION_NUMBERS_INVALID) { + launcher.writeToConsole(MessageFormat.format( + Constants.CLE_OLDER_THAN_MIN, Constants.MIN_CLE_SUPPORTED)); buildCancelled(monitor, false); - Util.showMessage(Constants.TOO_OLD_ENGINE); + Util.showMessageDialog(Constants.CLE_VERSION_MISMATCH, + MessageFormat.format(Constants.CLE_OLDER_THAN_MIN, + Constants.MIN_CLE_SUPPORTED), SWT.ICON_ERROR); return false; } /** - * - * Below is code a sample which are related to the AT-682, - * but it is decided to let out from current release. - String coreVersion = Util.getAtoolCoreVersion(cpi.getProject()); - compared = Util.compareVersionNumber(coreVersion, atoolVersion); - if( compared != Constants.VERSION_NUMBERS_EQUALS ) - { - boolean retValue = Util.openConfirmationDialog("AnalyzeTool command line engine and AnalyzeTool core version mismatch.\n" + - "This usually leads to problems.\n\nDo you want to continue?"); - if( !retValue ) { - buildCancelled(monitor, false); - return false; - } - } - */ + * + * Below is code a sample which are related to the AT-682, but it is + * decided to let out from current release. String coreVersion = + * Util.getAtoolCoreVersion(cpi.getProject()); compared = + * Util.compareVersionNumber(coreVersion, atoolVersion); if( compared != + * Constants.VERSION_NUMBERS_EQUALS ) { boolean retValue = + * Util.openConfirmationDialog( + * "AnalyzeTool command line engine and AnalyzeTool core version mismatch.\n" + * + "This usually leads to problems.\n\nDo you want to continue?"); if( + * !retValue ) { buildCancelled(monitor, false); return false; } } + */ // remove existing error markers try { CarbideCPPBuilder.removeAllMarkers(cpi.getProject()); - }catch (CoreException ce) { + } catch (CoreException ce) { ce.printStackTrace(); return false; } - + // check used platform if (!checkPlatform(cpi)) { buildCancelled(monitor, Util @@ -795,16 +733,11 @@ return false; } - // check AnalyzeTool libraries if the AnalyzeTool libraries missing => - // creates error marker for the project and cancels build - if( !Util.checkAtoolLibs(cpi) ) - { - PlatformUI.getWorkbench().getDisplay().syncExec( new Runnable() { - public void run() { - // show error message for the user - Util.showMessage(Constants.CAN_NOT_FIND_LIBRARIES); - } - }); + // check AnalyzeTool libraries + final String libsCheck = Util.checkAtoolLibs(cpi); + if (!libsCheck.equals(Constants.ATOOL_LIBS_OK)) { + Util.showMessageDialog(Constants.DIALOG_TITLE, libsCheck, + SWT.ICON_ERROR); buildCancelled(monitor, false); return false; } @@ -831,7 +764,7 @@ com.nokia.carbide.cpp.project.ui.utils.ProjectUIUtils .setKeepProjectsInSync(false); } catch (ClassNotFoundException cnfe) { - //Do nothing by design + // Do nothing by design } // set builder preference to not prompt mmp file change dialog @@ -846,7 +779,7 @@ boolean useConcBuild = cStore .getBoolean(com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING); - //store existing values + // store existing values store.setValue(Constants.PREFS_PROMPT_MMP, promptMPPChange); store.setValue(Constants.PREFS_MANAGE_DEPS, manageDeps); store.setValue(Constants.PREFS_CONC_BUILD, useConcBuild); @@ -863,57 +796,63 @@ .setValue( com.nokia.carbide.cdt.builder.BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING, false); - + // try to add -debug parameter to the build arguments list try { - //get selected build configuration + // get selected build configuration ICarbideBuildConfiguration config = cpi.getDefaultConfiguration(); - //get build arguments info + // get build arguments info BuildArgumentsInfo info = config.getBuildArgumentsInfoCopy(); - //get selected platform + // get selected platform String platform = cpi.getDefaultConfiguration().getPlatformString(); - //if platform is ARMV5 or GCCE and the "-debug" parameter is not set => we need set the parameter - if ( (platform.contains(Constants.BUILD_TARGET_ARMV5) || platform.contains(Constants.BUILD_TARGET_GCEE)) && !info.abldBuildArgs.contains("-debug") ) { - if( info.abldBuildArgs.length() > 0 && !info.abldBuildArgs.endsWith(" ") ) { + // if platform is ARMV5 or GCCE and the "-debug" parameter is not + // set => we need set the parameter + if ((platform.contains(Constants.BUILD_TARGET_ARMV5) || platform + .contains(Constants.BUILD_TARGET_GCEE)) + && !info.abldBuildArgs.contains("-debug")) { + if (info.abldBuildArgs.length() > 0 + && !info.abldBuildArgs.endsWith(" ")) { info.abldBuildArgs += " "; } info.abldBuildArgs += "-debug"; config.setBuildArgumentsInfo(info); } - } - //catch NoSuchMethodError because is it possible to use older versions where this method is not available - catch( java.lang.NoSuchMethodError nsme) - { - //Do nothing by design + // catch NoSuchMethodError because is it possible to use older versions + // where this method is not available + catch (java.lang.NoSuchMethodError nsme) { + // Do nothing by design } - return true; } /** * Executes uninstrument for the project. - * @param command Uninstrument command - * @param cpi ICarbideProjectInfo reference - * @param monitor IProgressMonitor reference + * + * @param command + * Uninstrument command + * @param cpi + * ICarbideProjectInfo reference + * @param monitor + * IProgressMonitor reference */ - public void runUninstrument(String command, ICarbideProjectInfo cpi, IProgressMonitor monitor) - { + public void runUninstrument(String command, ICarbideProjectInfo cpi, + IProgressMonitor monitor) { cmdLauncher.showCommand(true); String[] arguments = new String[1]; - arguments[0] = command; + arguments[0] = command; int error = cmdLauncher.executeCommand(new Path(Util - .getAtoolInstallFolder()),arguments, - CarbideCPPBuilder.getResolvedEnvVars(cpi - .getDefaultConfiguration()), cpi - .getINFWorkingDirectory()); - + .getAtoolInstallFolder()), arguments, CarbideCPPBuilder + .getResolvedEnvVars(cpi.getDefaultConfiguration()), cpi + .getINFWorkingDirectory()); + // if some occurs => display it to user - if( error != Constants.COMMAND_LINE_ERROR_CODE.OK.getCode() ) { - Constants.COMMAND_LINE_ERROR_CODE errorCode = Util.getErrorCode(error); + if (error != Constants.COMMAND_LINE_ERROR_CODE.OK.getCode()) { + Constants.COMMAND_LINE_ERROR_CODE errorCode = Util + .getErrorCode(error); Util.displayCommandLineError(errorCode); } }