Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Move PEGTL into a git submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Dec 26, 2020
1 parent 6ca897e commit 6e845c2
Show file tree
Hide file tree
Showing 245 changed files with 142 additions and 12,827 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "external/PEGTL"]
path = external/PEGTL
url = https://github.com/taocpp/PEGTL
75 changes: 13 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,70 +18,21 @@ target_include_directories(json INTERFACE
# require C++17
target_compile_features(json INTERFACE cxx_std_17)

option(TAOCPP_JSON_PEGTL_USE_BOOST_FILESYSTEM "Override the auto-detection of std::filesystem and use Boost.Filesystem" OFF)

# Try compiling a test program with std::filesystem or one of its alternatives
function(check_filesystem_impl FILESYSTEM_HEADER FILESYSTEM_NAMESPACE OPTIONAL_LIBS OUT_RESULT)
set(TEST_FILE "test_${OUT_RESULT}.cpp")
configure_file(.cmake/test_filesystem.cpp.in ${TEST_FILE} @ONLY)

try_compile(TEST_RESULT
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE}
CXX_STANDARD 17)

if(NOT TEST_RESULT)
# Retry with each of the optional libraries
foreach(OPTIONAL_LIB IN LISTS OPTIONAL_LIBS)
try_compile(TEST_RESULT
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE}
LINK_LIBRARIES ${OPTIONAL_LIB}
CXX_STANDARD 17)

if(TEST_RESULT)
# Looks like the optional library was required, go ahead and add it to the link options.
message(STATUS "Adding ${OPTIONAL_LIB} to taoJSON to build with ${FILESYSTEM_NAMESPACE}.")
target_link_libraries(json INTERFACE ${OPTIONAL_LIB})
break()
endif()
endforeach(OPTIONAL_LIB)
endif()

set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE)
endfunction(check_filesystem_impl)

if(TAOCPP_JSON_PEGTL_USE_BOOST_FILESYSTEM)
# Force the use of Boost.Filesystem: #include <boost/filesystem.hpp> // boost::filesystem
find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(json INTERFACE Boost::filesystem)
target_compile_definitions(json INTERFACE TAO_JSON_PEGTL_BOOST_FILESYSTEM)
else()
# Try compiling a minimal program with each header/namespace, in order of preference:
# C++17: #include <filesystem> // std::filesystem
# Experimental C++17: #include <experimental/filesystem> // std::experimental::filesystem
# Boost.Filesystem: #include <boost/filesystem.hpp> // boost::filesystem
check_filesystem_impl("filesystem" "std::filesystem" "stdc++fs;c++fs" STD_FILESYSTEM)
if(STD_FILESYSTEM)
message(STATUS "Using std::filesystem")
else()
check_filesystem_impl("experimental/filesystem" "std::experimental::filesystem" "stdc++fs;c++fs" STD_EXPERIMENTAL_FILESYSTEM)
if(STD_EXPERIMENTAL_FILESYSTEM)
target_compile_definitions(json INTERFACE TAO_JSON_PEGTL_STD_EXPERIMENTAL_FILESYSTEM)
message(WARNING "Using std::experimental::filesystem as a fallback")
else()
find_package(Boost COMPONENTS filesystem)
check_filesystem_impl("boost/filesystem.hpp" "boost::filesystem" Boost::filesystem BOOST_FILESYSTEM)
if(BOOST_FILESYSTEM)
target_compile_definitions(json INTERFACE TAO_JSON_PEGTL_BOOST_FILESYSTEM)
message(WARNING "Using Boost.Filesystem as a fallback")
else()
message(FATAL_ERROR "taoJSON requires C++17, including an implementation of std::filesystem, which your compiler toolchain does not seem to support. You can try installing Boost.Filesystem as a temporary workaround, but there's no guarantee taoJSON will keep working with your project. Consider upgrading your compiler toolchain or downgrading taoJSON to the previous version.")
endif()
endif()
endif()
# find a suitable PEGTL
find_package(pegtl 3.1.0 QUIET CONFIG)
if(NOT pegtl_FOUND)
# if a compatible version of PEGTL is not already installed, build and install it from the submodule directory
message(STATUS "Adding PEGTL as submodule from external/PEGTL.")
set(PEGTL_BUILD_TESTS OFF CACHE BOOL "Disable PEGTL tests")
set(PEGTL_BUILD_EXAMPLES OFF CACHE BOOL "Disable PEGTL examples")
set(PEGTL_INSTALL_INCLUDE_DIR ${TAOCPP_JSON_INSTALL_INCLUDE_DIR} CACHE STRING "Override PEGTL include install directory")
set(PEGTL_INSTALL_CMAKE_DIR ${TAOCPP_JSON_INSTALL_CMAKE_DIR}/pegtl CACHE STRING "Override PEGTL cmake install directory")
add_subdirectory(external/PEGTL)
endif()

