Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 41 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
sudo apt-get -qq update
sudo apt-get -q install \
ninja-build clang$CLANG_VERSION qtkeychain-qt6-dev libsecret-1-dev libolm-dev gnome-keyring
ninja-build clang$CLANG_VERSION qtkeychain-qt6-dev libsecret-1-dev libolm-dev gnome-keyring rustc cargo
gnome-keyring-daemon -d --unlock <<<'' # Create a login keyring with no password

- name: Install Qt and necessary tools
Expand Down Expand Up @@ -124,6 +124,25 @@ jobs:
cmake -E make_directory ${{ runner.workspace }}/build
echo "BUILD_PATH=${{ runner.workspace }}/build/libQuotient" >>$GITHUB_ENV

- name: Install Rustup using win.rustup.rs
if: startsWith(matrix.os, 'windows')
run: |
# Disable the download progress bar which can cause perf issues
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc
del rustup-init.exe
rustup target add x86_64-pc-windows-msvc
rustup --version
shell: powershell

- name: Install Rustup
if: startsWith(matrix.os, 'macos')
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
rustup target add "x86_64-apple-darwin"

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1
if: startsWith(matrix.os, 'windows')
Expand All @@ -135,21 +154,29 @@ jobs:
if: matrix.static-analysis == 'sonar'
uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5

- name: Build and install QtKeychain
if: "!startsWith(matrix.os, 'ubuntu')"

- name: Build and install QtKeychain (mac)
if: startsWith(matrix.os, 'macos')
run: |
cd ..
git clone -b v0.13.0 https://github.com/frankosterfeld/qtkeychain.git
cmake -S qtkeychain -B qtkeychain/build -DBUILD_WITH_QT6=ON -DBUILD_TRANSLATIONS=OFF $CMAKE_ARGS
cmake --build qtkeychain/build --target install

- name: Build and install QtKeychain (not mac)
if: "!startsWith(matrix.os, 'macos')"
run: |
cd ..
git clone -b 0.15.0 https://github.com/frankosterfeld/qtkeychain.git
cmake -S qtkeychain -B qtkeychain/build -DBUILD_WITH_QT6=ON -DBUILD_TRANSLATIONS=OFF $CMAKE_ARGS
cmake --build qtkeychain/build --target install

- name: Build and install Olm (non-Linux)
if: "!startsWith(matrix.os, 'ubuntu')"
- name: Build and install Corrosion
run: |
cd ..
git clone https://gitlab.matrix.org/matrix-org/olm.git
cmake -S olm -B olm/build $CMAKE_ARGS
cmake --build olm/build --target install
git clone -b v0.5.2 https://github.com/corrosion-rs/corrosion
cmake -S corrosion -B corrosion/build $CMAKE_ARGS
cmake --build corrosion/build --target install

- name: Get CS API definitions; clone and build GTAD
if: matrix.update-api
Expand Down Expand Up @@ -182,13 +209,13 @@ jobs:
run: cmake --build $BUILD_PATH --target update-api

- name: Build and install libQuotient
shell: pwsh # The Rust toolchain chooses the wrong linker on bash, for some reason
run: |
if [[ '${{ matrix.static-analysis }}' == 'sonar' ]]; then
BUILD_WRAPPER="${{ steps.sonar.outputs.build-wrapper-binary }} --out-dir $SONAR_DIR"
fi
$BUILD_WRAPPER cmake --build $BUILD_PATH --target all
cmake --build $BUILD_PATH --target install
ls ~/.local$BIN_DIR/quotest
${{ matrix.static-analysis == 'sonar'
&& format('{0} --out-dir {1}/sonar ', steps.sonar.outputs.build-wrapper-binary,
env.BUILD_PATH)
|| ''}}cmake --build $env:BUILD_PATH --target all
cmake --build $env:BUILD_PATH --target install

- name: Run tests
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ compile_commands.json
# Created by doxygen
html/
latex/

