core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java
author timkelly
Fri, 26 Mar 2010 11:40:51 -0500
changeset 1134 081b99cb271a
parent 693 2d475d296af4
child 1138 352c0236f181
permissions -rw-r--r--
bug 10674. Add support for long alias names from Carbide.xml (initial support)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     1
/*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     3
* All rights reserved.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     8
*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    11
*
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    12
*/
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    13
package com.nokia.carbide.cpp.internal.api.sdk;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    14
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    15
import java.io.File;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    16
import java.io.FileFilter;
693
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
    17
import java.text.MessageFormat;
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    18
import java.util.ArrayList;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    19
import java.util.Collections;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    20
import java.util.Comparator;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    21
import java.util.HashMap;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    22
import java.util.Iterator;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    23
import java.util.List;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    24
import java.util.Map;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    25
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    26
import javax.xml.parsers.DocumentBuilder;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    27
import javax.xml.parsers.DocumentBuilderFactory;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    28
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    29
import org.eclipse.cdt.utils.spawner.EnvironmentReader;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    30
import org.eclipse.core.filesystem.URIUtil;
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    31
import org.eclipse.core.runtime.IPath;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    32
import org.eclipse.core.runtime.Path;
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
    33
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
    34
import org.eclipse.core.runtime.preferences.InstanceScope;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    35
import org.osgi.framework.Version;
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
    36
import org.osgi.service.prefs.BackingStoreException;
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    37
import org.w3c.dom.Element;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    38
import org.w3c.dom.Node;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    39
import org.w3c.dom.NodeList;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    40
import org.xml.sax.InputSource;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    41
import org.xml.sax.helpers.DefaultHandler;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    42
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    43
import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    44
import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    45
import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
176
11eeeeeb1733 clean up imports
timkelly
parents: 0
diff changeset
    46
import com.nokia.cpp.internal.api.utils.core.FileUtils;
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    47
import com.nokia.cpp.internal.api.utils.core.HostOS;
176
11eeeeeb1733 clean up imports
timkelly
parents: 0
diff changeset
    48
import com.nokia.cpp.internal.api.utils.core.Logging;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    49
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    50
/**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    51
 * Utility class for SBSv2
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    52
 * @since 2.0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    53
 */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    54
