change deprecated #128
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ main, deploy-to-scijava ] | |
pull_request: | |
branches: [ main ] | |
env: | |
opencl-icd-loader-git-tag: "v2023.04.17" | |
opencl-headers-git-tag: "v2023.04.17" | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
name: [ubuntu, windows, macos] | |
include: | |
- name: ubuntu | |
os: ubuntu-latest | |
c-compiler: "gcc" | |
cxx-compiler: "g++" | |
cmake-build-type: "Release" | |
cmake-build-flag: "" | |
- name: windows | |
os: windows-latest | |
c-compiler: "cl.exe" | |
cxx-compiler: "cl.exe" | |
cmake-build-type: "Release" | |
cmake-build-flag: "-A x64" | |
- name: macos | |
os: macos-13 | |
c-compiler: "clang" | |
cxx-compiler: "clang++" | |
cmake-build-type: "Release" | |
cmake-build-flag: "" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Install ocl-icd-loader - windows | |
if: runner.os == 'Windows' | |
run: | | |
cd .. | |
git clone --branch ${{ env.opencl-icd-loader-git-tag }} https://github.com/KhronosGroup/OpenCL-ICD-Loader | |
git clone --branch ${{ env.opencl-headers-git-tag }} https://github.com/KhronosGroup/OpenCL-Headers | |
cmake -S "./OpenCL-Headers" -B "./OpenCL-Headers/build" | |
cmake --build "./OpenCL-Headers/build" --parallel 6 --target install | |
cmake -D CMAKE_PREFIX_PATH="./OpenCL-Headers" -D OPENCL_ICD_LOADER_HEADERS_DIR="./OpenCL-Headers/" -S "./OpenCL-ICD-Loader" -B "./OpenCL-ICD-Loader/build" -A x64 | |
cmake --build "./OpenCL-ICD-Loader/build" --parallel 6 --target install --config Release | |
shell: bash -l {0} | |
- name: Increase swapfile on Ubuntu | |
if: runner.os == 'Linux' | |
run: | | |
sudo swapoff -a | |
sudo fallocate -l 15G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo swapon --show | |
- name: Install openCL on Ubuntu | |
if: runner.os == 'Linux' | |
run: sudo apt install ocl-icd-opencl-dev | |
- name: Build with Maven | |
run: mvn clean install -DskipTests | |
shell: bash | |
- name: Run Java class (only possible on MacOS) | |
if: contains(matrix.os, 'macos') | |
run: | | |
mvn dependency:build-classpath -Dmdep.outputFile=classpath.txt | |
java -cp target/classes:$(cat classpath.txt) net.clesperanto.ClesperantoJ | |
- name: Get Maven Version and Upload Artifact | |
shell: bash | |
run: | | |
MVN_VERSION=$(mvn -q \ | |
-Dexec.executable=echo \ | |
-Dexec.args='${project.version}' \ | |
--non-recursive \ | |
exec:exec) | |
MVN_NAME=$(mvn -q \ | |
-Dexec.executable=echo \ | |
-Dexec.args='${project.name}' \ | |
--non-recursive \ | |
exec:exec) | |
echo "version=${MVN_VERSION}" >> $GITHUB_OUTPUT | |
echo "name=${MVN_NAME}" >> $GITHUB_OUTPUT | |
id: mvn_info | |
- name: Upload native library | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.name }}-artifact | |
path: target/${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar | |
create-jar: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Download all platform-specific JAR files | |
uses: actions/download-artifact@v4 | |
- name: understand what is downlaoded | |
run: ls | |
- name: Get Maven Version and Upload Artifact | |
run: | | |
MVN_VERSION=$(mvn -q \ | |
-Dexec.executable=echo \ | |
-Dexec.args='${project.version}' \ | |
--non-recursive \ | |
exec:exec) | |
MVN_NAME=$(mvn -q \ | |
-Dexec.executable=echo \ | |
-Dexec.args='${project.name}' \ | |
--non-recursive \ | |
exec:exec) | |
echo "version=${MVN_VERSION}" >> $GITHUB_OUTPUT | |
echo "name=${MVN_NAME}" >> $GITHUB_OUTPUT | |
id: mvn_info | |
# There is no specific reason to select the JAR file containing the macos dynamic libraries as the final one, we could have selected any other | |
- name: Select one of the JARs as the JAR to be the final | |
run: | | |
mv macos-artifact/${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar ${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar | |
- name: Add Linux and Windows dynamic libraries | |
run: | | |
jar xf ubuntu-artifact/${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar net/clesperanto/linux-x86_64 | |
jar xf windows-artifact/${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar net/clesperanto/windows-x86_64 | |
jar uf ${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar -C . net/clesperanto | |
- name: Upload final JAR | |
uses: actions/upload-artifact@v4 | |
with: | |
name: final-jar | |
path: ${{steps.mvn_info.outputs.name}}-${{steps.mvn_info.outputs.version}}.jar |