Fix for Bug 11073 (Remove SBSv1 as a builder option). RCL_2_4
authorstechong
Mon, 26 Apr 2010 20:32:24 -0500
branchRCL_2_4
changeset 1287 971e41db5d47
parent 1286 fabd5f1bbac9
child 1289 7c4a4568b9c5
Fix for Bug 11073 (Remove SBSv1 as a builder option).
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuildSettingsUI.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuilderPreferencePage.java
builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java
core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java
core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/api/sdk/ui/BuildPlatformFilterPage.java
project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/sharedui/BuilderSelectionComposite.java
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuildSettingsUI.java	Mon Apr 26 15:48:38 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuildSettingsUI.java	Mon Apr 26 20:32:24 2010 -0500
@@ -33,6 +33,7 @@
 
 	private Shell shell;
 	private TabFolder tabFolder;
+	private boolean wantsSBSv1;
 	private boolean wantsSBSv2;
 	private boolean projectSetting;
 	
@@ -66,8 +67,9 @@
 	private Label extraArgsLabel;
 	private Text  extraArgsText;
 
-	public BuildSettingsUI(Shell shell, boolean wantsSBSv2, boolean projectSetting) {
+	public BuildSettingsUI(Shell shell, boolean wantsSBSv1, boolean wantsSBSv2, boolean projectSetting) {
 		this.shell = shell;
+		this.wantsSBSv1 = wantsSBSv1;
 		this.wantsSBSv2 = wantsSBSv2;
 		this.projectSetting = projectSetting;
 	}
@@ -81,7 +83,7 @@
 		
 		// for project settings we show either sbsv1 or sbsv2.  for workspace prefs
 		// we potentially show both
-		if ((projectSetting && !wantsSBSv2) || !projectSetting) {
+		if (wantsSBSv1) {
 			createSBSv1TabComposite();
 		}
 		
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuilderPreferencePage.java	Mon Apr 26 15:48:38 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuilderPreferencePage.java	Mon Apr 26 20:32:24 2010 -0500
@@ -36,19 +36,22 @@
 	}
 	
 	protected Control createContents(Composite parent) {
-		buildSettingsUI = new BuildSettingsUI(parent.getShell(), SBSv2Utils.enableSBSv2Support(), false);
+		buildSettingsUI = new BuildSettingsUI(parent.getShell(), SBSv2Utils.enableSBSv1Support(), SBSv2Utils.enableSBSv2Support(), false);
 		Control control = buildSettingsUI.createControl(parent);
 		
-		buildSettingsUI.setDefaultCleanLevelv1(getCleanLevel());
 		buildSettingsUI.setBuildTestComponents(isBuildingTestComps());
-		buildSettingsUI.setManageDependencies(manageDependencies());
 		buildSettingsUI.setUseIncrementalBuilder(useIncrementalBuilder());
 		buildSettingsUI.setUseConcurrentBuilding(useConcurrentBuilding());
 		buildSettingsUI.setNumConcurrentBuildJobs(concurrentBuildJobs());
-		buildSettingsUI.setPromptForMMPChangedAction(promptForMMPChangedAction());
-		buildSettingsUI.setDefaultMMPChangedAction(defaultMMPChangedAction());
 		buildSettingsUI.setUseBuiltInEnvVars(useBuiltInX86Vars());
-		buildSettingsUI.setDontPromtTrackDeps(promtDontTrackDependencies());
+		
+		if (SBSv2Utils.enableSBSv1Support()) {
+			buildSettingsUI.setDefaultCleanLevelv1(getCleanLevel());
+			buildSettingsUI.setManageDependencies(manageDependencies());
+			buildSettingsUI.setPromptForMMPChangedAction(promptForMMPChangedAction());
+			buildSettingsUI.setDefaultMMPChangedAction(defaultMMPChangedAction());
+			buildSettingsUI.setDontPromtTrackDeps(promtDontTrackDependencies());
+		}
 		
 		if (SBSv2Utils.enableSBSv2Support()) {
 			buildSettingsUI.setDefaultCleanLevelv2(getCleanLevelv2());
@@ -76,16 +79,19 @@
 	@Override
 	protected void performApply() {
 		IPreferenceStore store = CarbideBuilderPlugin.getDefault().getPreferenceStore();
-		store.setValue(BuilderPreferenceConstants.PREF_CLEAN_LEVEL, buildSettingsUI.getDefaultCleanLevelv1());
 		store.setValue(BuilderPreferenceConstants.PREF_BUILD_TEST_COMPS, buildSettingsUI.getBuildTestComponents());
-		store.setValue(BuilderPreferenceConstants.PREF_MANAGE_DEPENDENCIES, buildSettingsUI.getManageDependencies());
 		store.setValue(BuilderPreferenceConstants.PREF_USE_INCREMENTAL_BUILDER, buildSettingsUI.getUseIncrementalBuilder());
 		store.setValue(BuilderPreferenceConstants.PREF_USE_CONCURRENT_BUILDING, buildSettingsUI.getUseConcurrentBuilding());
 		store.setValue(BuilderPreferenceConstants.PREF_CONCURRENT_BUILD_JOBS, buildSettingsUI.getNumConcurrentBuildJobs());
-		store.setValue(BuilderPreferenceConstants.PREF_MMP_CHANGED_ACTION_PROMPT, buildSettingsUI.getPromptForMMPChangedAction());
-		store.setValue(BuilderPreferenceConstants.PREF_DEFAULT_MMP_CHANGED_ACTION, buildSettingsUI.getDefaultMMPChangedAction());
 		store.setValue(BuilderPreferenceConstants.PREF_USE_BUILIN_X86_VARS, buildSettingsUI.getUseBuiltInEnvVars());
-		store.setValue(BuilderPreferenceConstants.PREF_DONT_PROMPT_FOR_DEPENDENCY_MISMATCH, buildSettingsUI.getDontPromtTrackDeps()); // global setting only
+		
+		if (SBSv2Utils.enableSBSv1Support()) {
+			store.setValue(BuilderPreferenceConstants.PREF_CLEAN_LEVEL, buildSettingsUI.getDefaultCleanLevelv1());
+			store.setValue(BuilderPreferenceConstants.PREF_MANAGE_DEPENDENCIES, buildSettingsUI.getManageDependencies());
+			store.setValue(BuilderPreferenceConstants.PREF_MMP_CHANGED_ACTION_PROMPT, buildSettingsUI.getPromptForMMPChangedAction());
+			store.setValue(BuilderPreferenceConstants.PREF_DEFAULT_MMP_CHANGED_ACTION, buildSettingsUI.getDefaultMMPChangedAction());
+			store.setValue(BuilderPreferenceConstants.PREF_DONT_PROMPT_FOR_DEPENDENCY_MISMATCH, buildSettingsUI.getDontPromtTrackDeps()); // global setting only
+		}
 		
 		if (SBSv2Utils.enableSBSv2Support()) {
 			store.setValue(BuilderPreferenceConstants.PREF_CLEAN_LEVEL_V2, buildSettingsUI.getDefaultCleanLevelv2());
@@ -98,16 +104,19 @@
 	}
 	
 	protected void performDefaults() {
-		buildSettingsUI.setDefaultCleanLevelv1(0);
 		buildSettingsUI.setBuildTestComponents(true);
-		buildSettingsUI.setManageDependencies(true);
 		buildSettingsUI.setUseIncrementalBuilder(false);
 		buildSettingsUI.setUseConcurrentBuilding(true);
 		buildSettingsUI.setNumConcurrentBuildJobs(4);
-		buildSettingsUI.setPromptForMMPChangedAction(true);
-		buildSettingsUI.setDefaultMMPChangedAction(0);
 		buildSettingsUI.setUseBuiltInEnvVars(true);
-		buildSettingsUI.setDontPromtTrackDeps(false);
+
+		if (SBSv2Utils.enableSBSv1Support()) {
+			buildSettingsUI.setDefaultCleanLevelv1(0);
+			buildSettingsUI.setManageDependencies(true);
+			buildSettingsUI.setPromptForMMPChangedAction(true);
+			buildSettingsUI.setDefaultMMPChangedAction(0);
+			buildSettingsUI.setDontPromtTrackDeps(false);
+		}
 
 		if (SBSv2Utils.enableSBSv2Support()) {
 			buildSettingsUI.setDefaultCleanLevelv2(0);
--- a/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java	Mon Apr 26 15:48:38 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java	Mon Apr 26 20:32:24 2010 -0500
@@ -154,7 +154,7 @@
 			sbsv2Project = CarbideBuilderPlugin.getBuildManager().isCarbideSBSv2Project(project);
 		}
 
-		buildSettingsUI = new BuildSettingsUI(parent.getShell(), sbsv2Project, true);
+		buildSettingsUI = new BuildSettingsUI(parent.getShell(), !sbsv2Project, sbsv2Project, true);
 		buildSettingsUI.createControl(optionsGroup);
 
 		noDefaultAndApplyButton();
--- a/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java	Mon Apr 26 15:48:38 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java	Mon Apr 26 20:32:24 2010 -0500
@@ -40,6 +40,7 @@
 import org.xml.sax.InputSource;
 import org.xml.sax.helpers.DefaultHandler;
 
+import com.nokia.carbide.cpp.sdk.core.ISDKManager;
 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
@@ -55,6 +56,7 @@
 	private static final String SBSV2_FILTERED_CONFIGS_STORE = "sbsv2FilteredConfigs"; //$NON-NLS-1$
 	private static final String SBSV2_FILTERED_CONFIGS_STORE_INITED = "sbsv2FilteredConfigsInited"; //$NON-NLS-1$
 	private static final String SBSV2_FILTERED_CONFIGS_DELIMETER = ";"; //$NON-NLS-1$
+	private static final long VALID_ABLD_SIZE = 1024;
 
 	/** Path, to and including the SBS script */ 
 	protected static IPath sbsPath; 
@@ -257,6 +259,20 @@
 	}
 
 	/**
+	 * Whether or not to display SBSv1 builder UI
+	 * @return true if SBSv1 is available, false otherwise
+	 */
+	public static boolean enableSBSv1Support() {
+//		if (!enableSBSv2Support())
+//			return true;
+//		
+//		if (isSBSv1Supported())
+//			return true;
+		
+		return false;
+	}
+	
+	/**
 	 * Whether or not to display SBSv2 builder UI
 	 * @return true if SBSv2 is installed, false otherwise
 	 */
@@ -463,4 +479,17 @@
 		}
 		return newOutputDir;
 	}
+
+	private static boolean isSBSv1Supported() {
+		ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
+		for (ISymbianSDK sdk : sdkMgr.getSDKList()) {
+			File abld = new File(sdk.getEPOCROOT(), "epoc32/tools/abld.pl"); //$NON-NLS-1$
+			if (abld.exists()) {
+				long size = abld.length();
+				if (size >= VALID_ABLD_SIZE)
+					return true;
+			}
+		}
+		return false;
+	}
 }
--- a/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/api/sdk/ui/BuildPlatformFilterPage.java	Mon Apr 26 15:48:38 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.ui/src/com/nokia/carbide/cpp/internal/api/sdk/ui/BuildPlatformFilterPage.java	Mon Apr 26 20:32:24 2010 -0500
@@ -63,13 +63,15 @@
 			sbsv2TabItem.setControl(sbsv2Tab);
 		}
 		
