Skip to content

Commit 1d4f6c3

Browse files
committed
Fix windows compilation issues
1 parent 7a2a775 commit 1d4f6c3

File tree

13 files changed

+48
-43
lines changed

13 files changed

+48
-43
lines changed

cppparser/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,18 @@ set(CPPPARSER_SOURCES
6060
)
6161

6262
add_library(cppparser STATIC ${CPPPARSER_SOURCES})
63-
add_dependencies(cppparser btyacc boost_filesystem boost_program_options)
63+
add_dependencies(cppparser btyacc)
6464
target_link_libraries(cppparser
6565
PUBLIC
6666
cppast
67-
boost_filesystem
68-
boost_program_options
69-
boost_system
7067
)
7168
target_include_directories(cppparser
7269
PUBLIC
7370
include
7471
src
7572
../../common/third_party/boost_tp
73+
PRIVATE
74+
src/win_hack
7675
)
7776
target_compile_definitions(cppparser
7877
PRIVATE

cppparser/include/cppparser/cpputil.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#ifndef FF2B85CA_C19B_482E_9B0F_5F098BF974A1
55
#define FF2B85CA_C19B_482E_9B0F_5F098BF974A1
66

7-
#include <boost/filesystem.hpp>
7+
#include <filesystem>
88

99
#include "cppast/cppast.h"
1010
#include "cppconst.h"
1111

12-
namespace fs = boost::filesystem;
12+
namespace fs = std::filesystem;
1313

1414
using CppProgFileSelecter = std::function<bool(const std::string&)>;
1515

cppparser/src/cppparser.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <set>
1212
#include <string>
1313
#include <vector>
14+
#include <stdexcept>
1415

1516
// Unfortunately parser is not reentrant and has no way as of now to inject parameters.
1617
// So, we need globals.

cppparser/src/parser.l

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For this very reason this file does not use any class that are defined in cppast
1414

1515
%{
1616
// C++17 causes problem when register is used and flex uses register in generated code
17-
#define register
17+
// #define register
1818

1919
#include "cpptoken.h"
2020
#include "parser.l.h"
@@ -238,7 +238,6 @@ static void updateMacroDependence()
238238
%option stack
239239
%option noyy_top_state
240240
%option noyywrap
241-
%option nounistd
242241

243242
/************************************************************************/
244243

cppparser/src/utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
#include "utils.h"
55
#include "cppparser/string-utils.h"
66

7-
#include <boost/filesystem.hpp>
7+
#include <filesystem>
88

99
#include <cassert>
1010
#include <fstream>
1111

12-
namespace fs = boost::filesystem;
12+
namespace fs = std::filesystem;
1313

1414
static CppToken classNameFromTemplatedIdentifier(const CppToken& identifier)
1515
{

cppparser/src/win_hack/unistd.h

Whitespace-only changes.

cppparser/test/CMakeLists.txt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ target_link_libraries(cppparsertest
1515
PRIVATE
1616
cppparser
1717
cppwriter
18-
boost_filesystem
1918
boost_program_options
20-
boost_system
2119
)
2220

2321
set(E2E_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/e2e)
@@ -58,9 +56,6 @@ target_include_directories(cppparserunittest
5856
target_link_libraries(cppparserunittest
5957
PRIVATE
6058
cppparser
61-
boost_filesystem
62-
boost_program_options
63-
boost_system
6459
)
6560
set(UNIT_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/unit)
6661
add_test(
@@ -88,12 +83,18 @@ target_compile_definitions(cppparserembeddedsnippetvalidity
8883
target_link_libraries(cppparserembeddedsnippetvalidity
8984
PRIVATE
9085
cppparser
91-
boost_filesystem
92-
boost_program_options
93-
boost_system
9486
)
9587

96-
if(NOT MSVC)
88+
if(MSVC)
89+
target_compile_options(cppparserembeddedsnippetvalidity
90+
PRIVATE
91+
# Igbore warning related to test snippets
92+
/wd\"4101\"
93+
/wd\"4552\"
94+
/wd\"5030\"
95+
)
96+
97+
else()
9798
target_compile_options(cppparserembeddedsnippetvalidity
9899
PRIVATE
99100
-Wno-unused-variable

cppparser/test/app/compare.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
#include <iostream>
88
#include <sstream>
9+
#include <fstream>
910

10-
#include <boost/filesystem.hpp>
11+
#include <filesystem>
1112
#include <boost/program_options.hpp>
1213
#include <boost/system/config.hpp>
1314

14-
namespace bfs = boost::filesystem;
15+
namespace fs = std::filesystem;
1516
namespace bpo = boost::program_options;
1617

1718
template <typename _Itr1, typename _Itr2, typename _Pr>
@@ -71,7 +72,7 @@ enum FileCompareResult
7172
kDifferentFiles
7273
};
7374

74-
inline FileCompareResult compareFiles(const bfs::path& path1, const bfs::path& path2, std::pair<int, int>& diffStartsAt)
75+
inline FileCompareResult compareFiles(const fs::path& path1, const fs::path& path2, std::pair<int, int>& diffStartsAt)
7576
{
7677
std::ifstream file1(path1.string(), std::ios_base::in);
7778
std::ifstream file2(path2.string(), std::ios_base::in);
@@ -87,8 +88,8 @@ inline FileCompareResult compareFiles(const bfs::path& path1, const bfs::path& p
8788
}
8889

8990
inline void reportFileComparisonError(FileCompareResult result,
90-
const bfs::path& path1,
91-
const bfs::path& path2,
91+
const fs::path& path1,
92+
const fs::path& path2,
9293
std::pair<int, int>& diffStartsAt)
9394
{
9495
if (result == kFailedToOpen1stFile)

cppparser/test/app/cppparsertest.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@
1111
#include <iostream>
1212
#include <utility>
1313

14-
#include <boost/filesystem.hpp>
1514
#include <boost/program_options.hpp>
1615
#include <boost/system/config.hpp>
1716

18-
namespace bfs = boost::filesystem;
17+
18+
#include <filesystem>
19+
20+
namespace fs = std::filesystem;
21+
1922
namespace bpo = boost::program_options;
2023

2124
//////////////////////////////////////////////////////////////////////////
2225

2326
static bool parseAndEmitFormatted(cppparser::CppParser& parser,
24-
const bfs::path& inputFilePath,
25-
const bfs::path& outputFilePath,
27+
const fs::path& inputFilePath,
28+
const fs::path& outputFilePath,
2629
const cppcodegen::CppWriter& cppWriter)
2730
{
2831
auto progUnit = parser.parseFile(inputFilePath.string().c_str());
2932
if (!progUnit)
3033
return false;
31-
bfs::create_directories(outputFilePath.parent_path());
34+
fs::create_directories(outputFilePath.parent_path());
3235
std::ofstream stm(outputFilePath.string());
3336
cppWriter.emit(*progUnit.get(), stm);
3437

@@ -54,21 +57,21 @@ static std::pair<size_t, size_t> performTest(cppparser::CppParser& parser, const
5457
std::vector<std::string> parsingFailedFor;
5558
std::vector<FilePair> diffFailedList;
5659

57-
for (bfs::recursive_directory_iterator dirItr(params.inputPath); dirItr != bfs::recursive_directory_iterator();
60+
for (fs::recursive_directory_iterator dirItr(params.inputPath); dirItr != fs::recursive_directory_iterator();
5861
++dirItr)
5962
{
6063
cppcodegen::CppWriter cppWriter;
61-
bfs::path file = *dirItr;
62-
if (bfs::is_regular_file(file))
64+
fs::path file = *dirItr;
65+
if (fs::is_regular_file(file))
6366
{
6467
++numInputFiles;
6568
std::cout << "CppParserTest: Parsing " << file.string() << " ...\n";
6669
auto fileRelPath = file.string().substr(inputPathLen);
67-
bfs::path outfile = params.outputPath / fileRelPath;
68-
bfs::remove(outfile);
69-
if (parseAndEmitFormatted(parser, file, outfile, cppWriter) && bfs::exists(outfile))
70+
fs::path outfile = params.outputPath / fileRelPath;
71+
fs::remove(outfile);
72+
if (parseAndEmitFormatted(parser, file, outfile, cppWriter) && fs::exists(outfile))
7073
{
71-
bfs::path masfile = params.masterPath / fileRelPath;
74+
fs::path masfile = params.masterPath / fileRelPath;
7275
std::pair<int, int> diffStartInfo;
7376
auto rez = compareFiles(outfile, masfile, diffStartInfo);
7477
if (rez == kSameFiles)

cppparser/test/app/options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
#include <iostream>
88

9-
#include <boost/filesystem.hpp>
9+
#include <filesystem>
1010
#include <boost/program_options.hpp>
1111
#include <boost/system/config.hpp>
1212

13-
namespace fs = boost::filesystem;
13+
namespace fs = std::filesystem;
1414
namespace bpo = boost::program_options;
1515

1616
struct TestParam

0 commit comments

Comments
 (0)