org.tizen.common.verrari,
org.tizen.common.verrari.realm
Import-Package:
- org.eclipse.osgi.util;version="1.1.0",
- org.tizen.common.sign.command,
- org.tizen.common.sign.preferences,
- org.tizen.nativecommon.build,
- org.tizen.nativecommon.build.exception,
- org.tizen.sdblib,
- org.tizen.sdblib.service,
- org.tizen.web.apptemplate.model,
- org.tizen.web.builder,
- org.tizen.web.builder.exception,
- org.tizen.web.common,
- org.tizen.web.config.schema.model,
- org.tizen.web.model,
- 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.eclipse.cdt.core.templateengine,
org.eclipse.cdt.core.templateengine.process.processes,
org.eclipse.cdt.managedbuilder.core,
org.eclipse.cdt.ui.templateengine,
+ org.eclipse.osgi.util;version="1.1.0",
+ org.tizen.common.sign.command,
+ org.tizen.common.sign.preferences,
org.tizen.nativeappcommon.templateengine,
org.tizen.nativeappcommon.wizards,
org.tizen.nativecommon,
+ org.tizen.nativecommon.build,
+ org.tizen.nativecommon.build.exception,
+ org.tizen.nativecommon.build.model,
org.tizen.nativecommon.exception,
org.tizen.nativecommon.templateengine,
org.tizen.nativecommon.templateengine.build,
org.tizen.nativecommon.templateengine.util,
org.tizen.nativecpp.templateengine,
org.tizen.nativecpp.wizards,
- org.tizen.nativecpp.wizards.build
+ org.tizen.nativecpp.wizards.build,
+ org.tizen.sdblib,
+ org.tizen.sdblib.service,
+ org.tizen.web.apptemplate.model,
+ org.tizen.web.builder,
+ org.tizen.web.builder.exception,
+ org.tizen.web.common,
+ org.tizen.web.config.schema.model,
+ org.tizen.web.model,
+ org.tizen.web.project.configuration,
+ org.tizen.web.project.wizard.model,
+ org.tizen.web.project.wizard.operation,
+ org.tizen.web.project.wizard.ui.commandbar
import org.tizen.ncli.core.TizenSubCommand;
import org.tizen.ncli.ide.subcommands.PackageCLICommand;
import org.tizen.ncli.ide.subcommands.PackageCLICommandData;
+import org.tizen.ncli.ide.subcommands.PackageNativeCLICommand;
+import org.tizen.ncli.ide.subcommands.PackageNativeCLICommandData;
@TizenSubCommand(name = "package", usage = "Package tizen project")
public class PackageCLI extends AbstractCLI
{
private Logger log = LoggerFactory.getLogger(getClass());
-
- @Option(name = "--type", metaVar = "tpk | wgt", usage = "packaging type")
+
+ @Option(name = "--type", required = true, metaVar = "tpk | wgt", usage = "packaging type")
private String type;
@Option(name = "--sign", usage = "Specify profile name")
public void execute()
{
log.trace("Execute PackageCLI...");
- PackageCLICommand packageCommand = new PackageCLICommand();
-
- log.trace("getRealWorkingPath: {}",getRealWorkingPath());
- packageCommand.setWorkingDir(getRealWorkingPath());
-
- PackageCLICommandData data = null;
+ log.trace("getRealWorkingPath: {}", getRealWorkingPath());
+
if (type.equals("wgt"))
{
- data = packageCommand.runCommand();
+ PackageCLICommand packageCommand = new PackageCLICommand();
+ packageCommand.setWorkingDir(getRealWorkingPath());
+ PackageCLICommandData data = packageCommand.runCommand();
+ if (null != data)
+ {
+ String wgtPath = data.getWgtPath();
+ if (null != wgtPath)
+ progressLog.info("Package File Location: {}", data.getWgtPath());
+ }
}
else if (type.equals("tpk"))
{
- // todo
- }
- if (null != data)
- {
- String wgtPath = data.getWgtPath();
- if (null != wgtPath)
- progressLog.info("Package File Location: {}", data.getWgtPath());
+ PackageNativeCLICommand nativePackageCommand = new PackageNativeCLICommand();
+ nativePackageCommand.setWorkingDir(getRealWorkingPath());
+ PackageNativeCLICommandData nativeData = nativePackageCommand.runCommand();
+ if (null != nativeData)
+ {
+ String tpkPath = nativeData.getTpkPath();
+ if (null != tpkPath)
+ progressLog.info("Package File Location: {}", nativeData.getTpkPath());
+ }
}
}
--- /dev/null
+package org.tizen.ncli.ide.subcommands;
+
+import java.io.File;
+import java.io.IOException;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.util.FileUtil;
+import org.tizen.common.util.HostUtil;
+import org.tizen.common.util.OSChecker;
+import org.tizen.nativecommon.build.SmartBuildInterface;
+import org.tizen.nativecommon.build.exception.SBIException;
+import org.tizen.nativecommon.build.model.SBIModel;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class PackageNativeCLICommand extends AbstractSubCommand<PackageNativeCLICommandData>
+{
+ private static final String PATH_SBI = FileUtil.appendPath(InstallPathConfig.getSDKPath(), "tools/smart-build-interface/bin");
+ private static final String CMD_CLI_NATIVE_PACK_LINUX = FileUtil.appendPath(PATH_SBI, "sbi");
+ private static final String CMD_CLI_NATIVE_PACK_WINDOWS = FileUtil.appendPath(PATH_SBI, "sbi.bat");
+
+ protected PackageNativeCLICommandData data = new PackageNativeCLICommandData();
+
+ protected SmartBuildInterface sbi;
+
+ protected String cprojectPath;
+ protected String projectFilePath;
+ protected String manifestPath;
+
+ protected Document projectDoc;
+ protected Document cprojectDoc;
+ protected Document manifestDoc;
+
+ protected String projectPath;
+ protected String activceConfiguration;
+ protected String workingProjectConfigurationPath;
+
+ protected String targetID;
+ protected String arch;
+ protected String packageType = "TPK";
+ protected String projectName;
+ protected String packageName;
+ protected String version;
+
+ XPath xpath = XPathFactory.newInstance().newXPath();
+
+ @Override
+ protected PackageNativeCLICommandData call()
+ {
+ if (!setEnv())
+ return null;
+
+ sbi = SmartBuildInterface.getInstance();
+
+ // create documents
+ cprojectDoc = getDocument(cprojectPath);
+ projectDoc = getDocument(projectFilePath);
+ manifestDoc = getDocument(manifestPath);
+
+ // create command
+ String option = getPackageOption();
+ String command = getCLICommand() + getSBIAction(targetID) + option;
+ progressLog.info("COMMAND = " + command);
+
+ // run command
+ progressLog.info(HostUtil.returnExecute(command));
+
+ // set TPK path
+ setTpkPath();
+
+ return data;
+ }
+
+ public void setConfiguration(String configuration)
+ {
+ activceConfiguration = configuration;
+ }
+
+ private boolean setEnv()
+ {
+
+ // set project path
+ try
+ {
+ workingProjectConfigurationPath = workingDir.getCanonicalPath();
+ activceConfiguration = workingDir.getName();
+ projectPath = workingDir.getParentFile().getCanonicalPath();
+
+ log.debug("Base project directory: {}", projectPath);
+
+ // set .project .cproject .manifest file path
+ cprojectPath = projectPath + File.separatorChar + ".cproject";
+ if (!new File(cprojectPath).isFile())
+ {
+ progressLog.error("Not found Tizen native project");
+ return false;
+ }
+
+ projectFilePath = projectPath + File.separatorChar + ".project";
+ manifestPath = projectPath + File.separatorChar + "manifest.xml";
+
+ return true;
+ } catch (IOException e)
+ {
+ log.error("Error occured during setting working directory", e.getMessage());
+ }
+ return false;
+ }
+
+ private void setTpkPath()
+ {
+ String tpkPath = workingProjectConfigurationPath + File.separatorChar + packageName + "-" + version + "-" + arch + ".tpk";
+ data.setTpkPath(tpkPath);
+ log.debug("Package path: {}", tpkPath);
+ }
+
+ // private void setWorkingProjectConfigurationPath(String projectPath)
+ // {
+ // if (new File(projectPath + File.separatorChar + "Debug").isDirectory())
+ // workingProjectConfigurationPath = projectPath + File.separatorChar +
+ // "Debug";
+ // else if (new File(projectPath + File.separatorChar +
+ // "Release").isDirectory())
+ // workingProjectConfigurationPath = projectPath + File.separatorChar +
+ // "Release";
+ // else if (new File(projectPath + File.separatorChar +
+ // "Dynamic Analyzer").isDirectory())
+ // workingProjectConfigurationPath = projectPath + File.separatorChar +
+ // "Dynamic Analyzer";
+ // }
+
+ private String getCLICommand()
+ {
+ if (OSChecker.isWindows())
+ {
+ return CMD_CLI_NATIVE_PACK_WINDOWS;
+ }
+ else
+ {
+ return CMD_CLI_NATIVE_PACK_LINUX;
+ }
+ }
+
+ private String getSBIAction(String targetId)
+ {
+ return String.format(" action %s -- buildpackage", targetId);
+ }
+
+ public String getPackageOption()
+ {
+ targetID = getTargetID(cprojectDoc);
+ String options = null;
+
+ try
+ {
+ options = String.format(" -BUILD_DIR=\"%s\"" + //$NON-NLS-1$
+ " -ARCH=%s" + //$NON-NLS-1$
+ " -PKG_TYPE=%s" + //$NON-NLS-1$
+ " -PKG_NAME=%s" + //$NON-NLS-1$
+ " -PRJ_NAME=%s" + //$NON-NLS-1$
+ " -ARTIFACT_NAME=%s" + //$NON-NLS-1$
+ " -PKG_VER=%s", //$NON-NLS-1$
+
+ workingProjectConfigurationPath, arch = SBIModel.getBaseArchName(sbi.getRootstrapArchitecture(targetID)), packageType, packageName = getPackageName(manifestDoc), projectName = getProjectName(projectDoc), projectName, version = getVersion(manifestDoc));
+ } catch (SBIException e)
+ {
+ e.printStackTrace();
+ }
+ return options;
+ }
+
+ // get document from xml file path
+ private Document getDocument(String path)
+ {
+ File cprojectFile = new File(path);
+ try
+ {
+ // create document
+ Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(cprojectFile);
+ return document;
+ } catch (SAXException e)
+ {
+ e.printStackTrace();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ } catch (ParserConfigurationException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ // get target id from document
+ private String getTargetID(Document doc)
+ {
+ try
+ {
+ String query = "//*[@superClass='sbi.gnu.cpp.compiler.option']";
+ Node superClassNode = (Node) xpath.evaluate(query, doc, XPathConstants.NODE);
+
+ NodeList list = superClassNode.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ // get node from node list
+ Node node = list.item(i);
+ if ("listOptionValue".equals(node.getNodeName()))
+ {
+ Node valueNode = node.getAttributes().getNamedItem("value");
+ targetID = valueNode.getNodeValue();
+ return targetID;
+ }
+ }
+ } catch (XPathExpressionException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ // get project name from document
+ private String getProjectName(Document doc)
+ {
+ try
+ {
+ String query = "//projectDescription/name";
+ NodeList nameNodeList = (NodeList) xpath.evaluate(query, doc, XPathConstants.NODESET);
+
+ if (nameNodeList.item(0) != null)
+ return nameNodeList.item(0).getTextContent();
+
+ } catch (XPathExpressionException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ // get package name from document
+ private String getPackageName(Document doc)
+ {
+ try
+ {
+ String query = "//Manifest/Id";
+ NodeList nameNodeList = (NodeList) xpath.evaluate(query, doc, XPathConstants.NODESET);
+
+ if (nameNodeList.item(0) != null)
+ return nameNodeList.item(0).getTextContent();
+
+ } catch (XPathExpressionException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private String getVersion(Document doc)
+ {
+ try
+ {
+ String query = "//Manifest/Version";
+ NodeList nameNodeList = (NodeList) xpath.evaluate(query, doc, XPathConstants.NODESET);
+
+ if (nameNodeList.item(0) != null)
+ return nameNodeList.item(0).getTextContent();
+
+ } catch (XPathExpressionException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+}