-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
230 lines (201 loc) · 8.63 KB
/
build.xml
File metadata and controls
230 lines (201 loc) · 8.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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?xml version="1.0"?>
<project name="Ser321 Assign5 C++ Media Library, build file."
default="targets" basedir="."
xmlns="antlib:org.apache.tools.ant">
<taskdef resource="cpptasks.tasks"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<property name="src.dir" value="./src"/>
<property name="lib" value="./lib" />
<property name="dist.dir" value="bin"/>
<property name="obj.dir" value="obj"/>
<property name="host" value="localhost"/>
<property name="port" value="8888"/>
<property name="json.file.name" value="MediaLibraryMethods.json"/>
<property name="omdbkey" value="myomdbkey"/>
<property environment="env"/>
<property name="userId" value="${env.USER}"/>
<property name="imagefile" value="seriesImage.jpg"/>
<!--Set the ostype property: <property name="ostype" value="${env.OSTYPE}"/>-->
<condition property="ostype" value="${env.OSTYPE}">
<isset property="env.OSTYPE" />
</condition>
<condition property="ostype" value="env.OSTYPE_inaccessable">
<not>
<isset property="env.OSTYPE" />
</not>
</condition>
<!--Set the dyldpath property <var name="dyldpath" value="${env.DYLD_FALLBACK_LIBRARY_PATH}"/>-->
<condition property="dyldpath" value="${env.DYLD_FALLBACK_PATH}">
<isset property="env.DYLD_FALLBACK_PATH" />
</condition>
<condition property="dyldpath" value="env.DYLD_FALLBACK_PATH_inaccessible">
<not>
<isset property="env.DYLD_FALLBACK_PATH" />
</not>
</condition>
<!-- Targets -->
<target name="targets">
<echo message="targets are clean, prepare, build.cpp.server, build.cpp.client, build.all, server, client, targets"/>
<echo message="execute cpp server: ant server -Dport=${port}"/>
<echo message="execute cpp client: ant client -Dhost=${host} -Dport=${port} -DuserId=${userId} -Domdbkey=${omdbkey}"/>
</target>
<!-- Clean -->
<target name="clean">
<delete dir="${dist.dir}" failonerror="false"/>
<delete dir="${obj.dir}" failonerror="false"/>
<delete dir="log" failonerror="false"/>
<delete file="log.txt" failonerror="false"/>
<delete file="logerrors.txt" failonerror="false"/>
<delete file="logpid.txt" failonerror="false"/>
<delete file="${src.dir}/server/mediaserverstub.h"
failonerror="false"/>
<delete file="${src.dir}/client/mediaclientstub.h"
failonerror="false"/>
<delete file="${imagefile}" failonerror="false"/>
</target>
<!-- Prepare -->
<target name="prepare">
<mkdir dir="${dist.dir}" />
<mkdir dir="log" />
<mkdir dir="${obj.dir}/client" />
<mkdir dir="${obj.dir}/server" />
<if>
<isset property="env.USERNAME"/>
<then>
<echo message="detected username is: ${env.USERNAME}"/>
</then>
<elseif>
<isset property="env.USER"/>
<then>
<echo message="detected user is: ${env.USER}"/>
</then>
</elseif>
</if>
<echo message="host name is: ${os.name}"/>
<echo message="host arch is: ${os.arch}"/>
<echo message="host version is: ${os.version}"/>
<echo message="base directory is: ${basedir}"/>
<!-- Platform identification : Only tested Linux prepare path; may not work with other systems -->
<condition property="build.host.islinux">
<and>
<os family="unix" />
<not>
<contains string="${os.name}" substring="mac"
casesensitive="false" />
</not>
</and>
</condition>
<condition property="build.host.platform" value="linux">
<isset property="build.host.islinux" />
</condition>
<condition property="build.host.ismac">
<and>
<os family="unix" />
<contains string="${os.name}" substring="mac" casesensitive="false"/>
</and>
</condition>
<condition property="build.host.platform" value="mac">
<isset property="build.host.ismac" />
</condition>
<fail unless="build.host.platform"
message="Building on ${os.name} is not supported" />
<echo message="build.host.platform is: ${build.host.platform}"/>
<if>
<isset property="build.host.ismac"/>
<then>
<echo message="detected a mac host"/>
<property name="cxxflag" value="-std=c++14"/>
<property name="includepath" value="/opt/local/include:/usr/local/include"/>
<property name="client.lib.path" value="/opt/local/lib"/>
<property name="client.lib.list" value="c++,jsoncpp,jsonrpccpp-client,jsonrpccpp-common,microhttpd,stdc++"/>
<property name="server.lib.path" value="/opt/local/lib"/>
<property name="server.lib.list" value="c++,jsoncpp,jsonrpccpp-server,jsonrpccpp-common,microhttpd"/>
</then>
<elseif>
<isset property="build.host.islinux"/>
<then>
<echo message="detected a linux host"/>
<property name="cxxflag" value="-std=c++14"/>
<property name="includepath" value="/usr/local/include:/usr/include/jsoncpp"/>
<property name="client.lib.path" value="/usr/local/lib"/>
<property name="client.lib.list" value="jsoncpp,jsonrpccpp-client,jsonrpccpp-common,microhttpd,stdc++"/>
<property name="server.lib.path" value="/usr/local/lib"/>
<property name="server.lib.list" value="jsoncpp,jsonrpccpp-server,jsonrpccpp-common,microhttpd,stdc++"/>
</then>
</elseif>
<else>
<echo message="failed to detect a host I know how to build on"/>
</else>
</if>
</target>
<!-- Build all (server and client) -->
<target name="build.all"
depends="clean,prepare,build.cpp.server,build.cpp.client"
description="Clean then build cpp server, cpp client"/>
<!-- Generate Client Stub -->
<target name="generate.client.stub" depends="prepare">
<exec dir="${basedir}" executable="jsonrpcstub">
<arg line="${json.file.name} --cpp-client=mediaclientstub"/>
</exec>
<copy file="mediaclientstub.h"
tofile="${src.dir}/client/mediaclientstub.h"/>
<delete file="mediaclientstub.h"/>
</target>
<!-- Build Client -->
<target name="build.cpp.client" depends="generate.client.stub">
<cc outtype="executable" subsystem="console"
outfile="${dist.dir}/MediaRPCClient"
objdir="${obj.dir}/client">
<compilerarg value="${cxxflag}"/>
<includepath>
<pathelement path="${includepath}"/>
</includepath>
<libset dir="/usr/lib" libs="stdc++,fltk,fltk_images,curl,jsoncpp,pthread"/>
<libset dir="/usr/local/lib" libs="curlpp"/>
<libset dir="${client.lib.path}" libs="${client.lib.list}"/>
<fileset dir="${src.dir}/client"
includes="MediaClientGui.cpp,MediaClient.cpp"/>
<fileset dir="${src.dir}/server"
includes="SeriesSeason.cpp,Episode.cpp,MediaLibrary.cpp"/>
</cc>
</target>
<!-- Generate Server Stub -->
<target name="generate.server.stub" depends="prepare">
<exec dir="${basedir}" executable="jsonrpcstub">
<arg line="${json.file.name} --cpp-server=mediaserverstub"/>
</exec>
<copy file="mediaserverstub.h"
tofile="${src.dir}/server/mediaserverstub.h"/>
<delete file="mediaserverstub.h"/>
</target>
<!-- Build Server -->
<target name="build.cpp.server" depends="generate.server.stub">
<cc outtype="executable" subsystem="console"
outfile="${dist.dir}/MediaRPCServer"
objdir="${obj.dir}/server">
<compilerarg value="${cxxflag}"/>
<includepath>
<pathelement path="${includepath}"/>
</includepath>
<libset dir="/usr/lib" libs="stdc++,fltk,fltk_images,curl,jsoncpp,pthread"/>
<libset dir="/usr/local/lib" libs="curlpp"/>
<libset dir="${server.lib.path}" libs="${server.lib.list}"/>
<fileset dir="${src.dir}/server"
includes="Episode.cpp,SeriesSeason.cpp,MediaLibrary.cpp,MediaLibraryServer.cpp"/>
</cc>
</target>
<!-- Run Client -->
<target name="client" depends ="build.cpp.client">
<echo message="./bin/MediaRPCClient ${host} ${port} ${userId} ${omdbkey}"/>
<exec executable="./bin/MediaRPCClient">
<arg line= " ${host} ${port} ${userId} ${omdbkey} "/>
</exec>
</target>
<!-- Run Server -->
<target name="server" depends ="build.cpp.server">
<echo message="./bin/MediaRPCServer ${port}"/>
<exec executable="./bin/MediaRPCServer">
<arg line= " ${port}"/>
</exec>
</target>
</project>