rm -rf ${INSTALL_DIR}/rt-ide/IDE.bat
rm -rf ${INSTALL_DIR}/rt-ide/eclipse.exe
cp -rf ${SRCDIR}/package/addingFiles/executable/windows/win32/eclipse_32.exe ${INSTALL_DIR}/rt-ide/eclipse.exe
- cp -rf ${SRCDIR}/resources/templates/* ${INSTALL_DIR}/rt-ide/resources/templates/
+ cp -rf ${SRCDIR}/resources/templates/* ${INSTALL_DIR}/platforms/tizen-rt/
+ cp -rf ${SRCDIR}/resources/scripts/* ${INSTALL_DIR}/rt-ide/resources/
;;
windows-64)
mv ${SRCDIR}/rt-ide/tizen.rt.product/target/products/org.tizen.rt.ide/win32/win32/x86_64/* ${INSTALL_DIR}
rm -rf ${INSTALL_DIR}/rt-ide/IDE.bat
rm -rf ${INSTALL_DIR}/rt-ide/eclipse.exe
cp -rf ${SRCDIR}/package/addingFiles/executable/windows/win64/eclipse_64.exe ${INSTALL_DIR}/rt-ide/eclipse.exe
- cp -rf ${SRCDIR}/resources/templates/* ${INSTALL_DIR}/rt-ide/resources/templates/
+ cp -rf ${SRCDIR}/resources/templates/* ${INSTALL_DIR}/platforms/tizen-rt/
+ cp -rf ${SRCDIR}/resources/scripts/* ${INSTALL_DIR}/rt-ide/resources/
;;
ubuntu-32)
mv ${SRCDIR}/rt-ide/tizen.rt.product/target/products/org.tizen.rt.ide/linux/gtk/x86/* ${INSTALL_DIR}
echo 'copied ${SRCDIR}/resources/templates to ${INSTALL_DIR}/platforms/tizen-rt/'
fi
+ if [ -d "${SRCDIR}/resources/scripts" ]; then
+ cp -rf ${SRCDIR}/resources/scripts ${INSTALL_DIR}/rt-ide/resources/
+ echo 'copied ${SRCDIR}/resources/scripts to ${INSTALL_DIR}/rt-ide/resources/'
+ fi
+
cp -rf ${SRCDIR}/lib/plugins/* ${INSTALL_DIR}/rt-ide/plugins/
if [ ! -d "${INSTALL_DIR}/tools" ]; then
echo 'copied ${SRCDIR}/resources/templates to ${INSTALL_DIR}/platforms/tizen-rt/'
fi
+ if [ -d "${SRCDIR}/resources/scripts" ]; then
+ cp -rf ${SRCDIR}/resources/scripts ${INSTALL_DIR}/rt-ide/resources/
+ echo 'copied ${SRCDIR}/resources/scripts to ${INSTALL_DIR}/rt-ide/resources/'
+ fi
+
cp -rf ${SRCDIR}/lib/plugins/* ${INSTALL_DIR}/rt-ide/plugins/
if [ ! -d "${INSTALL_DIR}/tools" ]; then
;;
macos-64)
mv ${SRCDIR}/rt-ide/tizen.rt.product/target/products/org.tizen.rt.ide/macosx/cocoa/x86_64/* ${INSTALL_DIR}
- cp -rf ${SRCDIR}/resources/templates/* ${INSTALL_DIR}/rt-ide/resources/templates/
+ cp -rf ${SRCDIR}/resources/templates/* ${INSTALL_DIR}/platforms/tizen-rt/
;;
esac
echo "Install Finished."
import java.io.FilenameFilter;
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.core.resources.IProject;
import org.slf4j.LoggerFactory;
import org.tizen.rt.ide.build.BuildOption;
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.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;
/**
* LinuxCommand
private static String LINUX_BUILD_RTOS_HOME_PATH = null;
- private static final String PATH_LINUX_BUILD_OS_HOME = "os"; //$NON-NLS-1$
- private static final String PATH_LINUX_BUILD_TOOLS = "os/tools"; //$NON-NLS-1$
+ // private static final String PATH_LINUX_BUILD_OS_HOME = "os"; //$NON-NLS-1$
+ // private static final String PATH_LINUX_BUILD_TOOLS = "os/tools"; //$NON-NLS-1$
private static final String PATH_LINUX_BUILD_OUTPUT = "build/output"; //$NON-NLS-1$
- private static final String LINUX_EXECUTE_SET_BUILD_OPTION = "./configure.sh"; //$NON-NLS-1$
- private static final String[] LINUX_EXECUTE_SETENV = new String[] {".", "./setenv.sh"}; //$NON-NLS-1$
- private static final String LINUX_EXECUTE_BUILD = "make"; //$NON-NLS-1$
+ // private static final String LINUX_EXECUTE_SET_BUILD_OPTION = "./configure.sh"; //$NON-NLS-1$
+ // private static final String[] LINUX_EXECUTE_SETENV = new String[] { ".", "./setenv.sh" }; //$NON-NLS-1$
+ // private static final String LINUX_EXECUTE_BUILD = "make"; //$NON-NLS-1$
private static final String PROP_NAME_OPTION = "option"; //$NON-NLS-1$
private static final String PROP_NAME_BOARD = "board"; //$NON-NLS-1$
private static final String FILE_NAME_DEFCONFIG = "defconfig"; //$NON-NLS-1$
private static final String PATH_BUILD_CONFIGS = "build/configs"; //$NON-NLS-1$
+ private static final String FILE_NAME_BUILD_SCRIPT = "build.xml"; //$NON-NLS-1$
private static final String FILE_NAME_BUILD_INFO = "build.info"; //$NON-NLS-1$
private static final String PROP_COMMENT_DEBUG_INFO = "TinyARA Debug information"; //$NON-NLS-1$
return buildOptionList;
}
+ private class BuildScript {
+ public String cmdStr;
+ public String curDir;
+ public boolean isShellCmd;
+ public String shell;
+
+ public BuildScript(String cmdStr, String curDir, boolean isShellCmd, String shell) {
+ this.cmdStr = cmdStr;
+ this.curDir = curDir;
+ this.isShellCmd = isShellCmd;
+ this.shell = shell;
+ }
+ }
+
+ private Map<String, BuildScript> getBuildScripts(File buildScriptFile, Map<String, String> macros) {
+ 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");
+ cmd = MacroUtil.processMacro(cmd, macros);
+ String curdir = elm.getAttribute("curdir");
+ curdir = MacroUtil.processMacro(curdir, macros);
+ 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;
+ }
+
protected int executeBuild(BuildOption buildOption, String toolchainPath, ConsoleManager consoleManager,
IProgressMonitor monitor) {
- String homePath = LINUX_BUILD_RTOS_HOME_PATH + File.separator + PATH_LINUX_BUILD_OS_HOME;
- String toolPath = LINUX_BUILD_RTOS_HOME_PATH + File.separator + PATH_LINUX_BUILD_TOOLS;
+ String homePath = LINUX_BUILD_RTOS_HOME_PATH;
String outputPath = LINUX_BUILD_RTOS_HOME_PATH + File.separator + PATH_LINUX_BUILD_OUTPUT;
+ String sdkPath = SDKUtil.getSdkPath();
+ File buildScriptFile = new File(sdkPath, "rt-ide" + File.separator + "resources" + File.separator + "scripts" + File.separator + FILE_NAME_BUILD_SCRIPT);
+ if (!buildScriptFile.exists()) {
+ buildScriptFile = new File(homePath, FILE_NAME_BUILD_SCRIPT);
+ if (!buildScriptFile.exists()) {
+ return 1;
+ }
+ }
+
+ Map<String, String> macros = new HashMap<String, String>();
+ macros.put("PROJECT_PATH", homePath);
+ macros.put("BOARD", buildOption.getBoard());
+ macros.put("BUILD_OPTION", buildOption.getBuildOption());
+ if (toolchainPath != null && !toolchainPath.isEmpty()) {
+ macros.put("TOOLCHAIN_PATH", toolchainPath);
+ }
+
+ consoleManager.println("Build project using " + buildScriptFile);
+
+ Map<String, BuildScript> scripts = getBuildScripts(buildScriptFile, macros);
+
ProcessBuilder pb = ProcUtil.genProcessBuilder(null);
- int result = ProcUtil.executeProcess(pb, new String[] { LINUX_EXECUTE_SET_BUILD_OPTION, buildOption.getBoard()
- + File.separator + buildOption.getBuildOption() },
- toolPath, consoleManager, resultBuildExecute);
+ String buildCmdName = "config";
+ BuildScript script = scripts.get(buildCmdName);
+ if (script == null) {
+ consoleManager.println("Cannot found build command : " + buildCmdName);
+ return 1;
+ }
+ int result = ProcUtil.executeProcess(pb, new String[] { script.cmdStr }, script.isShellCmd, script.shell,
+ script.curDir, consoleManager, resultBuildExecute);
+
monitor.worked(1);
if (result != 0) {
return result;
}
if (toolchainPath != null && !toolchainPath.isEmpty()) {
- result = ProcUtil.executeProcess(pb, new String[] { LINUX_EXECUTE_SETENV[0], LINUX_EXECUTE_SETENV[1], toolchainPath },
- toolPath, consoleManager, resultBuildExecute);
- monitor.worked(1);
- if (result != 0) {
- return result;
- }
+ buildCmdName = "buildWithToolchain";
+ } else {
+ buildCmdName = "build";
+ }
+ script = scripts.get(buildCmdName);
+ if (script == null) {
+ consoleManager.println("Cannot found build command : " + buildCmdName);
+ return 1;
}
+ result = ProcUtil.executeProcess(pb, new String[] { script.cmdStr }, script.isShellCmd, script.shell,
+ script.curDir, consoleManager, resultBuildExecute);
- result = ProcUtil.executeProcess(pb, new String[] { LINUX_EXECUTE_BUILD, "V=1" }, homePath, //$NON-NLS-1$
- consoleManager, resultBuildExecute);
monitor.worked(1);
if (result != 0) {
return result;
protected static final Logger logger = LoggerFactory.getLogger(ProcUtil.class);
- private static final String SHELL_COMMAND_LINUX = "/bin/bash"; //$NON-NLS-1$
+ private static final String SHELL_COMMAND_LINUX = "/bin/sh"; //$NON-NLS-1$
private static final String SHELL_COMMAND_MINGW = "sh"; //$NON-NLS-1$
private static final String SHELL_COMMAND_LINUX_PARAM = "-c"; //$NON-NLS-1$
private static final String SHELL_COMMAND_WINDOW = "cmd"; //$NON-NLS-1$
private static final String SHELL_WIN_PATH_NAME = "Path"; //$NON-NLS-1$
private static final int CMDLINEMAX = 65535;
- public static String[] getCommand(String commands[], boolean isLinux) {
+ public static String[] getCommand(String commands[], boolean shellCmd, String shell, boolean isLinux) {
+ if (!shellCmd) {
+ return commands;
+ }
+
String[] fullCommand;
+ if (shell == null || shell.isEmpty()) {
+ shell = SHELL_COMMAND_LINUX;
+ }
if (OSChecker.isWindows()) {
if (isLinux) {
}
} else {
fullCommand = new String[2 + 1];
- fullCommand[0] = SHELL_COMMAND_LINUX;
+ fullCommand[0] = shell;
fullCommand[1] = SHELL_COMMAND_LINUX_PARAM;
// System.arraycopy(commands, 0, fullCommand, 2, commands.length);
String st = ""; //$NON-NLS-1$
return pb;
}
- public static int executeProcess(ProcessBuilder pb, String[] cmds, String curDir, ConsoleManager consoleManager,
+ public static int executeProcess(ProcessBuilder pb, String[] cmds, boolean isShellCmd, String shell, String curDir, ConsoleManager consoleManager,
List<String> resultBuildExecute) {
- String sbiTrace = "[SBI] command : "; //$NON-NLS-1$
+ String sbiTrace = "[Command]"; //$NON-NLS-1$
for (String c : cmds) {
- sbiTrace += c + " "; //$NON-NLS-1$
+ sbiTrace += " " + c; //$NON-NLS-1$
}
logger.info(sbiTrace);
+ if (consoleManager != null) {
+ consoleManager.println(sbiTrace);
+ }
pb = genProcessBuilder(pb);
- cmds = getCommand(cmds, false);
+ cmds = getCommand(cmds, isShellCmd, shell, false);
pb.command(cmds);
pb.redirectErrorStream(true);
if (curDir != null) {
proc.waitFor();
} catch (IOException e) {
logger.error("IOException occurred:", e); //$NON-NLS-1$
+ consoleManager.println(e.getMessage());
return -1;
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
return proc.exitValue();
}
+ public static int executeProcess(ProcessBuilder pb, String[] cmds, boolean isShellCmd, String curDir, ConsoleManager consoleManager,
+ List<String> resultBuildExecute) {
+ return executeProcess(pb, cmds, isShellCmd, null, curDir, consoleManager, resultBuildExecute);
+ }
}