Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lief] add new port LIEF-0.16.0 #42374

Draft
wants to merge 84 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
bb08d3e
init
luadebug Nov 26, 2024
5f08f62
ver
luadebug Nov 26, 2024
3ea5f30
enforce c++17
luadebug Nov 27, 2024
2cd7cf1
ver
luadebug Nov 27, 2024
c3a499f
push include <algorithm> into src/OAT/utils.cpp
luadebug Nov 27, 2024
f391c67
ver
luadebug Nov 27, 2024
fde8501
downgrade to 14 C++ std
luadebug Nov 27, 2024
991a888
ver
luadebug Nov 27, 2024
2dfaeba
downgrade to 11 C++ std
luadebug Nov 27, 2024
6ae9a57
ver
luadebug Nov 27, 2024
bea8260
push #include <map> instead & c++14
luadebug Nov 27, 2024
d94531a
ver
luadebug Nov 27, 2024
8dd31d3
enforce frozen
luadebug Nov 28, 2024
7f4b3a9
ver
luadebug Nov 28, 2024
ad8799d
test android
luadebug Nov 28, 2024
73a7bfa
ver
luadebug Nov 28, 2024
3017791
simplify test
luadebug Nov 28, 2024
f85f0d1
ver
luadebug Nov 28, 2024
61f58eb
checking uwp
luadebug Nov 28, 2024
7cf39fc
ver
luadebug Nov 28, 2024
b7f5b46
clean
luadebug Nov 28, 2024
23aedc7
ver
luadebug Nov 28, 2024
243ac62
test linux
luadebug Nov 28, 2024
8315f34
ver
luadebug Nov 28, 2024
7552ead
fix
luadebug Nov 28, 2024
a9206d8
ver
luadebug Nov 28, 2024
36819c5
test2 linux
luadebug Nov 28, 2024
2a81ceb
ver
luadebug Nov 28, 2024
c4a2a64
clean
luadebug Nov 29, 2024
e543654
ver
luadebug Nov 29, 2024
667b350
ver
luadebug Nov 29, 2024
b7fd1d1
clean
luadebug Nov 29, 2024
2353914
ver
luadebug Nov 29, 2024
df580df
ver
luadebug Nov 29, 2024
b29d770
test
luadebug Dec 3, 2024
ca48233
ver
luadebug Dec 3, 2024
4bc73c3
fix2
luadebug Dec 3, 2024
d7f5c63
ver
luadebug Dec 3, 2024
756a4fb
fix3
luadebug Dec 3, 2024
f58b4bd
ver
luadebug Dec 3, 2024
0f043ae
fix4
luadebug Dec 3, 2024
834178f
ver
luadebug Dec 3, 2024
d09196d
fix5
luadebug Dec 3, 2024
3b311d6
ver
luadebug Dec 3, 2024
084abeb
test
luadebug Dec 3, 2024
32191c3
ver
luadebug Dec 3, 2024
8116f9b
test
luadebug Dec 3, 2024
5b0da05
ver
luadebug Dec 3, 2024
a57caea
release
luadebug Dec 4, 2024
e13c475
ver
luadebug Dec 4, 2024
08938ed
test for linux
luadebug Dec 4, 2024
c4dfaa5
ver
luadebug Dec 4, 2024
09db381
clean
luadebug Dec 4, 2024
ad62504
ver
luadebug Dec 4, 2024
1e1ba2a
usage
luadebug Dec 4, 2024
0261c79
ver
luadebug Dec 4, 2024
4115000
fuzzing & sanitizer remove
luadebug Dec 5, 2024
06e5138
ver
luadebug Dec 5, 2024
f066b24
optimize
luadebug Dec 5, 2024
83f0c54
ver
luadebug Dec 5, 2024
25bcf61
fmt
luadebug Dec 5, 2024
5c03fbc
ver
luadebug Dec 5, 2024
2787775
test
luadebug Dec 10, 2024
8d55be8
test2
luadebug Dec 10, 2024
7a65f59
ver
luadebug Dec 10, 2024
1fde52a
test3
luadebug Dec 10, 2024
4a1afed
ver
luadebug Dec 10, 2024
5403ff9
testing
luadebug Dec 10, 2024
8c8ddb2
ver
luadebug Dec 10, 2024
d796d9f
testing2
luadebug Dec 10, 2024
43a9181
ver
luadebug Dec 10, 2024
9f8aa76
testing3
luadebug Dec 10, 2024
3e47dff
ver
luadebug Dec 10, 2024
6056577
testing4
luadebug Dec 10, 2024
09db302
ver
luadebug Dec 10, 2024
643488e
testing5
luadebug Dec 10, 2024
7466fde
ver
luadebug Dec 10, 2024
68ddc98
features
luadebug Dec 10, 2024
2727050
fixup
luadebug Dec 10, 2024
b7660e3
ver
luadebug Dec 10, 2024
6eff159
fixup2
luadebug Dec 10, 2024
3000897
ver
luadebug Dec 10, 2024
8bc2940
one ver
luadebug Dec 11, 2024
e1c0361
test ci
luadebug Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 216 additions & 0 deletions ports/lief/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO lief-project/LIEF
REF ${VERSION}
SHA512 7df75fab6c7023e37a6a4d27fac8dcb4200e0235625fc5952bb23cedb2e582a37fb67ee471c1ae953c0b205fd9cca5538a835f65ef80a771f72dc7ff68000ed9
HEAD_REF master
)

