mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-21 10:12:01 +01:00
[gperftools] Add new port (#8750)
* [gperftools] Add new port * [gperftools] Fix linux build * [gperftools] Update * [vcpkg-baseline] Update [gperftools] Install tools optionally * [gperftools] Fail port on unsupported targets * [gperftools] Add `Supports` field into CONTROL file * [gperftools] Call vcpkg_copy_tools * [gperftools] Fix *nix build error [gperftools] Use static CRT in override mode * [gperftools] Format * [gperftools] Install deprecated headers
This commit is contained in:
parent
d1729dcaf5
commit
9b79636305
211
ports/gperftools/CMakeLists.txt
Normal file
211
ports/gperftools/CMakeLists.txt
Normal file
@ -0,0 +1,211 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(gperftools LANGUAGES C CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
option(GPERFTOOLS_BUILD_TOOLS "Build tools" ON)
|
||||
|
||||
if(WIN32) # TODO: MINGW, MSYS
|
||||
option(GPERFTOOLS_WIN32_OVERRIDE "Override allocators" OFF)
|
||||
endif()
|
||||
|
||||
set(deprecated_public_headers
|
||||
src/google/heap-checker.h
|
||||
src/google/heap-profiler.h
|
||||
src/google/malloc_extension.h
|
||||
src/google/malloc_extension_c.h
|
||||
src/google/malloc_hook.h
|
||||
src/google/malloc_hook_c.h
|
||||
src/google/profiler.h
|
||||
src/google/stacktrace.h
|
||||
)
|
||||
|
||||
set(gperftools_public_headers
|
||||
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
|
||||
)
|
||||
|
||||
if(WIN32) # TODO: MINGW, MSYS
|
||||
list(APPEND deprecated_public_headers
|
||||
src/windows/google/tcmalloc.h
|
||||
)
|
||||
|
||||
list(APPEND gperftools_public_headers
|
||||
src/windows/gperftools/tcmalloc.h
|
||||
)
|
||||
|
||||
set(libtcmalloc_minimal_headers
|
||||
src/addressmap-inl.h
|
||||
src/base/arm_instruction_set_select.h
|
||||
src/base/atomicops-internals-arm-generic.h
|
||||
src/base/atomicops-internals-arm-v6plus.h
|
||||
src/base/atomicops-internals-gcc.h
|
||||
src/base/atomicops-internals-linuxppc.h
|
||||
src/base/atomicops-internals-macosx.h
|
||||
src/base/atomicops-internals-mips.h
|
||||
src/base/atomicops-internals-windows.h
|
||||
src/base/atomicops-internals-x86.h
|
||||
src/base/atomicops.h
|
||||
src/base/basictypes.h
|
||||
src/base/commandlineflags.h
|
||||
src/base/googleinit.h
|
||||
src/base/logging.h
|
||||
src/base/low_level_alloc.h
|
||||
src/base/spinlock.h
|
||||
src/base/spinlock_internal.h
|
||||
src/base/spinlock_linux-inl.h
|
||||
src/base/spinlock_posix-inl.h
|
||||
src/base/spinlock_win32-inl.h
|
||||
src/base/stl_allocator.h
|
||||
src/base/sysinfo.h
|
||||
src/base/thread_annotations.h
|
||||
src/central_freelist.h
|
||||
src/common.h
|
||||
src/gperftools/heap-checker.h
|
||||
src/gperftools/heap-profiler.h
|
||||
src/gperftools/malloc_extension.h
|
||||
src/gperftools/malloc_hook.h
|
||||
src/gperftools/profiler.h
|
||||
src/gperftools/stacktrace.h
|
||||
src/heap-profile-table.h
|
||||
src/internal_logging.h
|
||||
src/malloc_hook-inl.h
|
||||
src/memory_region_map.h
|
||||
src/packed-cache-inl.h
|
||||
src/pagemap.h
|
||||
src/page_heap.h
|
||||
src/page_heap_allocator.h
|
||||
src/raw_printer.h
|
||||
src/sampler.h
|
||||
src/span.h
|
||||
src/stacktrace_win32-inl.h
|
||||
src/stack_trace_table.h
|
||||
src/static_vars.h
|
||||
src/symbolize.h
|
||||
src/system-alloc.h
|
||||
src/tcmalloc.h
|
||||
src/thread_cache.h
|
||||
src/windows/config.h
|
||||
src/windows/mini_disassembler.h
|
||||
src/windows/mini_disassembler_types.h
|
||||
src/windows/port.h
|
||||
src/windows/preamble_patcher.h
|
||||
)
|
||||
|
||||
set(libtcmalloc_minimal_sources
|
||||
src/base/dynamic_annotations.c
|
||||
src/base/logging.cc
|
||||
src/base/low_level_alloc.cc
|
||||
src/base/spinlock.cc
|
||||
src/base/spinlock_internal.cc
|
||||
src/base/sysinfo.cc
|
||||
src/central_freelist.cc
|
||||
src/common.cc
|
||||
src/fake_stacktrace_scope.cc
|
||||
src/heap-profile-table.cc
|
||||
src/internal_logging.cc
|
||||
src/malloc_extension.cc
|
||||
src/malloc_hook.cc
|
||||
src/memory_region_map.cc
|
||||
src/page_heap.cc
|
||||
src/raw_printer.cc
|
||||
src/sampler.cc
|
||||
src/span.cc
|
||||
src/stacktrace.cc
|
||||
src/stack_trace_table.cc
|
||||
src/static_vars.cc
|
||||
src/symbolize.cc
|
||||
src/thread_cache.cc
|
||||
src/windows/ia32_modrm_map.cc
|
||||
src/windows/ia32_opcode_map.cc
|
||||
src/windows/mini_disassembler.cc
|
||||
src/windows/port.cc
|
||||
src/windows/preamble_patcher.cc
|
||||
src/windows/preamble_patcher_with_stub.cc
|
||||
src/windows/system-alloc.cc
|
||||
)
|
||||
|
||||
if(GPERFTOOLS_WIN32_OVERRIDE)
|
||||
list(APPEND libtcmalloc_minimal_sources src/windows/override_functions.cc)
|
||||
else()
|
||||
list(APPEND libtcmalloc_minimal_sources src/windows/patch_functions.cc)
|
||||
endif()
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
source_group("Header Files" FILES ${libtcmalloc_minimal_headers})
|
||||
source_group("Source Files" FILES ${libtcmalloc_minimal_sources})
|
||||
|
||||
if(GPERFTOOLS_WIN32_OVERRIDE)
|
||||
add_library(libtcmalloc_minimal
|
||||
STATIC
|
||||
${libtcmalloc_minimal_headers}
|
||||
${libtcmalloc_minimal_sources}
|
||||
)
|
||||
else()
|
||||
add_library(libtcmalloc_minimal
|
||||
${libtcmalloc_minimal_headers}
|
||||
${libtcmalloc_minimal_sources}
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(
|
||||
libtcmalloc_minimal
|
||||
PRIVATE
|
||||
$<$<BOOL:${GPERFTOOLS_WIN32_OVERRIDE}>:
|
||||
WIN32_OVERRIDE_ALLOCATORS
|
||||
PERFTOOLS_DLL_DECL=
|
||||
>
|
||||
)
|
||||
|
||||
target_compile_options(
|
||||
libtcmalloc_minimal
|
||||
PRIVATE
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/wd4141
|
||||
/wd4251
|
||||
>
|
||||
)
|
||||
|
||||
target_include_directories(
|
||||
libtcmalloc_minimal
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:
|
||||
${CMAKE_CURRENT_LIST_DIR}/src
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/windows
|
||||
>
|
||||
)
|
||||
|
||||
install(FILES ${deprecated_public_headers}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/google
|
||||
)
|
||||
|
||||
install(FILES ${gperftools_public_headers}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gperftools
|
||||
)
|
||||
|
||||
install(TARGETS libtcmalloc_minimal
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
if(GPERFTOOLS_BUILD_TOOLS)
|
||||
add_executable(addr2line-pdb src/windows/addr2line-pdb.c)
|
||||
target_link_libraries(addr2line-pdb PRIVATE DbgHelp)
|
||||
|
||||
add_executable(nm-pdb src/windows/nm-pdb.c)
|
||||
target_link_libraries(nm-pdb PRIVATE DbgHelp)
|
||||
|
||||
install(TARGETS addr2line-pdb nm-pdb DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
else()
|
||||
endif()
|
11
ports/gperftools/CONTROL
Normal file
11
ports/gperftools/CONTROL
Normal file
@ -0,0 +1,11 @@
|
||||
Source: gperftools
|
||||
Version: 2019-09-02
|
||||
Description: A set of tools for performance profiling and memory checking
|
||||
Supports: !(arm|arm64|uwp)
|
||||
Homepage: https://github.com/gperftools/gperftools
|
||||
|
||||
Feature: override
|
||||
Description: Override allocators
|
||||
|
||||
Feature: tools
|
||||
Description: Build gperftools CLI tools
|
83
ports/gperftools/portfile.cmake
Normal file
83
ports/gperftools/portfile.cmake
Normal file
@ -0,0 +1,83 @@
|
||||
vcpkg_fail_port_install(ON_ARCH "arm" "arm64" ON_TARGET "uwp")
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO gperftools/gperftools
|
||||
REF fe62a0baab87ba3abca12f4a621532bf67c9a7d2
|
||||
SHA512 fc0fb2c56d38046ac7bc2d36863dabf073b7aede7ce18916228d7b9f64cf33ae754708bff028353ada52bf4b79a7cd3e3334c1558a9ba64b06326b1537faf690
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||
|
||||
if(override IN_LIST FEATURES)
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||
message(STATUS "${PORT}[override] only supports static library linkage. Building static library.")
|
||||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY ONLY_STATIC_CRT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
vcpkg_check_features(
|
||||
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
override GPERFTOOLS_WIN32_OVERRIDE
|
||||
tools GPERFTOOLS_BUILD_TOOLS
|
||||
)
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
PREFER_NINJA
|
||||
DISABLE_PARALLEL_CONFIGURE
|
||||
OPTIONS
|
||||
${FEATURE_OPTIONS}
|
||||
)
|
||||
|
||||
vcpkg_install_cmake()
|
||||
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
|
||||
file(GLOB gperf_public_headers ${CURRENT_PACKAGES_DIR}/include/gperftools/*.h)
|
||||
|
||||
foreach(gperf_header ${gperf_public_headers})
|
||||
vcpkg_replace_string(${gperf_header} "__declspec(dllimport)" "")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(tools IN_LIST FEATURES)
|
||||
vcpkg_copy_tools(TOOL_NAMES addr2line-pdb nm-pdb AUTO_CLEAN)
|
||||
endif()
|
||||
else()
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
|
||||
set(BUILD_OPTS --enable-shared --disable-static)
|
||||
else()
|
||||
set(BUILD_OPTS --enable-static --disable-shared)
|
||||
endif()
|
||||
|
||||
vcpkg_configure_make(
|
||||
SOURCE_PATH ${SOURCE_PATH}
|
||||
AUTOCONFIG
|
||||
OPTIONS
|
||||
${BUILD_OPTS}
|
||||
)
|
||||
|
||||
vcpkg_install_make()
|
||||
|
||||
if(tools IN_LIST FEATURES)
|
||||
vcpkg_copy_tools(TOOL_NAMES pprof pprof-symbolize AUTO_CLEAN)
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE
|
||||
${CURRENT_PACKAGES_DIR}/debug/include
|
||||
${CURRENT_PACKAGES_DIR}/debug/share
|
||||
)
|
||||
|
||||
# https://github.com/microsoft/vcpkg/pull/8750#issuecomment-625590773
|
||||
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
|
@ -569,6 +569,9 @@ google-cloud-cpp-spanner:x86-windows=fail
|
||||
gppanel:x64-osx=fail
|
||||
gperf:x64-uwp=fail
|
||||
gperf:arm-uwp=fail
|
||||
gperftools:arm64-windows=fail
|
||||
gperftools:x64-uwp=fail
|
||||
gperftools:arm-uwp=fail
|
||||
graphicsmagick:arm64-windows=fail
|
||||
graphicsmagick:arm-uwp=fail
|
||||
graphicsmagick:x64-uwp=fail
|
||||
|
Loading…
x
Reference in New Issue
Block a user