-		TabItem sbsv1TabItem = new TabItem(tabFolder, SWT.NONE);
-		sbsv1TabItem.setText(Messages.getString("BuildPlatformFilterPage.SBSv1TabText")); //$NON-NLS-1$
-		sbsv1TabItem.setToolTipText(Messages.getString("BuildPlatformFilterPage.SBSv1TabToolTip")); //$NON-NLS-1$
-
-		sbsv1Tab = new SBSv1PlatformFilterComposite(tabFolder);
-		sbsv1Tab.createControls();
-		sbsv1TabItem.setControl(sbsv1Tab);
+		if (SBSv2Utils.enableSBSv1Support()) {
+			TabItem sbsv1TabItem = new TabItem(tabFolder, SWT.NONE);
+			sbsv1TabItem.setText(Messages.getString("BuildPlatformFilterPage.SBSv1TabText")); //$NON-NLS-1$
+			sbsv1TabItem.setToolTipText(Messages.getString("BuildPlatformFilterPage.SBSv1TabToolTip")); //$NON-NLS-1$
+	
+			sbsv1Tab = new SBSv1PlatformFilterComposite(tabFolder);
+			sbsv1Tab.createControls();
+			sbsv1TabItem.setControl(sbsv1Tab);
+		}
 
 		PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), SDKUIHelpIds.SDK_BUILD_FILTER_PAGE);
 		
