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