Skip to content

Commit e01c138

Browse files
authored
Merge pull request #311 from mtconnect/upgrade_boost_to_1_82
Upgrade boost to 1.82 and Dockerfile with tests
2 parents 5f02c8e + ad71370 commit e01c138

24 files changed

+286
-275
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929
jobs:
3030
build_windows:
3131
runs-on: windows-2019
32+
name: "Windows 2019 Arch: ${{ matrix.arch }}, Shared: ${{ matrix.shared }}"
3233
strategy:
3334
matrix:
3435
arch: ["x86", "amd64"]
@@ -106,6 +107,7 @@ jobs:
106107

107108
build_linux:
108109
runs-on: ubuntu-latest
110+
name: "Ubuntu Latest, Shared: ${{ matrix.shared }}"
109111
strategy:
110112
matrix:
111113
shared: ["True", "False"]
@@ -147,6 +149,7 @@ jobs:
147149
148150
build_macos:
149151
runs-on: macos-latest
152+
name: "MacOS Latest, Shared: ${{ matrix.shared }}"
150153
strategy:
151154
matrix:
152155
shared: ["True", "False"]

Dockerfile

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# --push \
1515
# .
1616
#
17+
# To run tests, use `--build-arg WITH_TESTS=true`
18+
#
1719
# # Note: In this case, I would suggest to map port `5000` to `5000`. The user can always change the port according to their needs.
1820
# docker run -it --rm --init --name agent -p5001:5000 \
1921
# mtconnect/agent:2.0.0.12_RC18
@@ -70,20 +72,25 @@ WORKDIR /root/agent
7072
# bring in the repo contents, minus .dockerignore files
7173
COPY . .
7274

73-
# make installer
74-
RUN conan profile detect \
75-
&& conan create . \
76-
--build=missing \
77-
-c "tools.build:jobs=$CONAN_CPU_COUNT" \
78-
-c tools.build:skip_test=True \
79-
-o agent_prefix=mtc \
80-
-o cpack=True \
81-
-o "with_ruby=$WITH_RUBY" \
82-
-o cpack_destination=/root/agent \
83-
-o cpack_name=dist \
84-
-o cpack_generator=TGZ \
85-
-pr "$CONAN_PROFILE" \
86-
-tf ''
75+
ARG WITH_TESTS=false
76+
ARG WITH_TESTS_ARG=argument
77+
78+
# Build and optionally test
79+
RUN if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; \
80+
then WITH_TESTS_ARG="--test-folder="; \
81+
else WITH_TESTS_ARG=""; fi \
82+
&& conan profile detect \
83+
&& conan create . \
84+
--build=missing \
85+
-c "tools.build:jobs=$CONAN_CPU_COUNT" \
86+
-o agent_prefix=mtc \
87+
-o cpack=True \
88+
-o "with_ruby=$WITH_RUBY" \
89+
-o cpack_destination=/root/agent \
90+
-o cpack_name=dist \
91+
-o cpack_generator=TGZ \
92+
-pr "$CONAN_PROFILE" \
93+
${WITH_TESTS_ARG}
8794

8895
# ---------------------------------------------------------------------
8996
# release

Dockerfile.alpine

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
# --push \
1515
# .
1616
#
17+
# To run tests, use `--build-arg WITH_TESTS=true`
18+
#
1719
# # Note: In this case, I would suggest to map port `5000` to `5000`. The user can always change the port according to their needs.
1820
# docker run -it --rm --init --name agent -p5001:5000 \
1921
# mtconnect/agent:2.0.0.12_RC18
@@ -69,20 +71,25 @@ WORKDIR /root/agent
6971
# bring in the repo contents, minus .dockerignore files
7072
COPY . .
7173

