From e72d8f00987e3255dd402e69827364461c333f08 Mon Sep 17 00:00:00 2001 From: Eric Kilmer Date: Mon, 27 Jun 2022 10:03:33 -0400 Subject: [PATCH] vcpkg integration Overlay ports for projects (sleigh, lief) that don't exist in upstream vcpkg repo and/or are required overlays (mbedtls v3) because upstream won't accept them due to single-version package policy and mandatory compatibility of all existing packages. This uses a development version of sleigh that does a large refactor of the CMake and some target names. The lief portfile was copied from an existing PR --- CMakeLists.txt | 4 +- CMakePresets.json | 25 +++- ports/lief/0001-Support-vcpkg.patch | 45 +++++++ .../0002-Fix-Uninitialized-CMake-var.patch | 19 +++ ports/lief/portfile.cmake | 88 +++++++++++++ ports/lief/vcpkg.json | 116 ++++++++++++++++++ ports/mbedtls/enable-pthread.patch | 94 ++++++++++++++ ports/mbedtls/portfile.cmake | 36 ++++++ ports/mbedtls/vcpkg.json | 29 +++++ ports/sleigh/portfile.cmake | 84 +++++++++++++ ports/sleigh/vcpkg.json | 62 ++++++++++ vcpkg.json | 18 +++ 12 files changed, 613 insertions(+), 7 deletions(-) create mode 100644 ports/lief/0001-Support-vcpkg.patch create mode 100644 ports/lief/0002-Fix-Uninitialized-CMake-var.patch create mode 100644 ports/lief/portfile.cmake create mode 100644 ports/lief/vcpkg.json create mode 100755 ports/mbedtls/enable-pthread.patch create mode 100644 ports/mbedtls/portfile.cmake create mode 100644 ports/mbedtls/vcpkg.json create mode 100644 ports/sleigh/portfile.cmake create mode 100644 ports/sleigh/vcpkg.json create mode 100644 vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index e7f2e135..f717ff73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,14 +151,14 @@ add_custom_command( # Allow user to override sleigh compiler to support cross-compilation. Default # location is the one imported when we found the sleigh package if(CMAKE_CROSSCOMPILING) - find_program(maat_SLEIGH_COMPILER "sleigh_opt" + find_program(maat_SLEIGH_COMPILER "sleigh" DOC "Sleigh compiler executable" ) if(NOT maat_SLEIGH_COMPILER) message(FATAL_ERROR "Maat needs a sleigh compiler. Specify path manually by setting 'maat_SLEIGH_COMPILER'") endif() else() - set(maat_SLEIGH_COMPILER "$" CACHE PATH "Sleigh compiler executable") + set(maat_SLEIGH_COMPILER "$" CACHE PATH "Sleigh compiler executable") endif() macro(maat_sleigh_compile ARCH_DIR ARCH) diff --git a/CMakePresets.json b/CMakePresets.json index 4f9676f4..57bf8994 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -29,6 +29,21 @@ "maat_DEVELOPER_MODE": "ON" } }, + { + "name": "vcpkg", + "hidden": true, + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "VCPKG_OVERLAY_PORTS": "${sourceDir}/ports" + } + }, + { + "name": "vcpkg-win64-static", + "hidden": true, + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-windows-static-md" + } + }, { "name": "cppcheck", "hidden": true, @@ -98,7 +113,7 @@ }, { "name": "ci-coverage", - "inherits": ["coverage-unix", "dev-mode"], + "inherits": ["coverage-unix", "dev-mode", "vcpkg"], "cacheVariables": { "COVERAGE_HTML_COMMAND": "" } @@ -106,7 +121,7 @@ { "name": "ci-sanitize", "binaryDir": "${sourceDir}/build/sanitize", - "inherits": ["ci-unix", "dev-mode"], + "inherits": ["ci-unix", "dev-mode", "vcpkg"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Sanitize", "CMAKE_CXX_FLAGS_SANITIZE": "-O2 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fno-common", @@ -120,15 +135,15 @@ }, { "name": "ci-macos", - "inherits": ["ci-build", "ci-unix", "dev-mode"] + "inherits": ["ci-build", "ci-unix", "dev-mode", "vcpkg"] }, { "name": "ci-ubuntu", - "inherits": ["ci-build", "ci-unix", "dev-mode"] + "inherits": ["ci-build", "ci-unix", "dev-mode", "vcpkg"] }, { "name": "ci-windows", - "inherits": ["ci-build", "ci-win64", "dev-mode"] + "inherits": ["ci-build", "ci-win64", "dev-mode", "vcpkg", "vcpkg-win64-static"] } ] } diff --git a/ports/lief/0001-Support-vcpkg.patch b/ports/lief/0001-Support-vcpkg.patch new file mode 100644 index 00000000..0bcabb70 --- /dev/null +++ b/ports/lief/0001-Support-vcpkg.patch @@ -0,0 +1,45 @@ +From 426d8167648fff0ad79832a701223b8171dad096 Mon Sep 17 00:00:00 2001 +From: Eric Kilmer +Date: Tue, 12 Apr 2022 10:42:27 -0400 +Subject: [PATCH] Support vcpkg + +Remove msvccrt choosing and fix install paths on Windows +--- + CMakeLists.txt | 7 ++----- + 1 file changed, 2 insertions(+), 5 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b89d0522..9ca50c35 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -11,9 +11,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_CROSSCOMPILING) + endif() + + +-if(WIN32 OR ${IS_WIN_CROSS_COMPILE}) +- include(ChooseMSVCCRT) +-endif() + include(CheckCXXCompilerFlag) + include(CheckCCompilerFlag) + include(ExternalProject) +@@ -667,7 +664,7 @@ endif() + # Installation + # ====================== + +-if(UNIX) ++if(1) + include(GNUInstallDirs) + set(CMAKE_INSTALL_LIBDIR "lib") + else() +@@ -688,7 +685,7 @@ install( + EXPORT LIEFExport + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + install( +-- +2.35.1 + diff --git a/ports/lief/0002-Fix-Uninitialized-CMake-var.patch b/ports/lief/0002-Fix-Uninitialized-CMake-var.patch new file mode 100644 index 00000000..7c0cc9aa --- /dev/null +++ b/ports/lief/0002-Fix-Uninitialized-CMake-var.patch @@ -0,0 +1,19 @@ +diff --git a/LIEFConfig.cmake.in b/LIEFConfig.cmake.in +index 8c35eeab..ea09099f 100644 +--- a/LIEFConfig.cmake.in ++++ b/LIEFConfig.cmake.in +@@ -165,7 +165,8 @@ set(LIEF_LIBRARIES LIEF::LIEF) + get_target_property(LIEF_INCLUDE_DIRS LIEF::LIEF INTERFACE_INCLUDE_DIRECTORIES) + + # Set the following for backwards compatibility +-if(LIEF_INCLUDE_DIR AND EXISTS "${LIEF_INCLUDE_DIR}/LIEF/version.h") ++if(LIEF_INCLUDE_DIR) ++if(EXISTS "${LIEF_INCLUDE_DIR}/LIEF/version.h") + file(STRINGS "${LIEF_INCLUDE_DIR}/LIEF/version.h" LIEF_H REGEX "^#define LIEF_VERSION \"[^\"]*\"$") + + string(REGEX REPLACE "^.*LIEF_VERSION \"([0-9]+).*$" "\\1" LIEF_VERSION_MAJOR "${LIEF_H}") +@@ -177,3 +178,4 @@ if(LIEF_INCLUDE_DIR AND EXISTS "${LIEF_INCLUDE_DIR}/LIEF/version.h") + set(LIEF_MINOR_VERSION "${LIEF_VERSION_MINOR}") + set(LIEF_PATCH_VERSION "${LIEF_VERSION_PATCH}") + endif() ++endif() diff --git a/ports/lief/portfile.cmake b/ports/lief/portfile.cmake new file mode 100644 index 00000000..1d408d8a --- /dev/null +++ b/ports/lief/portfile.cmake @@ -0,0 +1,88 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lief-project/LIEF + REF 0.12.1 + SHA512 833a04ece5ff7365717aee3408a2d522756319e43cf4ff795047021c46b48d5d525c2a56cdafd04259ddfcf6888972d19655924f999460ce05f52a32ac7e8bca + HEAD_REF master + PATCHES + 0001-Support-vcpkg.patch + 0002-Fix-Uninitialized-CMake-var.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS +FEATURES + "tests" LIEF_TESTS # Enable tests + "c-api" LIEF_C_API # C API + "examples" LIEF_EXAMPLES # Build LIEF C++ examples + "force32" LIEF_FORCE32 # Force build LIEF 32 bits version + "coverage" LIEF_COVERAGE # Perform code coverage + "use-ccache" LIEF_USE_CCACHE # Use ccache to speed up compilation + "extra-warnings" LIEF_EXTRA_WARNINGS # Enable extra warning from the compiler + "logging" LIEF_LOGGING # Enable logging + "logging-debug" LIEF_LOGGING_DEBUG # Enable debug logging + "enable-json" LIEF_ENABLE_JSON # Enable JSON-related APIs + + "elf" LIEF_ELF # Build LIEF with ELF module + "pe" LIEF_PE # Build LIEF with PE module + "macho" LIEF_MACHO # Build LIEF with MachO module + + "oat" LIEF_OAT # Build LIEF with OAT module + "dex" LIEF_DEX # Build LIEF with DEX module + "vdex" LIEF_VDEX # Build LIEF with VDEX module + "art" LIEF_ART # Build LIEF with ART module + + # Sanitizer + "asan" LIEF_ASAN # Enable Address sanitizer + "lsan" LIEF_LSAN # Enable Leak sanitizer + "tsan" LIEF_TSAN # Enable Thread sanitizer + "usan" LIEF_USAN # Enable undefined sanitizer + + # Fuzzer + "fuzzing" LIEF_FUZZING # Fuzz LIEF + + # Profiling + "profiling" LIEF_PROFILING # Enable performance profiling + +INVERTED_FEATURES + "enable-frozen" LIEF_DISABLE_FROZEN # Disable Frozen even if it is supported +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + + OPTIONS + ${FEATURE_OPTIONS} + + -DLIEF_PYTHON_API=OFF + -DLIEF_USE_CCACHE=OFF + + # Build with external vcpkg dependencies + -DLIEF_OPT_MBEDTLS_EXTERNAL=ON + -DLIEF_OPT_UTFCPP_EXTERNAL=ON + -DLIEF_EXTERNAL_SPDLOG=ON + -DLIEF_OPT_NLOHMANN_JSON_EXTERNAL=ON + -DLIEF_OPT_FROZEN_EXTERNAL=ON + -DLIEF_OPT_EXTERNAL_LEAF=ON + "-DLIEF_EXTERNAL_LEAF_DIR=${CURRENT_INSTALLED_DIR}/include" + -DLIEF_OPT_EXTERNAL_SPAN=ON +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH share/LIEF/cmake) + +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +# Check if all-caps directory is empty (it won't be on case-insensitive filesystems). +# These files could have been moved during vcpkg_cmake_config_fixup +file(GLOB dir_files "${CURRENT_PACKAGES_DIR}/share/LIEF/*") +list(LENGTH dir_files dir_files_len) +if(dir_files_len EQUAL 0) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/LIEF") +endif() + +# Handle copyright +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/lief/vcpkg.json b/ports/lief/vcpkg.json new file mode 100644 index 00000000..c13aafef --- /dev/null +++ b/ports/lief/vcpkg.json @@ -0,0 +1,116 @@ +{ + "name": "lief", + "version-semver": "0.12.1", + "description": "LIEF - Library to Instrument Executable Formats", + "homepage": "https://lief.quarkslab.com", + "license": "Apache-2.0", + "supports": "!uwp", + "dependencies": [ + "boost-leaf", + "mbedtls", + "spdlog", + "tcb-span", + "utfcpp", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "art", + "c-api", + "dex", + "elf", + "enable-frozen", + "enable-json", + "logging", + "macho", + "oat", + "pe", + "vdex" + ], + "features": { + "art": { + "description": "Build LIEF with ART module" + }, + "asan": { + "description": "Enable Address sanitizer" + }, + "c-api": { + "description": "C API" + }, + "coverage": { + "description": "Perform code coverage" + }, + "dex": { + "description": "Build LIEF with DEX module" + }, + "elf": { + "description": "Build LIEF with ELF module" + }, + "enable-frozen": { + "description": "Enable Frozen", + "dependencies": [ + "frozen" + ] + }, + "enable-json": { + "description": "Enable JSON-related APIs", + "dependencies": [ + "nlohmann-json" + ] + }, + "examples": { + "description": "Build LIEF C++ examples" + }, + "extra-warnings": { + "description": "Enable extra warning from the compiler" + }, + "force32": { + "description": "Force build LIEF 32 bits version" + }, + "fuzzing": { + "description": "Fuzz LIEF" + }, + "logging": { + "description": "Enable logging" + }, + "logging-debug": { + "description": "Enable debug logging" + }, + "lsan": { + "description": "Enable Leak sanitizer" + }, + "macho": { + "description": "Build LIEF with MachO module" + }, + "oat": { + "description": "Build LIEF with OAT module" + }, + "pe": { + "description": "Build LIEF with PE module" + }, + "profiling": { + "description": "Enable performance profiling" + }, + "tests": { + "description": "Enable tests" + }, + "tsan": { + "description": "Enable Thread sanitizer" + }, + "usan": { + "description": "Enable undefined sanitizer" + }, + "use-ccache": { + "description": "Use ccache to speed up compilation" + }, + "vdex": { + "description": "Build LIEF with VDEX module" + } + } +} diff --git a/ports/mbedtls/enable-pthread.patch b/ports/mbedtls/enable-pthread.patch new file mode 100755 index 00000000..ce97c797 --- /dev/null +++ b/ports/mbedtls/enable-pthread.patch @@ -0,0 +1,94 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6debe35..64e0674 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -51,6 +51,7 @@ if(WIN32) + else() + option(GEN_FILES "Generate the auto-generated files as needed" ON) + endif() ++option(ENABLE_PTHREAD "Build mbed TLS with pthread" OFF) + + string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") + string(REGEX MATCH "GNU" CMAKE_COMPILER_IS_GNU "${CMAKE_C_COMPILER_ID}") +@@ -243,12 +244,26 @@ else() + set(LIB_INSTALL_DIR lib) + endif() + ++#include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/) ++ + add_subdirectory(include) + + add_subdirectory(3rdparty) + + add_subdirectory(library) + ++if(ENABLE_PTHREAD) ++ if(WIN32) ++ find_package(pthreads_windows REQUIRED) ++ include_directories(${PThreads4W_INCLUDE_DIR}) ++ else() ++ set(CMAKE_THREAD_PREFER_PTHREAD ON) ++ find_package(Threads REQUIRED) ++ endif() ++ set(LINK_WITH_PTHREAD ON) ++endif() ++ ++ + # + # The C files in tests/src directory contain test code shared among test suites + # and programs. This shared test code is compiled and linked to test suites and +diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt +index e693bc1..7f5216a 100644 +--- a/include/CMakeLists.txt ++++ b/include/CMakeLists.txt +@@ -1,9 +1,13 @@ + option(INSTALL_MBEDTLS_HEADERS "Install mbed TLS headers." ON) + ++#configure_file(mbedtls/config_threading.h.in mbedtls/config_threading.h) ++ + if(INSTALL_MBEDTLS_HEADERS) + + file(GLOB headers "mbedtls/*.h") + file(GLOB psa_headers "psa/*.h") ++ ++ #set(headers ${headers} ${CMAKE_CURRENT_BINARY_DIR}/mbedtls/config_threading.h) + + install(FILES ${headers} + DESTINATION include/mbedtls +diff --git a/include/mbedtls/mbedtls_config.h b/include/mbedtls/mbedtls_config.h +index 0558ee0..d2fd425 100644 +--- a/include/mbedtls/mbedtls_config.h ++++ b/include/mbedtls/mbedtls_config.h +@@ -24,6 +24,15 @@ + * limitations under the License. + */ + ++ ++ ++ ++ ++#ifdef ENABLE_PTHREAD ++#define MBEDTLS_THREADING_C ++#define MBEDTLS_THREADING_PTHREAD ++#endif ++ + /** + * This is an optional version symbol that enables comatibility handling of + * config files. +diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt +index 07599f5..27e426d 100644 +--- a/library/CMakeLists.txt ++++ b/library/CMakeLists.txt +@@ -189,7 +189,11 @@ if(HAIKU) + endif(HAIKU) + + if(LINK_WITH_PTHREAD) +- set(libs ${libs} pthread) ++ if(WIN32) ++ set(libs ${libs} ${PThreads4W_LIBRARY}) ++ else() ++ set(libs ${libs} pthread) ++ endif() + endif() + + if(LINK_WITH_TRUSTED_STORAGE) diff --git a/ports/mbedtls/portfile.cmake b/ports/mbedtls/portfile.cmake new file mode 100644 index 00000000..968fb9fc --- /dev/null +++ b/ports/mbedtls/portfile.cmake @@ -0,0 +1,36 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO ARMmbed/mbedtls + REF d65aeb37349ad1a50e0f6c9b694d4b5290d60e49 #v3.1.0 + SHA512 a3fde5e6e206d0ab43282502fec45da14f1ccb24974db7a9348a18870d3c07b10fe72419ebf5130cec1b9e819ef804608b0f7b48670f619e328f5b798a8d9eb1 + HEAD_REF master + PATCHES + enable-pthread.patch +) + +vcpkg_check_features( + OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + pthreads ENABLE_PTHREAD +) + +vcpkg_find_acquire_program(PYTHON3) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + -DENABLE_TESTING=OFF + -DENABLE_PROGRAMS=OFF + -DMBEDTLS_FATAL_WARNINGS=FALSE +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH "cmake") + +vcpkg_copy_pdbs() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/mbedtls/vcpkg.json b/ports/mbedtls/vcpkg.json new file mode 100644 index 00000000..e193eea1 --- /dev/null +++ b/ports/mbedtls/vcpkg.json @@ -0,0 +1,29 @@ +{ + "name": "mbedtls", + "version": "3.1.0", + "description": "An open source, portable, easy to use, readable and flexible SSL library", + "homepage": "https://github.com/ARMmbed/mbedtls", + "license": "Apache-2.0", + "supports": "!uwp", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "pthreads": { + "description": "Multi-threading support", + "dependencies": [ + { + "name": "pthreads", + "platform": "windows" + } + ] + } + } +} diff --git a/ports/sleigh/portfile.cmake b/ports/sleigh/portfile.cmake new file mode 100644 index 00000000..2cd09523 --- /dev/null +++ b/ports/sleigh/portfile.cmake @@ -0,0 +1,84 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO lifting-bits/sleigh + REF 814b41c45dd4ce357bd1982a6c7e01c3dbcc1aa8 # cmake-presets branch, unmerged + SHA512 ff0273f092f3f546f4beed50d0dba8cdb885a4ef3d623acd62b3fb2cfe50c5a20993ca7d193dd8170847676e86177362f338e5d4ac20a8080b6f0bb253ea9ac8 + HEAD_REF master +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS +FEATURES + "sleighspecs" sleigh_BUILD_SLEIGHSPECS # compiled sla files + "spec-compiler" sleigh_BUILD_SPECCOMPILER # Compiler + "decompiler" sleigh_BUILD_DECOMPILER # Decompiler + "ghidra" sleigh_BUILD_GHIDRA # Ghidra + "support" sleigh_BUILD_SUPPORT # Support libraries + "extra-tools" sleigh_BUILD_EXTRATOOLS # Extra tools +) + +set(tools "") +if("spec-compiler" IN_LIST FEATURES) + list(APPEND tools "sleigh") +endif() +if("decompiler" IN_LIST FEATURES) + list(APPEND tools "decomp") +endif() +if("ghidra" IN_LIST FEATURES) + list(APPEND tools "ghidra") +endif() + +# The tools won't be built unless this option is enabled +if("tools" IN_LIST FEATURES OR tools) + list(APPEND FEATURE_OPTIONS "-Dsleigh_BUILD_TOOLS=ON") +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} + OPTIONS_RELEASE + "-Dsleigh_INSTALL_CMAKEDIR=${CURRENT_PACKAGES_DIR}/share/${PORT}" + OPTIONS_DEBUG + "-Dsleigh_INSTALL_CMAKEDIR=${CURRENT_PACKAGES_DIR}/debug/share/${PORT}" + MAYBE_UNUSED_VARIABLES + sleigh_BUILD_DECOMPILER + sleigh_BUILD_GHIDRA + sleigh_BUILD_SPECCOMPILER +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup() +vcpkg_copy_pdbs() + +if(tools) + vcpkg_copy_tools( + TOOL_NAMES ${tools} + AUTO_CLEAN + ) +endif() + +if(EXISTS "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}Targets-debug.cmake") + foreach(tool ${tools}) + vcpkg_replace_string( + "${CURRENT_PACKAGES_DIR}/share/${PORT}/${PORT}Targets-debug.cmake" + "tools/${PORT}/${tool}_dbg" + "tools/${PORT}/${tool}" + ) + endforeach() +endif() + +if("extra-tools" IN_LIST FEATURES) + vcpkg_copy_tools( + TOOL_NAMES sleighLift + AUTO_CLEAN + ) +endif() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR NOT VCPKG_TARGET_IS_WINDOWS) + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin") + file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") +endif() + +file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/sleigh/vcpkg.json b/ports/sleigh/vcpkg.json new file mode 100644 index 00000000..e472d03a --- /dev/null +++ b/ports/sleigh/vcpkg.json @@ -0,0 +1,62 @@ +{ + "name": "sleigh", + "version": "10.1.4", + "description": "Unofficial CMake build for Ghidra SLEIGH", + "homepage": "https://github.com/lifting-bits/sleigh", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + "sleighspecs", + "support", + "tools" + ], + "features": { + "decompiler": { + "description": "Build the decompiler tool" + }, + "extra-tools": { + "description": "Include extra tools written by ToB", + "dependencies": [ + { + "name": "sleigh", + "features": [ + "support" + ] + } + ] + }, + "ghidra": { + "description": "Build the ghidra tool" + }, + "sleighspecs": { + "description": "Compile and install the sleigh specs" + }, + "spec-compiler": { + "description": "Build the sleigh spec compiler tool" + }, + "support": { + "description": "Include support libraries written by ToB" + }, + "tools": { + "description": "Build all upstream tools", + "dependencies": [ + { + "name": "sleigh", + "features": [ + "decompiler", + "ghidra", + "spec-compiler" + ] + } + ] + } + } +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 00000000..f15d42ea --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "maat", + "version-semver": "0.5.1", + "builtin-baseline": "cef0b3ec767df6e83806899fe9525f6cf8d7bc91", + "dependencies": [ + "gmp", + "lief", + { + "name": "sleigh", + "default-features": false, + "features": [ + "spec-compiler" + ] + }, + "z3" + ], + "default-features": [] +}