Skip to content
33 changes: 33 additions & 0 deletions ports/triton/fix-dependencies.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8bbe47..966ded8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,9 +99,9 @@ list(APPEND CMAKE_MODULE_PATH "${TRITON_ROOT}/CMakeModules/")
# Find Z3
if(Z3_INTERFACE)
message(STATUS "Compiling with Z3 SMT solver")
- find_package(Z3 REQUIRED)
- include_directories(${Z3_INCLUDE_DIRS})
+ find_package(Z3 CONFIG REQUIRED)
set(TRITON_Z3_INTERFACE ON)
+ set(Z3_LIBRARIES z3::libz3)
endif()

# Find bitwuzla
diff --git a/CMakeModules/FindCAPSTONE.cmake b/CMakeModules/FindCAPSTONE.cmake
index ff2c63f..4dcf9af 100644
--- a/CMakeModules/FindCAPSTONE.cmake
+++ b/CMakeModules/FindCAPSTONE.cmake
@@ -26,9 +26,11 @@ if(NOT CAPSTONE_INCLUDE_DIRS AND NOT CAPSTONE_LIBRARIES)
NAMES capstone/capstone.h
PATHS ${CAPSTONE_PKGCONF_INCLUDE_DIRS}
)
+
+ string(APPEND CAPSTONE_INCLUDE_DIR "/capstone")

find_library(CAPSTONE_LIBRARY
- NAMES capstone
+ NAMES capstone capstone_dll
PATHS ${CAPSTONE_PKGCONF_LIBRARY_DIRS}
)

27 changes: 27 additions & 0 deletions ports/triton/fix-python.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 966ded8..baf0ec3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,7 +52,6 @@ if(PYTHON_BINDINGS)
find_package(PythonInterp ${PYTHON_VERSION} REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION} REQUIRED)
include_directories(${PYTHON_INCLUDE_DIRS})
- add_definitions("-DPYTHON_LIBRARIES=\"${PYTHON_LIBRARIES}\"")
add_custom_target(test-python
COMMAND ${PYTHONPATH_CMD} ${PYTHON_EXECUTABLE} -m unittest discover ${TRITON_ROOT}/src/testers/unittests
DEPENDS python-triton
diff --git a/src/libtriton/CMakeLists.txt b/src/libtriton/CMakeLists.txt
index 6770b08..701d55b 100644
--- a/src/libtriton/CMakeLists.txt
+++ b/src/libtriton/CMakeLists.txt
@@ -326,8 +326,8 @@ if(PYTHON_BINDINGS)
)
execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print(get_path('platlib'))" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/triton${PYTHON_SUFFIX} DESTINATION ${PYTHON_SITE_PACKAGES})
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CONFIG_NAME}/triton${PYTHON_SUFFIX} DESTINATION share/triton)
else()
- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/triton${PYTHON_SUFFIX} DESTINATION ${PYTHON_SITE_PACKAGES})
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/triton${PYTHON_SUFFIX} DESTINATION share/triton)
endif()
endif()
14 changes: 14 additions & 0 deletions ports/triton/fix-usage.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/src/libtriton/Config.cmake.in b/src/libtriton/Config.cmake.in
index 683b5f2..94c58bc 100644
--- a/src/libtriton/Config.cmake.in
+++ b/src/libtriton/Config.cmake.in
@@ -19,6 +19,9 @@ message(STATUS "Found Triton: ${CMAKE_CURRENT_LIST_DIR}/tritonConfig.cmake (foun

include(CMakeFindDependencyMacro)
find_dependency(Boost)
+if (@Z3_INTERFACE@)
+ find_dependency(Z3 CONFIG)
+endif()

# Triton include
include_directories("@CMAKE_INSTALL_PREFIX@/include")
60 changes: 60 additions & 0 deletions ports/triton/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO JonathanSalwan/Triton
REF 64a2b9b0490c82e41b37e623b1d0da14e2382e7a
SHA512 ff99a270813043df2bc0da765e04aae4b9d5a911d20c6e5ffca1472eae8d6e1fcfff3cd56da023d6a77a647644839430bf72902acd84ec521a0e098f185d275c
PATCHES
fix-dependencies.patch
fix-usage.patch
fix-python.patch
)

file(REMOVE "${SOURCE_PATH}/CMakeModules/FindZ3.cmake")

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" STATICLIB)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" STATICCRT)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"python" PYTHON_BINDINGS
)

set(ADDITIONAL_OPTIONS )
if(PYTHON_BINDINGS)
vcpkg_find_acquire_program(PYTHON3)
list(APPEND ADDITIONAL_OPTIONS
-DPYTHON_EXECUTABLE=${PYTHON3}
)
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DZ3_INTERFACE=ON
-DBUILD_SHARED_LIBS=${STATICLIB}
-DMSVC_STATIC=${STATICCRT}
-DBUILD_EXAMPLES=OFF
-DENABLE_TEST=OFF
-DCAPSTONE_PKGCONF_INCLUDE_DIRS="${CURRENT_INSTALLED_DIR}/include"
${ADDITIONAL_OPTIONS}
OPTIONS_DEBUG
-DCAPSTONE_PKGCONF_LIBRARY_DIRS="${CURRENT_INSTALLED_DIR}/debug/lib"
OPTIONS_RELEASE
-DCAPSTONE_PKGCONF_LIBRARY_DIRS="${CURRENT_INSTALLED_DIR}/lib"

)

vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

# Move cmake configs
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT})

# Remove duplicate files
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share")

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
42 changes: 42 additions & 0 deletions ports/triton/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "triton",
"version": "0.9",
"description": "Triton is a Dynamic Binary Analysis (DBA) framework. It provides internal components like a Dynamic Symbolic Execution (DSE) engine, a dynamic taint engine, AST representations of the x86, x86-64, ARM32 and AArch64 Instructions Set Architecture (ISA), SMT simplification passes, an SMT solver interface and, the last but not least, Python bindings.",
"homepage": "https://github.com/JonathanSalwan/Triton",
"license": "Apache-2.0",
"supports": "!arm",
"dependencies": [
"boost-math",
"boost-multiprecision",
"boost-numeric-conversion",
{
"name": "capstone",
"default-features": false,
"features": [
"arm",
"arm64",
"x86"
]
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"z3"
],
"features": {
"python": {
"description": "Build Triton with Python bindings",
"dependencies": [
{
"name": "python3",
"default-features": false
}
]
}
}
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -7008,6 +7008,10 @@
"baseline": "1.6",
"port-version": 2
},
"triton": {
"baseline": "0.9",
"port-version": 0
},
"trompeloeil": {
"baseline": "41",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/t-/triton.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "168cc90ef1373fadb8b05ad53430eb37a022dd50",
"version": "0.9",
"port-version": 0
}
]
}