Quotient/crypto-sdk/target
.kateproject.build
70 changes: 30 additions & 40 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ else()
endif ()
endforeach ()
foreach (FLAG unused-parameter gnu-zero-variadic-macro-arguments
subobject-linkage) # Switch these off
subobject-linkage dollar-in-identifier-extension) # Switch these off
CHECK_CXX_COMPILER_FLAG("-Wno-${FLAG}" Wno-${FLAG}_SUPPORTED)
if (Wno-${FLAG}_SUPPORTED AND
NOT CMAKE_CXX_FLAGS MATCHES "W(no-)?${FLAG}($| )")
Expand Down Expand Up @@ -90,28 +90,23 @@ set(${PROJECT_NAME}_INSTALL_INCLUDEDIR
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

find_package(${Qt} ${QtMinVersion} REQUIRED Core Network Gui Test Sql)
find_package(${Qt} ${QtMinVersion} REQUIRED COMPONENTS Core Network Gui Test Sql)
find_package(${Qt} ${QtMinVersion} COMPONENTS CorePrivate)
get_filename_component(Qt_Prefix "${${Qt}_DIR}/../../../.." ABSOLUTE)

if(${Qt}Core_VERSION VERSION_GREATER_EQUAL 6.10)
find_package(${Qt} ${QtMinVersion} REQUIRED COMPONENTS CorePrivate)
endif()

find_package(${Qt}Keychain REQUIRED)
find_package(Corrosion REQUIRED)

find_package(Olm 3.2.5 REQUIRED)
set_package_properties(Olm PROPERTIES
DESCRIPTION "Implementation of the Olm and Megolm cryptographic ratchets"
URL "https://gitlab.matrix.org/matrix-org/olm"
TYPE REQUIRED
)
if(NOT WIN32)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SQLITE sqlite3 REQUIRED IMPORTED_TARGET)
endif()

find_package(OpenSSL 1.1.0 REQUIRED)
set_package_properties(OpenSSL PROPERTIES
DESCRIPTION "Open source SSL and TLS implementation and cryptographic library"
URL "https://www.openssl.org/"
TYPE REQUIRED
)
corrosion_import_crate(MANIFEST_PATH Quotient/crypto-sdk/Cargo.toml)

add_library(${QUOTIENT_LIB_NAME})

