[fix] avoid conflict in tests with older c4core from c4fs

This commit is contained in:
Joao Paulo Magalhaes
2022-01-02 19:39:23 +00:00
parent dc111c8a6b
commit 8013655b33
16 changed files with 68 additions and 46 deletions

View File

@@ -1,9 +1,11 @@
#ifndef RYML_SINGLE_HEADER
#include "c4/yml/std/std.hpp"
#include "c4/yml/parse.hpp"
#include "c4/yml/emit.hpp"
#include <c4/format.hpp>
#include <c4/yml/detail/checks.hpp>
#include <c4/yml/detail/print.hpp>
#endif
#include "./test_case.hpp"

View File

@@ -1,9 +1,11 @@
#ifndef RYML_SINGLE_HEADER
#include "c4/yml/std/std.hpp"
#include "c4/yml/parse.hpp"
#include "c4/yml/emit.hpp"
#include <c4/format.hpp>
#include <c4/yml/detail/checks.hpp>
#include <c4/yml/detail/print.hpp>
#endif
#include "./test_case.hpp"

View File

@@ -1,5 +1,7 @@
#include "./test_case.hpp"
#ifndef RYML_SINGLE_HEADER
#include "c4/yml/common.hpp"
#endif
#include <stdexcept>

View File

@@ -1,13 +1,12 @@
#include "./test_case.hpp"
#include "c4/yml/common.hpp"
#ifndef RYML_SINGLE_HEADER
#include "c4/yml/common.hpp"
#include "c4/format.hpp"
#include "c4/span.hpp"
#include "c4/yml/std/std.hpp"
#endif
// these headers are not amalgamated
#include "c4/yml/detail/print.hpp"
#include "c4/yml/detail/checks.hpp"
#endif
#include <gtest/gtest.h>

View File

@@ -1,5 +1,7 @@
#include "./test_group.hpp"
#ifndef RYML_SINGLE_HEADER
#include "c4/yml/detail/print.hpp"
#endif
#include "test_group.hpp"
#include "test_case.hpp"
#include <c4/fs/fs.hpp>
#include <fstream>

View File

@@ -1,9 +1,8 @@
#include <gtest/gtest.h>
#ifndef RYML_SINGLE_HEADER
#include <c4/yml/std/std.hpp>
#include <c4/yml/yml.hpp>
#include <initializer_list>
#include <string>
#include <iostream>
#endif
#include <gtest/gtest.h>
#include "./test_case.hpp"

View File

