|
7 | 7 | <property name="src.dir" value="./src" /> |
8 | 8 | <property name="npm.dir" value="./npm" /> |
9 | 9 | <property name="tests.dir" value="./tests" /> |
10 | | - |
| 10 | + |
11 | 11 | <!-- the directories and files to output to --> |
12 | 12 | <property name="build.dir" value="./build" /> |
13 | 13 | <property name="release.dir" value="./release" /> |
14 | 14 | <property name="build.npm.dir" value="${build.dir}/npm" /> |
15 | 15 |
|
16 | 16 | <!-- the directory containing library files --> |
17 | | - <property name="lib.dir" value="./lib" /> |
18 | | - |
| 17 | + <property name="lib.dir" value="./lib" /> |
| 18 | + |
19 | 19 | <!-- library files --> |
20 | 20 | <property name="jshint.js" value="jshint.js" /> |
21 | 21 | <property name="parserlib.js" value="parserlib.js" /> |
22 | 22 | <property name="yuitest.js" value="yuitest.js" /> |
23 | | - |
| 23 | + |
24 | 24 | <!-- external resources --> |
25 | 25 | <property name="parser.url" value="https://raw.github.com/nzakas/parser-lib/master/release/parserlib.js"/> |
26 | 26 |
|
|
29 | 29 | <property name="node.build.file" value="csslint-node.js"/> |
30 | 30 | <property name="worker.build.file" value="csslint-worker.js"/> |
31 | 31 | <property name="tests.build.file" value="csslint-tests.js"/> |
| 32 | + <property name="tests.node.build.file" value="csslint-node-tests.js"/> |
32 | 33 | <property name="rhino.build.file" value="csslint-rhino.js"/> |
33 | 34 | <property name="wsh.build.file" value="csslint-wsh.js"/> |
34 | | - |
| 35 | + |
35 | 36 | <!-- embeddable license --> |
36 | | - <loadfile property="license.text" srcfile="LICENSE" /> |
| 37 | + <loadfile property="license.text" srcfile="LICENSE" /> |
37 | 38 |
|
38 | 39 | <!-- get a timestamp --> |
39 | 40 | <tstamp> |
|
45 | 46 | <format property="SIMPLE_DATE" |
46 | 47 | pattern="MMMM d, yyyy" |
47 | 48 | locale="en,US"/> |
48 | | - </tstamp> |
49 | | - |
| 49 | + </tstamp> |
| 50 | + |
50 | 51 | <!-- clean --> |
51 | 52 | <target name="clean"> |
52 | 53 | <delete dir="${build.dir}" /> |
53 | 54 | </target> |
54 | | - |
| 55 | + |
55 | 56 | <target name="changelog.update"> |
56 | 57 | <exec executable="git" failonerror="true" outputproperty="git.tag"> |
57 | 58 | <arg line="tag"/> |
58 | | - </exec> |
| 59 | + </exec> |
59 | 60 | <script language="javascript"><![CDATA[ |
60 | 61 | //get the most recent tag to get the diff |
61 | 62 | var tags = csslint.getProperty("git.tag").replace("\r", "").split("\n"), |
62 | 63 | lastTag = tags[tags.length-1]; |
63 | 64 | csslint.setProperty("git.log.range", lastTag + "..HEAD"); |
64 | 65 | ]]></script> |
65 | | - |
| 66 | + |
66 | 67 | <!-- git log -pretty=format:'* %s (%an)' v0.4.0..v0.5.0--> |
67 | 68 | <exec executable="git" failonerror="true" outputproperty="git.changelog"> |
68 | 69 | <arg line="log --pretty=format:'* %s (%an)' ${git.log.range}"/> |
69 | | - </exec> |
70 | | - |
| 70 | + </exec> |
| 71 | + |
71 | 72 | <concat destfile="CHANGELOG.tmp" fixlastline="true"> |
72 | 73 | <header trimleading="yes">${SIMPLE_DATE} - v${csslint.version} |
73 | | - |
| 74 | + |
74 | 75 | ${git.changelog} |
75 | | - |
| 76 | + |
76 | 77 | </header> |
77 | 78 | <fileset dir="." includes="CHANGELOG" /> |
78 | 79 | </concat> |
79 | | - |
| 80 | + |
80 | 81 | <delete file="CHANGELOG"/> |
81 | 82 | <move file="CHANGELOG.tmp" tofile="CHANGELOG"/> |
82 | | - |
| 83 | + |
83 | 84 | </target> |
84 | | - |
| 85 | + |
85 | 86 | <!-- validate JS files with JSHint --> |
86 | | - <target name="lint"> |
| 87 | + <target name="lint"> |
87 | 88 | <fileset dir="${src.dir}" includes="**/*.js" id="jsfiles.raw"/> |
88 | 89 | <pathconvert pathsep=" " property="jsfiles.clean" refid="jsfiles.raw" /> |
89 | 90 | <exec executable="java" failonerror="true"> |
90 | 91 | <arg line="-jar"/> |
91 | 92 | <arg path="${lib.dir}/js.jar"/> |
92 | | - <arg path="${lib.dir}/jshint.js" /> |
| 93 | + <arg path="${lib.dir}/jshint.js" /> |
93 | 94 | <arg line="${jsfiles.clean} curly=true,forin=true,latedef=true,noempty=true,undef=true,rhino=false" /> |
94 | | - </exec> |
| 95 | + </exec> |
95 | 96 | </target> |
96 | 97 |
|
97 | 98 | <!-- run tests on the command line --> |
98 | | - <target name="test" depends="build.all,lint,test.general.rules"> |
| 99 | + <target name="test" depends="build.all,lint,test.general.rules"> |
99 | 100 | <exec executable="java" failonerror="true"> |
100 | 101 | <arg line="-jar"/> |
101 | 102 | <arg path="${lib.dir}/js.jar"/> |
102 | 103 | <arg path="${lib.dir}/yuitest-rhino-cli.js" /> |
103 | 104 | <arg path="${build.dir}/${core.build.file}" /> |
104 | 105 | <arg path="${build.dir}/${tests.build.file}" /> |
105 | | - </exec> |
| 106 | + </exec> |
106 | 107 | </target> |
107 | 108 |
|
108 | 109 | <!-- must be done separately from other tests due to Rhino limitations --> |
109 | | - <target name="test.general.rules"> |
| 110 | + <target name="test.general.rules"> |
110 | 111 | <exec executable="java" failonerror="true"> |
111 | 112 | <arg line="-jar"/> |
112 | 113 | <arg path="${lib.dir}/js.jar"/> |
113 | 114 | <arg path="${lib.dir}/yuitest-rhino-cli.js" /> |
114 | 115 | <arg path="${build.dir}/${core.build.file}" /> |
115 | 116 | <arg path="${tests.dir}/all-rules.js" /> |
116 | | - </exec> |
| 117 | + </exec> |
| 118 | + </target> |
| 119 | + |
| 120 | + <!-- tests using Node.js for better performance --> |
| 121 | + <target name="test.node" depends="build.all,lint"> |
| 122 | + <exec executable="yuitest" failonerror="true"> |
| 123 | + <arg line="--webcompat"/> |
| 124 | + <arg path="${build.dir}/${tests.node.build.file}" /> |
| 125 | + </exec> |
117 | 126 | </target> |
118 | 127 |
|
119 | 128 | <!-- build the core library --> |
120 | | - <target name="build.core"> |
| 129 | + <target name="build.core"> |
121 | 130 | <concat destfile="${build.dir}/${core.build.file}" fixlastline="true"> |
122 | | - <header trimleading="yes">/*! |
| 131 | + <header trimleading="yes">/*! |
123 | 132 | ${license.text} |
124 | 133 | */ |
125 | 134 | /* Build time: ${RIGHT_NOW} */ |
|
134 | 143 | return CSSLint; |
135 | 144 | })(); |
136 | 145 | </footer> |
137 | | - |
| 146 | + |
138 | 147 | </concat> |
139 | 148 | </target> |
140 | | - |
| 149 | + |
141 | 150 | <!-- build the web worker library --> |
142 | | - <target name="build.worker"> |
| 151 | + <target name="build.worker"> |
143 | 152 | <concat destfile="${build.dir}/${worker.build.file}" fixlastline="true"> |
144 | 153 | <header trimleading="yes">/*! |
145 | 154 | ${license.text} |
|
149 | 158 | <fileset dir="${lib.dir}" includes="${parserlib.js}" /> |
150 | 159 | <filelist dir="${src.dir}/core" files="CSSLint.js" /> |
151 | 160 | <fileset dir="${src.dir}/core" includes="*.js" excludes="CSSLint.js"/> |
152 | | - <fileset dir="${src.dir}/rules" includes="*.js" /> |
| 161 | + <fileset dir="${src.dir}/rules" includes="*.js" /> |
153 | 162 | <fileset dir="${src.dir}/formatters" includes="*.js" /> |
154 | | - <fileset dir="${src.dir}/worker" includes="*.js" /> |
155 | | - </concat> |
156 | | - </target> |
157 | | - |
158 | | - |
| 163 | + <fileset dir="${src.dir}/worker" includes="*.js" /> |
| 164 | + </concat> |
| 165 | + </target> |
| 166 | + |
| 167 | + |
159 | 168 | <!-- build the Node.js package --> |
160 | 169 | <target name="build.node"> |
161 | | - |
| 170 | + |
162 | 171 | <concat destfile="${build.dir}/${node.build.file}" fixlastline="true"> |
163 | 172 | <header trimleading="yes">/*! |
164 | 173 | ${license.text} |
|
174 | 183 | exports.CSSLint = CSSLint; |
175 | 184 | </footer> |
176 | 185 | </concat> |
177 | | - |
| 186 | + |
178 | 187 | <mkdir dir="${build.npm.dir}"/> |
179 | 188 | <mkdir dir="${build.npm.dir}/lib"/> |
180 | 189 | <copy file="${npm.dir}/package.json" todir="${build.npm.dir}"/> |
|
185 | 194 | <filelist dir="${src.dir}/cli" files="common.js,node.js" /> |
186 | 195 | </concat> |
187 | 196 | <copy file="${build.dir}/${node.build.file}" todir="${build.npm.dir}/lib"/> |
188 | | - |
| 197 | + |
189 | 198 | <!-- CRLF will cause Node version to break --> |
190 | 199 | <fixcrlf srcdir="${build.dir}" includes="**/*" eol="lf" /> |
191 | 200 | </target> |
192 | | - |
| 201 | + |
193 | 202 | <!-- build the tests into a single file --> |
194 | | - <target name="build.tests"> |
| 203 | + <target name="build.tests" depends="build.node.tests"> |
195 | 204 | <concat destfile="${build.dir}/${tests.build.file}" fixlastline="true"> |
196 | | - <fileset dir="${tests.dir}/" includes="**/*.js" excludes="all-rules.js" /> |
197 | | - </concat> |
198 | | - </target> |
| 205 | + <fileset dir="${tests.dir}/" includes="**/*.js" excludes="all-rules.js" /> |
| 206 | + </concat> |
| 207 | + </target> |
| 208 | + |
| 209 | + <!-- build the tests into a single file --> |
| 210 | + <target name="build.node.tests" depends="build.core"> |
| 211 | + <concat destfile="${build.dir}/${tests.node.build.file}" fixlastline="true"> |
| 212 | + <filelist dir="${build.dir}" files="${core.build.file}" /> |
| 213 | + <fileset dir="${tests.dir}/" includes="**/*.js" /> |
| 214 | + </concat> |
| 215 | + </target> |
199 | 216 |
|
200 | 217 | <!-- build for rhino CLI integration --> |
201 | 218 | <target name="build.rhino" depends="build.core"> |
202 | 219 | <concat destfile="${build.dir}/${rhino.build.file}" fixlastline="true"> |
203 | 220 | <filelist dir="${build.dir}" files="${core.build.file}" /> |
204 | 221 | <filelist dir="${src.dir}/cli" files="common.js,rhino.js" /> |
205 | 222 | </concat> |
206 | | - </target> |
207 | | - |
| 223 | + </target> |
| 224 | + |
208 | 225 | <!-- build for WSH CLI integration --> |
209 | 226 | <target name="build.wsh" depends="build.core"> |
210 | 227 | <concat destfile="${build.dir}/${wsh.build.file}" fixlastline="true"> |
211 | 228 | <filelist dir="${build.dir}" files="${core.build.file}" /> |
212 | 229 | <filelist dir="${src.dir}/cli" files="common.js,wsh.js" /> |
213 | 230 | </concat> |
214 | | - </target> |
215 | | - |
| 231 | + </target> |
| 232 | + |
216 | 233 | <!-- Create a release with version number embedded --> |
217 | 234 | <target name="release" depends="test,build.all,changelog.update"> |
218 | 235 | <delete dir="${release.dir}" /> |
|
222 | 239 | </copy> |
223 | 240 | <replaceregexp match="@VERSION@" replace="${csslint.version}" flags="g" byline="true"> |
224 | 241 | <fileset dir="${release.dir}" includes="**/*"/> |
225 | | - </replaceregexp> |
| 242 | + </replaceregexp> |
226 | 243 | </target> |
227 | | - |
| 244 | + |
228 | 245 | <!-- Update CSS parser with the latest --> |
229 | 246 | <target name="parser.update"> |
230 | 247 | <get src="${parser.url}" dest="${lib.dir}/${parserlib.js}" /> |
231 | 248 | </target> |
232 | | - |
| 249 | + |
233 | 250 | <!-- Update JSHint with the latest --> |
234 | 251 | <target name="jshint.update"> |
235 | 252 | <get src="${jshint-rhino.url}" dest="${lib.dir}/" /> |
236 | 253 | <get src="${jshint.url}" dest="${lib.dir}/" /> |
237 | 254 | </target> |
238 | | - |
| 255 | + |
239 | 256 | <!-- Build all files --> |
240 | 257 | <target name="build.all" depends="clean,build.core,build.worker,build.node,build.tests,build.rhino,build.wsh"/> |
241 | 258 |
|
|
0 commit comments