--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/sharedui/BuilderSelectionComposite.java	Mon Apr 26 15:48:38 2010 -0500
+++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/sharedui/BuilderSelectionComposite.java	Mon Apr 26 20:32:24 2010 -0500
@@ -69,11 +69,16 @@
 		builderCombo.setToolTipText(Messages.getString("NewProjectPage.builderToolTip")); //$NON-NLS-1$
 		builderCombo.setLayoutData(new GridData());
 		builderCombo.setData(".uid", "builderCombo"); //$NON-NLS-1$ //$NON-NLS-2$
-		builderCombo.add(Messages.getString("NewProjectPage.sbsv1")); //$NON-NLS-1$
+		if (SBSv2Utils.enableSBSv1Support()) {
+			builderCombo.add(Messages.getString("NewProjectPage.sbsv1")); //$NON-NLS-1$
+		}
 		builderCombo.add(Messages.getString("NewProjectPage.sbsv2")); //$NON-NLS-1$
 		builderCombo.setData(".uid", "builderCombo"); //$NON-NLS-1$ //$NON-NLS-2$
 		builderCombo.select(0);
-
+		if (!SBSv2Utils.enableSBSv1Support()) {
+			// hide the whole composite if only SBSvw is enabled
+			this.setVisible(false);
+		}
     }
 
     /**
@@ -85,18 +90,32 @@
 		useSBSv2Builder = true;
 		IStatus status = null;
 		if (builderCombo != null && builderCombo.getSelectionIndex() == 1) { 
-			
-			if (SBSv2Utils.getSBSBinDirectory() == null){
-				status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "The Symbian Build System (sbs) cannot be found on the PATH. Carbide needs a valid SBS installation on the PATH to use the SBSv2 builder."); 
+			int index = builderCombo.getSelectionIndex();
+			String selection = builderCombo.getItem(index);
+			if (selection.equals(Messages.getString("NewProjectPage.sbsv1"))) { //$NON-NLS-1$
+				if (!SBSv2Utils.enableSBSv1Support()) {
+					status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "SBSv1 is not supported on this system.");
+				}
+				useSBSv2Builder = false;
 			}
-			// check the raptor version
-			else if (SDKCorePlugin.getSDKManager().getSBSv2Version(false).getMajor() == 0){
-				// Try to scan again....
-				if (SDKCorePlugin.getSDKManager().getSBSv2Version(true).getMajor() == 0){
-					status = new Status(Status.WARNING, ProjectUIPlugin.PLUGIN_ID, "SBS version cannot be determined, some SBS functionality may not work. Please check your SBS installation.");
+			else if (selection.equals(Messages.getString("NewProjectPage.sbsv2"))) { //$NON-NLS-1$
+				
+				// if SBSv2 is selected, make sure SBS bin directory exists
+				if (SBSv2Utils.getSBSBinDirectory() == null){
+					status = new Status(Status.ERROR, ProjectUIPlugin.PLUGIN_ID, "The Symbian Build System (sbs) cannot be found on the PATH. Carbide needs a valid SBS installation on the PATH to use the SBSv2 builder.");
 				}
+				
+				// check the raptor version
+				else if (SDKCorePlugin.getSDKManager().getSBSv2Version(false).getMajor() == 0){
+					// Try to scan again....
+					if (SDKCorePlugin.getSDKManager().getSBSv2Version(true).getMajor() == 0){
+						status = new Status(Status.WARNING, ProjectUIPlugin.PLUGIN_ID, "SBS version cannot be determined, some SBS functionality may not work. Please check your SBS installation.");
+					}
+				}
+
+			} else {
+				useSBSv2Builder = false;
 			}
-
 		} else {
 			useSBSv2Builder = false;
 		}