-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
203 lines (177 loc) · 9.05 KB
/
build.xml
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<project name="ejax" default="dist" basedir=".">
<!-- Properties -->
<property name="bin" location="bin"/>
<property name="lib" location="lib"/>
<property name="base.build" location="build"/>
<property name="base.build.jar" location="${base.build}/jar"/>
<property name="base.src" location="src"/>
<property name="java.src" location="${base.src}/java"/>
<property name="java.test.src" location="${base.src}/test/java"/>
<property name="java.build.jar" location="${base.build.jar}"/>
<property name="java.test.build" location="${base.build}/test"/>
<property name="java.dist" location="dist"/>
<property name="java.jar.name" value="ejax.jar"/>
<property name="java.jar" location="${bin}/${java.jar.name}"/>
<property name="java.include" location="/usr/lib/jvm/java-6-openjdk/include"/>
<property name="native.build" location="${base.build}/native"/>
<property name="native.src" location="${base.src}/native"/>
<property name="native.classes" value="org.ejax.Curses"/>
<property name="native.src.header" location="${native.src}/ejaxnative.h"/>
<property name="native.src.files" location="${native.src}/ejaxnative.c"/>
<property name="native.build.object" location="${native.build}/ejaxnative.o"/>
<property name="native.build.shared.object" location="${native.build}/libejaxnative.so"/>
<property name="native.shell" location="${native.src}/ejax" />
<property name="javascript.src" location="${base.src}/javascript"/>
<property name="javascript.test.src" location="${base.src}/test/javascript"/>
<property name="javascript.dest" value="${base.build}/html"/>
<property name="javascript.bootstrap.combined" value="${javascript.dest}/ejax-bootstrap-complete.js"/>
<property name="javascript.core.combined" value="${javascript.dest}/ejax-core-complete.js"/>
<property name="javascript.html.combined" value="${javascript.dest}/ejax-complete.js"/>
<property name="javascript.html.minified" value="${javascript.dest}/ejax-complete-min.js"/>
<property name="javascript.terminal.combined" value="${javascript.dest}/ejax-terminal-complete.js"/>
<property name="javascript.browser.combined" value="${javascript.dest}/ejax-browser-complete.js"/>
<property name="yuicompressor.jar" value="${lib}/yuicompressor-2.4.6.jar"/>
<property name="workingdir" location="${base.build}/tmp"/>
<property name="bootstrap.js.files" value="bootstrap.js"/>
<property name="core.js.files" value="monkeypatches.js,util.js,completionTree.js,logger.js,format.js,ejax.js,io.js,screen.js,windows.js,undo.js,buffers.js,bindings.js,modes.js,bindable-commands.js,global.js"/>
<property name="html.js.files" value="jquery-1.5.2.js,${core.js.files},html-io.js"/>
<property name="terminal.js.files" value="${core.js.files},file.js,shell.js,terminal-io.js"/>
<property name="browser.js.files" value="monkeypatches.js,file.js,shell.js,server.js,browser-main.js"/>
<property name="tests.toRun" value=""/>
<!-- Macros -->
<macrodef name="yuicompress">
<attribute name="src" />
<attribute name="dest" />
<attribute name="args" />
<sequential>
<echo level="info">Running yuicompressor on @{src}</echo>
<java jar="${yuicompressor.jar}" fork="true">
<arg line="@{args} -o" />
<arg file="@{dest}" />
<arg file="@{src}" />
</java>
</sequential>
</macrodef>
<macrodef name="concatsource">
<attribute name="destfile" />
<attribute name="sourcedir" />
<attribute name="sourcefiles" />
<attribute name="workingdir" default="${workingdir}" />
<element name="filters" optional="true" description="Additonal filters to apply to individual files"/>
<sequential>
<echo level="info">Concatenating</echo>
<echo level="info"> Source Files : @{sourcefiles}</echo>
<echo level="info"> In Source Dir : @{sourcedir}</echo>
<echo level="info"> To : @{destfile}</echo>
<delete dir="@{workingdir}" quiet="true"/>
<mkdir dir="@{workingdir}"/>
<copy todir="@{workingdir}">
<filelist dir="@{sourcedir}" files="@{sourcefiles}" />
<filterchain>
<filters />
<fixcrlf fixlast="true" eof="remove"/>
</filterchain>
</copy>
<concat destfile="@{destfile}" fixlastline="true" >
<filelist dir="@{workingdir}" files="@{sourcefiles}" />
</concat>
<delete dir="@{workingdir}" quiet="true"/>
</sequential>
</macrodef>
<!-- Paths and filesets -->
<path id="java.classpath">
<pathelement location="${javascript.src}"/>
</path>
<path id="java.test.classpath">
<path refid="java.classpath"/>
<pathelement location="${java.test.build}"/>
<pathelement location="${javascript.test.src}"/>
<pathelement location="${java.jar}"/>
<pathelement location="${javascript.core.combined}"/>
</path>
<!-- Compilation related targets -->
<target name="init" description="Initialize build environment.">
<mkdir dir="${base.build}"/>
<mkdir dir="${java.build.jar}"/>
<mkdir dir="${java.dist}"/>
<mkdir dir="${native.build}"/>
</target>
<target name="compile" depends="init" description="Compile the Java source.">
<javac srcdir="${java.src}" destdir="${java.build.jar}" classpathref="java.classpath" debug="true"/>
<javah class="${native.classes}" outputFile="${native.src.header}" classpath="${java.build.jar}"/>
<echo message="Compiling to object files..."/>
<exec executable="gcc" failonerror="true">
<arg line="-fpic -I${java.include} -c ${native.src.files} -o ${native.build.object}"/>
</exec>
<echo message="Compiling to shared object files..."/>
<exec executable="gcc" failonerror="true">
<arg line="-shared -o ${native.build.shared.object} ${native.build.object} -lcurses"/>
</exec>
</target>
<target name="concat-js" description="Concat the combined javascript files.">
<concatsource destfile="${javascript.bootstrap.combined}" sourcedir="${javascript.src}" sourcefiles="${bootstrap.js.files}"/>
<concatsource destfile="${javascript.core.combined}" sourcedir="${javascript.src}" sourcefiles="${core.js.files}"/>
<concatsource destfile="${javascript.html.combined}" sourcedir="${javascript.src}" sourcefiles="${html.js.files}"/>
<concatsource destfile="${javascript.terminal.combined}" sourcedir="${javascript.src}" sourcefiles="${terminal.js.files}"/>
<concatsource destfile="${javascript.browser.combined}" sourcedir="${javascript.src}" sourcefiles="${browser.js.files}"/>
</target>
<target name="compress-js" depends="concat-js" description="Compress the javascript files.">
<yuicompress src="${javascript.html.combined}" dest="${javascript.html.minified}" args=""/>
</target>
<target name="jar" depends="compile,concat-js,compress-js" description="Prepare and create the jar.">
<copy todir="${java.build.jar}" file="${javascript.bootstrap.combined}"/>
<copy todir="${java.build.jar}" file="${javascript.terminal.combined}"/>
<copy todir="${java.build.jar}" file="${javascript.browser.combined}"/>
<copy todir="${java.build.jar}" file="${javascript.html.minified}"/>
<copy todir="${java.build.jar}" file="${native.build.shared.object}"/>
<copy todir="${java.build.jar}">
<fileset dir="${javascript.src}" includes="**/*.html"/>
</copy>
<jar jarfile="${java.jar}" basedir="${base.build.jar}">
<manifest>
<attribute name="Main-Class" value="org.ejax.Main"/>
</manifest>
</jar>
</target>
<target name="dist" depends="jar" description="Generate the distribution.">
</target>
<target name="clean" description="Clean up.">
<delete dir="${base.build}"/>
<delete dir="${java.dist}"/>
<delete file="${java.jar}"/>
</target>
<target name="clean-all" depends="clean" description="Clean up everything."/>
<!-- Test related targets -->
<target name="test-init" description="Initialize test environment.">
<mkdir dir="${base.build}"/>
<mkdir dir="${java.test.build}"/>
</target>
<target name="test-compile" depends="jar, test-init" description="Compile the Java test source.">
<javac srcdir="${java.test.src}" destdir="${java.test.build}" classpathref="java.test.classpath" debug="true"/>
</target>
<target name="test" depends="test-compile" description="Run the suite of tests.">
<taskdef name="runit" classname="org.ejax.javascript.RUnitTask" classpathref="java.test.classpath"/>
<runit classpathref="java.test.classpath" testsToRun="${tests.toRun}">
<fileset dir="${javascript.test.src}">
<include name="*Test.js"/>
</fileset>
</runit>
</target>
<target name="install" depends="dist">
<exec executable="sudo" failonerror="true">
<arg line="cp ${native.shell} /usr/bin/ejax"/>
</exec>
<exec executable="sudo" failonerror="true">
<arg line="chmod 755 /usr/bin/ejax"/>
</exec>
<exec executable="sudo" failonerror="true">
<arg line="mkdir -p /usr/share/ejax"/>
</exec>
<exec executable="sudo" failonerror="true">
<arg line="cp ${java.jar} /usr/share/ejax/ejax.jar"/>
</exec>
<exec executable="sudo" failonerror="true">
<arg line="chmod 755 /usr/share/ejax/ejax.jar"/>
</exec>
</target>
</project>