Skip to content

Commit

Permalink
Add port for Rasterbar-libtorrent.
Browse files Browse the repository at this point in the history
  • Loading branch information
vktr committed Jul 9, 2017
1 parent 0afe111 commit 26cf1a8
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ports/libtorrent/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Source: libtorrent
Version: 1.1.4
Description: An efficient feature complete C++ BitTorrent implementation
Build-Depends: boost, openssl
13 changes: 13 additions & 0 deletions ports/libtorrent/add-datetime-to-boost-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 340e38f..1963d90 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -258,7 +258,7 @@ endif()

# Boost
if(NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
- FIND_PACKAGE(Boost REQUIRED COMPONENTS system chrono random)
+ FIND_PACKAGE(Boost REQUIRED COMPONENTS system date_time chrono random)
endif()
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
13 changes: 13 additions & 0 deletions ports/libtorrent/add-dbghelp-to-win32-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1963d90..99698a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -267,7 +267,7 @@ target_link_libraries(torrent-rasterbar ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_I
#add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -D__USE_W32_SOCKETS -DWIN32_LEAN_AND_MEAN )

if (WIN32)
- target_link_libraries(torrent-rasterbar wsock32 ws2_32 Iphlpapi)
+ target_link_libraries(torrent-rasterbar wsock32 ws2_32 Iphlpapi dbghelp)
add_definitions(-D_WIN32_WINNT=0x0600)
# prevent winsock1 to be included
add_definitions(-DWIN32_LEAN_AND_MEAN)
58 changes: 58 additions & 0 deletions ports/libtorrent/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Common Ambient Variables:
# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT}
# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET}
# CURRENT_PORT_DIR = ${VCPKG_ROOT_DIR}\ports\${PORT}
# PORT = current port name (zlib, etc)
# TARGET_TRIPLET = current triplet (x86-windows, x64-windows-static, etc)
# VCPKG_CRT_LINKAGE = C runtime linkage type (static, dynamic)
# VCPKG_LIBRARY_LINKAGE = target library linkage type (static, dynamic)
# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg>
# VCPKG_TARGET_ARCHITECTURE = target architecture (x64, x86, arm)
#

include(vcpkg_common_functions)
set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libtorrent-libtorrent-1_1_4)
vcpkg_download_distfile(ARCHIVE
URLS "https://github.com/arvidn/libtorrent/archive/libtorrent-1_1_4.zip"
FILENAME "libtorrent-1_1_4.zip"
SHA512 fd3b875c9626721db9b3e719ce50deeb6f39a030df1e23dd421d0b142aac9c3bb7bee3a61f0c18bb30f85d4dd6131fe90d6138c09ba598f09230824f8d5a3fb1
)

vcpkg_extract_source_archive(${ARCHIVE})

vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES ${CMAKE_CURRENT_LIST_DIR}/add-datetime-to-boost-libs.patch
PATCHES ${CMAKE_CURRENT_LIST_DIR}/add-dbghelp-to-win32-libs.patch
)

if (NOT VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
message(FATAL_ERROR "Only dynamic linking supported.")
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
OPTIONS
-Ddeprecated-functions=off
)

vcpkg_install_cmake()

if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
# Put shared libraries into the proper directory
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/bin)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/debug/bin)

file(RENAME ${CURRENT_PACKAGES_DIR}/lib/torrent-rasterbar.dll ${CURRENT_PACKAGES_DIR}/bin/torrent-rasterbar.dll)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/torrent-rasterbar.dll ${CURRENT_PACKAGES_DIR}/debug/bin/torrent-rasterbar.dll)
else()

endif()

# 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)

# Do not duplicate include files
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

0 comments on commit 26cf1a8

Please sign in to comment.