72-
# make installer
73-
RUN conan profile detect \
74-
&& conan create . \
75-
--build=missing \
76-
-c "tools.build:jobs=$CONAN_CPU_COUNT" \
77-
-c tools.build:skip_test=True \
78-
-o agent_prefix=mtc \
79-
-o cpack=True \
80-
-o "with_ruby=$WITH_RUBY" \
81-
-o cpack_destination=/root/agent \
82-
-o cpack_name=dist \
83-
-o cpack_generator=TGZ \
84-
-pr "$CONAN_PROFILE" \
85-
-tf ''
74+
ARG WITH_TESTS=false
75+
ARG WITH_TESTS_ARG=argument
76+
77+
# Build and optionally test
78+
RUN if [ -z "$WITH_TESTS" ] || [ "$WITH_TESTS" = "false" ]; \
79+
then WITH_TESTS_ARG="--test-folder="; \
80+
else WITH_TESTS_ARG=""; fi \
81+
&& conan profile detect \
82+
&& conan create . \
83+
--build=missing \
84+
-c "tools.build:jobs=$CONAN_CPU_COUNT" \
85+
-o agent_prefix=mtc \
86+
-o cpack=True \
87+
-o "with_ruby=$WITH_RUBY" \
88+
-o cpack_destination=/root/agent \
89+
-o cpack_name=dist \
90+
-o cpack_generator=TGZ \
91+
-pr "$CONAN_PROFILE" \
92+
${WITH_TESTS_ARG}
8693

8794
# ---------------------------------------------------------------------
8895
# release

appveyor.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

conan/mqtt_cpp/conanfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
class MqttcppConan(ConanFile):
66
name = "mqtt_cpp"
7-
version = "13.1.0"
7+
version = "13.2.1"
88
license = "Boost Software License, Version 1.0"
99
author = "Takatoshi Kondo [email protected]"
1010
url = "https://github.com/redboltz/mqtt_cpp"
1111
description = "MQTT client/server for C++14 based on Boost.Asio"
1212
topics = ("mqtt")
13-
requires = ["boost/1.79.0"]
13+
requires = ["boost/1.82.0"]
1414
no_copy_source = True
1515
exports_sources = "include/*"
1616

conanfile.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class MTConnectAgentConan(ConanFile):
7070
"date*:use_system_tz_db": True
7171
}
7272

73-
exports_sources = "*"
73+
exports_sources = "*", "!build", "!test_package/build"
7474
exports = "conan/mqtt_cpp/*", "conan/mruby/*"
7575

7676
def validate(self):
@@ -91,14 +91,23 @@ def config_options(self):
9191
if is_msvc(self):
9292
self.options.rm_safe("fPIC")
9393

94+
def build_requirements(self):
95+
self.tool_requires("cmake/3.26.4")
96+
97+
if self.options.with_docs:
98+
buf = io.StringIO()
99+
res = self.run(["doxygen --version"], shell=True, stdout=buf)
100+
if (res != 0 or not buf.getvalue().startswith('1.9')):
101+
self.tool_requires("doxygen/1.9.4")
102+
94103
def requirements(self):
95-
self.requires("boost/1.79.0", headers=True, libs=True, transitive_headers=True, transitive_libs=True)
104+
self.requires("boost/1.82.0", headers=True, libs=True, transitive_headers=True, transitive_libs=True)
96105
self.requires("libxml2/2.10.3", headers=True, libs=True, visible=True, transitive_headers=True, transitive_libs=True)
97106
self.requires("date/2.4.1", headers=True, libs=True, transitive_headers=True, transitive_libs=True)
98107
self.requires("nlohmann_json/3.9.1", headers=True, libs=False, transitive_headers=True, transitive_libs=False)
99108
self.requires("openssl/3.0.8", headers=True, libs=True, transitive_headers=True, transitive_libs=True)
100109
self.requires("rapidjson/cci.20220822", headers=True, libs=False, transitive_headers=True, transitive_libs=False)
101-
self.requires("mqtt_cpp/13.1.0", headers=True, libs=False, transitive_headers=True, transitive_libs=False)
110+
self.requires("mqtt_cpp/13.2.1", headers=True, libs=False, transitive_headers=True, transitive_libs=False)
102111
self.requires("bzip2/1.0.8", headers=True, libs=True, transitive_headers=True, transitive_libs=True)
103112

104113
if self.options.with_ruby:
@@ -164,15 +173,6 @@ def generate(self):
164173
deps = CMakeDeps(self)
165174
deps.generate()
166175

167-
def build_requirements(self):
168-
self.tool_requires("cmake/3.26.4")
169-
170-
if self.options.with_docs:
171-
buf = io.StringIO()
172-
res = self.run(["doxygen --version"], shell=True, stdout=buf)
173-
if (res != 0 or not buf.getvalue().startswith('1.9')):
174-
self.tool_requires("doxygen/1.9.4")
175-
176176
def build(self):
177177
cmake = CMake(self)
178178
cmake.verbose = True

