Skip to content

Commit ae00c1b

Browse files
committed
Release v3.0.4
2 parents 4bc2b11 + 8c4e0e4 commit ae00c1b

20 files changed

Lines changed: 815 additions & 325 deletions

.github/workflows/actions_build.yml

Lines changed: 98 additions & 121 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 132 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ option (DEMO3_GEN_SWIG "Use commsdsl2swig to generate swig bindings project." OF
1414
option (DEMO3_BUILD_SWIG "Build and install project generated by the commsdsl2swig." ${DEMO3_GEN_SWIG})
1515
option (DEMO3_GEN_EMSCRIPTEN "Use commsdsl2emscripten to generate emscripten bindings project." OFF)
1616
option (DEMO3_BUILD_EMSCRIPTEN "Build and install project generated by the commsdsl2emscripten." ${DEMO3_GEN_EMSCRIPTEN})
17+
option (DEMO3_GEN_C "Use commsdsl2c to generate \"C\" wrappers project." OFF)
18+
option (DEMO3_BUILD_C "Build and install project generated by the commsdsl2c." ${DEMO3_GEN_C})
19+
option (DEMO3_GEN_LATEX "Use commsdsl2latex to generate protocol specification." OFF)
20+
option (DEMO3_BUILD_LATEX "Build and install project generated by the commsdsl2latex." ${DEMO3_GEN_C})
1721
option (DEMO3_BUILD_EXAMPLES "Build examples." ON)
1822

1923
# Additional variables to be used if needed
@@ -26,15 +30,19 @@ option (DEMO3_BUILD_EXAMPLES "Build examples." ON)
2630
# DEMO3_SWIG_SRC_DIR - Path to the commsdsl2swig sources. If not provided local "src/swig" dir is used.
2731
# DEMO3_SWIG_LANGUAGES - Languages list to support by swig. If not provided "python java csharp" are chosen
2832
# DEMO3_EMSCRIPTEN_OUTPUT_DIR - Path to emscripten output directory. If not provided <build_dir>/output_emscripten one is used.
33+
# DEMO3_C_OUTPUT_DIR - Path to "c" output directory. If not provided <build_dir>/output_c one is used.
34+
# DEMO3_LATEX_OUTPUT_DIR - Path to latex output directory. If not provided <build_dir>/output_latex one is used.
2935
# DEMO3_CCACHE_EXECUTABLE - Custom ccache executable
3036
# COMMSDSL2COMMS_EXTRA_ARGS - Extra arguments to pass to "commsdsl2comms"
3137
# COMMSDSL2TEST_EXTRA_ARGS - Extra arguments to pass to "commsdsl2test"
3238
# COMMSDSL2TOOLS_QT_EXTRA_ARGS - Extra arguments to pass to "commsdsl2tools_qt"
3339
# COMMSDSL2SWIG_EXTRA_ARGS - Extra arguments to pass to "commsdsl2swig"
3440
# COMMSDSL2EMSCRIPTEN_EXTRA_ARGS - Extra arguments to pass to "commsdsl2emscripten"
41+
# COMMSDSL2C_EXTRA_ARGS - Extra arguments to pass to "commsdsl2c"
42+
# COMMSDSL2LATEX_EXTRA_ARGS - Extra arguments to pass to "commsdsl2latex"
3543

36-
set (DEMO3_VERSION "3.0.3")
37-
set (DEMO3_MIN_COMMSDSL_VERSION "7.1")
44+
set (DEMO3_VERSION "3.0.4")
45+
set (DEMO3_MIN_COMMSDSL_VERSION "7.3")
3846

3947
if (("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.30") AND
4048
(NOT DEFINED CMAKE_POLICY_DEFAULT_CMP0167))
@@ -80,6 +88,14 @@ if ("${DEMO3_EMSCRIPTEN_OUTPUT_DIR}" STREQUAL "")
8088
set (DEMO3_EMSCRIPTEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/output_emscripten")
8189
endif ()
8290

91+
if ("${DEMO3_C_OUTPUT_DIR}" STREQUAL "")
92+
set (DEMO3_C_OUTPUT_DIR "${CMAKE_BINARY_DIR}/output_c")
93+
endif ()
94+
95+
if ("${DEMO3_LATEX_OUTPUT_DIR}" STREQUAL "")
96+
set (DEMO3_LATEX_OUTPUT_DIR "${CMAKE_BINARY_DIR}/output_latex")
97+
endif ()
98+
8399
if ("${DEMO3_TOOLS_QT_VER}" STREQUAL "")
84100
set (DEMO3_TOOLS_QT_VER 5)
85101
endif ()
@@ -162,7 +178,7 @@ if (DEMO3_GEN_TEST)
162178

163179
add_custom_target("test_output_tgt" ALL
164180
COMMAND ${CMAKE_COMMAND} -E remove_directory ${test_tmp_dir}
165-
COMMAND ${COMMSDSL2TEST} ${warn_as_error} ${COMMSDSL2TEST_EXTRA_ARGS}
181+
COMMAND ${COMMSDSL2TEST} ${warn_as_error} -V ${DEMO3_VERSION} ${COMMSDSL2TEST_EXTRA_ARGS}
166182
-o ${test_tmp_dir} -c ${PROJECT_SOURCE_DIR}/src/test ${schema_file}
167183
COMMAND ${CMAKE_COMMAND}
168184
-DGENERATED="${test_tmp_dir}" -DOUTPUT="${DEMO3_TEST_OUTPUT_DIR}"
@@ -214,7 +230,7 @@ if (DEMO3_GEN_TOOLS)
214230

215231
add_custom_target("tools_output_tgt" ALL
216232
COMMAND ${CMAKE_COMMAND} -E remove_directory ${tools_tmp_dir}
217-
COMMAND ${COMMSDSL2TOOLS_QT} ${warn_as_error} ${COMMSDSL2TOOLS_QT_EXTRA_ARGS}
233+
COMMAND ${COMMSDSL2TOOLS_QT} ${warn_as_error} -V ${DEMO3_VERSION} ${COMMSDSL2TOOLS_QT_EXTRA_ARGS}
218234
--protocol "::CC Demo3:Synthenic demo protocol to demonstrate protocol versioning where the version is reported in the first Connect message.:cc.Demo3ProtocolPlugin"
219235
-o ${tools_tmp_dir} -c ${PROJECT_SOURCE_DIR}/src/tools ${schema_file}
220236
COMMAND ${CMAKE_COMMAND}
@@ -267,8 +283,8 @@ if (DEMO3_GEN_SWIG)
267283

268284
add_custom_target("swig_output_tgt" ALL
269285
COMMAND ${CMAKE_COMMAND} -E remove_directory ${swig_tmp_dir}
270-
COMMAND ${COMMSDSL2SWIG} ${warn_as_error} ${COMMSDSL2SWIG_EXTRA_ARGS}
271-
-c ${DEMO3_SWIG_SRC_DIR} -o ${swig_tmp_dir} ${schema_file}
286+
COMMAND ${COMMSDSL2SWIG} ${warn_as_error} -V ${DEMO3_VERSION} ${COMMSDSL2SWIG_EXTRA_ARGS}
287+
-c ${DEMO3_SWIG_SRC_DIR} -o ${swig_tmp_dir} ${schema_file}
272288
COMMAND ${CMAKE_COMMAND}
273289
-DGENERATED="${swig_tmp_dir}" -DOUTPUT="${DEMO3_SWIG_OUTPUT_DIR}"
274290
-P "${CMAKE_CURRENT_LIST_DIR}/CopyGenerated.cmake"
@@ -325,7 +341,7 @@ if (DEMO3_GEN_EMSCRIPTEN)
325341

326342
add_custom_target("emscripten_output_tgt" ALL
327343
COMMAND ${CMAKE_COMMAND} -E remove_directory ${emscripten_tmp_dir}
328-
COMMAND ${COMMSDSL2EMSCRIPTEN} ${warn_as_error} ${COMMSDSL2EMSCRIPTEN_EXTRA_ARGS}
344+
COMMAND ${COMMSDSL2EMSCRIPTEN} ${warn_as_error} -V ${DEMO3_VERSION} ${COMMSDSL2EMSCRIPTEN_EXTRA_ARGS}
329345
-o ${emscripten_tmp_dir} -c ${PROJECT_SOURCE_DIR}/src/emscripten ${schema_file}
330346
COMMAND ${CMAKE_COMMAND}
331347
-DGENERATED="${emscripten_tmp_dir}" -DOUTPUT="${DEMO3_EMSCRIPTEN_OUTPUT_DIR}"
@@ -373,6 +389,115 @@ if (DEMO3_GEN_EMSCRIPTEN)
373389
endif ()
374390
endif ()
375391

392+
if (DEMO3_GEN_C)
393+
find_program(COMMSDSL2C commsdsl2c PATH_SUFFIXES bin REQUIRED)
394+
execute_process(COMMAND "${COMMSDSL2C}" --version OUTPUT_VARIABLE commsdsl2c_version)
395+
if ("${commsdsl2c_version}" VERSION_LESS "${DEMO3_MIN_COMMSDSL_VERSION}")
396+
message (FATAL_ERROR "Version of commsdsl2c is too old, required minimum is v${DEMO3_MIN_COMMSDSL_VERSION}.")
397+
endif ()
398+
399+
set (c_tmp_dir "${CMAKE_BINARY_DIR}/output_c.tmp")
400+
401+
add_custom_target("c_output_tgt" ALL
402+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${c_tmp_dir}
403+
COMMAND ${COMMSDSL2C} ${warn_as_error} -V ${DEMO3_VERSION} ${COMMSDSL2C_EXTRA_ARGS}
404+
-o ${c_tmp_dir} -c ${PROJECT_SOURCE_DIR}/src/c ${schema_file}
405+
COMMAND ${CMAKE_COMMAND}
406+
-DGENERATED="${c_tmp_dir}" -DOUTPUT="${DEMO3_C_OUTPUT_DIR}"
407+
-P "${CMAKE_CURRENT_LIST_DIR}/CopyGenerated.cmake"
408+
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/CopyGenerated.cmake" ${schema_file})
409+
410+
if (DEMO3_BUILD_C)
411+
if ((NOT DEMO3_GEN_PROTOCOL) OR (NOT DEMO3_BUILD_PROTOCOL))
412+
message (FATAL_ERROR "DEMO3_GEN_PROTOCOL and DEMO3_BUILD_PROTOCOL are required for DEMO3_BUILD_C")
413+
endif ()
414+
415+
execute_process(
416+
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO3_C_OUTPUT_DIR}
417+
)
418+
419+
execute_process(
420+
COMMAND ${CMAKE_COMMAND} -E touch ${DEMO3_C_OUTPUT_DIR}/dummy.txt
421+
)
422+
423+
set (c_build_dir ${CMAKE_CURRENT_BINARY_DIR}/c_tgt_build)
424+
ExternalProject_Add(
425+
"c_tgt"
426+
BUILD_ALWAYS TRUE
427+
DEPENDS "prot_tgt" "c_output_tgt"
428+
SOURCE_DIR ${DEMO3_C_OUTPUT_DIR}
429+
BINARY_DIR ${c_build_dir}
430+
LIST_SEPARATOR |
431+
CMAKE_ARGS
432+
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
433+
-DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
434+
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
435+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
436+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
437+
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
438+
-DOPT_USE_CCACHE=${DEMO3_USE_CCACHE}
439+
-DOPT_CCACHE_EXECUTABLE=${DEMO3_CCACHE_EXECUTABLE}
440+
)
441+
442+
find_package(Doxygen)
443+
if (DEMO3_BUILD_PROT_DOC AND DOXYGEN_FOUND)
444+
ExternalProject_Add_Step(
445+
"c_tgt"
446+
"doc"
447+
COMMAND ${CMAKE_COMMAND} --build ${c_build_dir} --target doc_cc_demo3_c
448+
DEPENDEES "build"
449+
DEPENDERS "install"
450+
)
451+
endif ()
452+
endif ()
453+
endif ()
454+
455+
if (DEMO3_GEN_LATEX)
456+
find_program(COMMSDSL2LATEX commsdsl2latex PATH_SUFFIXES bin REQUIRED)
457+
execute_process(COMMAND "${COMMSDSL2LATEX}" --version OUTPUT_VARIABLE commsdsl2latex_version)
458+
if ("${commsdsl2latex_version}" VERSION_LESS "${DEMO3_MIN_COMMSDSL_VERSION}")
459+
message (FATAL_ERROR "Version of commsdsl2latex is too old, required minimum is v${DEMO3_MIN_COMMSDSL_VERSION}.")
460+
endif ()
461+
462+
set (latex_tmp_dir "${CMAKE_BINARY_DIR}/output_latex.tmp")
463+
464+
add_custom_target("latext_output_tgt" ALL
465+
COMMAND ${CMAKE_COMMAND} -E remove_directory ${latex_tmp_dir}
466+
COMMAND ${COMMSDSL2LATEX} ${warn_as_error} ${COMMSDSL2LATEX_EXTRA_ARGS}
467+
-o ${latex_tmp_dir} -c ${PROJECT_SOURCE_DIR}/src/latex ${schema_file}
468+
COMMAND ${CMAKE_COMMAND}
469+
-DGENERATED="${latex_tmp_dir}" -DOUTPUT="${DEMO3_LATEX_OUTPUT_DIR}"
470+
-P "${CMAKE_CURRENT_LIST_DIR}/CopyGenerated.cmake"
471+
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/CopyGenerated.cmake" ${schema_file})
472+
473+
if (DEMO3_BUILD_LATEX)
474+
execute_process(
475+
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEMO3_LATEX_OUTPUT_DIR}
476+
)
477+
478+
execute_process(
479+
COMMAND ${CMAKE_COMMAND} -E touch ${DEMO3_LATEX_OUTPUT_DIR}/dummy.txt
480+
)
481+
482+
set (latex_build_dir ${CMAKE_CURRENT_BINARY_DIR}/latex_tgt_build)
483+
ExternalProject_Add(
484+
"latex_tgt"
485+
BUILD_ALWAYS TRUE
486+
DEPENDS "latext_output_tgt"
487+
SOURCE_DIR ${DEMO3_LATEX_OUTPUT_DIR}
488+
BINARY_DIR ${latex_build_dir}
489+
LIST_SEPARATOR |
490+
CMAKE_ARGS
491+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
492+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
493+
BUILD_COMMAND
494+
${CMAKE_COMMAND} --build ${latex_build_dir} --config ${CMAKE_BUILD_TYPE} --target all_artifacts
495+
INSTALL_COMMAND
496+
${CMAKE_COMMAND} -E echo "No install for documentation build"
497+
)
498+
endif ()
499+
endif ()
500+
376501
if (NOT DEMO3_BUILD_EXAMPLES)
377502
return()
378503
endif()

dsl/schema.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<interface name="Message">
1111
<int name="Version" type="uint8" semanticType="version" />
1212
</interface>
13-
13+
1414
<frame name="Frame">
1515
<sync name="Sync">
1616
<int name="Sync" type="uint16" defaultValidValue="0xabcd" failOnInvalid="true"/>
@@ -26,12 +26,12 @@
2626
<checksum name="Checksum" alg="crc-ccitt" from="Size">
2727
<int name="Checksum" type="uint16" />
2828
</checksum>
29-
</frame>
29+
</frame>
3030

3131
<message name="Connect" id="MsgId.Connect" sender="client">
3232
<int name="Version" type="uint8" semanticType="version"/>
3333
</message>
34-
34+
3535
<message name="Msg1" id="MsgId.Msg1" sender="client">
3636
<int name="F1" type="uint8" defaultValue="1" />
3737
<int name="F2" type="uint8" defaultValue="2" deprecated="2" removed="true" />

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (DEMO3_USE_CCACHE)
3333

3434
if (NOT "${DEMO3_CCACHE_EXECUTABLE}" STREQUAL "")
3535
list (APPEND extra_opts CCACHE_EXECTUABLE "${DEMO3_CCACHE_EXECUTABLE}")
36-
endif ()
36+
endif ()
3737
endif()
3838

3939
cc_compile(${extra_opts})

examples/client/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ if (WIN32)
2121
${name} Setupapi.lib Ws2_32.lib imm32.lib winmm.lib)
2222
endif ()
2323

24-
2524
add_dependencies(${name} ${PROT_OUTPUT_TGT})
2625

2726
install(TARGETS ${name}

examples/client/Client.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ void printVersionDependentField(const TField& f)
3434
std::cout << static_cast<unsigned>(f.field().value());
3535
}
3636
std::cout << '\n';
37-
}
37+
}
3838

39-
} // namespace
39+
} // namespace
4040

4141
Client::Client(
42-
common::boost_wrap::io& io,
42+
common::boost_wrap::io& io,
4343
const std::string& server,
44-
std::uint16_t port)
44+
std::uint16_t port)
4545
: m_io(io),
4646
m_socket(io),
4747
m_server(server),
@@ -59,20 +59,20 @@ bool Client::start()
5959
auto resolveResult = resolver.resolve(m_server, std::to_string(m_port), ec);
6060
if (ec) {
6161
std::cerr << "ERROR: Failed to resolve \"" << m_server << ':' << m_port << "\" " <<
62-
"with error: " << ec.message() << std::endl;
62+
"with error: " << ec.message() << std::endl;
6363
return false;
6464
}
6565

