aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/gperftools
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/gperftools')
-rw-r--r--vcpkg/ports/gperftools/cmake-project-include.cmake4
-rw-r--r--vcpkg/ports/gperftools/install.diff89
-rw-r--r--vcpkg/ports/gperftools/libunwind.diff24
-rw-r--r--vcpkg/ports/gperftools/portfile.cmake65
-rw-r--r--vcpkg/ports/gperftools/vcpkg.json29
-rw-r--r--vcpkg/ports/gperftools/win32-override.diff16
6 files changed, 227 insertions, 0 deletions
diff --git a/vcpkg/ports/gperftools/cmake-project-include.cmake b/vcpkg/ports/gperftools/cmake-project-include.cmake
new file mode 100644
index 0000000..953c2ac
--- /dev/null
+++ b/vcpkg/ports/gperftools/cmake-project-include.cmake
@@ -0,0 +1,4 @@
+if(ANDROID)
+ include(CheckFunctionExists)
+ check_function_exists("glob" HAVE_GLOB_H)
+endif()
diff --git a/vcpkg/ports/gperftools/install.diff b/vcpkg/ports/gperftools/install.diff
new file mode 100644
index 0000000..c4cdfba
--- /dev/null
+++ b/vcpkg/ports/gperftools/install.diff
@@ -0,0 +1,89 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e9647d5..092f40d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -424,7 +424,7 @@ if(MSVC)
+ endif()
+
+ add_library(common
+- STATIC
++ OBJECT
+ src/base/logging.cc
+ src/base/generic_writer.cc
+ src/base/sysinfo.cc
+@@ -497,7 +497,7 @@ endif()
+
+ if(WITH_STACK_TRACE)
+ ### Making the library
+- add_library(stacktrace STATIC
++ add_library(stacktrace OBJECT
+ src/stacktrace.cc
+ src/base/elf_mem_image.cc
+ src/base/vdso_support.cc)
+@@ -926,4 +926,66 @@ if(MSVC)
+ add_subdirectory(src/windows)
+ endif()
+
++foreach(lib IN ITEMS
++ common stacktrace
++ tcmalloc_minimal tcmalloc tcmalloc_minimal_debug tcmalloc_debug
++ profiler
++)
++ if(TARGET "${lib}")
++ install(TARGETS "${lib}")
++ if(lib MATCHES "tcmalloc|profiler")
++ set(pc_file "${CMAKE_CURRENT_BINARY_DIR}/lib${lib}.pc")
++ set(pc_libs_private "${CMAKE_THREAD_LIBS_INIT}")
++ if("execinfo" IN_LIST unwind_libs AND lib MATCHES "tcmalloc")
++ string(APPEND pc_libs_private " -lexecinfo")
++ endif()
++ set(pc_requires_private "")
++ if(gperftools_enable_libunwind AND lib MATCHES "tcmalloc")
++ string(APPEND pc_requires_private " libunwind")
++ endif()
++ file(CONFIGURE OUTPUT "${pc_file}" CONTENT [[
++prefix=
++exec_prefix=${prefix}
++libdir=${prefix}/lib
++includedir=${prefix}/include
++
++Name: @PROJECT_NAME@
++Version: @PROJECT_VERSION@
++Description: Performance tools for C++
++URL: https://github.com/gperftools/gperftools
++Cflags: -I${includedir}
++Libs: -L${libdir} -l@lib@
++Libs.private: @pc_libs_private@
++Requires.private: @pc_requires_private@
++]] @ONLY)
++ install(FILES "${pc_file}" DESTINATION "lib/pkgconfig")
++ endif()
++ endif()
++endforeach()
++
++foreach(exe IN ITEMS addr2line-pdb nm-pdb)
++ if(NOT TARGET "${exe}")
++ continue()
++ elseif(GPERFTOOLS_BUILD_TOOLS)
++ install(TARGETS "${exe}")
++ else()
++ set_target_properties("${exe}" PROPERTIES EXCLUDE_FROM_ALL 1)
++ endif()
++endforeach()
++
++install(
++ FILES
++ src/gperftools/heap-checker.h
++ src/gperftools/heap-profiler.h
++ src/gperftools/malloc_extension.h
++ src/gperftools/malloc_extension_c.h
++ src/gperftools/malloc_hook.h
++ src/gperftools/malloc_hook_c.h
++ src/gperftools/nallocx.h
++ src/gperftools/profiler.h
++ src/gperftools/stacktrace.h
++ "${CMAKE_CURRENT_BINARY_DIR}/gperftools/tcmalloc.h"
++ DESTINATION include/gperftools
++)
++
+ message(WARNING "note: gperftools' cmake support is incomplete and is best-effort only")
diff --git a/vcpkg/ports/gperftools/libunwind.diff b/vcpkg/ports/gperftools/libunwind.diff
new file mode 100644
index 0000000..ad0a1c5
--- /dev/null
+++ b/vcpkg/ports/gperftools/libunwind.diff
@@ -0,0 +1,24 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 52629d3..a93c7e8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -241,13 +241,13 @@ if(NOT WIN32)
+ endif()
+
+ if(gperftools_enable_libunwind)
+- check_include_file("libunwind.h" HAVE_LIBUNWIND_H)
++ find_package(PkgConfig REQUIRED)
++ pkg_check_modules(PC_LIBUNWIND libunwind REQUIRED)
++ find_file(HAVE_LIBUNWIND_H "libunwind.h" PATHS ${PC_LIBUNWIND_INCLUDE_DIRS} NO_DEFAULT_PATH REQUIRED)
+ if(HAVE_LIBUNWIND_H)
+- find_library(libunwind_location NAMES unwind)
+- if(libunwind_location)
+- check_library_exists(
+- unwind backtrace ${libunwind_location} have_libunwind)
+- endif()
++ include_directories(${PC_LIBUNWIND_INCLUDE_DIRS})
++ set(libunwind_location "${PC_LIBUNWIND_LINK_LIBRARIES}" CACHE INTERNAL "")
++ set(have_libunwind 1)
+ if(have_libunwind)
+ set(unwind_libs ${libunwind_location})
+ set(will_use_libunwind ON)
diff --git a/vcpkg/ports/gperftools/portfile.cmake b/vcpkg/ports/gperftools/portfile.cmake
new file mode 100644
index 0000000..289401c
--- /dev/null
+++ b/vcpkg/ports/gperftools/portfile.cmake
@@ -0,0 +1,65 @@
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO gperftools/gperftools
+ REF gperftools-${VERSION}
+ SHA512 a6eddee06cd6a9344c724522a5bb977082d6ee30eded1c6793d6bb508d4c8542a238dc0f62818c715f09312c858cc90cded0ee95ba2a3ea15fad8a0b78bcdaea
+ HEAD_REF master
+ PATCHES
+ libunwind.diff
+ install.diff
+ win32-override.diff
+)
+file(REMOVE_RECURSE "${SOURCE_PATH}/vendor")
+
+if("override" IN_LIST FEATURES)
+ vcpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_STATIC_CRT)
+endif()
+
+vcpkg_check_features(
+ OUT_FEATURE_OPTIONS OPTIONS
+ FEATURES
+ libunwind gperftools_enable_libunwind
+ override GPERFTOOLS_WIN32_OVERRIDE
+ tools GPERFTOOLS_BUILD_TOOLS
+)
+
+if(gperftools_enable_libunwind)
+ vcpkg_find_acquire_program(PKGCONFIG)
+ list(APPEND OPTIONS "-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}")
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH "${SOURCE_PATH}"
+ OPTIONS
+ -DBUILD_TESTING=OFF
+ "-DCMAKE_PROJECT_INCLUDE=${CURRENT_PORT_DIR}/cmake-project-include.cmake"
+ -Dgperftools_build_benchmark=OFF
+ ${OPTIONS}
+ OPTIONS_DEBUG
+ -DGPERFTOOLS_BUILD_TOOLS=OFF
+ MAYBE_UNUSED_VARIABLES
+ GPERFTOOLS_BUILD_TOOLS
+ GPERFTOOLS_WIN32_OVERRIDE
+)
+vcpkg_cmake_install()
+vcpkg_copy_pdbs()
+vcpkg_fixup_pkgconfig()
+
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ file(GLOB gperf_public_headers "${CURRENT_PACKAGES_DIR}/include/gperftools/*.h")
+ foreach(gperf_header IN LISTS gperf_public_headers)
+ vcpkg_replace_string("${gperf_header}" "__declspec(dllimport)" "")
+ endforeach()
+endif()
+
+if("tools" IN_LIST FEATURES)
+ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
+ vcpkg_copy_tools(TOOL_NAMES addr2line-pdb nm-pdb AUTO_CLEAN)
+ endif()
+ # Perl script
+ file(INSTALL "${SOURCE_PATH}/src/pprof" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
+endif()
+
+file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
diff --git a/vcpkg/ports/gperftools/vcpkg.json b/vcpkg/ports/gperftools/vcpkg.json
new file mode 100644
index 0000000..449eac1
--- /dev/null
+++ b/vcpkg/ports/gperftools/vcpkg.json
@@ -0,0 +1,29 @@
+{
+ "name": "gperftools",
+ "version": "2.16",
+ "description": "A high-performance multi-threaded malloc() implementation, plus some performance analysis tools.",
+ "homepage": "https://github.com/gperftools/gperftools",
+ "license": "BSD-3-Clause",
+ "supports": "((x86 | x64) & windows & !uwp) | !windows | mingw",
+ "dependencies": [
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ }
+ ],
+ "features": {
+ "libunwind": {
+ "description": "Support libunwind for stack traces",
+ "dependencies": [
+ "libunwind"
+ ]
+ },
+ "override": {
+ "description": "Override Windows allocators",
+ "supports": "windows & staticcrt"
+ },
+ "tools": {
+ "description": "Install tools"
+ }
+ }
+}
diff --git a/vcpkg/ports/gperftools/win32-override.diff b/vcpkg/ports/gperftools/win32-override.diff
new file mode 100644
index 0000000..cd5e49c
--- /dev/null
+++ b/vcpkg/ports/gperftools/win32-override.diff
@@ -0,0 +1,16 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 2897655..7e93511 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -460,6 +460,11 @@ target_sources(common PRIVATE
+ set(SYSTEM_ALLOC_CC src/windows/system-alloc.cc)
+ set(TCMALLOC_CC src/windows/patch_functions.cc)
+
++if(GPERFTOOLS_WIN32_OVERRIDE)
++ set(TCMALLOC_CC src/windows/override_functions.cc)
++ add_definitions(-DWIN32_OVERRIDE_ALLOCATORS)
++endif()
++
+ # patch_function uses -lpsapi and spinlock bits use -synchronization
+ # and -lshlwapi
+ link_libraries(psapi synchronization shlwapi)