Skip to content

Commit

Permalink
initial octave support
Browse files Browse the repository at this point in the history
  • Loading branch information
mcg1969 committed Apr 10, 2024
1 parent beb58c0 commit 71f2931
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 14 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches:
- master
jobs:
build:
build-mex:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -33,12 +33,50 @@ jobs:
name: mexfiles-${{ matrix.os }}
path: |
Solver/Mexfun/*.mex*
build-oct:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest,windows-latest,macos-latest,macos-14]
steps:
- name: Retrieve the source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Octave
shell: bash
run: |
if [ "${{ matrix.os }}" = ubuntu-latest ]; then
sudo apt update
sudo apt install --no-install-recommends octave liboctave-dev
elif [ "${{ matrix.os }}" = windows-latest ]; then
choco install octave.portable
else
brew install octave
fi
- name: Build Octave mex files
if: matrix.os != 'windows-latest'
run: |
octave --eval 'computer'
octave --eval 'install_sdpt3 -rebuild'
- name: Build Octave mex files
if: matrix.os == 'windows-latest'
run: |
set PATH=C:\ProgramData\Chocolatey\bin:%PATH%
octave.exe --eval 'computer'
octave.exe --eval 'install_sdpt3 -rebuild'
- uses: actions/upload-artifact@v4
with:
name: mexfiles-oct-${{ matrix.os }}
path: |
Solver/Mexfun/*.mex
package:
needs: build
needs: [build-mex,build-oct]
runs-on: ubuntu-latest
steps:
- name: Retrieve the source code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
Expand Down
Binary file removed Solver/Mexfun/o_win/mexMatvec.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexProd2.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexProd2nz.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexexpand.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexinprod.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexmat.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexnnz.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexqops.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexschur.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexschurfun.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexskron.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexsmat.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mexsvec.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mextriang.mex
Binary file not shown.
Binary file removed Solver/Mexfun/o_win/mextriangsp.mex
Binary file not shown.
34 changes: 23 additions & 11 deletions install_sdpt3.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function install_sdpt3( varargin )
page_output_immediately( true, 'local' );
end


line = '---------------------------------------------------------------------------';
fprintf( '\n%s\nSDPT3 installation script\n Directory: %s\n %s %s on %s\n%s\n', ...
line, mpath, prog, version, COMPUTER, line );
Expand All @@ -45,6 +46,12 @@ function install_sdpt3( varargin )
mdir = '';
if ISOCTAVE && VERSION >= 4,
switch computer,
case 'x86_64-pc-linux-gnu',
mdir = 'o_lin';
case 'x86_64-apple-darwin21.6.0',
mdir = 'o_maci';
case 'aarch64-apple-darwin23.4.0',
mdir = 'o_maca';
case 'i686-w64-mingw32',
mdir = 'o_win';
end
Expand Down Expand Up @@ -88,19 +95,23 @@ function install_sdpt3( varargin )
% Note the use of 0.01 here. That's because version 7 had more than 10
% minor releases, so 7.10-7.14 need to be ordered after 7.01-7.09.
libs = {};
flags = {'-O'};
flags = {};
if ISOCTAVE,
% Octave has mwSize and mwIndex hardcoded in mex.h as ints.
% There is no definition for mwSignedIndex so include it here.
% This means that Octave ignores the -largeArrayDims flag.
cmd = 'mkoctfile';
flags{end+1} = '--mex';
if VERSION < 3.08,
flags{end+1} = '-DmwSignedIndex=int';
end
else
cmd = 'mex';
flags = {'-O'};
if ispc,
flags = {'-DPC'};
flags{end+1} = '-DPC';
elseif isunix,
flags = {'-DUNIX'};
flags{end+1} = '-DUNIX';
end
if strcmp(COMPUTER(end-1:end),'64') && ( VERSION >= 7.03 ),
flags{end+1} = '-largeArrayDims';
Expand Down Expand Up @@ -132,18 +143,19 @@ function install_sdpt3( varargin )
libs{end+1} = '-lmwlapack';
end
end
libs = sprintf( ' %s', libs{:} );
flags = sprintf( ' %s', flags{:} );
olddir = pwd;
cd( mbase );
failed = false;
fprintf( 'Template: mex%s <sources>%s\n', flags, libs );
fprintf( 'Template: %s%s <source>%s\n', cmd, sprintf( ' %s', flags{:} ), sprintf( ' %s', libs{:} ) );
for i=1:length(targets64),
targ = targets64{i};
mfile = [ targ(1:min(strfind(targ,'.'))), mext ];
temp = [ 'mex ', flags, ' ', targets64{i}, '.c ', libs ];
fprintf( ' %s: %s\n', mfile, targ );
eval( temp, 'failed=true;' ); %#ok
targ = [ targets64{i}, '.', mext ];
sfile = [ targets64{i}, '.c' ];
fprintf( ' %s\n', targ );
if ISOCTAVE,
mkoctfile(flags{:}, sfile, libs{:});
else
mex(flags{:}, sfile, libs{:});
end
end
cd( olddir );
if failed,
Expand Down

0 comments on commit 71f2931

Please sign in to comment.