diff --git a/AutoAnswer/CMakeLists.txt b/AutoAnswer/CMakeLists.txt index 1eece747fe9f81f8902ed44ef2f1efd2d3763604..75876bb77305b478a173ea7fc3b99ddd3df5c93a 100644 --- a/AutoAnswer/CMakeLists.txt +++ b/AutoAnswer/CMakeLists.txt @@ -37,28 +37,35 @@ set (LIBS_DIR ${PROJECT_SOURCE_DIR}/../contrib/Libs) # Detect the operating system if(WIN32) - set(OS_NAME "WINDOWS") - + set(DISTRIBUTION "x64-windows") elseif(ANDROID) set(OS_NAME "ANDROID") - + set(CONTRIB_PLATFORM_CURT ${ARCH}) + set(CONTRIB_PLATFORM ${CONTRIB_PLATFORM_CURT}-${OS_NAME}) +elseif(APPLE) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + set(DISTRIBUTION "arm64-apple-Darwin") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(DISTRIBUTION "x86_64-apple-Darwin") + else() + message(FATAL_ERROR "Unsupported architecture. Only x64 or arm64 is supported.") + endif() else() - set(OS_NAME "UNIX") - + set(DISTRIBUTION "x86_64-linux-gnu") endif() # Detect the architecture if(CMAKE_SIZEOF_VOID_P EQUAL 8) + message(ARCH: x64) set(ARCH "x64") +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") + message(ARCH: arm64) + set(ARCH "arm64") else() - message(FATAL_ERROR "Unsupported architecture. Only x64 is supported.") + message(FATAL_ERROR "Unsupported architecture. Only x64 or aarch64 is supported.") endif() -# Set platform-specific variables -set(CONTRIB_PLATFORM_CURT ${ARCH}) -set(CONTRIB_PLATFORM ${CONTRIB_PLATFORM_CURT}-${OS_NAME}) - -message(OS: ${OS_NAME} ${ARCH}) +message(OS: ${DISTRIBUTION}) message(Building: ${ProjectName} ${Version}) message(Build path: ${PROJECT_BINARY_DIR}) message(JPL assembling path: ${JPL_DIRECTORY}) @@ -135,14 +142,13 @@ add_custom_command( COMMENT "Assembling Plugin files" ) - if(WIN32) # Windows-specific file copying add_custom_command( TARGET ${ProjectName} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${ProjectName}.lib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${ProjectName}.dll ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${ProjectName}.lib ${JPL_DIRECTORY}/lib/${DISTRIBUTION}/${ProjectName}.lib + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${ProjectName}.dll ${JPL_DIRECTORY}/lib/${DISTRIBUTION}/${ProjectName}.dll COMMENT "Copying files to jpl directory for Windows" ) elseif(APPLE) @@ -150,15 +156,22 @@ elseif(APPLE) add_custom_command( TARGET ${ProjectName} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lib${ProjectName}.dylib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lib${ProjectName}.dylib ${JPL_DIRECTORY}/lib/${DISTRIBUTION}/lib${ProjectName}.dylib COMMENT "Copying files to jpl directory for macOS" ) +elseif(ANDROID) + add_custom_command( + TARGET ${ProjectName} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lib${ProjectName}.so ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMENT "Copying files to jpl directory for Android" + ) else() # Unix-like systems (Linux, etc.) add_custom_command( TARGET ${ProjectName} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lib${ProjectName}.so ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} + COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lib${ProjectName}.so ${JPL_DIRECTORY}/lib/${DISTRIBUTION}/lib${ProjectName}.so COMMENT "Copying files to jpl directory for Unix-like systems or Android" ) endif() diff --git a/AutoAnswer/build.md b/AutoAnswer/build.md new file mode 100644 index 0000000000000000000000000000000000000000..f0e8627f62680bcd4942d738b5986ea7d8ab94ef --- /dev/null +++ b/AutoAnswer/build.md @@ -0,0 +1,24 @@ +# To build AutoAnswer, follow these steps: + +## Go to the AutoAnswer folder and create a build directory: + +``` +mkdir build-local +cd build-local +``` + +## Run the following commands to build the project: + +``` +cmake .. +cmake --build . +``` + +## Once the build is complete, you will find your unsigned `AutoAnswer.jpl` in: + +``` +jami-plugins/build/<your distribution>/ +``` + +## To install it on Jami, you need to sign the plugin. Refer to `sign.md` in the `jami-plugins/` directory for instructions on how to sign your plugin. + diff --git a/Example/CMakeLists.txt b/Example/CMakeLists.txt index 071d4bb112180be065b3d05f501bc40cd9fd7f5d..4b661190b2ce522aa59c62907cfc7861fd28e43e 100644 --- a/Example/CMakeLists.txt +++ b/Example/CMakeLists.txt @@ -30,7 +30,7 @@ set (DAEMON ${PROJECT_SOURCE_DIR}/../daemon) set (JPL_FILE_NAME ${ProjectName}.jpl) set (DAEMON_SRC ${DAEMON}/src) set (CONTRIB_PATH ${DAEMON}/contrib) -set (PLUGINS_LIB ${PROJECT_SOURCE_DIR}/../lib)/ +set (PLUGINS_LIB ${PROJECT_SOURCE_DIR}/../lib) set (JPL_DIRECTORY ${PROJECT_BINARY_DIR}/jpl) # Detect the operating system @@ -217,5 +217,4 @@ if (DEBUG_SIGN) COMMENT "Generating plugin certificate" ) -python3 ./SDK/certKey.py --plugin sign --path /tmp/plugins/foo --issuer /tmp/foo /tmp/plugins/foo endif() diff --git a/sign.md b/sign.md new file mode 100644 index 0000000000000000000000000000000000000000..e47ecd3b4ebdf28396964d29fac6654471939408 --- /dev/null +++ b/sign.md @@ -0,0 +1,49 @@ +# To add your plugin built on Jami, you need to sign it with certificates. + +## Create a directory to store them: + +``` +mkdir -p jami-plugins/certificate +``` + +## In a Python environment (recommended) install the requirements: + +``` +cd jami-plugins/SDK +pip install -r requirements.txt +pip install -r certificate_requirements.txt +pip install requests +``` + +## Create the certificates: + +``` +python3 ./certKey.py create --subject PluginName ../certificate/ +``` + +## Verify the certificates: + +``` +openssl x509 -in ../certificate/certificate.crt -text -noout +``` + +## Sign the plugin (certKey.py will automatically add the `.crt` and `.jpl` extensions): + +``` +python3 ./certKey.py --plugin sign --issuer <Path to your certificate without the ".crt"> --path <path to your plugin.jpl> <path to your signed plugin output without the ".jpl"> +``` + +For example: + +``` +python3 ./certKey.py --plugin sign --issuer ../certificate/certificate --path ../build/x86_64-linux-gnu/AutoAnswer.jpl ../build/x86_64-linux-gnu/signed/AutoAnswerSigned +``` + +## Display the signed files: + +``` +ls ../build/<your distribution>/signed +``` + +## You can now add your signed `.jpl` plugin to Jami. +