Fix for Bug 11073 (Remove SBSv1 as a builder option).
authorstechong
Mon, 26 Apr 2010 20:37:32 -0500
changeset 1288 7f5308d16da0
parent 1285 84caa86f9460
child 1293 be3d8ca5bafe
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
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:40:54 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuildSettingsUI.java	Mon Apr 26 20:37:32 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:40:54 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/BuilderPreferencePage.java	Mon Apr 26 20:37:32 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,17 +79,20 @@
 	@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());
 			store.setValue(BuilderPreferenceConstants.PREF_KEEP_GOING, buildSettingsUI.getKeepGoing());
@@ -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:40:54 2010 -0500
+++ b/builder/com.nokia.carbide.cdt.builder/src/com/nokia/carbide/cdt/internal/builder/ui/CarbideCPPProjectSettingsPage.java	Mon Apr 26 20:37:32 2010 -0500
@@ -23,7 +23,6 @@
 
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -154,7 +153,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:40:54 2010 -0500
+++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/api/sdk/SBSv2Utils.java	Mon Apr 26 20:37:32 2010 -0500
@@ -30,7 +30,6 @@
 import org.eclipse.core.filesystem.URIUtil;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Preferences;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.osgi.framework.Version;
@@ -41,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;
@@ -57,6 +57,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;
 
 	/**
 	 * Map of usable Raptor alias for -c parameter and base platform: <alise, base plat>
@@ -279,9 +280,9 @@
 		if (!enableSBSv2Support())
 			return true;
 		
-		// TODO LINUX: more accurate check
-		if (HostOS.IS_WIN32)
+		if (isSBSv1Supported())
 			return true;
+		
 		return false;
 	}
 	
@@ -494,4 +495,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/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/sharedui/BuilderSelectionComposite.java	Mon Apr 26 15:40:54 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:37:32 2010 -0500
@@ -16,7 +16,6 @@
 */
 package com.nokia.carbide.cpp.internal.project.ui.sharedui;
 
-import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.dialogs.IDialogSettings;
@@ -60,10 +59,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);
+		}
     }
 
     /**
@@ -75,13 +80,15 @@
 		useSBSv2Builder = true;
 		IStatus status = null;
 		if (builderCombo != null) {
-			if (builderCombo.getSelectionIndex() == 0) {
+			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;
 			}
-			else if (builderCombo.getSelectionIndex() == 1) {
+			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){