Skip to content

Commit

Permalink
set back folly
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippGrulich committed Jan 30, 2023
1 parent be22af1 commit 76b389c
Show file tree
Hide file tree
Showing 11 changed files with 317 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vcpkg-registry/ports/folly/FindLZ4.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find_path(LZ4_INCLUDE_DIR lz4.h)

find_library(LZ4_LIBRARY_DEBUG NAMES lz4d)
find_library(LZ4_LIBRARY_RELEASE NAMES lz4)

include(SelectLibraryConfigurations)
select_library_configurations(LZ4)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
LZ4 DEFAULT_MSG
LZ4_LIBRARY LZ4_INCLUDE_DIR
)
13 changes: 13 additions & 0 deletions vcpkg-registry/ports/folly/FindSnappy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
find_path(SNAPPY_INCLUDE_DIR snappy.h)

find_library(SNAPPY_LIBRARY_DEBUG NAMES snappyd)
find_library(SNAPPY_LIBRARY_RELEASE NAMES snappy)

include(SelectLibraryConfigurations)
select_library_configurations(SNAPPY)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
SNAPPY DEFAULT_MSG
SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR
)
22 changes: 22 additions & 0 deletions vcpkg-registry/ports/folly/boost-1.70.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/folly/portability/PThread.cpp b/folly/portability/PThread.cpp
index 2126ec0..ef82ade 100644
--- a/folly/portability/PThread.cpp
+++ b/folly/portability/PThread.cpp
@@ -20,6 +20,8 @@
#include <boost/thread/exceptions.hpp>
#include <boost/thread/tss.hpp>
#include <boost/version.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/thread_only.hpp>

#include <errno.h>

@@ -691,7 +693,7 @@ int pthread_setspecific(pthread_key_t key, const void* value) {
boost::detail::thread::cleanup_caller_t(),
boost::detail::thread::cleanup_func_t(),
#else
- boost::shared_ptr<boost::detail::tss_cleanup_function>(),
+ 0,0,
#endif
const_cast<void*>(value),
false);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
diff --git a/folly/portability/Windows.h b/folly/portability/Windows.h
index 86fd0f9..ccad11e 100644
--- a/folly/portability/Windows.h
+++ b/folly/portability/Windows.h
@@ -32,24 +32,17 @@
// disabled to ensure all of the normal names get declared properly.
#include <stdio.h>

-#ifndef __STDC__
-/* nolint */
-#define __STDC__ 1
#pragma push_macro("_CRT_DECLARE_NONSTDC_NAMES")
#ifdef _CRT_DECLARE_NONSTDC_NAMES
#undef _CRT_DECLARE_NONSTDC_NAMES
#endif
+
+#include <corecrt.h>
#pragma push_macro("_CRT_INTERNAL_NONSTDC_NAMES")
-#undef _CRT_INTERNAL_NONSTDC_NAMES
-#include <direct.h> // @manual nolint
-#include <io.h> // @manual nolint
-#undef __STDC__
+#define _CRT_INTERNAL_NONSTDC_NAMES 0
+#include <direct.h>
+#include <io.h>
#pragma pop_macro("_CRT_INTERNAL_NONSTDC_NAMES")
-#pragma pop_macro("_CRT_DECLARE_NONSTDC_NAMES")
-#else
-#include <direct.h> // @manual nolint
-#include <io.h> // @manual nolint
-#endif

#if defined(min) || defined(max)
#error Windows.h needs to be included by this header, or else NOMINMAX needs \
13 changes: 13 additions & 0 deletions vcpkg-registry/ports/folly/fix-musl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/folly/experimental/symbolizer/Elf.cpp b/folly/experimental/symbolizer/Elf.cpp
index cbd0feec8..8e7454082 100644
--- a/folly/experimental/symbolizer/Elf.cpp
+++ b/folly/experimental/symbolizer/Elf.cpp
@@ -38,7 +38,7 @@

