From 30e69332799eda1f6067b60990938ac13a21a73e Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Mon, 6 Nov 2023 08:48:29 -0600 Subject: [PATCH 01/14] Fix yaml-cpp-config.cmake.in --- yaml-cpp-config.cmake.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yaml-cpp-config.cmake.in b/yaml-cpp-config.cmake.in index f71e13b..7f16f79 100644 --- a/yaml-cpp-config.cmake.in +++ b/yaml-cpp-config.cmake.in @@ -19,8 +19,11 @@ include("${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-targets.cmake") # These are IMPORTED targets created by yaml-cpp-targets.cmake set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@") -add_library(yaml-cpp INTERFACE IMPORTED) -target_link_libraries(yaml-cpp INTERFACE yaml-cpp::yaml-cpp) +if(NOT TARGET yaml-cpp) + add_library(yaml-cpp INTERFACE IMPORTED) + target_link_libraries(yaml-cpp INTERFACE yaml-cpp::yaml-cpp) +endif() + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) set_target_properties(yaml-cpp PROPERTIES DEPRECATION "The target yaml-cpp is deprecated and will be removed in version 0.10.0. Use the yaml-cpp::yaml-cpp target instead." From 51adc5f7392648622c80909f65bf794fc48d013f Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Mon, 6 Nov 2023 10:17:50 -0600 Subject: [PATCH 02/14] Update yaml-cpp-config.cmake.in --- yaml-cpp-config.cmake.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yaml-cpp-config.cmake.in b/yaml-cpp-config.cmake.in index 7f16f79..260ae00 100644 --- a/yaml-cpp-config.cmake.in +++ b/yaml-cpp-config.cmake.in @@ -19,15 +19,15 @@ include("${CMAKE_CURRENT_LIST_DIR}/yaml-cpp-targets.cmake") # These are IMPORTED targets created by yaml-cpp-targets.cmake set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@") +# Protect against multiple inclusion, which would fail when already imported targets are added once more. if(NOT TARGET yaml-cpp) add_library(yaml-cpp INTERFACE IMPORTED) target_link_libraries(yaml-cpp INTERFACE yaml-cpp::yaml-cpp) -endif() - -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) - set_target_properties(yaml-cpp PROPERTIES - DEPRECATION "The target yaml-cpp is deprecated and will be removed in version 0.10.0. Use the yaml-cpp::yaml-cpp target instead." - ) + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) + set_target_properties(yaml-cpp PROPERTIES + DEPRECATION "The target yaml-cpp is deprecated and will be removed in version 0.10.0. Use the yaml-cpp::yaml-cpp target instead." + ) + endif() endif() check_required_components(yaml-cpp) From 1c5a38eef3fafea9f796b04d16d1c27874f70a02 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 26 Nov 2023 18:30:38 +0100 Subject: [PATCH 03/14] workflows/build.yml: Use debug std C++ library on Ubuntu Protect from regressions due to use of undefined or implementation-specific behavior when using `std::` containers and smart pointers. This only has effect on platforms with the GNU standard C++ library. Refer to https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html. --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f681eb1..a939320 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,6 +37,7 @@ jobs: ${{format(matrix.generator != 'Default Generator' && '-G "{0}"' || '', matrix.generator)}} CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/install-prefix" CMAKE_BUILD_TYPE: Debug + CMAKE_CXX_FLAGS_DEBUG: ${{ matrix.googletest == 'build' && '-g -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC' || '-g' }} runs-on: ${{ matrix.os }} steps: @@ -57,6 +58,7 @@ jobs: -D CMAKE_CXX_STANDARD=${{ matrix.cxx_standard }} \ -D CMAKE_INSTALL_PREFIX="${{ env.CMAKE_INSTALL_PREFIX }}" \ -D CMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }} \ + -D CMAKE_CXX_FLAGS_DEBUG="${{ env.CMAKE_CXX_FLAGS_DEBUG }}" \ -D YAML_BUILD_SHARED_LIBS=${{ env.YAML_BUILD_SHARED_LIBS }} \ -D YAML_USE_SYSTEM_GTEST=${{ env.YAML_USE_SYSTEM_GTEST }} \ -D YAML_CPP_BUILD_TESTS=ON From eaf72053724814be3b99d38e292fca5797a57b7b Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Mon, 27 Nov 2023 18:57:10 +0100 Subject: [PATCH 04/14] README.md: Describe building with debug libstdc++ mode --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 70c2314..e860706 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,17 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] .. * `yaml-cpp` builds a static library by default, you may want to build a shared library by specifying `-DYAML_BUILD_SHARED_LIBS=ON`. + * [Debug mode of the GNU standard C++ + library](https://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html) + can be used when both `yaml-cpp` and client code is compiled with the + `_GLIBCXX_DEBUG` flag (e.g. by calling CMake with `-D + CMAKE_CXX_FLAGS_DEBUG='-g -D_GLIBCXX_DEBUG'` option). + + Note that for `yaml-cpp` unit tests to run successfully, the _GoogleTest_ + library also must be built with this flag, i.e. the system one cannot be + used (the _YAML_USE_SYSTEM_GTEST_ CMake option must be _OFF_, which is the + default). + * For more options on customizing the build, see the [CMakeLists.txt](https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt) file. #### 2. Build it! From f30582fb09c4203872fc28443541ae3c5c540057 Mon Sep 17 00:00:00 2001 From: Diogo Teles Sant'Anna Date: Wed, 13 Dec 2023 20:22:04 +0000 Subject: [PATCH 05/14] ci: hash-pin sensitive workflow dependency Signed-off-by: Diogo Teles Sant'Anna --- .github/workflows/bzlmod-archive.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bzlmod-archive.yml b/.github/workflows/bzlmod-archive.yml index 362888c..38a75dd 100644 --- a/.github/workflows/bzlmod-archive.yml +++ b/.github/workflows/bzlmod-archive.yml @@ -12,7 +12,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - run: git archive $GITHUB_REF -o "yaml-cpp-${GITHUB_REF:10}.tar.gz" - run: gh release upload ${GITHUB_REF:10} "yaml-cpp-${GITHUB_REF:10}.tar.gz" env: From c7639e81d5f00a5b47a2c9bd668f10d74b949071 Mon Sep 17 00:00:00 2001 From: Diogo Teles Sant'Anna Date: Thu, 14 Dec 2023 14:56:37 +0000 Subject: [PATCH 06/14] ci: configure dependabot to montly update GHAs Signed-off-by: Diogo Teles Sant'Anna --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..dc23806 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + groups: + github-actions: + patterns: + - "*" + From 94710bb2213cb6793121eaaa4edfb15abcca7af9 Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Thu, 28 Dec 2023 10:11:58 -0600 Subject: [PATCH 07/14] Add default destructor to EmitFromEvents --- include/yaml-cpp/emitfromevents.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/yaml-cpp/emitfromevents.h b/include/yaml-cpp/emitfromevents.h index 1f389c5..c00d26e 100644 --- a/include/yaml-cpp/emitfromevents.h +++ b/include/yaml-cpp/emitfromevents.h @@ -23,6 +23,7 @@ class Emitter; class EmitFromEvents : public EventHandler { public: EmitFromEvents(Emitter& emitter); + ~EmitFromEvents() override = default; void OnDocumentStart(const Mark& mark) override; void OnDocumentEnd() override; From c28295bda489422e4b5928aa0b978eb51dbdcbb1 Mon Sep 17 00:00:00 2001 From: Alexandre TISSOT <60519602+Trompettesib@users.noreply.github.com> Date: Thu, 13 Oct 2022 22:12:19 +0200 Subject: [PATCH 08/14] Add CMake integration example --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index e860706..f2ec061 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,27 @@ cmake [-G generator] [-DYAML_BUILD_SHARED_LIBS=on|OFF] .. **Note:** To clean up, just remove the `build` directory. +## How to Integrate it within your project using CMake + +You can use for example FetchContent : + +```cmake +include(FetchContent) + +FetchContent_Declare(yaml-cpp + GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git + GIT_TAG 1b50109f7bea60bd382d8ea7befce3d2bd67da5f) # The latest yaml-cpp commit at the time of writing. +FetchContent_GetProperties(yaml-cpp) + +if(NOT yaml-cpp_POPULATED) + message(STATUS "Fetching yaml-cpp...") + FetchContent_Populate(yaml-cpp) + add_subdirectory(${yaml-cpp_SOURCE_DIR} ${yaml-cpp_BINARY_DIR}) +endif() + +target_link_libraries(YOUR_LIBRARY PUBLIC yaml-cpp::yaml-cpp) # The library or executable that require yaml-cpp library +``` + ## Recent Releases [yaml-cpp 0.6.0](https://github.com/jbeder/yaml-cpp/releases/tag/yaml-cpp-0.6.0) released! This release requires C++11, and no longer depends on Boost. From 9eb1142900096b9115ba2db2a521c76c117cacd9 Mon Sep 17 00:00:00 2001 From: Trompettesib Date: Thu, 4 Jan 2024 12:03:33 +0100 Subject: [PATCH 09/14] Fix GIT_TAG field in cmake integration example --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2ec061..a121b70 100644 --- a/README.md +++ b/README.md @@ -56,9 +56,11 @@ You can use for example FetchContent : ```cmake include(FetchContent) -FetchContent_Declare(yaml-cpp +FetchContent_Declare( + yaml-cpp GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git - GIT_TAG 1b50109f7bea60bd382d8ea7befce3d2bd67da5f) # The latest yaml-cpp commit at the time of writing. + GIT_TAG # Can be a tag (yaml-cpp-x.x.x), a commit hash, or a branch name (master) +) FetchContent_GetProperties(yaml-cpp) if(NOT yaml-cpp_POPULATED) From c67d701ad81da65a576efd3341634f8cd3892c9b Mon Sep 17 00:00:00 2001 From: Alejandro-FA <61871580+Alejandro-FA@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:19:15 +0100 Subject: [PATCH 10/14] Fix indentation of empty sequences and add test --- src/emitter.cpp | 3 ++- test/integration/emitter_test.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/emitter.cpp b/src/emitter.cpp index 4d48307..2a2262d 100644 --- a/src/emitter.cpp +++ b/src/emitter.cpp @@ -213,7 +213,8 @@ void Emitter::EmitEndSeq() { if (m_pState->CurGroupFlowType() == FlowType::Flow) { if (m_stream.comment()) m_stream << "\n"; - m_stream << IndentTo(m_pState->CurIndent()); + if (originalType == FlowType::Block || m_pState->HasBegunNode()) + m_stream << IndentTo(m_pState->CurIndent()); if (originalType == FlowType::Block) { m_stream << "["; } else { diff --git a/test/integration/emitter_test.cpp b/test/integration/emitter_test.cpp index b277d57..e3464a6 100644 --- a/test/integration/emitter_test.cpp +++ b/test/integration/emitter_test.cpp @@ -176,6 +176,17 @@ TEST_F(EmitterTest, EmptyFlowSeqWithBegunContent) { ]])"); } +TEST_F(EmitterTest, EmptyFlowSeqInMap) { + out << BeginMap; + out << Key << Flow << BeginSeq << EndSeq; + out << Value << 1; + out << Key << 2; + out << Value << Flow << BeginSeq << EndSeq; + out << EndMap; + + ExpectEmit("[]: 1\n2: []"); +} + TEST_F(EmitterTest, EmptyFlowMapWithBegunContent) { out << Flow; out << BeginSeq; From 96f5c887f373ac483844c51cfc9a3621002314f0 Mon Sep 17 00:00:00 2001 From: Jason Beach Date: Fri, 26 Jan 2024 12:26:52 -0500 Subject: [PATCH 11/14] assign fallback value --- include/yaml-cpp/node/impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h index 312281f..150a6cf 100644 --- a/include/yaml-cpp/node/impl.h +++ b/include/yaml-cpp/node/impl.h @@ -97,7 +97,7 @@ struct as_if { if (!node.m_pNode) return fallback; - T t; + T t = fallback; if (convert::decode(node, t)) return t; return fallback; From 4afd53b0d3140ba2eb85816bfced209cf37ff096 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 16:49:13 +0000 Subject: [PATCH 12/14] Bump the github-actions group with 1 update Bumps the github-actions group with 1 update: [actions/checkout](https://github.com/actions/checkout). - [Release notes](https://github.com/actions/checkout/releases) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] --- .github/workflows/build.yml | 6 +++--- .github/workflows/bzlmod-archive.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a939320..1256493 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ jobs: packages: googletest libgmock-dev libgtest-dev version: 1.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure run: | @@ -105,7 +105,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build run: | @@ -123,7 +123,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Build shell: bash diff --git a/.github/workflows/bzlmod-archive.yml b/.github/workflows/bzlmod-archive.yml index 38a75dd..cdb008f 100644 --- a/.github/workflows/bzlmod-archive.yml +++ b/.github/workflows/bzlmod-archive.yml @@ -12,7 +12,7 @@ jobs: permissions: contents: write steps: - - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - run: git archive $GITHUB_REF -o "yaml-cpp-${GITHUB_REF:10}.tar.gz" - run: gh release upload ${GITHUB_REF:10} "yaml-cpp-${GITHUB_REF:10}.tar.gz" env: From 5c1bbbd276f7ef0c07d18af35c1b1cf887fb59ca Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Wed, 21 Feb 2024 13:19:22 -0300 Subject: [PATCH 13/14] Skip Position Independent Code for PSP/PS3 --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b0978b..c486161 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,9 @@ set_property(TARGET yaml-cpp CXX_STANDARD_REQUIRED ON) if (NOT YAML_BUILD_SHARED_LIBS) - set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ON) + if (NOT PSP AND NOT PS3) + set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ON) + endif() endif() target_include_directories(yaml-cpp From 76dc6715734295ff1866bfc32872ff2278258fc8 Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Thu, 22 Feb 2024 14:50:05 -0300 Subject: [PATCH 14/14] Add option YAML_ENABLE_PIC=ON --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c486161..72fa542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(YAML_CPP_INSTALL "Enable generation of yaml-cpp install targets" ${YAML_C option(YAML_CPP_FORMAT_SOURCE "Format source" ${YAML_CPP_MAIN_PROJECT}) option(YAML_CPP_DISABLE_UNINSTALL "Disable uninstallation of yaml-cpp" OFF) option(YAML_USE_SYSTEM_GTEST "Use system googletest if found" OFF) +option(YAML_ENABLE_PIC "Use Position-Independent Code " ON) cmake_dependent_option(YAML_CPP_BUILD_TESTS "Enable yaml-cpp tests" OFF @@ -91,9 +92,7 @@ set_property(TARGET yaml-cpp CXX_STANDARD_REQUIRED ON) if (NOT YAML_BUILD_SHARED_LIBS) - if (NOT PSP AND NOT PS3) - set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ON) - endif() + set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE ${YAML_ENABLE_PIC}) endif() target_include_directories(yaml-cpp