Skip to content

Commit

Permalink
Cpp windows ci (#211)
Browse files Browse the repository at this point in the history
* chore: using cmade/cmate

* chore: using new cmate tool

* chore: fix CI push path for cpp

* chore: fix CI push path for cpp
  • Loading branch information
chybz committed Jan 4, 2024
1 parent 230e028 commit 5140563
Show file tree
Hide file tree
Showing 69 changed files with 1,732 additions and 298 deletions.
32 changes: 16 additions & 16 deletions .github/workflows/test-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@ on:
- main
- renovate/**
paths:
- cpp/**
- cpp*
- testdata/**
- gherkin-languages.json
pull_request:
branches:
- main
paths:
- cpp/**
- cpp*
- testdata/**
- gherkin-languages.json
workflow_call:

jobs:
test-cpp:
runs-on: ubuntu-latest

strategy:
matrix:
os:
#- ubuntu-20.04
#- ubuntu-22.04
#- windows-2019
- windows-2022
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: install cmake and libraries
- name: install dependencies
working-directory: cpp
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
cmake -P cmake/cmate update
- name: configure and build
env:
NPROCS: 1
run: |
make acceptance
working-directory: cpp
run: |
cmake -P cmake/cmate configure
cmake -P cmake/cmate build
2 changes: 2 additions & 0 deletions cpp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ ext/
build/
acceptance/
stage/
.cenv/
.cmate/
.built
.configured
.deps-installed
26 changes: 13 additions & 13 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)

project(gherkin-cpp VERSION 1.0.0 LANGUAGES C CXX)
project(cucumber_gherkin VERSION 0.1.0 LANGUAGES C CXX)

include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(nlohmann_json CONFIG REQUIRED)
find_package(cucumber-messages CONFIG REQUIRED)
find_package(cucumber_messages CONFIG REQUIRED)

add_subdirectory(src/lib/gherkin)
add_subdirectory(src/bin/gherkin)
add_subdirectory(src/bin/gherkin-generate-tokens)

install(
TARGETS
gherkin-cpp
gherkin-bin
gherkin-generate-tokens-bin
EXPORT gherkin-cpp-config
cucumber_gherkin_lib
cucumber_gherkin_bin
cucumber_gherkin_generate_tokens_bin
EXPORT cucumber_gherkin-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}/gherkin
EXPORT cucumber_gherkin-config
FILE cucumber_gherkin-config.cmake
NAMESPACE cucumber::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cucumber_gherkin
)

install(
EXPORT gherkin-cpp-config
FILE gherkin-cpp-config.cmake
NAMESPACE gherkin-cpp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/gherkin-cpp
DIRECTORY "${PROJECT_SOURCE_DIR}/include/gherkin/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cucumber
)
28 changes: 11 additions & 17 deletions cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
SHELL := /usr/bin/env bash

SUB_DIR = gherkin/cucumber/gherkin

GRAMMAR_GENERATED = \
include/gherkin/rule_type.hpp \
include/gherkin/parser.hpp
include/$(SUB_DIR)/rule_type.hpp \
include/$(SUB_DIR)/parser.hpp
LANGUAGE_GENERATED = \
src/lib/gherkin/dialect.cpp
src/lib/$(SUB_DIR)/dialect.cpp
ALL_GENERATED := $(GRAMMAR_GENERATED) $(LANGUAGE_GENERATED)
ALL_SOURCE_FILES = $(shell find include src -name "*.[ch]*")
SOURCE_FILES := $(filter-out $(ALL_GENERATED),$(ALL_SOURCE_FILES))
Expand Down Expand Up @@ -53,32 +55,24 @@ clean: clean-deps ## Remove all build artifacts and files generated by the accep
acceptance: .built $(TOKENS) $(ASTS) $(PICKLES) $(ERRORS) $(SOURCES) ## Build acceptance test dir and compare results with reference

.built: .configured $(SOURCE_FILES)
cmake --build build/gherkin --parallel $(NPROCS)
cmake --install build/gherkin
./cmake/cmate build
touch $@

.configured: .deps-installed
rm -rf build/gherkin && mkdir -p build/gherkin
cmake \
-G Ninja \
-DCMAKE_PREFIX_PATH=$(CMAKE_BUILDROOT) \
-DCMAKE_INSTALL_PREFIX=$(HERE)/stage \
-S . \
-B build/gherkin \
--toolchain cmake/toolchains/ext.cmake
./cmake/cmate configure
touch $@

define berp-generate-parser =
berp -g ../gherkin.berp -t $< -o $@ --noBOM
endef

include/gherkin/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp
include/$(SUB_DIR)/rule_type.hpp: gherkin-cpp-rule-type.razor ../gherkin.berp
$(berp-generate-parser)

include/gherkin/parser.hpp: gherkin-cpp-parser.razor ../gherkin.berp
include/$(SUB_DIR)/parser.hpp: gherkin-cpp-parser.razor ../gherkin.berp
$(berp-generate-parser)

src/lib/gherkin/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq
src/lib/$(SUB_DIR)/dialect.cpp: ../gherkin-languages.json dialect.cpp.jq
jq -f dialect.cpp.jq -r -c < $< > $@

acceptance/testdata/%.tokens: ../testdata/% ../testdata/%.tokens
Expand Down Expand Up @@ -113,7 +107,7 @@ install-deps: .deps-installed
.PHONY: install-deps

.deps-installed:
./scripts/build-externals deps.txt
./cmake/cmade install
touch $@

clean-deps:
Expand Down
Loading

0 comments on commit 5140563

Please sign in to comment.