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;
+ "-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 = {
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;
}
} catch (IOException e) {
e.printStackTrace();
}
-
+ String configuration = BuildNativeOption.configuration.input;
if(!isVaildImportPathAndConfiguration(importPath, configuration)) {
result = false;
} else {
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)) {
}
}
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);
*/
@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);
}
return null;
}
} else {
- System.out.println(TizenCLIMessages.CANNOT_SET_OPTIONS);
+ System.out.println(TizenCLIMessages.CANNOT_GET_OPTIONS);
}
-
return null;
}
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);
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);
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) {