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

Linux & Macos support for the Unreal Engine plugin #873

Merged
merged 62 commits into from
Aug 17, 2023

Conversation

demonixis
Copy link
Contributor

@demonixis demonixis commented Mar 30, 2023

Hello,
This PR adds build support for Macos as well as foundations for Linux and Android.
I've update the readme located into the UnrealEngine folder with everything required to compile it.

Linux / Android support is on its way, just few compilation error to fix on Android and a linking issue with Linux. Other PR will come later to fix that.

@seanmcleod
Copy link
Member

Note that users will have to edit the prop.hxx copied to the UnrealEngine plugin folder and change this line because rtti is not supported on mac/linux build with unreal.

It seems that this code could be removed, but I think it's a better idea to do that in a separate PR.

I'd suggest doing a separate PR to remove the code from prop.hxx first after testing it and then pull from master into this PR so that we don't end up with a temporary version with manual instructions for editing prop.hxx etc.

@demonixis
Copy link
Contributor Author

All right, I'm preparing a new PR with the code removed

@demonixis
Copy link
Contributor Author

OK I've submitted an new PR #874 . When it's merged I'll update this one.

@demonixis
Copy link
Contributor Author

The branch was updated, the hack removed and merged with master.

@codecov
Copy link

codecov bot commented Mar 31, 2023

Codecov Report

Merging #873 (4b70b5e) into master (951d312) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #873   +/-   ##
=======================================
  Coverage   24.89%   24.89%           
=======================================
  Files         168      168           
  Lines       18887    18887           
=======================================
  Hits         4701     4701           
  Misses      14186    14186           

@bcoconni
Copy link
Member

@gallonmate, @AlbanBERGERET-Epic does this PR look good to you ?

@AlbanBERGERET-Epic
Copy link
Contributor

The UE changes seem to be legit, but I can't test them because I don't have these platforms.

But I guess Yannick did so and did not break anything on the Windows platform.

@demonixis
Copy link
Contributor Author

demonixis commented Mar 31, 2023

@AlbanBERGERET-Epic here is a screenshot of the plugin working on the mac editor. As explained in the description, this PR is for Macos support only for now because I've an issue with the linker on Linux. A separate PR will add Linux and probably Android support in few days/weeks.

@bcoconni I found a potential bug, please do not merge the PR until it's sure to be fixed

image

@demonixis demonixis changed the title Add initial support for Macos (and foundation for Linux/Android) to the Unreal Engine plugin [Do not merge] Add initial support for Macos (and foundation for Linux/Android) to the Unreal Engine plugin Mar 31, 2023
@demonixis
Copy link
Contributor Author

Hey there,
I need more time to submit this PR. I close it for now and I'll reopen it with a proper history.

@demonixis demonixis closed this Apr 3, 2023
@bcoconni
Copy link
Member

bcoconni commented Apr 4, 2023

@demonixis

I'll reopen it with a proper history.

Don't bother polishing your PR history as we are squashing PR commits into one single commit anyway.

@demonixis demonixis reopened this Apr 5, 2023
@demonixis
Copy link
Contributor Author

OK I've reopened the PR and will change the status when it's ready then

@bcoconni bcoconni marked this pull request as draft April 6, 2023 23:32
@bcoconni
Copy link
Member

bcoconni commented Aug 16, 2023

@demonixis, @finger563
Did you have the opportunity to conduct your tests ? Is the PR ready for being merged ?

@finger563
Copy link

finger563 commented Aug 17, 2023

@bcoconni I did switch over to @demonixis' mainline branch and did a full re-build of the dynamic library, unreal engine project (in xcode), and played the example map in the editor in UE 5.2.1 - everything worked as expected.

Edit:
For reference, here is the build script I used

#!/bin/bash

# make build folder and cd into it
mkdir -p build
cd build

# build the jsbsim library with cmake
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" ..
make -j4

# cd back to the root directory
cd ..

# set the unreal plugin folder for use in the script
UNREAL_PLUGIN_FOLDER=./UnrealEngine/Plugins/JSBSimFlightDynamicsModel
UNREAL_PLUGIN_INCLUDE_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Include
UNREAL_PLUGIN_LIB_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Lib/Mac
UNREAL_PLUGIN_RESOURCES_FOLDER=$UNREAL_PLUGIN_FOLDER/Resources/JSBSim

echo "Copying JSBSim header files to Unreal plugin folder: $UNREAL_PLUGIN_INCLUDE_FOLDER"
# make the  unreal plugin thirdparty/jsbsim/include folder
rm -rf $UNREAL_PLUGIN_INCLUDE_FOLDER
mkdir -p $UNREAL_PLUGIN_INCLUDE_FOLDER
# copy the include files (.h,.hxx) from src (and its subdirectories) into unreal
# plugin thirdparty/jsbsim/include folder, keeping the same directory structure
# as in src. Since we're on macos, we use rsync instead of cp to preserve the
# directory structure

# Copy headers
rsync -avm --include='*.h' --include='*.hpp' --include='*.hxx' -f 'hide,! */' src/ UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/

