sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/builder/CustomPostBuilder.java
author Matti Laitinen <matti.t.laitinen@nokia.com>
Tue, 24 Aug 2010 12:16:27 +0300
changeset 15 0367d2db2c06
parent 6 f65f740e69f9
permissions -rw-r--r--
AnalyzeTool Carbide extension 1.10.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     1
/*
6
f65f740e69f9 AnalyzeTool Carbide Extension v1.9.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 1
diff changeset
     2
 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     3
 * All rights reserved.
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     8
 *
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     9
 * Initial Contributors:
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    11
 *
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    12
 * Contributors:
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    13
 *
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    14
 * Description:  Definitions for the class CustomPostBuilder
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    15
 *
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    16
 */
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    17
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    18
package com.nokia.s60tools.analyzetool.builder;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    19
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    20
import org.eclipse.core.resources.IProject;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    21
import org.eclipse.core.runtime.IProgressMonitor;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    22
import org.eclipse.jface.preference.IPreferenceStore;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    23
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    24
//import com.nokia.carbide.cdt.builder.BuildArgumentsInfo;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    25
import com.nokia.carbide.cdt.builder.CarbideBuilderPlugin;
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    26
import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder; //import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration;
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    27
import com.nokia.carbide.cdt.builder.project.ICarbideProjectInfo;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    28
import com.nokia.s60tools.analyzetool.Activator;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    29
import com.nokia.s60tools.analyzetool.global.Constants;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    30
import com.nokia.s60tools.analyzetool.global.Util;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    31
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    32
/**
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    33
 * Class to execute custom post-build actions.
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    34
 * 
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    35
 * @author kihe
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    36
 * 
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    37
 */
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    38
public class CustomPostBuilder extends AnalyzeToolBuilder {
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    39
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    40
	/** Post-builder id. */
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    41
	public static final String POST_BUILDER_ID = "com.nokia.s60tools.analyzetool.analyzeToolPostBuilder";
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    42
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    43
	/**
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    44
	 * Executes AnalyzeTool post actions when user builds projects.
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    45
	 * 
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    46
	 * 
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    47
	 * @see com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder#build(int,
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    48
	 *      java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    49
	 */
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    50
	@Override
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    51
	@SuppressWarnings("unchecked")
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    52
	protected IProject[] build(int kind, java.util.Map args,
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    53
			IProgressMonitor monitor) {
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    54
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    55
		// get project reference
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    56
		IProject project = super.getProject();
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    57
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    58
		// get project info
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    59
		ICarbideProjectInfo cpi = CarbideBuilderPlugin.getBuildManager()
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    60
				.getProjectInfo(project);
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    61
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    62
		IPreferenceStore store = Activator.getPreferences();
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    63
		boolean buildCanceled = store
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    64
				.getBoolean(Constants.PREFS_BUILD_CANCELLED);
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    65
		// if the AnalyzeTool is canceled
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    66
		if (buildCanceled) {
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    67
			getCarbideCommandLauncher().writeToConsole(
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    68
					Constants.BUILD_CANCELLED);
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    69
			buildCanceled = false;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    70
			// if atool.exe is not available write info to console view
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    71
			if (!Util.isAtoolAvailable()) {
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    72
				getCarbideCommandLauncher().writeToConsole(
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    73
						Constants.INFO_ATOOL_NOT_AVAILABLE);
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    74
			}
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    75
			super.forgetLastBuiltState();
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    76
			runPostSteps(cpi);
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    77
			return null;
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    78
		}
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    79
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    80
		// execute atool.exe
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    81
		if (CarbideCPPBuilder.projectHasBuildErrors(cpi.getProject())) {
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    82
			runUninstrument(Constants.ATOOL_UNINST_FAILED, cpi, monitor);
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    83
		} else {
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    84
			runUninstrument(Constants.ATOOL_UNINST, cpi, monitor);
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    85
		}
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    86
		monitor.worked(1);
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    87
		runPostSteps(cpi);
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    88
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    89
		return new IProject[0];
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    90
	}
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    91
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    92
	@Override
15
0367d2db2c06 AnalyzeTool Carbide extension 1.10.0
Matti Laitinen <matti.t.laitinen@nokia.com>
parents: 6
diff changeset
    93
	protected void clean(final IProgressMonitor arg0) {
1
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    94
		// DO nothing by design
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    95
	}
1050670c6980 Initial version of AnalyzeTool under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    96
}