Skip to content

Commit 8c33951

Browse files
committed
Port to matrix-rust-sdk-crypto
1 parent 4999cf7 commit 8c33951

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+5520
-6490
lines changed

.github/workflows/ci.yml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Install dependencies (Linux)
5050
if: startsWith(matrix.os, 'ubuntu')
5151
run: |
52-
COMMON_PKGS="libolm-dev ninja-build gnome-keyring g++$GCC_VERSION clang$CLANG_VERSION"
52+
COMMON_PKGS="libolm-dev ninja-build gnome-keyring rustc cargo g++$GCC_VERSION clang$CLANG_VERSION"
5353
# See https://github.com/actions/runner-images/issues/9679
5454
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
5555
# Add LLVM repo for newer Clang
@@ -123,6 +123,25 @@ jobs:
123123
cmake -E make_directory ${{ runner.workspace }}/build
124124
echo "BUILD_PATH=${{ runner.workspace }}/build/libQuotient" >>$GITHUB_ENV
125125
126+
- name: Install Rustup using win.rustup.rs
127+
if: startsWith(matrix.os, 'windows')
128+
run: |
129+
# Disable the download progress bar which can cause perf issues
130+
$ProgressPreference = "SilentlyContinue"
131+
Invoke-WebRequest https://win.rustup.rs/ -OutFile rustup-init.exe
132+
.\rustup-init.exe -y --default-host=x86_64-pc-windows-msvc
133+
del rustup-init.exe
134+
rustup target add x86_64-pc-windows-msvc
135+
rustup --version
136+
shell: powershell
137+
138+
- name: Install Rustup
139+
if: startsWith(matrix.os, 'macos')
140+
run: |
141+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
142+
sh rustup-init.sh -y --default-toolchain none
143+
rustup target add "x86_64-apple-darwin"
144+
126145
- name: Setup MSVC
127146
uses: ilammy/msvc-dev-cmd@v1
128147
if: startsWith(matrix.os, 'windows')
@@ -141,12 +160,12 @@ jobs:
141160
cmake -S qtkeychain -B qtkeychain/build -DBUILD_WITH_QT6=ON $CMAKE_ARGS
142161
cmake --build qtkeychain/build --target install
143162
144-
- name: Build and install Olm
163+
- name: Build and install Corrosion
145164
run: |
146165
cd ..
147-
git clone https://gitlab.matrix.org/matrix-org/olm.git
148-
cmake -S olm -B olm/build $CMAKE_ARGS
149-
cmake --build olm/build --target install
166+
git clone https://github.com/corrosion-rs/corrosion
167+
cmake -S corrosion -B corrosion/build $CMAKE_ARGS
168+
cmake --build corrosion/build --target install
150169
151170
- name: Get CS API definitions; clone and build GTAD
152171
if: matrix.update-api
@@ -172,20 +191,20 @@ jobs:
172191

173192
- name: Configure libQuotient
174193
run: |
175-
cmake -S $GITHUB_WORKSPACE -B $BUILD_PATH $CMAKE_ARGS -DQuotient_INSTALL_TESTS=ON
194+
cmake -S $GITHUB_WORKSPACE -B build $CMAKE_ARGS -DQuotient_INSTALL_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1
176195
177196
- name: Regenerate API code
178197
if: matrix.update-api
179-
run: cmake --build ../build/libQuotient --target update-api
198+
run: cmake --build build --target update-api
180199

