diff --git a/doc/doxygen.cfg.in b/doc/doxygen.cfg.in new file mode 100644 index 00000000..ebd0c6ca --- /dev/null +++ b/doc/doxygen.cfg.in @@ -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 diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 00000000..0eaf4dfd --- /dev/null +++ b/doc/meson.build @@ -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 diff --git a/include/meson.build b/include/meson.build new file mode 100644 index 00000000..64fed95c --- /dev/null +++ b/include/meson.build @@ -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 diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..8c73d51a --- /dev/null +++ b/meson.build @@ -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') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..0c4d773f --- /dev/null +++ b/meson_options.txt @@ -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 diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000..494f9748 --- /dev/null +++ b/src/meson.build @@ -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, + ) diff --git a/subprojects/.gitignore b/subprojects/.gitignore new file mode 100644 index 00000000..3353b24c --- /dev/null +++ b/subprojects/.gitignore @@ -0,0 +1,2 @@ +googletest-release-*/ +packagecache/ diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap new file mode 100644 index 00000000..8d87fa8d --- /dev/null +++ b/subprojects/gtest.wrap @@ -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 diff --git a/tests/gt_address.cpp b/tests/gt_address.cpp new file mode 100644 index 00000000..dfb95c15 --- /dev/null +++ b/tests/gt_address.cpp @@ -0,0 +1,21 @@ +#include +#include + +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 diff --git a/tests/gt_numericfield.cpp b/tests/gt_numericfield.cpp new file mode 100644 index 00000000..bd1a0b44 --- /dev/null +++ b/tests/gt_numericfield.cpp @@ -0,0 +1,20 @@ +#include +#include + +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 diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 00000000..3415f540 --- /dev/null +++ b/tests/meson.build @@ -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