@@ -1,7 +1,9 @@
#ifndef RYML_SINGLE_HEADER
#include <c4/yml/std/string.hpp>
#include <c4/yml/preprocess.hpp>
#include <gtest/gtest.h>
#endif
#include "./test_case.hpp"
#include <gtest/gtest.h>
namespace c4 {
namespace yml {

View File

@@ -7,29 +7,31 @@ include(../../ext/c4core/cmake/c4Project.cmake)
c4_project(VERSION 0.3.0
AUTHOR "Joao Paulo Magalhaes <dev@jpmag.me>")
set(rymldir "${CMAKE_CURRENT_LIST_DIR}/../..")
set(singleheaderdir "${rymldir}/src_singleheader")
set(singleheader "${singleheaderdir}/ryml_all.hpp")
if(NOT (EXISTS "${singleheader}"))
# try generating a header
set(cmd python "${rymldir}/tools/amalgamate.py" "${singleheader}")
message(STATUS "single header not found, attempting to generate... ${cmd}")
execute_process(COMMAND ${cmd}
#COMMMAND_ECHO STDOUT
RESULT_VARIABLE status)
if((NOT (status EQUAL "0")) OR NOT (EXISTS "${singleheader}"))
message(FATAL_ERROR "cannot find or generate single header for ryml: ${singleheader}")
endif()
message(STATUS "single header successfully generated: ${singleheader}")
endif()
# amalgamate ryml to get the single header
function(amalgamate_ryml header_dir header_file)
set(rymldir "${CMAKE_CURRENT_LIST_DIR}/../..")
set(singleheaderdir "${rymldir}/src_singleheader")
set(singleheader "${singleheaderdir}/ryml_all.hpp")
set(amscript "${rymldir}/tools/amalgamate.py")
file(GLOB_RECURSE srcfiles
LIST_DIRECTORIES FALSE
CONFIGURE_DEPENDS "${rymldir}/src")
add_custom_command(OUTPUT "${singleheader}"
COMMAND python "${amscript}" "${singleheader}"
COMMENT "python ${amscript} ${singleheader}"
DEPENDS ${srcfiles} "${amscript}" "${rymldir}/ext/c4core/cmake/amalgamate_utils.py")
set(${header_dir} "${singleheaderdir}" PARENT_SCOPE)
set(${header_file} "${singleheader}" PARENT_SCOPE)
endfunction()
amalgamate_ryml(header_dir header_file)
c4_add_library(ryml
INC_DIRS
$<BUILD_INTERFACE:${singleheaderdir}> $<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${rymldir}/src> # because of a couple of detail:: headers which are not amalgamated
SOURCE_ROOT ${singleheaderdir}
$<BUILD_INTERFACE:${header_dir}>
$<INSTALL_INTERFACE:include>
SOURCE_ROOT ${header_dir}
SOURCES
${singleheader}
${header_file}
${CMAKE_CURRENT_LIST_DIR}/libryml_singleheader.cpp)
target_compile_definitions(ryml PUBLIC -DRYML_SINGLE_HEADER) # this is needed only for the tests, not ryml itself

View File

@@ -1,4 +1,8 @@
#ifdef RYML_SINGLE_HEADER
#include "ryml_all.hpp"
#else
#include "c4/yml/detail/stack.hpp"
#endif
#include <gtest/gtest.h>
//-------------------------------------------
@@ -309,8 +313,10 @@ TEST(stack, move_assign)
// this is needed to use the test case library
#ifndef RYML_SINGLE_HEADER
#include "c4/substr.hpp"
#include "c4/yml/common.hpp"
#endif
namespace c4 {
namespace yml {

View File

@@ -1,20 +1,18 @@
#include <gtest/gtest.h>
#ifndef RYML_SINGLE_HEADER
#include <c4/yml/std/std.hpp>
#include <c4/fs/fs.hpp>
#include <c4/log/log.hpp>
#include <c4/yml/tree.hpp>
#include <c4/yml/parse.hpp>
#include <c4/yml/emit.hpp>
#include <c4/yml/detail/print.hpp>
#include <c4/yml/detail/checks.hpp>
#endif
#include "test_case.hpp"
#include "test_suite/test_suite_common.hpp"
#include "test_suite/test_suite_parts.hpp"
#include "test_suite/test_suite_events.hpp"
#include <c4/fs/fs.hpp>
#include <c4/log/log.hpp>
#include <gtest/gtest.h>
C4_SUPPRESS_WARNING_MSVC_PUSH

View File

@@ -1,20 +1,20 @@
#ifndef C4_YML_TEST_SUITE_COMMON_HPP_
#define C4_YML_TEST_SUITE_COMMON_HPP_
#include <gtest/gtest.h>
#ifndef RYML_SINGLE_HEADER
#include <c4/yml/std/std.hpp>
#include <c4/fs/fs.hpp>
#include <c4/log/log.hpp>
#include <c4/yml/tree.hpp>
#include <c4/yml/parse.hpp>
#include <c4/yml/emit.hpp>
#include <c4/yml/detail/print.hpp>
#include <c4/yml/detail/checks.hpp>
#endif
#include <c4/fs/fs.hpp>
#include <c4/log/log.hpp>
#include "test_case.hpp"
#include <gtest/gtest.h>
#define RYML_NFO (1 || RYML_DBG)

View File

@@ -1,7 +1,8 @@
#include "test_suite_events.hpp"
#include "test_suite_common.hpp"
#ifndef RYML_SINGLE_HEADER
#include <c4/yml/detail/stack.hpp>
#endif
#include <gtest/gtest.h>
namespace c4 {

View File

@@ -1,7 +1,11 @@
#ifndef C4_YML_TEST_SUITE_EVENTS_HPP_
#define C4_YML_TEST_SUITE_EVENTS_HPP_
#ifdef RYML_SINGLE_HEADER
#include <ryml_all.hpp>
#else
#include <c4/yml/tree.hpp>
#endif
namespace c4 {
namespace yml {

View File

@@ -1,9 +1,12 @@
#ifndef C4_YML_TEST_SUITE_PARTS_HPP_
#define C4_YML_TEST_SUITE_PARTS_HPP_
#ifdef RYML_SINGLE_HEADER
#include <ryml_all.hpp>
#else
#include <c4/yml/common.hpp>
#include <c4/span.hpp>
#endif
#include <c4/log/log.hpp>

View File

@@ -89,8 +89,8 @@ INSTRUCTIONS:
"src/c4/yml/node.cpp",
"src/c4/yml/preprocess.hpp",
"src/c4/yml/preprocess.cpp",
#"src/c4/yml/detail/checks.hpp",
#"src/c4/yml/detail/print.hpp",
"src/c4/yml/detail/checks.hpp",
"src/c4/yml/detail/print.hpp",
"src/c4/yml/yml.hpp",
"src/ryml.hpp",
]