Skip to content

Commit 1a9948c

Browse files
committed
Simulink: disable create_FAST_SFunc.m Mac/Linux/CMake builds
1 parent 66b91a9 commit 1a9948c

File tree

1 file changed

+23
-44
lines changed

1 file changed

+23
-44
lines changed
+23-44
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
%% INSTRUCTIONS
2-
% This script is used to manually build a Simulink mex file which uses the openfastlib shared library (.dll, .so, .dylib).
3-
% If you are building OpenFAST with CMake on linux or macOS or windows, you can automatically generate the mex file
4-
% by specifying -DBUILD_OPENFAST_SIMULINK_API=ON when running cmake, you do not need to use this script.
2+
% This script is used to manually build a Simulink mex file on Windows with Visual Studio. It uses the openfastlib shared
3+
% library (.dll).
54
%
6-
% Before running this script, you must have compiled OpenFAST for Simulink to create a DLL (i.e., a shared library like .so, .dylib, .lib, etc.).
7-
% - If cmake was used, make sure the install directory is specified properly in the `installDir` variable below,
8-
% and if using Windows, set `built_with_visualStudio` to false.
5+
% If you are using Windows and building with CMake, do not use this script. Instead use cmake to build the FAST_SFunc.mexXXXX directly.
6+
%
7+
% If you are not using Windows, do not use this script. Instead use cmake to build the FAST_SFunc.mexXXXX directly.
8+
%
9+
% Alternative building with CMAKE:
10+
% specify -DBUILD_OPENFAST_SIMULINK_API=ON when running cmake
11+
% - "make FAST_SFunc" will place the resulting mex file at <build-dir>/glue-codes/simulink/FAST_SFunc.mexXXXX
12+
% - "make install" will place the resulting mex file at install/bin/FAST_SFunc.mexXXXX
13+
%
14+
%
15+
% Before running this script, you must have compiled OpenFAST for Simulink to create a DLL (i.e., a shared library .lib).
916
% - If the Visual Studio Solution file contained in the vs-build directory was used to create the DLL on Windows,
1017
% make sure `built_with_visualStudio` is set to true.
1118
% - The name of the library that was generated must match the `libname` variable below
1219
% and should be located in the directory specified by `libDir`.
1320
% - The `includeDir` variable must specify the directory that contains the following header files:
14-
% "FAST_Library.h", "OpenFOAM_Types.h", and "SuperController_Types.h"
15-
% - The `outDir` variable indicates where the resulting mex file will reside.
21+
% "FAST_Library.h", "OpenFOAM_Types.h", "SuperController_Types.h", and "ExtLoadsDX_Types.h"
1622
%
1723
% Run `mex -setup` in Matlab to configure a C compiler if you have not already done so.
1824

1925
mexname = 'FAST_SFunc'; % base name of the resulting mex file
2026

21-
built_with_visualStudio = false; %if the libraries were built with cmake, set to false
27+
built_with_visualStudio = true; %if the libraries were built with cmake, set to false
2228

2329

2430
if (ispc && built_with_visualStudio)
@@ -42,28 +48,19 @@
4248
else
4349
%% defaults for cmake builds:
4450

45-
if ( ismac ) % Apple MacOS
46-
installDir = '../../../install';
47-
outDir = fullfile(installDir, 'lib');
48-
elseif ( ispc ) % Windows PC
49-
installDir = '../../../install';
50-
outDir = fullfile(installDir, 'lib');
51-
% If there are shared libraries does it work for outDir to be the local directory?
52-
else
53-
installDir = '../../../install';
54-
outDir = '.';
55-
end
51+
fprintf( '\n----------------------------\n' );
52+
fprintf( 'Do not use this script with Mac/Linux. Follow the CMake instructions at the top of the script instead.' );
53+
fprintf( '\n----------------------------\n' );
5654

57-
libDir = fullfile(installDir, 'lib');
58-
includeDir = fullfile(installDir, 'include');
59-
libName = 'openfastlib_mex';
6055
end
6156

62-
%% BUILD COMMAND
63-
fprintf( '\n----------------------------\n' );
64-
fprintf( 'Creating %s\n\n', [outDir filesep mexname '.' mexext] );
57+
6558

6659
if ispc () % Windows PC
60+
%% BUILD COMMAND
61+
fprintf( '\n----------------------------\n' );
62+
fprintf( 'Creating %s\n\n', [outDir filesep mexname '.' mexext] );
63+
6764

6865
mex('-largeArrayDims', ...
6966
... % '-v', ... %add this line for "verbose" output (for debugging)
@@ -78,22 +75,4 @@
7875
'-output', mexname, ...
7976
'FAST_SFunc.c');
8077

81-
else % mac/unix
82-
83-
mex('-largeArrayDims', ...
84-
... '-v', ... %add this line for "verbose" output (for debugging)
85-
['-L', libDir], ...
86-
['-l', libName], ...
87-
'-lgfortran', ...
88-
'-lquadmath', ...
89-
'-llapack', ...
90-
'-lblas', ...
91-
'-ldl', ...
92-
['-I', includeDir], ...
93-
'-outdir', outDir, ...
94-
['CFLAGS=$CFLAGS -DS_FUNCTION_NAME=' mexname], ...
95-
... ['CXXFLAGS=$CXXFLAGS -DS_FUNCTION_NAME=' mexname], ...
96-
'-output', mexname, ...
97-
'FAST_SFunc.c');
98-
9978
end

0 commit comments

Comments
 (0)