core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java Fri Apr 16 15:31:49 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java Mon Apr 19 11:38:03 2010 -0500
@@ -14,6 +14,7 @@
import java.io.File;
import java.io.FileFilter;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -52,27 +53,27 @@
private static final String SBSV2_FILTERED_CONFIGS_STORE = "sbsv2FilteredConfigs"; //$NON-NLS-1$
private static final String SBSV2_FILTERED_CONFIGS_DELIMETER = ";"; //$NON-NLS-1$
- protected static String sbsHome;
+ /** Path, to and including the SBS script */
protected static IPath sbsPath;
private static boolean scannedSbsState = false;
private static final String sbsScriptName = "sbs.bat";
- protected static final String SBS_HOME = "SBS_HOME";
/** Map of usable Raptor alias for -c parameter and base platform: <alias, base plat> */
private static Map<String, String> unfilteredSBSv2ConfigNames;
/**
- * Get the path to the SBSv2 bin directory. This is based on the SBS_HOME environment variable
- * and may or may not actually exist.
- * @return absolute path to the bin directory, or null if SBS_HOME is not set
+ * Get the path to the SBSv2 bin directory. not including the sbs executable.
+ * May or may not actually exist.
+ * @return absolute path to the bin directory, or null if sbs is not set
*/
public static IPath getSBSBinDirectory() {
- String sbsHome = EnvironmentReader.getEnvVar("SBS_HOME"); //$NON-NLS-1$
- if (sbsHome != null) {
- return new Path(sbsHome).append("bin"); //$NON-NLS-1$
+ String pathValue = EnvironmentReader.getEnvVar("PATH"); //$NON-NLS-1$
+ IPath sbs = HostOS.findProgramOnPath(sbsScriptName, pathValue);
+ if (sbs != null){
+ sbs = sbs.removeLastSegments(1);
}
- return null;
+ return sbs;
}
/**
@@ -82,10 +83,10 @@
*/
public static Map<String, String> getUnfilteredSBSv2BuildConfigurations(boolean refreshList) {
- if (unfilteredSBSv2ConfigNames == null || refreshList) {
+ if (unfilteredSBSv2ConfigNames == null || refreshList || unfilteredSBSv2ConfigNames.size() == 0) {
unfilteredSBSv2ConfigNames = new HashMap<String, String>();
- // parse the xml files in SBS_HOME/lib/config/ to get SBSv2 configs
+ // parse the xml files in <sbs-install>/lib/config/ to get SBSv2 configs
try {
IPath configPath = getSBSBinDirectory();
@@ -301,18 +302,24 @@
**/
public static String scanSBSv2() {
// do some basic checks
- sbsHome = System.getenv(SBS_HOME);
- if (sbsHome == null) {
- return "Please define the SBS_HOME environment (e.g. /path/to/raptor) and add $SBS_HOME/bin to your PATH before running Carbide.";
- }
-
- sbsPath = HostOS.findProgramOnPath(sbsScriptName, null);
- if (sbsPath == null) {
- return "Please add $SBS_HOME/bin to your PATH before running Carbide.";
- }
-
+ if (sbsPath != null){
+ return null;
+ }
+ IPath expectedPath = getSBSBinDirectory();
+ if (expectedPath != null) {
+ expectedPath = expectedPath.append(sbsScriptName);
+ if (expectedPath.toFile().exists()) {
+ sbsPath = expectedPath;
+ }
+ }
+ if (sbsPath == null) {
+ return MessageFormat.format(Messages
+ .getString("SBSv2Utils.CannotFindSBSScriptError"), //$NON-NLS-1$
+ sbsScriptName);
+ }
+
return null;
- }
+ }
/**
* Get the path to SBSv2 (sbs.bat or sbs)