-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
175 lines (157 loc) · 6.63 KB
/
Copy pathbuild.xml
File metadata and controls
175 lines (157 loc) · 6.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?xml version="1.0" encoding="UTF-8"?>
<project name="hello-javacard" default="help" basedir=".">
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="cap.out.dir" value="${build.dir}/cap"/>
<!-- Java Card app/package identifiers for this starter applet -->
<property name="package.name" value="com.example.jc"/>
<property name="package.aid" value="0xA0:0x00:0x00:0x00:0x62:0x03:0x01:0x0C:0x01"/>
<property name="package.version" value="1.0"/>
<property name="applet.class" value="com.example.jc.HelloApplet"/>
<property name="applet.aid" value="0xA0:0x00:0x00:0x00:0x62:0x03:0x01:0x0C:0x01:0x01"/>
<!-- Prefer JC_HOME; fallback to local SDK folder in this repo -->
<condition property="jc.home" value="${env.JC_HOME}" else="${basedir}/tools/sdk-2.2.2">
<and>
<isset property="env.JC_HOME"/>
<not>
<equals arg1="${env.JC_HOME}" arg2=""/>
</not>
</and>
</condition>
<property name="jc.api.jar" value="${jc.home}/lib/api.jar"/>
<property name="jc.converter.jar" value="${jc.home}/lib/converter.jar"/>
<property name="jc.verifier.jar" value="${jc.home}/lib/offcardverifier.jar"/>
<property name="jc.export.path" value="${jc.home}/api_export_files"/>
<!-- Compile Java Card 2.2.2 sources with JDK 8 toolchain explicitly. -->
<condition property="java8.home" value="${env.JAVA8_HOME}" else="/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home">
<and>
<isset property="env.JAVA8_HOME"/>
<not>
<equals arg1="${env.JAVA8_HOME}" arg2=""/>
</not>
</and>
</condition>
<target name="help">
<echo>Targets:</echo>
<echo> ant check-env - Validate Java and Java Card SDK setup.</echo>
<echo> ant clean - Remove build outputs.</echo>
<echo> ant compile - Compile applet source.</echo>
<echo> ant package-cap - Convert class files to CAP/EXP/JCA outputs.</echo>
</target>
<target name="check-env">
<available file="${jc.home}" type="dir" property="jc.home.exists"/>
<available file="${jc.api.jar}" property="jc.api.exists"/>
<available file="${jc.converter.jar}" property="jc.converter.exists"/>
<available file="${jc.verifier.jar}" property="jc.verifier.exists"/>
<available file="${jc.export.path}" type="dir" property="jc.export.exists"/>
<available file="${java8.home}/bin/javac" property="java8.javac.exists"/>
<available file="${java8.home}/bin/java" property="java8.java.exists"/>
<fail message="Java runtime not detected. Install JDK 8 and ensure 'java' is available in PATH.">
<condition>
<not>
<available file="${java.home}"/>
</not>
</condition>
</fail>
<fail message="Java Card SDK directory not found: ${jc.home}">
<condition>
<not>
<isset property="jc.home.exists"/>
</not>
</condition>
</fail>
<fail message="Missing API jar: ${jc.api.jar}">
<condition>
<not>
<isset property="jc.api.exists"/>
</not>
</condition>
</fail>
<fail message="Missing converter jar: ${jc.converter.jar}">
<condition>
<not>
<isset property="jc.converter.exists"/>
</not>
</condition>
</fail>
<fail message="Missing verifier jar: ${jc.verifier.jar}">
<condition>
<not>
<isset property="jc.verifier.exists"/>
</not>
</condition>
</fail>
<fail message="Missing export path: ${jc.export.path}">
<condition>
<not>
<isset property="jc.export.exists"/>
</not>
</condition>
</fail>
<fail message="JDK8 javac not found at ${java8.home}/bin/javac. Set JAVA8_HOME or adjust java8.home in build.xml.">
<condition>
<not>
<isset property="java8.javac.exists"/>
</not>
</condition>
</fail>
<fail message="JDK8 java not found at ${java8.home}/bin/java. Set JAVA8_HOME or adjust java8.home in build.xml.">
<condition>
<not>
<isset property="java8.java.exists"/>
</not>
</condition>
</fail>
<echo message="JC_HOME=${jc.home}"/>
<echo message="JAVA8_HOME=${java8.home}"/>
<echo message="Java runtime: ${java.version}"/>
<echo message="Toolchain check passed."/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
<target name="compile" depends="clean,check-env">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
includeantruntime="false"
source="1.5"
target="1.5"
debug="true"
fork="true"
executable="${java8.home}/bin/javac">
<classpath>
<pathelement path="${jc.api.jar}"/>
</classpath>
</javac>
</target>
<target name="package-cap" depends="compile">
<mkdir dir="${cap.out.dir}"/>
<java classname="com.sun.javacard.converter.Converter" fork="true" failonerror="true" jvm="${java8.home}/bin/java">
<classpath>
<pathelement path="${jc.converter.jar}"/>
<pathelement path="${jc.verifier.jar}"/>
<pathelement path="${jc.api.jar}"/>
</classpath>
<arg value="-classdir"/>
<arg value="${classes.dir}"/>
<arg value="-exportpath"/>
<arg value="${jc.export.path}"/>
<arg value="-out"/>
<arg value="CAP"/>
<arg value="EXP"/>
<arg value="JCA"/>
<arg value="-d"/>
<arg value="${cap.out.dir}"/>
<arg value="-applet"/>
<arg value="${applet.aid}"/>
<arg value="${applet.class}"/>
<arg value="${package.name}"/>
<arg value="${package.aid}"/>
<arg value="${package.version}"/>
</java>
<echo message="CAP conversion done. Check ${cap.out.dir}/${package.name} (path form) for output files."/>
</target>
</project>