-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: initial cpp structure and implementation * chore: compile ok * chore: cleaned library name, install interface * chore: add message files * chore: missing include * chore: missing include * chore: de-virtualized messages, cleaned CMakeLists * chore: fixed enum * chore: removed inheritance * chore: added nlohmann json library * chore: json serialization * chore: json serialization * chore: missing source file * chore: serialization fixes * chore: made non required properties optional * chore: added convenience global header * chore: removed CMake 3.23+ dependency * fix: installed include directories * chore: fixing json serialization for enums * chore: externalized nlohmann::json dependency, lowered C++ standard to 17 * chore: initial license and Dockerfile * chore: with-dependencies stage build ok * chore: added basic README * chore: added cpp to bake targets * chore: adding C++ workflow * chore: added cpp to languages --------- Co-authored-by: Remy Chibois <[email protected]> Co-authored-by: Remy Chibois <[email protected]>
- Loading branch information
1 parent
c48958b
commit 17f4fc4
Showing
146 changed files
with
6,473 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: test-cpp | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- renovate/** | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_call: | ||
|
||
jobs: | ||
test-cpp: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: install cmake and libraries | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install ninja-build cmake | ||
sudo apt-get install nlohmann-json3-dev | ||
ninja --version | ||
cmake --version | ||
gcc --version | ||
- name: configure and build | ||
run: | | ||
cmake -S . -B build | ||
cmake --build build | ||
working-directory: cpp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.configured | ||
.built | ||
build/ | ||
ext/ | ||
stage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR) | ||
|
||
project(cucumber-messages VERSION 1.0.0 LANGUAGES CXX) | ||
|
||
include(GNUInstallDirs) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
find_package(nlohmann_json CONFIG REQUIRED) | ||
|
||
add_subdirectory(src) | ||
|
||
install( | ||
TARGETS | ||
cucumber-messages | ||
EXPORT cucumber-messages-config | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
|
||
install( | ||
DIRECTORY "${CMAKE_SOURCE_DIR}/include/" | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cucumber | ||
) | ||
|
||
install( | ||
EXPORT cucumber-messages-config | ||
FILE cucumber-messages-config.cmake | ||
NAMESPACE cucumber:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cucumber-messages | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#syntax=docker/dockerfile:1.4 | ||
|
||
# Base image | ||
FROM debian:bullseye-slim AS cpp | ||
|
||
RUN <<EOF | ||
# Install/update tools. Don't forget to clean cache | ||
apt-get update | ||
apt-get install -y \ | ||
bash \ | ||
curl \ | ||
unzip \ | ||
build-essential \ | ||
cmake | ||
rm -rf /var/lib/apt/lists/* | ||
EOF | ||
|
||
|
||
WORKDIR /cucumber | ||
|
||
# Dummy stage for generated code, overriden in main build | ||
FROM scratch AS schema-codegen | ||
|
||
FROM cpp AS with-dependencies | ||
|
||
COPY --link cmake cmake | ||
COPY --link scripts scripts | ||
COPY --link Makefile deps.txt . | ||
|
||
# verify loads additional dependencies without running the tests (they aren't copied in yet) | ||
RUN make install-deps | ||
|
||
FROM cpp AS tested | ||
|
||
COPY --link . . | ||
COPY --link --from=with-dependencies build/root build/root | ||
#COPY --link --from=schema-codegen / src/generated/java/io/cucumber/messages/types | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Cucumber Ltd | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
schemas = $(shell find ../jsonschema -name "*.json") | ||
|
||
.DEFAULT_GOAL = help | ||
|
||
INC_DIR = include/cucumber/messages | ||
LIB_DIR = src/lib/cucumber-messages/cucumber/messages | ||
|
||
SOURCES = \ | ||
$(shell find $(INC_DIR) -name "*.[ch]pp") \ | ||
$(shell find $(LIB_DIR) -name "*.[ch]pp") | ||
|
||
HERE = $(shell pwd) | ||
CMAKE_BUILDROOT = $(HERE)/build/root | ||
CMAKELISTS = $(shell find . -name CMakeLists.txt) | ||
|
||
help: ## Show this help | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make <target>\n\nWhere <target> is one of:\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
generate: require .generate-messages ## Generate C++ code based on the schemas found in ../jsonschema and using the scripts in ../jsonschema/scripts for the generation | ||
|
||
require: ## Check requirements for the code generation (ruby, csplit and tail are required) | ||
@ruby --version >/dev/null 2>&1 || (echo "ERROR: ruby is required."; exit 1) | ||
@csplit --version >/dev/null 2>&1 || (echo "ERROR: csplit is required."; exit 1) | ||
@tail --version >/dev/null 2>&1 || (echo "ERROR: tail is required."; exit 1) | ||
|
||
clean: ## Remove automatically generated files and related artifacts | ||
rm -rf build .configured | ||
|
||
.generate-messages: $(schemas) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/cpp.hpp.erb ../jsonschema/scripts/templates/cpp.enum.hpp.erb | ||
ruby ../jsonschema/scripts/codegen.rb Cpp ../jsonschema cpp.hpp.erb > Generated.hpp.tmp | ||
ruby ../jsonschema/scripts/codegen.rb Cpp ../jsonschema cpp.enum.hpp.erb >> Generated.hpp.tmp | ||
csplit --quiet --prefix=Generated --suffix-format=%02d.hpp.tmp --elide-empty-files Generated.hpp.tmp /^[A-Za-z_.]*[.][ch]pp/ {*} | ||
rm Generated.hpp.tmp | ||
|
||
for file in Generated**; do \ | ||
F=$$(head -n 1 $$file | tr -d '\r\n'); \ | ||
if [ -n "$$F" ]; then \ | ||
tail -n +2 $$file > $(INC_DIR)/$$F; \ | ||
fi; \ | ||
rm $$file; \ | ||
done | ||
|
||
mv $(INC_DIR)/*.cpp $(LIB_DIR)/ || true | ||
|
||
clean-build: | ||
rm -rf build .configured .built | ||
|
||
clean-deps: | ||
rm -rf ext build/src build/root | ||
|
||
install-deps: | ||
./scripts/build-externals deps.txt | ||
|
||
.configured: $(CMAKELISTS) | ||
mkdir -p build | ||
cmake \ | ||
-DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \ | ||
-DCMAKE_INSTALL_PREFIX=$(HERE)/stage \ | ||
-S . \ | ||
-B build \ | ||
--toolchain cmake/toolchains/ext.cmake \ | ||
&& touch $@ | ||
|
||
clean-configure: | ||
rm -f .configured | ||
|
||
reconfigure: clean-configure .configured | ||
|
||
rebuild: reconfigure .built | ||
|
||
.built: .configured $(SOURCES) | ||
cmake --build build --parallel && touch $@ | ||
cmake --install build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Cucumber Messages for C++ (JSON schema) | ||
|
||
## Requirements | ||
|
||
This library requires: | ||
- A C++ 17 compiler (tested with GCC 10, 12) | ||
- [JSON for Modern C++](https://json.nlohmann.me/) | ||
|
||
## Installing from Git repository | ||
|
||
```shell | ||
$ git clone https://github.com/cucumber/messages | ||
$ cd messages/cpp | ||
$ cmake -S . -B build | ||
$ cmake --build build | ||
$ cmake --install build | ||
``` | ||
|
||
## CMake integration | ||
|
||
```cmake | ||
find_package(cucumber-messages CONFIG REQUIRED) | ||
target_link_libraries(mylib PRIVATE cucumber::cucumber-messages) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# CMake toolchain to be used when building external libraries | ||
# | ||
|
||
# use, i.e. don't skip the full RPATH for the build tree | ||
set(CMAKE_SKIP_BUILD_RPATH FALSE) | ||
|
||
find_program(CCACHE ccache) | ||
|
||
if(CCACHE) | ||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}") | ||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}") | ||
endif() | ||
|
||
if(DEFINED ENV{GHERKIN_DEBUG}) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fsanitize=address") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fsanitize=address") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://github.com/nlohmann/json/archive/refs/tags/v3.11.2.zip -DJSON_BuildTests=OFF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <cucumber/messages/attachment.hpp> | ||
#include <cucumber/messages/duration.hpp> | ||
#include <cucumber/messages/envelope.hpp> | ||
#include <cucumber/messages/exception.hpp> | ||
#include <cucumber/messages/gherkin_document.hpp> | ||
#include <cucumber/messages/background.hpp> | ||
#include <cucumber/messages/comment.hpp> | ||
#include <cucumber/messages/data_table.hpp> | ||
#include <cucumber/messages/doc_string.hpp> | ||
#include <cucumber/messages/examples.hpp> | ||
#include <cucumber/messages/feature.hpp> | ||
#include <cucumber/messages/feature_child.hpp> | ||
#include <cucumber/messages/rule.hpp> | ||
#include <cucumber/messages/rule_child.hpp> | ||
#include <cucumber/messages/scenario.hpp> | ||
#include <cucumber/messages/step.hpp> | ||
#include <cucumber/messages/table_cell.hpp> | ||
#include <cucumber/messages/table_row.hpp> | ||
#include <cucumber/messages/tag.hpp> | ||
#include <cucumber/messages/hook.hpp> | ||
#include <cucumber/messages/location.hpp> | ||
#include <cucumber/messages/meta.hpp> | ||
#include <cucumber/messages/ci.hpp> | ||
#include <cucumber/messages/git.hpp> | ||
#include <cucumber/messages/product.hpp> | ||
#include <cucumber/messages/parameter_type.hpp> | ||
#include <cucumber/messages/parse_error.hpp> | ||
#include <cucumber/messages/pickle.hpp> | ||
#include <cucumber/messages/pickle_doc_string.hpp> | ||
#include <cucumber/messages/pickle_step.hpp> | ||
#include <cucumber/messages/pickle_step_argument.hpp> | ||
#include <cucumber/messages/pickle_table.hpp> | ||
#include <cucumber/messages/pickle_table_cell.hpp> | ||
#include <cucumber/messages/pickle_table_row.hpp> | ||
#include <cucumber/messages/pickle_tag.hpp> | ||
#include <cucumber/messages/source.hpp> | ||
#include <cucumber/messages/source_reference.hpp> | ||
#include <cucumber/messages/java_method.hpp> | ||
#include <cucumber/messages/java_stack_trace_element.hpp> | ||
#include <cucumber/messages/step_definition.hpp> | ||
#include <cucumber/messages/step_definition_pattern.hpp> | ||
#include <cucumber/messages/test_case.hpp> | ||
#include <cucumber/messages/group.hpp> | ||
#include <cucumber/messages/step_match_argument.hpp> | ||
#include <cucumber/messages/step_match_arguments_list.hpp> | ||
#include <cucumber/messages/test_step.hpp> | ||
#include <cucumber/messages/test_case_finished.hpp> | ||
#include <cucumber/messages/test_case_started.hpp> | ||
#include <cucumber/messages/test_run_finished.hpp> | ||
#include <cucumber/messages/test_run_started.hpp> | ||
#include <cucumber/messages/test_step_finished.hpp> | ||
#include <cucumber/messages/test_step_result.hpp> | ||
#include <cucumber/messages/test_step_started.hpp> | ||
#include <cucumber/messages/timestamp.hpp> | ||
#include <cucumber/messages/undefined_parameter_type.hpp> | ||
|
Oops, something went wrong.