-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add first GitHub Action that download a CasADi version and generate v…
…ia custom SWIG the MATLAB bindings (#1)
- Loading branch information
1 parent
a17cb04
commit bab788b
Showing
1 changed file
with
100 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Regenerate MATLAB bindings | ||
# This action regenerates the MATLAB bindings for CasADi | ||
# Inspired from: | ||
# * https://github.com/robotology/yarp-matlab-bindings/blob/master/.github/workflows/regenerate-matlab-bindings.yml | ||
# * https://github.com/robotology/idyntree/blob/master/.github/workflows/regenerate-matlab-bindings.yml | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
|
||
jobs: | ||
regenerate-matlab-bindings: | ||
name: "Regenerate MATLAB bindings" | ||
# Use Ubuntu Bionic as the https://github.com/casadi/casadi/wiki/matlab suggest to use GCC 7 | ||
runs-on: [ubuntu-18.04] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install dependencies via apt | ||
run: | | ||
# Install CasADi dependencies | ||
sudo apt-get update -y | ||
sudo apt-get upgrade -y | ||
# From https://github.com/casadi/casadi/wiki/InstallationLinux | ||
sudo apt-get install -y build-essential gcc g++ gfortran git cmake liblapack-dev pkg-config coinor-libipopt-dev liboctave-dev --install-recommends | ||
# From https://github.com/swig/swig/wiki/Getting-Started | ||
sudo apt-get install -y libpcre3-dev autoconf automake libtool bison --install-recommends | ||
# From https://github.com/casadi/casadi/wiki/matlab | ||
- name: Install SWIG for that supports MATLAB required by CasADi | ||
run: | | ||
sudo apt-get remove swig swig3.0 | ||
cd .. | ||
git clone https://github.com/jaeandersson/swig | ||
cd swig | ||
git checkout matlab-customdoc | ||
sh autogen.sh | ||
./configure --with-matlab | ||
make | ||
sudo make install | ||
- name: Verify which SWIG and gcc is found | ||
run: | | ||
which swig | ||
swig --help | ||
which gcc | ||
gcc --version | ||
- name: Configure and compile CasADi | ||
run: | | ||
# Remove autogenerate files to ensure that removed files are actually removed | ||
# ignore return status if the directory does not exist | ||
git rm -r autogenerated || true | ||
# Clone casadi from a given tag | ||
git clone https://github.com/dic-iit/casadi.git | ||
cd casadi | ||
git checkout 3.5.5.3 | ||
# Compile casadi and generate MATLAB bindings | ||
mkdir build | ||
cd build | ||
cmake -DWITH_IPOPT:BOOL=ON -DWITH_OCTAVE:BOOL=ON -DWITH_EXAMPLES:BOOL=OFF -DINCLUDE_PREFIX:PATH=include -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_PREFIX:PATH=lib/cmake/casadi -DLIB_PREFIX:PATH=lib -DBIN_PREFIX:PATH=bin .. | ||
make install | ||
# Copy the MATLAB files from the install directory | ||
cd ${GITHUB_WORKSPACE} | ||
mkdir -p autogenerated/matlab | ||
cp ./casadi/build/install/matlab/*.m ./autogenerated/matlab | ||
mkdir -p autogenerated/matlab/+casadi | ||
cp ./casadi/build/install/matlab/+casadi/*.m ./autogenerated/matlab/+casadi | ||
mkdir -p autogenerated/matlab/octave-extra/ | ||
cp ./casadi/build/install/matlab/octave-extra/*.m ./autogenerated/matlab/octave-extra | ||
# Copy the mex C++ file from the build directory | ||
mkdir -p autogenerated/cxx | ||
cp ./casadi/build/swig/*.cxx ./autogenerated/cxx | ||
cp ./casadi/build/swig/*.h ./autogenerated/cxx | ||
# Remove casadi directory | ||
rm -rf casadi | ||
- name: Check local changes due to bindings generation | ||
run: | | ||
git status | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
commit-message: 'update matlab bindings' | ||
committer: GitHub <noreply@github.com> | ||
branch: regenerate-matlab-bindings | ||
delete-branch: true | ||
title: 'update matlab bindings' | ||
body: | | ||
This is a PR that regenerated the MATLAB/Octave CasADi bindings. | ||
For more info, check the documentation of this repo. | ||
- name: Check outputs | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |