Skip to content

Commit

Permalink
⚒ Build improvements (#29)
Browse files Browse the repository at this point in the history
Carries over some optimizations made in Glimesh/janus-ftl-plugin#88

Spdlog is now built and linked statically. We provide our own copy of `fmt` (which we can leverage in the future instead of `stringstream` for easy string formatting).

Fmt, Spdlog, and Catch2 are all included in precompiled headers to improve build times.
  • Loading branch information
haydenmc authored Feb 28, 2021
1 parent 9b84729 commit 974b559
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 159 deletions.
24 changes: 21 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,26 @@ sources = files([
'src/TlsConnectionManager.cpp',
])

# Pull in subprojects
fmt_wrap = subproject('fmt', default_options: 'default_library=static')
meson.override_dependency('fmt', fmt_wrap.get_variable('fmt_dep')) # Use our copy of fmt for spdlog
spdlog_wrap = subproject('spdlog', default_options: ['default_library=static', 'compile_library=true', 'external_fmt=true'] )
catch2_wrap = subproject('catch2')

deps = [
dependency('libssl'),
dependency('libcrypto'),
dependency('catch2', fallback: ['catch2', 'catch2_dep']),
subproject('spdlog').get_variable('spdlog_dep'), # use wrapped copy of spdlog
# Meson wrapped dependencies
fmt_wrap.get_variable('fmt_dep'),
spdlog_wrap.get_variable('spdlog_dep'),
]

incdir = include_directories(['src', 'inc'])

executable(
'janus-ftl-orchestrator',
sources,
cpp_pch: 'pch/pch.h',
include_directories: incdir,
dependencies: deps,
install: true,
Expand All @@ -51,9 +59,19 @@ testsources = files([
'src/TlsConnectionManager.cpp',
])

testdeps = [
dependency('libssl'),
dependency('libcrypto'),
# Meson wrapped dependencies
fmt_wrap.get_variable('fmt_dep'),
spdlog_wrap.get_variable('spdlog_dep'),
catch2_wrap.get_variable('catch2_dep'),
]

executable(
'janus-ftl-orchestrator-test',
testsources,
cpp_pch: 'pch/test_pch.h',
include_directories: incdir,
dependencies: deps,
dependencies: testdeps,
)
10 changes: 10 additions & 0 deletions pch/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @file pch.h
* @author Hayden McAfee ([email protected])
* @date 2021-02-28
* @copyright Copyright (c) 2021 Hayden McAfee
* @brief Pre-compiled header for janus-ftl-orchestrator
*/

#include <fmt/core.h>
#include <spdlog/spdlog.h>
13 changes: 13 additions & 0 deletions pch/test_pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @file test_pch.h
* @author Hayden McAfee ([email protected])
* @date 2021-02-28
* @copyright Copyright (c) 2021 Hayden McAfee
* @brief Pre-compiled header for janus-ftl-orchestrator-test
*/

#include <fmt/core.h>
#include <spdlog/spdlog.h>

#define CATCH_CONFIG_ALL_PARTS
#include <catch2/catch.hpp>
1 change: 0 additions & 1 deletion src/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include "Configuration.h"

#include <spdlog/spdlog.h>
#include <sstream>

#pragma region Public methods
Expand Down
2 changes: 0 additions & 2 deletions src/Orchestrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include "StreamStore.h"
#include "Util.h"

#include <spdlog/spdlog.h>

#include <list>

#pragma region Constructor/Destructor
Expand Down
2 changes: 0 additions & 2 deletions src/SubscriptionStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "ChannelSubscription.h"
#include "FtlTypes.h"

#include <spdlog/spdlog.h>

#include <map>
#include <memory>
#include <mutex>
Expand Down
1 change: 0 additions & 1 deletion src/TlsConnectionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "Util.h"

#include <openssl/ssl.h>
#include <spdlog/spdlog.h>
#include <sstream>
#include <stdexcept>

Expand Down
138 changes: 0 additions & 138 deletions src/test-client.cpp

This file was deleted.

11 changes: 11 additions & 0 deletions subprojects/fmt.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[wrap-file]
directory = fmt-7.1.3
source_url = https://github.com/fmtlib/fmt/archive/7.1.3.tar.gz
source_filename = fmt-7.1.3.tar.gz
source_hash = 5cae7072042b3043e12d53d50ef404bbb76949dad1de368d7f993a15c8c05ecc
patch_url = https://wrapdb.mesonbuild.com/v1/projects/fmt/7.1.3/1/get_zip
patch_filename = fmt-7.1.3-1-wrap.zip
patch_hash = 6eb951a51806fd6ffd596064825c39b844c1fe1799840ef507b61a53dba08213

[provide]
fmt = fmt_dep
2 changes: 0 additions & 2 deletions test/TestLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@

#pragma once

#include <catch2/catch.hpp>
#include <spdlog/sinks/base_sink.h>

#include <string>

template<typename Mutex>
Expand Down
2 changes: 0 additions & 2 deletions test/functional/FunctionalTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* @copyright Copyright (c) 2020 Hayden McAfee
*/

#include <catch2/catch.hpp>

#include <FtlOrchestrationClient.h>
#include <Orchestrator.h>
#include <TlsConnectionManager.h>
Expand Down
11 changes: 7 additions & 4 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
* @copyright Copyright (c) 2020 Hayden McAfee
*/

#define CATCH_CONFIG_RUNNER // This tells Catch that we'll be providing the main entrypoint
#include <catch2/catch.hpp>
#include <spdlog/spdlog.h>

#include "TestLogging.h"

#include <memory>
#include <mutex>

// Some Catch2 defines required for PCH support
// https://github.com/catchorg/Catch2/blob/v2.x/docs/ci-and-misc.md#precompiled-headers-pchs
#undef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define CATCH_CONFIG_IMPL_ONLY
#define CATCH_CONFIG_RUNNER
#include <catch2/catch.hpp>

int main(int argc, char* argv[])
{
// Set up logging
Expand Down
2 changes: 0 additions & 2 deletions test/unit/FtlConnectionUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* @copyright Copyright (c) 2020 Hayden McAfee
*/

#include <catch2/catch.hpp>

#include <FtlConnection.h>

#include "../mocks/MockConnectionTransport.h"
Expand Down
2 changes: 0 additions & 2 deletions test/unit/OrchestratorUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* @brief Contains unit tests for the Orchestrator class.
*/

#include <catch2/catch.hpp>

#include <array>
#include <memory>
#include <sstream>
Expand Down

0 comments on commit 974b559

Please sign in to comment.