#if defined(__ELF_NATIVE_CLASS)
#define FOLLY_ELF_NATIVE_CLASS __ELF_NATIVE_CLASS
-#elif defined(__FreeBSD__)
+#else
#if defined(__LP64__)
#define FOLLY_ELF_NATIVE_CLASS 64
#else
12 changes: 12 additions & 0 deletions vcpkg-registry/ports/folly/fix-windows-minmax.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/CMake/FollyCompilerMSVC.cmake b/CMake/FollyCompilerMSVC.cmake
index ec2ce1a1d..16deda71c 100644
--- a/CMake/FollyCompilerMSVC.cmake
+++ b/CMake/FollyCompilerMSVC.cmake
@@ -289,6 +289,7 @@ function(apply_folly_compile_options_to_target THETARGET)
# And the extra defines:
target_compile_definitions(${THETARGET}
PUBLIC
+ NOMINMAX
_CRT_NONSTDC_NO_WARNINGS # Don't deprecate posix names of functions.
_CRT_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps.
_SCL_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps.
95 changes: 95 additions & 0 deletions vcpkg-registry/ports/folly/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
if (VCPKG_TARGET_IS_WINDOWS)
vcpkg_fail_port_install(ON_TARGET "UWP" ON_ARCH "x86" "arm" "arm64")
else()
vcpkg_fail_port_install(ON_ARCH "x86" "arm")
endif()

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

# Required to run build/generate_escape_tables.py et al.
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO nebulastream/folly
REF dd3a8a099582982999e6b1f31267a0a7d2919b27
SHA512 56111217bb9a03c28f17e4912b64025b988c2dbe64a2eef1f197a28e84ded8796cedab2189901b0d5c7c8ef1a28a44cb11e984a1128f5df2cea2400229145cea
#HEAD_REF main
PATCHES
reorder-glog-gflags.patch
disable-non-underscore-posix-names.patch
boost-1.70.patch
fix-windows-minmax.patch
fix-musl.patch
)

file(COPY
"${CMAKE_CURRENT_LIST_DIR}/FindLZ4.cmake"
"${CMAKE_CURRENT_LIST_DIR}/FindSnappy.cmake"
DESTINATION "${SOURCE_PATH}/CMake/"
)
file(REMOVE "${SOURCE_PATH}/CMake/FindGFlags.cmake")

string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" MSVC_USE_STATIC_RUNTIME)

set(FEATURE_OPTIONS)

macro(feature FEATURENAME PACKAGENAME)
if("${FEATURENAME}" IN_LIST FEATURES)
list(APPEND FEATURE_OPTIONS -DCMAKE_DISABLE_FIND_PACKAGE_${PACKAGENAME}=OFF)
else()
list(APPEND FEATURE_OPTIONS -DCMAKE_DISABLE_FIND_PACKAGE_${PACKAGENAME}=ON)
endif()
endmacro()

feature(zlib ZLIB)
feature(bzip2 BZip2)
feature(lzma LibLZMA)
feature(lz4 LZ4)
feature(zstd Zstd)
feature(snappy Snappy)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DMSVC_USE_STATIC_RUNTIME=${MSVC_USE_STATIC_RUNTIME}
-DCMAKE_DISABLE_FIND_PACKAGE_LibDwarf=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Libiberty=ON
-DCMAKE_DISABLE_FIND_PACKAGE_LibAIO=ON
-DLIBAIO_FOUND=OFF
-DLIBURCU_FOUND=OFF
-DCMAKE_DISABLE_FIND_PACKAGE_LibURCU=ON
-DCMAKE_INSTALL_DIR=share/folly
${FEATURE_OPTIONS}
)

vcpkg_cmake_install(ADD_BIN_TO_PATH)

vcpkg_copy_pdbs()

vcpkg_cmake_config_fixup()