file(REMOVE_RECURSE "${SOURCE_PATH}/third-party")

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
"target_link_libraries(LIB_LIEF PRIVATE lief_spdlog)"
"find_package(fmt CONFIG REQUIRED)\nfind_package(spdlog CONFIG REQUIRED)\ntarget_link_libraries(LIB_LIEF PRIVATE fmt::fmt spdlog::spdlog)"
)

vcpkg_replace_string("${SOURCE_PATH}/cmake/LIEFConfig.cmake.in"
[[if("${lib_type}" STREQUAL "static")]]
[[if(1)]]
)

vcpkg_replace_string("${SOURCE_PATH}/cmake/LIEFConfig.cmake.in"
"include(CMakeFindDependencyMacro)"
"include(CMakeFindDependencyMacro)\nfind_dependency(tl-expected)\nfind_dependency(fmt)"
)

vcpkg_replace_string("${SOURCE_PATH}/cmake/LIEFConfig.cmake.in"
"if(DEFINED LIEF_INCLUDE_DIR)"
"check_required_components(lief)\nif(DEFINED LIEF_INCLUDE_DIR)"
)

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
"TARGETS LIB_LIEF lief_spdlog"
"TARGETS LIB_LIEF"
)

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
[[set(CMAKE_INSTALL_LIBDIR "lib")]]
[[#set(CMAKE_INSTALL_LIBDIR "lib")]]
)
vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
"set(CMAKE_INSTALL_LIBDIR \"lib\")"
"#[[set(CMAKE_INSTALL_LIBDIR \"lib\")"
)

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
"set(CMAKE_INSTALL_DATAROOTDIR \"share\")"
"set(CMAKE_INSTALL_DATAROOTDIR \"share\")]]\nset(CMAKE_INSTALL_INCLUDEDIR \"include\")"
)

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
"COMPONENT libraries"
" "
)

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
[[ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}]]
" "
)

vcpkg_replace_string("${SOURCE_PATH}/CMakeLists.txt"
[[RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}]]
" "
)

