Skip to content
Snippets Groups Projects
Commit 6b4f5751 authored by Alexandre Eberhardt's avatar Alexandre Eberhardt Committed by Alexandre Eberhardt
Browse files

plugins: fix build and add documentation

Add documentation to build and sign AutoAnswer from scratch
Fix some of the Example plugin
Fix the CMakeLists.txt to copy the shared library in the right folder
Copy the library to the right folder created by SDK/jplManipulation.py at line 146

Change-Id: Id0584d0c659d08687a41968b6b7f0064b4e7fac5
parent 03e13290
No related branches found
No related tags found
No related merge requests found
...@@ -37,28 +37,35 @@ set (LIBS_DIR ${PROJECT_SOURCE_DIR}/../contrib/Libs) ...@@ -37,28 +37,35 @@ set (LIBS_DIR ${PROJECT_SOURCE_DIR}/../contrib/Libs)
# Detect the operating system # Detect the operating system
if(WIN32) if(WIN32)
set(OS_NAME "WINDOWS") set(DISTRIBUTION "x64-windows")
elseif(ANDROID) elseif(ANDROID)
set(OS_NAME "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() else()
set(OS_NAME "UNIX") message(FATAL_ERROR "Unsupported architecture. Only x64 or arm64 is supported.")
endif()
else()
set(DISTRIBUTION "x86_64-linux-gnu")
endif() endif()
# Detect the architecture # Detect the architecture
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
message(ARCH: x64)
set(ARCH "x64") set(ARCH "x64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
message(ARCH: arm64)
set(ARCH "arm64")
else() else()
message(FATAL_ERROR "Unsupported architecture. Only x64 is supported.") message(FATAL_ERROR "Unsupported architecture. Only x64 or aarch64 is supported.")
endif() endif()
# Set platform-specific variables message(OS: ${DISTRIBUTION})
set(CONTRIB_PLATFORM_CURT ${ARCH})
set(CONTRIB_PLATFORM ${CONTRIB_PLATFORM_CURT}-${OS_NAME})
message(OS: ${OS_NAME} ${ARCH})
message(Building: ${ProjectName} ${Version}) message(Building: ${ProjectName} ${Version})
message(Build path: ${PROJECT_BINARY_DIR}) message(Build path: ${PROJECT_BINARY_DIR})
message(JPL assembling path: ${JPL_DIRECTORY}) message(JPL assembling path: ${JPL_DIRECTORY})
...@@ -135,14 +142,13 @@ add_custom_command( ...@@ -135,14 +142,13 @@ add_custom_command(
COMMENT "Assembling Plugin files" COMMENT "Assembling Plugin files"
) )
if(WIN32) if(WIN32)
# Windows-specific file copying # Windows-specific file copying
add_custom_command( add_custom_command(
TARGET ${ProjectName} TARGET ${ProjectName}
POST_BUILD 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}.lib ${JPL_DIRECTORY}/lib/${DISTRIBUTION}/${ProjectName}.lib
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${ProjectName}.dll ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM} COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/${ProjectName}.dll ${JPL_DIRECTORY}/lib/${DISTRIBUTION}/${ProjectName}.dll
COMMENT "Copying files to jpl directory for Windows" COMMENT "Copying files to jpl directory for Windows"
) )
elseif(APPLE) elseif(APPLE)
...@@ -150,15 +156,22 @@ elseif(APPLE) ...@@ -150,15 +156,22 @@ elseif(APPLE)
add_custom_command( add_custom_command(
TARGET ${ProjectName} TARGET ${ProjectName}
POST_BUILD 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" 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() else()
# Unix-like systems (Linux, etc.) # Unix-like systems (Linux, etc.)
add_custom_command( add_custom_command(
TARGET ${ProjectName} TARGET ${ProjectName}
POST_BUILD 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" COMMENT "Copying files to jpl directory for Unix-like systems or Android"
) )
endif() endif()
......
# 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.
...@@ -30,7 +30,7 @@ set (DAEMON ${PROJECT_SOURCE_DIR}/../daemon) ...@@ -30,7 +30,7 @@ set (DAEMON ${PROJECT_SOURCE_DIR}/../daemon)
set (JPL_FILE_NAME ${ProjectName}.jpl) set (JPL_FILE_NAME ${ProjectName}.jpl)
set (DAEMON_SRC ${DAEMON}/src) set (DAEMON_SRC ${DAEMON}/src)
set (CONTRIB_PATH ${DAEMON}/contrib) 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) set (JPL_DIRECTORY ${PROJECT_BINARY_DIR}/jpl)
# Detect the operating system # Detect the operating system
...@@ -217,5 +217,4 @@ if (DEBUG_SIGN) ...@@ -217,5 +217,4 @@ if (DEBUG_SIGN)
COMMENT "Generating plugin certificate" COMMENT "Generating plugin certificate"
) )
python3 ./SDK/certKey.py --plugin sign --path /tmp/plugins/foo --issuer /tmp/foo /tmp/plugins/foo
endif() endif()
sign.md 0 → 100644
# 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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment