Skip to content

Commit ae01f79

Browse files
committed
Revert "Set -DENABLE_MODERN flag to ON by default and remove it (#66)"
This reverts commit 0f8f904.
1 parent addfefd commit ae01f79

File tree

8 files changed

+98
-53
lines changed

8 files changed

+98
-53
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
run: |
7272
mkdir build
7373
cd build
74-
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON
74+
cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON
7575
make
7676
7777
- name: Perform CodeQL Analysis

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ endif (WIN32)
6161

6262
set(ENABLE_QPID_PROTON ON CACHE BOOL "Enable qpid proton clients")
6363
set(ENABLE_QPID_MESSAGING ON CACHE BOOL "Enable qpid messaging clients")
64+
set(ENABLE_MODERN ON CACHE BOOL "Enable usage of refactored code")
6465
set(BUILD_WITH_UNIT_TESTS OFF CACHE BOOL "Build unit tests for the CPP client code")
6566

6667
if (NOT WIN32)
@@ -168,6 +169,14 @@ if (BUILD_WITH_UNIT_TESTS)
168169
set (CTEST_BINARY_DIRECTORY ${CMAKE_BINARY_DIR}/target/tests/bin)
169170
endif (BUILD_WITH_UNIT_TESTS)
170171

172+
if (ENABLE_MODERN)
173+
add_definitions(-DENABLE_MODERN)
174+
else (ENABLE_MODERN)
175+
if (ENABLE_QPID_PROTON)
176+
message(FATAL_ERROR "Modern code is a requirement for proton code")
177+
endif(ENABLE_QPID_PROTON)
178+
endif(ENABLE_MODERN)
179+
171180
add_subdirectory(src/contrib)
172181
add_subdirectory(src/common)
173182

@@ -185,7 +194,7 @@ set(CPPCHECK_EXECUTABLE "/usr/bin/cppcheck" CACHE STRING "Path to cppcheck")
185194
set(CPPCHECK_FLAGS "--report-progress" "-v" "--enable=all" "--xml"
186195
CACHE STRING "Options for cppcheck")
187196

