RT: apply meta
authorgyeongmin.ju <gyeongmin.ju@samsung.com>
Mon, 4 Sep 2017 10:03:00 +0000 (19:03 +0900)
committer허형석/개발플랫폼팀/L5/ <harry.heo@samsung.com>
Tue, 12 Sep 2017 12:12:34 +0000 (21:12 +0900)
Signed-off-by: gyeongmin.ju <gyeongmin.ju@samsung.com>
32 files changed:
resources/scripts/.buildSpec.xml [new file with mode: 0644]
resources/scripts/.debugSpec.xml [new file with mode: 0644]
resources/scripts/.flashSpec.xml [new file with mode: 0644]
resources/scripts/build.xml [deleted file]
resources/scripts/debug.xml [deleted file]
rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/model/debug/Execute.java
rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/model/flash/Flashes.java [deleted file]
rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/model/flash/ObjectFactory.java
rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/util/MetaModelUtil.java
rt-ide/tizen.rt.product.meta/test/src/org/tizen/rt/product/meta/model/LoadModelTest.java
rt-ide/tizen.rt.product.plugin/plugin.xml
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/BuildScriptData.java [deleted file]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/ui/BuildConfigureDialog.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/ui/BuildEnvSettingDialog.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/BuildCommand.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/BuildConfigureCommand.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/BuildEnvSettingCommand.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/CleanCommand.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/CommandManager.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/FlashCommand.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/BuildOption.java [moved from rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/BuildOption.java with 99% similarity]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/BuildScriptData.java [new file with mode: 0644]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/BuildSettingData.java [moved from rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/BuildSettingData.java with 95% similarity]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/DebugScriptData.java [new file with mode: 0644]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/FlashOption.java [moved from rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashOption.java with 96% similarity]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/FlashScriptData.java [new file with mode: 0644]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizard.java [deleted file]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizardDialog.java [deleted file]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/ui/FlashOptionDialog.java [moved from rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizardPage.java with 54% similarity]
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/handlers/FlashHandler.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/launch/LaunchShortcut.java
rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/meta/MetaManager.java

