Added more error check on validation to let result be more exact.
[mirror_edk2.git] / Tools / Source / SurfaceArea / build.xml
CommitLineData
878ddf1f 1<?xml version="1.0" encoding="UTF-8"?>\r
2<!--\r
3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11-->\r
12<project default="all" basedir="." name="SurfaceArea">\r
13 <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
14 <property environment="env" />\r
15 <property name="WORKSPACE" value="${env.WORKSPACE}"/>\r
16 <taskdef resource="net/sf/antcontrib/antlib.xml"/>\r
17\r
18 <path id="classpath">\r
19 <fileset dir="${WORKSPACE}/Tools/Jars">\r
20 <include name="*.jar"/>\r
21 </fileset>\r
19924945 22 <fileset dir="${env.XMLBEANS_HOME}/lib">\r
878ddf1f 23 <include name="*.jar"/>\r
24 </fileset>\r
25 <pathelement path = "${env.CLASSPATH}"/>\r
26 </path>\r
27\r
28 <target name="init">\r
29 <uptodate targetfile="${WORKSPACE}/Tools/Jars/SurfaceArea.jar" property="jar.newer">\r
30 <srcfiles dir="${WORKSPACE}/Tools/XMLSchema" includes="*.xsd"/>\r
31 </uptodate>\r
32 </target>\r
33\r
34 <!--\r
35 Generate SurfaceArea.jar and source code \r
36 -->\r
37 <target name="SurfaceArea.jar" depends="init">\r
38 <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler">\r
39 <classpath refid="classpath"/>\r
40 <arg value="-javasource"/>\r
41 <arg value="1.5"/>\r
42 <arg value="-dl"/>\r
43 <arg value="-out"/>\r
44 <arg value="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>\r
45 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>\r
9c39e214 46 <arg value="${WORKSPACE}/Tools/XMLSchema/FarManifest.xsd"/>\r
878ddf1f 47 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsdconfig"/>\r
48 </java>\r
49 </target>\r
50 \r
51 <target name="SurfaceArea.java" depends="init">\r
52 <antcall target="SurfaceArea.java.clean"/>\r
53 <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler">\r
54 <classpath refid="classpath"/>\r
55 <arg value="-javasource"/>\r
56 <arg value="1.5"/>\r
57 <arg value="-dl"/>\r
58 <arg value="-srconly"/>\r
59 <arg value="-src"/>\r
60 <arg value="${WORKSPACE}/Tools/Source/SurfaceArea"/>\r
61 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>\r
9c39e214 62 <arg value="${WORKSPACE}/Tools/XMLSchema/FarManifest.xsd"/>\r
878ddf1f 63 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsdconfig"/>\r
64 </java>\r
65 </target>\r
66 \r
67 <target name="SurfaceArea" depends="init" unless="jar.newer">\r
68 <antcall target="SurfaceArea.java.clean"/>\r
f3dcd511 69 <java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler" fork="true">\r
878ddf1f 70 <classpath refid="classpath"/>\r
71 <arg value="-javasource"/>\r
72 <arg value="1.5"/>\r
73 <arg value="-dl"/>\r
74 <arg value="-src"/>\r
75 <arg value="${WORKSPACE}/Tools/Source/SurfaceArea"/>\r
76 <arg value="-out"/>\r
77 <arg value="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>\r
78 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>\r
9c39e214 79 <arg value="${WORKSPACE}/Tools/XMLSchema/FarManifest.xsd"/>\r
878ddf1f 80 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsdconfig"/>\r
81 </java>\r
82 </target>\r
83 \r
84 <target name="SurfaceArea.java.clean">\r
8db3db9a 85 <delete includeemptydirs="true" failonerror="false">\r
86 <fileset dir="${WORKSPACE}/Tools/Source/SurfaceArea/org" includes="**/*"/>\r
878ddf1f 87 </delete>\r
88 </target>\r
89\r
90 <target name="SurfaceArea.jar.clean">\r
91 </target>\r
92 \r
93 <!--\r
94 Surface Area Description file validation\r
95 -->\r
96 <target name="validate">\r
97 <echo message="Validating ... ${SURFACE_AREA_FILE}"/>\r
98 <!--\r
99 java -classpath %cp% org.apache.xmlbeans.impl.tool.InstanceValidator %*\r
100 -->\r
101 <copy file="${SURFACE_AREA_FILE}" tofile="${SURFACE_AREA_FILE}.xml"/>\r
102 <java classname="org.apache.xmlbeans.impl.tool.InstanceValidator" \r
6c96db71 103 outputproperty="XMLBEANS_OUTPUT"\r
6c96db71 104 errorproperty="XMLBEANS_ERROR">\r
878ddf1f 105 \r
106 <classpath refid="classpath"/>\r
107 <arg value="-dl"/>\r
108 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>\r
109 <arg value="${SURFACE_AREA_FILE}.xml"/>\r
110 \r
111 </java> \r
112\r
113 <delete file="${SURFACE_AREA_FILE}.xml" quiet="true"/>\r
6c96db71 114 <if>\r
27169a56 115 <or>\r
116 <contains string="${XMLBEANS_OUTPUT}" substring="NOT valid"/>\r
117 <contains string="${XMLBEANS_OUTPUT}" substring=": error:"/>\r
118 <contains string="${XMLBEANS_ERROR}" substring="XmlException"/>\r
119 <contains string="${XMLBEANS_ERROR}" substring=": error:"/>\r
120 </or>\r
6c96db71 121 <then>\r
27169a56 122 <echo message="Result ... ${XMLBEANS_OUTPUT}&#x0d;&#x0a;${XMLBEANS_ERROR}"/>\r
123 <fail message="${SURFACE_AREA_FILE} is invalid!"/>\r
6c96db71 124 </then>\r
125 <else>\r
27169a56 126 <echo message="Result ... ${SURFACE_AREA_FILE} is valid"/>\r
6c96db71 127 </else>\r
128 </if>\r
878ddf1f 129 </target>\r
130 \r
131 <!--\r
132 beautify xml file\r
133 -->\r
134 <target name="pretty">\r
135 <echo message="Beautify ... ${SURFACE_AREA_FILE}"/>\r
136 <!--\r
137 java -classpath %cp% org.apache.xmlbeans.impl.tool.PrettyPrinter %*\r
138 -->\r
139 <java classname="org.apache.xmlbeans.impl.tool.PrettyPrinter" \r
140 errorproperty="XMLBEANS_OUTPUT"\r
141 output="${SURFACE_AREA_FILE}">\r
142 \r
143 <classpath refid="classpath"/>\r
144 <arg value="-indent"/>\r
145 <arg value="2"/>\r
146 <arg value="${SURFACE_AREA_FILE}"/>\r
147 \r
148 </java>\r
149\r
150 <if>\r
151 <equals arg1="${XMLBEANS_OUTPUT}" arg2=""/>\r
152 <then>\r
153 <echo message="Result ... DONE"/>\r
154 </then>\r
155 <else>\r
156 <echo message="Result ... ${XMLBEANS_OUTPUT}"/>\r
157 </else>\r
158 </if>\r
159 </target>\r
160\r
161 <!--\r
162 generate Surface Area template file from schema\r
163 -->\r
164 <target name="generate">\r
165 <echo message="Generating ... ${SURFACE_AREA_FILE}"/>\r
166 <!--\r
167 java -classpath %cp% org.apache.xmlbeans.impl.xsd2inst.SchemaInstanceGenerator %*\r
168 -->\r
169 <java classname="org.apache.xmlbeans.impl.xsd2inst.SchemaInstanceGenerator" fork="true"\r
170 errorproperty="XMLBEANS_OUTPUT" \r
171 output="${SURFACE_AREA_FILE}.tmp">\r
172 \r
173 <classpath refid="classpath"/>\r
174 <arg value="-dl"/>\r
175 <arg value="${WORKSPACE}/Tools/XMLSchema/SurfaceArea.xsd"/>\r
176 <arg value="-name"/>\r
177 <arg value="${SURFACE_AREA_ELEMENT}"/>\r
178 \r
179 </java>\r
180\r
181 <concat destfile="${SURFACE_AREA_FILE}">\r
182 <header trimleading="yes" filtering="no"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>]]>\r
183 </header>\r
184 <fileset file="${SURFACE_AREA_FILE}.tmp"/>\r
185 </concat>\r
186 \r
187 <delete file="${SURFACE_AREA_FILE}.tmp" deleteonexit="true" quiet="true"/>\r
188 <if>\r
189 <equals arg1="${XMLBEANS_OUTPUT}" arg2=""/>\r
190 <then>\r
191 <echo message="Result ... DONE"/>\r
192 </then>\r
193 <else>\r
194 <echo message="Result ... ${XMLBEANS_OUTPUT}"/>\r
195 </else>\r
196 </if>\r
197 </target>\r
198\r
199 <target name="clean" depends="SurfaceArea.java.clean">\r
200 </target>\r
201\r
202 <target name="cleanall" depends="SurfaceArea.jar.clean">\r
617cc72b 203 <delete file="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>\r
878ddf1f 204 <if>\r
205 <available file="${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>\r
206 <then>\r
207 <echo message="You must manually remove the file: ${WORKSPACE}/Tools/Jars/SurfaceArea.jar"/>\r
208 <echo message="Java has already loaded the file, and cannot remove it within ANT!"/>\r
209 </then>\r
210 </if>\r
211 </target>\r
212\r
213 <target name="all" depends="SurfaceArea">\r
214 </target>\r
215\r
216 <target name="install" depends="SurfaceArea.jar">\r
217 </target>\r
218\r
219</project> \r