6666
if (resolveResult.empty()) {
67-
std::cerr << "ERROR: No resolution result" << std::endl;
68-
return false;
69-
}
67+
std::cerr << "ERROR: No resolution result" << std::endl;
68+
return false;
69+
}
7070

7171
auto endpoint = resolveResult.begin()->endpoint();
7272
m_socket.connect(endpoint, ec);
7373
if (ec) {
7474
std::cerr << "ERROR: Failed to connect to \"" << endpoint << "\" " <<
75-
"with error: " << ec.message() << std::endl;
75+
"with error: " << ec.message() << std::endl;
7676
return false;
7777
}
7878

@@ -109,7 +109,7 @@ void Client::readDataFromServer()
109109

110110
m_inputBuf.insert(m_inputBuf.end(), m_readBuf.begin(), m_readBuf.begin() + bytesCount);
111111
processInput();
112-
readDataFromServer();
112+
readDataFromServer();
113113
});
114114
}
115115

@@ -119,7 +119,7 @@ void Client::readDataFromStdin()
119119
m_sentVersion = std::numeric_limits<decltype(m_sentVersion)>::max();
120120

121121
do {
122-
// Unfortunatelly Windows doesn't provide an easy way to
122+
// Unfortunatelly Windows doesn't provide an easy way to
123123
// asynchronously read from stdin with boost::asio,
124124
// read synchronously. DON'T COPY-PASTE TO PRODUCTION CODE!!!
125125
std::cin >> m_sentVersion;

examples/client/Client.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace cc_demo3
2424
{
2525

26-
namespace client
26+
namespace client
2727
{
2828

2929
class Client
@@ -33,7 +33,7 @@ class Client
3333

3434
bool start();
3535

36-
using InputMsg =
36+
using InputMsg =
3737
cc_demo3::Message<
3838
comms::option::ReadIterator<const std::uint8_t*>,
3939
comms::option::Handler<Client>,
@@ -45,7 +45,7 @@ class Client
4545
private:
4646
using Socket = boost::asio::ip::tcp::socket;
4747

48-
using OutputMsg =
48+
using OutputMsg =
4949
cc_demo3::Message<
5050
comms::option::WriteIterator<std::back_insert_iterator<std::vector<std::uint8_t> > >,
5151
comms::option::LengthInfoInterface,
@@ -57,7 +57,6 @@ class Client
5757

5858
using Frame = cc_demo3::frame::Frame<InputMsg, AllInputMessages>;
5959

60-
6160
void readDataFromServer();
6261
void readDataFromStdin();
6362
void sendConnect();

examples/client/ProgramOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace cc_demo3
1515
{
1616

1717
namespace client
18-
{
18+
{
1919

2020
namespace
2121
{

examples/common/include/common/boost_wrap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ void post(io& i, TFunc&& func)
5050

5151
} // namespace boost_wrap
5252

53-
5453
} // namespace common
5554

56-
5755
} // namespace cc_demo3

examples/server/ProgramOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace cc_demo3
1515
{
1616

1717
namespace server
18-
{
18+
{
1919

2020
namespace
2121
{

0 commit comments

Comments
 (0)