public class SBSv2Utils {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    55
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    56
	private static final String SBSV2_FILTERED_CONFIGS_STORE = "sbsv2FilteredConfigs"; //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    57
	private static final String SBSV2_FILTERED_CONFIGS_DELIMETER = ";"; //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    58
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    59
	/**
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    60
	 * Map of usable Raptor alias for -c parameter and base platform: <alise, base plat>
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    61
	 */
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    62
	private static Map<String, String> unfilteredSBSv2ConfigNames;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    63
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    64
	protected static final String SBS_HOME = "SBS_HOME";
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    65
	protected static String sbsHome;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    66
	protected static IPath sbsPath;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    67
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    68
	private static boolean scannedSbsState = false;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
    69
	private static final String sbsScriptName = HostOS.IS_WIN32 ? "sbs.bat" : "sbs"; 
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    70
	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    71
	/**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    72
     * Get the path to the SBSv2 bin directory.  This is based on the SBS_HOME environment variable
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    73
     * and may or may not actually exist.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    74
     * @return absolute path to the bin directory, or null if SBS_HOME is not set
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    75
     */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    76
    public static IPath getSBSBinDirectory() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    77
    	String sbsHome = EnvironmentReader.getEnvVar("SBS_HOME"); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    78
    	if (sbsHome != null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    79
    		return new Path(sbsHome).append("bin"); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    80
    	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    81
    	return null;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    82
    }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    83
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    84
    /**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    85
     * Get the build configurations supported by SBSv2
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    86
     * @param refreshList whether or not to parse the configuration xml files again
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    87
     * @return A map of raptor aliases (key) to base build platform. Never null;
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    88
     */
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    89
    public static Map<String, String> getUnfilteredSBSv2BuildConfigurations(boolean refreshList) {
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    90
    	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    91
    	if (unfilteredSBSv2ConfigNames == null || refreshList) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
    92
    		unfilteredSBSv2ConfigNames = new HashMap<String, String>();
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    93
    		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    94
        	// parse the xml files in SBS_HOME/lib/config/ to get SBSv2 configs
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    95
    		try {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    96
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    97
    			IPath configPath = getSBSBinDirectory();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    98
    			if (configPath != null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
    99
    				configPath = configPath.removeLastSegments(1).append("lib/config"); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   100
    				File configDir = configPath.toFile();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   101
    				if (configDir.exists() && configDir.isDirectory()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   102
    					File[] configFiles = FileUtils.listFilesInTree(configDir, new FileFilter() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   103
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   104
    						public boolean accept(File arg0) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   105
    							if (arg0.isDirectory()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   106
    								return true;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   107
    							}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   108
    							return arg0.getName().toLowerCase().endsWith("xml"); //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   109
    						}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   110
    						
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   111
    					}, false);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   112
    					
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   113
    					for (File file : configFiles) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   114
    						getConfigsForFile(file);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   115
    					}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   116
    				}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   117
    			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   118
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   119
    		} catch (Exception e) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   120
        		e.printStackTrace();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   121
        		Logging.log(SDKCorePlugin.getDefault(), Logging.newStatus(SDKCorePlugin.getDefault(), e));
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   122
    		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   123
    	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   124
    	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   125
    	return unfilteredSBSv2ConfigNames;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   126
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   127
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   128
    /**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   129
     * Given a list of SDKs, returns the list of the SDK's supported by SBSv2
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   130
     * @param sdks list of SDK's to check
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   131
     * @return list of SBSv2 supported SDK's, may be empty
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   132
     */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   133
    public static List<ISymbianSDK> getSupportedSDKs(List<ISymbianSDK> sdks) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   134
    	List<ISymbianSDK> supportedSDKs = new ArrayList<ISymbianSDK>();
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   135
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   136
    	// If there is no SBSv1 builder, then assume all SDKs are SBSv2 capable
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   137
    	if (!enableSBSv1Support()) {
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   138
    		supportedSDKs.addAll(sdks);
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   139
    	} else {
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   140
	    	//TODO need a better way to do this from Symbian.
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   141
	    	// For now, just filter out anything older than 9.4
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   142
	    	for (ISymbianSDK sdk : sdks) {
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   143
	    		Version osVersion = sdk.getOSVersion();
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   144
	    		if (osVersion.getMajor() > 8 ||
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   145
	    				(osVersion.getMajor() == 8 && osVersion.getMinor() > 3)) {
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   146
	    			supportedSDKs.add(sdk);
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   147
	    		}
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   148
	    	}
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   149
    	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   150
    	return supportedSDKs;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   151
    }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   152
    
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   153
	/**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   154
	 * Returns the list of SBSv2 build configuration names that should
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   155
	 * be filtered out of any UI
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   156
	 */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   157
	public static String[] getSBSv2ConfigurationsToFilter() {
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   158
		IEclipsePreferences prefs = new InstanceScope().getNode(SDKCorePlugin.PLUGIN_ID);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   159
		if (prefs != null) {
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   160
			String configs = prefs.get(SBSV2_FILTERED_CONFIGS_STORE, "");
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   161
			return configs.split(SBSV2_FILTERED_CONFIGS_DELIMETER);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   162
		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   163
		return new String[0];
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   164
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   165
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   166
	/**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   167
	 * Set the list of SBSv2 build configurations that should be filtered
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   168
	 * out of any UI
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   169
	 * @param configs configs to be filtered
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   170
	 */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   171
	public static void setSBSv2ConfigurationsToFilter(String[] configs) {
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   172
		IEclipsePreferences prefs = new InstanceScope().getNode(SDKCorePlugin.PLUGIN_ID);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   173
		if (prefs != null) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   174
			String store = ""; //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   175
			for (String config : configs) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   176
				store = store + SBSV2_FILTERED_CONFIGS_DELIMETER + config;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   177
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   178
			
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   179
			// remove the leading delimeter
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   180
			if (store.length() > 0) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   181
				store = store.substring(1);
266
c7ecdd0b9f52 Fix bug 9310. Fix save problem with Platform Filter Prefs (sbsv2) and add Restore / Apply buttons.
timkelly
parents: 176
diff changeset
   182
			}
c7ecdd0b9f52 Fix bug 9310. Fix save problem with Platform Filter Prefs (sbsv2) and add Restore / Apply buttons.
timkelly
parents: 176
diff changeset
   183
			if (store.length() >= 0){
c7ecdd0b9f52 Fix bug 9310. Fix save problem with Platform Filter Prefs (sbsv2) and add Restore / Apply buttons.
timkelly
parents: 176
diff changeset
   184
				// lenght of zero means there are not configs to filter (or show them all)
629
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   185
				prefs.put(SBSV2_FILTERED_CONFIGS_STORE, store);
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   186
				try {
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   187
					prefs.flush();
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   188
				} catch (BackingStoreException e) {
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   189
					Logging.log(SDKCorePlugin.getDefault(),
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   190
							Logging.newStatus(SDKCorePlugin.getDefault(), e));
c24c517fe8c2 Fix SBSv2 SDK filtering.
Ed Swartz <ed.swartz@nokia.com>
parents: 608
diff changeset
   191
				}
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   192
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   193
		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   194
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   195
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   196
	/**
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   197
	 * Gets the list of SBSv2 build contexts for the given SDK
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   198
	 * @param sdk the SDK to get the build contexts for
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   199
	 * @return the list of SBSv2 build contexts.  the list may be empty
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   200
	 */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   201
	public static List<ISymbianBuildContext> getFilteredSBSv2BuildContexts(ISymbianSDK sdk) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   202
		List<ISymbianBuildContext> contexts = new ArrayList<ISymbianBuildContext>();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   203
		
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   204
		Iterator it = getUnfilteredSBSv2BuildConfigurations(false).entrySet().iterator();
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   205
		
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   206
		while (it.hasNext()){
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   207
			
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   208
			Map.Entry buildConfigPair = (Map.Entry)it.next();
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   209
			String alias = (String)buildConfigPair.getKey(); // The sbsv2 alias 
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   210
			String basePlat = (String)buildConfigPair.getValue();
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   211
			boolean addConfig = true;
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   212
			
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   213
			for (String filteredConfig : getSBSv2ConfigurationsToFilter()) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   214
				if (filteredConfig.compareTo(alias) == 0) {
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   215
					addConfig = false;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   216
					break;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   217
				}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   218
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   219
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   220
			if (addConfig) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   221
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   222
				// only support configs that fall into something we can make a build context
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   223
				// out of.  They must have a platform and a target.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   224
				String targetString = null;
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   225
				String[] configTokens = alias.split("_"); // $//$NON-NLS-N$
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   226
				// We presume that aliases have the second token as the "target". 
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   227
		    	if (configTokens[1].toLowerCase().endsWith("deb")) { //$NON-NLS-1$ //$NON-NLS-2$
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   228
		    		targetString = ISymbianBuildContext.DEBUG_TARGET;
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   229
		    	} else if (configTokens[1].toLowerCase().endsWith("rel")) { //$NON-NLS-1$ //$NON-NLS-2$
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   230
		    		targetString = ISymbianBuildContext.RELEASE_TARGET;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   231
		    	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   232
		    	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   233
		    	if (targetString != null) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   234
		    		SymbianBuildContext context = null;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   235
		    		context = new SymbianBuildContext(sdk, basePlat, targetString, alias);
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   236
		    		if (context != null) 
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   237
		    			contexts.add(context);
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   238
		    	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   239
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   240
		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   241
		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   242
		Collections.sort(contexts, new Comparator<ISymbianBuildContext>() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   243
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   244
			public int compare(ISymbianBuildContext o1, ISymbianBuildContext o2) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   245
				String platform1 = o1.getPlatformString();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   246
				String platform2 = o2.getPlatformString();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   247
				if (platform1.equals(platform2)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   248
					return o1.getTargetString().compareTo(o2.getTargetString());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   249
				} else {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   250
					if (platform1.equals(ISymbianBuildContext.EMULATOR_PLATFORM)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   251
						return -1;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   252
					}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   253
					else if (platform2.equals(ISymbianBuildContext.EMULATOR_PLATFORM)) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   254
						return 1;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   255
					}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   256
				}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   257
				return 0;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   258
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   259
			
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   260
		});
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   261
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   262
		return contexts;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   263
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   264
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   265
	/**
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   266
	 * Whether or not to display SBSv1 builder UI
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   267
	 * @return true if SBSv1 is available, false otherwise
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   268
	 */
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   269
	public static boolean enableSBSv1Support() {
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   270
		if (!enableSBSv2Support())
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   271
			return true;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   272
		
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   273
		// TODO LINUX: more accurate check
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   274
		if (HostOS.IS_WIN32)
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   275
			return true;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   276
		return false;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   277
	}
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   278
	
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   279
	/**
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   280
	 * Whether or not to display SBSv2 builder UI
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   281
	 * @return true if SBSv2 is installed, false otherwise
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   282
	 */
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   283
	public static boolean enableSBSv2Support() {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   284
		IPath sbsBinPath = getSBSBinDirectory();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   285
		if (sbsBinPath != null && sbsBinPath.toFile().exists()) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   286
			return true;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   287
		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   288
		return false;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   289
	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   290
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   291
	private static void getConfigsForFile(File file) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   292
    	
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   293
    	try {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   294
    		Element root = null;
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   295
    		DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   296
    		parser.setErrorHandler(new DefaultHandler());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   297
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   298
    		InputSource source = new InputSource(URIUtil.toURI(file.getAbsolutePath()).getPath());
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   299
    		root = parser.parse(source).getDocumentElement();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   300
    		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   301
    		NodeList children = root.getChildNodes();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   302
    		for (int i=0; i< children.getLength(); i++) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   303
    			getConfigsForNode(children.item(i), root);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   304
    		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   305
    		
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   306
    	} catch (Exception e) {
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   307
    		e.printStackTrace();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   308
    		Logging.log(SDKCorePlugin.getDefault(), Logging.newStatus(SDKCorePlugin.getDefault(), e));
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   309
    	}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   310
    }
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   311
    
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   312
    private static void getConfigsForNode(Node node, Node parentNode) {
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   313
		if (node.getNodeName().equals("config")) { //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   314
			Node abstractNode = node.getAttributes().getNamedItem("abstract");  //$NON-NLS-1$
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   315
			Node namedNode = node.getAttributes().getNamedItem("name"); //$NON-NLS-1$
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   316
			if (abstractNode == null || abstractNode.getNodeValue().equals("false")) { //$NON-NLS-1$
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   317
				if (namedNode != null) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   318
					
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   319
					// Get the parent base build platform
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   320
					String baseBuildPlatform = null;
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   321
					if (parentNode != null){
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   322
						baseBuildPlatform = parentNode.getAttributes().getNamedItem("name").getNodeValue();
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   323
					}
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   324
					
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   325
					// only support configs that fall into something we can make a build context
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   326
					// out of.  They must have a platform and a target.
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   327
					String configName = namedNode.getNodeValue();
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   328
					String[] configTokens = configName.split("_");
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   329
			    	if (configTokens.length >= 2) { //$NON-NLS-1$
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   330
			    		String target = configTokens[1];
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   331
			    		if (target.endsWith("deb") || target.endsWith("rel")){ //$NON-NLS-1$
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   332
			    			if (baseBuildPlatform == null){
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   333
			    				baseBuildPlatform = "unknown";
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   334
			    			}
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   335
			    			unfilteredSBSv2ConfigNames.put(configName, baseBuildPlatform);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   336
			    		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   337
			    	}
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   338
			    }
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   339
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   340
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   341
			NodeList children = node.getChildNodes();
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   342
			for (int i=0; i< children.getLength(); i++) {
1134
081b99cb271a bug 10674. Add support for long alias names from Carbide.xml (initial support)
timkelly
parents: 693
diff changeset
   343
				getConfigsForNode(children.item(i), node);
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   344
			}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   345
		}
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   346
    }
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   347
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   348
	/**
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   349
	 * (Re-)scan the SBSv2 / Raptor configuration
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   350
	 * @return message if error, else null
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   351
	 */
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   352
	public static String scanSBSv2() {
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   353
		// do some basic checks
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   354
		sbsHome = System.getenv(SBS_HOME);
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   355
		if (sbsHome == null) {
693
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   356
			return Messages.getString("SBSv2Utils.DefineSBS_HOMEMessage"); //$NON-NLS-1$
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   357
		}
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   358
		
693
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   359
		IPath expectedPath = new Path(sbsHome).append("bin").append(sbsScriptName);
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   360
		if (expectedPath.toFile().exists()) {
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   361
			sbsPath = expectedPath;
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   362
		} else {
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   363
			sbsPath = HostOS.findProgramOnPath(sbsScriptName, null);
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   364
			if (sbsPath == null) {
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   365
				return MessageFormat.format(
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   366
								Messages.getString("SBSv2Utils.CannotFindSBSScriptError"), //$NON-NLS-1$
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   367
								sbsScriptName);
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   368
			}
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   369
		}
693
2d475d296af4 Look for sbs or sbs.bat under SBS_HOME/bin first, instead of only looking at the PATH.
Ed Swartz <ed.swartz@nokia.com>
parents: 629
diff changeset
   370
		
608
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   371
		return null;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   372
	}
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   373
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   374
    /**
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   375
     * Get the path to SBSv2 (sbs.bat or sbs)
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   376
     */
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   377
	public static IPath getSBSPath() {
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   378
		if (!scannedSbsState) {
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   379
			scanSBSv2();
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   380
			scannedSbsState = true;
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   381
		}
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   382
		return sbsPath != null ? sbsPath : new Path(sbsScriptName);  // dummy
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   383
	}
d2a651a847a5 Initial work to support an ISDKManager implementation that only understands SBSv2 (meaning, no devices.xml support).
Ed Swartz <ed.swartz@nokia.com>
parents: 266
diff changeset
   384
0
fb279309251b DP tools release version Revision: 200912
Deepak Modgil <Deepak.Modgil@Nokia.com>
parents:
diff changeset
   385
}