echo "Copying JSBSim library to Unreal plugin folder: $UNREAL_PLUGIN_LIB_FOLDER"
# make the unreal plugin thirdparty/jsbsim/lib folder
mkdir -p $UNREAL_PLUGIN_LIB_FOLDER
# copy the jsbsim library from the build folder into the unreal plugin
# thirdparty/jsbsim/lib folder
# cp ./build/src/libJSBSim.a $UNREAL_PLUGIN_LIB_FOLDER/.
cp ./build/src/*.dylib $UNREAL_PLUGIN_LIB_FOLDER/.

echo "Copying JSBSim resources to Unreal plugin folder: $UNREAL_PLUGIN_RESOURCES_FOLDER"
# make the unreal plugin resources folder
mkdir -p $UNREAL_PLUGIN_RESOURCES_FOLDER
# copy the aircraft, engine, and systems folders into the unreal plugin resources folder
cp -r ./aircraft $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./engine $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./systems $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.

@demonixis
Copy link
Contributor Author

@bcoconni I did switch over to @demonixis' mainline branch and did a full re-build of the dynamic library, unreal engine project (in xcode), and played the example map in the editor in UE 5.2.1 - everything worked as expected.

Edit: For reference, here is the build script I used

#!/bin/bash

# make build folder and cd into it
mkdir -p build
cd build

# build the jsbsim library with cmake
cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS="-stdlib=libc++" ..
make -j4

# cd back to the root directory
cd ..

# set the unreal plugin folder for use in the script
UNREAL_PLUGIN_FOLDER=./UnrealEngine/Plugins/JSBSimFlightDynamicsModel
UNREAL_PLUGIN_INCLUDE_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Include
UNREAL_PLUGIN_LIB_FOLDER=$UNREAL_PLUGIN_FOLDER/Source/ThirdParty/JSBSim/Lib/Mac
UNREAL_PLUGIN_RESOURCES_FOLDER=$UNREAL_PLUGIN_FOLDER/Resources/JSBSim

echo "Copying JSBSim header files to Unreal plugin folder: $UNREAL_PLUGIN_INCLUDE_FOLDER"
# make the  unreal plugin thirdparty/jsbsim/include folder
rm -rf $UNREAL_PLUGIN_INCLUDE_FOLDER
mkdir -p $UNREAL_PLUGIN_INCLUDE_FOLDER
# copy the include files (.h,.hxx) from src (and its subdirectories) into unreal
# plugin thirdparty/jsbsim/include folder, keeping the same directory structure
# as in src. Since we're on macos, we use rsync instead of cp to preserve the
# directory structure

# Copy headers
rsync -avm --include='*.h' --include='*.hpp' --include='*.hxx' -f 'hide,! */' src/ UnrealEngine/Plugins/JSBSimFlightDynamicsModel/Source/ThirdParty/JSBSim/Include/

echo "Copying JSBSim library to Unreal plugin folder: $UNREAL_PLUGIN_LIB_FOLDER"
# make the unreal plugin thirdparty/jsbsim/lib folder
mkdir -p $UNREAL_PLUGIN_LIB_FOLDER
# copy the jsbsim library from the build folder into the unreal plugin
# thirdparty/jsbsim/lib folder
# cp ./build/src/libJSBSim.a $UNREAL_PLUGIN_LIB_FOLDER/.
cp ./build/src/*.dylib $UNREAL_PLUGIN_LIB_FOLDER/.

echo "Copying JSBSim resources to Unreal plugin folder: $UNREAL_PLUGIN_RESOURCES_FOLDER"
# make the unreal plugin resources folder
mkdir -p $UNREAL_PLUGIN_RESOURCES_FOLDER
# copy the aircraft, engine, and systems folders into the unreal plugin resources folder
cp -r ./aircraft $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./engine $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.
cp -r ./systems $UNREAL_PLUGIN_FOLDER/Resources/JSBSim/.

That great to read, note it adds Linux (and Android) too. However I wasn't able to run it on my M2 mac. Have you tried on an Apple Silicon or an Intel based one?

@demonixis
Copy link
Contributor Author

demonixis commented Aug 17, 2023

This time it's ready :)
@finger563 thanks for the script. I adapted it for Linux and created to scripts for an easy install way
@bcoconni it's tested and running on an M2 mac too now. For me it's validated, I'll merge my master branch into my dev branch to get these changes. Thanks for your help for cmake ;)

bcoconni and others added 22 commits August 17, 2023 12:20
* Test tied properties.

* Add the ability to untie `FGAtmosphere` properties
* Add a new `LoadPlanet` method

* Fix the help messages.
…#908)

* Do not store the result of `FGFDMExec::GetAtmosphere()`.

* Constification to clarify the intent.
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.12.3 to 2.13.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](pypa/cibuildwheel@v2.12.3...v2.13.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.13.0 to 2.13.1.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](pypa/cibuildwheel@v2.13.0...v2.13.1)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Bump pypa/cibuildwheel from 2.13.1 to 2.14

Bumps [pypa/cibuildwheel](https://github.com/pypa/cibuildwheel) from 2.13.1 to 2.14.0.
- [Release notes](https://github.com/pypa/cibuildwheel/releases)
- [Changelog](https://github.com/pypa/cibuildwheel/blob/main/docs/changelog.md)
- [Commits](pypa/cibuildwheel@v2.13.1...v2.14.0)

---
updated-dependencies:
- dependency-name: pypa/cibuildwheel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Remove the patch version number.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bertrand Coconnier <[email protected]>
Copy link
Member

@bcoconni bcoconni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@bcoconni bcoconni merged commit e4aa2a9 into JSBSim-Team:master Aug 17, 2023
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants