--- /dev/null
+/*
+* Native IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Ho Namkoong <ho.namkoong@samsung.com>
+* BonYong Lee <bonyong.lee@samsung.com>
+* Kangho Kim <kh5325.kim@samsung.com>
+*
+* 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.cli.exec.pack;
+
+import java.io.File;
+
+import org.tizen.common.core.command.Executor;
+import org.tizen.nativecommon.IXMLStore;
+import org.tizen.nativecommon.build.AbstractMultiPackager;
+import org.tizen.nativecpp.misc.core.NewAppXmlStore;
+import org.tizen.nativecpp.uibuilder.launcher.xml.ManifestXmlFile;
+
+public class CLIMultiPackager extends AbstractMultiPackager{
+
+ private static final String BIN_FOLDER_NAME = "CommandLineBuild";
+ private String rootPrjPath;
+ private String[] refPrjPath;
+
+
+ CLIMultiPackager(String rootPrjPath, String[] refPrjPath, Executor executor) {
+ super(executor);
+ this.rootPrjPath = rootPrjPath;
+ this.refPrjPath = refPrjPath;
+ }
+
+ @Override
+ protected String getBinaryFolder() {
+ return BIN_FOLDER_NAME;
+ }
+
+ @Override
+ protected void buildPrjs() throws Exception {
+ // TODO do later
+ }
+
+ @Override
+ protected String[] getRefPrjPaths() {
+ return refPrjPath;
+ }
+
+ @Override
+ protected String getRootPrjPath() {
+ return rootPrjPath;
+ }
+
+ @Override
+ protected boolean validateMultiPackage() {
+ File manifestFile = new File(rootPrjPath, ManifestXmlFile.MANIFEST_XML_FILE_NAME);
+ if(manifestFile.exists() || (refPrjPath != null && refPrjPath.length > 0)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ protected IXMLStore getIXmlStore() throws Exception {
+ return new NewAppXmlStore();
+ }
+
+}
--- /dev/null
+/*
+* Native IDE - Command Line Interface
+*
+* Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact:
+* Ho Namkoong <ho.namkoong@samsung.com>
+* BonYong Lee <bonyong.lee@samsung.com>
+* Kangho Kim <kh5325.kim@samsung.com>
+*
+* 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.cli.exec.pack;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.tizen.cli.exec.AbstractLauncher;
+import org.tizen.common.core.application.InstallPathConfig;
+import org.tizen.common.core.command.CommandCancelException;
+import org.tizen.common.util.FileUtil;
+import org.tizen.common.util.StringUtil;
+
+public class NativeMain extends AbstractLauncher{
+
+ private boolean printHelp = false;
+ private CommandLine cmdLine;
+
+ private static final String USAGE_PACK = "usage: native-packaging --sign-author-key <path> --sign-author-pwd <passwd> [OPTIONS]\nPackage a project\n\n";
+
+ private static final String PATH_SBI = FileUtil.appendPath(InstallPathConfig.getSDKPath(), "tools/smart-build-interface/bin");
+ private static final String CMD_CLI_NATIVE_PACK = FileUtil.appendPath(PATH_SBI, "sbi_pack");
+
+ private static final String OPTION_TARGET = "target";
+ private static final String OPTION_SIGN_AK = "sign-author-key";
+ private static final String OPTION_SIGN_APWD = "sign-author-pwd";
+ private static final String OPTION_SIGN_DK = "sign-dist2-key";
+ private static final String OPTION_SIGN_DPWD = "sign-dist2-pwd";
+ private static final String OPTION_SIGN_DCA = "sign-dist2-ca";
+ private static final String OPTION_SIGN_DROOT = "sign-dist2-root";
+ private static final String OPTION_REF_PROJECTS = "ref-prj";
+
+ private static final String DESC_TARGET = "Specify target. Emulator or device.";
+ private static final String DESC_SIGN_AK = "Specify author p12 file path.";
+ private static final String DESC_SIGN_APWD = "Specify author certificate password.";
+ private static final String DESC_SIGN_DK = "Specify distributor2 p12 file path.";
+ private static final String DESC_SIGN_DPWD = "Specify distributor2 password.";
+ private static final String DESC_SIGN_DCA = "Specify distributor2 CA path.";
+ private static final String DESC_SIGN_DROOT = "Specify distributor2 root certicate path";
+ private static final String DESC_REF_PROJECTS = "Specify paths of referenced projects. Paths can be seperator by ','";
+
+ private static final String[] OPTION_REMAINING = {
+ "sign_cert_dir", "sign_dist1_key", "sign_dist1_pwd", "sign_dist1_ca"
+ };
+
+ public static void main(String[] args) throws Exception {
+
+ final NativeMain instance = new NativeMain();
+
+ if(args.length == 0) {
+ instance.printHelp = true;
+ }
+
+ instance.run( args );
+ }
+
+ @Override
+ protected void execute(CommandLine cmdLine) throws Exception {
+
+ if(printHelp) {
+ printHelp();
+ return;
+ }
+
+ this.cmdLine = cmdLine;
+
+ logger.trace("get user input");
+
+ String rowRefPrjs = this.cmdLine.getOptionValue(OPTION_REF_PROJECTS);
+ String[] refPrjPaths = rowRefPrjs.split(",");
+
+ if(StringUtil.isEmpty(this.cmdLine.getOptionValue(OPTION_SIGN_AK)) ||
+ StringUtil.isEmpty(this.cmdLine.getOptionValue(OPTION_SIGN_APWD))) {
+ logger.error(String.format("--%s and --%s are mandatory options.", OPTION_SIGN_AK, OPTION_SIGN_APWD));
+ return;
+ }
+
+ CLIMultiPackager packager = new CLIMultiPackager("../", refPrjPaths, getExecutor());
+
+ try {
+ packager.doMultiPreProcess();
+ }
+ catch (CommandCancelException e) {
+ packager.removeMutilAppResources();
+ logger.error("Packaging canceld");
+ }
+
+ StringBuffer option = new StringBuffer();
+ appendOption(option, OPTION_TARGET);
+ appendOption(option, OPTION_SIGN_AK);
+ appendOption(option, OPTION_SIGN_APWD);
+ appendOption(option, OPTION_SIGN_DK);
+ appendOption(option, OPTION_SIGN_DPWD);
+ appendOption(option, OPTION_SIGN_DCA);
+ appendOption(option, OPTION_SIGN_DROOT);
+
+ appendRemaningOptions(option);
+
+ String command = CMD_CLI_NATIVE_PACK + option.toString();
+
+ Runtime.getRuntime().exec(command);
+// p.wait();
+
+ }
+
+ private void appendRemaningOptions(StringBuffer option) {
+ for(String remaningOption: OPTION_REMAINING) {
+ option.append(String.format(" --%s \" \"", remaningOption));
+ }
+ }
+
+ private void appendOption(StringBuffer option, String optionTarget) {
+ String optionValue = cmdLine.getOptionValue(optionTarget);
+ if(!StringUtil.isEmpty(optionValue)) {
+ option.append(String.format(" --%s \"%s\"", optionTarget, optionValue));
+ }
+ }
+
+ @Override
+ protected String printHelp() {
+ StringBuffer helpBuffer = new StringBuffer();
+ helpBuffer.append(USAGE_PACK);
+ helpBuffer.append(getHelp().getHelp());
+ String helpStr = helpBuffer.toString();
+ getPrompter().error(helpStr);
+ return helpStr;
+ }
+
+ @SuppressWarnings("static-access")
+ @Override
+ protected Options getOptions() {
+ Options result = super.getOptions();
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_TARGET).withDescription(DESC_TARGET).create("t"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SIGN_AK).withDescription(DESC_SIGN_AK).create("ak"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SIGN_APWD).withDescription(DESC_SIGN_APWD).create("ap"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SIGN_DK).withDescription(DESC_SIGN_DK).create("dk"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SIGN_DPWD).withDescription(DESC_SIGN_DPWD).create("dp"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SIGN_DCA).withDescription(DESC_SIGN_DCA).create("dc"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_SIGN_DROOT).withDescription(DESC_SIGN_DROOT).create("dr"));
+ result.addOption(OptionBuilder.hasArg().withLongOpt(OPTION_REF_PROJECTS).withDescription(DESC_REF_PROJECTS).create("rp"));
+
+ return result;
+ }
+
+}