Skip to content

Commit 3add6d3

Browse files
authored
Merge pull request #125 from wravery/master
Update to PEGTL 3.0.0 Release
2 parents b456137 + f133278 commit 3add6d3

File tree

4 files changed

+25
-41
lines changed

4 files changed

+25
-41
lines changed

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ exposes an instance of [GraphiQL](https://github.com/graphql/graphiql) on top of
3737

3838
## Installation process
3939

40-
I've tested this on Windows with both Visual Studio 2017 and 2019, and on Linux using an Ubuntu 18.04 LTS instance running in
41-
WSL with both gcc 7.3.0 and clang 6.0.0. The key compiler requirement is support for C++17, earlier versions of gcc and clang
42-
may not have enough support for that.
40+
I've tested this on Windows with both Visual Studio 2017 and 2019, and on Linux using an Ubuntu 20.04 LTS instance running in
41+
WSL with both gcc 9.3.0 and clang 10.0.0. The key compiler requirement is support for C++17 including std::filesystem, earlier
42+
versions of gcc and clang may not have enough support for that.
4343

4444
The easiest way to get all of these and to build `cppgraphqlgen` in one step is to use
4545
[microsoft/vcpkg](https://github.com/microsoft/vcpkg). To install with vcpkg, make sure you've pulled the latest version
4646
and then run `vcpkg install cppgraphqlgen` (or `cppgraphqlgen:x64-windows`, `cppgraphqlgen:x86-windows-static`, etc.
4747
depending on your platform). To install just the dependencies and work in a clone of this repo, you'll need some subset
48-
of `vcpkg install pegtl boost-program-options boost-filesystem rapidjson gtest`. It works for Windows, Linux, and Mac,
48+
of `vcpkg install pegtl boost-program-options rapidjson gtest`. It works for Windows, Linux, and Mac,
4949
but if you want to try building for another platform (e.g. Android or iOS), you'll need to do more of this manually.
5050

5151
Manual installation will work best if you clone the GitHub repos for each of the dependencies and follow the installation
@@ -68,7 +68,7 @@ means you need to include an acknowledgement along with the license text.
6868
- GraphQL parsing: [Parsing Expression Grammar Template Library (PEGTL)](https://github.com/taocpp/PEGTL) release 3.0.0,
6969
which is part of [The Art of C++](https://taocpp.github.io/) library collection. I've added this as a sub-module, so you
7070
do not need to install this separately. If you already have 3.0.0 installed where CMake can find it, it will use that
71-
instead of the sub-module and avoid installing another copy of PEGTL. _Note: PEGTL 3.0.0 is currently at pre-release._
71+
instead of the sub-module and avoid installing another copy of PEGTL.
7272

7373
### graphqlservice
7474

@@ -85,11 +85,6 @@ do that.
8585

8686
I'm using [Boost](https://www.boost.org/doc/libs/1_69_0/more/getting_started/index.html) for `schemagen`:
8787

88-
- C++17 std::filesystem support on Unix:
89-
[Boost.Filesystem](https://www.boost.org/doc/libs/1_69_0/libs/filesystem/doc/index.htm). Most of the default C++
90-
compilers on Linux still have `std::filesystem` from C++17 in an experimental directory and require an extra
91-
library. The standard just adopted the Boost library, so on Unix systems I have an `#ifdef` which redirects back to
92-
it for the time being.
9388
- Command line handling: [Boost.Program_options](https://www.boost.org/doc/libs/1_69_0/doc/html/program_options.html).
9489
Run `schemagen -?` to get a list of options. Many of the files in the [samples](samples/) directory were generated
9590
with `schemagen`, you can look at [samples/CMakeLists.txt](samples/CMakeLists.txt) for a few examples of how to call it:

src/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ if(GRAPHQL_BUILD_SCHEMAGEN)
5151
set(BOOST_COMPONENTS program_options)
5252
set(BOOST_LIBRARIES Boost::program_options)
5353

54-
if(NOT MSVC)
55-
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem)
56-
set(BOOST_LIBRARIES ${BOOST_LIBRARIES} Boost::filesystem)
57-
target_compile_options(schemagen PRIVATE -DUSE_BOOST_FILESYSTEM)
58-
endif()
59-
6054
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
6155
target_link_libraries(schemagen PRIVATE ${BOOST_LIBRARIES})
6256

src/SchemaGenerator.cpp

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@
55

66
#include <boost/program_options.hpp>
77

8-
#ifdef USE_BOOST_FILESYSTEM
9-
#include <boost/filesystem.hpp>
10-
namespace fs = boost::filesystem;
11-
#else
12-
#include <filesystem>
13-
namespace fs = std::filesystem;
14-
#endif
15-
168
#include <cctype>
9+
#include <filesystem>
1710
#include <fstream>
1811
#include <iostream>
1912
#include <regex>
@@ -304,11 +297,11 @@ std::string Generator::getHeaderDir() const noexcept
304297
{
305298
if (_isIntrospection)
306299
{
307-
return (fs::path { "include" } / "graphqlservice").string();
300+
return (std::filesystem::path { "include" } / "graphqlservice").string();
308301
}
309302
else if (_options.paths)
310303
{
311-
return fs::path { _options.paths->headerPath }.string();
304+
return std::filesystem::path { _options.paths->headerPath }.string();
312305
}
313306
else
314307
{
@@ -324,13 +317,13 @@ std::string Generator::getSourceDir() const noexcept
324317
}
325318
else
326319
{
327-
return fs::path(_options.paths->sourcePath).string();
320+
return std::filesystem::path(_options.paths->sourcePath).string();
328321
}
329322
}
330323

331324
std::string Generator::getHeaderPath() const noexcept
332325
{
333-
fs::path fullPath { _headerDir };
326+
std::filesystem::path fullPath { _headerDir };
334327

335328
if (_isIntrospection)
336329
{
@@ -348,7 +341,7 @@ std::string Generator::getObjectHeaderPath() const noexcept
348341
{
349342
if (_options.separateFiles)
350343
{
351-
fs::path fullPath { _headerDir };
344+
std::filesystem::path fullPath { _headerDir };
352345

353346
fullPath /= (_options.customSchema->filenamePrefix + "Objects.h");
354347
return fullPath.string();
@@ -359,7 +352,7 @@ std::string Generator::getObjectHeaderPath() const noexcept
359352

360353
std::string Generator::getSourcePath() const noexcept
361354
{
362-
fs::path fullPath { _sourceDir };
355+
std::filesystem::path fullPath { _sourceDir };
363356

364357
if (_isIntrospection)
365358
{
@@ -1666,7 +1659,8 @@ std::string Generator::getOutputCppType(const OutputField& field) const noexcept
16661659
bool Generator::outputHeader() const noexcept
16671660
{
16681661
std::ofstream headerFile(_headerPath, std::ios_base::trunc);
1669-
IncludeGuardScope includeGuard { headerFile, fs::path(_headerPath).filename().string() };
1662+
IncludeGuardScope includeGuard { headerFile,
1663+
std::filesystem::path(_headerPath).filename().string() };
16701664

16711665
headerFile << R"cpp(#include "graphqlservice/GraphQLService.h"
16721666
@@ -2048,8 +2042,8 @@ bool Generator::outputSource() const noexcept
20482042
)cpp";
20492043
if (!_isIntrospection)
20502044
{
2051-
sourceFile << R"cpp(#include ")cpp" << fs::path(_objectHeaderPath).filename().string()
2052-
<< R"cpp("
2045+
sourceFile << R"cpp(#include ")cpp"
2046+
<< std::filesystem::path(_objectHeaderPath).filename().string() << R"cpp("
20532047
20542048
)cpp";
20552049
}
@@ -3427,8 +3421,8 @@ std::string Generator::getIntrospectionType(
34273421
std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34283422
{
34293423
std::vector<std::string> files;
3430-
const fs::path headerDir(_headerDir);
3431-
const fs::path sourceDir(_sourceDir);
3424+
const std::filesystem::path headerDir(_headerDir);
3425+
const std::filesystem::path sourceDir(_sourceDir);
34323426
std::string queryType;
34333427

34343428
for (const auto& operation : _operationTypes)
@@ -3443,10 +3437,10 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34433437
// Output a convenience header
34443438
std::ofstream objectHeaderFile(_objectHeaderPath, std::ios_base::trunc);
34453439
IncludeGuardScope includeGuard { objectHeaderFile,
3446-
fs::path(_objectHeaderPath).filename().string() };
3440+
std::filesystem::path(_objectHeaderPath).filename().string() };
34473441

3448-
objectHeaderFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string()
3449-
<< R"cpp("
3442+
objectHeaderFile << R"cpp(#include ")cpp"
3443+
<< std::filesystem::path(_headerPath).filename().string() << R"cpp("
34503444
34513445
)cpp";
34523446

@@ -3480,7 +3474,8 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
34803474
std::ofstream headerFile(headerPath, std::ios_base::trunc);
34813475
IncludeGuardScope includeGuard { headerFile, headerFilename };
34823476

3483-
headerFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() << R"cpp("
3477+
headerFile << R"cpp(#include ")cpp"
3478+
<< std::filesystem::path(_headerPath).filename().string() << R"cpp("
34843479
34853480
)cpp";
34863481

@@ -3503,7 +3498,7 @@ std::vector<std::string> Generator::outputSeparateFiles() const noexcept
35033498
sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved.
35043499
// Licensed under the MIT License.
35053500
3506-
#include ")cpp" << fs::path(_objectHeaderPath).filename().string()
3501+
#include ")cpp" << std::filesystem::path(_objectHeaderPath).filename().string()
35073502
<< R"cpp("
35083503
35093504
#include "graphqlservice/Introspection.h"

0 commit comments

Comments
 (0)