188-
set(CPPCHECK_DEFS "-DENABLE_PROTON" "-DENABLE_QPID_MESSAGING"
197+
set(CPPCHECK_DEFS "-DENABLE_MODERN" "-DENABLE_PROTON" "-DENABLE_QPID_MESSAGING"
189198
"-DQPIDSYSEPOCH" CACHE STRING "Defines for cppcheck")
190199

191200
add_custom_target(check

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ sudo make install ;
3939
These variables apply to all code base and may affect what code is built with
4040
along with the project. For example, they may enable refactored code.
4141

42+
* ENABLE_MODERN: Enable new and/or refactored code. It is a requirement for -DENABLE_QPID_PROTON.
43+
Default: off
44+
4245

4346
#### Boost libraries
4447

@@ -93,7 +96,7 @@ for some older RHEL/qpid versions. Default: false.
9396
These variables affect only the QPID Proton clients.
9497

9598
* ENABLE_QPID_PROTON: Enable qpid proton messaging/reactor clients (eg.: aac3
96-
and aac4).
99+
and aac4). This variable requires ENABLE_MODERN.
97100
* PROTON_DIR: QPID Proton base directory.
98101

99102

@@ -106,14 +109,14 @@ RHEL >= 6, with QPID Proton clients, using a non-standard QPID Proton directory
106109

107110
```
108111
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
109-
-DCMAKE_CXX_COMPILER=`which c++` .
112+
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` .
110113
```
111114

112115
RHEL 5.11 without QPID Proton and disabled unit tests
113116

114117
```
115118
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
116-
-DCMAKE_CXX_COMPILER=`which c++` \
119+
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` \
117120
-DCMAKE_VERBOSE_MAKEFILE=OFF -DBUILD_WITH_UNIT_TESTS=OFF \
118121
-DQPID_WITH_GET_CONTENT_OBJECT=ON \
119122
-DBoost_INCLUDE_DIRS=/usr/include/boost141/ \
@@ -124,7 +127,7 @@ RHEL 5.11 with QPID Proton and disabled unit tests
124127

125128
```
126129
cmake -DENABLE_QPID_PROTON=ON -DPROTON_DIR=/opt/devel/qpid-proton \
127-
-DCMAKE_CXX_COMPILER=`which c++` `
130+
-DENABLE_MODERN=ON -DCMAKE_CXX_COMPILER=`which c++` `
128131
-DCMAKE_VERBOSE_MAKEFILE=OFF -DBUILD_WITH_UNIT_TESTS=OFF `
129132
-DQPID_WITH_GET_CONTENT_OBJECT=ON `
130133
-DBoost_INCLUDE_DIRS=/usr/include/boost141/ `

dist/dtests-rhel-cpp.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ C++ clients, tools and runtime libraries
3535
%build
3636

3737
%ifarch x86_64
38-
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
38+
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=ON -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
3939
%else
40-
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=OFF -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
40+
cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_MODERN=ON -DENABLE_QPID_CLIENT=OFF -DENABLE_QPID_MESSAGING=OFF -DENABLE_QPID_PROTON=ON -DBUILD_WITH_UNIT_TESTS=ON -DCMAKE_INSTALL_PREFIX=%{buildroot}/opt/dtests
4141
%endif
4242
make
4343

src/api/qpid/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ target_link_libraries(
6565
dtests-qpid-messaging-common
6666

6767
${Qpid_LIBRARIES}
68-
${ProtonCpp_LIBRARIES}
6968
dtests-cpp-legacy
7069
boost_regex # would be `Boost::regex` in new CMake
7170
${qpid_client_link_libraries}
@@ -127,9 +126,11 @@ foreach(client ${qpid_messaging_clients})
127126
endforeach(client)
128127

129128

130-
if (BUILD_WITH_UNIT_TESTS)
131-
add_subdirectory(common/formatter/test)
132-
endif (BUILD_WITH_UNIT_TESTS)
129+
if (ENABLE_MODERN)
130+
if (BUILD_WITH_UNIT_TESTS)
131+
add_subdirectory(common/formatter/test)
132+
endif (BUILD_WITH_UNIT_TESTS)
133+
endif (ENABLE_MODERN)
133134

134135

135136
install(TARGETS

src/api/qpid/common/formatter/FormatUtil.cpp

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,30 @@ namespace messaging {
77
using std::cout;
88

99
void printMessageUpstream(const Message &message, bool verbose) {
10-
QpidDecoder decoder = QpidDecoder(message);
11-
12-
std::ostringstream stream;
13-
UpstreamWriter writer = UpstreamWriter(&stream);
14-
15-
UpstreamFormatter formatter = UpstreamFormatter();
16-
formatter.printMessage(&decoder, &writer);
17-
18-
writer.endLine();
19-
std::cout << writer.toString();
10+
#ifdef ENABLE_MODERN
11+
QpidDecoder decoder = QpidDecoder(message);
12+
13+
std::ostringstream stream;
14+
UpstreamWriter writer = UpstreamWriter(&stream);
15+
16+
UpstreamFormatter formatter = UpstreamFormatter();
17+
formatter.printMessage(&decoder, &writer);
18+
19+
writer.endLine();
20+
std::cout << writer.toString();
21+
22+
#else
23+
Formatter formatter;
24+
25+
Message tmp = const_cast<Message &>(message);
26+
27+
formatter.printMessage(tmp, verbose);
28+
#endif // ENABLE_MODERN
2029
}
2130

2231

2332
void printMessageDict(const Message &message) {
33+
#ifdef ENABLE_MODERN
2434
QpidDecoder decoder = QpidDecoder(message);
2535

2636
std::ostringstream stream;
@@ -31,6 +41,13 @@ void printMessageDict(const Message &message) {
3141

3242
writer.endLine();
3343
std::cout << writer.toString();
44+
#else
45+
Formatter formatter;
46+
47+
Message tmp = const_cast<Message &>(message);
48+
49+
formatter.printMessageAsDict(tmp);
50+
#endif // ENABLE_MODERN
3451
}
3552

3653
std::string formatBool(const bool b) {
@@ -337,6 +354,7 @@ void printMessageInterop(const Message &message) {
337354
}
338355

339356
void printStatistics(const Message &message, const Variant::Map &stats) {
357+
#ifdef ENABLE_MODERN
340358
/*
341359
* NOTE: this is *not* the best way to solve this problem and I will
342360
* implement a more elegant design in the future
@@ -348,6 +366,13 @@ void printStatistics(const Message &message, const Variant::Map &stats) {
348366

349367
DictFormatter formatter = DictFormatter();
350368
formatter.printStatistics(&decoder, &writer, stats);
369+
#else
370+
Formatter formatter;
371+
372+
Variant::Map tmp = const_cast<Variant::Map &>(stats);
373+
374+
formatter.printStatistics(tmp);
375+
#endif // ENABLE_MODERN
351376
}
352377

353378
}}}

src/api/qpid/common/formatter/FormatUtil.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121
#include <iostream>
2222
#include <iomanip>
2323

24+
#ifdef ENABLE_MODERN
2425
#include "formatter/DictFormatter.h"
2526
#include "formatter/DictWriter.h"
2627

2728
#include "formatter/UpstreamFormatter.h"
2829
#include "formatter/UpstreamWriter.h"
2930

3031
#include "QpidDecoder.h"
32+
#else
33+
#include "Formatter.h"
34+
#endif // ENABLE_MODERN
3135

3236
using qpid::messaging::Message;
3337
using qpid::types::Variant;

src/common/CMakeLists.txt

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,43 @@ include_directories(
1313
common/options/modern
1414
)
1515

16-
set(COMMON_MODERN_SRC
17-
output/Printer.cpp
18-
exceptions/BaseException.cpp
19-
exceptions/IOException.cpp
20-
exceptions/TimerExpiredException.cpp
21-
options/BaseOptionsParser.cpp
22-
options/OptionsHelper.cpp
23-
formatter/Writer.cpp
24-
formatter/DictWriter.cpp
25-
formatter/UpstreamWriter.cpp
26-
formatter/AbstractDecoder.cpp
27-
formatter/AbstractFormatter.cpp
28-
formatter/DictFormatter.cpp
29-
formatter/UpstreamFormatter.cpp
30-
logger/Logger.cpp
31-
logger/LoggerWrapper.cpp
32-
33-
Timer.cpp
34-
UriParser.cpp
35-
Client.cpp
36-
ContentType.cpp
37-
MessageHeader.cpp
38-
)
39-
40-
if (BUILD_WITH_UNIT_TESTS)
41-
set(TEST_SUPPORT_SRC
42-
TestUtils.cpp
16+
if (ENABLE_MODERN)
17+
set(COMMON_MODERN_SRC
18+
output/Printer.cpp
19+
exceptions/BaseException.cpp
20+
exceptions/IOException.cpp
21+
exceptions/TimerExpiredException.cpp
22+
options/BaseOptionsParser.cpp
23+
options/OptionsHelper.cpp
24+
formatter/Writer.cpp
25+
formatter/DictWriter.cpp
26+
formatter/UpstreamWriter.cpp
27+
formatter/AbstractDecoder.cpp
28+
formatter/AbstractFormatter.cpp
29+
formatter/DictFormatter.cpp
30+
formatter/UpstreamFormatter.cpp
31+
logger/Logger.cpp
32+
logger/LoggerWrapper.cpp
33+
34+
Timer.cpp
35+
UriParser.cpp
36+
Client.cpp
37+
ContentType.cpp
38+
MessageHeader.cpp
4339
)
4440

41+
if (BUILD_WITH_UNIT_TESTS)
42+
set(TEST_SUPPORT_SRC
43+
TestUtils.cpp
44+
)
45+
4546
add_subdirectory(test)
46-
add_subdirectory(output/test)
47-
add_subdirectory(logger/test)
48-
add_subdirectory(options/test)
49-
endif (BUILD_WITH_UNIT_TESTS)
47+
add_subdirectory(output/test)
48+
add_subdirectory(logger/test)
49+
add_subdirectory(options/test)
50+
endif (BUILD_WITH_UNIT_TESTS)
51+
52+
endif (ENABLE_MODERN)
5053

5154
add_library(dtests-cpp-common
5255
${COMMON_MODERN_SRC}

0 commit comments

Comments
 (0)