NCLI: modified messages 59/13059/1
authorhyunsik.noh <hyunsik.noh@samsung.com>
Wed, 27 Nov 2013 09:51:46 +0000 (18:51 +0900)
committerhyunsik.noh <hyunsik.noh@samsung.com>
Wed, 27 Nov 2013 09:51:46 +0000 (18:51 +0900)
Change to check all options and show messages.

Change-Id: Ib5afffdbdad65293d68d13c2b47d6a33cc70a7b6
Signed-off-by: hyunsik.noh <hyunsik.noh@samsung.com>
org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/messages/TizenCLIMessages.properties
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/BuildNativeCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/ListCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/shell/SignCLI.java
org.tizen.ncli.ide/src/org/tizen/ncli/ide/subcommands/BuildNativeCLICommand.java

index 629c90d..6a9b061 100644 (file)
@@ -8,7 +8,7 @@ public class TizenCLIMessages extends NLS {
     }
     //Common
     public static String CANNOT_READ_CPROJECT;
-    public static String CANNOT_SET_OPTIONS;
+    public static String CANNOT_GET_OPTIONS;
     
     public static String INVALID_ARG;
     public static String INVALID_ARGS;
@@ -22,13 +22,12 @@ public class TizenCLIMessages extends NLS {
     public static String BN_CANNOT_MAKE_BUILD_COMMAND;
     public static String BN_CANNOT_SET_BUILD_TARGET;
     public static String BN_CANNOT_WRITE_BUILD_TARGET_INFO;
+    public static String BN_CANNOT_FIND_DEFAULT_INFO_CONFIG;
     
 
     public static String BN_INVALID_CONFIGURATION;
 
-    public static String BN_NO_CONFIG_BUILD_ARCHITECTURE;
-    public static String BN_NO_CONFIG_BUILD_CONFIGURATION;
-    public static String BN_NO_CONFIG_BUILD_COMPILER;
+    public static String BN_NO_BUILD_INPUT;
     
     public static String BN_SUCCESS_SET_TARGET_INFO;
     
index 294aa2f..8e73694 100644 (file)
@@ -1,5 +1,5 @@
 CANNOT_READ_CPROJECT = Can not read the .cproject file.
-CANNOT_SET_OPTIONS = Can not set the options.
+CANNOT_GET_OPTIONS = Can not get the required options.
 
 INVALID_ARG = The {0} is an invalid argument\nTry to use one of {1}
 INVALID_ARGS = There are invalid arguments.
@@ -12,12 +12,11 @@ BN_CANNOT_GET_TOOLCHAIN_ID = Can not get the toolchain id.
 BN_CANNOT_MAKE_BUILD_COMMAND = Can not make the build command.
 BN_CANNOT_SET_BUILD_TARGET = Can not set the build target information.
 BN_CANNOT_WRITE_BUILD_TARGET_INFO = Can not write the build target information.
+BN_CANNOT_FIND_DEFAULT_INFO_CONFIG = Can not read the {0} value in config file.
 
 BN_INVALID_CONFIGURATION = The {0} is an invalid configuration\nTry to use one of {1}
 
-BN_NO_CONFIG_BUILD_ARCHITECTURE = There is no default architecture value in config file.
-BN_NO_CONFIG_BUILD_COMPILER = There is no default compiler value in config file.
-BN_NO_CONFIG_BUILD_CONFIGURATION = There is no default configuration value in config file.
+BN_NO_BUILD_INPUT = There is no {0} input. -> Try to find default value from config file.
 
 BN_SUCCESS_SET_TARGET_INFO = Success to write the build target information
 
index fcd09f5..a72d9c5 100644 (file)
@@ -38,10 +38,10 @@ import org.tizen.ncli.ide.subcommands.BuildNativeCLICommand;
 public class BuildNativeCLI extends AbstractCLI {\r
     private Logger log = LoggerFactory.getLogger(getClass());\r
 \r
-    @Option(name = "--arch", depends="--compiler", metaVar = "x86 | arm", usage = "Architecture for build result")\r
+    @Option(name = "--arch", metaVar = "x86 | arm", usage = "Architecture for build result")\r
     private String architecture;\r
 \r
-    @Option(name = "--compiler", depends="--arch", metaVar = "gcc | llvm", usage = "Compiler for build result")\r
+    @Option(name = "--compiler", metaVar = "gcc | llvm", usage = "Compiler for build result")\r
     private String compiler;\r
 \r
     @Option(name = "--configuration", metaVar = "Debug | Release | DA", usage = "Configuration for build result")\r
@@ -60,14 +60,13 @@ public class BuildNativeCLI extends AbstractCLI {
      */\r
     @Override\r
     public void execute() {\r
-        log.trace("Execute BuildWebCLI...");\r
+        log.trace("Execute BuildNativeCLI...");\r
 \r
         BuildNativeCLICommand command = new BuildNativeCLICommand();\r
 \r
         command.setWorkingDir(workingDir == null ? currentWorkspacePath : workingDir);\r
-        command.setArchitecture(architecture);\r
-        command.setCompiler(compiler);\r
-        command.setConfiguration(DA.equals(configuration) ? DA_ORIGIN : configuration);\r
+        configuration = DA.equals(configuration) ? DA_ORIGIN : configuration;\r
+        command.setRequiredOptions(new String[]{architecture, compiler, configuration});\r
         command.setPredefineOption(predefineOption);\r
 \r
         BuildNative runCommand = command.runCommand();\r
index 2590f6b..f11671d 100644 (file)
@@ -45,6 +45,7 @@ public class ListCLI extends AbstractCLI{
 
     @Override
     public void execute() {
+        log.trace("Execute ListCLI...");
         if( null != this.tizenCLI) {
             this.tizenCLI.execute();
         }
index a4b325f..51f3be8 100644 (file)
@@ -39,7 +39,7 @@ public class SignCLI extends AbstractCLI {
      */\r
     @Override\r
     public void execute() {\r
-        log.trace("Execute Signing...");\r
+        log.trace("Execute SignCLI...");\r
         \r
         SignCLICommand command = new SignCLICommand();\r
         \r
index 5ac1e4e..89fb659 100644 (file)
@@ -59,11 +59,9 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
     private Configuration config;
 
     private String predefineOption;
-    private String architecture;
-    private String compiler;
-    private String configuration;
     
     private SmartBuildInterface sbi = null;
+    private boolean isOptionsOK = true;
 
     private String idePath = null;
     private String importPath = null;
@@ -82,40 +80,24 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
             + "-T org.tizen.nativecpp.tool.sbi.gnu.cpp.compiler sbi.gnu.cpp.compiler.option=%s";
     
     private enum BuildNativeOption {
-        architecture(new String[]{"x86", "arm"}, TizenCLIMessages.BN_NO_CONFIG_BUILD_ARCHITECTURE),
-        compiler(new String[]{"gcc", "llvm"}, TizenCLIMessages.BN_NO_CONFIG_BUILD_COMPILER),
-        configuration(new String[]{"Debug", "Release", "Dynamic Analyzer"}, TizenCLIMessages.BN_NO_CONFIG_BUILD_CONFIGURATION);
+        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 noValueMessage) {
+        private BuildNativeOption(String[] candidates, String key) {
             this.candidates = candidates;
-            this.noValueMessage = noValueMessage;
-        }
-        
-        public void setInput(String option) {
-            this.input = option;
-        }
-        
-        public String getInput() {
-            return input;
-        }
-        
-        public String[] getCandidates() {
-            return candidates;
-        }
-        
-        public String getNoValueMessage() {
-            return noValueMessage;
+            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.getCandidates()[0], "emulator"},
-            {BuildNativeOption.architecture.getCandidates()[1], "device"}
+            {BuildNativeOption.architecture.candidates[0], "emulator"},
+            {BuildNativeOption.architecture.candidates[1], "device"}
     };
 
     private final String[][] cprojectCriteria = { 
@@ -126,53 +108,33 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
     public BuildNativeCLICommand() {
         config = new Configuration();
     }
-    private boolean setOptions() {
-        boolean result = true;
-        
-        BuildNativeOption[] options = BuildNativeOption.values();
-        BuildNativeOption option = null;
-        String input = null;
 
-        for(int i = 0; i < options.length; i++) {
-            option = options[i];
-            input = option.getInput();
-            if(input == null) {
-                System.out.println(option.getNoValueMessage());
-                result = false;
-                break;
-            }
-        }
-        return result;
-    }
-    
     private boolean validateOptions() {
         boolean result = true;
         
-        System.out.println("[ARCHITECTURE]: " + architecture);
-        System.out.println("[COMPILER]: " + compiler);
-        System.out.println("[CONFIGURATION]: " + configuration);
-        
         BuildNativeOption[] options = BuildNativeOption.values();
         BuildNativeOption option = null;
         String input = null;
         String[] candidates = null;
+        boolean isValid = false;
         
         for(int i = 0; i < options.length; i++) {
-            result = false;
+            isValid = false;
             option = options[i];
-            input = option.getInput();
-            candidates = option.getCandidates();
+            input = option.input;
+            candidates = option.candidates;
             for(int j = 0; j < candidates.length; j++) {
                 if(input.equals(candidates[j])) {
-                    result = true;
+                    isValid = true;
                     break;
                 }
             }
-            if(!result) {
+            if(!isValid) {
                 String suggestion = "";
                 for(int j = 0; j < candidates.length; j++) {
                     suggestion = suggestion + " \"" + candidates[j] + "\"";
                 }
+                result = false;
                 System.out.println(NLS.bind(TizenCLIMessages.INVALID_ARG, option, suggestion.trim()));
                 break;
             }
@@ -190,7 +152,7 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
         } catch (IOException e) {
             e.printStackTrace();
         }
-        
+        String configuration = BuildNativeOption.configuration.input;
         if(!isVaildImportPathAndConfiguration(importPath, configuration)) {
             result = false;
         } else {
@@ -217,6 +179,9 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
     private boolean getBuildTarget() {
         boolean result = false;
         String archKey = null;
+        String architecture = BuildNativeOption.architecture.input;
+        String compiler = BuildNativeOption.compiler.input;
+        String configuration = BuildNativeOption.configuration.input;
         
         for(int i = 0; i < rootstrapByArch.length; i++) {
             if(rootstrapByArch[i][0].equals(architecture)) {
@@ -237,7 +202,7 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
                 }
             }
             if(platformId != null) {
-                String artefactType = getArtifactType(importPath, configuration);
+                String artefactType = getArtefactType(importPath, configuration);
                 if(artefactType != null) {
                     System.out.println("[ARTEFACT TYPE]: " + artefactType);
                     List<String> toolchainList = CommonConfigurationManager.getToolchainList(platformId, artefactType);
@@ -284,13 +249,13 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
      */
     @Override
     protected BuildNative call() {
-        if(setOptions()) {
+        if(this.isOptionsOK) {
             if(validateOptions()) {
                 if(makeCommand()) {
                     String command = String.format(HEADLESS_CMD, idePath, importPath, buildPath, dataPath, targetId);
                     System.out.println(HostUtil.returnExecute(command));
                     // TODO: how to know building project works well?
-                    setBuildTargetInfo(importPath, configuration);
+                    setBuildTargetInfo();
                 } else {
                     System.out.println(TizenCLIMessages.BN_CANNOT_MAKE_BUILD_COMMAND);
                 }
@@ -299,9 +264,8 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
                 return null;
             }
         } else {
-            System.out.println(TizenCLIMessages.CANNOT_SET_OPTIONS);
+            System.out.println(TizenCLIMessages.CANNOT_GET_OPTIONS);
         }
-        
         return null;
     }
 
@@ -339,7 +303,7 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
         sbi.create(targetId, rootstrapId, toolchainId);
     }
 
-    private String getArtifactType(String path, String configuration) {
+    private String getArtefactType(String path, String configuration) {
         String type = null;
         String cprojectPath = path + "/" + ".cproject";
         File cprojectFile = new File(cprojectPath);
@@ -373,7 +337,10 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
         return type;
     }
 
-    private boolean setBuildTargetInfo(String path, String configuration) {
+    private boolean setBuildTargetInfo() {
+        String path= importPath;
+        String configuration = BuildNativeOption.configuration.input;
+        
         boolean[] setResult = { false, false };
         String cprojectPath = path + "/" + ".cproject";
         File cprojectFile = new File(cprojectPath);
@@ -530,28 +497,25 @@ public class BuildNativeCLICommand extends AbstractSubCommand<BuildNative> {
         return found;
     }
 
-    public void setArchitecture(String architecture) {
-        if(architecture == null) {
-            architecture = config.getValue(ConfigConstant.DEFAULT_BUILD_ARCHITECTURE); 
-        }
-        BuildNativeOption.architecture.setInput(architecture);
-        this.architecture = BuildNativeOption.architecture.getInput();
-    }
-
-    public void setCompiler(String compiler) {
-        if(compiler == null) {
-            compiler = config.getValue(ConfigConstant.DEFAULT_BUILD_COMPILER); 
-        }
-        BuildNativeOption.compiler.setInput(compiler);
-        this.compiler = BuildNativeOption.compiler.getInput();
-    }
-
-    public void setConfiguration(String configuration) {
-        if(configuration == null) {
-            configuration = config.getValue(ConfigConstant.DEFAULT_BUILD_CONFIGURATION); 
+    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++) {
+            String str = input[i];
+            if(str == null) {
+                System.out.println(NLS.bind(TizenCLIMessages.BN_NO_BUILD_INPUT, optionName[i]));
+                str = config.getValue(optionKey[i]);
+            }
+            if(str == null) {
+                System.out.println(options[i].noValueMessage);
+                isOptionsOK = false;
+            } else {
+                System.out.println("[" + optionName[i].toUpperCase() + "]: " + str);
+                options[i].input = str;
+            }
         }
-        BuildNativeOption.configuration.setInput(configuration);
-        this.configuration = BuildNativeOption.configuration.getInput();
     }
 
     public void setPredefineOption(String predefineOption) {