Expand Down Expand Up @@ -143,6 +138,7 @@ target_sources(${QUOTIENT_LIB_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS .
Quotient/eventitem.h
Quotient/accountregistry.h
Quotient/mxcreply.h
Quotient/rust_util.h
Quotient/events/event.h
Quotient/events/roomevent.h
Quotient/events/stateevent.h
Expand Down Expand Up @@ -176,23 +172,13 @@ target_sources(${QUOTIENT_LIB_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS .
Quotient/jobs/syncjob.h
Quotient/jobs/mediathumbnailjob.h
Quotient/jobs/downloadfilejob.h
Quotient/database.h
Quotient/connectionencryptiondata_p.h
Quotient/keyverificationsession.h
Quotient/e2ee/e2ee_common.h
Quotient/e2ee/qolmaccount.h
Quotient/e2ee/qolmsession.h
Quotient/e2ee/qolminboundsession.h
Quotient/e2ee/qolmoutboundsession.h
Quotient/e2ee/qolmutility.h
Quotient/e2ee/qolmsession.h
Quotient/e2ee/qolmmessage.h
Quotient/e2ee/cryptoutils.h
Quotient/e2ee/sssshandler.h
Quotient/events/keyverificationevent.h
Quotient/keyimport.h
Quotient/qt_connection_util.h
Quotient/thread.h
Quotient/e2ee/sssshandler.h
# The following headers are not included from public headers and so excluded from distribution
PRIVATE FILE_SET private_headers TYPE HEADERS BASE_DIRS . FILES
Quotient/logging_categories_p.h
Expand All @@ -218,6 +204,7 @@ target_sources(${QUOTIENT_LIB_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS .
Quotient/eventitem.cpp
Quotient/accountregistry.cpp
Quotient/mxcreply.cpp
Quotient/rust_util.cpp
Quotient/events/event.cpp
Quotient/events/roomevent.cpp
Quotient/events/stateevent.cpp
Expand All @@ -239,22 +226,13 @@ target_sources(${QUOTIENT_LIB_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS .
Quotient/jobs/syncjob.cpp
Quotient/jobs/mediathumbnailjob.cpp
Quotient/jobs/downloadfilejob.cpp
Quotient/database.cpp
Quotient/connectionencryptiondata_p.cpp
Quotient/keyverificationsession.cpp
Quotient/e2ee/e2ee_common.cpp
Quotient/e2ee/qolmaccount.cpp
Quotient/e2ee/qolmsession.cpp
Quotient/e2ee/qolminboundsession.cpp
Quotient/e2ee/qolmoutboundsession.cpp
Quotient/e2ee/qolmutility.cpp
Quotient/e2ee/qolmsession.cpp
Quotient/e2ee/qolmmessage.cpp
Quotient/e2ee/cryptoutils.cpp
Quotient/e2ee/sssshandler.cpp
Quotient/keyimport.cpp
Quotient/thread.cpp
Quotient/e2ee/sssshandler.cpp
libquotientemojis.qrc
Quotient/e2ee/cryptoutils.cpp
)

# Configure API files generation
Expand Down Expand Up @@ -374,9 +352,22 @@ target_include_directories(${QUOTIENT_LIB_NAME} PUBLIC
$<BUILD_INTERFACE:$<$<NOT:$<BOOL:${QUOTIENT_FORCE_NAMESPACED_INCLUDES}>>:${CMAKE_CURRENT_SOURCE_DIR}/Quotient>>
)

find_package(OpenSSL REQUIRED)

target_link_libraries(${QUOTIENT_LIB_NAME}
PUBLIC ${Qt}::Core ${Qt}::Network ${Qt}::Gui qt${${Qt}Core_VERSION_MAJOR}keychain Olm::Olm ${Qt}::Sql
PRIVATE OpenSSL::Crypto ${Qt}::CorePrivate)
PUBLIC ${Qt}::Core ${Qt}::Network ${Qt}::Gui qt${${Qt}Core_VERSION_MAJOR}keychain ${Qt}::Sql
PRIVATE ${Qt}::CorePrivate matrix_rust_sdk_crypto_cpp OpenSSL::Crypto)

if(NOT WIN32)
target_link_libraries(${QUOTIENT_LIB_NAME} PRIVATE PkgConfig::SQLITE)
else()
target_link_libraries(${QUOTIENT_LIB_NAME} PRIVATE Bcrypt.lib)
endif()

target_include_directories(${QUOTIENT_LIB_NAME} PRIVATE
${CMAKE_BINARY_DIR}/cargo/build/${Rust_CARGO_TARGET}/cxxbridge/matrix-rust-sdk-crypto/src/)



configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${QUOTIENT_LIB_NAME}.pc @ONLY NEWLINE_STYLE UNIX)

Expand All @@ -401,6 +392,7 @@ write_basic_package_version_file(
COMPATIBILITY SameMajorVersion
)

install(TARGETS matrix_rust_sdk_crypto_cpp EXPORT ${QUOTIENT_LIB_NAME}Targets)
export(PACKAGE ${QUOTIENT_LIB_NAME})
export(EXPORT ${QUOTIENT_LIB_NAME}Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${QUOTIENT_LIB_NAME}/${QUOTIENT_LIB_NAME}Targets.cmake")
Expand Down Expand Up @@ -444,8 +436,6 @@ message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS " Header files install prefix: ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDEDIR}")
message(STATUS "Using Qt ${${Qt}_VERSION} at ${Qt_Prefix}")
message(STATUS "Using QtKeychain ${${Qt}Keychain_VERSION} at ${${Qt}Keychain_DIR}")
message(STATUS "Using libOlm ${Olm_VERSION} at ${Olm_DIR}")
message(STATUS "Using OpenSSL libcrypto ${OPENSSL_VERSION} at ${OPENSSL_CRYPTO_LIBRARY}")
message(STATUS)
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES
FATAL_ON_MISSING_REQUIRED_PACKAGES)
Expand Down
Loading
Loading