vcpkg_replace_string("${SOURCE_PATH}/src/BinaryStream/BinaryStream.cpp"
[[#include "third-party/utfcpp.hpp"]]
[[#include <utf8cpp/utf8.h>]]
)

vcpkg_replace_string("${SOURCE_PATH}/src/utils.cpp"
[[#include "third-party/utfcpp.hpp"]]
[[#include <utf8cpp/utf8.h>]]
)

vcpkg_replace_string("${SOURCE_PATH}/src/PE/Builder.cpp"
[[#include "third-party/utfcpp.hpp"]]
[[#include <utf8cpp/utf8.h>]]
)

vcpkg_replace_string("${SOURCE_PATH}/src/logging.cpp"
[[#include "spdlog/fmt/bundled/args.h"]]
"#include <fmt/args.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/logging.hpp"
"#include <spdlog/fmt/fmt.h>"
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/utils.cpp"
"#include <spdlog/fmt/fmt.h>"
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/internal_utils.hpp"
[[#include "spdlog/fmt/fmt.h"]]
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/PE/Header.cpp"
"#include <spdlog/fmt/fmt.h>"
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/PE/OptionalHeader.cpp"
"#include <spdlog/fmt/fmt.h>"
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/PE/TLS.cpp"
[[#include "spdlog/fmt/fmt.h"]]
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/MachO/BuildVersion.cpp"
"#include <spdlog/fmt/fmt.h>"
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/MachO/SourceVersion.cpp"
[[#include "spdlog/fmt/fmt.h"]]
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/MachO/DylibCommand.cpp"
[[#include "spdlog/fmt/fmt.h"]]
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

vcpkg_replace_string("${SOURCE_PATH}/src/MachO/VersionMin.cpp"
[[#include "spdlog/fmt/fmt.h"]]
"#include <spdlog/fmt/fmt.h>\n#include <spdlog/fmt/ranges.h>"
)

if (VCPKG_TARGET_IS_LINUX)
vcpkg_replace_string("${SOURCE_PATH}/src/internal_utils.hpp"
[[#include "LIEF/iterators.hpp"]]
"#include <LIEF/iterators.hpp>\n#include <memory>"
)
endif()

vcpkg_replace_string("${SOURCE_PATH}/include/LIEF/errors.hpp"
[[#include <LIEF/third-party/expected.hpp>]]
"#include <tl/expected.hpp>"
)

vcpkg_replace_string("${SOURCE_PATH}/include/LIEF/span.hpp"
[[#include <LIEF/third-party/span.hpp>]]
"#include <tcb/span.hpp>"
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"c-api" LIEF_C_API # C API
"enable-json" LIEF_ENABLE_JSON # Enable JSON-related APIs
"examples" LIEF_EXAMPLES # Build LIEF C++ examples
"extra-warnings" LIEF_EXTRA_WARNINGS # Enable extra warning from the compiler
"logging" LIEF_LOGGING # Enable logging
"logging-debug" LIEF_LOGGING_DEBUG # Enable debug logging

"use-ccache" LIEF_USE_CCACHE # Use ccache to speed up compilation

"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

"debug" LIEF_DEBUG_INFO # Build LIEF with DWARF/PDB support
"objc" LIEF_OBJC # Build LIEF with inspect Objective-C metadata support
"dyld-shared-cache" LIEF_DYLD_SHARED_CACHE # Build LIEF with dyld shared cache support
"asm" LIEF_ASM # Build LIEF with assembler/disassembler support
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}

# Build with external vcpkg dependencies
-DLIEF_OPT_MBEDTLS_EXTERNAL=ON
-DLIEF_EXTERNAL_SPDLOG=ON
-DLIEF_OPT_NLOHMANN_JSON_EXTERNAL=ON
-DLIEF_OPT_FROZEN_EXTERNAL=ON
-DLIEF_OPT_EXTERNAL_SPAN=ON
-DLIEF_OPT_UTFCPP_EXTERNAL=ON
-DLIEF_OPT_EXTERNAL_EXPECTED=ON
-DLIEF_DISABLE_FROZEN=OFF
-DLIEF_DISABLE_EXCEPTIONS=OFF
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/LIEF")

vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/lief/LIEFConfig.cmake"
[[include("${LIEF_${lib_type}_export}")]]
[[include("${CMAKE_CURRENT_LIST_DIR}/LIEFExport-${lib_type}.cmake")]]
)

vcpkg_fixup_pkgconfig()

if("debug" IN_LIST FEATURES)
vcpkg_copy_pdbs()
endif()

file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
)

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
9 changes: 9 additions & 0 deletions ports/lief/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
lief provides CMake targets:

find_package(LIEF CONFIG REQUIRED)
target_link_libraries(main PRIVATE LIEF::LIEF)

lief provides pkg-config modules:

# Library to Instrument Executable Formats
LIEF
99 changes: 99 additions & 0 deletions ports/lief/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"name": "lief",
"version-semver": "0.16.0",
"description": "LIEF - Library to Instrument Executable Formats",
"homepage": "https://lief.quarkslab.com",
"license": "Apache-2.0",
"dependencies": [
"fmt",
"frozen",
"mbedtls",
"spdlog",
"tcb-span",
"tl-expected",
"utfcpp",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"default-features": [
"art",
"c-api",
"dex",
"elf",
"enable-json",
"logging",
"macho",
"oat",
"pe",
"vdex"
],
"features": {
"art": {
"description": "Build LIEF with ART module"
},
"asm": {
"description": "Build LIEF with assembler/disassembler support",
"supports": "!(windows & !static)"
},
"c-api": {
"description": "C API"
},
"debug": {
"description": "Build LIEF with DWARF/PDB support",
"supports": "!(windows & !static)"
},
"dex": {
"description": "Build LIEF with DEX module"
},
"dyld-shared-cache": {
"description": "Build LIEF with Dyld shared cache support",
"supports": "!(windows & !static)"
},
"elf": {
"description": "Build LIEF with ELF module"
},
"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"
},
"logging": {
"description": "Enable logging"
},
"logging-debug": {
"description": "Enable debug logging"
},
"macho": {
"description": "Build LIEF with MachO module"
},
"oat": {
"description": "Build LIEF with OAT module"
},
"objc": {
"description": "Build LIEF with ObjC metadata support",
"supports": "!(windows & !static)"
Copy link
Contributor Author

@luadebug luadebug Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet extended features wont work for Windows/UWP Shared
https://lief.re/doc/latest/extended/intro.html

},
"pe": {
"description": "Build LIEF with PE module"
},
"use-ccache": {
"description": "Use ccache to speed up compilation"
},
"vdex": {
"description": "Build LIEF with VDEX module"
}
}
}
7 changes: 7 additions & 0 deletions scripts/test_ports/vcpkg-ci-lief/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SET(VCPKG_POLICY_EMPTY_PACKAGE enabled)

vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
)

vcpkg_cmake_build()
11 changes: 11 additions & 0 deletions scripts/test_ports/vcpkg-ci-lief/project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.24)

project(vcpkg-ci-lief LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 14)

find_package(LIEF CONFIG REQUIRED)

add_executable(main main.cpp)

target_link_libraries(main PRIVATE LIEF::LIEF)
11 changes: 11 additions & 0 deletions scripts/test_ports/vcpkg-ci-lief/project/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>
#include <LIEF/LIEF.hpp>
#include <LIEF/version.h>
using namespace std;
using namespace LIEF;
int main()
{
std::cout << "access flags public = " << LIEF::DEX::to_string(LIEF::DEX::access_flags_list[1]) << std::endl;
std::cout << "Version = " << LIEF_VERSION << std::endl;
return 0;
}
13 changes: 13 additions & 0 deletions scripts/test_ports/vcpkg-ci-lief/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "vcpkg-ci-lief",
"version-string": "ci",
"description": "Testing packages which provide lief",
"license": null,
"dependencies": [
"lief",
{
"name": "vcpkg-cmake",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5524,6 +5524,10 @@
"baseline": "2020-11-24",
"port-version": 0
},
"lief": {
"baseline": "0.16.0",
"port-version": 0
},
"lightgbm": {
"baseline": "4.5.0",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/lief.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "aff018b24b685b86596713f8819c4e3d13d1e6d4",
"version-semver": "0.16.0",
"port-version": 0
}
]
}