Skip to content

Add Unix-like system support in octavelibczi.c #96

Add Unix-like system support in octavelibczi.c

Add Unix-like system support in octavelibczi.c #96

Workflow file for this run

name: Build for Ubuntu-x64 and Windows-x64
on:
workflow_dispatch:
inputs:
create_release:
description: "Should a release be created?"
required: true
default: "false"
type: choice
options:
- "true"
- "false"
push:
permissions:
contents: write
jobs:
build:
name: Build Binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # Windows and Linux builds
outputs:
linuxx64_artifact: ${{ steps.prepare_linux_artifact.outputs.linuxx64_build }}
windowsx64_matlab_artifact: ${{ steps.prepare_windows_matlab_artifact.outputs.windowsx64_matlab_build }}
windowsx64_octave_artifact: ${{ steps.prepare_windows_octave_artifact.outputs.windowsx64_octave_build }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2
- name: run build (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j
- name: run build (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release -j
- name: Prepare artifact (Linux)
id: prepare_linux_artifact
if: runner.os == 'Linux'
shell: bash
run: |
mkdir -p artifacts
name="MEXlibCZI-linux-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp build/MEXlibCZI/MEXlibCZI.mexa64 artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
echo "linuxx64_build=${name}" >> "$GITHUB_OUTPUT"
- name: install Octave (Windows)
if: runner.os == 'Windows'
shell: bash
run: |
choco install octave --no-progress
# I am not sure how to find the octave-cli-executable now, so we search for the link in the start menu
search_dir="/c/ProgramData/Microsoft/Windows/Start Menu/Programs"
octave_link=$(find "$search_dir" -type f -name "Octave*CLI*.lnk" 2>/dev/null)
octave_link_windows_path=$(cygpath -w "$octave_link")
echo "octave_link=$octave_link"
echo "octave_link_windows_path=$octave_link_windows_path"
echo "OCTAVECLI_LINK=$octave_link_windows_path" >> "$GITHUB_ENV"
- name: install Octave (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
sudo apt install octave liboctave-dev
- name: build Octave mex-file (Windows)
if: runner.os == 'Windows'
shell: cmd
run: |
REM We compile the mex file for Octave within Octave itself, this seems the easiest way. The
REM downside is that installing octave takes a long time.
REM Note that we are using cmd.exe here, because it can "execute" the .lnk file.
"%OCTAVECLI_LINK%" --version
REM echo "cd %GITHUB_WORKSPACE%/OctaveMex , mkoctfile --mex octavelibczi.c"
set "GITHUB_WORKSPACE_FORWARD_SLASHES=%GITHUB_WORKSPACE:\=/%
"%OCTAVECLI_LINK%" --eval "cd %GITHUB_WORKSPACE_FORWARD_SLASHES%/OctaveMex , mkoctfile --mex octavelibczi.c"
# now, copy the libmexlibczi.dll to this folder
cp build/MEXlibCZI/Release/libmexlibczi.dll %GITHUB_WORKSPACE%\OctaveMex
dir %GITHUB_WORKSPACE%\OctaveMex
- name: build Octave mex-file (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
cd OctaveMex
octave --evalsu "mkoctfile --mex octavelibczi.c"
cp build/MEXlibCZI/Release/libmexlibczi.so .
ls
- name: Prepare MATLAB-mex artifact (Windows)
id: prepare_windows_matlab_artifact
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p artifacts
name="MATLAB-MEXlibCZI-windows-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp build/MEXlibCZI/Release/MEXlibCZI.mexw64 artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
echo "windowsx64_matlab_build=${name}" >> $GITHUB_OUTPUT
- name: Upload MATLAB-mex artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.artifactPath }}/
name: ${{ env.artifactName }}
- name: Prepare Octave-mex artifact (Windows)
id: prepare_windows_octave_artifact
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p artifacts
name="Octave-MEXlibCZI-windows-x64-$(git describe --always)"
mkdir -p artifacts/${name}
cp $(cygpath "${GITHUB_WORKSPACE}")/libmexlibczi/libmexlibczi.dll artifacts/${name}/
cp $(cygpath "${GITHUB_WORKSPACE}")/OctaveMex/octavelibczi.mex artifacts/${name}/
echo "artifactName=${name}" >> "$GITHUB_ENV"
echo "artifactPath=artifacts/${name}" >> "$GITHUB_ENV"
echo "windowsx64_octave_build=${name}" >> $GITHUB_OUTPUT
- name: Upload Octave-mex artifacts
uses: actions/upload-artifact@v4
if: runner.os == 'Windows' # currently we only build Octave mex files on Windows
with:
path: ${{ env.artifactPath }}/
name: ${{ env.artifactName }}
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
if: inputs.create_release == 'true' # Only run if release is selected
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Download All Artifacts
if: needs.build.outputs.linuxx64_artifact != '' || needs.build.outputs.windowsx64_matlab_artifact != ''
uses: actions/download-artifact@v4
with:
path: ./artifacts # download to a specific folder
- name: Script to prepare release
shell: bash
run: |
cd scripts
mexlibczi_version=$(bash get_version.sh)
cd ..
git_version=$(git describe --always)
echo "releaseName=version ${mexlibczi_version} (${git_version})" >> "$GITHUB_ENV"
echo "tagName=v${mexlibczi_version}" >> "$GITHUB_ENV"
- name: Release
uses: softprops/action-gh-release@v2
with:
name: ${{ env.releaseName }}
tag_name: ${{ env.tagName }}
files: |
./artifacts/${{ needs.build.outputs.linuxx64_artifact }}/MEXlibCZI.mexa64
./artifacts/${{ needs.build.outputs.windowsx64_matlab_artifact }}/MEXlibCZI.mexw64
prerelease: true