Skip to content
Snippets Groups Projects
Unverified Commit d4b891e3 authored by Nicolas Werner's avatar Nicolas Werner Committed by GitHub
Browse files

Merge pull request #58 from Nheko-Reborn/meson

Preliminary Meson support
parents 5eb3aa0a 2e770f29
No related branches found
No related tags found
No related merge requests found
Pipeline #1874 passed
......@@ -112,6 +112,30 @@ build linux arm64:
- job: "build synapse arm64"
optional: true
build linux meson wraps:
stage: build
image: alpine:latest
tags: [docker]
needs:
- job: "build synapse amd64"
optional: true
variables:
M_ARCH: x86_64
COVERAGE: "ON"
services: !reference [.build-linux, services]
before_script:
- echo 'https://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
- apk update && apk add meson git g++ cmake pkgconf openssl openssl-dev make
script:
- meson setup builddir -Dtests=true -Dexamples=true -Ddefault_library=static
- meson compile -C builddir
- MTXCLIENT_SERVER=synapse meson test -C builddir
artifacts:
reports:
junit: builddir/*.xml
paths:
- builddir/*.xml
build-macos:
stage: build
tags: [macos]
......
spdlog_dep = dependency('spdlog', fallback: ['spdlog', 'spdlog_dep'])
room_feed = executable('room_feed',
'room_feed.cpp',
dependencies: [matrix_client_dep],
include_directories : '../tests'
)
if meson.get_compiler('cpp').has_header('filesystem')
media_downloader = executable('media_downloader',
'media_downloader.cpp',
dependencies: [matrix_client_dep],
include_directories : '../tests'
)
endif
simple_bot = executable('simple_bot',
'simple_bot.cpp',
dependencies: [matrix_client_dep],
include_directories : '../tests'
)
crypto_bot = executable('crypto_bot',
'crypto_bot.cpp',
dependencies: [matrix_client_dep, spdlog_dep],
include_directories : '../tests'
)
online_backup_exporter = executable('online_backup_exporter',
'online_backup_exporter.cpp',
dependencies: [matrix_client_dep],
include_directories : '../tests'
)
project(
'mtxclient',
'cpp',
version : '0.5.1',
meson_version : '>=0.57.0',
license : 'MIT',
default_options : 'cpp_std=c++17'
)
cmake = import('cmake')
coeurl_dep = dependency('coeurl', required: true)
thread_dep = dependency('threads', required: true)
openssl_dep = dependency('openssl', version: '>=1.1', required: true)
json_dep = dependency('nlohmann_json', version: '>=3.2.0', required: true)
olm_dep = dependency('Olm', method: 'cmake', required: get_option('wrap_mode') == 'nofallback')
if (not olm_dep.found()
or get_option('wrap_mode') == 'forcefallback'
or 'Olm' in get_option('force_fallback_for'))
olm_options = cmake.subproject_options()
olm_options.add_cmake_defines({
'BUILD_SHARED_LIBS': false,
'OLM_TESTS': false,
})
if target_machine.system() != 'windows'
olm_options.add_cmake_defines({
'CMAKE_C_FLAGS': '-fPIC',
})
endif
olm_options.set_override_option('werror', 'false')
olm_options.set_override_option('warning_level', '0')
olm_proj = cmake.subproject('Olm', options: olm_options)
olm_dep = olm_proj.dependency('olm')
endif
deps = [
coeurl_dep,
thread_dep,
olm_dep,
openssl_dep,
json_dep
]
inc = include_directories('include')
src = [
'lib/crypto/client.cpp',
'lib/crypto/encoding.cpp',
'lib/crypto/types.cpp',
'lib/crypto/utils.cpp',
'lib/http/client.cpp',
'lib/log.cpp',
'lib/structs/common.cpp',
'lib/structs/errors.cpp',
'lib/structs/events.cpp',
'lib/structs/events/account_data/fully_read.cpp',
'lib/structs/events/aliases.cpp',
'lib/structs/events/avatar.cpp',
'lib/structs/events/canonical_alias.cpp',
'lib/structs/events/collections.cpp',
'lib/structs/events/common.cpp',
'lib/structs/events/create.cpp',
'lib/structs/events/encrypted.cpp',
'lib/structs/events/encryption.cpp',
'lib/structs/events/ephemeral/receipt.cpp',
'lib/structs/events/ephemeral/typing.cpp',
'lib/structs/events/guest_access.cpp',
'lib/structs/events/history_visibility.cpp',
'lib/structs/events/join_rules.cpp',
'lib/structs/events/member.cpp',
'lib/structs/events/messages/audio.cpp',
'lib/structs/events/messages/emote.cpp',
'lib/structs/events/messages/file.cpp',
'lib/structs/events/messages/image.cpp',
'lib/structs/events/messages/notice.cpp',
'lib/structs/events/messages/text.cpp',
'lib/structs/events/messages/video.cpp',
'lib/structs/events/mscs/image_packs.cpp',
'lib/structs/events/name.cpp',
'lib/structs/events/nheko_extensions/hidden_events.cpp',
'lib/structs/events/pinned_events.cpp',
'lib/structs/events/power_levels.cpp',
'lib/structs/events/presence.cpp',
'lib/structs/events/reaction.cpp',
'lib/structs/events/redaction.cpp',
'lib/structs/events/spaces.cpp',
'lib/structs/events/tag.cpp',
'lib/structs/events/tombstone.cpp',
'lib/structs/events/topic.cpp',
'lib/structs/events/unknown.cpp',
'lib/structs/events/voip.cpp',
'lib/structs/identifiers.cpp',
'lib/structs/pushrules.cpp',
'lib/structs/requests.cpp',
'lib/structs/responses/common.cpp',
'lib/structs/responses/create_room.cpp',
'lib/structs/responses/crypto.cpp',
'lib/structs/responses/empty.cpp',
'lib/structs/responses/groups.cpp',
'lib/structs/responses/login.cpp',
'lib/structs/responses/media.cpp',
'lib/structs/responses/messages.cpp',
'lib/structs/responses/notifications.cpp',
'lib/structs/responses/profile.cpp',
'lib/structs/responses/public_rooms.cpp',
'lib/structs/responses/register.cpp',
'lib/structs/responses/sync.cpp',
'lib/structs/responses/turn_server.cpp',
'lib/structs/responses/version.cpp',
'lib/structs/responses/well-known.cpp',
'lib/structs/secret_storage.cpp',
'lib/structs/user_interactive.cpp',
'lib/utils.cpp',
]
matrix_client = library('matrix_client',
src,
dependencies: deps,
include_directories : inc,
install : true)
matrix_client_dep = declare_dependency(
link_with: matrix_client,
dependencies: deps,
include_directories: inc)
meson.override_dependency('mtxclient', matrix_client_dep)
pkg = import('pkgconfig')
pkg.generate(matrix_client,
libraries : [matrix_client],
version : meson.project_version(),
filebase : meson.project_name(),
description : 'Client API library for Matrix.',
url : 'https://github.com/Nheko-Reborn/mtxclient)')
conf = configuration_data()
cmake.write_basic_package_version_file(
name: 'MatrixClient',
compatibility: 'AnyNewerVersion',
version: meson.project_version())
cmake.configure_package_config_file(
name: 'MatrixClient',
input: 'cmake/MatrixClientConfig.cmake.in',
configuration: conf)
if get_option('examples')
subdir('examples')
endif
if get_option('tests')
subdir('tests')
endif
option('examples', type : 'boolean', value : false)
option('tests', type : 'boolean', value : false)
[wrap-git]
directory = Olm
url = https://git.matrix.org/git/olm.git
revision = 3.2.6
buildsystem = cmake
[wrap-git]
url = https://nheko.im/nheko-reborn/coeurl.git
revision = head
[wrap-file]
directory = googletest-release-1.11.0
source_url = https://github.com/google/googletest/archive/release-1.11.0.zip
source_filename = gtest-1.11.0.zip
source_hash = 353571c2440176ded91c2de6d6cd88ddd41401d14692ec1f99e35d013feda55a
patch_filename = gtest_1.11.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.11.0-1/get_patch
patch_hash = d38c39184384608b08419be52aed1d0f9d9d1b5ed71c0c35e51cccbdddab7084
[provide]
gtest = gtest_dep
gtest_main = gtest_main_dep
gmock = gmock_dep
gmock_main = gmock_main_dep
[wrap-file]
directory = nlohmann_json-3.9.1
lead_directory_missing = true
source_url = https://github.com/nlohmann/json/releases/download/v3.9.1/include.zip
source_filename = nlohmann_json-3.9.1.zip
source_hash = 6bea5877b1541d353bd77bdfbdb2696333ae5ed8f9e8cc22df657192218cad91
patch_url = https://wrapdb.mesonbuild.com/v2/nlohmann_json_3.9.1-1/get_patch
patch_filename = nlohmann_json-3.9.1-1-wrap.zip
patch_hash = 1774e5506fbe3897d652f67e41973194b948d2ab851cf464a742f35f160a1435
[provide]
nlohmann_json = nlohmann_json_dep
[wrap-file]
directory = openssl-1.1.1l
source_url = https://www.openssl.org/source/openssl-1.1.1l.tar.gz
source_filename = openssl-1.1.1l.tar.gz
source_hash = 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
patch_filename = openssl_1.1.1l-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/openssl_1.1.1l-1/get_patch
patch_hash = 670db31580039e06c17f48bcd31e489f453fe72c22006de6d693b9b033f1003a
[provide]
libcrypto = libcrypto_dep
libssl = libssl_dep
openssl = openssl_dep
[wrap-file]
directory = spdlog-1.8.5
source_url = https://github.com/gabime/spdlog/archive/v1.8.5.tar.gz
source_filename = v1.8.5.tar.gz
source_hash = 944d0bd7c763ac721398dca2bb0f3b5ed16f67cef36810ede5061f35a543b4b8
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.8.5-1/get_patch
patch_filename = spdlog-1.8.5-1-wrap.zip
patch_hash = 3c38f275d5792b1286391102594329e98b17737924b344f98312ab09929b74be
[provide]
spdlog = spdlog_dep
......@@ -81,7 +81,7 @@ TEST(MediaAPI, UploadAudio)
bob->login("bob", "secret", [bob](const mtx::responses::Login &, RequestErr err) {
ASSERT_FALSE(err);
const auto audio = read_file("./fixtures/sound.mp3");
const auto audio = read_file(fixture_prefix() + "/fixtures/sound.mp3");
bob->upload(audio,
"audio/mp3",
......@@ -112,7 +112,7 @@ TEST(MediaAPI, UploadImage)
carl->login("carl", "secret", [carl](const mtx::responses::Login &, RequestErr err) {
ASSERT_FALSE(err);
const auto img = read_file("./fixtures/test.jpeg");
const auto img = read_file(fixture_prefix() + "/fixtures/test.jpeg");
carl->upload(img,
"image/jpeg",
......@@ -157,7 +157,7 @@ TEST(MediaAPI, UploadSVG)
carl->login("carl", "secret", [carl](const mtx::responses::Login &, RequestErr err) {
ASSERT_FALSE(err);
const auto img = read_file("./fixtures/kiwi.svg");
const auto img = read_file(fixture_prefix() + "/fixtures/kiwi.svg");
carl->upload(img,
"image/svg",
......
gtest_dep = dependency('gtest', main : true, fallback : ['gtest', 'gtest_main_dep'], required : true)
client_api = executable('client_api', 'client_api.cpp', dependencies: [matrix_client_dep, gtest_dep])
media_api = executable('media_api', 'media_api.cpp', dependencies: [matrix_client_dep, gtest_dep])
e2ee = executable('e2ee', 'e2ee.cpp', dependencies: [matrix_client_dep, gtest_dep])
utils = executable('utils', 'utils.cpp', dependencies: [matrix_client_dep, gtest_dep])
pushrules = executable('pushrules', 'pushrules.cpp', dependencies: [matrix_client_dep, gtest_dep])
connection = executable('connection', 'connection.cpp', dependencies: [matrix_client_dep, gtest_dep])
identifiers = executable('identifiers', 'identifiers.cpp', dependencies: [matrix_client_dep, gtest_dep])
events = executable('events', 'events.cpp', dependencies: [matrix_client_dep, gtest_dep])
messages = executable('messages', 'messages.cpp', dependencies: [matrix_client_dep, gtest_dep])
responses = executable('responses', 'responses.cpp', dependencies: [matrix_client_dep, gtest_dep])
requests = executable('requests', 'requests.cpp', dependencies: [matrix_client_dep, gtest_dep])
errors = executable('errors', 'errors.cpp', dependencies: [matrix_client_dep, gtest_dep])
crypto = executable('crypto', 'crypto.cpp', dependencies: [matrix_client_dep, gtest_dep])
test('connection', connection, protocol: 'gtest', suite: 'network', is_parallel: false)
test('client_api', client_api, protocol: 'gtest', suite: 'network', is_parallel: false, timeout: 300)
test('media_api', media_api, protocol: 'gtest', suite: 'network', is_parallel: false,env: ['FIXTURE_PREFIX='+meson.current_source_dir()])
test('e2ee', e2ee, protocol: 'gtest', suite: 'network', is_parallel: false)
test('pushrules', pushrules, protocol: 'gtest', suite: 'network', is_parallel: false)
test('crypto', crypto, protocol: 'gtest', suite: 'nonetwork')
test('errors', errors, protocol: 'gtest', suite: 'nonetwork')
test('requests', requests, protocol: 'gtest', suite: 'nonetwork')
test('responses', responses, protocol: 'gtest', suite: 'nonetwork',env: ['FIXTURE_PREFIX='+meson.current_source_dir()])
test('messages', messages, protocol: 'gtest', suite: 'nonetwork')
test('events', events, protocol: 'gtest', suite: 'nonetwork')
test('identifiers', identifiers, protocol: 'gtest', suite: 'nonetwork')
test('utils', utils, protocol: 'gtest', suite: 'nonetwork')
......@@ -7,6 +7,8 @@
#include <mtx.hpp>
#include "test_helpers.hpp"
using json = nlohmann::json;
using namespace mtx::responses;
......@@ -323,7 +325,7 @@ TEST(Responses, InvitedRoom)
TEST(Responses, Sync)
{
std::ifstream file("./fixtures/responses/sync.json");
std::ifstream file(fixture_prefix() + "/fixtures/responses/sync.json");
json data1;
file >> data1;
......@@ -361,7 +363,7 @@ TEST(Responses, Sync)
TEST(Responses, SyncWithEncryption)
{
std::ifstream file("./fixtures/responses/sync_with_crypto.json");
std::ifstream file(fixture_prefix() + "/fixtures/responses/sync_with_crypto.json");
json data;
file >> data;
......
#pragma once
#include "gtest/gtest.h"
#include <cstdlib>
#include <iostream>
#include <limits>
#include <random>
......@@ -90,3 +91,14 @@ get_event_ids(const std::vector<Collection> &events)
return ids;
}
inline std::string
fixture_prefix()
{
auto var = std::getenv("FIXTURE_PREFIX");
if (var)
return var;
else
return ".";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment