fips icon indicating copy to clipboard operation
fips copied to clipboard

Unity3d native plugins / MultiMake / Find Package Config Mode / Dockercross

Open roscopecoltran opened this issue 7 years ago • 3 comments

Hey @floooh ,

Hope you are all well !

I am having a try with your interesting project because I wanted to manage more easily my cross-platform builds and stacks of c/c++ dependencies. While making some tests, some questions popped from my mind :-) about several topics. Sorry for this long post, but I was wondering if it was worth to chunk it into sub-issues before having your overall point of view on that, so let me know if you want me to split it later on.

Questions:

Each of them starts with the following :-), would it be possible to build or manage it with FIPS ... ?

1. Build Unity3d Native plugins:

Goal: Automate the build of a project or a dependency for several platform builds (eg Android, iOS, PhoneSDK81, SDK81, Linux)

Reference: https://github.com/mixpanel/mixpanel-unity/blob/master/native/build/build_all.py

Output example: ./Assets/Plugins/OpenCV/Android/libs/armeabi-v7a/opencv-sharedlib.so ./Assets/Plugins/OpenCV/Android/libs/x86/opencv-sharedlib.so ./Assets/Plugins/OpenCV/iOS/opencv2.framework ./Assets/Plugins/OpenCV/iOS/libopencv.a (combined armv7/arm64) ./Assets/Plugins/OpenCV/opencv.bundle ./Assets/Plugins/OpenCV/WSA/PhoneSDK81/ARM/.dll ./Assets/Plugins/OpenCV/WSA/PhoneSDK81/x86/.dll ./Assets/Plugins/OpenCV/WSA/SDK81/ARM/.dll ./Assets/Plugins/OpenCV/WSA/SDK81/x86/.dll ./Assets/Plugins/OpenCV/WSA/SDK81/x64/.dll ./Assets/Plugins/OpenCV/x86/.dll ./Assets/Plugins/OpenCV/x86_64/*.dll One dll per OpenCV module, eg. opencv_xfeatures2d310.dll, opencv_core310.dll ~27 files)

2. Auto generated unsafe bindings for C#/.NET and Mono from C/C++ projects.

Goal: Build bindings (with CppSharp with the IDisposable interface to manage the memory and import some C/C++ libraries into Unity3D projects.

Requirements:

  • generate a list of library include files per toolchain with CMake
  • generate a list of libraries generated per toolchain with CMake
  • use CppSharp-CLI to generate those bindings (link to one CMake driven project CppPlug)
  • copy .cs generated bindings to the Unity3D project

References:

  • FFmpeg: https://github.com/Ruslan-B/FFmpeg.AutoGen
  • MonoGame: https://github.com/mono/MonoGame
  • GLFW3: https://github.com/realvictorprm/GLFW3.NET
  • CppSharpTizen: https://github.com/kitsilanosoftware/CppSharpTizen
  • CppPlug: https://github.com/zillemarco/CppPlug
  • Sugar: https://github.com/ruslo/sugar

Notes:

  • SWIG is another alternative (eg. link) but CppSharps sounds more active and closer to Mono develop integration.

3. CMake/Fips - Import more easily different external projects with find_package config mode (autotools, autogen-autotools, csprojects).

Goals:

  • Support of CMake packages (link)
  • Support of QMake packages (link)
  • Support of Automake packages (link)
  • Support of Maven packages (link)
  • Support of package installation in non-standard location (prefix)
  • Create a config package file for dependencies targets with a namespace (eg. link Config.cmake.in, CMakeLists.txt)
  • Create a cache for big projects per toolchains like hunter.

Requirements:

  • Define specific input variables for the ExternalProject_Add command per plarform (eg. link)

Example:

References: multimake: https://github.com/Pelagicore/multimake hunter: https://github.com/ruslo/hunter/wiki/example.find_package.config hunter: https://github.com/ruslo/hunter/wiki/example.find_package.config ExternalProjectMultiPlatform: https://github.com/janelia-flyem/buildem/blob/master/ExternalProjectMultiPlatform.cmake

**4. (Last question but really quick one) Analyse and prepare a project for FIPS compatibility

Goals:

  • extract from an external project
    • project tree
    • all targets list (link)
    • all options commands

Requirements:

References: CMake++: https://github.com/toeb/cmakepp

Global idea/intent:

  1. Manage more easily cross-build projects with wider sets of complex dependencies
  2. Prevent duplicate dependencies between projects by creating a package config for CMake and use a namespace
  3. Create stacks of dependencies per platforms with user-managed manifests like hunter (link) or CMake++ (json manifest, cmake manifest parser), I am much more keen to use yaml manifest as you are doing with FIPS
  4. Copy imported packages and projects libraries (eg. OpenCV+libpng,libturbo-jpeg,Protobuf+Tiny-DNN+Eigen,...) to a Unity3D project

That's all but I am already checking the scope of possibilities with FIPS as before I used to work with Polly as a build wrapper for cross-platform builds.

The suggestions above would make of FIPS a really really useful tool for any students or developers working on C/C++ projects and wanting to try their project on different platfroms.

Have an awesome day ! and thanks if you have read all of that post :-)

Cheers, Richard

roscopecoltran avatar Apr 04 '17 14:04 roscopecoltran

last question ^^, is there any tutorial or wiki page explaining how to wrap an external project with FIPS ?

roscopecoltran avatar Apr 04 '17 14:04 roscopecoltran

Hi, supporting all this in core-fips would introduce quite a lot of 'scope-creep', but it may be possible to do some of those things through project-specific extensions, for instance:

  • you can put a fips-include.cmake file into a project root directory which is included and evaluated during 'fips gen', it might be possible to use this to include other cmake helper scripts or your own cmake functions
  • you can write your own fips verbs (in fips-verbs directory) and fips custom build jobs (in fips-generators directory) in python
  • you can overwrite the default cmake-toolchain files, or add new toolchains into a directory fips-toolchains in your own project

As for including more different types of external projects I'm thinking about adding support for conan (https://www.conan.io/), this would only support C/C++ dependencies though.

There's not much information for fipsifying projects, because there's so many different ways to do it.

Here are some examples:

  • this is a typical example, where the actual project is in a git submodule, and a single root CMakeLists.txt file and fips.yml file describes the project for fips: https://github.com/floooh/fips-imgui
  • BGFX is currently the most complex example: https://github.com/floooh/fips-bgfx
  • assimp is an example where simply the original project CMakeLists.txt file is included: https://github.com/floooh/fips-assimp/

floooh avatar Apr 04 '17 14:04 floooh

I am giving a try now, I will let your know tomorrow if you do not mind ^^

roscopecoltran avatar Apr 04 '17 16:04 roscopecoltran