-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Changes from all commits
bb08d3e
5f08f62
3ea5f30
2cd7cf1
c3a499f
f391c67
fde8501
991a888
2dfaeba
6ae9a57
bea8260
d94531a
8dd31d3
7f4b3a9
ad8799d
73a7bfa
3017791
f85f0d1
61f58eb
7cf39fc
b7f5b46
23aedc7
243ac62
8315f34
7552ead
a9206d8
36819c5
2a81ceb
c4a2a64
e543654
667b350
b7fd1d1
2353914
df580df
b29d770
ca48233
4bc73c3
d7f5c63
756a4fb
f58b4bd
0f043ae
834178f
d09196d
3b311d6
084abeb
32191c3
8116f9b
5b0da05
a57caea
e13c475
08938ed
c4dfaa5
09db381
ad62504
1e1ba2a
0261c79
4115000
06e5138
f066b24
83f0c54
25bcf61
5c03fbc
2787775
8d55be8
7a65f59
1fde52a
4a1afed
5403ff9
8c8ddb2
d796d9f
43a9181
9f8aa76
3e47dff
6056577
09db302
643488e
7466fde
68ddc98
2727050
b7660e3
6eff159
3000897
8bc2940
e1c0361
4b0da2d
7a2a629
64bb3c3
8d8dba3
c858394
3845f25
aa8e377
8496f22
96a2ce0
75868e8
f04fc8c
0ac87c4
5b3e0fc
8f98a69
c7b33fa
02dce0f
85f1870
762ed13
1575b18
b73c4c0
532b77b
f5a0f66
9013183
438a291
5fb3aae
f2740d8
4f52cea
11f78ac
9f4157a
ef132a3
7aa87d8
0ead927
bec34d6
88a54b0
23e02dd
d7ae488
58116d6
dd34b83
e512c27
900d3d2
106b399
4115c90
5f820ff
3ff8dd3
1e5670b
e1911bb
fbeb5d3
2297141
c0c4182
1e9de7e
4fc103e
92b782b
d4cd77b
3e2ecd3
6a67018
0472a6c
c57d44d
62f7832
6d18562
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index fc2b679..4ec92b9 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -113,19 +113,7 @@ message(STATUS "CMAKE_CXX_IMPLICIT_LINK_LIBRARIES: ${CMAKE_CXX_IMPLICIT_LINK_LIB | ||
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") | ||
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY: ${CMAKE_MSVC_RUNTIME_LIBRARY}") | ||
|
||
-if(LIEF_INSTALL) | ||
- if(UNIX) | ||
- include(GNUInstallDirs) | ||
- set(CMAKE_INSTALL_LIBDIR "lib") | ||
- else() | ||
- set(CMAKE_INSTALL_LIBDIR "lib") | ||
- set(CMAKE_INSTALL_DATADIR "share") | ||
set(CMAKE_INSTALL_INCLUDEDIR "include") | ||
- set(CMAKE_INSTALL_BINDIR "bin") | ||
- set(CMAKE_INSTALL_DATAROOTDIR "share") | ||
- message(STATUS "Setting installation destination to: ${CMAKE_INSTALL_PREFIX}") | ||
- endif() | ||
-endif() | ||
|
||
# LIEF Source definition | ||
# ====================== | ||
@@ -318,7 +306,9 @@ else() | ||
${CMAKE_CURRENT_BINARY_DIR}/include/LIEF/third-party/internal/span.hpp) | ||
endif() | ||
|
||
-target_link_libraries(LIB_LIEF PRIVATE lief_spdlog) | ||
+find_package(fmt CONFIG REQUIRED) | ||
+find_package(spdlog CONFIG REQUIRED) | ||
+target_link_libraries(LIB_LIEF PRIVATE fmt::fmt spdlog::spdlog) | ||
|
||
if(ANDROID AND LIEF_LOGGING) | ||
target_link_libraries(LIB_LIEF PUBLIC log) | ||
@@ -507,11 +497,11 @@ if(LIEF_INSTALL) | ||
endif() | ||
|
||
install( | ||
- TARGETS LIB_LIEF lief_spdlog | ||
+ TARGETS LIB_LIEF | ||
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( |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/cmake/LIEFConfig.cmake.in b/cmake/LIEFConfig.cmake.in | ||
index dba7363..7f88f98 100644 | ||
--- a/cmake/LIEFConfig.cmake.in | ||
+++ b/cmake/LIEFConfig.cmake.in | ||
@@ -69,7 +69,7 @@ macro(LIEF_load_targets lib_type) | ||
return() | ||
endif () | ||
|
||
- if("${lib_type}" STREQUAL "static") | ||
+ if(1) | ||
# Need to find all dependencies even if they're private when LIEF is | ||
# compiled statically | ||
include(CMakeFindDependencyMacro) | ||
@@ -93,6 +93,10 @@ macro(LIEF_load_targets lib_type) | ||
if(NOT @LIEF_DISABLE_FROZEN@ AND @LIEF_OPT_FROZEN_EXTERNAL@) | ||
find_dependency(frozen) | ||
endif() | ||
+ | ||
+ find_dependency(tl-expected) | ||
+ find_dependency(fmt) | ||
+ check_required_components(lief) | ||
endif() | ||
|
||
# Include the respective targets file |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
diff --git a/src/BinaryStream/BinaryStream.cpp b/src/BinaryStream/BinaryStream.cpp | ||
index 83e618c..6447b7b 100644 | ||
--- a/src/BinaryStream/BinaryStream.cpp | ||
+++ b/src/BinaryStream/BinaryStream.cpp | ||
@@ -15,7 +15,7 @@ | ||
*/ | ||
#include "LIEF/BinaryStream/BinaryStream.hpp" | ||
#include "LIEF/DWARF/enums.hpp" | ||
-#include "third-party/utfcpp.hpp" | ||
+#include <utf8cpp/utf8.h> | ||
|
||
#include <mbedtls/x509.h> | ||
#include <mbedtls/x509_crt.h> | ||
diff --git a/src/PE/Builder.cpp b/src/PE/Builder.cpp | ||
index 8cbe7b2..994e9bf 100644 | ||
--- a/src/PE/Builder.cpp | ||
+++ b/src/PE/Builder.cpp | ||
@@ -21,7 +21,7 @@ | ||
|
||
#include "logging.hpp" | ||
|
||
-#include "third-party/utfcpp.hpp" | ||
+#include <utf8cpp/utf8.h> | ||
|
||
|
||
#include "LIEF/PE/Builder.hpp" | ||
diff --git a/src/logging.cpp b/src/logging.cpp | ||
index 39936fe..f5e1345 100644 | ||
--- a/src/logging.cpp | ||
+++ b/src/logging.cpp | ||
@@ -20,7 +20,7 @@ | ||
#include "logging.hpp" | ||
|
||
#include "spdlog/spdlog.h" | ||
-#include "spdlog/fmt/bundled/args.h" | ||
+#include <fmt/args.h> | ||
#include "spdlog/sinks/stdout_color_sinks.h" | ||
#include "spdlog/sinks/basic_file_sink.h" | ||
#include "spdlog/sinks/android_sink.h" | ||
diff --git a/src/utils.cpp b/src/utils.cpp | ||
index 0acbba1..b624a1d 100644 | ||
--- a/src/utils.cpp | ||
+++ b/src/utils.cpp | ||
@@ -22,7 +22,7 @@ | ||
#include "LIEF/utils.hpp" | ||
#include "LIEF/errors.hpp" | ||
|
||
-#include "third-party/utfcpp.hpp" | ||
+#include <utf8cpp/utf8.h> | ||
|
||
#include "LIEF/config.h" | ||
#include "logging.hpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
vcpkg_download_distfile( | ||
FIX_FMT_V11_JOIN_LINUX_INCLUDE_MEMORY_PATCH | ||
URLS https://github.com/lief-project/LIEF/commit/41166332a2435fdb7d2bdc5c73f9ff9b442c5459.patch?full_index=1 | ||
FILENAME fix-fmt-v11-join-linux-include-memory-41166332a2435fdb7d2bdc5c73f9ff9b442c5459.patch | ||
SHA512 14d5f7380352bd340c16447905b8185dbd2d977c8ba245e01d982fe7fbbdffb71004b9d4fdd732bc13e71a11aa3f46a4822cdeb2277e2cec6b841492d0de5606 | ||
) | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO lief-project/LIEF | ||
REF ${VERSION} | ||
SHA512 7df75fab6c7023e37a6a4d27fac8dcb4200e0235625fc5952bb23cedb2e582a37fb67ee471c1ae953c0b205fd9cca5538a835f65ef80a771f72dc7ff68000ed9 | ||
HEAD_REF master | ||
PATCHES | ||
fix-cmakelists.patch | ||
fix-liefconfig-cmake-in.patch | ||
fix-vcpkg-includes.patch | ||
"${FIX_FMT_V11_JOIN_LINUX_INCLUDE_MEMORY_PATCH}" | ||
) | ||
|
||
file(REMOVE_RECURSE "${SOURCE_PATH}/third-party") | ||
|
||
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 | ||
"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 | ||
) | ||
|
||
vcpkg_cmake_configure( | ||
SOURCE_PATH "${SOURCE_PATH}" | ||
OPTIONS | ||
${FEATURE_OPTIONS} | ||
-DLIEF_EXAMPLES=OFF | ||
|
||
# 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 | ||
|
||
"-DLIEF_EXTERNAL_SPAN_DIR=${_VCPKG_INSTALLED_DIR}/${TARGET_TRIPLET}/include/tcb" | ||
) | ||
|
||
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() | ||
|
||
file(REMOVE_RECURSE | ||
"${CURRENT_PACKAGES_DIR}/debug/include" | ||
"${CURRENT_PACKAGES_DIR}/debug/share" | ||
) | ||
|
||
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"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", | ||
"dex", | ||
"elf", | ||
"enable-json", | ||
"logging", | ||
"macho", | ||
"oat", | ||
"pe", | ||
"vdex" | ||
], | ||
Comment on lines
+24
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default features in vcpkg are meant to ensure basic functionality for users who may not know they’re using the library. They must not add APIs, executables, or optional capabilities. -> Please revisit the default feature set and reduce it to only what is strictly necessary for the library to be reasonably functional. Additionally, none of the features introduced in this PR can be alternatives of each other. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As the core dev of LIEF, I confirm that these options are the expected features There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thank you for your confirmation. |
||
"features": { | ||
"art": { | ||
"description": "Build LIEF with ART module" | ||
}, | ||
"c-api": { | ||
"description": "C API" | ||
}, | ||
"dex": { | ||
"description": "Build LIEF with DEX module" | ||
}, | ||
"elf": { | ||
"description": "Build LIEF with ELF module" | ||
}, | ||
"enable-json": { | ||
"description": "Enable JSON-related APIs", | ||
"dependencies": [ | ||
"nlohmann-json" | ||
] | ||
}, | ||
"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" | ||
}, | ||
"pe": { | ||
"description": "Build LIEF with PE module" | ||
}, | ||
"use-ccache": { | ||
"description": "Use ccache to speed up compilation" | ||
}, | ||
"vdex": { | ||
"description": "Build LIEF with VDEX module" | ||
} | ||
} | ||
} |
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() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
#include <LIEF/LIEF.hpp> | ||
#include <LIEF/version.h> | ||
|
||
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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "vcpkg-ci-lief", | ||
"version-string": "ci", | ||
"description": "Testing packages which provide lief", | ||
"license": null, | ||
"dependencies": [ | ||
{ | ||
"name": "lief", | ||
"features": [ | ||
"c-api", | ||
"enable-json", | ||
"extra-warnings", | ||
"logging", | ||
"logging-debug", | ||
"use-ccache", | ||
"elf", | ||
"pe", | ||
"macho", | ||
"oat", | ||
"dex", | ||
"vdex", | ||
"art" | ||
] | ||
}, | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"git-tree": "fafe51c4db1abe4b79e44013592db1c89945740d", | ||
"version-semver": "0.16.0", | ||
"port-version": 0 | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ports are not allowed to use vendored dependencies in vcpkg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ve removed third-party folder in 21 line.
file(REMOVE_RECURSE "${SOURCE_PATH}/third-party")
Indeed, but those flags are responsible to provide packages. https://github.com/lief-project/LIEF/blob/41166332a2435fdb7d2bdc5c73f9ff9b442c5459/CMakeLists.txt#L245-L248
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JavierMatosD CMake options
*_EXTERNAL
are exactly intended for this.