--- /dev/null
+#!/bin/bash
+
+SIGNCOMMAND="web-signing"
+PACKCOMMAND="web-packaging"
+
+TEMPROOTPATH=".pack"
+FOLDER_LIST="
+setting
+data
+icons
+lib
+llvm
+res
+"
+DEBUG_FOLDER="Debug"
+RELEASE_FOLDER="Release"
+MANIFEST="manifest.xml"
+CONFIGURATION="config.xml"
+INFO_FOLDER="info"
+BIN_TARGET_FOLDER="bin"
+RES_FOLDER="res"
+WGT_FOLDER="wgt"
+
+#################
+## Check arguments
+
+function usage() {
+ echo "This is the hybrid app structure generator."
+ echo "A builded native project and a web project are required."
+ echo ""
+ echo "Usage : $ ${0} [native service project path] [web project path]"
+}
+
+if [ $# -lt 2 ]; then
+ usage
+ exit 65;
+fi
+
+## set arguments with strippingcd bin last slash
+NATIVEPATH=`echo "$1" | sed -s "s/^\(.*\)\/$/\\1/g" `
+WEBPATH=`echo "$2" | sed -s "s/^\(.*\)\/$/\\1/g" `
+
+NATIVE_NAME=${NATIVEPATH##*/}
+WEB_NAME=${WEBPATH##*/}
+
+BIN_FILE="${NATIVE_NAME}.exe"
+MANIFESTPATH="${NATIVEPATH}/${MANIFEST}"
+CONFIGURATIONPATH="${WEBPATH}/${CONFIGURATION}"
+
+NATIVE_DEBUG_FILE="${NATIVEPATH}/${DEBUG_FOLDER}/${BIN_FILE}"
+NATIVE_RELEASE_FILE="${NATIVEPATH}/${RELEASE_FOLDER}/${BIN_FILE}"
+TEMPPATH="${TEMPROOTPATH}/${WEBPATH}"
+TARGET_BIN_FOLDER="${TEMPPATH}/${BIN_TARGET_FOLDER}"
+TARGET_BIN_FILE="${TARGET_BIN_FOLDER}/${BIN_FILE}"
+TARGET_INFO_FOLDER="${TEMPPATH}/${INFO_FOLDER}"
+
+################
+## Define functions
+
+function checkDirectory() {
+ echo "[ Checking $1 directory ]"
+ if [ ! -d "$1" ]; then
+ echo "$1 is not a directory."
+ exit 65;
+ fi
+}
+
+function checkNativeProject() {
+ checkDirectory "${NATIVEPATH}"
+ if [ ! -e "${MANIFESTPATH}" ]; then
+ echo "Could not find the native project."
+ exit 65;
+ fi
+}
+
+function checkWebProject() {
+ checkDirectory "${WEBPATH}"
+ if [ ! -e "${CONFIGURATIONPATH}" ]; then
+ echo "Could not find the web project."
+ exit 65;
+ fi
+}
+
+function isError() {
+ ERROR_CODE=$?
+ if [ ! ${ERROR_CODE} == 0 ]; then
+ echo "[ $1 : Fail (ErrorCode : ${ERROR_CODE}) ]"
+ exit ${ERROR_CODE}
+ fi
+}
+
+function generateStructure() {
+ echo "[ Generating structures ]"
+
+ ###################
+ ## make temp directory
+ if [ -d "${TEMPPATH}" ]; then
+ echo "The old structure is detected. remove this."
+ rm -rI "${TEMPPATH}"
+ fi
+ mkdir -p "${TEMPPATH}"
+ isError "make ${TEMPPATH} directory"
+
+ ###########################
+ ## copy from native project directly
+ for EACH_FOLDER in ${FOLDER_LIST}; do
+ NATIVE_EACH_FOLDER="${NATIVEPATH}/${EACH_FOLDER}"
+ if [ -d "${NATIVE_EACH_FOLDER}" ]; then
+ cp -fr "${NATIVE_EACH_FOLDER}" "${TEMPPATH}"
+ isError "copy ${NATIVE_EACH_FOLDER}"
+ fi
+ done
+
+ #################
+ ## copy manifest file
+ mkdir -p "${TARGET_INFO_FOLDER}"
+
+ ## get package id from config.xml
+ CONFIG_APPID=`grep -oE 'package=\"([^\"]*)\"' ${CONFIGURATIONPATH} | cut -f2 -d"\""`
+ isError "get package id"
+
+ ## replace manifest id and copy
+ REPLACE_REGEX="s/<Id>.*<\/Id>/<Id>${CONFIG_APPID}<\/Id>/g"
+ sed -e "${REPLACE_REGEX}" ${MANIFESTPATH} >> "${TARGET_INFO_FOLDER}/${MANIFEST}"
+ isError "copy ${MANIFEST}"
+
+ ###############
+ ## copy binary file
+ mkdir -p "${TARGET_BIN_FOLDER}"
+
+ NATIVE_DEBUG_FILE="${NATIVEPATH}/${DEBUG_FOLDER}/${BIN_FILE}"
+ NATIVE_RELEASE_FILE="${NATIVEPATH}/${RELEASE_FOLDER}/${BIN_FILE}"
+
+ if [ -e "${NATIVE_RELEASE_FILE}" ]; then
+ echo "${RELEASE_FOLDER} binary is found."
+ cp -fr "${NATIVE_RELEASE_FILE}" "${TARGET_BIN_FILE}"
+ elif [ -e "${NATIVE_DEBUG_FILE}" ]; then
+ echo "${DEBUG_FOLDER} binary is found."
+ cp -fr "${NATIVE_DEBUG_FILE}" "${TARGET_BIN_FILE}"
+ else
+ echo "[ copy a binary file : Fail ]"
+ exit -1
+ fi
+
+ ####################
+ ## copy from web project
+ cp -fr "${WEBPATH}/." "${TEMPPATH}/${RES_FOLDER}/${WGT_FOLDER}"
+ isError "copy web project"
+
+ echo "[ Complete. see \"${TEMPPATH}\" folder ]"
+ echo "Explain next steps:"
+ echo " Please sign \"${TEMPPATH}\" folder using the \"${SIGNCOMMAND}\" tool and pack it using the \"${PACKCOMMAND}\" tool"
+}
+
+
+###############
+## Check projects
+checkNativeProject
+checkWebProject
+
+###########
+## Generate
+generateStructure