Skip to content

Commit

Permalink
Patch Scanner and Parser to remove register keyword and enable c++17
Browse files Browse the repository at this point in the history
C++17 removes the 'register' keyword and it is no longer allowed to
suppress the warning, so use sed to patch the generated scanner and
parser files to remove the register keyword. Since the original file
generation now outputs an intermediate file, also patch the filename
strings embedded in the generated code so they match the final patched
versions

This also unpins the Parser library from c++14
  • Loading branch information
steveblackmon-mapd authored and andrewseidl committed Nov 26, 2019
1 parent 117c70f commit 8b0622f
Showing 1 changed file with 38 additions and 9 deletions.
47 changes: 38 additions & 9 deletions Parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(Bisonpp REQUIRED)
find_package(Flexpp REQUIRED)

set(BisonppOutput ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp)
set(BisonppOutput ${CMAKE_CURRENT_BINARY_DIR}/Parser_with_register.cpp)

add_custom_command(
OUTPUT
Expand All @@ -18,9 +18,8 @@ add_custom_command(
COMMENT "Generating Parser.cpp"
)

set(FlexppOutput ${CMAKE_CURRENT_BINARY_DIR}/Scanner.cpp)
set(FlexppOutput ${CMAKE_CURRENT_BINARY_DIR}/Scanner_with_register.cpp)

set(FlexppOutput Scanner.cpp)
add_custom_command(
OUTPUT ${FlexppOutput}
COMMAND ${FLEXPP_EXECUTABLE}
Expand All @@ -32,10 +31,40 @@ add_custom_command(
COMMENT "Generating Scanner.cpp"
)

# C++17 removes the 'register' keyword and it is no longer allowed to
# suppress the warning, so patch the generated scanner and parser files
# to remove the register keyword, and also patch embedded filename strings
# so they match the final file
set(ParserPatched ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp)
set(ScannerPatched ${CMAKE_CURRENT_BINARY_DIR}/Scanner.cpp)

add_custom_command(
OUTPUT ${ParserPatched}
COMMAND sed
-e "s/register //g"
-e "s/Parser_with_register/Parser/g"
${BisonppOutput} > ${ParserPatched}
DEPENDS ${BisonppOutput}
COMMENT "Patching Parser.cpp to remove register keyword"
)

add_custom_command(
OUTPUT ${ScannerPatched}
COMMAND sed
-e "s/register //g"
-e "s/Scanner_with_register/Scanner/g"
${FlexppOutput} > ${ScannerPatched}
DEPENDS ${FlexppOutput}
COMMENT "Patching Scanner.cpp to remove register keyword"
)

add_custom_target(ParserFiles DEPENDS ${BisonppOutput})
add_custom_target(ScannerFiles DEPENDS ${FlexppOutput})
add_custom_target(ScannerFiles DEPENDS ${FlexppOutput})

add_custom_target(PatchParser DEPENDS ${ParserPatched})
add_custom_target(PatchScanner DEPENDS ${ScannerPatched})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register -Wno-write-strings -Wno-unused-function -Wno-unused-label -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-function -Wno-unused-label -Wno-sign-compare")

set(parser_source_files
ParserNode.cpp
Expand All @@ -46,10 +75,10 @@ set(parser_source_files
${CMAKE_CURRENT_SOURCE_DIR}/../QueryEngine/DateTruncate.cpp
)

add_library(ParserGenerated ${BisonppOutput} ${FlexppOutput})
set_property(TARGET ParserGenerated PROPERTY CXX_STANDARD 14)

add_library(ParserGenerated ${ParserPatched} ${ScannerPatched})
add_library(Parser ${CMAKE_CURRENT_BINARY_DIR}/parser.h ${parser_source_files})
add_dependencies(Parser ParserFiles ScannerFiles)

add_dependencies(Parser PatchParser PatchScanner)

target_link_libraries(Parser ParserGenerated Shared QueryEngine Catalog DataMgr LockMgr)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

0 comments on commit 8b0622f

Please sign in to comment.