[Title] Check a mismatch arch between rootstrap and configuration when
authordonghyuk.yang <donghyuk.yang@samsung.com>
Fri, 23 Nov 2012 01:38:39 +0000 (10:38 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Fri, 23 Nov 2012 01:38:39 +0000 (10:38 +0900)
selecting rootstrap

org.tizen.nativeplatform/src/org/tizen/nativeplatform/rootstrap/RootstrapManager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapUIMessages.properties
org.tizen.nativeplatform/src/org/tizen/nativeplatform/views/ui/RootstrapView.java

index e695b8d..e796617 100644 (file)
@@ -31,6 +31,7 @@ import org.tizen.nativecommon.build.exception.SBIException;
 import org.tizen.nativecommon.build.model.Rootstrap;
 import org.tizen.nativecommon.build.model.SBIModel;
 import org.tizen.nativecommon.build.model.Target;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
 import org.tizen.nativeplatform.preferences.PreferencesManager;
 import org.tizen.nativeplatform.util.CommandLauncher;
 import org.tizen.nativeplatform.views.model.PlatformRootstrap;
@@ -299,10 +300,13 @@ public class RootstrapManager {
        
        
        public static PlatformRootstrap getDefaultRootstrap( String arch ) {
-       String baseArch = RootstrapManager.getBaseArchitecture( arch );
-       String defaultRootstrapID = baseArch.equals("arm") ? 
-                       PlatformRootstrap.DEFAULT_ROOTSTRAP_ARM_ID : PlatformRootstrap.DEFAULT_ROOTSTRAP_I386_ID;
-       
+               String defaultRootstrapID = null;
+               if (PlatformConfigurationManager.isEmulatorArch(arch)) {
+                       defaultRootstrapID = PlatformRootstrap.DEFAULT_ROOTSTRAP_I386_ID;
+               } else if (PlatformConfigurationManager.isDeviceArch(arch)) {
+                       defaultRootstrapID = PlatformRootstrap.DEFAULT_ROOTSTRAP_ARM_ID;
+               }
+               
        return RootstrapManager.getRootstrap( defaultRootstrapID );
        }
        
@@ -493,8 +497,7 @@ public class RootstrapManager {
                }
 
                CommandLauncher.executeSudo( String.format("sudo -S rm -rf %s", path), null );
-       }
-       
+       }       
        
        public static String getBaseArchitecture( String arch ) {
                if ( arch.contains("arm") ) {
@@ -505,8 +508,6 @@ public class RootstrapManager {
                }
        }
        
-       
-       
        public static boolean generateSBIPluginXML( String id, String name, String arch, ArrayList<String> reposURLs) {
                
                IPath pluginPath = new Path(SmartBuildInterface.getInstance().getPluginPath());
index cd2b4a2..95c8c15 100644 (file)
@@ -41,6 +41,7 @@ SelectRootDlg.Title = Warning
 SelectRootDlg.Msg.LastOne = "%s [%s]" rootstrap is the last one. You can not remove it
 SelectRootDlg.Label.Desc = Follow projects use "%s" rootstrap.\nYou should set other rootstraps if you want to remove "%s" rootstrap
 
+Action.Msg.Error.SelectRootstrap = The "%s" rootstrap can not be selected at "%s" configuration because of architecture mismatch.
 Action.Msg.Error.RemoveDefault = Cannot remove basic rootstrap!  
 Action.Msg.Progress.Exporting = Exporting rootstrap...
 Action.Msg.Error.ExportUninitialzed = Cannot export uninitialized rootstrap!  
index 03562d2..a677717 100644 (file)
@@ -550,6 +550,10 @@ public class RootstrapView extends ViewPart {
                TableItem[] item = table.getSelection();
                PlatformRootstrap selected = (PlatformRootstrap)item[0].getData();
                if (project != null) {
+                       if (!verifyActiveRootstrap( project, selected)) {
+                               showErrorSelectRootstrap(project, selected);
+                               return;
+                       }
                        setActiveRootstrap( project, selected );
                }
             }
@@ -562,6 +566,14 @@ public class RootstrapView extends ViewPart {
         });
     }
     
+    private void showErrorSelectRootstrap(IProject project, PlatformRootstrap rootstrap) {
+       IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+       IConfiguration config = info.getDefaultConfiguration();
+       String message = String.format(resources.getString("Action.Msg.Error.SelectRootstrap"), 
+                       rootstrap.getId(), config.getName());
+       DialogUtil.openErrorDialog(message);
+    }
+    
     
     private void setActiveRootstrap(IProject project, PlatformRootstrap rootstrap ) {
                String rootId = rootstrap.getId();
@@ -585,6 +597,24 @@ public class RootstrapView extends ViewPart {
        ManagedBuildManager.saveBuildInfo( project, true );
     }
     
+    private boolean verifyActiveRootstrap(IProject project, PlatformRootstrap rootstrap ) {
+               IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+       IConfiguration config = info.getDefaultConfiguration();
+       String rootArch = rootstrap.getArch();
+       
+       if (PlatformConfigurationManager.isEmulatorConfiguration(config)) {
+               if (!PlatformConfigurationManager.isEmulatorArch(rootArch)) {
+                       return false;
+               }
+       } else if (PlatformConfigurationManager.isDeviceConfiguration(config)) {
+               if (!PlatformConfigurationManager.isDeviceArch(rootArch)) {
+                       return false;
+               }
+       }
+       
+       return true;
+    }
+    
     
     public void selectionPkgMgr()
     {