diff --git a/ports/libtorrent/CONTROL b/ports/libtorrent/CONTROL index 08964ba96b..645b8f84bf 100644 --- a/ports/libtorrent/CONTROL +++ b/ports/libtorrent/CONTROL @@ -1,5 +1,23 @@ Source: libtorrent -Version: 1.2.2-1 +Version: 1.2.6 Homepage: https://github.com/arvidn/libtorrent -Description: An efficient feature complete C++ BitTorrent implementation +Description: An efficient feature complete C++ BitTorrent implementation Build-Depends: openssl, boost-system, boost-date-time, boost-chrono, boost-random, boost-asio, boost-crc, boost-config, boost-iterator, boost-scope-exit, boost-multiprecision +Supports: !uwp + +Feature: deprfun +Description: build with deprecated functions enabled + +Feature: examples +Description: build the examples in the examples directory + +Feature: python +Build-Depends: boost-python, libtorrent[deprfun] +Description: build the python bindings in bindings/python directory + +Feature: test +Build-Depends: libtorrent[deprfun] +Description: build the libtorrent tests + +Feature: tools +Description: build the tools in the tools directory diff --git a/ports/libtorrent/add-datetime-to-boost-libs.patch b/ports/libtorrent/add-datetime-to-boost-libs.patch index 1ec65a8f5f..1ef09021a8 100644 --- a/ports/libtorrent/add-datetime-to-boost-libs.patch +++ b/ports/libtorrent/add-datetime-to-boost-libs.patch @@ -1,16 +1,16 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 944602b..9d95446 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -678,9 +678,9 @@ else() - endif() - - # Boost --find_public_dependency(Boost REQUIRED COMPONENTS system) -+find_public_dependency(Boost REQUIRED COMPONENTS system date_time) - target_include_directories(torrent-rasterbar PUBLIC ${Boost_INCLUDE_DIRS}) --target_link_libraries(torrent-rasterbar PUBLIC ${Boost_SYSTEM_LIBRARY}) -+target_link_libraries(torrent-rasterbar PUBLIC ${Boost_LIBRARIES}) - - if (exceptions) - if (MSVC) +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4f329339f..36f033b92 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -672,9 +672,9 @@ else() + endif() + + # Boost +-find_public_dependency(Boost REQUIRED COMPONENTS system) ++find_public_dependency(Boost REQUIRED COMPONENTS system date_time) + target_include_directories(torrent-rasterbar PUBLIC ${Boost_INCLUDE_DIRS}) +-target_link_libraries(torrent-rasterbar PUBLIC ${Boost_SYSTEM_LIBRARY}) ++target_link_libraries(torrent-rasterbar PUBLIC ${Boost_LIBRARIES}) + + if (exceptions) + if (MSVC) diff --git a/ports/libtorrent/add-executor_type.patch b/ports/libtorrent/add-executor_type.patch deleted file mode 100644 index 2d2a36c491..0000000000 --- a/ports/libtorrent/add-executor_type.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/include/libtorrent/aux_/socket_type.hpp b/include/libtorrent/aux_/socket_type.hpp -index 1342d39ad..364ec1e8f 100644 ---- a/include/libtorrent/aux_/socket_type.hpp -+++ b/include/libtorrent/aux_/socket_type.hpp -@@ -184,6 +184,9 @@ namespace aux { - using receive_buffer_size = tcp::socket::receive_buffer_size; - using send_buffer_size = tcp::socket::send_buffer_size; - -+#if BOOST_VERSION >= 106600 -+ using executor_type = tcp::socket::executor_type; -+#endif - explicit socket_type(io_service& ios): m_io_service(ios), m_type(0) {} - ~socket_type(); - diff --git a/ports/libtorrent/fix_python_cmake.patch b/ports/libtorrent/fix_python_cmake.patch new file mode 100644 index 0000000000..942b8e3b8a --- /dev/null +++ b/ports/libtorrent/fix_python_cmake.patch @@ -0,0 +1,130 @@ +diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt +index 0b9b3ebe7..74e608901 100644 +--- a/bindings/python/CMakeLists.txt ++++ b/bindings/python/CMakeLists.txt +@@ -1,7 +1,6 @@ + # To build python bindings we need a python executable and boost python module. Unfortunately, + # their names might not be interlinked and we can not implement a general solution. +-# The code below assumes default boost installation, when the module for python 2 is named +-# 'python' and the module for python 3 is named 'python3'. ++# The code below assumes default boost installation, when the module for python 3 is named 'python3'. + # To customize that one can provide a name for the Boost::python module via + # 'boost-python-module-name' variable when invoking cmake. + # E.g. on Gentoo with python 3.6 and Boost::python library name 'libboost_python-3.6.so' +@@ -15,12 +14,9 @@ + # Sets _ret to a list of python versions (major.minor) that use the same MSVC runtime as this build does + # assumes MSVC was detected already + # See https://en.wikipedia.org/wiki/Microsoft_Visual_C++#Internal_version_numbering ++# See https://devguide.python.org/#status-of-python-branches for supported python versions + function(_get_compatible_python_versions _ret) +- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16) +- list(APPEND _tmp 2.6 2.7 3.0 3.1 3.2) +- elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17) +- list(APPEND _tmp 3.3 3.4) +- elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 20) ++ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 20) + list(APPEND _tmp 3.5 3.6 3.7 3.8) + endif() + set(${_ret} ${_tmp} PARENT_SCOPE) +@@ -31,31 +27,26 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" AND NOT skip-python-runtime-test) + _get_compatible_python_versions(Python_ADDITIONAL_VERSIONS) + endif() + +-find_package(PythonInterp REQUIRED) ++find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" AND NOT skip-python-runtime-test) +- message(STATUS "Testing found python version. Requested: ${Python_ADDITIONAL_VERSIONS}, found: ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") +- if (NOT "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" IN_LIST Python_ADDITIONAL_VERSIONS) +- message(FATAL_ERROR "Incompatible Python and C runtime: MSVC ${CMAKE_CXX_COMPILER_VERSION} and Python ${PYTHON_VERSION_STRING}") ++ message(STATUS "Testing found python version. Requested: ${Python_ADDITIONAL_VERSIONS}, found: ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") ++ if (NOT "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}" IN_LIST Python_ADDITIONAL_VERSIONS) ++ message(FATAL_ERROR "Incompatible Python and C runtime: MSVC ${CMAKE_CXX_COMPILER_VERSION} and Python ${Python3_VERSION}") + endif() + endif() + +-set(Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") +-find_package(PythonLibs REQUIRED) ++set(Python_ADDITIONAL_VERSIONS "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}") + + if (NOT boost-python-module-name) + # use active python +- if (PYTHON_VERSION_STRING VERSION_GREATER_EQUAL "3") +- set(_boost-python-module-name "python${PYTHON_VERSION_MAJOR}") +- else() +- set(_boost-python-module-name "python") # to overwrite possible value from a previous run +- endif() ++ set(_boost-python-module-name "python${Python3_VERSION_MAJOR}") + endif() + + set(boost-python-module-name ${_boost-python-module-name} CACHE STRING "Boost:python module name, e.g. 'pythom-3.6'") + + find_package(Boost REQUIRED COMPONENTS ${boost-python-module-name}) + +-python_add_module(python-libtorrent ++Python3_add_library(python-libtorrent STATIC + src/module.cpp + src/sha1_hash.cpp + src/converters.cpp +@@ -80,12 +71,12 @@ python_add_module(python-libtorrent + + set_target_properties(python-libtorrent + PROPERTIES +- OUTPUT_NAME libtorrent ++ OUTPUT_NAME torrent + ) + + target_include_directories(python-libtorrent + PRIVATE +- ${PYTHON_INCLUDE_DIRS} ++ ${Python3_INCLUDE_DIRS} + ) + + string(TOUPPER "${boost-python-module-name}" boost_python_module_name_uppercase) +@@ -96,7 +87,7 @@ target_link_libraries(python-libtorrent + # Boost::python adds that but without a path to the library. Therefore we have to either + # provide the path (but, unfortunately, FindPythonLibs.cmake does not return the library dir), + # or give the full file name here (this FindPythonLibs.cmake provides to us). +- ${PYTHON_LIBRARIES} ++ ${Python3_LIBRARIES} + ) + + # Bindings module uses deprecated libtorrent features, thus we disable these warnings +@@ -108,7 +99,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + endif() + + execute_process(COMMAND +- ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; ++ ${Python3_EXECUTABLE} -c "import distutils.sysconfig; + print(';'.join(map(str, [ + distutils.sysconfig.get_python_lib(plat_specific=True, prefix=''), + distutils.sysconfig.get_config_var('EXT_SUFFIX') +@@ -119,13 +110,11 @@ list(GET _python_sysconfig_vars 0 PYTHON_SITE_PACKAGES) + list(GET _python_sysconfig_vars 1 PYTHON_EXT_SUFFIX) + + message(STATUS "Python site packages: ${PYTHON_SITE_PACKAGES}") +-# python 2 does not provide the 'EXT_SUFFIX' sysconfig variable, so we use cmake default then +-if (NOT "${PYTHON_EXT_SUFFIX}" STREQUAL "None") +- message(STATUS "Python extension suffix: ${PYTHON_EXT_SUFFIX}") +- # we mimic the name, created by setuptools +- # example: libtorrent.cpython-36m-x86_64-linux-gnu.so +- set_target_properties(python-libtorrent PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX}) +-endif() ++ ++message(STATUS "Python extension suffix: ${PYTHON_EXT_SUFFIX}") ++# we mimic the name, created by setuptools ++# example: libtorrent.cpython-36m-x86_64-linux-gnu.so ++set_target_properties(python-libtorrent PROPERTIES SUFFIX ${PYTHON_EXT_SUFFIX}) + + set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake.in") + set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py") +@@ -135,8 +124,8 @@ set(DEPS python-libtorrent "${SETUP_PY}") + configure_file(${SETUP_PY_IN} ${SETUP_PY} @ONLY) + + add_custom_command(OUTPUT ${OUTPUT} +- COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} build -b "${CMAKE_CURRENT_SOURCE_DIR}" +- COMMAND ${PYTHON_EXECUTABLE} ${SETUP_PY} egg_info -b "${CMAKE_CURRENT_SOURCE_DIR}" ++ COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} build -b "${CMAKE_CURRENT_SOURCE_DIR}" ++ COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} egg_info -b "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS ${DEPS}) + diff --git a/ports/libtorrent/portfile.cmake b/ports/libtorrent/portfile.cmake index 3dbf7750e3..0b0cfc8e82 100644 --- a/ports/libtorrent/portfile.cmake +++ b/ports/libtorrent/portfile.cmake @@ -1,21 +1,60 @@ -include(vcpkg_common_functions) +vcpkg_fail_port_install(ON_TARGET "uwp") + +if(VCPKG_TARGET_IS_WINDOWS) + # Building python bindings is currently broken on Windows + if("python" IN_LIST FEATURES) + message(FATAL_ERROR "The python feature is currently broken on Windows") + endif() + + # Ensure OPENSSL_USE_STATIC_LIBS is set to ON + # when statically linking against OpenSSL on Windows. + # Also ensure "static_runtime" will be used when statically linking against the runtime. + # Prevents OpenSSL crypt32.lib linking errors. + if(VCPKG_CRT_LINKAGE STREQUAL "static") + set(LIBTORRENT_STATIC_RUNTIME ON) + elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + set(_OPENSSL_USE_STATIC_LIBS ON) + endif() +endif() + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + deprfun deprecated-functions + examples build_examples + python python-bindings + test build_tests + tools build_tools +) + +# Note: the python feature currently requires `python3-dev` and `python3-setuptools` installed on the system +if("python" IN_LIST FEATURES) + vcpkg_find_acquire_program(PYTHON3) + get_filename_component(PYTHON3_PATH ${PYTHON3} DIRECTORY) + vcpkg_add_to_path(${PYTHON3_PATH}) + + file(GLOB BOOST_PYTHON_LIB "${CURRENT_INSTALLED_DIR}/lib/*boost_python*") + string(REGEX REPLACE ".*(python)([0-9])([0-9]+).*" "\\1\\2\\3" BOOST_PYTHON_MODULE "${BOOST_PYTHON_LIB}") +endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO arvidn/libtorrent - REF libtorrent-1_2_2 - SHA512 34dcf5421dfccbba78bdd30890b9c18b92fdee1a2e1693ada9b55b79a167730093862017581b9251a654b5517011dbe4c46b520b03b78aa86a909457f7edcf2c + REF libtorrent-1_2_6 + SHA512 9f03e28449b08e18a98a1f1bf0571f470c56fabd2becde5bde56ad566611c8519b0b387939f285a552d1f0382446633b67d00b6b5ff7083e4d1420a3ce9232fc HEAD_REF master PATCHES add-datetime-to-boost-libs.patch - add-executor_type.patch + fix_python_cmake.patch ) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA # Disable this option if project cannot be built with Ninja OPTIONS - -Ddeprecated-functions=off + ${FEATURE_OPTIONS} + -Dboost-python-module-name=${BOOST_PYTHON_MODULE} + -Dstatic_runtime=${LIBTORRENT_STATIC_RUNTIME} + -DOPENSSL_USE_STATIC_LIBS=${_OPENSSL_USE_STATIC_LIBS} + -DPython3_USE_STATIC_LIBS=ON ) vcpkg_install_cmake() @@ -32,8 +71,7 @@ file(WRITE ${CURRENT_PACKAGES_DIR}/include/libtorrent/aux_/export.hpp "${EXPORT_ vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/LibtorrentRasterbar TARGET_PATH share/libtorrentrasterbar) # Handle copyright -file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libtorrent) -file(RENAME ${CURRENT_PACKAGES_DIR}/share/libtorrent/LICENSE ${CURRENT_PACKAGES_DIR}/share/libtorrent/copyright) +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) # Do not duplicate include files file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/share ${CURRENT_PACKAGES_DIR}/share/cmake)