181200
- name: Build and install libQuotient
201+
shell: pwsh
182202
run: |
183-
if [[ '${{ matrix.static-analysis }}' == 'sonar' ]]; then
184-
BUILD_WRAPPER="${{ steps.sonar.outputs.build-wrapper-binary }} --out-dir $BUILD_PATH/sonar"
185-
fi
186-
$BUILD_WRAPPER cmake --build $BUILD_PATH --target all
187-
cmake --build $BUILD_PATH --target install
188-
ls ~/.local$BIN_DIR/quotest
203+
# if [[ '${{ matrix.static-analysis }}' == 'sonar' ]]; then
204+
# BUILD_WRAPPER="${{ steps.sonar.outputs.build-wrapper-binary }} --out-dir build/sonar"
205+
# fi
206+
cmake --build build --target all
207+
cmake --build build --target install
189208
190209
- name: Run tests
191210
env:
@@ -195,7 +214,7 @@ jobs:
195214
QT_LOGGING_RULES: 'quotient.*.debug=true;quotient.jobs.sync.debug=false;quotient.events.ephemeral.debug=false;quotient.events.state.debug=false;quotient.events.members.debug=false'
196215
QT_MESSAGE_PATTERN: '%{time h:mm:ss.zzz}|%{category}|%{if-debug}D%{endif}%{if-info}I%{endif}%{if-warning}W%{endif}%{if-critical}C%{endif}%{if-fatal}F%{endif}|%{message}'
197216
run: |
198-
CTEST_ARGS="--test-dir $BUILD_PATH --output-on-failure"
217+
CTEST_ARGS="--test-dir build --output-on-failure"
199218
if [[ '${{ runner.os }}' != 'Linux' ]]; then
200219
CTEST_ARGS="$CTEST_ARGS -E testolmaccount"
201220
else
@@ -219,14 +238,14 @@ jobs:
219238
SONAR_SERVER_URL: 'https://sonarcloud.io'
220239
run: |
221240
mkdir .coverage && pushd .coverage
222-
find $BUILD_PATH -name '*.gcda' -print0 \
241+
find ../build -name '*.gcda' -print0 \
223242
| xargs -0 gcov$GCC_VERSION -s $GITHUB_WORKSPACE -pr
224243
# Coverage of the test source code is not tracked, as it is always 100%
225244
# (if not, some tests failed and broke the build at an earlier stage)
226245
rm -f quotest* autotests*
227246
popd
228247
${{ steps.sonar.outputs.sonar-scanner-binary }} \
229248
-Dsonar.host.url="$SONAR_SERVER_URL" \
230-
-Dsonar.cfamily.compile-commands="$BUILD_PATH/sonar/compile_commands.json" \
249+
-Dsonar.cfamily.compile-commands="build/compile_commands.json" \
231250
-Dsonar.cfamily.threads=2 \
232251
-Dsonar.cfamily.gcov.reportsPath=.coverage

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ compile_commands.json
3232
# Created by doxygen
3333
html/
3434
latex/
35+
36+
Quotient/crypto-sdk/target
37+
.kateproject.build

CMakeLists.txt

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -95,20 +95,14 @@ find_package(${Qt} ${QtMinVersion} REQUIRED Core Network Gui Test Sql)
9595
get_filename_component(Qt_Prefix "${${Qt}_DIR}/../../../.." ABSOLUTE)
9696

9797
find_package(${Qt}Keychain REQUIRED)
98+
find_package(Corrosion REQUIRED)
9899

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

106-
find_package(OpenSSL 1.1.0 REQUIRED)
107-
set_package_properties(OpenSSL PROPERTIES
108-
DESCRIPTION "Open source SSL and TLS implementation and cryptographic library"
109-
URL "https://www.openssl.org/"
110-
TYPE REQUIRED
111-
)
105+
corrosion_import_crate(MANIFEST_PATH Quotient/crypto-sdk/Cargo.toml)
112106

113107
add_library(${QUOTIENT_LIB_NAME})
114108