# Release folly-targets.cmake does not link to the right libraries in debug mode.
# We substitute with generator expressions so that the right libraries are linked for debug and release.
set(FOLLY_TARGETS_CMAKE "${CURRENT_PACKAGES_DIR}/share/folly/folly-targets.cmake")
FILE(READ ${FOLLY_TARGETS_CMAKE} _contents)
STRING(REPLACE "\${_IMPORT_PREFIX}/lib/zlib.lib" "ZLIB::ZLIB" _contents "${_contents}")
STRING(REPLACE "\${_IMPORT_PREFIX}/lib/" "\${_IMPORT_PREFIX}/\$<\$<CONFIG:DEBUG>:debug/>lib/" _contents "${_contents}")
STRING(REPLACE "\${_IMPORT_PREFIX}/debug/lib/" "\${_IMPORT_PREFIX}/\$<\$<CONFIG:DEBUG>:debug/>lib/" _contents "${_contents}")
STRING(REPLACE "-vc140-mt.lib" "-vc140-mt\$<\$<CONFIG:DEBUG>:-gd>.lib" _contents "${_contents}")
FILE(WRITE ${FOLLY_TARGETS_CMAKE} "${_contents}")
FILE(READ ${CURRENT_PACKAGES_DIR}/share/folly/folly-config.cmake _contents)
FILE(WRITE ${CURRENT_PACKAGES_DIR}/share/folly/folly-config.cmake
"include(CMakeFindDependencyMacro)
find_dependency(Threads)
find_dependency(glog CONFIG)
find_dependency(gflags CONFIG REQUIRED)
find_dependency(ZLIB)
${_contents}")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
28 changes: 28 additions & 0 deletions vcpkg-registry/ports/folly/reorder-glog-gflags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/CMake/folly-deps.cmake b/CMake/folly-deps.cmake
index 92b8ce7..04589ed 100644
--- a/CMake/folly-deps.cmake
+++ b/CMake/folly-deps.cmake
@@ -52,6 +52,11 @@ find_package(DoubleConversion MODULE REQUIRED)
list(APPEND FOLLY_LINK_LIBRARIES ${DOUBLE_CONVERSION_LIBRARY})
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${DOUBLE_CONVERSION_INCLUDE_DIR})

+find_package(Glog CONFIG REQUIRED)
+set(FOLLY_HAVE_LIBGLOG ${GLOG_FOUND})
+list(APPEND FOLLY_LINK_LIBRARIES glog::glog)
+list(APPEND FOLLY_INCLUDE_DIRECTORIES ${GLOG_INCLUDE_DIR})
+
find_package(Gflags MODULE)
set(FOLLY_HAVE_LIBGFLAGS ${LIBGFLAGS_FOUND})
if(LIBGFLAGS_FOUND)
@@ -61,11 +66,6 @@ if(LIBGFLAGS_FOUND)
set(FOLLY_LIBGFLAGS_INCLUDE ${LIBGFLAGS_INCLUDE_DIR})
endif()

-find_package(Glog MODULE)
-set(FOLLY_HAVE_LIBGLOG ${GLOG_FOUND})
-list(APPEND FOLLY_LINK_LIBRARIES ${GLOG_LIBRARY})
-list(APPEND FOLLY_INCLUDE_DIRECTORIES ${GLOG_INCLUDE_DIR})
-
find_package(LibEvent MODULE REQUIRED)
list(APPEND FOLLY_LINK_LIBRARIES ${LIBEVENT_LIB})
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LIBEVENT_INCLUDE_DIR})
77 changes: 77 additions & 0 deletions vcpkg-registry/ports/folly/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"name": "folly",
"version-string": "2021.10.11.00",
"description": "An open-source C++ library developed and used at Facebook. The library is UNSTABLE on Windows",
"homepage": "https://github.com/facebook/folly",
"supports": "x64 | (arm64 & !windows)",
"dependencies": [
"boost-chrono",
"boost-context",
"boost-conversion",
"boost-crc",
"boost-date-time",
"boost-filesystem",
"boost-multi-index",
"boost-program-options",
"boost-regex",
"boost-smart-ptr",
"boost-system",
"boost-thread",
"double-conversion",
"fmt",
"gflags",
"glog",
"libevent",
"libsodium",
"openssl",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"default-features": [
"zlib"
],
"features": {
"bzip2": {
"description": "Support bzip2 for compression",
"dependencies": [
"bzip2"
]
},
"lz4": {
"description": "Support lz4 for compression",
"dependencies": [
"lz4"
]
},
"lzma": {
"description": "Support LZMA for compression",
"dependencies": [
"liblzma"
]
},
"snappy": {
"description": "Support Snappy for compression",
"dependencies": [
"snappy"
]
},
"zlib": {
"description": "Support zlib for compression",
"dependencies": [
"zlib"
]
},
"zstd": {
"description": "Support zstd for compression",
"dependencies": [
"zstd"
]
}
}
}
1 change: 1 addition & 0 deletions vcpkg-registry/versions/baseline.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"default": {
"folly": { "baseline": "2021.10.11.00", "port-version": 0 },
"jemalloc-nes": { "baseline": "5.2.1", "port-version": 0 },
"oatpp": { "baseline": "1.3.0", "port-version": 0 }
}
Expand Down
9 changes: 9 additions & 0 deletions vcpkg-registry/versions/f/folly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "",
"version-string": "2021.10.11.00",
"port-version": 0
}
]
}

0 comments on commit 76b389c

Please sign in to comment.