Skip to content

Commit

Permalink
Generate the MATLAB script to compile the S-Function directly from th…
Browse files Browse the repository at this point in the history
…e folder installed by the Windows installer.

See discussion in issue JSBSim-Team#491.
  • Loading branch information
bcoconni committed Feb 5, 2022
1 parent 5e967a4 commit 4e59284
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 45 deletions.
87 changes: 45 additions & 42 deletions .github/workflows/cpp-python-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,58 @@ jobs:
uses: matlab-actions/run-command@v1
with:
command: addpath('build/matlab/RelWithDebInfo'), run('matlab/TestJSBSim.m')

# Build the Windows installer
- name: Checkout JSBSim logos
if: env.release == 'true' && runner.os == 'Windows'
id: InstallLogos
uses: actions/checkout@v2
with:
repository: JSBSim-Team/jsbsim-logo
path: jsbsim-logo
- name: Build JSBSim installer for Windows
if: steps.InstallLogos.outcome == 'success'
id: BuildInstaller
working-directory: build
run: |
cmake --build . --config RelWithDebInfo --target JSBSim aeromatic
# Relocate the logos for the wizard installer
mkdir logos
cp ..\jsbsim-logo\wizard_installer\*.bmp logos\.
mkdir small
cp ..\jsbsim-logo\wizard_installer\small\*.bmp small\.
# Relocate the executables for the installer
cp src\RelWithDebInfo\JSBSim.exe src\.
cp src\RelWithDebInfo\JSBSim.lib src\.
cp utils\aeromatic++\RelWithDebInfo\aeromatic.exe utils\aeromatic++\.
# Get the MSVC C++ DLL
$Paths = $Env:PATH+';'+[System.Environment]::SystemDirectory
foreach($path in $Paths -split ';') {
if (Test-Path $path) {
$File = Get-ChildItem -Path $path | Where-Object {$_.Name -eq 'msvcp140.dll'}
if ($File) {
cp $File.FullName .
break;
}
}
}
# Compile the installer with Inno Setup
iscc JSBSim.iss
- name: Upload Files for Release (Linux & MacOSX)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v2
with:
name: Matlab-SFunction-${{ runner.os }}.binaries
path: build/matlab/JSBSim_SFunction.mex*
- name: Upload Files for Release (Windows)
if: runner.os == 'Windows'
if: steps.BuildInstaller.outcome == 'success'
uses: actions/upload-artifact@v2
with:
name: Matlab-SFunction-${{ runner.os }}.binaries
path: build/matlab/RelWithDebInfo/JSBSim_SFunction.mex*
path: |
build/matlab/RelWithDebInfo/JSBSim_SFunction.mex*
build\Output\*.exe
Windows-MinGW32:
name: C/C++ build (MinGW32)
Expand Down Expand Up @@ -356,49 +396,12 @@ jobs:
build/Testing/Temporary/*.log
build/tests/*-build.log
# Build the Windows installer
- name: Checkout JSBSim logos
if: env.release == 'true'
id: InstallLogos
uses: actions/checkout@v2
with:
repository: JSBSim-Team/jsbsim-logo
path: jsbsim-logo
- name: Build JSBSim installer for Windows
if: steps.InstallLogos.outcome == 'success'
id: BuildInstaller
working-directory: build
run: |
# Relocate the logos for the wizard installer
mkdir logos
cp ..\jsbsim-logo\wizard_installer\*.bmp logos\.
mkdir small
cp ..\jsbsim-logo\wizard_installer\small\*.bmp small\.
# Relocate the executables for the installer
cp src\RelWithDebInfo\JSBSim.exe src\.
cp src\RelWithDebInfo\JSBSim.lib src\.
cp utils\aeromatic++\RelWithDebInfo\aeromatic.exe utils\aeromatic++\.
# Get the MSVC C++ DLL
$Paths = $Env:PATH+';'+[System.Environment]::SystemDirectory
foreach($path in $Paths -split ';') {
if (Test-Path $path) {
$File = Get-ChildItem -Path $path | Where-Object {$_.Name -eq 'msvcp140.dll'}
if ($File) {
cp $File.FullName .
break;
}
}
}
# Compile the installer with Inno Setup
iscc JSBSim.iss
- name: Upload Files for Release
uses: actions/upload-artifact@v2
if: steps.BuildInstaller.outcome == 'success'
if: env.release == 'true'
with:
name: ${{ runner.os }}.binaries
path: |
build\Output\*.exe
build\src\RelWithDebInfo\JSBSim.lib
build\python\jsbsim.cxx
build\python\setup.py
Expand Down Expand Up @@ -576,7 +579,7 @@ jobs:
build/python/dist/*.whl
Rolling-Release:
needs: [ManyLinux-Wheels, MacWin-Wheels, Test-Build-PyPackage-From-Source, Windows-MinGW32]
needs: [ManyLinux-Wheels, MacWin-Wheels, Test-Build-PyPackage-From-Source, Windows-MinGW32, Matlab-SFunction]
name: Deploy Rolling Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand Down Expand Up @@ -606,7 +609,7 @@ jobs:
dist/*.deb
Stable-Release:
needs: [ManyLinux-Wheels, MacWin-Wheels, Test-Build-PyPackage-From-Source, Windows-MinGW32]
needs: [ManyLinux-Wheels, MacWin-Wheels, Test-Build-PyPackage-From-Source, Windows-MinGW32, Matlab-SFunction]
name: Deploy Stable Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
Expand Down
2 changes: 1 addition & 1 deletion JSBSim.iss.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Source: "${CMAKE_SOURCE_DIR}\src\*.h"; DestDir: "{app}\include"; Flags: recurses
Source: "${CMAKE_SOURCE_DIR}\src\*.hxx"; DestDir: "{app}\include"; Flags: recursesubdirs; Components: devfiles
Source: "${CMAKE_SOURCE_DIR}\matlab\*.cpp"; DestDir: "{app}\matlab"; Components: devfiles\matlab
Source: "${CMAKE_SOURCE_DIR}\matlab\*.h"; DestDir: "{app}\matlab"; Components: devfiles\matlab
Source: "${CMAKE_SOURCE_DIR}\matlab\JSBSimSimulinkCompile.m"; DestDir: "{app}\matlab"; Components: devfiles\matlab
Source: "${CMAKE_BINARY_DIR}\matlab\JSBSimSimulinkCompile.m"; DestDir: "{app}\matlab"; Components: devfiles\matlab
Source: "${CMAKE_SOURCE_DIR}\matlab\TestJSBSim.m"; DestDir: "{app}\matlab"; Components: devfiles\matlab
Source: "${CMAKE_SOURCE_DIR}\matlab\ex737cruise.slx"; DestDir: "{app}\matlab"; Components: devfiles\matlab
Source: "${CMAKE_SOURCE_DIR}\matlab\readme.txt"; DestDir: "{app}\matlab"; Components: devfiles\matlab
12 changes: 10 additions & 2 deletions matlab/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
find_package(Matlab)

set(CMAKE_CXX_STANDARD 14)

if(Matlab_FOUND)
matlab_add_mex(NAME JSBSim_SFunction SRC JSBSim_SFunction.cpp JSBSimInterface.cpp
LINK_TO libJSBSim)
target_include_directories(JSBSim_SFunction PUBLIC ${CMAKE_SOURCE_DIR}/src
${Matlab_ROOT_DIR}/simulink/include)
set_target_properties(JSBSim_SFunction PROPERTIES CXX_STANDARD 14)

if(MSVC)
foreach(LINK_LIB ${JSBSIM_WINDOWS_LINK_LIBRARIES})
string(APPEND WINDOWS_LINK_LIBRARIES " ${LINK_LIB}.lib")
endforeach()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/WindowsSimulinkCompile.m.in ${CMAKE_CURRENT_BINARY_DIR}/JSBSimSimulinkCompile.m)
endif(MSVC)

endif(Matlab_FOUND)
4 changes: 4 additions & 0 deletions matlab/WindowsSimulinkCompile.m.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
% This file is automatically generated.
disp('Compiling S-function from JSBSim...');
mex -v -R2017b JSBSim_SFunction.cpp JSBSimInterface.cpp -I"..\include" -L"..\lib" -lJSBSim ${WINDOWS_LINK_LIBRARIES}
disp('Finished.')

0 comments on commit 4e59284

Please sign in to comment.