[tracy] Add Tracy profiler and capture tools using project files (#24091)

* [tracy] Add Tracy `profiler` and `capture` tools

* [tracy] Linux supports

* [capstone] fix non-installed pkg-config

* [tracy] supports for capstone (including pkgconfig support)

* [tracy] Add license

* [tracy] fix OSX

* [tracy] tools cannot be built on x86 Windows

* [tracy] do not build tools by default

* [tracy] Fix case

* [tracy] fix vcpkg copyright location convention

* Apply suggestions from code review

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* Finish code for code review suggestions

* Use `vcpkg_build_make` instead of `vcpkg_execute_build_process`

* Apply suggestions from code review

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* Workaround Windows cl complaint about `nodiscard`

* Use tools bundle rather than individual tools in features

* [capstone] Upgrade port after capstone-engine/capstone#1870 merge

Co-authored-by: MACHIZAUD Andréa <andrea.machizaud@adobe.com>
Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
This commit is contained in:
MACHIZAUD Andréa 2022-04-20 23:51:12 +02:00 committed by GitHub
parent dc2b45330b
commit e0c3408c77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 276 additions and 11 deletions

View File

@ -1,8 +1,8 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REF d5141c04785678535c7792eddc21f146186e639f # 5.0.0-rc2
REPO "capstone-engine/capstone"
SHA512 de9cf7da9fc3e502165b28b998b472791c8d5366e1a1a1fabd6bb8856a6fae80bf7d1fc4d268572d69c3526161bb0509a598ad4d94207e25a62aff6a5f9e9404
REF 000561b4f74dc15bda9af9544fe714efda7a6e13 # 5.0.0-rc2
SHA512 66b09a7d2fda297836bbedaeece71dcfe39bdbd633d9b6ecb68ee2e5aa094b697226136ab172cdc4550e8b2ef1448d001c8ee4e0d456c6d277afe0b3d1aab5a1
HEAD_REF next
PATCHES
001-silence-windows-crt-secure-warnings.patch

View File

@ -1,6 +1,7 @@
{
"name": "capstone",
"version": "5.0.0-rc2",
"port-version": 1,
"description": "Multi-architecture disassembly framework",
"homepage": "https://github.com/capstone-engine/capstone",
"dependencies": [

View File

@ -0,0 +1,44 @@
diff --git a/profiler/build/win32/Tracy.vcxproj b/profiler/build/win32/Tracy.vcxproj
index 8215cc7..f427953 100644
--- a/profiler/build/win32/Tracy.vcxproj
+++ b/profiler/build/win32/Tracy.vcxproj
@@ -57,7 +57,7 @@
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;IMGUI_ENABLE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..\imgui;..\..\..\vcpkg\vcpkg\installed\x64-windows-static\include;..\..\..\vcpkg\vcpkg\installed\x64-windows-static\include\capstone;$(VcpkgRoot)\installed\$(VcpkgTriplet)\include\capstone;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\..\imgui;$(VcpkgRoot)\installed\$(VcpkgTriplet)\include\capstone;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<ConformanceMode>true</ConformanceMode>
@@ -67,9 +67,8 @@
<FloatingPointModel>Fast</FloatingPointModel>
</ClCompile>
<Link>
- <AdditionalDependencies>brotlicommon-static.lib;brotlidec-static.lib;ws2_32.lib;freetyped.lib;glfw3.lib;libpng16d.lib;zlibd.lib;bz2d.lib;capstone.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
- <AdditionalLibraryDirectories>..\..\..\vcpkg\vcpkg\installed\x64-windows-static\debug\lib</AdditionalLibraryDirectories>
</Link>
<Manifest>
<EnableDpiAwareness>true</EnableDpiAwareness>
@@ -83,7 +82,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;IMGUI_ENABLE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>..\..\..\imgui;..\..\..\vcpkg\vcpkg\installed\x64-windows-static\include;..\..\..\vcpkg\vcpkg\installed\x64-windows-static\include\capstone;$(VcpkgRoot)\installed\$(VcpkgTriplet)\include\capstone;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>..\..\..\imgui;$(VcpkgRoot)\installed\$(VcpkgTriplet)\include\capstone;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ConformanceMode>true</ConformanceMode>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
@@ -94,9 +93,8 @@
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
- <AdditionalDependencies>brotlicommon-static.lib;brotlidec-static.lib;ws2_32.lib;freetype.lib;glfw3.lib;libpng16.lib;zlib.lib;bz2.lib;capstone.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
- <AdditionalLibraryDirectories>..\..\..\vcpkg\vcpkg\installed\x64-windows-static\lib</AdditionalLibraryDirectories>
</Link>
<Manifest>
<EnableDpiAwareness>true</EnableDpiAwareness>

View File

@ -0,0 +1,26 @@
diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp
index cc56298..7b9370a 100644
--- a/server/TracySourceView.cpp
+++ b/server/TracySourceView.cpp
@@ -2,7 +2,7 @@
#include <inttypes.h>
#include <stdio.h>
-#include <capstone.h>
+#include <capstone/capstone.h>
#include "imgui.h"
#include "TracyCharUtil.hpp"
diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp
index fcb1718..2433e59 100644
--- a/server/TracyWorker.cpp
+++ b/server/TracyWorker.cpp
@@ -19,7 +19,7 @@
#include <inttypes.h>
#include <sys/stat.h>
-#include <capstone.h>
+#include <capstone/capstone.h>
#define ZDICT_STATIC_LINKING_ONLY
#include "../zstd/zdict.h"

View File

@ -1,24 +1,174 @@
# It is possible to run into some issues when profiling when we uses Tracy client as a shared client
# As as safety measure let's build Tracy as a static library for now
# More details on Tracy Discord (e.g. https://discord.com/channels/585214693895962624/585214693895962630/953599951328403506)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO wolfpld/tracy
REF 9ba7171c3dd6f728268a820ee268a62c75f2dfb6
SHA512 a2898cd04a532a5cc71fd6c5fd3893ebff68df25fc38e8d988ba4a8a6cbe33e3d0049661029d002160b94b57421e5c5b7400658b404e51bfab721d204dd0cc5d
REF e83e83dae9852a9d4d451589f324776710b34ee6
SHA512 1286a54bc9c874b076ca36be63055b78ed8af3df0f10da06478bd5a7036538ce0ee26f3e7bec771e1408b78bc8094d6e7a9f420645b6a0da8eef415fb2717133
HEAD_REF master
PATCHES
001-fix-vcxproj-vcpkg.patch
002-fix-capstone-5.patch
)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
if(VCPKG_TARGET_IS_LINUX)
set(any_tracy_tool_requested OFF)
if(profiler IN_LIST FEATURES)
message(WARNING
"Tracy currently requires the following libraries from the system package manager to build its tools:
gtk+-3.0
tbb
These can be installed on Ubuntu systems via sudo apt install libgtk-3-dev libtbb-dev")
set(any_tracy_tool_requested ON)
else()
foreach(CLI_TOOL capture csvexport import-chrome update)
if(${CLI_TOOL} IN_LIST FEATURES)
message(WARNING
"Tracy currently requires the following libraries from the system package manager to build its tools:
tbb
These can be installed on Ubuntu systems via sudo apt install libtbb-dev")
set(any_tracy_tool_requested ON)
break()
endif()
endforeach()
endif()
endif()
vcpkg_list(SET tracy_tools)
if("cli-tools" IN_LIST FEATURES)
vcpkg_list(APPEND tracy_tools capture csvexport import-chrome update)
endif()
if("gui-tools" IN_LIST FEATURES)
vcpkg_list(APPEND tracy_tools profiler)
endif()
function(tracy_tool_install_make tracy_TOOL tracy_TOOL_NAME)
foreach(buildtype IN ITEMS "debug" "release")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "${buildtype}")
if("${buildtype}" STREQUAL "debug")
set(short_buildtype "-dbg")
set(path_suffix "/debug")
else()
set(short_buildtype "-rel")
set(path_suffix "")
endif()
file(COPY "${SOURCE_PATH}/${tracy_TOOL}/build/unix" DESTINATION "${SOURCE_PATH}/${tracy_TOOL}/_build")
file(RENAME "${SOURCE_PATH}/${tracy_TOOL}/_build/unix" "${SOURCE_PATH}/${tracy_TOOL}/build/unix${short_buildtype}")
file(REMOVE_RECURSE "${SOURCE_PATH}/${tracy_TOOL}/_build")
set(path_makefile_dir "${SOURCE_PATH}/${tracy_TOOL}/build/unix${short_buildtype}")
cmake_path(RELATIVE_PATH path_makefile_dir
BASE_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}${short_buildtype}"
OUTPUT_VARIABLE relative_path_makefile_dir)
vcpkg_backup_env_variables(VARS PKG_CONFIG_PATH)
vcpkg_host_path_list(PREPEND ENV{PKG_CONFIG_PATH} "${CURRENT_INSTALLED_DIR}${path_suffix}/lib/pkgconfig")
message(STATUS "Building ${tracy_TOOL_NAME} ${TARGET_TRIPLET}${short_buildtype}")
vcpkg_build_make(
BUILD_TARGET ${buildtype}
SUBPATH ${relative_path_makefile_dir}
LOGFILE_ROOT "build-${tracy_TOOL}"
)
vcpkg_restore_env_variables(VARS PKG_CONFIG_PATH)
file(INSTALL "${SOURCE_PATH}/${tracy_TOOL}/build/unix${short_buildtype}/${tracy_TOOL_NAME}-${buildtype}" DESTINATION "${CURRENT_PACKAGES_DIR}${path_suffix}/tools/${PORT}" RENAME "${tracy_TOOL_NAME}")
endif()
endforeach()
endfunction()
if("capture" IN_LIST tracy_tools)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_install_msbuild(
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH "capture/build/win32/capture.vcxproj"
USE_VCPKG_INTEGRATION
)
else()
tracy_tool_install_make(capture capture)
endif()
endif()
if("csvexport" IN_LIST tracy_tools)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_install_msbuild(
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH "csvexport/build/win32/csvexport.vcxproj"
USE_VCPKG_INTEGRATION
)
else()
tracy_tool_install_make(csvexport csvexport)
endif()
endif()
if("import-chrome" IN_LIST tracy_tools)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_install_msbuild(
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH "import-chrome/build/win32/import-chrome.vcxproj"
USE_VCPKG_INTEGRATION
)
else()
tracy_tool_install_make(import-chrome import-chrome)
endif()
endif()
if("profiler" IN_LIST tracy_tools)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_install_msbuild(
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH "profiler/build/win32/Tracy.vcxproj"
USE_VCPKG_INTEGRATION
)
else()
tracy_tool_install_make(profiler Tracy)
endif()
endif()
if("update" IN_LIST tracy_tools)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_install_msbuild(
SOURCE_PATH "${SOURCE_PATH}"
PROJECT_SUBPATH "update/build/win32/update.vcxproj"
USE_VCPKG_INTEGRATION
)
else()
tracy_tool_install_make(update update)
endif()
endif()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(PACKAGE_NAME Tracy)
vcpkg_fixup_pkgconfig()
foreach(TOOL capture csvexport import-chrome profiler update)
if(${TOOL} IN_LIST tracy_tools)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/debug/tools/${PORT}")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}")
endif()
break()
endif()
endforeach()
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
# Cleanup
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

View File

@ -1,8 +1,10 @@
{
"name": "tracy",
"version": "0.8.0",
"version-semver": "0.8.0",
"port-version": 1,
"description": "A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications.",
"homepage": "https://github.com/wolfpld/tracy",
"license": "BSD-3-Clause",
"supports": "!(windows & (arm | uwp))",
"dependencies": [
{
@ -17,5 +19,37 @@
"name": "vcpkg-cmake-config",
"host": true
}
]
],
"features": {
"cli-tools": {
"description": "Build Tracy command-line tools: `capture`, `csvexport`, `import-chrome` and `update`",
"supports": "!(windows & x86)",
"dependencies": [
{
"name": "capstone",
"features": [
"arm",
"arm64",
"x86"
]
}
]
},
"gui-tools": {
"description": "Build Tracy GUI tool: `profiler` (aka `Tracy` executable)",
"supports": "!(windows & x86)",
"dependencies": [
{
"name": "capstone",
"features": [
"arm",
"arm64",
"x86"
]
},
"freetype",
"glfw3"
]
}
}
}

View File

@ -1246,7 +1246,7 @@
},
"capstone": {
"baseline": "5.0.0-rc2",
"port-version": 0
"port-version": 1
},
"cargs": {
"baseline": "1.0.3",
@ -7090,7 +7090,7 @@
},
"tracy": {
"baseline": "0.8.0",
"port-version": 0
"port-version": 1
},
"transwarp": {
"baseline": "2.2.2",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f31ba3baba34c74dea464d864cca666c8793b1e7",
"version": "5.0.0-rc2",
"port-version": 1
},
{
"git-tree": "f7b26d8f672f30156cad79a647525b8dd8c9781b",
"version": "5.0.0-rc2",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "65aeedc7adaa4e1b13998f781e702d7672b2aca5",
"version-semver": "0.8.0",
"port-version": 1
},
{
"git-tree": "b34c2e1fb20aa7f46e350fbf5b90e8dda71aaf3a",
"version": "0.8.0",