src/mtconnect/config.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
/// @file config.hpp
2121
/// @brief common includes and cross platform requirements
2222

23+
// TODO: Remove when BOOST fixes its multiple defined symbol issue with phoenix placeholders
24+
#define BOOST_PHOENIX_STL_TUPLE_H_
25+
#define BOOST_BIND_NO_PLACEHOLDERS
26+
2327
#include <boost/config.hpp>
2428

2529
#ifndef __STDC_LIMIT_MACROS

src/mtconnect/configuration/agent_config.cpp

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ namespace mtconnect::configuration {
351351
using namespace chrono;
352352
using namespace chrono_literals;
353353

354-
using boost::placeholders::_1;
354+
using std::placeholders::_1;
355355

356356
m_monitorTimer.expires_from_now(100ms);
357357
m_monitorTimer.async_wait(boost::bind(&AgentConfiguration::monitorFiles, this, _1));
@@ -373,7 +373,7 @@ namespace mtconnect::configuration {
373373
using namespace chrono;
374374
using namespace chrono_literals;
375375

376-
using boost::placeholders::_1;
376+
using std::placeholders::_1;
377377

378378
m_monitorTimer.expires_from_now(m_monitorInterval);
379379
m_monitorTimer.async_wait(boost::bind(&AgentConfiguration::monitorFiles, this, _1));
@@ -610,13 +610,85 @@ namespace mtconnect::configuration {
610610
// Formatter for the logger
611611
core->add_sink(m_sink);
612612
}
613+
614+
static std::string ExpandValue(const std::map<std::string, std::string> &values, const std::string &s)
615+
{
616+
static std::regex pat("\\$(([A-Za-z0-9_]+)|\\{([^}]+)\\})");
617+
stringstream out;
618+
std::sregex_iterator iter(s.begin(), s.end(), pat);
619+
std::sregex_iterator end;
620+
std::sregex_iterator::value_type::value_type suf;
621+
622+
if (iter == end)
623+
{
624+
return s;
625+
}
626+
627+
while (iter != end)
628+
{
629+
out << iter->prefix().str();
630+
string sym;
631+
if ((*iter)[3].matched)
632+
sym = (*iter)[3].str();
633+
else if ((*iter)[2].matched)
634+
sym = (*iter)[2].str();
635+
636+
// Resolve match text
637+
auto opt = values.find(sym);
638+
if (opt != values.end())
639+
{
640+
out << opt->second;
641+
}
642+
else if (auto env = getenv(sym.c_str()))
643+
{
644+
out << env;
645+
}
646+
else
647+
{
648+
out << iter->str();
649+
}
650+
651+
suf = iter->suffix();
652+
iter++;
653+
}
654+
655+
out << suf.str();
656+
657+
return out.str();
658+
}
659+
660+
static void ExpandValues(std::map<std::string,std::string> values,
661+
boost::property_tree::ptree &node)
662+
{
663+
if (auto value = node.get_value_optional<std::string>();
664+
value->find('$') != std::string::npos)
665+
{
666+
auto expanded = ExpandValue(values, *value);
667+
node.put_value(expanded);
668+
}
669+
670+
for (auto &block : node)
671+
{
672+
ExpandValues(values, block.second);
673+
const auto &value = block.second.get_value_optional<std::string>();
674+
if (value && !value->empty())
675+
values[block.first] = *value;
676+
}
677+
}
678+
679+
void AgentConfiguration::expandConfigVariables(boost::property_tree::ptree &config)
680+
{
681+
std::map<std::string,std::string> values;
682+
ExpandValues(values, config);
683+
}
684+
613685

614-
void AgentConfiguration::loadConfig(const std::string &file)
686+
void AgentConfiguration::loadConfig(const std::string &text)
615687
{
616688
NAMED_SCOPE("AgentConfiguration::loadConfig");
617689

618690
// Now get our configuration
619-
auto config = Parser::parse(file);
691+
auto config = Parser::parse(text);
620692

621693
// if (!m_loggerFile)
622694
if (!m_sink)

0 commit comments

Comments
 (0)