org.tizen.web.project.configuration,
org.tizen.web.project.wizard.model,
org.tizen.web.project.wizard.operation,
- org.tizen.web.project.wizard.ui.commandbar
+ org.tizen.web.project.wizard.ui.commandbar,
+ org.eclipse.cdt.core.templateengine,
+ org.eclipse.cdt.core.templateengine.process.processes,
+ org.eclipse.cdt.managedbuilder.core,
+ org.eclipse.cdt.ui.templateengine,
+ org.tizen.nativeappcommon.templateengine,
+ org.tizen.nativeappcommon.wizards,
+ org.tizen.nativecommon,
+ org.tizen.nativecommon.exception,
+ org.tizen.nativecommon.templateengine,
+ org.tizen.nativecommon.templateengine.build,
+ org.tizen.nativecommon.templateengine.build.model,
+ org.tizen.nativecommon.templateengine.model,
+ org.tizen.nativecommon.templateengine.process,
+ org.tizen.nativecommon.templateengine.util,
+ org.tizen.nativecpp.templateengine,
+ org.tizen.nativecpp.wizards,
+ org.tizen.nativecpp.wizards.build
+
import java.util.List;
import org.tizen.nativecommon.build.exception.SBIException;
+import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommandData;
import org.tizen.ncli.ide.subcommands.CreateProjectCommandData;
public class TizenAutoComplete {
public static String[][] subCommands = {
{ "list", "target", "app" },
- { "create", "web-project nativ-project security-profile security-profile-item certificate" },
+ { "create", "web-project native-project security-profile security-profile-item certificate" },
{ "help", commands } };
public static String[][] options = {
architecture(options[1][0], "--arch", "x86 arm"),
compiler(options[1][0], "--compiler", "llvm gcc"),
configuration(options[1][0], "--configuration", "Debug Release DA"),
- template("-t");
+ webtemplate(optionsForSub[0][0], "-t", ""),
+ nativetemplate(optionsForSub[1][0], "-t", "");
private String mainCmd;
private String option;
case configuration:
suggestion = optionFortSuggestion.getSuggestion();
break;
- case template:
+ case webtemplate:
+ System.out.println("WEBTEMPLATE");
List<String> listResult = CreateProjectCommandData.getTemplateList();
for (String result : listResult) {
suggestion = suggestion + " " + result;
}
suggestion = suggestion.trim();
break;
- }
+ case nativetemplate:
+ System.out.println("NATIVEEMPLATE");
+ List<String> nativelistResult = CreateNativeProjectCommandData.getTemplateList();
+ for (String result : nativelistResult) {
+ suggestion = suggestion + " " + result;
+ }
+ suggestion = suggestion.trim();
+ break;
+ }
return suggestion;
}
}
package org.tizen.ncli.ide.shell;
+import java.io.File;
+import java.io.IOException;
+
+import org.kohsuke.args4j.Option;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+//import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
+import org.tizen.ncli.ide.subcommands.CreateNativeProjectCommand;
+
public class CreateNativeProjectCLI extends AbstractCLI
{
+ private Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Option(name = "-t", aliases = { "--type" }, usage = "Specify template name")
+ private String templateName;
+
+ @Option(name = "-n", aliases = { "--name" }, usage = "Specify project name")
+ private String projectName;
@Override
public void execute()
{
- // TODO Auto-generated method stub
+ CreateNativeProjectCommand nativeCommand = new CreateNativeProjectCommand();
+
+ // set template name
+ if (templateName != null)
+ {
+ nativeCommand.setTemplateName(templateName);
+ nativeCommand.setProjectName(templateName);
+ }
+
+ // set project name
+ if (projectName != null)
+ nativeCommand.setProjectName(projectName);
+
+ // set output directory
+ try
+ {
+ File outputDirectory = (workingDir != null ? workingDir : currentWorkspacePath);
+ nativeCommand.setOutputName(outputDirectory.getCanonicalPath() + File.separatorChar + nativeCommand.getProjectName());
+ } catch (IOException e)
+ {
+ logger.error(e.getMessage());
+ }
+ nativeCommand.runCommand();
+
+ System.out.println("Creating native project succeeded!");
}
}
--- /dev/null
+package org.tizen.ncli.ide.subcommands;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.core.templateengine.process.processes.Messages;
+import org.tizen.common.util.FileUtil;
+import org.tizen.nativeappcommon.wizards.TizenProjectWizard;
+import org.tizen.nativecommon.Activator;
+import org.tizen.nativecommon.exception.TizenProcessFailureException;
+import org.tizen.nativecommon.templateengine.TizenTemplateEngine;
+import org.tizen.nativecommon.templateengine.build.model.TargetModel;
+import org.tizen.nativecommon.templateengine.model.TizenTemplate;
+import org.tizen.nativecommon.templateengine.process.TizenProcessRunner;
+import org.tizen.nativecommon.templateengine.util.TemplateUtil;
+import org.tizen.nativecpp.wizards.TemplateTizenCppNewWizard;
+import org.tizen.nativecpp.wizards.build.ExpressProjectGenerator;
+
+public class CreateNativeProjectCommand extends AbstractSubCommand<CreateProjectCommandData>
+{
+ private CreateNativeProjectCommandData data = new CreateNativeProjectCommandData();
+
+ public void setTemplateName(String projectName)
+ {
+ this.data.setTemplateName(projectName);
+ }
+
+ public void getTemplateName()
+ {
+ this.data.getTemplateName();
+ }
+
+ public void setProjectName(String projectName)
+ {
+ this.data.setProjectName(projectName);
+ }
+
+ public String getProjectName()
+ {
+ return this.data.getProjectName();
+ }
+
+ public void setOutputName(String projectName)
+ {
+ this.data.setOutputName(projectName);
+ }
+
+ public String getOutputName()
+ {
+ return this.data.getOutputName();
+ }
+
+ /*
+ * create native project from template.
+ *
+ * 1. get template list
+ * 2. copy native project template
+ */
+
+ @Override
+ protected CreateProjectCommandData call()
+ {
+ progressLog.info("-----------------------------------------------------");
+ progressLog.info("Starting Tizen project creation:");
+ progressLog.info("-----------------------------------------------------");
+
+ // get template list
+ data.getTemplateList();
+
+ // copy native project template and generate .cproject and .project file
+ copyNativeProjectTemplate();
+
+ return null;
+ }
+
+ public void copyNativeProjectTemplate()
+ {
+
+ String templateName = data.getTemplateName();
+ String projectPath = data.getTizenNativeTemplateRootPath(templateName);
+ String projectName = data.getProjectName();
+ String destDir = data.getOutputName();
+
+ // initialize tizen template
+ TizenTemplate template = new TizenTemplate(new File(projectPath).getAbsolutePath(), projectName, new File(destDir).getAbsolutePath());
+ try
+ {
+ TizenTemplateEngine.createProject(template, new WebCLIProjectGenerator());
+ } catch (TizenProcessFailureException e)
+ {
+ log.error("Template is not created", e.getMessage());
+ }
+ }
+
+ class WebCLIProjectGenerator extends ExpressProjectGenerator
+ {
+ private static final String PACKAGE_PREFIX_TEMPLATE_PROCESS = Activator.PLUGIN_ID + ".templateengine.process";
+
+ private static final String TEMPLATE_EMULATOR_TARGET = "\t\t\t\t\t\t\t\t\t<listOptionValue builtIn=\"false\" value=\"%s\"/>";
+
+ private final String[] VALUESTORE_BUILD_APP = { "org.tizen.nativecpp.config.sbi.gcc45.app.debug", "org.tizen.nativecpp.config.sbi.gcc45.app.release", "org.tizen.nativecpp.config.sbi.gcc45.app.debug.da" };
+ private final String[] VALUESTORE_BUILD_SHARED = { "org.tizen.nativecpp.config.sbi.gcc45.so.debug", "org.tizen.nativecpp.config.sbi.gcc45.so.release" };
+ private final String[] VALUESTORE_BUILD_STATIC = { "org.tizen.nativecpp.config.sbi.gcc45.lib.debug", "org.tizen.nativecpp.config.sbi.gcc45.lib.release" };
+
+ private HashMap<String, String> BUILD_CONFIG_MAP = new HashMap<String, String>();
+
+ private final String[] FILENAME_BUILD_APP = { "app_debug", "release", "app_debug_da" };
+ private final String[] FILENAME_SHARED_APP = { "shared_debug", "shared_release" };
+ private final String[] FILENAME_STATIC_APP = { "static_debug", "static_release" };
+
+ private final String DIR_APP = "Executables" + File.separator + "EFLCApplicationTemplate";
+ private final String DIR_SHARED = "Libraries" + File.separator + "SLPSimpleSharedLibraryTemplate";
+ private final String DIR_STATIC = "Libraries" + File.separator + "SLPSimpleStaticLibraryTemplate";
+
+ private final String CPROJECT_TEMPLATE_FILE = ".cproject";
+ private final String PROJECT_TEMPLATE_FILE = ".project";
+
+ private String cProjectTemplatePath = "";
+ private String cProjectTemplateFilePath = "";
+ private String projectTemplateFilePath = "";
+
+ private ProjectGenUtil pg = new ProjectGenUtil();
+
+ public WebCLIProjectGenerator()
+ {
+ super();
+ }
+
+ // set default value used to make .cproject and .project file
+ @Override
+ public void pressDefaultPostValueStore(Map<String, String> valueStore, TizenTemplate template) throws TizenProcessFailureException
+ {
+ // put emulator target
+ TargetModel emulTarget = (TargetModel) template.getProperty(TizenTemplate.PROPERTY_KEY_EMUL_TARGET);
+ String emulTargetId = emulTarget.getId();
+ valueStore.put(TizenTemplateEngine.MACRO_EMULATOR_TARGET, String.format(TEMPLATE_EMULATOR_TARGET, emulTargetId));
+
+ // put project name
+ valueStore.put(TizenTemplateEngine.MACRO_PROJECTNAME, template.getProjectName());
+
+ super.pressDefaultPostValueStore(valueStore, template);
+ }
+
+ // create .cproject and .project file
+ @Override
+ public void createBuildFiles(Map<String, String> postValueStore, TizenTemplate template)
+ {
+ String projectType = (String) template.getProperty(TizenTemplate.PROPERTY_KEY_PROJECTTYPE);
+ String projectPath = template.getProjectPath();
+
+ setBuildConfigMap(projectType);
+ String tempDescriptionPath = FileUtil.appendPath(projectPath, TizenProjectWizard.FILENAME_C_PROJECT_DESCRIPTION + "temp");
+
+ try
+ {
+ // create .cproject
+ URL cPrjDesUrl = new File(cProjectTemplateFilePath).toURL();
+
+ if (cPrjDesUrl != null)
+ {
+ TemplateUtil.createReplaceableFile(cPrjDesUrl, tempDescriptionPath, BUILD_CONFIG_MAP);
+ }
+
+ TemplateUtil.createReplaceableFile(tempDescriptionPath, FileUtil.appendPath(projectPath, TizenProjectWizard.FILENAME_C_PROJECT_DESCRIPTION), postValueStore);
+
+ // create .project
+ URL prjDesUrl = new File(projectTemplateFilePath).toURL();
+
+ if (prjDesUrl != null)
+ {
+ TemplateUtil.createReplaceableFile(prjDesUrl, FileUtil.appendPath(projectPath, TizenProjectWizard.FILENAME_PROJECT_DESCRIPTION), postValueStore);
+ }
+ } catch (IOException e)
+ {
+ log.error("not crate build file", e.getMessage());
+ }
+ new File(tempDescriptionPath).delete();
+ }
+
+ public void setBuildConfigMap(String projectType)
+ {
+ String tempPath = pg.extractBuiltinJarFiles("templates" + File.separator + "Executables");
+ tempPath = tempPath.substring(0, tempPath.lastIndexOf(File.separator));
+ cProjectTemplatePath = tempPath.substring(0, tempPath.lastIndexOf(File.separator));
+
+ if (projectType.equals(TemplateTizenCppNewWizard.APP_PROJECT_TYPE))
+ {
+ readTemplateAndFillHashMap(VALUESTORE_BUILD_APP, FILENAME_BUILD_APP, cProjectTemplatePath + File.separator + DIR_APP);
+ cProjectTemplateFilePath = cProjectTemplatePath + File.separator + DIR_APP + File.separator + CPROJECT_TEMPLATE_FILE;
+ projectTemplateFilePath = cProjectTemplatePath + File.separator + DIR_APP + File.separator + PROJECT_TEMPLATE_FILE;
+ }
+ else if (projectType.equals(TemplateTizenCppNewWizard.SHARED_PROJECT_TYPE))
+ {
+ readTemplateAndFillHashMap(VALUESTORE_BUILD_SHARED, FILENAME_SHARED_APP, cProjectTemplatePath + File.separator + DIR_SHARED);
+ cProjectTemplateFilePath = cProjectTemplatePath + File.separator + FILENAME_SHARED_APP + File.separator + CPROJECT_TEMPLATE_FILE;
+ projectTemplateFilePath = cProjectTemplatePath + File.separator + FILENAME_SHARED_APP + File.separator + PROJECT_TEMPLATE_FILE;
+ }
+ else if (projectType.equals(TemplateTizenCppNewWizard.STATIC_PROJECT_TYPE))
+ {
+ readTemplateAndFillHashMap(VALUESTORE_BUILD_STATIC, FILENAME_STATIC_APP, cProjectTemplatePath + File.separator + DIR_STATIC);
+ cProjectTemplateFilePath = cProjectTemplatePath + File.separator + FILENAME_STATIC_APP + File.separator + CPROJECT_TEMPLATE_FILE;
+ projectTemplateFilePath = cProjectTemplatePath + File.separator + FILENAME_STATIC_APP + File.separator + PROJECT_TEMPLATE_FILE;
+ }
+ }
+
+ // read app, shared, static template used to create .cproject file
+ private void readTemplateAndFillHashMap(String[] valueStoreKey, String[] fileName, String parentPath)
+ {
+ String lastPath = null;
+ try
+ {
+ for (int i = 0; i < valueStoreKey.length; i++)
+ {
+ lastPath = parentPath + File.separator + fileName[i];
+ File file = new File(lastPath);
+ String fileContent = FileUtil.readTextFile(file, "UTF-8");
+ BUILD_CONFIG_MAP.put(valueStoreKey[i], fileContent);
+ }
+ } catch (Exception e)
+ {
+ }
+ }
+
+ public TizenProcessRunner getTemplateProcess(String templateId, TizenTemplate template) throws TizenProcessFailureException
+ {
+ String processResolvedName = PACKAGE_PREFIX_TEMPLATE_PROCESS + "." + FileUtil.getFileExtension(templateId);
+ ClassLoader cLoader = ClassLoader.getSystemClassLoader();
+
+ TizenProcessRunner runner = null;
+
+ try
+ {
+ Class<?> processClass = cLoader.loadClass(processResolvedName);
+ runner = (TizenProcessRunner) processClass.newInstance();
+ } catch (Exception e)
+ {
+ throw new TizenProcessFailureException(MessageFormat.format(Messages.getString("WebCLIProjectGenerator.EXCEPTION_CREATING_CLASS"), processResolvedName), e); //$NON-NLS-1$
+ }
+
+ runner.setTemplate(template);
+ return runner;
+ }
+ }
+}
--- /dev/null
+package org.tizen.ncli.ide.subcommands;
+
+import static org.tizen.web.common.WebConstant.WIDGET_CONFIGURATION_FILE;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
+import org.tizen.common.AppIdGenerator;
+import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.util.FileUtil;
+import org.tizen.nativeappcommon.templateengine.TizenTemplateProcessParser;
+import org.tizen.web.model.TizenModelFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class CreateNativeProjectCommandData
+{
+
+ private static final String PLATFORM_PATH = InstallPathConfig.getPlatformPath(null, null);
+ private static final String NATIVE_PROJECT_PATH = "samples" + File.separator + "native" + File.separator + "cpp" + File.separator + "Template" + File.separator + "Tizen Native";
+ private static final String TIZEN_NATIVE_APP_TEMPLATE_FILE = "sample.xml";
+ private static final String TIZEN_PROJECT_DESCRIPTION_FILE = ".tproject";
+ private static final String TIZEN_PROJECT_FOLDER = "project";
+
+ public static final String DEFAULT_TEMPLATE_NAME = "empty";
+ public static final String DEFAULT_PROJECT_NAME = "empty";
+
+ public static final Map<String, String> nativeProjects = new HashMap<String, String>();
+
+ private String templateName = DEFAULT_TEMPLATE_NAME;
+ private String projectName = DEFAULT_PROJECT_NAME;
+ private String outputName = "";
+
+ public static List<String> getTemplateList()
+ {
+ File root = new File(PLATFORM_PATH + File.separator + NATIVE_PROJECT_PATH);
+
+ List<File> fileArray = new ArrayList<File>();
+ List<String> fileNameArray = new ArrayList<String>();
+
+ try
+ {
+ fileArray = FileUtil.findFiles(root, TIZEN_NATIVE_APP_TEMPLATE_FILE, true);
+
+ for (File samplefile : fileArray)
+ {
+ TemplateDescriptor templateDesc = TizenTemplateProcessParser.createTemplateDesc(samplefile);
+ Element elementRoot = templateDesc.getRootElement();
+ Element slpPropertyElement = TizenTemplateProcessParser.getElementFromTag(elementRoot, TizenTemplateProcessParser.TAG_SLPPROPERTY);
+ slpPropertyElement = TizenTemplateProcessParser.getElementFromTag(slpPropertyElement, TizenTemplateProcessParser.TAG_PROPERTYGROUP);
+ // String templateName = TizenTemplateProcessParser.getTextContextFromElement(slpPropertyElement,TizenTemplateProcessParser.TAG_SAMPLE);
+ String templateName = samplefile.getParentFile().getName();
+ nativeProjects.put(templateName, samplefile.getParentFile().getAbsolutePath());
+ }
+
+ } catch (FileNotFoundException e)
+ {
+ }
+ return fileNameArray;
+ }
+
+ public void setOutputName(String outputName)
+ {
+ this.outputName = outputName;
+ }
+
+ public String getOutputName()
+ {
+ return outputName;
+ }
+
+ public void setProjectName(String projectName)
+ {
+ this.projectName = projectName;
+ }
+
+ public String getProjectName()
+ {
+ return projectName;
+ }
+
+ public void setTemplateName(String templateName)
+ {
+ this.templateName = templateName;
+ }
+
+ public String getTemplateName()
+ {
+ return templateName;
+ }
+
+ // get native template root path
+ public String getTizenNativeTemplateRootPath(String id)
+ {
+ return nativeProjects.get(id);
+ }
+
+ // get native project root path
+ public String getTizenNativeProjectRootPath(String id)
+ {
+ String TemplatePath = getTizenNativeTemplateRootPath(id);
+
+ return TemplatePath + File.separator + TIZEN_PROJECT_FOLDER;
+ }
+
+ // get native project template configuration path
+ public String getTizenNativeTemplateConfigFile(String id)
+ {
+ String TemplatePath = getTizenNativeTemplateRootPath(id);
+
+ return TemplatePath + File.separator + TIZEN_NATIVE_APP_TEMPLATE_FILE;
+ }
+
+ // get native project configuration path
+ public String getTizenNativeProjectConfigFile(String id)
+ {
+ String TemplatePath = getTizenNativeTemplateRootPath(id);
+
+ return TemplatePath + File.separator + WIDGET_CONFIGURATION_FILE;
+ }
+
+ // get native project configuration destination path
+ public String getDestTizenNativeProjectConfigFile()
+ {
+ return outputName + File.separator + WIDGET_CONFIGURATION_FILE;
+ }
+
+ // get project description file path
+ public String getDestTizenProjectDescriptionFile()
+ {
+ return outputName + File.separator + TIZEN_PROJECT_DESCRIPTION_FILE;
+ }
+
+}
ProfileInfo profileInfo = InstallPathConfig.getLatestProfileInfo();
// extract jar file contained built-in library
- String rootPath = pg.extractBuiltinJarFiles();
+ String rootPath = pg.extractBuiltinJarFiles(WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER);
// get library pool
libraryPool = new TizenTemplateLibrariesPool(profileInfo, rootPath);
}
- public String extractBuiltinJarFiles()
+ /* extract jar file and get the extracted folder path
+ * when jar file is already extracted in a folder, return the folder path.
+ * folder path has the name appended '_dir' to jar file name.
+ */
+
+ public String extractBuiltinJarFiles(String resource)
{
- URL url = getClass().getClassLoader().getResource(WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER);
+ URL url = getClass().getClassLoader().getResource(resource);
+
+ if(url == null){
+ logger.error("not found jar file");
+ return null;
+ }
+
String urlPath = url.getPath();
+
String templateLibPath = urlPath + File.separator;
// if the url is not expressed jar file
if(urlPath.contains("!"))
{
- String jarPath = urlPath.replaceAll("file:", "").substring(0, urlPath.lastIndexOf(WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER) - 7);
+ String urlPathTemp = urlPath.replaceAll("file:", "");
+ String jarPath = urlPathTemp.substring(0, urlPathTemp.lastIndexOf('!'));
String destDirPath = jarPath + "_dir";
- templateLibPath = destDirPath + File.separator + WebConstant.BUILTIN_TEMPLATE_LIBRARIES_FOLDER + File.separator;
+ templateLibPath = destDirPath + File.separator + resource + File.separator;
// make it if the destination directory is not created.
File destDirFile = new File(destDirPath);
org.tizen.common.sdblib_*
org.tizen.web.sign_*
org.tizen.nativecommon_*
- org.tizen.nativecpp.misc_*
+ org.tizen.nativecpp.misc_*
+ org.eclipse.cdt.ui_*
+ com.ibm.icu_*
+ org.tizen.nativeappcommon_*
+ org.tizen.nativecpp_*
+ org.tizen.nativecpp.template_*
"
for SRC in ${SRC_LIST}
do
TARGET=`find $ROOTDIR -name "${SRC}" | head -1`
- cp ${TARGET} ${NCLI_LIB}
+ cp -r ${TARGET} ${NCLI_LIB}
done
INCLUDING_LIB_SRC_LIST="