# add pegtl as a dependency
target_link_libraries(json INTERFACE taocpp::pegtl)

# testing
option(TAOCPP_JSON_BUILD_TESTS "Build test programs" ON)
if(TAOCPP_JSON_BUILD_TESTS)
Expand Down
1 change: 1 addition & 0 deletions external/PEGTL
Submodule PEGTL added at a6a247
1 change: 0 additions & 1 deletion include/tao/json/binding/constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <cstdint>
#include <string>

#include "../external/pegtl/internal/pegtl_string.hpp"
#include "../internal/escape.hpp"
#include "../internal/format.hpp"
#include "../internal/string_t.hpp"
Expand Down
5 changes: 3 additions & 2 deletions include/tao/json/binding/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
#include <stdexcept>
#include <string>

#include <tao/pegtl/demangle.hpp>
// #include <tao/pegtl/internal/pegtl_string.hpp>

#include "../forward.hpp"

#include "../basic_value.hpp"
#include "../external/pegtl/demangle.hpp"
#include "../external/pegtl/internal/pegtl_string.hpp"
#include "../internal/escape.hpp"
#include "../internal/format.hpp"
#include "../internal/string_t.hpp"
Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/binding/internal/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
#include <utility>
#include <vector>

#include <tao/pegtl/demangle.hpp>

#include "../../basic_value.hpp"
#include "../../forward.hpp"

#include "../../external/pegtl/demangle.hpp"
#include "../../internal/format.hpp"
#include "../../internal/type_traits.hpp"

Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/binding/internal/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
#include <string>
#include <utility>

#include <tao/pegtl/demangle.hpp>

#include "../for_nothing_value.hpp"
#include "../for_unknown_key.hpp"
#include "../member_kind.hpp"

#include "../../forward.hpp"

#include "../../basic_value.hpp"
#include "../../external/pegtl/demangle.hpp"
#include "../../internal/escape.hpp"
#include "../../internal/format.hpp"
#include "../../internal/type_traits.hpp"
Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/binding/versions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#include <exception>
#include <stdexcept>

#include <tao/pegtl/demangle.hpp>

#include "../forward.hpp"

#include "../external/pegtl/demangle.hpp"
#include "../internal/format.hpp"
#include "../internal/type_traits.hpp"

Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/cbor/consume_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#ifndef TAO_JSON_CBOR_CONSUME_FILE_HPP
#define TAO_JSON_CBOR_CONSUME_FILE_HPP

#include "../external/pegtl/file_input.hpp"
#include <tao/pegtl/file_input.hpp>

#include "../internal/filesystem.hpp"

#include "../consume.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/cbor/consume_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef TAO_JSON_CBOR_CONSUME_STRING_HPP
#define TAO_JSON_CBOR_CONSUME_STRING_HPP

#include "../external/pegtl/string_input.hpp"
#include <tao/pegtl/memory_input.hpp>

#include "../consume.hpp"
#include "../forward.hpp"
Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/cbor/events/from_binary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#ifndef TAO_JSON_CBOR_EVENTS_FROM_BINARY_HPP
#define TAO_JSON_CBOR_EVENTS_FROM_BINARY_HPP

#include <tao/pegtl/memory_input.hpp>

#include "../../binary.hpp"
#include "../../binary_view.hpp"
#include "../../external/pegtl/memory_input.hpp"

#include "from_input.hpp"

Expand Down
5 changes: 3 additions & 2 deletions include/tao/json/cbor/events/from_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#ifndef TAO_JSON_CBOR_EVENTS_FROM_FILE_HPP
#define TAO_JSON_CBOR_EVENTS_FROM_FILE_HPP

#include "../../external/pegtl/file_input.hpp"
#include "../../external/pegtl/parse.hpp"
#include <tao/pegtl/file_input.hpp>
#include <tao/pegtl/parse.hpp>

#include "../../internal/filesystem.hpp"

#include "../internal/grammar.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/cbor/events/from_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <utility>

