mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
Do not require Boost for minimal C++ build
This commit is contained in:
1 parent
ad335f953b
commit
6f67a7eacf
9 files changed
+107
-49
No files matched your search
@@ -224,10 +224,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
define_option(ARROW_BOOST_USE_SHARED "Rely on boost shared libraries where relevant" ON)
|
||||
|
||||
define_option(ARROW_BOOST_VENDORED "Use vendored Boost instead of existing Boost. \
|
||||
Note that this requires linking Boost statically. \
|
||||
Deprecated. Use BOOST_SOURCE=BUNDLED instead." OFF)
|
||||
|
||||
define_option(ARROW_PROTOBUF_USE_SHARED
|
||||
"Rely on Protocol Buffers shared libraries where relevant" ON)
|
||||
|
||||
|
||||
@@ -112,12 +112,6 @@ if(ARROW_PACKAGE_PREFIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ARROW_BOOST_VENDORED AND "${BOOST_SOURCE}" STREQUAL "")
|
||||
message(
|
||||
DEPRECATION "ARROW_BOOST_VENDORED is deprecated. Use BOOST_SOURCE=BUNDLED instead.")
|
||||
set(BOOST_SOURCE "BUNDLED")
|
||||
endif()
|
||||
|
||||
# For each dependency, set dependency source to global default, if unset
|
||||
foreach(DEPENDENCY ${ARROW_THIRDPARTY_DEPENDENCIES})
|
||||
if("${${DEPENDENCY}_SOURCE}" STREQUAL "")
|
||||
@@ -615,36 +609,44 @@ set(Boost_ADDITIONAL_VERSIONS
|
||||
"1.60.0"
|
||||
"1.60")
|
||||
|
||||
if(BOOST_SOURCE STREQUAL "AUTO")
|
||||
find_package(BoostAlt ${ARROW_BOOST_REQUIRED_VERSION})
|
||||
if(NOT BoostAlt_FOUND)
|
||||
build_boost()
|
||||
endif()
|
||||
elseif(BOOST_SOURCE STREQUAL "BUNDLED")
|
||||
build_boost()
|
||||
elseif(BOOST_SOURCE STREQUAL "SYSTEM")
|
||||
find_package(BoostAlt ${ARROW_BOOST_REQUIRED_VERSION} REQUIRED)
|
||||
endif()
|
||||
|
||||
if(TARGET Boost::system)
|
||||
set(BOOST_SYSTEM_LIBRARY Boost::system)
|
||||
set(BOOST_FILESYSTEM_LIBRARY Boost::filesystem)
|
||||
set(BOOST_REGEX_LIBRARY Boost::regex)
|
||||
elseif(BoostAlt_FOUND)
|
||||
set(BOOST_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY})
|
||||
set(BOOST_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY})
|
||||
set(BOOST_REGEX_LIBRARY ${Boost_REGEX_LIBRARY})
|
||||
if(ARROW_BUILD_INTEGRATION OR ARROW_BUILD_TESTS OR ARROW_HDFS OR ARROW_PARQUET)
|
||||
set(ARROW_BOOST_REQUIRED TRUE)
|
||||
else()
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system_static)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem_static)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex_static)
|
||||
set(ARROW_BOOST_REQUIRED FALSE)
|
||||
endif()
|
||||
set(ARROW_BOOST_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY})
|
||||
|
||||
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIR}")
|
||||
message(STATUS "Boost libraries: ${ARROW_BOOST_LIBS}")
|
||||
if(ARROW_BOOST_REQUIRED)
|
||||
if(BOOST_SOURCE STREQUAL "AUTO")
|
||||
find_package(BoostAlt ${ARROW_BOOST_REQUIRED_VERSION})
|
||||
if(NOT BoostAlt_FOUND)
|
||||
build_boost()
|
||||
endif()
|
||||
elseif(BOOST_SOURCE STREQUAL "BUNDLED")
|
||||
build_boost()
|
||||
elseif(BOOST_SOURCE STREQUAL "SYSTEM")
|
||||
find_package(BoostAlt ${ARROW_BOOST_REQUIRED_VERSION} REQUIRED)
|
||||
endif()
|
||||
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
|
||||
if(TARGET Boost::system)
|
||||
set(BOOST_SYSTEM_LIBRARY Boost::system)
|
||||
set(BOOST_FILESYSTEM_LIBRARY Boost::filesystem)
|
||||
set(BOOST_REGEX_LIBRARY Boost::regex)
|
||||
elseif(BoostAlt_FOUND)
|
||||
set(BOOST_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY})
|
||||
set(BOOST_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY})
|
||||
set(BOOST_REGEX_LIBRARY ${Boost_REGEX_LIBRARY})
|
||||
else()
|
||||
set(BOOST_SYSTEM_LIBRARY boost_system_static)
|
||||
set(BOOST_FILESYSTEM_LIBRARY boost_filesystem_static)
|
||||
set(BOOST_REGEX_LIBRARY boost_regex_static)
|
||||
endif()
|
||||
set(ARROW_BOOST_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY})
|
||||
|
||||
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIR}")
|
||||
message(STATUS "Boost libraries: ${ARROW_BOOST_LIBS}")
|
||||
|
||||
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Google double-conversion
|
||||
|
||||
@@ -23,4 +23,4 @@ RUN apt-get update -y -q && \
|
||||
apt-get install -y -q --no-install-recommends \
|
||||
build-essential \
|
||||
cmake && \
|
||||
apt-get clean && rm -rf /var/lib/apt/lists*
|
||||
apt-get clean && rm -rf /var/lib/apt/lists*
|
||||
@@ -27,8 +27,7 @@ NPROC=$(nproc)
|
||||
mkdir $BUILD_DIR
|
||||
pushd $BUILD_DIR
|
||||
|
||||
cmake /arrow/cpp -DBOOST_SOURCE=BUNDLED \
|
||||
-DARROW_BOOST_USE_SHARED=OFF \
|
||||
cmake /arrow/cpp \
|
||||
-DARROW_COMPUTE=OFF \
|
||||
-DARROW_DATASET=OFF \
|
||||
-DARROW_FILESYSTEM=OFF \
|
||||
|
||||
@@ -39,6 +39,7 @@ add_arrow_test(utility-test
|
||||
parsing_util_test.cc
|
||||
range_test.cc
|
||||
stl_util_test.cc
|
||||
string_test.cc
|
||||
trie_test.cc
|
||||
utf8_util_test.cc)
|
||||
|
||||
|
||||
@@ -38,9 +38,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
@@ -49,9 +46,8 @@
|
||||
#include <string>
|
||||
|
||||
#include "arrow/util/logging.h"
|
||||
#include "arrow/util/string.h"
|
||||
|
||||
using boost::algorithm::contains;
|
||||
using boost::algorithm::trim;
|
||||
using std::max;
|
||||
|
||||
#if defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR < 5
|
||||
@@ -87,7 +83,7 @@ namespace {
|
||||
int64_t ParseCPUFlags(const std::string& values) {
|
||||
int64_t flags = 0;
|
||||
for (int i = 0; i < num_flags; ++i) {
|
||||
if (contains(values, flag_mappings[i].name)) {
|
||||
if (values.find(flag_mappings[i].name) != std::string::npos) {
|
||||
flags |= flag_mappings[i].flag;
|
||||
}
|
||||
}
|
||||
@@ -224,10 +220,8 @@ void CpuInfo::Init() {
|
||||
getline(cpuinfo, line);
|
||||
size_t colon = line.find(':');
|
||||
if (colon != std::string::npos) {
|
||||
name = line.substr(0, colon - 1);
|
||||
value = line.substr(colon + 1, std::string::npos);
|
||||
trim(name);
|
||||
trim(value);
|
||||
name = TrimString(line.substr(0, colon - 1));
|
||||
value = TrimString(line.substr(colon + 1, std::string::npos));
|
||||
if (name.compare("flags") == 0) {
|
||||
hardware_flags_ |= ParseCPUFlags(value);
|
||||
} else if (name.compare("cpu MHz") == 0) {
|
||||
|
||||
@@ -87,4 +87,24 @@ Status ParseHexValue(const char* data, uint8_t* out) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
constexpr bool IsWhitespace(char c) { return c == ' ' || c == '\t'; }
|
||||
|
||||
std::string TrimString(std::string value) {
|
||||
size_t ltrim_chars = 0;
|
||||
while (ltrim_chars < value.size() && IsWhitespace(value[ltrim_chars])) {
|
||||
++ltrim_chars;
|
||||
}
|
||||
value.erase(0, ltrim_chars);
|
||||
size_t rtrim_chars = 0;
|
||||
while (rtrim_chars < value.size() &&
|
||||
IsWhitespace(value[value.size() - 1 - rtrim_chars])) {
|
||||
++rtrim_chars;
|
||||
}
|
||||
value.erase(value.size() - rtrim_chars, rtrim_chars);
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace arrow
|
||||
@@ -38,4 +38,11 @@ ARROW_EXPORT std::string Escape(util::string_view str);
|
||||
|
||||
ARROW_EXPORT Status ParseHexValue(const char* data, uint8_t* out);
|
||||
|
||||
namespace internal {
|
||||
|
||||
/// \brief Trim whitespace from left and right sides of string
|
||||
ARROW_EXPORT
|
||||
std::string TrimString(std::string value);
|
||||
|
||||
} // namespace internal
|
||||
} // namespace arrow
|
||||
@@ -0,0 +1,39 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "arrow/util/string.h"
|
||||
|
||||
namespace arrow {
|
||||
namespace internal {
|
||||
|
||||
TEST(Trim, Basics) {
|
||||
std::vector<std::pair<std::string, std::string>> test_cases = {
|
||||
{"", ""}, {" ", ""}, {" ", ""}, {"\t ", ""},
|
||||
{" \ta\t ", "a"}, {" \ta", "a"}, {"ab \t", "ab"}};
|
||||
for (auto case_ : test_cases) {
|
||||
EXPECT_EQ(case_.second, TrimString(case_.first));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace arrow
|
||||
Reference in new issue
Block a user