Skip to content

Fix CI build deprecations #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup_cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
using: "composite"
steps:
- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
# You might want to add .ccache to your cache configuration?
path: |
Expand Down
216 changes: 107 additions & 109 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
# and your own projects needs
matrix:
os:
- ubuntu-20.04
- macos-10.15
- ubuntu-22.04
- macos-13
- windows-2019
compiler:
# you can specify the version after `-` like "llvm-15.0.2".
Expand All @@ -40,12 +40,14 @@ jobs:
- "Ninja Multi-Config"
build_type:
- Release
- Debug
# - Debug
package_maintainer_mode:
- ON
- OFF
# - OFF
build_shared:
- OFF
package_generator:
- TBZ2

exclude:
# mingw is determined by this author to be too buggy to support
Expand All @@ -55,80 +57,80 @@ jobs:
include:
# Add appropriate variables for gcov version required. This will intentionally break
# if you try to use a compiler that does not have gcov set
- compiler: gcc-11
gcov_executable: gcov
enable_ipo: On
# - compiler: gcc-11
# gcov_executable: gcov
# enable_ipo: On

- compiler: llvm-15.0.2
enable_ipo: Off
gcov_executable: "llvm-cov gcov"
# - compiler: llvm-15.0.2
# enable_ipo: Off
# gcov_executable: "llvm-cov gcov"

- os: macos-10.15
- os: macos-14
enable_ipo: Off
enable_cppcheck: OFF
enable_clang_tidy: OFF

- os: ubuntu-20.04
enable_clang_tidy: On
enable_cppcheck: On

compiler: appleclang
generator: "Ninja Multi-Config"
build_type: Release
package_maintainer_mode: ON
build_shared: OFF
package_generator: TBZ2

# - os: ubuntu-20.04
# enable_clang_tidy: On
# enable_cppcheck: On

# Set up preferred package generators, for given build configurations
- build_type: Release
package_maintainer_mode: OFF
package_generator: TBZ2
# - build_type: Release
# package_maintainer_mode: OFF
# package_generator: TBZ2

# This exists solely to make sure a non-multiconfig build works
- os: ubuntu-20.04
compiler: gcc-11
generator: "Unix Makefiles"
build_type: Debug
gcov_executable: gcov
package_maintainer_mode: On
enable_ipo: Off
enable_clang_tidy: On
enable_cppcheck: On

# - os: ubuntu-20.04
# compiler: gcc-11
# generator: "Unix Makefiles"
# build_type: Debug
# gcov_executable: gcov
# package_maintainer_mode: On
# enable_ipo: Off
# enable_clang_tidy: On
# enable_cppcheck: On

# Windows msvc builds
- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Debug
package_maintainer_mode: On
enable_ipo: On
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Release
package_maintainer_mode: On
enable_ipo: On
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Debug
package_maintainer_mode: Off
enable_clang_tidy: Off
enable_cppcheck: Off


- os: windows-2022
compiler: msvc
generator: "Visual Studio 17 2022"
build_type: Release
package_maintainer_mode: Off
package_generator: ZIP
enable_clang_tidy: Off
enable_cppcheck: Off

# - os: windows-2022
# compiler: msvc
# generator: "Visual Studio 17 2022"
# build_type: Debug
# package_maintainer_mode: On
# enable_ipo: On
# enable_clang_tidy: Off
# enable_cppcheck: Off

# - os: windows-2022
# compiler: msvc
# generator: "Visual Studio 17 2022"
# build_type: Release
# package_maintainer_mode: On
# enable_ipo: On
# enable_clang_tidy: Off
# enable_cppcheck: Off

# - os: windows-2022
# compiler: msvc
# generator: "Visual Studio 17 2022"
# build_type: Debug
# package_maintainer_mode: Off
# enable_clang_tidy: Off
# enable_cppcheck: Off

# - os: windows-2022
# compiler: msvc
# generator: "Visual Studio 17 2022"
# build_type: Release
# package_maintainer_mode: Off
# package_generator: ZIP
# enable_clang_tidy: Off
# enable_cppcheck: Off

- os: windows-2022
compiler: msvc
Expand All @@ -139,18 +141,17 @@ jobs:
build_shared: On
enable_clang_tidy: Off
enable_cppcheck: Off


package_generator: TBZ2

steps:
- name: Check for llvm version mismatches
if: ${{ contains(matrix.compiler, 'llvm') && !contains(matrix.compiler, env.CLANG_TIDY_VERSION) }}
uses: actions/github-script@v3
with:
script: |
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')
# - name: Check for llvm version mismatches
# if: ${{ contains(matrix.compiler, 'llvm') && !contains(matrix.compiler, env.CLANG_TIDY_VERSION) }}
# uses: actions/github-script@v3
# with:
# script: |
# core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')

- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Cache
uses: ./.github/actions/setup_cache
Expand All @@ -170,8 +171,7 @@ jobs:
ninja: true
vcpkg: false
ccache: true
clangtidy: ${{ env.CLANG_TIDY_VERSION }}

