Skip to content

Commit 4ed7ac2

Browse files
authored
Ensure we correctly produce native artifact on macos and linux (java-native-access#8)
Motivation: We should ensure we can produce a native artifact that works on macos and on linux Modification: - Add the correct ldflags - Delete shared lib so we not link against it. Result: Works on macos and linux
1 parent 72766e3 commit 4ed7ac2

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

pom.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,33 @@
8181
<generatedSourcesDir>${project.build.directory}/generated-sources</generatedSourcesDir>
8282
<cflags>-Werror -fno-omit-frame-pointer -fvisibility=hidden -Wunused -Wno-unused-value -O3 -I${quicheCheckoutDir}/include</cflags>
8383
<ldflags>-L${quicheBuildDir} -lquiche</ldflags>
84+
<extraLdflags></extraLdflags>
8485
</properties>
8586

87+
<profiles>
88+
<profile>
89+
<id>mac</id>
90+
<activation>
91+
<os>
92+
<family>mac</family>
93+
</os>
94+
</activation>
95+
<properties>
96+
<extraLdflags>-Wl,-exported_symbol,_JNI_*</extraLdflags>
97+
</properties>
98+
</profile>
99+
<profile>
100+
<id>linux</id>
101+
<activation>
102+
<os>
103+
<family>linux</family>
104+
</os>
105+
</activation>
106+
<properties>
107+
<extraLdflags>-Wl,--exclude-libs,ALL -lrt</extraLdflags>
108+
</properties>
109+
</profile>
110+
</profiles>
86111
<build>
87112
<extensions>
88113
<extension>
@@ -185,6 +210,12 @@
185210
<exec executable="cargo" failonerror="true" dir="${quicheCheckoutDir}" resolveexecutable="true">
186211
<arg value="build" />
187212
</exec>
213+
<!-- delete the shared library as otherwise we may link against it and not against the static
214+
library.
215+
-->
216+
<delete>
217+
<fileset dir="${quicheBuildDir}" includes="*.so" />
218+
</delete>
188219
</else>
189220
</if>
190221
<if>
@@ -431,7 +462,7 @@
431462
<verbose>true</verbose>
432463
<configureArgs>
433464
<configureArg>CFLAGS=${cflags}</configureArg>
434-
<configureArg>LDFLAGS=${ldflags}</configureArg>
465+
<configureArg>LDFLAGS=${ldflags} ${extraLdflags}</configureArg>
435466
<configureArg>--libdir=${project.build.directory}/native-build/target/lib</configureArg>
436467
</configureArgs>
437468
</configuration>

0 commit comments

Comments
 (0)