diff --git a/resources/scripts/.buildSpec.xml b/resources/scripts/.buildSpec.xml
new file mode 100644 (file)
index 0000000..a337160
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2017 Samsung Electronics All Rights Reserved.
+
+ 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.
+-->
+<!--
+    predefined macro values:
+    * BOARD - selected board name by UI
+    * BUILD_OPTION - selected build option by UI
+    * TOOLCHAIN_PATH - user defined toolchain path by UI
+-->
+<build name="artik053">
+    <!-- path attribute value must be relative path from project root -->
+    <!-- Don't touch command name. IDE use command with name -->
+    <commands>
+        <command name="config" command="./configure.sh" path="${PROJECT_PATH}/os/tools" shellcmd="true">
+            <param name="buildOption" value="${BOARD}/${BUILD_OPTION}"/>
+        </command>
+        <command name="build" command="make" path="${PROJECT_PATH}/os" shellcmd="true">
+            <param name="V" value="V=1"/>
+        </command>
+        <command name="buildWithToolchain" command=". ./setenv.sh ${TOOLCHAIN_PATH};make V=1" path="${PROJECT_PATH}/os" shellcmd="true" shell="/bin/bash"/>
+        <command name="clean" command="make clean" path="${PROJECT_PATH}/os" shellcmd="true">
+            <param name="clean" value="clean"/>
+        </command>
+        <command name="distclean" command="make distclean" path="${PROJECT_PATH}/os" shellcmd="true">
+            <param name="distclean" value="distclean"/>
+        </command>
+    </commands>
+    <executors> <!-- execute command sequentially on build -->
+        <executor name="linux default executor" os="linux" bit="all">
+            <commandref name="config"/>
+            <commandref name="build"/>
+        </executor>
+    </executors>
+</build>
diff --git a/resources/scripts/.debugSpec.xml b/resources/scripts/.debugSpec.xml
new file mode 100644 (file)
index 0000000..298cabd
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2017 Samsung Electronics All Rights Reserved.
+
+ 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.
+-->
+<!--
+    predefined macro values:
+    * PROJECT_PATH - current project path
+    * BOARD - selected board name
+    * SCRIPT_PATH - selected script path
+    * SCRIPT_FILE - selected script file
+-->
+<debugs>
+    <debug name="openocd debug" type="openocd">
+        <!-- path attribute value must be relative path from project root -->
+        <!-- usage : openocd -f debug_all.cfg -->
+        <options name="scriptfile" type="file" path="${PROJECT_PATH}/build/configs/${BOARD}/tools/openocd" filter="*.cfg"/>
+        <execute name="debug" os="linux" bit="32" command="${PROJECT_PATH}/build/configs/${BOARD}/tools/openocd/linux32/openocd">
+            <params>
+                <param prefix="-s" value="${SCRIPT_PATH}"/>
+                <param prefix="-f" value="${SCRIPT_FILE}"/>
+            </params>
+        </execute>
+        <execute name="debug" os="linux" bit="64" command="${PROJECT_PATH}/build/configs/${BOARD}/tools/openocd/linux64/openocd">
+            <params>
+                <param prefix="-s" value="${SCRIPT_PATH}"/>
+                <param prefix="-f" value="${SCRIPT_FILE}"/>
+            </params>
+        </execute>
+    </debug>
+</debugs>
diff --git a/resources/scripts/.flashSpec.xml b/resources/scripts/.flashSpec.xml
new file mode 100644 (file)
index 0000000..6ffdb58
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2017 Samsung Electronics All Rights Reserved.
+
+ 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.
+-->
+<flash name="artik053 flash" virtual="false">
+    <!-- path attribute value must be relative path from project root -->
+    <executors>
+        <execute name="flash" path="${PROJECT_PATH}/os" command="make download" os="linux" bit="all"></execute>
+    </executors>
+    <options>
+        <option>ALL</option>
+    </options>
+</flash>
diff --git a/resources/scripts/build.xml b/resources/scripts/build.xml
deleted file mode 100644 (file)
index 42b592d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<sbi>
-       <!--
-               predefined macro values:
-               * PROJECT_PATH - current project path
-               * BOARD - selected board name
-               * BUILD_OPTION - selected build option
-               * TOOLCHAIN_PATH - custom toolchain path
-       -->
-
-       <build>
-               <command name="config" command="./configure.sh ${BOARD}/${BUILD_OPTION}" curdir="${PROJECT_PATH}/os/tools" shellcmd="true" />
-               <command name="build" command="make V=1" curdir="${PROJECT_PATH}/os" shellcmd="true" />
-               <command name="buildWithToolchain" command=". ./setenv.sh ${TOOLCHAIN_PATH};cd ..;make V=1" curdir="${PROJECT_PATH}/os/tools" shellcmd="true" shell="/bin/bash" />
-               <command name="clean" command="make clean" curdir="${PROJECT_PATH}/os" shellcmd="true" />
-        <command name="distclean" command="make distclean" curdir="${PROJECT_PATH}/os" shellcmd="true" />
-       </build>
-</sbi>
diff --git a/resources/scripts/debug.xml b/resources/scripts/debug.xml
deleted file mode 100644 (file)
index ffe42bb..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<launch>
-       <!--
-               predefined macro values:
-               * PROJECT_PATH - current project path
-               * BOARD - selected board name
-               * SCRIPT_PATH - selected script path
-               * SCRIPT_FILE - selected script file
-       -->
-
-       <debug name="openocd" type="openocd">
-               <reqired name="scriptfile" type="file" curdir="${PROJECT_PATH}/configs/${BOARD}/scripts" filter="*.cfg" default=""/>
-
-               <execute platform="linux32" execute="${PROJECT_PATH}/build/configs/${BOARD}/tools/openocd/linux32/openocd">
-                       <param prefix="-s" value="${SCRIPT_PATH}" />
-                       <param prefix="-f" value="${SCRIPT_FILE}" />
-               </execute>
-               <execute platform="linux64" execute="${PROJECT_PATH}/build/configs/${BOARD}/tools/openocd/linux64/openocd">
-                       <param prefix="-s" value="${SCRIPT_PATH}" />
-                       <param prefix="-f" value="${SCRIPT_FILE}" />
-               </execute>
-       </debug>
-</launch>
-
index 2e094e6..22e53df 100644 (file)
@@ -64,6 +64,8 @@ public class Execute {
     protected Params params;
     @XmlAttribute(name = "name", required = true)
     protected String name;
+    @XmlAttribute(name = "path", required = false)
+    protected String path;
     @XmlAttribute(name = "command", required = true)
     protected String command;
     @XmlAttribute(name = "os", required = true)
@@ -120,6 +122,22 @@ public class Execute {
     }
 
     /**
+     * Gets the value of the path property.
+     * @return possible object is {@link String }
+     */
+    public String getPath() {
+        return path;
+    }
+
+    /**
+     * Sets the value of the path property.
+     * @param value allowed object is {@link String }
+     */
+    public void setPath(String value) {
+        this.path = value;
+    }
+
+    /**
      * Gets the value of the os property.
      * @return possible object is {@link String }
      */
diff --git a/rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/model/flash/Flashes.java b/rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/model/flash/Flashes.java
deleted file mode 100644 (file)
index fcf634f..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2017.06.12 at 05:10:24 PM KST
-//
-
-package org.tizen.rt.product.meta.model.flash;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-/**
- * <p>
- * Java class for anonymous complex type.
- * <p>
- * The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * &lt;complexType>
- *   &lt;complexContent>
- *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       &lt;sequence>
- *         &lt;element ref="{}flash" maxOccurs="unbounded"/>
- *       &lt;/sequence>
- *     &lt;/restriction>
- *   &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "", propOrder = {
-        "flash"
-})
-@XmlRootElement(name = "flashes")
-public class Flashes {
-
-    @XmlElement(required = true)
-    protected List<Flash> flash;
-
-    /**
-     * Gets the value of the flash property.
-     * <p>
-     * This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is
-     * not a <CODE>set</CODE> method for the flash property.
-     * <p>
-     * For example, to add a new item, do as follows:
-     *
-     * <pre>
-     * getFlash().add(newItem);
-     * </pre>
-     * <p>
-     * Objects of the following type(s) are allowed in the list {@link Flash }
-     */
-    public List<Flash> getFlash() {
-        if (flash == null) {
-            flash = new ArrayList<Flash>();
-        }
-        return this.flash;
-    }
-
-}
index cf9f438..ced5190 100644 (file)
@@ -51,13 +51,6 @@ public class ObjectFactory {
     }
 
     /**
-     * Create an instance of {@link Flashes }
-     */
-    public Flashes createFlashes() {
-        return new Flashes();
-    }
-
-    /**
      * Create an instance of {@link Flash }
      */
     public Flash createFlash() {
index d5f5995..7e100e0 100755 (executable)
@@ -54,7 +54,7 @@ import org.tizen.rt.product.meta.IModelConstants;
 import org.tizen.rt.product.meta.RtMetaPlugin;
 import org.tizen.rt.product.meta.model.build.Build;
 import org.tizen.rt.product.meta.model.debug.Debugs;
-import org.tizen.rt.product.meta.model.flash.Flashes;
+import org.tizen.rt.product.meta.model.flash.Flash;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
 
@@ -90,9 +90,9 @@ public class MetaModelUtil {
      * @throws IOException
      * @throws JAXBException
      */
-    public static Flashes copyDefaultFlashModelAndLoad(String destination) throws IOException, JAXBException {
+    public static Flash copyDefaultFlashModelAndLoad(String destination) throws IOException, JAXBException {
         InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_FLASH_META_XML);
-        return copyDefaultModelAndLoad(Flashes.class, source, destination);
+        return copyDefaultModelAndLoad(Flash.class, source, destination);
     }
 
     /**
@@ -182,8 +182,8 @@ public class MetaModelUtil {
      * @return {@link Flashes} model instance
      * @throws JAXBException
      */
-    public static Flashes loadFlashModel(File flashXmlFile) throws JAXBException {
-        return loadModel(Flashes.class, flashXmlFile);
+    public static Flash loadFlashModel(File flashXmlFile) throws JAXBException {
+        return loadModel(Flash.class, flashXmlFile);
     }
 
     /**
@@ -191,8 +191,8 @@ public class MetaModelUtil {
      * @return {@link Flashes} model instance
      * @throws JAXBException
      */
-    public static Flashes loadFlashModel(InputStream flashXmlFile) throws JAXBException {
-        return loadModel(Flashes.class, flashXmlFile);
+    public static Flash loadFlashModel(InputStream flashXmlFile) throws JAXBException {
+        return loadModel(Flash.class, flashXmlFile);
     }
 
     /**
@@ -200,8 +200,8 @@ public class MetaModelUtil {
      * @return xml strings of marshaled flash model
      * @throws JAXBException
      */
-    public static String showFlashModel(Flashes flashModel) throws JAXBException {
-        return showModel(Flashes.class, flashModel);
+    public static String showFlashModel(Flash flashModel) throws JAXBException {
+        return showModel(Flash.class, flashModel);
     }
 
     /**
index cf41841..25db5f7 100755 (executable)
@@ -39,7 +39,7 @@ import org.tizen.rt.product.meta.IModelConstants;
 import org.tizen.rt.product.meta.RtMetaPlugin;
 import org.tizen.rt.product.meta.model.build.Build;
 import org.tizen.rt.product.meta.model.debug.Debugs;
-import org.tizen.rt.product.meta.model.flash.Flashes;
+import org.tizen.rt.product.meta.model.flash.Flash;
 import org.tizen.rt.product.meta.util.MetaModelUtil;
 import org.xml.sax.SAXException;
 
@@ -63,7 +63,7 @@ public class LoadModelTest {
     @Test
     public void flashModelTest() throws JAXBException {
         InputStream is = RtMetaPlugin.class.getResourceAsStream("resources/flashSpec.xml");
-        Flashes model = MetaModelUtil.loadFlashModel(is);
+        Flash model = MetaModelUtil.loadFlashModel(is);
         Assert.assertNotNull(model);
 
         String result = MetaModelUtil.showFlashModel(model);
index 017d4f7..dd953e0 100644 (file)
         </run>
      </builder>
   </extension>
-  <!-- temporary disabled debug in 1.2 release
   <extension
         point="org.eclipse.debug.ui.launchShortcuts">
      <shortcut
         </contextualLaunch>
      </shortcut>
   </extension>
-  -->
 </plugin>
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/BuildScriptData.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/build/BuildScriptData.java
deleted file mode 100644 (file)
index 144332b..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Common
- *
- * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Daeryong Park <bdragon.park@samsung.com>
- * Hyeongseok Heo <harry.heo@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.rt.ide.build;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.tizen.rt.ide.console.ConsoleManager;
-import org.tizen.rt.ide.util.MacroUtil;
-import org.tizen.rt.ide.util.ProcUtil;
-import org.tizen.rt.ide.util.XMLUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @since 2017. 5. 18.
- * @author Daeryong Park {@literal <bdragon.park@samsung.com>}
- */
-public class BuildScriptData {
-
-       private static class BuildScript {
-           public String cmdStr;
-           public String curDir;
-           public boolean isShellCmd;
-           public String shell;
-           
-           /**
-            * @param cmdStr command string
-            * @param curDir current directory
-            * @param isShellCmd is shell command
-            * @param shell shell name to use like "/bin/bash"
-            */
-           public BuildScript(String cmdStr, String curDir, boolean isShellCmd, String shell) {
-               this.cmdStr = cmdStr;
-               this.curDir = curDir;
-               this.isShellCmd = isShellCmd;
-               this.shell = shell;
-           }
-
-           /**
-            * @return the cmdStr
-            */
-           public String getCmdStr() {
-               return cmdStr;
-           }
-
-           /**
-            * @return the curDir
-            */
-           public String getCurDir() {
-               return curDir;
-           }
-
-           /**
-            * @return the isShellCmd
-            */
-           public boolean isShellCmd() {
-               return isShellCmd;
-           }
-
-           /**
-            * @return the shell
-            */
-           public String getShell() {
-               return shell;
-           }
-       }
-    
-    private Map<String, String> macros = new HashMap<String, String>();
-    private Map<String, BuildScript> scripts;
-    private ConsoleManager consoleManager;
-    
-    public BuildScriptData(ConsoleManager consoleManager) {
-       this.consoleManager = consoleManager;
-    }
-    
-    private Map<String, BuildScript> getBuildScripts(File buildScriptFile) {
-        Document doc = XMLUtil.readXML(buildScriptFile);
-
-        NodeList commands = XMLUtil.getDOMNodes(doc.getDocumentElement(), "/sbi/build/command");
-        if (commands == null || commands.getLength() <= 0) {
-            return null;
-        }
-
-        Map<String, BuildScript> scripts = new HashMap<String, BuildScript>();
-
-        int len = commands.getLength();
-        for (int i = 0; i < len; i++) {
-            Node node = commands.item(i);
-            if (node instanceof Element) {
-                Element elm = (Element) node;
-
-                String name = elm.getAttribute("name");
-                String cmd = elm.getAttribute("command");
-                String curdir = elm.getAttribute("curdir");
-                String shellcmd = elm.getAttribute("shellcmd");
-                boolean isShellCmd = Boolean.valueOf(shellcmd);
-                String shell = elm.getAttribute("shell");
-
-                scripts.put(name, new BuildScript(cmd, curdir, isShellCmd, shell));
-            }
-        }
-
-        return scripts;
-    }
-
-    public String getBuildScriptFileName() {
-       return "build.xml";
-    }
-
-    public void addMacro(String name, String value) {
-        macros.put(name, value);
-    }
-
-    public void consolePrintln(String str) {
-       if(consoleManager != null) {
-               consoleManager.println(str);
-       }
-    }
-    
-    public int load(File buildScriptFile) {
-       consolePrintln("Build project using " + buildScriptFile);
-        scripts = getBuildScripts(buildScriptFile);
-        
-        return (scripts != null)? 0 : 1;
-    }
-    
-    public int load(String buildScriptFilename) {
-       return load(new File(buildScriptFilename));
-    }
-    
-    public int doCommand(String buildCmdName, Map<String, String> env) {
-        ProcessBuilder pb = ProcUtil.genProcessBuilder(null);
-
-        BuildScript script = scripts.get(buildCmdName);
-        if (script == null) {
-               consolePrintln("Cannot found build command : " + buildCmdName);
-            return 1;
-        }
-        
-        if(env != null) {
-               pb.environment().putAll(env);
-        }
-
-        String cmdStr = MacroUtil.processMacro(script.cmdStr, macros);
-        if(cmdStr == null || cmdStr.isEmpty()) {
-            return 1;            
-        }
-        String curDir = MacroUtil.processMacro(script.curDir, macros);
-        
-        return ProcUtil.executeProcess(pb, new String[] { cmdStr }, script.isShellCmd, script.shell,
-                curDir, consoleManager, null);
-       
-    }
-    
-    public int doCommand(String buildCmdName) {
-       return doCommand(buildCmdName, null);
-    }
-    
-}
index f684fd6..a4ad6f2 100644 (file)
@@ -21,7 +21,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.tizen.rt.ide.Messages;
-import org.tizen.rt.ide.build.BuildOption;
+import org.tizen.rt.ide.commands.model.BuildOption;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.widgets.Label;
index 44351dd..98ef558 100644 (file)
@@ -19,7 +19,7 @@ import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swt.widgets.Text;
 import org.tizen.rt.ide.Messages;
-import org.tizen.rt.ide.build.BuildSettingData;
+import org.tizen.rt.ide.commands.model.BuildSettingData;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
index 4f046c2..d1da939 100644 (file)
@@ -41,10 +41,10 @@ import org.eclipse.swt.widgets.Display;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.rt.ide.Messages;
-import org.tizen.rt.ide.build.BuildOption;
-import org.tizen.rt.ide.build.BuildScriptData;
-import org.tizen.rt.ide.build.BuildSettingData;
 import org.tizen.rt.ide.build.builder.RtBuilder;
+import org.tizen.rt.ide.commands.model.BuildOption;
+import org.tizen.rt.ide.commands.model.BuildScriptData;
+import org.tizen.rt.ide.commands.model.BuildSettingData;
 import org.tizen.rt.ide.console.ConsoleManager;
 import org.tizen.rt.ide.util.ResourceUtil;
 import org.tizen.rt.ide.util.SDKUtil;
@@ -64,6 +64,14 @@ public class BuildCommand {
 
     private static final String PROP_COMMENT_DEBUG_INFO = "TinyARA Debug information"; //$NON-NLS-1$
 
+    protected String getScriptFileName() {
+        return ".buildSpec.xml"; //$NON-NLS-1$
+    }
+    
+    protected String getSettingFileName() {
+        return ".buildSetting.xml"; //$NON-NLS-1$
+    }
+    
     public int execute(IProject project, ConsoleManager consoleManager, IProgressMonitor monitor) {
         String activeProjectPath = project.getLocation().toString();
 
@@ -71,40 +79,46 @@ public class BuildCommand {
         String homePath = activeProjectPath;
         String outputPath = activeProjectPath + File.separator + PATH_LINUX_BUILD_OUTPUT;
 
-        File buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
-                + File.separator + "build.xml"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        if (!buildScriptFile.exists()) {
-            buildScriptFile = new File(activeProjectPath, "build.xml");
-            if (!buildScriptFile.exists()) {
-                if (consoleManager != null) {
-                    consoleManager.println("Can not found xml file of build spec."); //$NON-NLS-1$
-                }
-                return 1;
-            }
-        }
-
-        BuildScriptData buildScript = new BuildScriptData(consoleManager);
-        buildScript.load(buildScriptFile);
-
-        buildScript.addMacro("PROJECT_PATH", activeProjectPath); //$NON-NLS-1$
-
-        String osDir = project.getLocation().toString() + File.separator + "os";
+        String osDir = project.getLocation().toString() + File.separator + "os"; //$NON-NLS-1$
 
         BuildSettingData setting = new BuildSettingData();
 
         String toolchainPath = null;
         BuildOption buildOption = null;
-        if (setting.load(new File(osDir, ".buildSetting"))) {
+        if (setting.load(new File(osDir, getSettingFileName()))) {
             toolchainPath = setting.getToolchainPath();
-            if (toolchainPath != null) {
-                buildScript.addMacro("TOOLCHAIN", setting.getToolchainPath());
-            }
-
             buildOption = setting.getBuildOption();
-            if (buildOption != null) {
-                buildScript.addMacro("BOARD", buildOption.getBoard());
-                buildScript.addMacro("BUILD_OPTION", buildOption.getBuildOption());
+        }
+
+        File buildScriptFile = null;
+        if (buildOption != null) {
+            buildScriptFile = new File(activeProjectPath, "build" + File.separator + "configs" + File.separator + buildOption.getBoard() + File.separator + getScriptFileName()); // $NON-NLS-1$  // $NON-NLS-2$
+        }        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(activeProjectPath, getScriptFileName()); // $NON-NLS-1$
+        }        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
+                    + File.separator + getScriptFileName()); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        }
+        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            if (consoleManager != null) {
+                consoleManager.println("Can not found xml file of build spec.");
             }
+            return 1;
+        }
+
+        BuildScriptData buildScript = new BuildScriptData(consoleManager);
+        buildScript.load(buildScriptFile);
+
+        buildScript.addMacro("PROJECT_PATH", activeProjectPath); //$NON-NLS-1$
+        if (buildOption != null) {
+            buildScript.addMacro("BOARD", buildOption.getBoard());
+            buildScript.addMacro("BUILD_OPTION", buildOption.getBuildOption());
+        }
+        if (toolchainPath != null) {
+            buildScript.addMacro("TOOLCHAIN", setting.getToolchainPath());
         }
 
         String buildCmdName;
@@ -125,7 +139,7 @@ public class BuildCommand {
             buildInfo.setProperty(PROP_NAME_BOARD, setting.getBuildOption().getBoard());
             buildInfo.setProperty(PROP_NAME_OPTION, setting.getBuildOption().getBuildOption());
             try {
-                buildInfo.store(new FileWriter(new File(outputPath, FILE_NAME_BUILD_INFO)), PROP_COMMENT_DEBUG_INFO); // $NON-NLS-1$
+                buildInfo.store(new FileWriter(new File(outputPath, FILE_NAME_BUILD_INFO)), PROP_COMMENT_DEBUG_INFO);
             } catch (IOException e) {
                 logger.error(e.getMessage());
             }
@@ -135,9 +149,9 @@ public class BuildCommand {
     }
 
     public Object execute(IProject project, ConsoleManager consoleManager) throws ExecutionException {
-        String osDir = project.getLocation().toString() + File.separator + "os";
+        String osDir = project.getLocation().toString() + File.separator + "os"; //$NON-NLS-1$
 
-        if (!new File(osDir, ".config").exists()) {
+        if (!new File(osDir, ".config").exists()) { //$NON-NLS-1$
             MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosBuildDialogPage_KconfigErrorMessage); //$NON-NLS-1$
             return null;
         }
index 2fb0bdd..79cbf63 100644 (file)
@@ -33,10 +33,10 @@ import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.widgets.Shell;
-import org.tizen.rt.ide.build.BuildOption;
-import org.tizen.rt.ide.build.BuildScriptData;
-import org.tizen.rt.ide.build.BuildSettingData;
 import org.tizen.rt.ide.build.ui.BuildConfigureDialog;
+import org.tizen.rt.ide.commands.model.BuildOption;
+import org.tizen.rt.ide.commands.model.BuildScriptData;
+import org.tizen.rt.ide.commands.model.BuildSettingData;
 import org.tizen.rt.ide.console.ConsoleManager;
 import org.tizen.rt.ide.util.ResourceUtil;
 import org.tizen.rt.ide.util.SDKUtil;
@@ -46,6 +46,14 @@ import org.tizen.rt.ide.util.ViewUtil;
  * @author Gyeongmin Ju{@literal <gyeongmin.ju>} (S-Core)
  */
 public class BuildConfigureCommand {
+    protected String getScriptFileName() {
+        return ".buildSpec.xml"; //$NON-NLS-1$
+    }
+    
+    protected String getSettingFileName() {
+        return ".buildSetting.xml"; //$NON-NLS-1$
+    }
+    
     protected int configure(IProject project, BuildOption buildOption, ConsoleManager consoleManager,
             IProgressMonitor monitor) {
         if (buildOption == null) {
@@ -60,40 +68,49 @@ public class BuildConfigureCommand {
             consoleManager.println("Build Option : " + buildOption.getBuildOption()); //$NON-NLS-1$
         }
 
-        String activeProjectPath = project.getLocation().toString();
-
         String sdkPath = SDKUtil.getSdkPath();
-        buildOption.getBoard();
-        File buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
-                + File.separator + "build.xml"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        if (!buildScriptFile.exists()) {
-            buildScriptFile = new File(activeProjectPath, "build.xml");
-            if (!buildScriptFile.exists()) {
-                if (consoleManager != null) {
-                    consoleManager.println("Can not found xml file of build spec."); //$NON-NLS-1$
-                }
-                return 1;
+        String activeProjectPath = project.getLocation().toString();
+        
+        File buildScriptFile = null;
+        if (buildOption != null) {
+            buildScriptFile = new File(activeProjectPath, "build" + File.separator + "configs" + File.separator + buildOption.getBoard() + File.separator + getScriptFileName()); // $NON-NLS-1$  // $NON-NLS-2$
+        }        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(activeProjectPath, getScriptFileName()); // $NON-NLS-1$
+        }        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
+                    + File.separator + getScriptFileName()); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        }
+        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            if (consoleManager != null) {
+                consoleManager.println("Can not found xml file of build spec.");
             }
+            return 1;
         }
 
         BuildScriptData buildScript = new BuildScriptData(consoleManager);
         buildScript.load(buildScriptFile);
 
         buildScript.addMacro("PROJECT_PATH", activeProjectPath); //$NON-NLS-1$
-        buildScript.addMacro("BOARD", buildOption.getBoard());
-        buildScript.addMacro("BUILD_OPTION", buildOption.getBuildOption());
+        if (buildOption != null) {
+            buildScript.addMacro("BOARD", buildOption.getBoard()); //$NON-NLS-1$
+            buildScript.addMacro("BUILD_OPTION", buildOption.getBuildOption()); //$NON-NLS-1$
+        }
 
-        String buildCmdName = "config";
+        BuildSettingData buildSetting = new BuildSettingData();
+        buildSetting.load(new File(activeProjectPath, "os" + File.separator + getSettingFileName())); //$NON-NLS-1$
+        
+        String buildCmdName = "config"; //$NON-NLS-1$
         int result = buildScript.doCommand(buildCmdName);
 
         if (result != 0) {
             return result;
         }
 
-        BuildSettingData buildSetting = new BuildSettingData();
-        buildSetting.load(new File(activeProjectPath, "os/.buildSetting"));
         buildSetting.setBuildOption(buildOption);
-        buildSetting.write(new File(activeProjectPath, "os/.buildSetting"));
+        buildSetting.write(new File(activeProjectPath, "os" + File.separator + getSettingFileName())); //$NON-NLS-1$
 
         return result;
     }
index 9aa9a7c..af94371 100644 (file)
@@ -32,8 +32,8 @@ import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.swt.widgets.Shell;
-import org.tizen.rt.ide.build.BuildSettingData;
 import org.tizen.rt.ide.build.ui.BuildEnvSettingDialog;
+import org.tizen.rt.ide.commands.model.BuildSettingData;
 import org.tizen.rt.ide.util.ResourceUtil;
 import org.tizen.rt.ide.util.ViewUtil;
 
index c6575f2..1912f83 100644 (file)
@@ -28,7 +28,9 @@ package org.tizen.rt.ide.commands;
 import java.io.File;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.tizen.rt.ide.build.BuildScriptData;
+import org.tizen.rt.ide.commands.model.BuildOption;
+import org.tizen.rt.ide.commands.model.BuildScriptData;
+import org.tizen.rt.ide.commands.model.BuildSettingData;
 import org.tizen.rt.ide.console.ConsoleManager;
 import org.tizen.rt.ide.util.SDKUtil;
 
@@ -41,23 +43,46 @@ public class CleanCommand {
     private static final String COMMAND_NAME_CLEAN = "clean"; //$NON-NLS-1$
     private static final String COMMAND_NAME_DISTCLEAN = "distclean"; //$NON-NLS-1$
 
+    protected String getScriptFileName() {
+        return ".buildSpec.xml"; //$NON-NLS-1$
+    }
+    
     protected int execute(IProject project, ConsoleManager consoleManager, IProgressMonitor monitor, boolean useDistClean) {
         String activeProjectPath = project.getLocation().toString();
 
         String sdkPath = SDKUtil.getSdkPath();
-        File buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
-                + File.separator + "build.xml"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-        if (!buildScriptFile.exists()) {
-            buildScriptFile = new File(activeProjectPath, "build.xml");
-            if (!buildScriptFile.exists()) {
+        
+        String osDir = project.getLocation().toString() + File.separator + "os";
+        
+        BuildSettingData setting = new BuildSettingData();
+
+        BuildOption buildOption = null;
+        if (setting.load(new File(osDir, ".buildSetting"))) {
+            buildOption = setting.getBuildOption();
+        }
+        
+        File buildScriptFile = null;
+        if (buildOption != null) {
+            buildScriptFile = new File(activeProjectPath, "build" + File.separator + "configs" + File.separator + buildOption.getBoard() + File.separator + getScriptFileName()); // $NON-NLS-1$  // $NON-NLS-2$
+        }        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(activeProjectPath, getScriptFileName()); // $NON-NLS-1$
+        }        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
+                    + File.separator + getScriptFileName()); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        }
+        
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            if (consoleManager != null) {
                 consoleManager.println("Can not found xml file of build spec."); //$NON-NLS-1$
-                return 1;
             }
+            return 1;
         }
 
         BuildScriptData buildScript = new BuildScriptData(consoleManager);
         buildScript.load(buildScriptFile);
-        
+
         buildScript.addMacro("PROJECT_PATH", activeProjectPath); //$NON-NLS-1$
         
         String buildCmdName = useDistClean ? COMMAND_NAME_DISTCLEAN : COMMAND_NAME_CLEAN;
index 40feeaa..92faa8c 100644 (file)
@@ -37,8 +37,8 @@ import org.eclipse.swt.SWT;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.rt.ide.ResourceManager;
+import org.tizen.rt.ide.commands.model.FlashOption;
 import org.tizen.rt.ide.console.ConsoleManager;
-import org.tizen.rt.ide.flash.FlashOption;
 
 /**
  * CommandManager
@@ -67,10 +67,10 @@ public class CommandManager {
     }
 
     // TODO
-    public static List<FlashOption> getFlashOptions(String board) {
+    public static List<FlashOption> getFlashOptions(String projectPath, String board) {
         flashOptionListClear();
 
-        List<FlashOption> result = FlashCommand.executeFindFlashOption(board);
+        List<FlashOption> result = FlashCommand.executeFindFlashOption(projectPath, board);
         return result;
     }
 
@@ -104,16 +104,16 @@ public class CommandManager {
      * @param monitor progress monitor
      * @return success or not
      */
-    public static boolean runFlash(IProject project, FlashOption option, ConsoleManager consoleManager, IProgressMonitor monitor) {
-        if (consoleManager == null) {
-            logger.error("ConsoleManager is null"); //$NON-NLS-1$
-            return false;
-        }
-        FlashCommand flashCommand = new FlashCommand();
-        int result = flashCommand.execute(project, option, consoleManager, monitor);
-
-        return processResult(result, consoleManager);
-    }
+//    public static boolean runFlash(IProject project, FlashOption option, ConsoleManager consoleManager, IProgressMonitor monitor) {
+//        if (consoleManager == null) {
+//            logger.error("ConsoleManager is null"); //$NON-NLS-1$
+//            return false;
+//        }
+//        FlashCommand flashCommand = new FlashCommand();
+//        int result = flashCommand.execute(project, option, consoleManager, monitor);
+//
+//        return processResult(result, consoleManager);
+//    }
 
     /**
      * @param project selected project
index a6b4aab..f85172d 100644 (file)
@@ -31,29 +31,84 @@ package org.tizen.rt.ide.commands;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
-
+import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.tizen.rt.ide.Messages;
+import org.tizen.rt.ide.commands.model.FlashOption;
+import org.tizen.rt.ide.commands.model.FlashScriptData;
 import org.tizen.rt.ide.console.ConsoleManager;
-import org.tizen.rt.ide.flash.FlashOption;
-import org.tizen.rt.ide.util.ProcUtil;
+import org.tizen.rt.ide.exception.BuildInfoHandlingException;
+import org.tizen.rt.ide.flash.ui.FlashOptionDialog;
+import org.tizen.rt.ide.meta.BuildInfo;
+import org.tizen.rt.ide.meta.BuildInfoManager;
+import org.tizen.rt.ide.util.SDKUtil;
+import org.tizen.rt.ide.util.ViewUtil;
 
 /**
- * LinuxCommand
- * @author jm.jaemin.kim{@literal <jm.jaemin.kim>} (S-Core)
+ * FlashCommand
+ * @author gyeongmin.ju{@literal <gyeongmin.ju>} (S-Core)
  */
 public class FlashCommand {
 
     /**
      * important PATH
      */
-    private static final String LINUX_EXECUTE_FLASH[] = new String[] { "make", "download", "" }; //$NON-NLS-1$
     private static final String PATH_BUILD_CONFIGS = "os"; //$NON-NLS-1$
+    private static final String PATH_LINUX_BUILD_OUTPUT = "build/output"; //$NON-NLS-1$
+    private static final String FILE_NAME_FLASH_SCRIPT = ".flashSpec.xml"; //$NON-NLS-1$
+    private static final String FILE_NAME_BUILD_INFO = "build.info"; //$NON-NLS-1$
+
+    protected static String getScriptFileName() {
+        return FILE_NAME_FLASH_SCRIPT; //$NON-NLS-1$
+    }
+    
+    private static FlashScriptData getScript(String activeProjectPath, String board, ConsoleManager consoleManager) {
+        String sdkPath = SDKUtil.getSdkPath();
+
+        File buildScriptFile = null;
+        if (board != null) {
+            buildScriptFile = new File(activeProjectPath, "build" + File.separator + "configs" + File.separator + board + File.separator + getScriptFileName()); // $NON-NLS-1$ // $NON-NLS-2$
+        }
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(activeProjectPath, getScriptFileName());
+        }
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
+                    + File.separator + getScriptFileName()); // $NON-NLS-1$ //$NON-NLS-2$
+        }
 
-    private List<String> resultFlashExecute = new ArrayList<String>();
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            return null;
+        }
 
-    protected static List<FlashOption> executeFindFlashOption(String board) {
-        String[] cfgs = new String[] { "ALL", "RESOURCE", "FOTA_ALL", "TINYARA_OTA0", "TINYARA_OTA1" };
+        FlashScriptData buildScript = new FlashScriptData(consoleManager);
+        buildScript.load(buildScriptFile);
+
+        buildScript.addMacro("PROJECT_PATH", activeProjectPath); //$NON-NLS-1$
+        if (board != null) {
+            buildScript.addMacro("BOARD", board); //$NON-NLS-1$
+        }
+
+        return buildScript;
+    }
+
+    public static List<FlashOption> executeFindFlashOption(String projectPath, String board) {
+        FlashScriptData script = getScript(projectPath, board, null);
+
+        List<String> cfgs = script.getOptions();
+        if (cfgs == null) {
+            return null;
+        }
 
         List<FlashOption> resultFlashOptionList = new ArrayList<FlashOption>();
         for (String cfg : cfgs) {
@@ -63,24 +118,77 @@ public class FlashCommand {
         return resultFlashOptionList;
     }
 
-    protected int execute(IProject project, FlashOption flashOption, ConsoleManager consoleManager,
-            IProgressMonitor monitor) {
+    public static int execute(IProject project, String board, FlashOption flashOption, ConsoleManager consoleManager, IProgressMonitor monitor) {
         String activeProjectPath = project.getLocation().toString();
 
-        String curDir = activeProjectPath + File.separator + PATH_BUILD_CONFIGS;
-        resultFlashExecute.clear();
+        FlashScriptData flashScript = getScript(activeProjectPath, board, consoleManager);
+        if (flashScript == null) {
+            return 1;
+        }
 
-        LINUX_EXECUTE_FLASH[2] = flashOption.getFlashOption();
+        String flashCmdName = "flash"; //$NON-NLS-1$
+        int result = flashScript.doCommand(flashCmdName, flashOption.getFlashOption(), null);
 
-        int result = ProcUtil.executeProcess(null, LINUX_EXECUTE_FLASH, false,
-                curDir, consoleManager, resultFlashExecute);
-        monitor.worked(1);
+        if (result != 0) {
+            return result;
+        }
 
         return result;
     }
 
-    protected String getScriptFileName() {
-        return "flashSpec.xml";
+    public Object execute(IProject project, ConsoleManager consoleManager) throws ExecutionException {
+        String osDir = project.getLocation().toString() + File.separator + "os"; //$NON-NLS-1$
+
+        if (!new File(osDir, ".config").exists()) { //$NON-NLS-1$
+            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosBuildDialogPage_KconfigErrorMessage);
+            return null;
+        }
+
+        String outDir = project.getLocation().toString() + File.separator + "build" + File.separator + "output"; //$NON-NLS-1$ //$NON-NLS-2$
+
+        if (!new File(outDir, FILE_NAME_BUILD_INFO).exists()) {
+            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.FlashHandler_NotFoundBuildInfo);
+            return null;
+        }
+
+        BuildInfo buildInfo = null;
+        try {
+            buildInfo = BuildInfoManager.loadBuildInfo(project);
+        } catch (BuildInfoHandlingException e) {
+            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.FlashHandler_BuildInfoIsNotNormal);
+            return null;
+        }
+
+        Shell shell = ViewUtil.getWorkbenchWindow().getShell();
+        FlashOptionDialog dialog = new FlashOptionDialog(shell, project, buildInfo.getBoard());
+        dialog.create();
+        int r = dialog.open();
+
+        if (r == Dialog.OK) {
+            String option = dialog.getOption();
+            scheduleFlash(project, buildInfo.getBoard(), new FlashOption(option, option), consoleManager);
+        }
+
+        return null;
+    }
+
+    public static void scheduleFlash(final IProject project, final String board, final FlashOption flashOption, final ConsoleManager consoleManager) {
+        WorkspaceJob wsJob = new WorkspaceJob("Flashing " + project.getName()) {
+            @Override
+            public boolean belongsTo(Object family) {
+                return ResourcesPlugin.FAMILY_MANUAL_BUILD.equals(family);
+            }
+
+            @Override
+            public IStatus runInWorkspace(IProgressMonitor monitor)
+                    throws CoreException {
+                return (FlashCommand.execute(project, board, flashOption, consoleManager, monitor) == 0) ? Status.OK_STATUS : Status.CANCEL_STATUS;
+            }
+        };
+
+        wsJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
+        wsJob.setUser(true);
+        wsJob.schedule();
     }
 
 }
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/BuildScriptData.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/BuildScriptData.java
new file mode 100644 (file)
index 0000000..2ce3a7f
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Gyeongmin Ju <gyoengmin.ju@samsung.com>
+ * Hyeongseok Heo <harry.heo@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.rt.ide.commands.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBException;
+
+import org.tizen.rt.ide.console.ConsoleManager;
+import org.tizen.rt.ide.util.MacroUtil;
+import org.tizen.rt.ide.util.ProcUtil;
+import org.tizen.rt.product.meta.model.build.Build;
+import org.tizen.rt.product.meta.model.build.Command;
+import org.tizen.rt.product.meta.model.build.Commands;
+import org.tizen.rt.product.meta.model.build.Param;
+import org.tizen.rt.product.meta.util.MetaModelUtil;
+
+/**
+ * @since 2017. 8. 25.
+ * @author Gyeongmin Ju {@literal <gyeongmin.ju@samsung.com>}
+ */
+public class BuildScriptData {
+
+    private static class BuildScript {
+        public String cmdStr;
+        public String curDir;
+        public boolean isShellCmd;
+        public String shell;
+        public String[] params;
+
+        /**
+         * @param cmdStr command string
+         * @param curDir current directory
+         * @param isShellCmd is shell command
+         * @param shell shell name to use like "/bin/bash"
+         * @param params parameters
+         */
+        public BuildScript(String cmdStr, String curDir, boolean isShellCmd, String shell, String[] params) {
+            this.cmdStr = cmdStr;
+            this.curDir = curDir;
+            this.isShellCmd = isShellCmd;
+            this.shell = shell;
+            this.params = params;
+        }
+
+        /**
+         * @param cmdStr command string
+         * @param curDir current directory
+         * @param isShellCmd is shell command
+         * @param shell shell name to use like "/bin/bash"
+         */
+        public BuildScript(String cmdStr, String curDir, boolean isShellCmd, String shell) {
+            this(cmdStr, curDir, isShellCmd, shell, null);
+        }
+
+        /**
+         * @return the cmdStr
+         */
+        public String getCmdStr() {
+            return cmdStr;
+        }
+
+        /**
+         * @return the curDir
+         */
+        public String getCurDir() {
+            return curDir;
+        }
+
+        /**
+         * @return the isShellCmd
+         */
+        public boolean isShellCmd() {
+            return isShellCmd;
+        }
+
+        /**
+         * @return the shell
+         */
+        public String getShell() {
+            return shell;
+        }
+    }
+
+    private Map<String, String> macros = new HashMap<String, String>();
+    private Map<String, BuildScript> scripts;
+    private ConsoleManager consoleManager;
+
+    public BuildScriptData(ConsoleManager consoleManager) {
+        this.consoleManager = consoleManager;
+    }
+
+    private Map<String, BuildScript> getBuildScripts(File buildScriptFile) {
+        Build buildModel = null;
+        try {
+            buildModel = MetaModelUtil.loadBuildModel(buildScriptFile);
+        } catch (JAXBException e) {
+            return null;
+        }
+
+        Map<String, BuildScript> scripts = new HashMap<String, BuildScript>();
+        
+        Commands commands = buildModel.getCommands();
+        List<Command> cmds = commands.getCommand();
+        if(cmds != null) {
+            for(Command cmd : cmds) {
+                String[] params = null;
+                List<Object> paramNodes = cmd.getContent();
+                if(paramNodes != null && !paramNodes.isEmpty()) {
+                    List<String> paramList = new ArrayList<String> ();
+                    
+                    for (Object paramObj : paramNodes) {
+                        if(paramObj instanceof Param) {
+                            Param param = (Param)paramObj;
+                            String value = param.getValue();
+                            paramList.add(value);
+                        }
+                    }
+                    
+                    if(!paramList.isEmpty()) {
+                        params = paramList.toArray(new String[paramList.size()]);
+                    }
+                }
+                
+                boolean isShellCmd = Boolean.valueOf(cmd.getShellcmd());
+                scripts.put(cmd.getName(), new BuildScript(cmd.getCommand(), cmd.getPath(), isShellCmd, cmd.getShell(), params));
+            }
+        }
+
+        return scripts;
+    }
+
+    public String getBuildScriptFileName() {
+        return "build.xml";
+    }
+
+    public void addMacro(String name, String value) {
+        macros.put(name, value);
+    }
+
+    public void consolePrintln(String str) {
+        if (consoleManager != null) {
+            consoleManager.println(str);
+        }
+    }
+
+    public int load(File buildScriptFile) {
+        consolePrintln("Build project using " + buildScriptFile);
+        scripts = getBuildScripts(buildScriptFile);
+
+        return (scripts != null) ? 0 : 1;
+    }
+
+    public int load(String buildScriptFilename) {
+        return load(new File(buildScriptFilename));
+    }
+
+    public int doCommand(String buildCmdName, Map<String, String> env) {
+        ProcessBuilder pb = ProcUtil.genProcessBuilder(null);
+
+        BuildScript script = scripts.get(buildCmdName);
+        if (script == null) {
+            consolePrintln("Cannot found build command : " + buildCmdName);
+            return 1;
+        }
+
+        if (env != null) {
+            pb.environment().putAll(env);
+        }
+
+        String cmdStr = MacroUtil.processMacro(script.cmdStr, macros);
+        if (cmdStr == null || cmdStr.isEmpty()) {
+            return 1;
+        }
+        String curDir = MacroUtil.processMacro(script.curDir, macros);
+
+        String[] cmds = null;
+
+        int paramLen = 0;
+        if (script.params != null) {
+            paramLen = script.params.length;
+        }
+
+        if (paramLen > 0) {
+            cmds = new String[paramLen + 1];
+            for (int i = 0; i < paramLen; i++) {
+                cmds[1 + i] = MacroUtil.processMacro(script.params[i], macros);
+            }
+        } else {
+            cmds = new String[1];
+        }
+        cmds[0] = cmdStr;
+
+        return ProcUtil.executeProcess(pb, cmds, script.isShellCmd, script.shell,
+                curDir, consoleManager, null);
+
+    }
+
+    public int doCommand(String buildCmdName) {
+        return doCommand(buildCmdName, null);
+    }
+
+}
@@ -26,7 +26,7 @@
 *
 */
 
-package org.tizen.rt.ide.build;
+package org.tizen.rt.ide.commands.model;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -37,11 +37,12 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+
+import org.tizen.rt.ide.commands.model.BuildOption;
+
 import java.util.Properties;
 import java.util.Set;
 
-import org.tizen.rt.ide.build.BuildOption;
-
 /**
  * @author Gyeongmin Ju{@literal <gyeongmin.ju>} (S-Core)
  */
@@ -94,11 +95,11 @@ public class BuildSettingData {
         if (keys != null) {
             for (Object key : keys) {
                 if (key instanceof String && ((String) key).startsWith("env.")) {
-                    removeKeys.add((String)key);
+                    removeKeys.add((String) key);
                 }
             }
         }
-        for(String key : removeKeys) {
+        for (String key : removeKeys) {
             prop.remove(key);
         }
     }
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/DebugScriptData.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/DebugScriptData.java
new file mode 100644 (file)
index 0000000..c00eaf7
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Gyeongmin Ju <gyoengmin.ju@samsung.com>
+ * Hyeongseok Heo <harry.heo@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.rt.ide.commands.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBException;
+
+import org.tizen.rt.ide.console.ConsoleManager;
+import org.tizen.rt.product.meta.model.debug.Debug;
+import org.tizen.rt.product.meta.model.debug.Debugs;
+import org.tizen.rt.product.meta.model.debug.Execute;
+import org.tizen.rt.product.meta.model.debug.Options;
+import org.tizen.rt.product.meta.model.debug.Param;
+import org.tizen.rt.product.meta.util.MetaModelUtil;
+
+/**
+ * @since 2017. 8. 25.
+ * @author Gyeongmin Ju {@literal <gyeongmin.ju@samsung.com>}
+ */
+public class DebugScriptData {
+
+    public static class DebugScript {
+
+        public static class DebugCommand {
+
+            public static class Option {
+                public String name;
+                public String type;
+                public String param1;
+                public String param2;
+
+                public Option(String name, String type, String param1, String param2) {
+                    this.name = name;
+                    this.type = type;
+                    this.param1 = param1;
+                    this.param2 = param2;
+                }
+            }
+
+            public static class Param {
+                public String prefix;
+                public String value;
+
+                public Param(String prefix, String value) {
+                    this.prefix = prefix;
+                    this.value = value;
+                }
+            }
+
+            public String cmdStr;
+            public String curDir;
+            public String platform;
+            public String platformArch;
+            public List<Param> params = null;
+            public List<Option> options = null;
+
+            /**
+             * @param cmdStr command string
+             * @param curDir current directory
+             * @param flatform platform
+             * @param flatformArch
+             */
+            public DebugCommand(String cmdStr, String curDir, String platform, String platformArch) {
+                this.cmdStr = cmdStr;
+                this.curDir = curDir;
+                this.platform = platform;
+                this.platformArch = platformArch;
+            }
+
+            /**
+             * @return the cmdStr
+             */
+            public String getCmdStr() {
+                return cmdStr;
+            }
+
+            /**
+             * @return the curDir
+             */
+            public String getCurDir() {
+                return curDir;
+            }
+
+            /**
+             * @return the flatform
+             */
+            public String getPlatform() {
+                return platform;
+            }
+
+            /**
+             * @return the platform architecture
+             */
+            public String getPlatformArch() {
+                return platformArch;
+            }
+
+            public void setOptions(List<Option> options) {
+                this.options = options;
+            }
+
+            public void addOptions(Option option) {
+                if (options == null) {
+                    options = new ArrayList<Option>();
+                }
+
+                options.add(option);
+            }
+
+            /**
+             * @return the options
+             */
+            public List<Option> getOptions() {
+                return options;
+            }
+
+            public void addParam(Param param) {
+                if (params == null) {
+                    params = new ArrayList<Param>();
+                }
+
+                params.add(param);
+            }
+
+            public String getFullParam() {
+                if (params == null) {
+                    return null;
+                }
+
+                String fullParam = null;
+                for (Param param : params) {
+                    if (fullParam != null && !fullParam.isEmpty()) {
+                        fullParam += " ";
+                    } else {
+                        fullParam = "";
+                    }
+                    fullParam += param.prefix + " " + param.value;
+                }
+
+                return fullParam;
+            }
+        }
+
+        public String name;
+        public String type;
+        public List<DebugCommand> commands = new ArrayList<DebugCommand>();
+
+        /**
+         * @param name name
+         */
+        public DebugScript(String name, String type) {
+            this.name = name;
+            this.type = type;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void AddDebugCommand(DebugCommand cmd) {
+            commands.add(cmd);
+        }
+
+        /**
+         * @return the command
+         */
+        public DebugCommand getCommand(String platform, String arch) {
+            if (commands == null) {
+                return null;
+            }
+
+            for (DebugCommand cmd : commands) {
+                if (cmd.getPlatform().equals(platform) && cmd.getPlatformArch().equals(arch)) {
+                    return cmd;
+                }
+            }
+
+            return null;
+        }
+    }
+
+    private Map<String, String> macros = new HashMap<String, String>();
+    private Map<String, DebugScript> scripts;
+    private ConsoleManager consoleManager;
+
+    public DebugScriptData(ConsoleManager consoleManager) {
+        this.consoleManager = consoleManager;
+    }
+
+    private Map<String, DebugScript> getBuildScripts(File DebugScriptFile) {
+        Debugs debugModel = null;
+        try {
+            debugModel = MetaModelUtil.loadDebugModel(DebugScriptFile);
+        } catch (JAXBException e) {
+            return null;
+        }
+
+        Map<String, DebugScript> scripts = new HashMap<String, DebugScript>();
+
+        List<Debug> debugs = debugModel.getDebug();
+        if (debugs != null) {
+            for (Debug debug : debugs) {
+                String name = debug.getName();
+                String type = debug.getType();
+
+                List<DebugScript.DebugCommand.Option> options = new ArrayList<DebugScript.DebugCommand.Option>();
+                Options opt = debug.getOptions();
+                if (opt != null) {
+                    options.add(new DebugScript.DebugCommand.Option(opt.getName(), opt.getType(), opt.getPath(), opt.getFilter()));
+                }
+
+                DebugScript script = new DebugScript(name, type);
+
+                for (Execute exec : debug.getExecute()) {
+                    String cmdStr = exec.getCommand();
+                    String curDir = exec.getPath();
+                    String platform = exec.getOs();
+                    String arch = exec.getBit();
+
+                    DebugScript.DebugCommand debugCmd = new DebugScript.DebugCommand(cmdStr, curDir, platform, arch);
+
+                    List<Param> params = exec.getParams().getParam();
+                    if (params != null) {
+                        for (Param param : params) {
+                            debugCmd.addParam(new DebugScript.DebugCommand.Param(param.getPrefix(), param.getValue()));
+                        }
+                    }
+                    debugCmd.setOptions(options);
+
+                    script.AddDebugCommand(debugCmd);
+                }
+
+                scripts.put(script.getName(), script);
+            }
+        }
+
+        return scripts;
+    }
+
+    public void addMacro(String name, String value) {
+        macros.put(name, value);
+    }
+
+    public void consolePrintln(String str) {
+        if (consoleManager != null) {
+            consoleManager.println(str);
+        }
+    }
+
+    public int load(File buildScriptFile) {
+        consolePrintln("Build project using " + buildScriptFile);
+        scripts = getBuildScripts(buildScriptFile);
+
+        return (scripts != null) ? 0 : 1;
+    }
+
+    public int load(String buildScriptFilename) {
+        return load(new File(buildScriptFilename));
+    }
+
+    public DebugScript getScript(String name) {
+        return scripts.get(name);
+    }
+
+    public Map<String, String> getMacros() {
+        return macros;
+    }
+}
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/FlashScriptData.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/commands/model/FlashScriptData.java
new file mode 100644 (file)
index 0000000..acdcb1e
--- /dev/null
@@ -0,0 +1,264 @@
+/*
+ * Common
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Daeryong Park <bdragon.park@samsung.com>
+ * Hyeongseok Heo <harry.heo@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.rt.ide.commands.model;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBException;
+
+import org.tizen.rt.ide.console.ConsoleManager;
+import org.tizen.rt.ide.util.MacroUtil;
+import org.tizen.rt.ide.util.ProcUtil;
+import org.tizen.rt.product.meta.model.build.Build;
+import org.tizen.rt.product.meta.model.build.Command;
+import org.tizen.rt.product.meta.model.build.Commands;
+import org.tizen.rt.product.meta.model.build.Param;
+import org.tizen.rt.product.meta.model.flash.Execute;
+import org.tizen.rt.product.meta.model.flash.Flash;
+import org.tizen.rt.product.meta.util.MetaModelUtil;
+
+/**
+ * @since 2017. 5. 18.
+ * @author Daeryong Park {@literal <bdragon.park@samsung.com>}
+ */
+public class FlashScriptData {
+
+    private static class FlashScript {
+        
+        public static class FlashCommand {
+            public String name;
+            public String cmdStr;
+            public String curDir;
+            public String flatform;
+            public String flatformArch;
+            
+            /**
+             * @param name command name
+             * @param cmdStr command string
+             * @param curDir current directory
+             * @param isShellCmd is shell command
+             * @param shell shell name to use like "/bin/bash"
+             * @param params shell name to use like "/bin/bash"
+             */
+            public FlashCommand(String name, String cmdStr, String curDir, String flatform, String flatformArch) {
+                this.name = name;
+                this.cmdStr = cmdStr;
+                this.curDir = curDir;
+                this.flatform = flatform;
+                this.flatformArch = flatformArch;
+            }
+
+            /**
+             * @return the name
+             */
+            public String getName() {
+                return name;
+            }
+
+            /**
+             * @return the cmdStr
+             */
+            public String getCmdStr() {
+                return cmdStr;
+            }
+
+            /**
+             * @return the curDir
+             */
+            public String getCurDir() {
+                return curDir;
+            }
+
+            /**
+             * @return the flatform
+             */
+            public String getFlatform() {
+                return flatform;
+            }
+            
+            /**
+             * @return the flatform
+             */
+            public String getFlatformArch() {
+                return flatformArch;
+            }
+        }
+        
+        public String name;
+        public Map<String, FlashCommand> commands = new HashMap<String, FlashCommand> ();
+        public List<String> options = null;
+
+        /**
+         * @param name name
+         */
+        public FlashScript(String name) {
+            this.name = name;
+        }
+
+        /**
+         * @return the command
+         */
+        public FlashCommand getCommand(String name) {
+            if(commands == null) {
+                return null;
+            }
+            return commands.get(name);
+        }
+
+        /**
+         * @return the options
+         */
+        public List<String> getOptions() {
+            return options;
+        }
+    }
+
+    private Map<String, String> macros = new HashMap<String, String>();
+    private Map<String, FlashScript> scripts;
+    private ConsoleManager consoleManager;
+
+    public FlashScriptData(ConsoleManager consoleManager) {
+        this.consoleManager = consoleManager;
+    }
+
+    private Map<String, FlashScript> getBuildScripts(File flashScriptFile) {
+        Flash flashModel = null;
+        try {
+            flashModel = MetaModelUtil.loadFlashModel(flashScriptFile);
+        } catch (JAXBException e) {
+            return null;
+        }
+
+        Map<String, FlashScript> scripts = new HashMap<String, FlashScript>();
+        
+        //FlashScript script = new FlashScript(cmd.getName()); 
+        FlashScript script = new FlashScript(flashModel.getName());
+        
+        List<Execute> execs = flashModel.getExecutors().getExecute();
+        for(Execute exec : execs) {
+            String name = exec.getName();
+            String cmdStr = exec.getCommand();
+            String curDir = exec.getPath();
+            String flatform = exec.getOs();
+            String arch = exec.getBit();
+            script.commands.put(name, new FlashScript.FlashCommand(name, cmdStr, curDir, flatform, arch));
+        }
+        
+        List<String> opts = flashModel.getOptions().getOption();
+        script.options = opts;
+        
+        //scripts.put(flashModel.getName(), script);
+        scripts.put("flash", script);
+
+        return scripts;
+    }
+
+    public String getBuildScriptFileName() {
+        return "build.xml";
+    }
+
+    public void addMacro(String name, String value) {
+        macros.put(name, value);
+    }
+
+    public void consolePrintln(String str) {
+        if (consoleManager != null) {
+            consoleManager.println(str);
+        }
+    }
+
+    public int load(File buildScriptFile) {
+        consolePrintln("Build project using " + buildScriptFile);
+        scripts = getBuildScripts(buildScriptFile);
+
+        return (scripts != null) ? 0 : 1;
+    }
+
+    public int load(String buildScriptFilename) {
+        return load(new File(buildScriptFilename));
+    }
+
+    public int doCommand(String buildCmdName, String flashOption, Map<String, String> env) {
+        ProcessBuilder pb = ProcUtil.genProcessBuilder(null);
+
+        FlashScript script = scripts.get(buildCmdName);
+        if (script == null) {
+            consolePrintln("Cannot found build command : " + buildCmdName);
+            return 1;
+        }
+
+        if (env != null) {
+            pb.environment().putAll(env);
+        }
+
+        FlashScript.FlashCommand cmd = script.getCommand("flash");
+        if(cmd == null) {
+            return 2;
+        }
+        
+        String cmdStr = MacroUtil.processMacro(cmd.getCmdStr(), macros); //
+        if (cmdStr == null || cmdStr.isEmpty()) {
+            return 1;
+        }
+        String curDir = MacroUtil.processMacro(cmd.getCurDir(), macros);
+
+        String[] cmds = null;
+
+        int paramLen = 0;
+        if (flashOption != null && !flashOption.isEmpty()) {
+            paramLen = 1;
+        }
+
+        if (paramLen > 0) {
+            cmds = new String[paramLen + 1];
+            cmds[1] = flashOption;
+        } else {
+            cmds = new String[1];
+        }
+        cmds[0] = cmdStr;
+
+        return ProcUtil.executeProcess(pb, cmds, true, null,
+                curDir, consoleManager, null);
+
+    }
+
+    public int doCommand(String buildCmdName) {
+        return doCommand(buildCmdName, "ALL", null);
+    }
+
+    public List<String> getOptions() {
+        FlashScript script = scripts.get("flash");
+        if (script == null) {
+            return null;
+        }
+        
+        return script.getOptions();
+    }
+}
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizard.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizard.java
deleted file mode 100644 (file)
index f08a211..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-*  Common
-*
-* Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* jm.jemin.kim <jm.jemin.kim@samsung.com>
-* Gyeongmin Ju <gyeongmin.ju@samsung.com>
-* Daeryong Park <bdragon.park@samsung.com>
-* Hyeongseok Heo <harry.heo@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.rt.ide.flash;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.IPageChangedListener;
-import org.eclipse.jface.dialogs.PageChangedEvent;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.wizard.IWizardContainer;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.tizen.rt.ide.Messages;
-import org.tizen.rt.ide.commands.CommandManager;
-import org.tizen.rt.ide.console.ConsoleManager;
-import org.tizen.rt.product.meta.model.flash.Flashes;
-
-/**
- * FlashWizard
- * @author jm.jaemin.kim{@literal <jm.jaemin.kim>} (S-Core)
- */
-public class FlashWizard extends Wizard implements IPageChangedListener {
-
-    private ConsoleManager consoleManager;
-    private Shell shell;
-    private String board;
-    private final String GUIDE_DIALOG_NAME = "Flash Option Selection"; //$NON-NLS-1$
-    private FlashWizardPage wizardPage = null;
-    private final Logger logger = LoggerFactory.getLogger(FlashWizard.class);
-    private IProject project;
-    private Flashes model;
-
-    public FlashWizard(Shell shell, IProject project, String board, Flashes model) {
-        super();
-        this.setWindowTitle(Messages.RtosFlashWizard_WindowTitle);
-        this.setNeedsProgressMonitor(true);
-        this.shell = shell;
-        this.project = project;
-        this.board = board;
-        this.model = model;
-        this.consoleManager = new ConsoleManager(true);
-    }
-
-    @Override
-    public boolean performFinish() {
-        IWizardContainer container = getContainer();
-        try {
-            container.run(true, false, new IRunnableWithProgress() {
-                @Override
-                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-                    // String selectedDeviceName =
-                    monitor.beginTask("Flash", 4); //$NON-NLS-1$
-                    FlashOption option = FlashWizardDialog.getSelectionOption();
-                    consoleManager.println(option.getFlashOption());
-                    monitor.worked(1);
-
-                    CommandManager.runFlash(project, option, consoleManager, monitor);
-                    monitor.done();
-                }
-            });
-        } catch (InvocationTargetException e) {
-            logger.error(e.getMessage(), e);
-        } catch (InterruptedException e) {
-            logger.error(e.getMessage(), e);
-        }
-        return true;
-    }
-
-    @Override
-    public void addPages() {
-        wizardPage = new FlashWizardPage(GUIDE_DIALOG_NAME, shell, board, model);
-        addPage(wizardPage);
-        WizardDialog dialog = (WizardDialog) getContainer();
-        dialog.addPageChangedListener(this);
-    }
-
-    @Override
-    public void pageChanged(PageChangedEvent arg0) {
-
-    }
-
-    @Override
-    public boolean canFinish() {
-        return true;
-    }
-}
diff --git a/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizardDialog.java b/rt-ide/tizen.rt.product.plugin/src/org/tizen/rt/ide/flash/FlashWizardDialog.java
deleted file mode 100644 (file)
index cfe9a96..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-*  Common
-*
-* Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
-*
-* Contact:
-* jm.jemin.kim <jm.jemin.kim@samsung.com>
-* Gyeongmin Ju <gyeongmin.ju@samsung.com>
-* Daeryong Park <bdragon.park@samsung.com>
-* Hyeongseok Heo <harry.heo@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.rt.ide.flash;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.wizard.IWizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.tizen.rt.ide.util.OSChecker;
-
-/**
- * FlashWizardDialog
- * @author jm.jaemin.kim{@literal <jm.jaemin.kim>} (S-Core)
- */
-public class FlashWizardDialog extends WizardDialog {
-
-    public static final String LAUNCHER_LABEL = "Flash"; //$NON-NLS-1$
-
-    private int x = 0;
-    private int y = 0;
-    private final int width = OSChecker.isWindows() ? 550 : 620;
-    private final int height = 450;
-    public static FlashOption selectionOption = null;
-    private Shell shell;
-    private Button flash;
-
-    public FlashWizardDialog(Shell parentShell, IWizard newWizard) {
-        super(parentShell, newWizard);
-        Rectangle bounds = null;
-        bounds = parentShell.getBounds();
-        setbounds(bounds);
-
-    }
-
-    public void setbounds(Rectangle bounds) {
-        this.x = bounds.x + (bounds.width - width) / 2;
-        this.y = bounds.y + (bounds.height - height) / 2;
-    }
-
-    public static void selectionOption(FlashOption selctionOption) {
-        selectionOption = selctionOption;
-    }
-
-    public static FlashOption getSelectionOption() {
-        return selectionOption;
-    }
-
-    @Override
-    protected void configureShell(Shell newShell) {
-        super.configureShell(newShell);
-        this.shell = newShell;
-        this.shell.setLocation(x, y);
-        this.shell.setSize(width, height);
-    }
-
-    protected void PressedFinished() {
-        super.finishPressed();
-    }
-
-    @Override
-    protected void createButtonsForButtonBar(Composite p) {
-        super.createButtonsForButtonBar(p);
-
-        // LAUNCHER_LABEL
-        flash = getButton(IDialogConstants.FINISH_ID);
-        flash.setText(LAUNCHER_LABEL);
-        flash.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                // TODO: something to launch
-            }
-        });
-
-        setButtonLayoutData(flash);
-    }
-}
 * - S-Core Co., Ltd
 *
 */
-
-package org.tizen.rt.ide.flash;
+package org.tizen.rt.ide.flash.ui;
 
 import java.util.List;
-
-import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.tizen.rt.ide.Messages;
 import org.tizen.rt.ide.commands.CommandManager;
-import org.tizen.rt.ide.util.ViewUtil;
-import org.tizen.rt.product.meta.model.flash.Flashes;
+import org.tizen.rt.ide.commands.model.FlashOption;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 
 /**
- * FlashWizardPage
- * @author jm.jaemin.kim{@literal <jm.jaemin.kim>} (S-Core)
+ * FlashOptionDialog
+ * @author gyeongmin.ju{@literal <gyeongmin.ju>} (S-Core)
  */
-public class FlashWizardPage extends WizardPage {
-    private Shell shell;
+public class FlashOptionDialog extends Dialog {
+
+    private String projectPath;
     private String board;
+    private String option;
     private Table table;
     public TableViewer tableViewer;
-    private Flashes model;
 
-    protected FlashWizardPage(String pageName, Shell shell, String board, Flashes model) {
-        super(pageName);
-        this.shell = shell;
+    /**
+     * Create the dialog.
+     * @param parentShell
+     */
+    public FlashOptionDialog(Shell parentShell, IProject project, String board) {
+        super(parentShell);
+
+        projectPath = project.getLocation().toString();
         this.board = board;
-        this.model = model; // TODO Need to fix all processing with model
-        setTitle(Messages.RtosFlashDialogPage_Title);
-        setDescription(Messages.RtosFlashDialogPage_Description);
-        setErrorMessage(null);
     }
 
+    /**
+     * Create contents of the dialog.
+     * @param parent
+     */
     @Override
-    public void createControl(Composite parentComposite) {
-
-        Composite composite = new Composite(parentComposite, SWT.NONE);
-
-        TableColumnLayout layout = new TableColumnLayout();
-        composite.setLayout(layout);
+    protected Control createDialogArea(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NONE);
+        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
 
         GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-        gridData.minimumHeight = 0;
+        gridData.heightHint = 280;
         composite.setLayoutData(gridData);
+        composite.setLayout(new GridLayout(1, false));
 
         tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
         tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -96,72 +97,49 @@ public class FlashWizardPage extends WizardPage {
                 IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                 for (Object o : selection.toArray()) {
                     FlashOption bOption = (FlashOption) o;
-                    FlashWizardDialog.selectionOption(bOption);
+                    option = bOption.getFlashOption();
                 }
 
             }
         });
 
         table = tableViewer.getTable();
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
         table.setHeaderVisible(true);
         table.setLinesVisible(true);
 
         TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
-        TableColumn tblclmnPixel100 = tableViewerColumn.getColumn();
-        layout.setColumnData(tblclmnPixel100, new ColumnPixelData(500, true, true));
-        tblclmnPixel100.setText(Messages.RtosFlashDialogPage_OptionNameColumn);
+        TableColumn tblclmnPixel400 = tableViewerColumn.getColumn();
+        tblclmnPixel400.setWidth(400);
+        tblclmnPixel400.setText(Messages.RtosFlashDialogPage_OptionNameColumn);
 
         tableViewer.setLabelProvider(new TableViewerProvider());
         tableViewer.setContentProvider(new ArrayContentProvider());
-        tableViewer.addDoubleClickListener(new IDoubleClickListener() {
-            @Override
-            public void doubleClick(DoubleClickEvent arg0) {
-                FlashWizard wizard = (FlashWizard) getWizard();
-                FlashWizardDialog dialog = (FlashWizardDialog) wizard.getContainer();
-                dialog.PressedFinished();
-            }
-
-        });
-
-        // get device list & extract Device Entry detailList From XML
-        List<FlashOption> testList = CommandManager.getFlashOptions(board);
-
-        FlashWizard wizard = (FlashWizard) getWizard();
-        if (testList.size() != 0) {
-            // set HighlightEntryList
-            ViewUtil.setHighlightListener(shell, table);
-
-            // input buildOption list
-            tableViewer.setInput(testList);
 
-            Object element = tableViewer.getElementAt(0);
-            // set Highlighting specific item with latestBuildOptionInfo.
-            tableViewer.setSelection(new StructuredSelection(element), true);
+        List<FlashOption> opts = CommandManager.getFlashOptions(projectPath, board);
 
-            // set default buildOption
-            FlashWizardDialog.selectionOption((FlashOption) element);
+        tableViewer.setInput(opts);
 
-            wizard.canFinish();
-        } else {
-            wizard.canFinish();
-        }
-
-        setControl(parentComposite);
+        return composite;
     }
 
     /**
-     * @return the shell
+     * Create contents of the button bar.
+     * @param parent
      */
     @Override
-    public Shell getShell() {
-        return shell;
+    protected void createButtonsForButtonBar(Composite parent) {
+        createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+        createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
     }
 
     /**
-     * @return the board
+     * Return the initial size of the dialog.
      */
-    public String getBoard() {
-        return board;
+    @Override
+    protected Point getInitialSize() {
+        // return new Point(640, 480);
+        return super.getInitialSize();
     }
 
     private class TableViewerProvider extends LabelProvider implements ITableLabelProvider {
@@ -173,7 +151,6 @@ public class FlashWizardPage extends WizardPage {
 
         @Override
         public String getColumnText(Object element, int columnIndex) {
-            // TODO: create object in associated with Device EntryList
             if (element instanceof FlashOption) {
                 FlashOption bOption = (FlashOption) element;
                 switch (columnIndex) {
@@ -188,4 +165,11 @@ public class FlashWizardPage extends WizardPage {
 
     }
 
+    /**
+     * @return the flash option
+     */
+    public String getOption() {
+        return option;
+    }
+
 }
index 2597155..2d906f3 100644 (file)
  */
 package org.tizen.rt.ide.handlers;
 
-import java.io.IOException;
-
-import javax.xml.bind.JAXBException;
-
+import java.io.File;
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
 import org.tizen.rt.ide.Messages;
-import org.tizen.rt.ide.exception.BuildInfoHandlingException;
-import org.tizen.rt.ide.exception.InvalidMetaException;
-import org.tizen.rt.ide.exception.MetaLoadException;
-import org.tizen.rt.ide.exception.MetaNotFoundException;
-import org.tizen.rt.ide.flash.FlashWizard;
-import org.tizen.rt.ide.flash.FlashWizardDialog;
-import org.tizen.rt.ide.meta.BuildInfo;
-import org.tizen.rt.ide.meta.BuildInfoManager;
-import org.tizen.rt.ide.meta.IMetaConstants;
-import org.tizen.rt.ide.meta.MetaManager;
+import org.tizen.rt.ide.commands.FlashCommand;
+import org.tizen.rt.ide.console.ConsoleManager;
 import org.tizen.rt.ide.util.ResourceUtil;
-import org.tizen.rt.ide.util.ViewUtil;
-import org.tizen.rt.product.meta.model.flash.Flashes;
-import org.tizen.rt.product.meta.util.MetaModelUtil;
 
 /**
  * Our sample handler extends AbstractHandler, an IHandler base class.
@@ -63,87 +46,19 @@ public class FlashHandler extends AbstractHandler {
 
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-        final IProject project = ResourceUtil.getCurrentProject();
-        if (project == null) {
-            return null;
-        }
-
-        ViewUtil.syncExec(new Runnable() {
-            @Override
-            public void run() {
-                Shell activeShell = Display.getDefault().getActiveShell();
-
-                try {
-                    // check build.info file exist
-                    BuildInfo buildInfo = BuildInfoManager.loadBuildInfo(project);
-
-                    // check build.info file is normal
-                    String board = buildInfo.getBoard();
-                    if (board == null || board.length() == 0) {
-                        processBuildInfoLoadError(activeShell, project); // $NON-NLS-1$
-                        return;
-                    }
-
-                    // Load flash model
-                    Flashes flash = null;
-                    try {
-                        flash = MetaManager.loadFlashMeta(project, board);
-                    } catch (MetaNotFoundException e) {
-                        // handle meta not found
-                        flash = processMetaNotFoundError(activeShell, project, board);
-                    } catch (InvalidMetaException e) {
-                        // handle meta load exception
-                        processMetaLoadError(activeShell, project);
-                    } catch (MetaLoadException e) {
-                        // handle meta load exception
-                        processMetaLoadError(activeShell, project);
-                    }
+        IProject project = ResourceUtil.getCurrentProject();
 
-                    if (flash != null) {
-                        // pass loaded flash model to wizard and wizard will be process with model
-                        FlashWizard rtosWizard = new FlashWizard(activeShell, project, board, flash);
-                        FlashWizardDialog rtosWizardDialog = new FlashWizardDialog(activeShell, rtosWizard);
+        String osDir = ResourceUtil.getCurrentProject().getLocation().toString() + File.separator + "os";
 
-                        rtosWizardDialog.create();
-                        rtosWizardDialog.open();
-                    }
-                } catch (BuildInfoHandlingException e) {
-                    processBuildInfoLoadError(activeShell, project);
-                }
-            }
-        });
-
-        return null;
-    }
+        if (!new File(osDir, ".config").exists()) {
+            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosBuildDialogPage_KconfigErrorMessage); //$NON-NLS-1$
+            return null;
+        }
 
-    protected void processBuildInfoLoadError(Shell activeShell, IProject project) {
-        MessageDialog.openError(activeShell, "Error", Messages.FlashHandler_BuildInfoIsNotNormal); //$NON-NLS-1$
-    }
+        ConsoleManager consoleManager = new ConsoleManager(true);
 
-    private void processMetaLoadError(Shell activeShell, IProject project) {
-        MessageDialog.openError(activeShell, "Error", Messages.FlashHandler_MetaLoadError); //$NON-NLS-1$
+        FlashCommand cmd = new FlashCommand();
+        return cmd.execute(project, consoleManager);
     }
 
-    private Flashes processMetaNotFoundError(Shell activeShell, IProject project, String board) {
-        // Confirm dialog : ask to want to use default flash meta or cancel
-        // If OK, copy default flashSpec.xml file to board directory and load it
-        boolean loadDefault = MessageDialog.openConfirm(
-                activeShell, "Flash meta not found", Messages.FlashHandler_ConfirmMessage);//$NON-NLS-1$
-        if (loadDefault) {
-            String destination = MetaManager.getMetaFilePath(project, board, IMetaConstants.FILE_NAME_FLASH_META_XML);
-            try {
-                Flashes model = MetaModelUtil.copyDefaultFlashModelAndLoad(destination);
-                project.refreshLocal(IProject.DEPTH_INFINITE, new NullProgressMonitor());
-                return model;
-            } catch (IOException e) {
-                processMetaLoadError(activeShell, project);
-            } catch (JAXBException e) {
-                processMetaLoadError(activeShell, project);
-            } catch (CoreException e) {
-                // Do nothing
-            }
-        }
-
-        return null;
-    }
 }
index f08e051..bb3ae7b 100644 (file)
@@ -28,12 +28,9 @@ package org.tizen.rt.ide.launch;
 
 import java.io.File;
 import java.io.FileReader;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 
 import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@@ -59,16 +56,12 @@ import org.eclipse.ui.IEditorPart;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.tizen.rt.ide.Messages;
+import org.tizen.rt.ide.commands.model.DebugScriptData;
+import org.tizen.rt.ide.console.ConsoleManager;
 import org.tizen.rt.ide.util.MacroUtil;
 import org.tizen.rt.ide.util.OSChecker;
 import org.tizen.rt.ide.util.ResourceUtil;
 import org.tizen.rt.ide.util.SDKUtil;
-import org.tizen.rt.ide.util.XMLUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
 import ilg.gnuarmeclipse.debug.gdbjtag.openocd.ConfigurationAttributes;
 
 /**
@@ -77,204 +70,133 @@ import ilg.gnuarmeclipse.debug.gdbjtag.openocd.ConfigurationAttributes;
  */
 public class LaunchShortcut implements ILaunchShortcut {
 
+    private static class KeyValue {
+        public String key;
+        public String value;
+
+        public KeyValue(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+    }
+
     private static final Logger logger = LoggerFactory.getLogger(LaunchShortcut.class);
 
     private static final String PROP_COMMENT_DEBUG_INFO = "TinyARA Debug information"; //$NON-NLS-1$
     private static final String PROP_NAME_SCRIPT = "script"; //$NON-NLS-1$
     private static final String PROP_NAME_BOARD = "board"; //$NON-NLS-1$
     private static final String FILE_NAME_BUILD_INFO = "build.info"; //$NON-NLS-1$
-    private static final String FILE_NAME_DEBUG_INFO = "debug.info"; //$NON-NLS-1$
     private static final String PATH_BUILD_OUTPUT = "build/output"; //$NON-NLS-1$
     private static final String PATH_BUILD_CONFIGS = "build/configs"; //$NON-NLS-1$
-    private static final String PATH_OPENOCD = "openocd"; //$NON-NLS-1$
-    private static final String PATH_OPENOCD_SCRIPT = "tools/openocd"; //$NON-NLS-1$
-    // private static final String PATH_DEBUG_OPENOCD = "tools/openocd"; //$NON-NLS-1$
     private static final String PROGRAM_NAME = PATH_BUILD_OUTPUT + "/bin/tinyara"; //$NON-NLS-1$
-    // private static final String OPENOCD_EXECUTABLE_32 = "openocd_0.10_linux32_t20"; //$NON-NLS-1$
-    // private static final String OPENOCD_EXECUTABLE_64 = "openocd_0.10_linux64_t20"; //$NON-NLS-1$
-    // private static final String OPENOCD_EXECUTABLE_32 = "linux32/openocd"; //$NON-NLS-1$
-    // private static final String OPENOCD_EXECUTABLE_64 = "linux64/openocd"; //$NON-NLS-1$
     private static final String DEBUGGER_NAME = "arm-none-eabi-gdb"; //$NON-NLS-1$
-    private static final String FILE_NAME_DEBUG_SCRIPT = "debug.xml"; //$NON-NLS-1$
+    private static final String PATH_LINUX_BUILD_OUTPUT = "build/output"; //$NON-NLS-1$
+    private static final String FILE_NAME_DEBUG_SCRIPT = ".debugSpec.xml"; //$NON-NLS-1$
 
     private final String OPENOCD_LAUNCHTYPE = "ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType"; //$NON-NLS-1$
 
-    private class LaunchParam {
-        public String name;
-        public String prefix;
-        public String value;
+    private static DebugScriptData getScript(String activeProjectPath, String boardPath, ConsoleManager consoleManager) {
+        String sdkPath = SDKUtil.getSdkPath();
 
-        public LaunchParam(String name, String prefix, String value) {
-            this.name = name;
-            this.prefix = prefix;
-            this.value = value;
+        File buildScriptFile = null;
+        if (boardPath != null) {
+            buildScriptFile = new File(boardPath, FILE_NAME_DEBUG_SCRIPT);
         }
-    }
-
-    private class LaunchExecute {
-        public String platform;
-        public String execute;
-        public List<LaunchParam> params;
-
-        public LaunchExecute(String platform, String execute, List<LaunchParam> params) {
-            this.platform = platform;
-            this.execute = execute;
-            this.params = params;
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(activeProjectPath, FILE_NAME_DEBUG_SCRIPT);
         }
-
-        public String getFullParam() {
-            if (params == null) {
-                return null;
-            }
-
-            String fullParam = null;
-            for (LaunchParam param : params) {
-                if (fullParam != null && !fullParam.isEmpty()) {
-                    fullParam += " ";
-                } else {
-                    fullParam = "";
-                }
-                fullParam += param.prefix + " " + param.value;
-            }
-
-            return fullParam;
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts"
+                    + File.separator + FILE_NAME_DEBUG_SCRIPT); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         }
-    }
 
-    private class LaunchScript {
-        public String type;
-        public Map<String, LaunchExecute> executes;
-
-        public LaunchScript(String type, Map<String, LaunchExecute> executes) {
-            this.type = type;
-            this.executes = executes;
+        if (buildScriptFile == null || !buildScriptFile.exists()) {
+            return null;
         }
 
-        public LaunchExecute getExecute(String platformName) {
-            if (executes == null) {
-                return null;
-            }
+        DebugScriptData buildScript = new DebugScriptData(consoleManager);
+        buildScript.load(buildScriptFile);
 
-            return executes.get(platformName);
-        }
+        return buildScript;
     }
 
-    private Map<String, LaunchScript> getBuildScripts(File buildScriptFile, Map<String, String> macros) {
-        Document doc = XMLUtil.readXML(buildScriptFile);
+    private ILaunchConfiguration createConfiguration(String projectName, IPath targetPath, String boardName) throws CoreException {
+        String sdkPath = SDKUtil.getSdkPath();
+        String homePath = ResourceUtil.getCurrentProject().getLocation().toString();
+        String boardPath = homePath + File.separator + "build" + File.separator + "configs" + File.separator + boardName; //$NON-NLS-1$ //$NON-NLS-2$
 
-        NodeList commands = XMLUtil.getDOMNodes(doc.getDocumentElement(), "/launch/debug");
-        if (commands == null || commands.getLength() <= 0) {
+        DebugScriptData debugScriptData = getScript(homePath, boardPath, null);
+        if (debugScriptData == null) {
+            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosDebug_ERROR_DEBUGSCRIPT_NOT_EXIST);
             return null;
         }
 
-        Map<String, LaunchScript> scripts = new HashMap<String, LaunchScript>();
-
-        int len = commands.getLength();
-        for (int i = 0; i < len; i++) {
-            Node node = commands.item(i);
-            if (node instanceof Element) {
-                Element elm = (Element) node;
-
-                String name = elm.getAttribute("name");
-                String type = elm.getAttribute("type");
-
-                Map<String, LaunchExecute> executes = new HashMap<String, LaunchExecute>();
-
-                NodeList execNodes = XMLUtil.getDOMNodes(elm, "execute");
-                if (execNodes != null && execNodes.getLength() > 0) {
-                    int len2 = execNodes.getLength();
-                    for (int j = 0; j < len2; j++) {
-                        Node execNode = execNodes.item(j);
-                        if (execNode instanceof Element) {
-                            Element execElm = (Element) execNode;
-
-                            String platform = execElm.getAttribute("platform");
-                            String execute = execElm.getAttribute("execute");
-                            execute = MacroUtil.processMacro(execute, macros);
-
-                            List<LaunchParam> params = new ArrayList<LaunchParam>();
-                            NodeList paramNodes = XMLUtil.getDOMNodes(execElm, "param");
-                            if (paramNodes != null && paramNodes.getLength() > 0) {
-                                int len3 = paramNodes.getLength();
-                                for (int k = 0; k < len3; k++) {
-                                    Node paramNode = paramNodes.item(k);
-                                    if (paramNode instanceof Element) {
-                                        Element paramElm = (Element) paramNode;
-
-                                        String prefix = paramElm.getAttribute("prefix");
-                                        String value = paramElm.getAttribute("value");
-                                        value = MacroUtil.processMacro(value, macros);
-
-                                        params.add(new LaunchParam(name, prefix, value));
-                                    }
-                                }
-                            }
-
-                            executes.put(platform, new LaunchExecute(platform, execute, params));
+        String platformName;
+        String platformArch;
+        if (OSChecker.is64bit()) {
+            platformName = "linux"; //$NON-NLS-1$
+            platformArch = "64"; //$NON-NLS-1$
+        } else {
+            platformName = "linux"; //$NON-NLS-1$
+            platformArch = "32"; //$NON-NLS-1$
+        }
+
+        DebugScriptData.DebugScript script = debugScriptData.getScript("openocd debug"); //$NON-NLS-1$
+
+        debugScriptData.addMacro("PROJECT_PATH", homePath); //$NON-NLS-1$
+        debugScriptData.addMacro("BOARD", boardName); //$NON-NLS-1$
+
+        DebugScriptData.DebugScript.DebugCommand openocdExec = script.getCommand(platformName, platformArch);
+        List<DebugScriptData.DebugScript.DebugCommand.Option> opts = openocdExec.getOptions();
+        List<KeyValue> optList = new ArrayList<KeyValue>();
+        if (opts != null) {
+            for (DebugScriptData.DebugScript.DebugCommand.Option opt : opts) {
+                if (opt.type != null && opt.type.equals("file")) { //$NON-NLS-1$
+                    String path = opt.param1;
+                    String filter = opt.param2;
+                    File home = new File(MacroUtil.processMacro(path, debugScriptData.getMacros()));
+                    if (filter != null && filter.contains("*")) { //$NON-NLS-1$
+                        FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SHEET);
+                        dialog.setFilterPath(home.toString());
+                        dialog.setFilterExtensions(new String[] { filter });
+                        String debugCfg = dialog.open();
+                        if (debugCfg == null) {
+                            return null;
+                        }
+                        optList.add(new KeyValue(opt.name, debugCfg));
+                    } else {
+                        if(filter != null && !filter.isEmpty()) {
+                            File filePath = new File(home, filter);
+                            optList.add(new KeyValue(opt.name, filePath.toString()));
+                        } else {
+                            optList.add(new KeyValue(opt.name, home.toString()));
                         }
                     }
                 }
-
-                scripts.put(name, new LaunchScript(type, executes));
             }
         }
 
-        return scripts;
-    }
-
-    private ILaunchConfiguration createConfiguration(String projectName, IPath targetPath, String boardName, String debugCfg) throws CoreException {
-        String sdkPath = SDKUtil.getSdkPath();
-        String homePath = ResourceUtil.getCurrentProject().getLocation().toString();
-        String boardPath = homePath + File.separator + "configs" + File.separator + boardName;
-
-        File launchScriptFile = new File(boardPath, FILE_NAME_DEBUG_SCRIPT);
-        if (!launchScriptFile.exists()) {
-            launchScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts" + File.separator + FILE_NAME_DEBUG_SCRIPT);
-            if (!launchScriptFile.exists()) {
-                MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosDebug_ERROR_DEBUGSCRIPT_NOT_EXIST); //$NON-NLS-1$
-                return null;
+        for (KeyValue v : optList) {
+            if (v.key == null || v.value == null) {
+                continue;
+            }
+            if (v.key.equals("scriptfile")) { //$NON-NLS-1$
+                String scriptPath = new File(v.value).getParent();
+                if (scriptPath != null) {
+                    debugScriptData.addMacro("SCRIPT_PATH", scriptPath); //$NON-NLS-1$
+                }
+                String debugCfg = new File(v.value).getName();
+                if (debugCfg != null) {
+                    debugScriptData.addMacro("SCRIPT_FILE", debugCfg); //$NON-NLS-1$
+                }
+            } else {
+                debugScriptData.addMacro(v.key, v.value); // $NON-NLS-1$
             }
         }
 
-        String scriptPath = new File(debugCfg).getParent();
-        debugCfg = new File(debugCfg).getName();
-
-        Map<String, String> macros = new HashMap<String, String>();
-        macros.put("PROJECT_PATH", homePath);
-        macros.put("BOARD", boardName);
-        macros.put("SCRIPT_PATH", scriptPath);
-        macros.put("SCRIPT_FILE", debugCfg);
-
-        // consoleManager.println("Launch project using " + launchScriptFile);
-
-        Map<String, LaunchScript> scripts = getBuildScripts(launchScriptFile, macros);
-        if (scripts == null) {
-            return null;
-        }
-        LaunchScript launch = scripts.get("openocd");
-        if (launch == null) {
-            return null;
-        }
-
-        String platformName;
-        if (OSChecker.is64bit()) {
-            platformName = "linux64";
-        } else {
-            platformName = "linux32";
-        }
-        LaunchExecute openocdExec = launch.getExecute(platformName);
-
-        // String openocdPath = targetPath.toOSString() + File.separator + PATH_BUILD_CONFIGS + File.separator + boardName + File.separator + PATH_DEBUG_OPENOCD;
-        // String openocdExec = null;
-        // if (OSChecker.is64bit()) {
-        // openocdExec = OPENOCD_EXECUTABLE_64;
-        // } else {
-        // openocdExec = OPENOCD_EXECUTABLE_32;
-        // }
-        // openocdExec = openocdPath + File.separator + openocdExec;
-
-        if (!new File(openocdExec.execute).exists()) {
-            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosDebug_ERROR_OPENOCD_NOT_EXIST); //$NON-NLS-1$
+        String cmdStr = MacroUtil.processMacro(openocdExec.getCmdStr(), debugScriptData.getMacros());
+        if (!new File(cmdStr).exists()) {
+            MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.RtosDebug_ERROR_OPENOCD_NOT_EXIST);
             return null;
         }
 
@@ -283,19 +205,14 @@ public class LaunchShortcut implements ILaunchShortcut {
 
         ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, manager.generateLaunchConfigurationName(targetPath.lastSegment()));
 
-        wc.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, openocdExec.execute);
-        wc.setAttribute(ConfigurationAttributes.GDB_SERVER_OTHER, openocdExec.getFullParam()); // $NON-NLS-1$
+        wc.setAttribute(ConfigurationAttributes.GDB_SERVER_EXECUTABLE, cmdStr);
+        wc.setAttribute(ConfigurationAttributes.GDB_SERVER_OTHER, MacroUtil.processMacro(openocdExec.getFullParam(), debugScriptData.getMacros()));
 
         wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
         wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, PROGRAM_NAME);
         wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, DEBUGGER_NAME);
         wc.setAttribute(IGDBJtagConstants.ATTR_LOAD_IMAGE, false);
 
-        // IResource targetResource = ResourcesPlugin.getWorkspace().getRoot().findMember(targetPath);
-        // if (targetResource != null && targetResource.exists()) {
-        // wc.setAttribute(ILaunchConfigurationConstants.ATTR_PROJECT_NAME, LaunchUtils.getLaunchProjectName(targetResource));
-        // }
-
         return wc.doSave();
     }
 
@@ -311,59 +228,21 @@ public class LaunchShortcut implements ILaunchShortcut {
 
                 File buildInfoFile = new File(outputPath, FILE_NAME_BUILD_INFO);
                 if (!buildInfoFile.exists()) {
-                    MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.LaunchShortcut_NotFoundBuildInfo); //$NON-NLS-1$
+                    MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.LaunchShortcut_NotFoundBuildInfo);
                     return;
                 }
 
-                boolean update = false;
-                String board = null;
-                String debugCfg = null;
-
-                Properties debugInfo = new Properties();
+                Properties buildInfo = new Properties();
                 try {
-                    debugInfo.load(new FileReader(new File(outputPath, FILE_NAME_DEBUG_INFO)));
-                    board = debugInfo.getProperty(PROP_NAME_BOARD);
-                    debugCfg = debugInfo.getProperty(PROP_NAME_SCRIPT);
+                    buildInfo.load(new FileReader(buildInfoFile));
                 } catch (IOException e) {
-                    update = true;
-                }
-
-                if (board == null || board.isEmpty()) {
-                    Properties buildInfo = new Properties();
-                    try {
-                        buildInfo.load(new FileReader(buildInfoFile));
-                    } catch (IOException e) {
-                        MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.LaunchShortcut_NotFoundBuildInfo); //$NON-NLS-1$
-                        return;
-                    }
-                    board = buildInfo.getProperty(PROP_NAME_BOARD);
-                    update = true;
-                }
-                if (debugCfg == null || debugCfg.isEmpty()) {
-                    FileDialog dialog = new FileDialog(Display.getDefault().getActiveShell(), SWT.SHEET);
-                    File home = new File(proj.getLocation().toString(), PATH_BUILD_CONFIGS + File.separator + board + File.separator + PATH_OPENOCD_SCRIPT);
-                    dialog.setFilterPath(home.toString());
-                    dialog.setFilterExtensions(new String[] { "*.cfg" }); //$NON-NLS-1$
-                    debugCfg = dialog.open();
-                    if (debugCfg == null) {
-                        return;
-                    }
-                    update = true;
-                }
-
-                if (update) {
-                    debugInfo.setProperty(PROP_NAME_BOARD, board);
-                    debugInfo.setProperty(PROP_NAME_SCRIPT, debugCfg);
-                    try {
-                        debugInfo.store(new FileWriter(new File(outputPath, FILE_NAME_DEBUG_INFO)), PROP_COMMENT_DEBUG_INFO);
-                        update = false;
-                    } catch (IOException e) {
-                        logger.error(e.getMessage());
-                    }
+                    MessageDialog.openError(Display.getDefault().getActiveShell(), "Error", Messages.LaunchShortcut_NotFoundBuildInfo);
+                    return;
                 }
+                String board = buildInfo.getProperty(PROP_NAME_BOARD);
 
                 try {
-                    ILaunchConfiguration config = createConfiguration(proj.getName(), proj.getLocation(), board, debugCfg);
+                    ILaunchConfiguration config = createConfiguration(proj.getName(), proj.getLocation(), board);
                     if (config != null) {
                         DebugUITools.launch(config, mode);
                     }
index aed1282..556fe18 100644 (file)
@@ -35,7 +35,7 @@ import org.tizen.rt.ide.exception.MetaLoadException;
 import org.tizen.rt.ide.exception.MetaNotFoundException;
 import org.tizen.rt.product.meta.model.build.Build;
 import org.tizen.rt.product.meta.model.debug.Debugs;
-import org.tizen.rt.product.meta.model.flash.Flashes;
+import org.tizen.rt.product.meta.model.flash.Flash;
 import org.tizen.rt.product.meta.util.MetaModelUtil;
 import org.tizen.rt.product.meta.util.MetaModelUtil.MODEL_TYPE;
 import org.xml.sax.SAXException;
@@ -66,7 +66,7 @@ public class MetaManager implements IMetaConstants {
         }
     }
 
-    public static Flashes loadFlashMeta(IProject project, String board)
+    public static Flash loadFlashMeta(IProject project, String board)
             throws MetaNotFoundException, InvalidMetaException, MetaLoadException {
         // flashSpec.xml file load
         File metaFile = getMetaFile(project, board, FILE_NAME_FLASH_META_XML);
@@ -76,7 +76,7 @@ public class MetaManager implements IMetaConstants {
 
         try {
             // flashSpec.xml model load
-            Flashes model = MetaModelUtil.loadFlashModel(metaFile);
+            Flash model = MetaModelUtil.loadFlashModel(metaFile);
             return model;
         } catch (JAXBException e) {
             throw new MetaLoadException(e);