@@ -174,19 +168,8 @@ target_sources(${QUOTIENT_LIB_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS .
174168
Quotient/jobs/syncjob.h
175169
Quotient/jobs/mediathumbnailjob.h
176170
Quotient/jobs/downloadfilejob.h
177-
Quotient/database.h
178-
Quotient/connectionencryptiondata_p.h
179171
Quotient/keyverificationsession.h
180172
Quotient/e2ee/e2ee_common.h
181-
Quotient/e2ee/qolmaccount.h
182-
Quotient/e2ee/qolmsession.h
183-
Quotient/e2ee/qolminboundsession.h
184-
Quotient/e2ee/qolmoutboundsession.h
185-
Quotient/e2ee/qolmutility.h
186-
Quotient/e2ee/qolmsession.h
187-
Quotient/e2ee/qolmmessage.h
188-
Quotient/e2ee/cryptoutils.h
189-
Quotient/e2ee/sssshandler.h
190173
Quotient/events/keyverificationevent.h
191174
Quotient/keyimport.h
192175
Quotient/qt_connection_util.h
@@ -233,19 +216,8 @@ target_sources(${QUOTIENT_LIB_NAME} PUBLIC FILE_SET HEADERS BASE_DIRS .
233216
Quotient/jobs/syncjob.cpp
234217
Quotient/jobs/mediathumbnailjob.cpp
235218
Quotient/jobs/downloadfilejob.cpp
236-
Quotient/database.cpp
237-
Quotient/connectionencryptiondata_p.cpp
238219
Quotient/keyverificationsession.cpp
239220
Quotient/e2ee/e2ee_common.cpp
240-
Quotient/e2ee/qolmaccount.cpp
241-
Quotient/e2ee/qolmsession.cpp
242-
Quotient/e2ee/qolminboundsession.cpp
243-
Quotient/e2ee/qolmoutboundsession.cpp
244-
Quotient/e2ee/qolmutility.cpp
245-
Quotient/e2ee/qolmsession.cpp
246-
Quotient/e2ee/qolmmessage.cpp
247-
Quotient/e2ee/cryptoutils.cpp
248-
Quotient/e2ee/sssshandler.cpp
249221
Quotient/keyimport.cpp
250222
libquotientemojis.qrc
251223
)
@@ -362,9 +334,22 @@ target_include_directories(${QUOTIENT_LIB_NAME} PUBLIC
362334
$<BUILD_INTERFACE:$<$<NOT:$<BOOL:${QUOTIENT_FORCE_NAMESPACED_INCLUDES}>>:${CMAKE_CURRENT_SOURCE_DIR}/Quotient>>
363335
)
364336

337+
find_package(OpenSSL REQUIRED)
338+
365339
target_link_libraries(${QUOTIENT_LIB_NAME}
366-
PUBLIC ${Qt}::Core ${Qt}::Network ${Qt}::Gui qt${${Qt}Core_VERSION_MAJOR}keychain Olm::Olm ${Qt}::Sql
367-
PRIVATE OpenSSL::Crypto ${Qt}::CorePrivate)
340+
PUBLIC ${Qt}::Core ${Qt}::Network ${Qt}::Gui qt${${Qt}Core_VERSION_MAJOR}keychain ${Qt}::Sql
341+
PRIVATE ${Qt}::CorePrivate matrix_rust_sdk_crypto_cpp OpenSSL::Crypto)
342+
343+
if(NOT WIN32)
344+
target_link_libraries(${QUOTIENT_LIB_NAME} PRIVATE PkgConfig::SQLITE)
345+
else()
346+
target_link_libraries(${QUOTIENT_LIB_NAME} PRIVATE Bcrypt.lib)
347+
endif()
348+
349+
target_include_directories(${QUOTIENT_LIB_NAME} PRIVATE
350+
${CMAKE_BINARY_DIR}/cargo/build/${Rust_CARGO_TARGET}/cxxbridge/matrix-rust-sdk-crypto/src/)
351+
352+
368353

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

@@ -389,6 +374,7 @@ write_basic_package_version_file(
389374
COMPATIBILITY SameMajorVersion
390375
)
391376

377+
install(TARGETS matrix_rust_sdk_crypto_cpp EXPORT ${QUOTIENT_LIB_NAME}Targets)
392378
export(PACKAGE ${QUOTIENT_LIB_NAME})
393379
export(EXPORT ${QUOTIENT_LIB_NAME}Targets
394380
FILE "${CMAKE_CURRENT_BINARY_DIR}/${QUOTIENT_LIB_NAME}/${QUOTIENT_LIB_NAME}Targets.cmake")
@@ -432,8 +418,6 @@ message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
432418
message(STATUS " Header files install prefix: ${CMAKE_INSTALL_PREFIX}/${${PROJECT_NAME}_INSTALL_INCLUDEDIR}")
433419
message(STATUS "Using Qt ${${Qt}_VERSION} at ${Qt_Prefix}")
434420
message(STATUS "Using QtKeychain ${${Qt}Keychain_VERSION} at ${${Qt}Keychain_DIR}")
435-
message(STATUS "Using libOlm ${Olm_VERSION} at ${Olm_DIR}")
436-
message(STATUS "Using OpenSSL libcrypto ${OPENSSL_VERSION} at ${OPENSSL_CRYPTO_LIBRARY}")
437421
message(STATUS)
438422
feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES
439423
FATAL_ON_MISSING_REQUIRED_PACKAGES)

0 commit comments

Comments
 (0)