Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: meson: add mesonbuild support #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions doc/doxygen.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PROJECT_NAME = AMQP-CPP
PROJECT_BRIEF = "C++ library for asynchronous non-blocking communication with RabbitMQ"
PROJECT_NUMBER = @PACKAGE_VERSION@
OUTPUT_DIRECTORY = @DOCDIR@
STRIP_FROM_INC_PATH = include
# Header support commands
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
TAB_SIZE = 4
OPTIMIZE_OUTPUT_FOR_C = YES
TYPEDEF_HIDES_STRUCT = NO
BUILTIN_STL_SUPPORT = YES
GENERATE_LATEX = NO
GENERATE_XML = NO
ALPHABETICAL_INDEX = YES
RECURSIVE = YES
EXTRACT_STATIC = YES
FILE_PATTERNS = *.h
INPUT = \
@TOP_SRCDIR@/include \
@TOP_BUILDDIR@/include
19 changes: 19 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
conf.set('TOP_SRCDIR', meson.source_root())
conf.set('TOP_BUILDDIR', meson.build_root())

datadir = join_paths(get_option('datadir'), 'doc')
conf.set('DOCDIR', 'doc')

if doxygen.found()
doxycfg = configure_file(input: 'doxygen.cfg.in',
output: 'doxygen.cfg',
configuration: conf,
install: false)

html_target = custom_target('docs',
input: doxycfg,
output: 'html',
command: [doxygen, doxycfg],
install: true,
install_dir: datadir)
endif
11 changes: 11 additions & 0 deletions include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
amqp_inc = include_directories('.')

install_headers('amqpcpp.h')
install_subdir('amqpcpp',
install_dir: 'include',
exclude_directories: 'linux_tcp')

if get_option('linux-tcp')
install_subdir('amqpcpp/linux_tcp',
install_dir: 'include/amqpcpp')
endif
48 changes: 48 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Non-standard build rules using meson
#
# Until meson 0.46 is released with support for default_library=both
# you can only build either static or shared. Default is shared.
#
# Support for building examples hasn't been added.

project('amqpcpp', 'cpp',
version: '3.1.0',
default_options: [
'cpp_std=c++11',
'werror=true',
],
meson_version: '>= 0.44',
)

version = meson.project_version().split('.')

conf = configuration_data()
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set('DEST_DIR', get_option('prefix'))
conf.set('VERSION_MAJOR', version[0])
conf.set('VERSION_MINOR', version[1])
conf.set('VERSION_PATCH', version[2])

doxygen = find_program('doxygen', required: false)
if find_program('dot', required: false).found()
conf.set('HAVE_DOT', 'YES')
else
conf.set('HAVE_DOT', 'NO')
endif
subdir('doc')

subdir('include')
subdir('src')

amqpcpp_dep = declare_dependency(link_with: amqp_lib,
include_directories: amqp_inc,
dependencies: lib_deps)

pkg = import('pkgconfig')
pkg.generate(libraries: lib_deps + [amqp_lib],
version: meson.project_version(),
name: 'libamqpcpp',
filebase: 'amqpcpp',
description: 'AMQP-CPP is a C++ library for communicating with a RabbitMQ message broker')

subdir('tests')
12 changes: 12 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# NB: By default meson uses --default-library shared
# Use meson --default-library static to get shared library
# With meson >= 0.46 use --default-library both to enable both
option('linux-tcp',
type: 'boolean',
value: false,
description: 'Build linux TCP socket implementation.')
option('googletest',
type: 'boolean',
value: false,
description: 'Enable Google Test framework subproject.')
# NB: examples not supported
41 changes: 41 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
lib_inc = [include_directories('.'), amqp_inc]

lib_src = [
'array.cpp',
'channelimpl.cpp',
'connectionimpl.cpp',
'deferredcancel.cpp',
'deferredconfirm.cpp',
'deferredconsumer.cpp',
'deferredextreceiver.cpp',
'deferredget.cpp',
'deferredpublisher.cpp',
'deferredreceiver.cpp',
'field.cpp',
'flags.cpp',
'receivedframe.cpp',
'table.cpp',
'watchable.cpp',
]
lib_deps = []

if get_option('linux-tcp')
lib_src += [
'linux_tcp/openssl.cpp',
'linux_tcp/tcpconnection.cpp',
]
lib_deps += dependency('openssl')
lib_deps += dependency('threads')
lib_deps += meson.get_compiler('cpp').find_library('dl')
endif

# Sorry, until meson 0.46 release adds --default-library both you only
# get shared or static. You can use static, but amqpcpp.pc won't
# include the required pthread flags.
amqp_lib = library('amqpcpp', lib_src,
include_directories: lib_inc,
dependencies: lib_deps,
version: meson.project_version(),
soversion: '.'.join([version[0], version[1]]),
install: true,
)
2 changes: 2 additions & 0 deletions subprojects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
googletest-release-*/
packagecache/
10 changes: 10 additions & 0 deletions subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[wrap-file]
directory = googletest-release-1.8.0

source_url = https://github.com/google/googletest/archive/release-1.8.0.zip
source_filename = gtest-1.8.0.zip
source_hash = f3ed3b58511efd272eb074a3a6d6fb79d7c2e6a0e374323d1e6bcbcc1ef141bf

patch_url = https://wrapdb.mesonbuild.com/v1/projects/gtest/1.8.0/4/get_zip
patch_filename = gtest-1.8.0-4-wrap.zip
patch_hash = 0b90fe055acbdb002a37dfb035184b306008b763931158497ef5dbaa8c7925af
21 changes: 21 additions & 0 deletions tests/gt_address.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <gtest/gtest.h>
#include <amqpcpp.h>

namespace {

TEST(Address, Basics)
{
AMQP::Address addr("amqp://user:passwd@server/vhost");
ASSERT_EQ(addr.port(), 5672);
ASSERT_FALSE(addr.secure());
ASSERT_STREQ(addr.hostname().c_str(), "server");
ASSERT_STREQ(addr.vhost().c_str(), "vhost");
ASSERT_STREQ(addr.login().user().c_str(), "user");
ASSERT_STREQ(addr.login().password().c_str(), "passwd");

addr = AMQP::Address("amqps://user:passwd@server/vhost");
ASSERT_TRUE(addr.secure());
ASSERT_EQ(addr.port(), 5671);
}

} // ns anonymous
20 changes: 20 additions & 0 deletions tests/gt_numericfield.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <gtest/gtest.h>
#include <amqpcpp.h>

namespace {

TEST(NumericField, implicitCast)
{
int64_t i64 = AMQP::Float(23);
ASSERT_EQ(i64, 23);
float f = AMQP::Long(2);
ASSERT_EQ(f, 2.0);
}

TEST(NumericField, isInteger)
{
ASSERT_FALSE(AMQP::Float(1).isInteger());
ASSERT_TRUE(AMQP::Long(1).isInteger());
}

} // ns anonymous
21 changes: 21 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if get_option('googletest')
gtest_sp = subproject('gtest')
gtest_dep = gtest_sp.get_variable('gtest_main_dep')
gmock_dep = gtest_sp.get_variable('gmock_main_dep')
else
gtest_dep = disabler()
gmock_dep = disabler()
endif

gt_bases = [
'gt_address',
'gt_numericfield',
]

foreach base: gt_bases
test(base, executable(base, base + '.cpp',
dependencies: [
amqpcpp_dep,
gtest_dep,
]))
endforeach