#include "../../external/pegtl/parse.hpp"
#include <tao/pegtl/parse.hpp>

#include "../internal/grammar.hpp"

Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/cbor/events/from_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string>
#include <string_view>

#include "../../external/pegtl/memory_input.hpp"
#include <tao/pegtl/memory_input.hpp>

#include "from_input.hpp"

Expand Down
9 changes: 4 additions & 5 deletions include/tao/json/cbor/internal/grammar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
#include <string_view>
#include <utility>

#include <tao/pegtl.hpp>

#include "major.hpp"

#include "../../binary_view.hpp"
#include "../../external/pegtl.hpp"
#include "../../forward.hpp"
#include "../../internal/endian.hpp"
#include "../../internal/format.hpp"
Expand Down Expand Up @@ -397,14 +398,12 @@ namespace tao::json::cbor::internal
template< utf8_mode V >
struct basic_grammar
: pegtl::must< data< V >, pegtl::eof >
{
};
{};

template< utf8_mode V >
struct basic_embedded
: pegtl::must< data< V > >
{
};
{};

using grammar = basic_grammar< utf8_mode::check >;
using embedded = basic_embedded< utf8_mode::check >;
Expand Down
5 changes: 4 additions & 1 deletion include/tao/json/cbor/parts_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
#include <cstdint>
#include <optional>

#include <tao/pegtl/parse_error.hpp>
#include <tao/pegtl/rules.hpp>
#include <tao/pegtl/string_input.hpp>

#include "../events/discard.hpp"
#include "../external/pegtl/string_input.hpp"
#include "../utf8.hpp"

#include "internal/grammar.hpp"
Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/consume_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#ifndef TAO_JSON_CONSUME_FILE_HPP
#define TAO_JSON_CONSUME_FILE_HPP

#include "external/pegtl/file_input.hpp"
#include <tao/pegtl/file_input.hpp>

#include "internal/filesystem.hpp"

#include "consume.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/consume_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef TAO_JSON_CONSUME_STRING_HPP
#define TAO_JSON_CONSUME_STRING_HPP

#include "external/pegtl/string_input.hpp"
#include <tao/pegtl/string_input.hpp>

#include "consume.hpp"
#include "forward.hpp"
Expand Down
6 changes: 3 additions & 3 deletions include/tao/json/contrib/schema.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <string>
#include <type_traits>

#include <tao/pegtl.hpp>
#include <tao/pegtl/contrib/uri.hpp>

#include "reference.hpp"

#include "../events/compare.hpp"
Expand All @@ -23,9 +26,6 @@
#include "../pointer.hpp"
#include "../value.hpp"

#include "../external/pegtl/contrib/uri.hpp"
#include "../external/pegtl/parse.hpp"

namespace tao::json
{
namespace internal
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/contrib/variant_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <utility>
#include <variant>

#include "../external/pegtl/demangle.hpp"
#include <tao/pegtl/demangle.hpp>

#include "../events/produce.hpp"

Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/events/from_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include "../internal/filesystem.hpp"
#include "../internal/grammar.hpp"

#include "../external/pegtl/file_input.hpp"
#include <tao/pegtl/file_input.hpp>
#include <tao/pegtl/parse.hpp>

namespace tao::json::events
{
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/events/from_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <utility>

#include "../external/pegtl/parse.hpp"
#include <tao/pegtl/parse.hpp>

#include "../internal/action.hpp"
#include "../internal/errors.hpp"
Expand Down
4 changes: 2 additions & 2 deletions include/tao/json/events/from_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <istream>

#include "../external/pegtl/internal/istream_reader.hpp"
#include "../external/pegtl/parse.hpp"
#include <tao/pegtl/istream_input.hpp>
#include <tao/pegtl/parse.hpp>

#include "../internal/action.hpp"
#include "../internal/errors.hpp"
Expand Down
2 changes: 1 addition & 1 deletion include/tao/json/events/from_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <string_view>

#include "../external/pegtl/memory_input.hpp"
#include <tao/pegtl/memory_input.hpp>

#include "from_input.hpp"

Expand Down
3 changes: 2 additions & 1 deletion include/tao/json/events/validate_keys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include <string_view>
#include <utility>

#include "../external/pegtl.hpp"
#include <tao/pegtl/memory_input.hpp>
#include <tao/pegtl/parse.hpp>

namespace tao::json::events
{
Expand Down
Loading

0 comments on commit 6e845c2

Please sign in to comment.