-
Notifications
You must be signed in to change notification settings - Fork 0
/
pom.xml
470 lines (443 loc) · 21.3 KB
/
pom.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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.regwhitton</groupId>
<artifactId>video-capture-inventory</artifactId>
<version>0.1.1</version>
<packaging>jar</packaging>
<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/regwhitton/video-capture-inventory</url>
</scm>
<!--
By default: the Java API and the native shared library for the current platform is built.
During a Gitlab build, profiles will be activated from the command line using -P option.
-Pjava-only - all native shared libraries are skipped.
-Pnatives-only - the Java API is skipped.
-Praspberrypi - also cross-compile native shared library for Raspberry Pi using docker.
Use only on Linux, but not on a Raspberry Pi.
NOT CURRENTLY WORKING.
-->
<profiles>
<!--
Release build profile for just the default jar containing the Java API.
-->
<profile>
<id>java-only</id>
<properties>
<win.natives.build.skip>true</win.natives.build.skip>
<linux.natives.build.skip>true</linux.natives.build.skip>
<rpi.natives.build.skip>true</rpi.natives.build.skip>
<java-api.jar.phase>package</java-api.jar.phase>
<win.natives.jar.phase>none</win.natives.jar.phase>
<linux.natives.jar.phase>none</linux.natives.jar.phase>
<rpi.natives.jar.phase>none</rpi.natives.jar.phase>
</properties>
</profile>
<!--
Release build profile to exclude the default jar containing the Java API.
-->
<profile>
<id>natives-only</id>
<properties>
<java-api.jar.phase>none</java-api.jar.phase>
</properties>
</profile>
<!--
Cross-compile shared library for Raspberry Pi (in addition to current native).
-->
<profile>
<id>raspberrypi</id>
<properties>
<rpi.natives.build.skip>false</rpi.natives.build.skip>
<rpi.natives.jar.phase>package</rpi.natives.jar.phase>
</properties>
</profile>
<!--
Detect the current platform and configure building/jaring native shared library for it
-->
<profile>
<id>windows-natives</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<!--
In the JVM, the java.home property points to the JRE not the JDK.
JAVA_HOME points to JDK on target build machine:
https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners#windows-server-2019
However, in Cygwin/MinGW environment, Maven changes JAVA_HOME
to Unix style but g++ doesn't understand it.
So we setup jdk.home to points to JDK by assuming it is folder above JRE.
-->
<win.jdk.home>${java.home}/..</win.jdk.home>
<win.natives.build.skip>false</win.natives.build.skip>
<win.natives.jar.phase>package</win.natives.jar.phase>
</properties>
</profile>
<profile>
<id>linux-natives</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<properties>
<linux.jdk.home>${java.home}/..</linux.jdk.home>
<linux.natives.build.skip>false</linux.natives.build.skip>
<linux.natives.jar.phase>package</linux.natives.jar.phase>
</properties>
</profile>
<profile>
<id>linux-x86_64</id>
<activation>
<os>
<family>linux</family>
<arch>x86-64</arch>
</os>
</activation>
<properties>
<platform>linux-x86_64</platform>
</properties>
</profile>
<profile>
<id>linux-amd64</id>
<activation>
<os>
<family>linux</family>
<arch>amd64</arch>
</os>
</activation>
<properties>
<platform>linux-x86_64</platform>
</properties>
</profile>
<profile>
<id>linux-armhf-raspberrypi</id>
<activation>
<os>
<family>linux</family>
<arch>arm</arch>
</os>
<file>
<exists>/etc/rpi-issue</exists>
</file>
</activation>
<properties>
<platform>linux-armhf</platform>
</properties>
</profile>
<!--
Create javadoc and sources (java & cpp) artifacts, if profile given on command line.
-->
<profile>
<id>sources-javadoc</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper.plugin.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/cpp</source>
</sources>
<doclint>none</doclint>
<show>public</show>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${sources.plugin.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadocs.plugin.version}</version>
<executions>
<execution>
<id>attach-javadoc</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<properties>
<win.natives.build.skip>true</win.natives.build.skip>
<linux.natives.build.skip>true</linux.natives.build.skip>
<rpi.natives.build.skip>true</rpi.natives.build.skip>
<java-api.jar.phase>package</java-api.jar.phase>
<win.natives.jar.phase>none</win.natives.jar.phase>
<linux.natives.jar.phase>none</linux.natives.jar.phase>
<rpi.natives.jar.phase>none</rpi.natives.jar.phase>
<generated.includes>${project.build.directory}/generated-includes</generated.includes>
<natives>${project.build.directory}/natives</natives>
<compiler.plugin.version>3.1</compiler.plugin.version>
<antrun.plugin.version>1.8</antrun.plugin.version>
<jar.plugin.version>3.2.0</jar.plugin.version>
<build-helper.plugin.version>3.0.0</build-helper.plugin.version>
<sources.plugin.version>3.2.0</sources.plugin.version>
<javadocs.plugin.version>3.1.1</javadocs.plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!--
While compiling java create C++ header files
for the native code and bundle them into the jar.
-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-Xlint</arg>
<arg>-h</arg>
<arg>${generated.includes}</arg>
</compilerArgs>
</configuration>
</plugin>
<!--
Compile the native shared library
-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${antrun.plugin.version}</version>
<executions>
<execution>
<id>windows-natives-build</id>
<phase>process-classes</phase>
<configuration>
<skip>${win.natives.build.skip}</skip>
<target>
<mkdir dir="${natives}/windows-x86_64" />
<echo message="Compiling windows-x86_64" />
<!-- Old version of MinGW64 g++ on Github runner has something missing.
<exec executable="g++" failonerror="true" >
<arg value="-m64" />
<arg value="-Wall" />
<arg value="-Werror" />
<arg value="-shared" />
<arg value="-I${win.jdk.home}/include" />
<arg value="-I${win.jdk.home}/include/win32" />
<arg value="-I${generated.includes}" />
<arg value="${basedir}/src/main/cpp/Win/VideoCaptureInventoryWin.cpp" />
<arg value="-o${natives}/windows-x86_64/vidcapinv.dll" />
<arg value="-Wl,-REMOVE-add-stdcall-alias" />
<arg value="-lsetupapi" />
<arg value="-lole32" />
<arg value="-loleaut32" />
<arg value="-lmf" />
<arg value="-lmfplat" />
<arg value="-lstrmiids" />
</exec>
-->
<!--
Switching to hard to find MSVC on Gitlab runner.
To build locally - install "Build Tools for Visual Studio 2019"
from https://visualstudio.microsoft.com/downloads
And set up MSVC, INCLUDE, LIB and LIBPATH environment vars (in bash):
export MSVC="C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610"
WINKIT="C:/Program Files (x86)/Windows Kits/10"
WINKITREL="10.0.18362.0"
WININC="$WINKIT/include/$WINKITREL"
export INCLUDE="$MSVC/include;$WININC/ucrt;$WININC/shared;$WININC/um;$WININC/winrt;$WININC/cppwinrt"
export LIB="$MSVC/lib/x64;$WINKIT/lib/$WINKITREL/ucrt/x64;$WINKIT/lib/$WINKITREL/um/x64"
export LIBPATH="$MSVC/lib/x64"
-->
<exec executable="${env.MSVC}/bin/HostX64/x64/cl" failonerror="true" >
<arg value="/Wall" />
<arg value="/I${win.jdk.home}/include" />
<arg value="/I${win.jdk.home}/include/win32" />
<arg value="/I${generated.includes}" />
<arg value="/D_USRDLL" />
<arg value="/D_WINDLL" />
<arg value="${basedir}/src/main/cpp/Win/VideoCaptureInventoryWin.cpp" />
<arg value="/Fo${natives}/windows-x86_64/VideoCaptureInventoryWin.obj" />
<arg value="/link" />
<arg value="/DLL" />
<arg value="/OUT:${natives}/windows-x86_64/vidcapinv.dll" />
<arg value="setupapi.lib" />
<arg value="ole32.lib" />
<arg value="oleaut32.lib" />
<arg value="mf.lib" />
<arg value="mfplat.lib" />
<arg value="strmiids.lib" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>linux-natives-build</id>
<phase>process-classes</phase>
<configuration>
<skip>${linux.natives.build.skip}</skip>
<target>
<mkdir dir="${natives}/${platform}" />
<echo message="Compiling ${platform}" />
<exec executable="g++" failonerror="true" >
<arg value="-fPIC" />
<arg value="-Wall" />
<arg value="-Werror" />
<arg value="-shared" />
<arg value="-I${linux.jdk.home}/include" />
<arg value="-I${linux.jdk.home}/include/linux" />
<arg value="-I${generated.includes}" />
<arg value="${basedir}/src/main/cpp/linux/VideoCaptureInventoryLinux.cpp" />
<arg value="-o${basedir}/target/natives/${platform}/libvidcapinv.so" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<!--
<execution>
<id>rpi-natives-build</id>
<phase>process-classes</phase>
<configuration>
<skip>${rpi.natives.build.skip}</skip>
<target>
<mkdir dir="${natives}/armhf" />
<echo message="Compiling armhf for Raspberry Pi" />
<exec executable="docker" failonerror="true" >
<arg value="run" />
<arg value="-v${basedir}:/workdir" />
<arg value="-w/workdir" />
<arg value="-v${linux.jdk.home}/include:/jdk-include" />
<arg value="- -rm" />
<arg value="balenalib/raspberrypi3" />
<arg value="g++" />
<arg value="-fPIC" />
<arg value="-Wall" />
<arg value="-Werror" />
<arg value="-shared" />
<arg value="-I/jdk-include" />
<arg value="-I/jdk-include/linux" />
<arg value="-I${generated.includes}" />
<arg value="${basedir}/src/main/cpp/linux/VideoCaptureInventoryLinux.cpp" />
<arg value="-o${basedir}/target/natives/armhf/libvidcapinv.so" />
</exec>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
-->
</executions>
</plugin>
<!--
Jar java-api as main artifact and each native share library with its own classifier.
-->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${jar.plugin.version}</version>
<executions>
<execution>
<id>default-jar</id>
<!-- Setting to "none" stop production of default jar -->
<phase>${java-api.jar.phase}</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
<execution>
<id>windows-x86_64-jar</id>
<phase>${win.natives.jar.phase}</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>windows-x86_64</classifier>
<classesDirectory>${natives}/windows-x86_64</classesDirectory>
</configuration>
</execution>
<execution>
<id>linux-jar</id>
<phase>${linux.natives.jar.phase}</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>${platform}</classifier>
<classesDirectory>${natives}/${platform}</classesDirectory>
</configuration>
</execution>
<execution>
<id>rpi-jar</id>
<phase>${rpi.natives.jar.phase}</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>armhf</classifier>
<classesDirectory>${natives}/armhf</classesDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>cz.adamh.utils</groupId>
<artifactId>native-utils</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>github</id>
<name>GitHub regwhitton Apache Maven Packages</name>
<url>https://maven.pkg.github.com/regwhitton/native-utils</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub regwhitton Apache Maven Packages</name>
<url>https://maven.pkg.github.com/regwhitton/video-capture-inventory</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</distributionManagement>
</project>