BUILD: Removed SBI process when building a platform project.
authordonghyuk.yang <donghyuk.yang@samsung.com>
Thu, 3 Apr 2014 02:23:22 +0000 (11:23 +0900)
committerdonghyuk.yang <donghyuk.yang@samsung.com>
Thu, 3 Apr 2014 02:23:22 +0000 (11:23 +0900)
Now, SBI process is removed when building a platform project and CDT
build process is used. SBI process has used because of sudo permission.
GBS actually does not need sudo permission, so it can be changed.

Change-Id: I11bd7ea55d13493b461769e802e1b5e4e5f7fabc
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
20 files changed:
org.tizen.nativeplatform/plugin.xml
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/IBuildCommandProvider.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/IBuildResultProcessor.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildCommandLauncher.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildCommandProviderFactory.java [moved from org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/factory/PackagerFactory.java with 65% similarity]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildPackageObjectAction.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildResultProcessorFactory.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformExternalBuildRunner.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentBuilder.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformProjectDependentPackager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildCommandProvider.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java [new file with mode: 0644]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/LaunchConfigurationProcessor.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/PlatformLaunchDelegate.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/PlatformPackagesTab.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectCommonLaunchShortcut.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmModelMaker.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java [deleted file]
org.tizen.nativeplatform/src/org/tizen/nativeplatform/preferences/PreferencesManager.java
org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java

index a50ebf6..1597839 100644 (file)
@@ -88,7 +88,7 @@
             <builder
                 autoBuildTarget="all"
                                cleanBuildTarget="clean"
-                command="sbi-make"
+                command="/usr/bin/gbs"
                 commandLauncher="org.tizen.nativeplatform.build.PlatformBuildCommandLauncher"                                          
                 buildfileGenerator="org.tizen.nativeplatform.build.PlatformMakeGenerator"
                 buildRunner="org.tizen.nativeplatform.build.PlatformExternalBuildRunner"
             
         </actionSet>
     </extension>
--->    
+-->
+
+<!--
     <extension
           point="org.eclipse.ui.popupMenus">
 
             </enablement>
         </objectContribution>          
     </extension>
