<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ssi version="0.1">
    <macros scope="common">
        <input name="DIR_SEP" method="sysvar" source="OS" value="dir.separator" />
        <input name="PATH_SEP" method="sysvar" source="OS" value="path.separator" />
        <input name="SSI_HOME" method="sysvar" source="SDK" value="ssi.path" />

        <input name="SDKPATH" method="sysvar" source="SDK" value="sdk.path" />

        <input name="STRIPPER_PATH" method="user" value="${__PARAM1__}" />
        <input name="VER3_EMPTY_OPT" method="user" value="${__PARAM2__}" />
    </macros>

    <variables>
        <input name="PROJ_PATH" value="project.path" />
        <input name="BUILD_CONFIG" value="build.config" />
        <input name="BUILD_ARCH" value="build.arch" />

        <input name="APPID" value="app.id" />
        <input name="APPTYPE" value="app.type" />

        <input name="OUTPUT_PATH" value="project.output.path" />

        <input name="FILE_SRC" value="fileentry.src" />
        <input name="FILE_DES" value="fileentry.des" />
    </variables>

    <!-- ******************************* -->

    <filesystem>
        <fileset name="all">
            <fileentry type="dir" src="." des="." />
        </fileset>

        <fileset name="common">
            <fileentry type="dir" src="lib" des="lib" attr="strip" />
        </fileset>

        <fileset name="web">
            <fileentry type="dir" src="css" des="css" />
            <fileentry type="dir" src="images" des="images" />
            <fileentry type="dir" src="js" des="js" />
            <fileentry type="dir" src="${OUTPUT_PATH}" des="">
                <filter exclude="*.wgt.zip" />
            </fileentry>
            <fileentry type="file,manifest" src="?select(?file(${OUTPUT_PATH}/config.xml),?file(${PROJ_PATH}/config.xml))" des="" />
        </fileset>

        <fileset name="native">
            <fileentry type="dir" src="res" des="res" attr="mandatory">
                <filter exclude="edje/*.edc" />
                <filter exclude="po/*.po" />
                <filter exclude="tep" />
                <filter exclude="contents/*.edc" />
                <filter exclude="contents/edje_res" />
                <filter exclude="contents/*/edje_res" />
            </fileentry>
            <fileentry type="dir" src="lib" des="lib" attr="mandatory" />
            <fileentry type="dir" src="shared" des="shared" attr="mandatory" />
            <fileentry type="dir" src="shared/res" des="shared/res">
                <filter exclude="edje/*.edc;po/*.po" />
            </fileentry>
            <fileentry type="dir" src="shared/trusted" des="shared/trusted" attr="${VER3_EMPTY_OPT}" />
            <fileentry type="dir" src="shared/data" des="shared/data" attr="${VER3_EMPTY_OPT}" />
            <fileentry type="dir" src="bin" des="bin" attr="mandatory">
                <filter exclude=".*?.mk;.*?.ninja" />
            </fileentry>
	    <fileentry type="dir" src="${OUTPUT_PATH}/res" des="res/">
                <filter exclude="edje/*.edc" />
            </fileentry>
            <fileentry type="dir" src="${OUTPUT_PATH}/${BUILD_CONFIG}/res/edje" des="res/edje" />
            <fileentry type="file,execute" src="?file(${OUTPUT_PATH}/${BUILD_CONFIG}/${APPID})" des="bin/" />
            <fileentry type="file,execute" src="?file(${OUTPUT_PATH}/${BUILD_CONFIG}/lib${APPID}.so)" des="lib/" />
            <fileentry type="file,manifest" src="?select(?file(${OUTPUT_PATH}/tizen-manifest.xml),?file(${PROJ_PATH}/tizen-manifest.xml))" des="" />
        </fileset>

        <fileset name="tep">
            <fileentry type="dir" src="res/tep" des="." attr="strip" />
        </fileset>
    </filesystem>

    <!-- ******************************* -->

    <action>
        <structure name="tpk" format="tpk">
            <proc type="copy" target="project" fileset="common,native" />
            <proc type="exec" target="project" fileset="native/*[type=execute]" echo="Stripping execute file ..." require="${STRIPPER_PATH}">
                ${STRIPPER_PATH} --strip-unneeded --remove-section .comment ${FILEENTRY:DES}
            </proc>
        </structure>

        <structure name="tep" attr="optional" format="tep">
            <proc type="copy" target="project" fileset="tep" attr="strip" />
        </structure>

        <structure name="wgt" format="wgt">
            <proc type="copy" target="project" fileset="common,web" />
        </structure>

        <structure name="multi_pack" format="tpk">
            <proc type="copy" target="project" fileset="common,native/*[type!=manifest]" />
            <proc type="exec" target="project[type=native]" fileset="native/*[type=execute]" echo="Stripping execute file ..." require="${STRIPPER_PATH}">
                ${STRIPPER_PATH} --strip-unneeded --remove-section .comment ${FILE_DES}
            </proc>
            <proc type="copy" target="dir" fileset="all" />
            <proc type="dom" target="project" des="dom1,/root/manifest" fileset="native/*[type=manifest]" />
            <proc type="gen" target="package" des="tizen-manifest.xml" src="dom1" transscript="native-multi.xsl" echo="Merging tizen-manifest.xml ..." />
        </structure>

        <structure name="web_multi" format="wgt">
            <proc type="copy" target="project[type=web]" fileset="common,web/*[type!=manifest]" />
            <proc type="dom" target="project" des="dom1,/root/manifest" fileset="web/*[type=manifest]" />
            <proc type="gen" target="package" des="config.xml" src="dom1" transscript="hybrid-web.xsl" />
        </structure>

        <structure name="hybrid" format="wgt">
            <proc type="copy" target="project[type=web]" fileset="common,web/*[type!=manifest]" des="res/wgt" />
            <proc type="copy" target="project[type=native]" fileset="common,native/*[type!=manifest]" />
            <proc type="dom" target="project[type=web]" des="/root/manifest" fileset="web/*[type=manifest]" />
            <proc type="dom" target="project[type=native]" des="/root/manifest" fileset="native/*[type=manifest]" />
            <proc type="gen" target="package" des="config.xml" src="dom" transscript="hybrid-web.xsl" />
            <proc type="gen" target="package" des="res/wgt/config.xml" src="dom" transscript="hybrid-web.xsl" />
            <proc type="gen" target="package" des="tizen-manifest.xml" src="dom" transscript="hybrid-native.xsl" />
        </structure>
    </action>
</ssi>
