@ECHO OFF
@REM SET PATH=""
@rem %JAVA_HOME%\bin\java -classpath %_CLASSES% com.sun.javacard.converter.Converter %*

SET _BUILD_DIR=%CD%
SET _PROJ_PATH="%_BUILD_DIR%\.."
SET _DELIVERY_PATH=%_BUILD_DIR%\Delivery

SET _SRC_PATH=%_PROJ_PATH%\Project\Src
SET _CAP_PATH=%_PROJ_PATH%\Project\bin\com\cscn\javacard
SET _OUT_PATH=%_PROJ_PATH%\Project\bin
SET _TOOLS_PATH=%_PROJ_PATH%\Tools

CD ..\Project
DEL /Q %_DELIVERY_PATH%\*.*
DEL /Q %_CAP_PATH%\*.*
RMDIR /S /Q %_OUT_PATH%
MKDIR %_OUT_PATH%
REM PAUSE

SET JAVA_HOME=%_TOOLS_PATH%\jdk1.5.0_19
SET JC_HOME=%_TOOLS_PATH%\jcdk222
SET PATH=%JAVA_HOME%\bin;%JC_HOME%\bin;%PATH%

SET EXT_API_PATH=%_TOOLS_PATH%\ext_api
SET _JavaC_HOME=%_TOOLS_PATH%\jdk1.5.0_19\jre\bin
SET _CLASS_PATH=%_TOOLS_PATH%\jcdk222\lib\api.jar;%EXT_API_PATH%\gp221.jar

SET JCDK_EXPORT_DIR=%_TOOLS_PATH%\api_exp\JCDK222
SET PROJ_EXPORT_DIR=%_OUT_PATH%
SET EXT_EXPORT_DIR=%_TOOLS_PATH%\api_exp\gp221
SET EXPORT_DIR=%JCDK_EXPORT_DIR%;%PROJ_EXPORT_DIR%;%EXT_EXPORT_DIR%

REM COMPILE JAVA TO CLASS
ECHO **********************************************
ECHO ***        Compile Java Source Code        ***
ECHO **********************************************
ECHO Setting Build Path
REM use <-verbose> display compile info
REM SET COMPILE_PARAM=-nowarn -verbose 
SET COMPILE_PARAM= -nowarn 

ECHO Compiling Java Card API source code
Call javac %COMPILE_PARAM% -classpath %_CLASS_PATH% %_SRC_PATH%\*.java -d %_OUT_PATH% -g

ECHO **********************************************
ECHO ***     Convert Java Card Assembly File    ***
ECHO **********************************************

CALL converter -nowarn -i -classdir .\bin -exportpath %EXPORT_DIR% -out EXP CAP -applet 0xA0:0x00:0x00:0x03:0x00:0x73:0x74:0x61:0x72:0x2E:0x61:0x70:0x70 com.cscn.XwSecurity com.cscn 0xA0:0x00:0x00:0x03:0x00:0x73:0x74:0x61:0x72:0x2E:0x70:0x6B:0x67 1.0

ECHO **********************************************
ECHO ***     Copy Exp and Cap File              ***
ECHO **********************************************
COPY %_CAP_PATH%\*.* %_BUILD_DIR%\Delivery\
PAUSE