From 04158e8abd503cd1634c06e99386dbb08703b63f Mon Sep 17 00:00:00 2001 From: "hyunsik.noh" Date: Wed, 8 Jan 2014 14:06:36 +0900 Subject: [PATCH] CLI: add BuildNativeData for buildnative. Change-Id: Id95f3723b564d8bd014fdc8e3f94ca915d2fb1b1 Signed-off-by: hyunsik.noh --- .../org/tizen/ncli/ide/shell/BuildNativeCLI.java | 8 +- .../tizen/ncli/ide/subcommands/BuildNative.java | 5 - .../{ => buildnative}/BuildNativeCLICommand.java | 237 ++++++++++----------- .../subcommands/buildnative/BuildNativeData.java | 134 ++++++++++++ .../subcommands/buildnative/BuildNativeOption.java | 75 +++++++ 5 files changed, 320 insertions(+), 139 deletions(-) delete mode 100644 org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNative.java rename org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/{ => buildnative}/BuildNativeCLICommand.java (75%) create mode 100644 org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeData.java create mode 100644 org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeOption.java diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/BuildNativeCLI.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/BuildNativeCLI.java index cfce137..46a4b3c 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/BuildNativeCLI.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/BuildNativeCLI.java @@ -28,8 +28,8 @@ import org.kohsuke.args4j.Option; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.tizen.ncli.core.TizenSubCommand; -import org.tizen.ncli.ide.subcommands.BuildNative; -import org.tizen.ncli.ide.subcommands.BuildNativeCLICommand; +import org.tizen.ncli.ide.subcommands.buildnative.BuildNativeCLICommand; +import org.tizen.ncli.ide.subcommands.buildnative.BuildNativeData; /** * @author Hyunsik Noh{@literal } (S-core) @@ -69,9 +69,9 @@ public class BuildNativeCLI extends AbstractCLI { command.setRequiredOptions(new String[]{architecture, compiler, configuration}); command.setPredefineOption(predefineOption); - BuildNative runCommand = command.runCommand(); + BuildNativeData data = command.runCommand(); } - + public boolean needPrintTime() { return true; } diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNative.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNative.java deleted file mode 100644 index 7db18ff..0000000 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNative.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.tizen.ncli.ide.subcommands; - -public class BuildNative { - -} diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNativeCLICommand.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeCLICommand.java similarity index 75% rename from org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNativeCLICommand.java rename to org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeCLICommand.java index 20d94ae..6e0ea65 100644 --- a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNativeCLICommand.java +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeCLICommand.java @@ -22,12 +22,10 @@ * Contributors: * - S-Core Co., Ltd */ -package org.tizen.ncli.ide.subcommands; +package org.tizen.ncli.ide.subcommands.buildnative; -import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; import java.util.List; import javax.xml.parsers.DocumentBuilderFactory; @@ -44,94 +42,50 @@ import org.eclipse.osgi.util.NLS; import org.tizen.common.core.application.InstallPathConfig; import org.tizen.common.util.FileUtil; import org.tizen.common.util.HostUtil; -import org.tizen.common.util.IOUtil; import org.tizen.common.util.StringUtil; import org.tizen.nativecommon.build.CommonConfigurationManager; import org.tizen.nativecommon.build.SmartBuildInterface; import org.tizen.nativecommon.build.exception.SBIException; -import org.tizen.ncli.ide.config.ConfigConstant; import org.tizen.ncli.ide.config.Configuration; import org.tizen.ncli.ide.messages.TizenCLIMessages; +import org.tizen.ncli.ide.subcommands.AbstractSubCommand; +import org.tizen.ncli.ide.subcommands.buildnative.BuildNativeOption.BuildNativeRequiredOption; import org.w3c.dom.Document; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -public class BuildNativeCLICommand extends AbstractSubCommand { +public class BuildNativeCLICommand extends AbstractSubCommand { private Configuration config; + private BuildNativeData data; private String predefineOption; private SmartBuildInterface sbi = null; - private boolean isOptionsOK = true; - private String cprojectPath = null; - private String binaryPath = null; - private final String binaryExt = ".exe"; - - private String idePath = null; - private String importPath = null; - private String buildPath = null; - private String dataPath = null; - - public String toolchainId = null; - public String platformId = null; - public String targetId = null; - - private String HEADLESS_CMD = "%s/eclipse -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild " - + "-import %s " - + "-build %s " - + "-data %s " - + "-Ea CLI=true " - + "-T org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler sbi.gnu.cpp.compiler.option=%s"; - - private enum BuildNativeOption { - architecture(new String[]{"x86", "arm"}, ConfigConstant.DEFAULT_BUILD_ARCHITECTURE), - compiler(new String[]{"gcc", "llvm"}, ConfigConstant.DEFAULT_BUILD_COMPILER), - configuration(new String[]{"Debug", "Release", "Dynamic Analyzer"}, ConfigConstant.DEFAULT_BUILD_CONFIGURATION); - - private String input; - private String[] candidates; - private String noValueMessage; - - private BuildNativeOption(String[] candidates, String key) { - this.candidates = candidates; - this.noValueMessage = NLS.bind(TizenCLIMessages.BN_CANNOT_FIND_DEFAULT_INFO_CONFIG, key); - } - } - //"emulator" means "x86" and "device" means "arm" at this time. - //use CommonConfigurationManager.ARCHGROUP_X86 or CommonConfigurationManager.ARCHGROUP_ARM later. - private String [][] rootstrapByArch = { - {BuildNativeOption.architecture.candidates[0], "emulator"}, - {BuildNativeOption.architecture.candidates[1], "device"} - }; - - private final String[][] cprojectCriteria = { - { "C++ Compiler", "sbi.gnu.cpp.compiler.option" }, - { "C Compiler", "sbi.gnu.c.compiler.option" } - }; public BuildNativeCLICommand() { config = new Configuration(); + data = new BuildNativeData(); } - private boolean validateOptions() { + private boolean validateRequiredOptions() { boolean result = true; - BuildNativeOption[] options = BuildNativeOption.values(); - BuildNativeOption option = null; - String input = null; + BuildNativeRequiredOption[] options = BuildNativeRequiredOption.values(); + BuildNativeRequiredOption option = null; + String value = null; String[] candidates = null; boolean isValid = false; for(int i = 0; i < options.length; i++) { isValid = false; option = options[i]; - input = option.input; - candidates = option.candidates; + value = option.getValue(); + candidates = option.getCandidates(); for(int j = 0; j < candidates.length; j++) { - if(input.equals(candidates[j])) { + if(value.equals(candidates[j])) { isValid = true; break; } @@ -149,58 +103,78 @@ public class BuildNativeCLICommand extends AbstractSubCommand { return result; } - private boolean makeCommand() { - boolean result = true; + private boolean setCommandArgs() { sbi = SmartBuildInterface.getInstance(); + + boolean result = true; + String importPath = null; + + data.setIdePath(InstallPathConfig.getSDKPath() + File.separatorChar + "ide"); - idePath = InstallPathConfig.getSDKPath() + File.separatorChar + "ide"; try { importPath = workingDir.getCanonicalPath(); + data.setImportPath(importPath); } catch (IOException e) { log.debug("IOException: " + e.getMessage()); } - String configuration = BuildNativeOption.configuration.input; - cprojectPath = importPath + File.separator + ".cproject"; + String configuration = BuildNativeRequiredOption.configuration.getValue(); + data.setCprojectPath(importPath + File.separator + BuildNativeData.CPROJECT_EXT); if(!isVaildImportPathAndConfiguration(importPath, configuration)) { result = false; } else { String projectName = StringUtil.getLastStringAfter(importPath, File.separator); - buildPath = projectName + File.separator + configuration; - binaryPath = importPath + File.separator + configuration + File.separator + projectName + binaryExt; + data.setBinaryPath(importPath + File.separator + configuration + File.separator + projectName + BuildNativeData.BIN_EXT); + + String buildPath = projectName + File.separator + configuration; + data.setBuildPath(buildPath); + File file = new File(buildPath); if (!file.exists()) { file.mkdir(); } String workParent = workingDir.getParent(); + String dataPath = null; if(workParent != null) { dataPath = workParent + File.separator + "headless"; } else { - dataPath = idePath + File.separator + "headless"; + dataPath = data.getIdePath() + File.separator + "headless"; } + data.setDataPath(dataPath); if(!getBuildTarget()) { log.debug(TizenCLIMessages.BN_CANNOT_CREATE_BUILD_TARGET); result = false; } else { - progressLog.info("[IMPORT PATH]: " + importPath); - progressLog.info("[IDE PATH]: " + idePath); - progressLog.info("[BUILD PATH]: " + buildPath); - progressLog.info("[DATA PATH]: " + dataPath); + progressLog.info("[IMPORT PATH]: " + data.getImportPath()); + progressLog.info("[IDE PATH]: " + data.getIdePath()); + progressLog.info("[BUILD PATH]: " + data.getBuildPath()); + progressLog.info("[DATA PATH]: " + data.getDataPath()); } } return result; } + private String makeBuildCommand(BuildNativeData data) { + String command = String.format(BuildNativeData.HEADLESS_CMD, data.getIdePath(), data.getImportPath(), data.getBuildPath(), data.getDataPath(), data.getTargetId()); + log.debug(command); + return command; + } + private boolean getBuildTarget() { boolean result = false; String archKey = null; - String architecture = BuildNativeOption.architecture.input; - String compiler = BuildNativeOption.compiler.input; - String configuration = BuildNativeOption.configuration.input; + String platformId = data.getPlatformId(); + String targetId = null; + String toolchainId = data.getToolchainId(); + + String architecture = BuildNativeRequiredOption.architecture.getValue(); + String compiler = BuildNativeRequiredOption.compiler.getValue(); + String configuration = BuildNativeRequiredOption.configuration.getValue(); - for(int i = 0; i < rootstrapByArch.length; i++) { - if(rootstrapByArch[i][0].equals(architecture)) { - archKey = rootstrapByArch[i][1]; + String[][] rootstraps = BuildNativeData.rootstrapByArch; + for(int i = 0; i < rootstraps.length; i++) { + if(rootstraps[i][0].equals(architecture)) { + archKey = rootstraps[i][1]; break; } } @@ -212,24 +186,27 @@ public class BuildNativeCLICommand extends AbstractSubCommand { continue; } else { platformId = rootstrap; + data.setPlatformId(platformId); progressLog.info("[PLATFORM ID]: " + platformId); } } } if(platformId != null) { - String artefactType = getArtefactType(importPath, configuration); + String artefactType = getArtefactType(data.getImportPath(), configuration); if(artefactType != null) { progressLog.info("[ARTEFACT TYPE]: " + artefactType); List toolchainList = CommonConfigurationManager.getToolchainList(platformId, artefactType); for(String toolchain: toolchainList) { if(toolchain.contains(compiler)) { toolchainId = toolchain; + data.setToolchainId(toolchainId); progressLog.info("[TOOLCHAIN ID]: " + toolchain); } } if(toolchainId != null) { targetId = platformId + "_" + toolchainId; + boolean isExist = false; List targets = sbi.getTargetList(); for (String target : targets) { @@ -241,6 +218,7 @@ public class BuildNativeCLICommand extends AbstractSubCommand { if(!isExist) { createTarget(targetId, platformId, toolchainId); } + data.setTargetId(targetId); result = true; } else { log.debug(TizenCLIMessages.BN_CANNOT_GET_TOOLCHAIN_ID); @@ -257,43 +235,13 @@ public class BuildNativeCLICommand extends AbstractSubCommand { return result; } - /* - * (non-Javadoc) - * - * @see org.tizen.ncli.ide.subcommands.AbstractSubCommand#call() - */ - @Override - protected BuildNative call() { - if(this.isOptionsOK) { - if(validateOptions()) { - if(makeCommand()) { - String command = String.format(HEADLESS_CMD, idePath, importPath, buildPath, dataPath, targetId); - log.debug(command); - HostUtil.executeWithLog(command, progressLog); - removeDataDir(); - if(isSuccessful()) { - setBuildTargetInfo(); - } - } else { - progressLog.info(TizenCLIMessages.BN_CANNOT_MAKE_BUILD_COMMAND); - } - } else { - progressLog.info(TizenCLIMessages.INVALID_ARGS); - return null; - } - } else { - progressLog.info(TizenCLIMessages.CANNOT_GET_OPTIONS); - } - return null; - } - private void removeDataDir() { - FileUtil.recursiveDelete(new File(dataPath)); + FileUtil.recursiveDelete(new File(data.getDataPath())); } private boolean isVaildImportPathAndConfiguration(String path, String configuration) { boolean result = false; - File cprojectFile = new File(cprojectPath); + File cprojectFile = new File(data.getCprojectPath()); if (cprojectFile.exists()) { String configurations = ""; @@ -320,13 +268,42 @@ public class BuildNativeCLICommand extends AbstractSubCommand { return result; } + /* + * (non-Javadoc) + * + * @see org.tizen.ncli.ide.subcommands.AbstractSubCommand#call() + */ + @Override + protected BuildNativeData call() { + if(data.hasRequiredOptions) { + if(validateRequiredOptions()) { + if(setCommandArgs()) { + String command = makeBuildCommand(data); + progressLog.info(HostUtil.returnExecute(command)); + removeDataDir(); + if(isSuccessful()) { + setBuildTargetInfo(); + } + } else { + progressLog.info(TizenCLIMessages.BN_CANNOT_MAKE_BUILD_COMMAND); + } + } else { + progressLog.info(TizenCLIMessages.INVALID_ARGS); + return null; + } + } else { + progressLog.info(TizenCLIMessages.CANNOT_GET_OPTIONS); + } + return data; + } + private void createTarget(String targetId, String rootstrapId, String toolchainId) throws SBIException { sbi.create(targetId, rootstrapId, toolchainId); } private String getArtefactType(String path, String configuration) { String type = null; - File cprojectFile = new File(cprojectPath); + File cprojectFile = new File(data.getCprojectPath()); if (!cprojectFile.exists()) { progressLog.info(NLS.bind(TizenCLIMessages.BN_CANNOT_FIND_CPROJECT, path)); @@ -358,11 +335,11 @@ public class BuildNativeCLICommand extends AbstractSubCommand { } private boolean setBuildTargetInfo() { - String path= importPath; - String configuration = BuildNativeOption.configuration.input; + String path= data.getImportPath(); + String configuration = BuildNativeRequiredOption.configuration.getValue(); - boolean[] setResult = { false, false }; - File cprojectFile = new File(cprojectPath); + boolean[] setResult = {false, false}; + File cprojectFile = new File(data.getCprojectPath()); if (!cprojectFile.exists()) { progressLog.info(NLS.bind(TizenCLIMessages.BN_CANNOT_FIND_CPROJECT, path)); @@ -384,12 +361,12 @@ public class BuildNativeCLICommand extends AbstractSubCommand { if (configuration.equals(value)) { while (index < 2) { if (toolNode == null) { - toolNode = findToolNode(node, cprojectCriteria[index][0]); + toolNode = findToolNode(node, BuildNativeData.CPROJECT_CRITERIA[index][0]); } if (node != null) { - setResult[index] = setTargetInfo(toolNode, "option", cprojectCriteria[index][1], targetId); + setResult[index] = setTargetInfo(toolNode, "option", BuildNativeData.CPROJECT_CRITERIA[index][1], data.getTargetId()); if (setResult[index] == false) { - log.debug(TizenCLIMessages.BN_CANNOT_SET_BUILD_TARGET + ": " + cprojectCriteria[index][1]); + log.debug(TizenCLIMessages.BN_CANNOT_SET_BUILD_TARGET + ": " + BuildNativeData.CPROJECT_CRITERIA[index][1]); progressLog.info(TizenCLIMessages.BN_CANNOT_SET_BUILD_TARGET); return false; } @@ -470,7 +447,7 @@ public class BuildNativeCLICommand extends AbstractSubCommand { private boolean isSuccessful() { boolean success = false; - File binFile = new File(binaryPath); + File binFile = new File(data.getBinaryPath()); if(binFile.exists()) { success = true; progressLog.info("Build Succeed"); @@ -505,7 +482,7 @@ public class BuildNativeCLICommand extends AbstractSubCommand { attributeMap = node.getAttributes(); Node valueNode = attributeMap.getNamedItem("value"); if(valueNode != null) { - valueNode.setNodeValue(targetId); + valueNode.setNodeValue(data.getTargetId()); log.debug(TizenCLIMessages.BN_SUCCESS_SET_TARGET_INFO); break; } @@ -527,22 +504,22 @@ public class BuildNativeCLICommand extends AbstractSubCommand { } public void setRequiredOptions(String [] input) { - String[] optionName= {"architecture", "compiler", "configuration"}; - String[] optionKey= {ConfigConstant.DEFAULT_BUILD_ARCHITECTURE, ConfigConstant.DEFAULT_BUILD_COMPILER, ConfigConstant.DEFAULT_BUILD_CONFIGURATION}; - BuildNativeOption[] options = BuildNativeOption.values(); - for(int i = 0; i < options.length; i++) { + BuildNativeRequiredOption[] requiredOptions = BuildNativeRequiredOption.values(); + for(int i = 0; i < requiredOptions.length; i++) { + BuildNativeRequiredOption requiredOption = requiredOptions[i]; String str = input[i]; if(str == null) { - progressLog.info(NLS.bind(TizenCLIMessages.BN_NO_BUILD_INPUT, optionName[i])); - str = config.getValue(optionKey[i]); + progressLog.info(NLS.bind(TizenCLIMessages.BN_NO_BUILD_INPUT, requiredOption.getName())); + //Try to read value from config file by key. + str = config.getValue(requiredOption.getKey()); } if(str == null) { - progressLog.info(options[i].noValueMessage); - isOptionsOK = false; + progressLog.info(requiredOption.getErrorMessage()); + data.hasRequiredOptions = false; } else { - progressLog.info("[" + optionName[i].toUpperCase() + "]: " + str); - options[i].input = str; + progressLog.info("[" + requiredOption.getName().toUpperCase() + "]: " + str); + requiredOption.setValue(str); } } } diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeData.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeData.java new file mode 100644 index 0000000..e56deaa --- /dev/null +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeData.java @@ -0,0 +1,134 @@ +/* + * IDE + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunsik Noh + * Hyeongseok Heo + * + * 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.ncli.ide.subcommands.buildnative; + +import org.tizen.ncli.ide.subcommands.buildnative.BuildNativeOption.BuildNativeRequiredOption; + +public class BuildNativeData { + + public static final String BIN_EXT = ".exe"; + public static final String CPROJECT_EXT = ".cproject"; + public static final String HEADLESS_CMD = "%s/eclipse -nosplash --launcher.suppressErrors -application org.eclipse.cdt.managedbuilder.core.headlessbuild " + + "-import %s " + + "-build %s " + + "-data %s " + + "-Ea CLI=true " + + "-T org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler sbi.gnu.cpp.compiler.option=%s"; + + public static String [][] rootstrapByArch = { + {BuildNativeRequiredOption.architecture.getCandidates()[0], "emulator"}, + {BuildNativeRequiredOption.architecture.getCandidates()[1], "device"} + }; + + public static final String[][] CPROJECT_CRITERIA = { + { "C++ Compiler", "sbi.gnu.cpp.compiler.option" }, + { "C Compiler", "sbi.gnu.c.compiler.option" } + }; + + public boolean hasRequiredOptions = true; + + private String cprojectPath = null; + private String binaryPath = null; + private String importPath = null; + private String buildPath = null; + private String dataPath = null; + + private String toolchainId = null; + private String platformId = null; + private String targetId = null; + private String idePath = null; + + public String getCprojectPath() { + return cprojectPath; + } + + public void setCprojectPath(String cprojectPath) { + this.cprojectPath = cprojectPath; + } + + public String getBinaryPath() { + return binaryPath; + } + + public void setBinaryPath(String binaryPath) { + this.binaryPath = binaryPath; + } + + public String getIdePath() { + return idePath; + } + + public void setIdePath(String idePath) { + this.idePath = idePath; + } + + public String getImportPath() { + return importPath; + } + + public void setImportPath(String importPath) { + this.importPath = importPath; + } + + public String getBuildPath() { + return buildPath; + } + + public void setBuildPath(String buildPath) { + this.buildPath = buildPath; + } + + public String getDataPath() { + return dataPath; + } + + public void setDataPath(String dataPath) { + this.dataPath = dataPath; + } + + public String getToolchainId() { + return toolchainId; + } + + public void setToolchainId(String toolchainId) { + this.toolchainId = toolchainId; + } + + public String getPlatformId() { + return platformId; + } + + public void setPlatformId(String platformId) { + this.platformId = platformId; + } + + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } +} diff --git a/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeOption.java b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeOption.java new file mode 100644 index 0000000..c272d26 --- /dev/null +++ b/org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/buildnative/BuildNativeOption.java @@ -0,0 +1,75 @@ +/* + * IDE + * + * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunsik Noh + * Hyeongseok Heo + * + * 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.ncli.ide.subcommands.buildnative; + +import org.eclipse.osgi.util.NLS; +import org.tizen.ncli.ide.config.ConfigConstant; +import org.tizen.ncli.ide.messages.TizenCLIMessages; + +public class BuildNativeOption { + + enum BuildNativeRequiredOption { + architecture("architecture", new String[]{"x86", "arm"}, ConfigConstant.DEFAULT_BUILD_ARCHITECTURE), + compiler("compiler", new String[]{"gcc", "llvm"}, ConfigConstant.DEFAULT_BUILD_COMPILER), + configuration("configuration", new String[]{"Debug", "Release", "Dynamic Analyzer"}, ConfigConstant.DEFAULT_BUILD_CONFIGURATION); + + private String name; + private String value; + private String[] candidates; + private String key; + private String noValueMessage; + + private BuildNativeRequiredOption(String name, String[] candidates, String key) { + this.name = name; + this.candidates = candidates; + this.key = key; + this.noValueMessage = NLS.bind(TizenCLIMessages.BN_CANNOT_FIND_DEFAULT_INFO_CONFIG, key); + } + + public void setValue(String value) { + this.value = value; + } + + public String getName() { + return name; + } + + public String getValue() { + return value; + } + + public String[] getCandidates() { + return candidates; + } + + public String getKey() { + return key; + } + + public String getErrorMessage() { + return noValueMessage; + } + } +} -- 2.7.4