From c095d5a2713edc21b1afa829fee10be20ad41b5a Mon Sep 17 00:00:00 2001 From: Park DongHa Date: Fri, 2 Apr 2021 02:37:58 +0900 Subject: [PATCH] [pthreadpool] create a new port (#16342) * [fxdiv] create a new port * [fxdiv] update baseline and port SHA * [pthreadpool] create a new port * [pthreadpool] update baseline and port SHA * [pthreadpool] update deps for uwp * [pthreadpool] apply PR feedback * [pthreadpool] remove unnecessary work in portfile --- ports/pthreadpool/fix-cmakelists.patch | 65 ++++++++++++++++++++++++++ ports/pthreadpool/portfile.cmake | 25 ++++++++++ ports/pthreadpool/vcpkg.json | 14 ++++++ versions/baseline.json | 4 ++ versions/p-/pthreadpool.json | 9 ++++ 5 files changed, 117 insertions(+) create mode 100644 ports/pthreadpool/fix-cmakelists.patch create mode 100644 ports/pthreadpool/portfile.cmake create mode 100644 ports/pthreadpool/vcpkg.json create mode 100644 versions/p-/pthreadpool.json diff --git a/ports/pthreadpool/fix-cmakelists.patch b/ports/pthreadpool/fix-cmakelists.patch new file mode 100644 index 00000000000000..2f56f6b9bfe643 --- /dev/null +++ b/ports/pthreadpool/fix-cmakelists.patch @@ -0,0 +1,65 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -4,8 +4,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5 FATAL_ERROR) + PROJECT(pthreadpool C CXX) + + # ---[ Options. +-SET(PTHREADPOOL_LIBRARY_TYPE "default" CACHE STRING "Type of library (shared, static, or default) to build") +-SET_PROPERTY(CACHE PTHREADPOOL_LIBRARY_TYPE PROPERTY STRINGS default static shared) + OPTION(PTHREADPOOL_ALLOW_DEPRECATED_API "Enable deprecated API functions" ON) + SET(PTHREADPOOL_SYNC_PRIMITIVE "default" CACHE STRING "Synchronization primitive (condvar, futex, gcd, event, or default) for worker threads") + SET_PROPERTY(CACHE PTHREADPOOL_SYNC_PRIMITIVE PROPERTY STRINGS default condvar futex gcd event) +@@ -14,7 +12,7 @@ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i[3-6]86|AMD64|x86(_64)?)$") + ELSE() + OPTION(PTHREADPOOL_ENABLE_FASTPATH "Enable fast path using atomic decrement instead of atomic compare-and-swap" OFF) + ENDIF() +-IF("${CMAKE_SOURCE_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") ++IF(FALSE) + OPTION(PTHREADPOOL_BUILD_TESTS "Build pthreadpool unit tests" ON) + OPTION(PTHREADPOOL_BUILD_BENCHMARKS "Build pthreadpool micro-benchmarks" ON) + ELSE() +@@ -36,7 +34,8 @@ MACRO(PTHREADPOOL_TARGET_ENABLE_CXX11 target) + ENDMACRO() + + # ---[ Download deps +-IF(NOT DEFINED FXDIV_SOURCE_DIR) ++find_path(FXDIV_INCLUDE_DIRS "fxdiv.h") ++IF(FALSE) + MESSAGE(STATUS "Downloading FXdiv to ${CMAKE_BINARY_DIR}/FXdiv-source (define FXDIV_SOURCE_DIR to avoid it)") + CONFIGURE_FILE(cmake/DownloadFXdiv.cmake "${CMAKE_BINARY_DIR}/FXdiv-download/CMakeLists.txt") + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . +@@ -93,15 +92,7 @@ IF(NOT PTHREADPOOL_ALLOW_DEPRECATED_API) + ENDIF() + INSTALL(FILES include/pthreadpool.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +-IF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "default") +- ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS}) +-ELSEIF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "shared") +- ADD_LIBRARY(pthreadpool SHARED ${PTHREADPOOL_SRCS}) +-ELSEIF(PTHREADPOOL_LIBRARY_TYPE STREQUAL "static") +- ADD_LIBRARY(pthreadpool STATIC ${PTHREADPOOL_SRCS}) +-ELSE() +- MESSAGE(FATAL_ERROR "Unsupported library type ${PTHREADPOOL_LIBRARY_TYPE}") +-ENDIF() ++ADD_LIBRARY(pthreadpool ${PTHREADPOOL_SRCS}) + + IF(PTHREADPOOL_SYNC_PRIMITIVE STREQUAL "condvar") + TARGET_COMPILE_DEFINITIONS(pthreadpool PRIVATE PTHREADPOOL_USE_FUTEX=0) +@@ -150,14 +141,14 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + ENDIF() + + # ---[ Configure FXdiv +-IF(NOT TARGET fxdiv) ++IF(FALSE) + SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "") + SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "") + ADD_SUBDIRECTORY( + "${FXDIV_SOURCE_DIR}" + "${CMAKE_BINARY_DIR}/FXdiv") + ENDIF() +-TARGET_LINK_LIBRARIES(pthreadpool PRIVATE fxdiv) ++TARGET_INCLUDE_DIRECTORIES(pthreadpool PRIVATE ${FXDIV_INCLUDE_DIRS}) + + INSTALL(TARGETS pthreadpool + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/ports/pthreadpool/portfile.cmake b/ports/pthreadpool/portfile.cmake new file mode 100644 index 00000000000000..f3be9109275692 --- /dev/null +++ b/ports/pthreadpool/portfile.cmake @@ -0,0 +1,25 @@ +if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_check_linkage(ONLY_STATIC_LIBRARY) +endif() + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Maratyszcza/pthreadpool + REF b4589998be9a0f794236cf46f1b5b232b2b15ca3 # there is a too much gap from the last release... + SHA512 8459e489a41c38f4dbe6c4401ebe624c7dc4685181b0852c2284f0e413a192ae9fd1ffd9b43fd97b7fd95dbda4970bc71d8c1eba8e33afa9efea74440f00803d + PATCHES + fix-cmakelists.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + -DPTHREADPOOL_BUILD_TESTS=OFF + -DPTHREADPOOL_BUILD_BENCHMARKS=OFF +) +vcpkg_install_cmake() +vcpkg_copy_pdbs() + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) diff --git a/ports/pthreadpool/vcpkg.json b/ports/pthreadpool/vcpkg.json new file mode 100644 index 00000000000000..e3924a69836df5 --- /dev/null +++ b/ports/pthreadpool/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "pthreadpool", + "version-date": "2020-02-21", + "description": "Portable (POSIX/Windows/Emscripten) thread pool for C/C++", + "homepage": "https://github.com/Maratyszcza/pthreadpool", + "supports": "!uwp", + "dependencies": [ + "fxdiv", + { + "name": "pthreads", + "platform": "uwp" + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index dc9e7da9efacdc..3dd4baa61d2db3 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4888,6 +4888,10 @@ "baseline": "3.0.0", "port-version": 0 }, + "pthreadpool": { + "baseline": "2020-02-21", + "port-version": 0 + }, "pthreads": { "baseline": "3.0.0-6", "port-version": 0 diff --git a/versions/p-/pthreadpool.json b/versions/p-/pthreadpool.json new file mode 100644 index 00000000000000..09c0ab0156ee8a --- /dev/null +++ b/versions/p-/pthreadpool.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "9c1519f2cc1eb186ccd706a4f634350877da6dba", + "version-date": "2020-02-21", + "port-version": 0 + } + ] +}