idpass / idpass-lite

A library to create and interact with secure and biometrically-binding QR code identity cards
https://www.idpass.org/
Apache License 2.0
28 stars 5 forks source link

Macos build #17

Closed typelogic closed 3 years ago

typelogic commented 3 years ago

Issue

This PR are additional changes on top of https://github.com/idpass/idpass-lite/pull/16. The aim as that using a MacBook Air Darwin x86_64 laptop, doing a build by ./build.sh macos will produce the libidpasslite.dylib library.

Changes

There were subtle differences in MacOS cmake. The reason for these subtle differences reflects the reality that a build process involves intricate details that already falls outside the reach of cmake. These differences took time to locate and rectify and these didn't manifest any issues during a Linux build. They are described as:

Other simpler changes involved using the WITH_JNI variable to decouple the build of the native library to any Java javac, jni.h header requirements.

In summary, the change files are in:

  1. lib/{src,tests}/CMakeLists.txt to insert cmake logic to handle the build in a Linux or Mac OS environment.
  2. lib/src,tests}/{idpass.cpp, idpasstests.cpp} to use the WITH_JNI variable to manage Java coupling
  3. Addition of macos build scripts in dependencies/scripts/build.{libsodium,dlib,protobuf}.macos.sh
  4. In the main build.sh
typelogic commented 3 years ago

While building libidpasslite.dylib for a macos M1 chip using the homebrew GNU C compiler (gcc-11), we encountered a build issue in the dependency libsodium. We did not encounter any issue with a macos x86_64 chip using the homebrew GNU C compiler.

I forked in https://github.com/typelogic/libsodium in branch macos_test and is now able to build libsodium libraries for macos M1 chip, using the native Apple C compiler.

Digging further, I found that gcc-11 has no support for Apple's M1 chip yet..

Additional work to be done to adjust the idpass-lite build scripts to properly deal with macos M1 and x86_64 chips using Apple's native C/C++ compiler.

typelogic commented 3 years ago

I have tested these changes in the MacOS Intel and M1 laptops. These changes are build scripts cmake changes to improve the repository cloning speed and to address MacOS platforms. No C/C++ code changes, except for those related to WITH_JNI pre-processor improvement macro to decouple it from any Java/JNI header dependencies which is only applicable for Linux and Android but not for a MacOS build. A MacOS laptop (intel, arm) should be able to build a libidpasslite.dylib without needing Java JNI headers and this is what the WITH_JNI pre-processor is for.