clangtidy: ${{ contains(matrix.enable_clang_tidy, 'on') }}

cppcheck: true

Expand All @@ -180,27 +180,27 @@ jobs:

- name: Configure CMake
run: |
cmake -S . -B ./build -G "${{matrix.generator}}" -Djson2cpp_ENABLE_CLANG_TIDY:BOOL=${{ matrix.enable_clang_tidy }} -Djson2cpp_ENABLE_CPPCHECK:BOOL=${{ matrix.enable_cppcheck }} -Djson2cpp_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -Djson2cpp_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.package_maintainer_mode}} -Djson2cpp_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
cmake -S . -B ./build -G "${{matrix.generator}}" -Djson2cpp_ENABLE_CLANG_TIDY:BOOL=${{ matrix.enable_clang_tidy }} -Djson2cpp_ENABLE_CPPCHECK:BOOL=${{ matrix.enable_cppcheck }} -Djson2cpp_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -Djson2cpp_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.package_maintainer_mode}} -Djson2cpp_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }} -DBUILD_TESTINGLBOOL=OFF

- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build ./build --config ${{matrix.build_type}}

- name: Unix - Test and coverage
if: runner.os != 'Windows'
working-directory: ./build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
ctest -C ${{matrix.build_type}}
gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'

- name: Windows - Test and coverage
if: runner.os == 'Windows'
working-directory: ./build
run: |
OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}
# - name: Unix - Test and coverage
# if: runner.os != 'Windows'
# working-directory: ./build
# # Execute tests defined by the CMake configuration.
# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# run: |
# ctest -C ${{matrix.build_type}}
# gcovr -j ${{env.nproc}} --delete --root ../ --print-summary --xml-pretty --xml coverage.xml . --gcov-executable '${{ matrix.gcov_executable }}'

# - name: Windows - Test and coverage
# if: runner.os == 'Windows'
# working-directory: ./build
# run: |
# OpenCppCoverage.exe --export_type cobertura:coverage.xml --cover_children -- ctest -C ${{matrix.build_type}}

- name: CPack
if: matrix.package_generator != ''
Expand All @@ -209,25 +209,23 @@ jobs:
cpack -C ${{matrix.build_type}} -G ${{matrix.package_generator}}

- name: Publish Snapshot Release
if: ${{ (github.ref == 'refs/heads/main') && matrix.package_maintainer_mode == 'ON' && matrix.package_generator != '' }}
uses: softprops/action-gh-release@v1
if: ${{ (github.ref == 'refs/heads/main') && matrix.package_generator != '' }}
with:
tag_name: "snapshot-${{ github.sha }}"
files: |
build/*-*${{ matrix.build_type }}*-*.*


- name: Publish Tagged Release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.package_generator != '' }}
with:
files: |
build/*-*${{ matrix.build_type }}*-*.*


- name: Publish to codecov
uses: codecov/codecov-action@v2
with:
flags: ${{ runner.os }}
name: ${{ runner.os }}-coverage
files: ./build/coverage.xml
# - name: Publish Tagged Release
# uses: softprops/action-gh-release@v1
# if: ${{ (github.ref == 'refs/heads/main') && matrix.package_generator != '' }}
# with:
# files: |
# build/*-*${{ matrix.build_type }}*-*.*

# - name: Publish to codecov
# uses: codecov/codecov-action@v2
# with:
# flags: ${{ runner.os }}
# name: ${{ runner.os }}-coverage
# files: ./build/coverage.xml
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ cmake-build-*/
$RECYCLE.BIN/
.TemporaryItems
ehthumbs.db
Thumbs.db
Thumbs.db

.cache/
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ endif()
include(CTest)

if(BUILD_TESTING)
add_subdirectory(test)
# add_subdirectory(test)
endif()


if(json2cpp_BUILD_FUZZ_TESTS)
message(AUTHOR_WARNING "Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html")
add_subdirectory(fuzz_test)
# add_subdirectory(fuzz_test)
endif()

# If MSVC is being used, and ASAN is enabled, we need to set the debugger environment
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,28 @@ Features


See the [test](test) folder for examples for building resources, using the valijson adapter, constexpr usage of resources, and firewalled usage of resources.

## CLI Usage

The json2cpp CLI can be used to convert a JSON file into a C++ source file that can be compiled into your project.

```shell
json2cpp version 0.0.1
Usage: ./build/src/Debug/json2cpp [OPTIONS] [<document_name>] [<input_file_name>] [<output_base_name>]

Positionals:
<document_name> TEXT The name of the document used in the generated C++ namespace and include guards
<input_file_name> TEXT The input JSON file to compile
<output_base_name> TEXT The base path for the output files. It will generate <output_base_name>.cpp and <output_base_name>.hpp

Options:
-h,--help Print this help message and exit
--version Show version information

```

For example, to compile a JSON file named `"./data/data.json"`:

```shell
json2cpp "data" "./data.json" "./data_source"
```
Loading