You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/08/01 22:59:59 UTC

[arrow] branch master updated: ARROW-6096: [C++] conditionally use boost regex for gcc < 4.9

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new e4febfb  ARROW-6096: [C++] conditionally use boost regex for gcc < 4.9
e4febfb is described below

commit e4febfb5802ea88606f53d8d378423f1dcea5dda
Author: Hatem Helal <hh...@mathworks.com>
AuthorDate: Thu Aug 1 17:59:50 2019 -0500

    ARROW-6096: [C++] conditionally use boost regex for gcc < 4.9
    
    I did a quick test of this on mac and verified that the parquet shared library no longer depends on the boost regex lib.
    
    Closes #4985 from hatemhelal/arrow-6096 and squashes the following commits:
    
    c88bb4e47 <Hatem Helal> remove boost regex dependency from libarrow
    6b8115301 <Hatem Helal> conditionally use boost regex for gcc < 4.9
    
    Authored-by: Hatem Helal <hh...@mathworks.com>
    Signed-off-by: Wes McKinney <we...@apache.org>
---
 cpp/CMakeLists.txt             |  6 ++----
 cpp/src/parquet/CMakeLists.txt |  7 ++++---
 cpp/src/parquet/metadata.cc    | 23 +++++++++++++++++------
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 15e7ebf..64e2e84 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -659,10 +659,9 @@ if(ARROW_STATIC_LINK_LIBS)
 endif()
 
 set(ARROW_SHARED_PRIVATE_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} ${BOOST_SYSTEM_LIBRARY}
-                                   ${BOOST_FILESYSTEM_LIBRARY} ${BOOST_REGEX_LIBRARY})
+                                   ${BOOST_FILESYSTEM_LIBRARY})
 
-list(APPEND ARROW_STATIC_LINK_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY}
-            ${BOOST_REGEX_LIBRARY})
+list(APPEND ARROW_STATIC_LINK_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY})
 
 list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS boost_system boost_filesystem boost_regex)
 
@@ -693,7 +692,6 @@ set(ARROW_TEST_SHARED_LINK_LIBS
     ${double-conversion_LIBRARIES}
     ${BOOST_SYSTEM_LIBRARY}
     ${BOOST_FILESYSTEM_LIBRARY}
-    ${BOOST_REGEX_LIBRARY}
     ${ARROW_TEST_LINK_TOOLCHAIN})
 
 if(NOT MSVC)
diff --git a/cpp/src/parquet/CMakeLists.txt b/cpp/src/parquet/CMakeLists.txt
index db00ab4..aa4ea6e 100644
--- a/cpp/src/parquet/CMakeLists.txt
+++ b/cpp/src/parquet/CMakeLists.txt
@@ -94,9 +94,10 @@ else()
 endif()
 
 set(PARQUET_BOOST_LINK_LIBS)
-list(APPEND PARQUET_BOOST_LINK_LIBS ${BOOST_REGEX_LIBRARY})
-if(MSVC)
-  list(APPEND PARQUET_BOOST_LINK_LIBS ${BOOST_SYSTEM_LIBRARY})
+
+if("${COMPILER_FAMILY}" STREQUAL "gcc" AND "${COMPILER_VERSION}" VERSION_LESS "4.9")
+  add_definitions(-DPARQUET_USE_BOOST_REGEX)
+  list(APPEND PARQUET_BOOST_LINK_LIBS ${BOOST_REGEX_LIBRARY})
 endif()
 
 set(PARQUET_MIN_TEST_LIBS GTest::Main GTest::GTest)
diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc
index 85073d1..bee818d 100644
--- a/cpp/src/parquet/metadata.cc
+++ b/cpp/src/parquet/metadata.cc
@@ -29,7 +29,18 @@
 #include "parquet/statistics.h"
 #include "parquet/thrift.h"
 
+// ARROW-6096: The boost regex library must be used when compiling with gcc < 4.9
+#if defined(PARQUET_USE_BOOST_REGEX)
 #include <boost/regex.hpp>  // IWYU pragma: keep
+using ::boost::regex;
+using ::boost::regex_match;
+using ::boost::smatch;
+#else
+#include <regex>
+using ::std::regex;
+using ::std::regex_match;
+using ::std::smatch;
+#endif
 
 namespace parquet {
 
@@ -520,16 +531,16 @@ ApplicationVersion::ApplicationVersion(const std::string& application, int major
     : application_(application), version{major, minor, patch, "", "", ""} {}
 
 ApplicationVersion::ApplicationVersion(const std::string& created_by) {
-  boost::regex app_regex{ApplicationVersion::APPLICATION_FORMAT};
-  boost::regex ver_regex{ApplicationVersion::VERSION_FORMAT};
-  boost::smatch app_matches;
-  boost::smatch ver_matches;
+  regex app_regex{ApplicationVersion::APPLICATION_FORMAT};
+  regex ver_regex{ApplicationVersion::VERSION_FORMAT};
+  smatch app_matches;
+  smatch ver_matches;
 
   std::string created_by_lower = created_by;
   std::transform(created_by_lower.begin(), created_by_lower.end(),
                  created_by_lower.begin(), ::tolower);
 
-  bool app_success = boost::regex_match(created_by_lower, app_matches, app_regex);
+  bool app_success = regex_match(created_by_lower, app_matches, app_regex);
   bool ver_success = false;
   std::string version_str;
 
@@ -538,7 +549,7 @@ ApplicationVersion::ApplicationVersion(const std::string& created_by) {
     application_ = app_matches[1];
     version_str = app_matches[3];
     build_ = app_matches[4];
-    ver_success = boost::regex_match(version_str, ver_matches, ver_regex);
+    ver_success = regex_match(version_str, ver_matches, ver_regex);
   } else {
     application_ = "unknown";
   }