forked from mapsforge/vtm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-windows64.xml
192 lines (176 loc) · 6.54 KB
/
build-windows64.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
<project name="vtm-jni-Windows-64" basedir="." default="postcompile">
<!-- include the environment -->
<property environment="env"/>
<!-- output directory for temporary object files -->
<property name="buildDir" value="target/windows64" />
<!-- output directory for the shared library -->
<property name="libsDir" value="../libs/windows64" />
<!-- the name of the shared library -->
<property name="libName" value="vtm-jni64.dll"/>
<!-- the jni header jniPlatform to use -->
<property name="jniPlatform" value="win32"/>
<!-- the compiler to use when compiling c files -->
<property name="cCompiler" value="gcc"/>
<!-- the compiler to use when compiling c++ files -->
<property name="cppCompiler" value="g++"/>
<!-- the command to use when archiving files -->
<property name="archiver" value="ar"/>
<!-- the compilerPrefix for the C & C++ compilers -->
<property name="compilerPrefix" value="x86_64-w64-mingw32-"/>
<!-- the compilerSuffix for the C & C++ compilers -->
<property name="compilerSuffix" value=".exe" />
<!-- define gcc compiler, options and files to compile -->
<property name="gcc" value="${compilerPrefix}${cCompiler}${compilerSuffix}"/>
<property name="gcc-opts" value="-c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m64 -Wall -std=c99 -O2 -ffast-math -DNDEBUG"/>
<fileset id="gcc-files" dir="./">
<exclude name="target/"/>
<include name="memcpy_wrap.c"/>
<include name="gl/utils.c"/>
<include name="libtess2/Source/bucketalloc.c"/>
<include name="libtess2/Source/dict.c"/>
<include name="libtess2/Source/geom.c"/>
<include name="libtess2/Source/mesh.c"/>
<include name="libtess2/Source/priorityq.c"/>
<include name="libtess2/Source/sweep.c"/>
<include name="libtess2/Source/tess.c"/>
</fileset>
<!-- define g++ compiler, options and files to compile -->
<property name="g++" value="${compilerPrefix}${cppCompiler}${compilerSuffix}"/>
<property name="g++-opts" value="-v -c -Wall -O2 -mfpmath=sse -msse2 -fmessage-length=0 -m64 -Wall -std=c99 -O2 -ffast-math -DNDEBUG -fpermissive"/>
<fileset id="g++-files" dir="./">
<exclude name="target/"/>
<include name="**/*.cpp"/>
</fileset>
<!-- define linker and options -->
<property name="linker" value="${compilerPrefix}${cppCompiler}${compilerSuffix}"/>
<property name="linker-opts" value="-Wl,--kill-at -shared -static -static-libgcc -static-libstdc++ -m64"/>
<property name="libraries" value=""/>
<!-- define stripper -->
<property name="stripper" value="${compilerPrefix}strip${compilerSuffix}"/>
<!-- cleans the build directory, removes all object files and shared libs -->
<target name="clean">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${buildDir}"/>
<fileset dir="${libsDir}" includes="**/*"/>
</delete>
</target>
<target name="precompile" depends="clean">
<condition property="compiler-found">
<and>
<or>
<!-- Include both b/c Windows might be either -->
<available file="${g++}" filepath="${env.PATH}"/>
<available file="${g++}" filepath="${env.Path}"/>
</or>
<or>
<!-- Include both b/c Windows might be either -->
<available file="${gcc}" filepath="${env.PATH}"/>
<available file="${gcc}" filepath="${env.Path}"/>
</or>
</and>
</condition>
<condition property="has-compiler">
<equals arg1="${compiler-found}" arg2="true"/>
</condition>
<condition property="stripper-found">
<or>
<!-- Include both b/c Windows might be either -->
<available file="${stripper}" filepath="${env.PATH}"/>
<available file="${stripper}" filepath="${env.Path}"/>
</or>
</condition>
<condition property="should-strip">
<and>
<equals arg1="${stripper-found}" arg2="true"/>
<equals arg1="${release}" arg2="true"/>
<!-- Don't strip mac osx libs -->
<not>
<contains string="${libName}" substring="dylib"/>
</not>
</and>
</condition>
</target>
<target name="create-build-dir" depends="precompile" if="has-compiler">
<!-- FIXME this is pretty nasty :/ -->
<copy todir="${buildDir}">
<fileset refid="g++-files"/>
<fileset refid="gcc-files"/>
</copy>
<delete>
<fileset dir="${buildDir}">
<include name="*"/>
<exclude name="*.o"/>
</fileset>
</delete>
</target>
<!-- compiles all C and C++ files to object files in the build directory -->
<target name="compile" depends="create-build-dir" if="has-compiler">
<mkdir dir="${buildDir}"/>
<apply failonerror="true" executable="${g++}" dest="${buildDir}" verbose="true">
<arg line="${g++-opts}"/>
<arg value="-Ijni-headers"/>
<arg value="-Ijni-headers/${jniPlatform}"/>
<arg value="-I."/>
<arg value="-I."/>
<arg value="-Ilibtess2/Include"/>
<srcfile/>
<arg value="-o"/>
<targetfile/>
<fileset refid="g++-files"/>
<compositemapper>
<mapper type="glob" from="*.cpp" to="*.o"/>
<mapper type="glob" from="*.mm" to="*.o"/>
</compositemapper>
</apply>
<apply failonerror="true" executable="${gcc}" dest="${buildDir}" verbose="true">
<arg line="${gcc-opts}"/>
<arg value="-Ijni-headers"/>
<arg value="-Ijni-headers/${jniPlatform}"/>
<arg value="-I."/>
<arg value="-I."/>
<arg value="-Ilibtess2/Include"/>
<arg value="-Ilibtess2/Source"/>
<srcfile/>
<arg value="-o"/>
<targetfile/>
<fileset refid="gcc-files"/>
<compositemapper>
<mapper type="glob" from="*.c" to="*.o"/>
<mapper type="glob" from="*.m" to="*.o"/>
</compositemapper>
</apply>
</target>
<!-- links the shared library based on the previously compiled object files -->
<target name="link" depends="compile" if="has-compiler">
<fileset dir="${buildDir}" id="objFileSet">
<patternset>
<include name="**/*.o" />
</patternset>
</fileset>
<pathconvert pathsep=" " property="objFiles" refid="objFileSet" />
<mkdir dir="${libsDir}" />
<exec executable="${linker}" failonerror="true" dir="${buildDir}">
<arg line="${linker-opts}" />
<arg value="-o" />
<arg path="${libsDir}/${libName}" />
<arg line="${objFiles}"/>
<arg line="${libraries}" />
</exec>
</target>
<!-- strips the shared library of debug symbols -->
<target name="strip" depends="link" if="should-strip">
<exec executable="${stripper}" failonerror="true" dir="${buildDir}">
<arg value="--strip-unneeded"/>
<arg path="${libsDir}/${libName}" />
</exec>
</target>
<!-- copy dll into dev environment -->
<target name="copyDLL" depends="link">
<copy
file ="${libsDir}/${libName}"
todir ="C:/DAT/MT/mytourbook/bundles/net.tourbook.ext.vtm.windows/natives"
/>
</target>
<target name="postcompile" depends="strip,copyDLL">
</target>
</project>