+-->
        <extension
        point="org.eclipse.cdt.core.templateProcessTypes">
         <processType
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/IBuildCommandProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/IBuildCommandProvider.java
new file mode 100644 (file)
index 0000000..3412bd8
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.build;
+
+public interface IBuildCommandProvider {
+    enum BUILDTOOL {
+        GBS
+    }
+    
+    String getBuildCommand();
+    String[] getBuildArguments();
+    String getCleanCommand();
+    String[] getCleanArguments();
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/IBuildResultProcessor.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/IBuildResultProcessor.java
new file mode 100644 (file)
index 0000000..baf285b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.build;
+
+public interface IBuildResultProcessor {
+    boolean process(String[] buildArguments);
+    String[] getOutputFiles();
+}
index 697e09a..4914927 100644 (file)
@@ -37,11 +37,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
-
 import org.tizen.common.util.ProcessMonitorThread;
 import org.tizen.nativecommon.ProjectUtil;
 import org.tizen.nativecommon.build.ProjectTypeManager;
-import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativeplatform.Activator;
 
 public class PlatformBuildCommandLauncher extends CommandLauncher {
@@ -51,36 +49,32 @@ public class PlatformBuildCommandLauncher extends CommandLauncher {
 
         Process proc = null;
 
-        if (commandPath.toString().contains("sbi-make")) {
+        if (commandPath.toString().contains("/usr/bin/gbs")) {
             IProject proj = getProject();
-            PlatformProjectDependentPackager packager = (PlatformProjectDependentPackager) ProjectTypeManager
-                    .getProjectPackagerInstance(proj);
-            SmartBuildInterface sbi = SmartBuildInterface.getInstance(proj);
+            PlatformProjectDependentBuilder builder = (PlatformProjectDependentBuilder) ProjectTypeManager
+                    .getProjectBuilderInstance(proj);
             IConfiguration config = ManagedBuildManager.getBuildInfo(proj)
                     .getDefaultConfiguration();
             IPath workingPath = new Path(proj.getLocation().toOSString());
-            String[] new_envs = packager.getEnvironment(config);
-            String cmd = "";
+            String[] new_envs = builder.getEnvironment(config);
+
+            String command = "";
+            String[] arguments = null;
             if ("clean".equals(args[0])) {
-                cmd = packager.getCleanCmd(config);
+                command = builder.getCleanCommand(config);
+                arguments = builder.getCleanArguments(config);
             } else {
-                cmd = packager.getBuildPackageCmd(config);
+                command = builder.getBuildCommand(config);
+                arguments = builder.getBuildArguments(config);
             }
-            if (cmd == null || cmd.isEmpty()) {
+
+            if (command == null || command.isEmpty()) {
                 Status status = new Status(Status.ERROR, Activator.PLUGIN_ID,
                         "Failed to build the project", null);
                 throw new CoreException(status);
             }
-
-            String[] cmds = sbi.parseCommandString(cmd);
-            String[] argus = new String[cmds.length - 1];
-            for (int i = 0; i < cmds.length - 1; i++) {
-                argus[i] = cmds[i + 1];
-            }
-
-            proc = super.execute(new Path(cmds[0]), argus, new_envs, workingPath,
+            proc = super.execute(new Path(command), arguments, new_envs, workingPath,
                     new NullProgressMonitor());
-
             if ("clean".equals(args[0])) {
                 proj.touch(monitor);
                 ProjectUtil.refreshResources(proj);
  *
  */
 
-package org.tizen.nativeplatform.pkg.commander.factory;
+package org.tizen.nativeplatform.build;
 
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.core.resources.IProject;
-import org.tizen.nativeplatform.pkg.commander.IPackager;
-import org.tizen.nativeplatform.pkg.commander.rpm.RpmPackager;
-import org.tizen.nativeplatform.types.PkgTypes;
+import org.tizen.nativeplatform.build.IBuildCommandProvider.BUILDTOOL;
+import org.tizen.nativeplatform.build.gbs.GBSBuildCommandProvider;
 
-public class PackagerFactory {
-
-    public static IPackager getPackager(PkgTypes type, IProject project,
-            IConfiguration config) {
-        if (type.equals(PkgTypes.RPM)) {
-            return new RpmPackager(project, config);
+public class PlatformBuildCommandProviderFactory {
+    public static IBuildCommandProvider getProvider(BUILDTOOL tool, IConfiguration config) {
+        if (tool.equals(BUILDTOOL.GBS)) {
+            IBuildCommandProvider provider = new GBSBuildCommandProvider(config);
+            return provider;
         } else {
             return null;
         }
index 9e84c58..f8a158b 100644 (file)
@@ -78,7 +78,7 @@ public class PlatformBuildPackageObjectAction implements IWorkbenchWindowActionD
                 @Override
                 public void run(IProgressMonitor monitor) throws InvocationTargetException,
                         InterruptedException {
-                    packagingResult = pkgUtil.pakaging(project, config, monitor);
+                    //packagingResult = pkgUtil.pakaging(project, config, monitor);
                 }
             });
         } catch (InvocationTargetException e1) {
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildResultProcessorFactory.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/PlatformBuildResultProcessorFactory.java
new file mode 100644 (file)
index 0000000..8386f5f
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.build;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.tizen.nativeplatform.build.IBuildCommandProvider.BUILDTOOL;
+import org.tizen.nativeplatform.build.gbs.GBSBuildResultProcessor;
+
+public class PlatformBuildResultProcessorFactory {
+    public static IBuildResultProcessor getProcessor(BUILDTOOL tool, IConfiguration config) {
+        if (tool.equals(BUILDTOOL.GBS)) {
+            IBuildResultProcessor processor = new GBSBuildResultProcessor(config);
+            return processor;
+        } else {
+            return null;
+        }
+    }
+}
index 85015bb..c8f3b13 100644 (file)
@@ -47,6 +47,7 @@ import org.eclipse.cdt.core.resources.RefreshScopeManager;
 import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
 import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
 import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
+import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
 import org.eclipse.cdt.make.core.scannerconfig.InfoContext;
 import org.eclipse.cdt.make.internal.core.StreamMonitor;
 import org.eclipse.cdt.make.internal.core.scannerconfig2.SCProfileInstance;
@@ -56,6 +57,7 @@ import org.eclipse.cdt.managedbuilder.core.ExternalBuildRunner;
 import org.eclipse.cdt.managedbuilder.core.IBuilder;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
 import org.eclipse.cdt.managedbuilder.core.IFileInfo;
+import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
 import org.eclipse.cdt.managedbuilder.core.IInputType;
 import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
 import org.eclipse.cdt.managedbuilder.core.ITool;
@@ -81,12 +83,10 @@ import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.QualifiedName;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser;
-import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
 import org.eclipse.swt.widgets.Display;
-import org.tizen.common.util.OSChecker;
 import org.tizen.common.util.log.UserInteraction;
 import org.tizen.common.util.log.UserLogger;
+import org.tizen.nativeplatform.build.IBuildCommandProvider.BUILDTOOL;
 import org.tizen.nativeplatform.util.PackageUtil;
 import org.tizen.nativeplatform.util.PlatformProjectUtil;
 
@@ -104,8 +104,10 @@ public class PlatformExternalBuildRunner extends ExternalBuildRunner {
             final IConfiguration configuration, IBuilder builder, IConsole console,
             IMarkerGenerator markerGenerator, IncrementalProjectBuilder projectBuilder,
             IProgressMonitor monitor) throws CoreException {
+        UserLogger.start(UserInteraction.CATE_PLATFORM_BUILD);
         boolean isClean = invokeExternalBuild(kind, project, configuration, builder, console,
                 markerGenerator, projectBuilder, monitor);
+        UserLogger.end(UserInteraction.CATE_PLATFORM_BUILD);
         final PackageUtil pkgUtil = new PackageUtil(PlatformProjectUtil.getPkgType());
         Display.getDefault().asyncExec(new Runnable() {
             public void run() {
@@ -236,8 +238,9 @@ public class PlatformExternalBuildRunner extends ExternalBuildRunner {
                         monitor);
                 if (p != null) {
                     /*
-                     * try { // Close the input of the Process explicitly. // We will never write to
-                     * it. p.getOutputStream().close(); } catch (IOException e) { }
+                     * try { // Close the input of the Process explicitly. // We
+                     * will never write to it. p.getOutputStream().close(); }
+                     * catch (IOException e) { }
                      */
                     // Before launching give visual cues via the monitor
                     monitor.subTask(ManagedMakeMessages
@@ -250,14 +253,42 @@ public class PlatformExternalBuildRunner extends ExternalBuildRunner {
                             .getResourceString("MakeBuilder.Updating_project")); //$NON-NLS-1$
 
                     try {
-                        // Do not allow the cancel of the refresh, since the builder is external
-                        // to Eclipse, files may have been created/modified and we will be
+                        // Do not allow the cancel of the refresh, since the
+                        // builder is external
+                        // to Eclipse, files may have been created/modified and
+                        // we will be
                         // out-of-sync.
-                        // The caveat is for huge projects, it may take sometimes at every build.
+                        // The caveat is for huge projects, it may take
+                        // sometimes at every build.
 
                         // TODO should only refresh output folders
                         // project.refreshLocal(IResource.DEPTH_INFINITE, null);
 
+                        // Synchronize build output files.
+                        int exitValue = p.exitValue();
+                        if (exitValue == 0) {
+                            IBuildResultProcessor processor = PlatformBuildResultProcessorFactory
+                                    .getProcessor(BUILDTOOL.GBS, configuration);
+                            if (processor.process(buildArguments)) {
+                                String[] outputFiles = processor.getOutputFiles();
+                                buf = new StringBuffer(NEWLINE);
+                                buf.append("**** Synchronized output files ****").append(NEWLINE);
+                                for (String file : outputFiles) {
+                                    buf.append(" - ").append(file).append(NEWLINE);
+                                }
+                                consoleOut.write(buf.toString().getBytes());
+                            } else {
+                                buf = new StringBuffer(NEWLINE);
+                                buf.append("**** Failed to synchronize output files ****").append(
+                                        NEWLINE);
+                                consoleOut.write(buf.toString().getBytes());
+                            }
+                        } else {
+                            buf = new StringBuffer(NEWLINE);
+                            buf.append("**** Failed to build ****").append(NEWLINE);
+                            consoleOut.write(buf.toString().getBytes());
+                        }
+
                         // use the refresh scope manager to refresh
                         RefreshScopeManager refreshManager = RefreshScopeManager.getInstance();
                         IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project);
index 158d84b..66ee60f 100644 (file)
 package org.tizen.nativeplatform.build;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
+import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.Path;
 import org.tizen.nativecommon.build.CommonProjectDependentBuilder;
+import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.build.exception.SBIException;
+import org.tizen.nativeplatform.build.IBuildCommandProvider.BUILDTOOL;
 import org.tizen.nativeplatform.password.SudoPasswdManager;
+import org.tizen.nativeplatform.preferences.PreferencesManager;
 
 public class PlatformProjectDependentBuilder extends CommonProjectDependentBuilder {
 
@@ -64,21 +77,17 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild
 
     @Override
     protected String getConfigureOption() {
-
         String options = String.format(" ");
-
         return options;
     }
 
     @Override
     protected String getMakeOption() {
-        // TODO Auto-generated method stub
         return "";
     }
 
     @Override
     protected String getCleanOption() {
-        // TODO Auto-generated method stub
         return "";
     }
 
@@ -152,6 +161,87 @@ public class PlatformProjectDependentBuilder extends CommonProjectDependentBuild
             return options.concat(sysroot);
         }
     }
+    
+    public String getBuildCommand(IConfiguration config) {
+        IBuildCommandProvider provider = PlatformBuildCommandProviderFactory.getProvider(BUILDTOOL.GBS, config);
+        if (provider != null) {
+            return provider.getBuildCommand();
+        } else {
+            return "";
+        }
+    }
+    
+    public String[] getBuildArguments(IConfiguration config) {
+        IBuildCommandProvider provider = PlatformBuildCommandProviderFactory.getProvider(BUILDTOOL.GBS, config);
+        if (provider != null) {
+            return provider.getBuildArguments();
+        } else {
+            return new String[0];
+        }
+    }
+    
+    public String getCleanCommand(IConfiguration config) {
+        IBuildCommandProvider provider = PlatformBuildCommandProviderFactory.getProvider(BUILDTOOL.GBS, config);
+        if (provider != null) {
+            return provider.getCleanCommand();
+        } else {
+            return "";
+        }
+    }
+    
+    public String[] getCleanArguments(IConfiguration config) {
+        IBuildCommandProvider provider = PlatformBuildCommandProviderFactory.getProvider(BUILDTOOL.GBS, config);
+        if (provider != null) {
+            return provider.getCleanArguments();
+        } else {
+            return new String[0];
+        }
+    }
+
+    public String[] getEnvironment(IConfiguration config) {
+        List<String> newEnvArray = new ArrayList<String>();
+        ICConfigurationDescription cfgDes = ManagedBuildManager
+                .getDescriptionForConfiguration(config);
+        IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
+        IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
+        Map<String, String> envMap = new HashMap<String, String>();
+        for (IEnvironmentVariable var : vars) {
+            envMap.put(var.getName(), var.getValue());
+        }
+        // add proxySet variable to Map
+        if (PreferencesManager.isProxyUsed()) {
+            String[] proxyInfo = PreferencesManager.getProxyParsedURL();
+            if (proxyInfo != null) {
+                String protocol = proxyInfo[0];
+                String host = proxyInfo[1];
+                String port = proxyInfo[2];
+                String envKey = String.format("%s_proxy", protocol);
+                String envValue = String.format("%s://%s:%s", protocol, host, port);
+                envMap.put(envKey, envValue);
+            }
+        }
+        for (Entry<String, String> entry : envMap.entrySet()) {
+            newEnvArray.add(String.format("%s=%s", entry.getKey(), entry.getValue()));
+        }
+        return newEnvArray.toArray(new String[0]);
+    }
+
+    public String[] getEnvsWithProxy() {        
+        String[] envs = SmartBuildInterface.getInstance().getEnvironmentVariables();
+        if (PreferencesManager.isProxyUsed()) {
+            String[] proxyInfo = PreferencesManager.getProxyParsedURL();
+            if (proxyInfo != null) {
+                String protocol = proxyInfo[0];
+                String host = proxyInfo[1];
+                String port = proxyInfo[2];
+                SmartBuildInterface sbi = SmartBuildInterface.getInstance();
+                String envKey = String.format("%s_proxy", protocol);
+                String envValue = String.format("%s://%s:%s", protocol, host, port);
+                envs = sbi.addEnvironmentVariableArray(envKey, envValue);
+            }
+        }
+        return envs;
+    }
 
     @Override
     public void setBuildTargetID(IConfiguration config, String targetId) {
index 2c3bed7..30fafd3 100644 (file)
 
 package org.tizen.nativeplatform.build;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
-import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
-import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
 import org.tizen.nativecommon.build.CommonProjectDependentPackager;
-import org.tizen.nativecommon.build.SmartBuildInterface;
 import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativeplatform.password.SudoPasswdManager;
-import org.tizen.nativeplatform.preferences.PreferencesManager;
-import org.tizen.nativeplatform.rootstrap.RootstrapManager;
-import org.tizen.nativeplatform.views.model.PlatformRootstrap;
 
+//This class is not used in platform project
 public class PlatformProjectDependentPackager extends CommonProjectDependentPackager {
 
-    private static final String ACTION_BUILDPACKAGE = "buildpackage";
-    private static final String CONSOLE_NAME = "Packaging";
     private static PlatformProjectDependentPackager instance = new PlatformProjectDependentPackager();
 
     public static final CommonProjectDependentPackager getInstance() {
@@ -75,153 +57,7 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack
 
     @Override
     public String getPackageOption(IConfiguration config, String pkgType) {
-        String workingDir = getWorkingDir(config);
-        String options = "";
-        String passwd = SudoPasswdManager.getSudoPassword();
-        if (passwd == null) {
-            return null;
-        }
-
-        if (RPM.equals(pkgType)) {
-            options = String.format("-PASSWD=%s " + "-WORKING_DIR=%s " + "-PKG_TYPE=%s", passwd,
-                    workingDir, pkgType);
-        } else {
-            options = String.format("-WORKING_DIR=%s " + "-PKG_TYPE=%s", workingDir, pkgType);
-        }
-
-        return options;
-    }
-
-    public String getPackageOption(IConfiguration config, PlatformRootstrap rootstrap) {
-        String workingDir = getWorkingDir(config);
-        String passwd = SudoPasswdManager.getSudoPassword();
-        if (passwd == null) {
-            return null;
-        }
-
-        StringBuffer sbSnapshots = new StringBuffer();
-        for (String s : rootstrap.getJustRepoURLs()) {
-            sbSnapshots.append(" " + s);
-        }
-
-        StringBuffer sbGbsOptions = new StringBuffer();
-        for (String op : PlatformConfigurationManager.getGBSOptions(config)) {
-            sbGbsOptions.append(" " + op);
-        }
-
-        // Add --dist option if the rootstrap is based on local repository.
-        IPath confFile = rootstrap.getConfFile();
-        if (confFile != null) {
-            sbGbsOptions.append(" " + String.format("--dist %s", confFile.toOSString()));
-        }
-
-        String gbsOptions = sbGbsOptions.toString().trim();
-        String options = String
-                .format("-PASSWD=%s " + "-WORKING_DIR=%s " + "-SNAPSHOTS=\"%s\" "
-                        + "-OPTIONS=\"%s\" ", passwd, workingDir, sbSnapshots.toString().trim(),
-                        gbsOptions);
-
-        return options;
-    }
-
-    public void buildPackage(String pkgType) throws SBIException {
-        IConfiguration config = getCurrentConfiguration();
-
-        buildPackage(config, pkgType);
-    }
-
-    public void buildPackage(String configName, String pkgType) throws SBIException {
-        IConfiguration[] configurations = ManagedBuildManager.getBuildInfo(project)
-                .getManagedProject().getConfigurations();
-        IConfiguration config = null;
-
-        for (IConfiguration c : configurations) {
-            if (c.getName().equals(configName)) {
-                config = c;
-                break;
-            }
-        }
-
-        buildPackage(config, pkgType);
-    }
-
-    // command "build package" from specified configuration and pkgType
-    private void buildPackage(IConfiguration config, String pkgType) throws SBIException {
-        String projectDir = getProjectPath();
-        String[] new_envs = getEnvironment(config);
-        String cmd = getBuildPackageCmd(config);
-        if (cmd == null || cmd.isEmpty()) {
-            throw new SBIException("Failed to build the project");
-        }
-        sbi.actionConsole(cmd, projectDir, new_envs, CONSOLE_NAME);
-    }
-
-    public String[] getEnvironment(IConfiguration config) {
-        List<String> newEnvArray = new ArrayList<String>();
-        ICConfigurationDescription cfgDes = ManagedBuildManager
-                .getDescriptionForConfiguration(config);
-        IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
-        IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
-        Map<String, String> envMap = new HashMap<String, String>();
-        for (IEnvironmentVariable var : vars) {
-            envMap.put(var.getName(), var.getValue());
-        }
-        // add proxySet variable to Map
-        if (PreferencesManager.isProxyUsed()) {
-            String[] proxyInfo = PreferencesManager.getProxyParsedURL();
-            if (proxyInfo != null) {
-                String protocol = proxyInfo[0];
-                String host = proxyInfo[1];
-                String port = proxyInfo[2];
-                String envKey = String.format("%s_proxy", protocol);
-                String envValue = String.format("%s://%s:%s", protocol, host, port);
-                envMap.put(envKey, envValue);
-            }
-        }
-        for (Entry<String, String> entry : envMap.entrySet()) {
-            newEnvArray.add(String.format("%s=%s", entry.getKey(), entry.getValue()));
-        }
-        return newEnvArray.toArray(new String[0]);
-    }
-
-    public String getCleanCmd(IConfiguration config) {
-        String targetId = getTargetID(config);
-        IPath configPath = project.getLocation().append(config.getName());
-
-        return String.format("%s action %s -- %s -CONFIG_DIR=\"%s\"", sbi.getSBICommandPath("sbi"),
-                targetId, "clean", configPath.toOSString());
-    }
-
-    public String getBuildPackageCmd(IConfiguration config) {
-        String targetId = getTargetID(config);
-        String rootId = sbi.getRootstrapIDFromTargetID(targetId);
-        PlatformRootstrap rt = RootstrapManager.getRootstrap(rootId);
-        if (rt == null) {
-            return "";
-        }
-        String options = getPackageOption(config, rt);
-        if (options == null) {
-            return "";
-        }
-        return String.format("%s action %s -- %s %s", sbi.getSBICommandPath("sbi"), targetId,
-                ACTION_BUILDPACKAGE, options);
-    }
-
-    public String[] getEnvsWithProxy() {
-        String[] envs = sbi.getEnvironmentVariables();
-        if (PreferencesManager.isProxyUsed()) {
-            String[] proxyInfo = PreferencesManager.getProxyParsedURL();
-            if (proxyInfo != null) {
-                String protocol = proxyInfo[0];
-                String host = proxyInfo[1];
-                String port = proxyInfo[2];
-                SmartBuildInterface sbi = SmartBuildInterface.getInstance();
-                String envKey = String.format("%s_proxy", protocol);
-                String envValue = String.format("%s://%s:%s", protocol, host, port);
-                envs = sbi.addEnvironmentVariableArray(envKey, envValue);
-            }
-        }
-        return envs;
+        return "";
     }
 
     @Override
@@ -252,12 +88,18 @@ public class PlatformProjectDependentPackager extends CommonProjectDependentPack
     @Override
     public void buildPackage(String configName, String pkgType, boolean signApp)
             throws SBIException, CoreException {
-        buildPackage(configName, pkgType);
     }
 
     @Override
     public void buildPackage(String pkgType, boolean signApp, boolean isLaunchMode)
             throws SBIException, CoreException {
-        buildPackage(pkgType);
+    }
+
+    @Override
+    public void buildPackage(String pkgType) throws SBIException, CoreException {
+    }
+
+    @Override
+    public void buildPackage(String configName, String pkgType) throws SBIException, CoreException {
     }
 }
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildCommandProvider.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildCommandProvider.java
new file mode 100644 (file)
index 0000000..1a1b6e0
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.build.gbs;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.build.IBuildCommandProvider;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+
+public class GBSBuildCommandProvider implements IBuildCommandProvider {
+
+    private IConfiguration config;
+
+    public static final String BUILD_COMMAND = "/usr/bin/gbs";
+    public static final String CLEAN_COMMAND = "/bin/rm";
+    public static final String BUILD_SUBCOMMAND = "build";
+    public static final String ARCH_OP = "--arch";
+    public static final String REPO_OP = "--repository";
+    public static final String DEFINE_OP = "--define";
+    public static final String BUILDROOT_OP = "--buildroot";
+    public static final String EXTRAPKG_OP = "--extra-packs";
+
+    public GBSBuildCommandProvider(IConfiguration config) {
+        this.config = config;
+    }
+
+    @Override
+    public String getBuildCommand() {
+        return BUILD_COMMAND;
+    }
+
+    @Override
+    public String[] getBuildArguments() {
+        String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+        String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+        PlatformRootstrap rt = RootstrapManager.getRootstrap(rootId);
+        List<String> args = new ArrayList<String>();
+        args.add(BUILD_SUBCOMMAND);
+        args.add(ARCH_OP);
+        args.add(rt.getArch());
+        for (String snapshot : rt.getJustRepoURLs()) {
+            args.add(REPO_OP);
+            args.add(snapshot);
+        }
+        args.add(String.format("%s=%s", BUILDROOT_OP, rt.getPath().toOSString()));
+        args.add(String.format("%s=zypper,gdb,gdb-server", EXTRAPKG_OP));
+        for (String op : PlatformConfigurationManager.getGBSOptions(config)) {
+            args.add(op);
+        }
+        args.add(DEFINE_OP);
+        args.add("BUILD_TYPE ${BUILD_TYPE}");
+        return args.toArray(new String[0]);
+    }
+
+    @Override
+    public String getCleanCommand() {
+        return CLEAN_COMMAND;
+    }
+
+    @Override
+    public String[] getCleanArguments() {
+        IProject project = (IProject) config.getOwner();
+        IPath configPath = project.getLocation().append(config.getName());
+        List<String> args = new ArrayList<String>();
+        args.add("-rf");
+        args.add(configPath.toOSString());
+        return args.toArray(new String[0]);
+    }
+
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java
new file mode 100644 (file)
index 0000000..b0e8dc1
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Native Platform
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Donghyuk Yang <donghyuk.yang@samsung.com>  
+ * DongHee Yang <donghee.yang@samsung.com>
+ * Kangho Kim <kh5325.kim@samsung.com>
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+package org.tizen.nativeplatform.build.gbs;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.tizen.common.util.FileUtil;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativeplatform.build.IBuildResultProcessor;
+import org.tizen.nativeplatform.build.PlatformConfigurationManager;
+import org.tizen.nativeplatform.filefilter.RpmFileFilter;
+import org.tizen.nativeplatform.filefilter.XmlFileFilter;
+import org.tizen.nativeplatform.rootstrap.RootstrapManager;
+import org.tizen.nativeplatform.views.model.PlatformRootstrap;
+
+public class GBSBuildResultProcessor implements IBuildResultProcessor {
+
+    private IConfiguration config;
+    private List<String> rpmfiles = new ArrayList<String>();
+    private List<String> xmlfiles = new ArrayList<String>();
+
+    public GBSBuildResultProcessor(IConfiguration config) {
+        this.config = config;
+    }
+
+    @Override
+    public boolean process(String[] buildArguments) {
+        if (buildArguments != null && buildArguments.length > 0) {
+            if (buildArguments[0].equals("clean")) {
+                return true;
+            }
+        }
+        String targetId = PlatformConfigurationManager.getBuildTargetName(config);
+        String rootId = SmartBuildInterface.getInstance().getRootstrapIDFromTargetID(targetId);
+        PlatformRootstrap rootstrap = RootstrapManager.getRootstrap(rootId);
+        List<String> rpms = getRpmFiles(rootstrap);
+        if (rpms.isEmpty()) {
+            return false;
+        }
+        rpmfiles.clear();
+        xmlfiles.clear();
+        IProject project = (IProject) config.getOwner();
+        IPath projectPath = project.getLocation();
+        IPath configPath = project.getLocation().append(config.getName());
+        for (String rpm : rpms) {
+            try {
+                String filename = FileUtil.getFileNameFromPath(rpm);
+                String targetPath = configPath.append(filename).toOSString();
+                FileUtil.copyTo(rpm, targetPath);
+                rpmfiles.add(targetPath);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        List<String> xmls = getXmlFiles(rootstrap);
+        for (String xml : xmls) {
+            try {
+                String fileName = FileUtil.getFileNameFromPath(xml);
+                String targetPath = projectPath.append(fileName).toOSString();
+                FileUtil.copyTo(xml, targetPath);
+                xmlfiles.add(targetPath);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return true;
+    }
+
+    private List<String> getRpmFiles(PlatformRootstrap rootstrap) {
+        List<String> rpms = new ArrayList<String>();
+        String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+                rootstrap.getPath());
+        String arch = rootstrap.getArch();
+        IPath rpmPath = new Path(rootstrapPath).append("home").append("abuild").append("rpmbuild")
+                .append("RPMS").append(arch);
+        File rpmDir = rpmPath.toFile();
+        if (rpmDir.exists()) {
+            String[] files = rpmDir.list(new RpmFileFilter());
+            for (String file : files) {
+                IPath pkgPath = new Path(rpmDir.getPath()).append(file);
+                rpms.add(pkgPath.toOSString());
+            }
+        }
+        return rpms;
+    }
+
+    private List<String> getXmlFiles(PlatformRootstrap rootstrap) {
+        List<String> xmls = new ArrayList<String>();
+        String rootstrapPath = SmartBuildInterface.getInstance().getPlatformRootstrapPath(
+                rootstrap.getPath());
+        IPath rpmPath = new Path(rootstrapPath).append("home").append("abuild").append("rpmbuild")
+                .append("BUILD");
+        File[] paths = rpmPath.toFile().listFiles();
+        for (File path : paths) {
+            if (path.exists() && path.isDirectory()) {
+                String[] files = path.list(new XmlFileFilter());
+                for (String file : files) {
+                    IPath xmlPath = new Path(path.getPath()).append(file);
+                    xmls.add(xmlPath.toOSString());
+                }
+            }
+        }
+        return xmls;
+    }
+
+    @Override
+    public String[] getOutputFiles() {
+        List<String> result = new ArrayList<String>();
+        result.addAll(rpmfiles);
+        result.addAll(xmlfiles);
+        return result.toArray(new String[0]);
+    }
+
+}
index 993fcd9..a69824b 100644 (file)
@@ -16,7 +16,9 @@ import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Shell;
+import org.tizen.common.util.DialogUtil;
 import org.tizen.common.util.SWTUtil;
 import org.tizen.nativeplatform.Activator;
 import org.tizen.nativeplatform.build.PlatformConfigurationManager;
@@ -49,6 +51,7 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
     private IPkgFilter pkgFilter = PkgFilterFactory.getFilter(PlatformProjectUtil.getPkgType());
     private String rootstrapInstallLog = "";
     private String deviceInstallLog = "";
+    private boolean continueLaunch = true;
 
     public LaunchConfigurationProcessor(Shell shell, ILaunchConfiguration launchConfig,
             IProject project, String mode, PkgCommandTarget target, IProgressMonitor monitor) {
@@ -146,7 +149,11 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
             }
             setOptionAttributes(wc, devicePackages, rootstrapPackages, reinstallOp);
         }
-        return _installPackages(devicePackages, rootstrapPackages, reinstallOp, monitor);
+        if (questionIfNoPackagesToInstall(devicePackages, rootstrapPackages)) {
+            return _installPackages(devicePackages, rootstrapPackages, reinstallOp, monitor);
+        } else {
+            return false;
+        }
     }
 
     private boolean setLaunchConfigurationForEFL(IProgressMonitor monitor, final String descMsg,
@@ -268,4 +275,31 @@ public class LaunchConfigurationProcessor implements ILaunchConfigurationProcess
     protected IConfiguration getBuildConfiguration() {
         return PlatformConfigurationManager.getDefaultConfiguration(project);
     }
+    
+    protected boolean questionIfNoPackagesToInstall(List<IPackage> devicePackages, List<IPackage> rootstrapPackages) {
+        final StringBuffer msg = new StringBuffer();
+        if (devicePackages.isEmpty()) {
+            msg.append("There is no package to install to device.");
+            msg.append("\n");
+        }        
+        if (mode.equals(ILaunchManager.DEBUG_MODE) && rootstrapPackages.isEmpty()) {
+            msg.append("There is no package to install to rootstrap.");
+            msg.append("\n");
+        }
+        if (msg.length() != 0) {
+            msg.append("\n");
+            msg.append("Do you want to continue?");
+            SWTUtil.syncExec(new Runnable() {
+                @Override
+                public void run() {
+                    if (DialogUtil.openQuestionDialog(msg.toString()) == SWT.YES) {
+                        continueLaunch = true;
+                    } else {
+                        continueLaunch = false;
+                    }
+                }
+            });
+        }
+        return continueLaunch;
+    }
 }
index e97da7b..3b7ccb3 100644 (file)
@@ -301,10 +301,10 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         }
     }
 
-    protected boolean packagingProject(final IProject targetProj, final IConfiguration config,
-            IProgressMonitor monitor) {
-        boolean packagingResult = pkgUtil.pakaging(targetProj, config, monitor);
-        if (packagingResult) {
+    protected boolean buildProject(final IProject targetProj, final IConfiguration config,
+            IProgressMonitor monitor) throws CoreException {
+        boolean result = pkgUtil.build(targetProj, config, monitor);
+        if (result) {
             Display.getDefault().asyncExec(new Runnable() {
                 public void run() {
                     pkgUtil.cachePkgChecksum(targetProj, config);
@@ -316,7 +316,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
             DialogUtil.openErrorDialog(shell, CommonBuildMessages.BUILD_RESULT,
                     CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
         }
-        return packagingResult;
+        return result;
     }
 
     protected void verifyPlatformProjectSettings(ILaunchConfiguration config) throws CoreException {
@@ -882,7 +882,7 @@ public class PlatformLaunchDelegate extends AbstractCLaunchDelegate {
         List<IPackage> pkgs = pkgUtil.getPackages(project, config);
         if (pkgs.isEmpty()) {
             if (PlatformLaunchUtil.questionPackaging(project)) {
-                if (packagingProject(project, config, new SubProgressMonitor(monitor, 1))) {
+                if (buildProject(project, config, new SubProgressMonitor(monitor, 1))) {
                     pkgs = pkgUtil.getPackages(project, config);
                 } else {
                     if (!PlatformLaunchUtil.questionContinue()) {
index f1ff2c3..ad55009 100644 (file)
@@ -485,6 +485,7 @@ public class PlatformPackagesTab extends PlatformCommonTab {
         devicePackages.clear();
         deviceTableViewer.getTable().clearAll();
         if (devicePkgs.isEmpty()) {
+            deviceTableViewer.setInput(devicePackages);
             setErrorMessage("Failed to get packages. Build a project first");
         } else {
             IPkgModelMaker maker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType());
index 4d97904..d2108c0 100644 (file)
@@ -360,7 +360,7 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
         List<IPackage> pkgs = pkgUtil.getPackages(project, config);
         if (pkgs.isEmpty()) {
             if (PlatformLaunchUtil.questionPackaging(project)) {
-                if (!packagingProject(project, config)) {
+                if (!buildProject(project, config)) {
                     DialogUtil.openErrorDialog(CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
                     if (PlatformLaunchUtil.questionContinue()) {
                         return true;
@@ -374,6 +374,8 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
                         }
                     });
                 }
+            } else {
+                return false;
             }
         }
         return true;
@@ -388,7 +390,7 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
         return false;
     }
 
-    protected boolean packagingProject(final IProject project, final IConfiguration config) {
+    protected boolean buildProject(final IProject project, final IConfiguration config) {
         Shell shell = getAvaiableShell();
         ProgressMonitorDialog dialog = new ProgressMonitorDialog(shell);
         try {
@@ -396,7 +398,11 @@ abstract public class PlatformProjectCommonLaunchShortcut extends CApplicationLa
                 @Override
                 public void run(IProgressMonitor monitor) throws InvocationTargetException,
                         InterruptedException {
-                    result = pkgUtil.pakaging(project, config, monitor);
+                    try {
+                        result = pkgUtil.build(project, config, monitor);
+                    } catch (CoreException e) {
+                        throw new InvocationTargetException(e);
+                    }
                 }
             });
         } catch (InvocationTargetException e) {
index e727973..210e38f 100644 (file)
@@ -87,7 +87,9 @@ public class RpmModelMaker implements IPkgModelMaker {
         List<IPackage> pkgs = new ArrayList<IPackage>();
         for (String path : filePaths) {
             IPackage pkg = makeModel(path);
-            pkgs.add(pkg);
+            if (pkg != null) {
+                pkgs.add(pkg);
+            }
         }
         return pkgs;
     }
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmPackager.java
deleted file mode 100644 (file)
index 923bb8d..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Native Platform
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Donghyuk Yang <donghyuk.yang@samsung.com>  
- * DongHee Yang <donghee.yang@samsung.com>
- * Kangho Kim <kh5325.kim@samsung.com>
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-package org.tizen.nativeplatform.pkg.commander.rpm;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.tizen.nativecommon.build.CommonProjectDependentPackager;
-import org.tizen.nativecommon.build.ProjectTypeManager;
-import org.tizen.nativecommon.build.exception.SBIException;
-import org.tizen.nativeplatform.build.PlatformCheckCancelJob;
-import org.tizen.nativeplatform.filefilter.RpmFileFilter;
-import org.tizen.nativeplatform.pkg.commander.IPackager;
-
-public class RpmPackager implements IPackager {
-
-    private IProject project = null;
-    private IConfiguration config = null;
-
-    public RpmPackager(IProject proj, IConfiguration config) {
-        this.project = proj;
-        this.config = config;
-    }
-
-    @Override
-    public boolean packaging(IProgressMonitor monitor) {
-        String PKGTYPE = "RPM";
-        boolean result = false;
-
-        CommonProjectDependentPackager packager = ProjectTypeManager
-                .getProjectPackagerInstance(project);
-
-        monitor.beginTask("Packaging...", 2);
-
-        PlatformCheckCancelJob cancelJob = new PlatformCheckCancelJob(monitor, project,
-                packager.getSbi());
-        Thread checkCancelThread = new Thread(cancelJob);
-        checkCancelThread.start();
-
-        try {
-            monitor.subTask("Packaging " + project.getName());
-            packager.buildPackage(PKGTYPE);
-        } catch (SBIException e) {
-            e.printStackTrace();
-            cancelJob.setFinishFlag(true);
-            monitor.done();
-            return false;
-        } catch (CoreException e) {
-            cancelJob.setFinishFlag(true);
-            monitor.done();
-            return false;
-        }
-        monitor.worked(1);
-        cancelJob.setFinishFlag(true);
-        monitor.subTask("Refreshing project...");
-        List<String> pkgfiles = getProjectPackages();
-        try {
-            project.refreshLocal(IResource.DEPTH_INFINITE, null);
-        } catch (CoreException e) {
-            e.printStackTrace();
-        }
-        monitor.worked(1);
-        result = !pkgfiles.isEmpty();
-        monitor.done();
-        return result;
-    }
-
-    public List<String> getProjectPackages() {
-        List<String> pkgs = new ArrayList<String>();
-        IFolder folder = project.getFolder(config.getName());
-        File dir = new File(folder.getLocation().toOSString());
-        if (dir.exists()) {
-            String[] files = dir.list(new RpmFileFilter());
-            for (String file : files) {
-                IPath pkgPath = new Path(dir.getPath()).append(file);
-                pkgs.add(pkgPath.toOSString());
-            }
-        }
-        return pkgs;
-    }
-}
index 2bf0bd1..c63f60e 100644 (file)
@@ -512,7 +512,7 @@ public class PreferencesManager {
 
         public String getListCacheFile() {
             return ResourcesPlugin.getWorkspace().getRoot().getLocation()
-                    .append(String.format(GIT_LIST_CACHE_FILE_FORMAT, name)).toString();
+                    .append(String.format(GIT_LIST_CACHE_FILE_FORMAT, name)).toOSString();
         }
 
         public String getName() {
index b60780b..3889e7e 100644 (file)
 
 package org.tizen.nativeplatform.util;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 
 import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.common.util.ArrayUtil;
-import org.tizen.common.util.log.UserInteraction;
-import org.tizen.common.util.log.UserLogger;
+import org.tizen.nativeplatform.filefilter.RpmFileFilter;
 import org.tizen.nativeplatform.launch.PlatformLaunchMessages;
-import org.tizen.nativeplatform.pkg.commander.IPackager;
 import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker;
-import org.tizen.nativeplatform.pkg.commander.factory.PackagerFactory;
 import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory;
 import org.tizen.nativeplatform.pkg.model.IPackage;
 import org.tizen.nativeplatform.rds.CachePackageChecksum;
@@ -74,19 +77,16 @@ public class PackageUtil {
             return false;
         }
     }
-
-    public boolean pakaging(IProject project, IConfiguration config, IProgressMonitor monitor) {
-        IPackager packager = PackagerFactory.getPackager(type, project, config);
-        UserLogger.start(UserInteraction.CATE_PLATFORM_BUILD, UserInteraction.BUILD_PACKAGING);
-        if (packager == null) {
+    
+    public boolean build(IProject project, IConfiguration config, IProgressMonitor monitor) throws CoreException {
+        project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+        List<IPackage> pkgs = getPackages(project, config);
+        if (pkgs.isEmpty()) {
             return false;
         }
-        boolean result = packager.packaging(monitor);
-        UserLogger.end(UserInteraction.CATE_PLATFORM_BUILD, UserInteraction.BUILD_PACKAGING);
-        return result;
-
+        return true;
     }
-    
+
     public void cachePkgChecksum(IProject project, IConfiguration config) {
         try {
             if(!CachePackageChecksum.cachePkgChecksum(project, getPackages(project, config))) {
@@ -99,11 +99,16 @@ public class PackageUtil {
     }
 
     public List<IPackage> getPackages(IProject project, IConfiguration config) {
-        IPackager packager = PackagerFactory.getPackager(type, project, config);
-        if (packager == null) {
-            return new ArrayList<IPackage>();
+        List<String> pkgs = new ArrayList<String>();
+        IFolder folder = project.getFolder(config.getName());
+        File dir = new File(folder.getLocation().toOSString());
+        if (dir.exists()) {
+            String[] files = dir.list(new RpmFileFilter());
+            for (String file : files) {
+                IPath pkgPath = new Path(dir.getPath()).append(file);
+                pkgs.add(pkgPath.toOSString());
+            }
         }
-        List<String> pkgPaths = packager.getProjectPackages();
-        return modelMaker.makeModels(pkgPaths);
+        return modelMaker.makeModels(pkgs);
     }
 }