Skip to content

Commit

Permalink
Copy native libraries to source tree with Maven action executed only …
Browse files Browse the repository at this point in the history
…on explicit demand and after a test phase (#153)

Copy native libraries to source tree only on explicit demand and after a test phase
  • Loading branch information
pietrygamat authored Nov 10, 2023
1 parent ea2ade2 commit 4fb5e3f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
${{ matrix.image }} \
bash -c \
'apt-get update && apt-get install --yes maven openjdk-11-jdk-headless && \
mvn -B clean install -P dockcross \
mvn -B clean install -P dockcross,update-resources-precompiled \
-Dos.target.name=${{ matrix.os_target_name }} \
-Dos.target.arch=${{ matrix.os_target_arch }} \
-Dos.target.bitness=${{ matrix.os_target_bitness }} \
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
export SDKROOT=$XCODE_12_DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/${{ matrix.sdk-version }}
export CMAKE_OSX_SYSROOT=$SDKROOT
- name: Build with Maven
run: mvn -B clean install -P ${{ matrix.profile }}
run: mvn -B clean install -P ${{ matrix.profile }},update-resources-precompiled

- name: Push recompiled binaries
run: |
Expand Down
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,8 @@ if(CMAKE_STRIP AND NOT CMAKE_BUILD_TYPE MATCHES "Deb")
add_custom_command(TARGET jssc POST_BUILD COMMAND "${CMAKE_STRIP}" ${STRIP_ARGS} $<TARGET_FILE:jssc>)
endif()


# Copy native library to target/classes for processing by junit, maven
add_custom_command(TARGET jssc POST_BUILD
# Copy native library back to source tree
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/natives/ ${CMAKE_CURRENT_SOURCE_DIR}/src/main/resources-precompiled/natives/
# Copy native library back to target/classes tree
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/natives/ ${CMAKE_CURRENT_BINARY_DIR}/../classes/natives/
)

Expand Down
6 changes: 6 additions & 0 deletions ant/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,10 @@
<arg line="${cmake.build.arg}"/>
</exec>
</target>

<target name="update-resources-precompiled">
<copy todir="${ant.project.basedir}/src/main/resources-precompiled/natives/">
<fileset dir="${cmake.generated.directory}/natives/" includes="**" />
</copy>
</target>
</project>
21 changes: 21 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<plugin.signature.version>1.1</plugin.signature.version>
<plugin.source.version>3.0.1</plugin.source.version>
<plugin.surfire.version>3.0.0-M4</plugin.surfire.version>
<update-resources-precompiled.skip>true</update-resources-precompiled.skip>
</properties>

<dependencies>
Expand Down Expand Up @@ -247,6 +248,18 @@
</configuration>
</execution>

<execution>
<id>update-resources-precompiled</id>
<phase>prepare-package</phase>
<goals><goal>run</goal></goals>
<configuration>
<skip>${update-resources-precompiled.skip}</skip>
<target>
<ant dir="ant" target="update-resources-precompiled" />
</target>
</configuration>
</execution>

<execution>
<id>show-file-info</id>
<phase>install</phase>
Expand Down Expand Up @@ -432,6 +445,14 @@
</properties>
</profile>

<!-- Copy newly built native libraries back to source tree -->
<profile>
<id>update-resources-precompiled</id>
<properties>
<update-resources-precompiled.skip>false</update-resources-precompiled.skip>
</properties>
</profile>

<!-- collect existing native libraries for a distribution; skips native compilation -->
<profile>
<id>package</id>
Expand Down

0 comments on commit 4fb5e3f

Please sign in to comment.