Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first GitHub Action that download a CasADi version and generate via custom SWIG the MATLAB bindings #1

Merged
merged 24 commits into from
May 19, 2021
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
05591e7
Create regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
2cdb747
Update regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
34e69da
Update regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
902b399
Update regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
594f7aa
Update regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
ea999b3
Update regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
c8d8b63
Update regenerate-matlab-bindings.yml.yml
traversaro May 19, 2021
adcfc54
Rename regenerate-matlab-bindings.yml.yml to regenerate-matlab-bindin…
traversaro May 19, 2021
f55fbad
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
4952c52
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
aea018e
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
7bf6eee
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
ffaf4c8
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
0bd586a
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
c374d7b
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
52e4e09
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
adeb7e9
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
952c556
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
d72b6ee
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
436e4d5
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
c904a48
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
af01eec
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
2b06446
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
2b9530d
Update regenerate-matlab-bindings.yml
traversaro May 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/regenerate-matlab-bindings.yml
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 }}"