1
0
mirror of synced 2024-12-01 02:37:18 +01:00

build: Bundle files from the ImHex-Patterns repo with the installation

This commit is contained in:
WerWolv 2022-02-21 22:47:56 +01:00
parent bdb2ac3a0b
commit 1487f760b0
3 changed files with 27 additions and 5 deletions

View File

@ -35,3 +35,6 @@ add_subdirectory(tests EXCLUDE_FROM_ALL)
# Configure packaging # Configure packaging
createPackage() createPackage()
# Download and install all current files from the ImHex-Patterns repo
downloadImHexPatternsFiles()

View File

@ -1,3 +1,5 @@
include(FetchContent)
macro(addVersionDefines) macro(addVersionDefines)
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git") if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
# Get the current working branch # Get the current working branch
@ -279,3 +281,20 @@ macro(detectBadClone)
endif() endif()
endforeach () endforeach ()
endmacro() endmacro()
function(downloadImHexPatternsFiles)
FetchContent_Declare(
imhex_patterns
GIT_REPOSITORY https://github.com/WerWolv/ImHex-Patterns.git
GIT_TAG master
)
FetchContent_Populate(imhex_patterns)
set(PATTERNS_FOLDERS_TO_INSTALL constants encodings includes patterns yara magic)
foreach (FOLDER ${PATTERNS_FOLDERS_TO_INSTALL})
install(DIRECTORY "${imhex_patterns_SOURCE_DIR}/${FOLDER}" DESTINATION "./")
endforeach()
endfunction()

View File

@ -59,7 +59,7 @@ namespace hex {
CoTaskMemFree(wAppDataPath); CoTaskMemFree(wAppDataPath);
} }
std::vector<fs::path> paths = { parentDir, appDataDir / "imhex" }; std::vector<fs::path> paths = { appDataDir / "imhex", parentDir };
switch (path) { switch (path) {
case ImHexPath::Patterns: case ImHexPath::Patterns:
@ -128,7 +128,7 @@ namespace hex {
// Get path to special directories // Get path to special directories
const fs::path applicationSupportDir(getMacApplicationSupportDirectoryPath()); const fs::path applicationSupportDir(getMacApplicationSupportDirectoryPath());
std::vector<fs::path> paths = { exePath, applicationSupportDir }; std::vector<fs::path> paths = { applicationSupportDir, exePath };
switch (path) { switch (path) {
case ImHexPath::Patterns: case ImHexPath::Patterns:
@ -179,9 +179,6 @@ namespace hex {
for (auto &dir : dataDirs) for (auto &dir : dataDirs)
dir = dir / "imhex"; dir = dir / "imhex";
if (!exePath.empty())
dataDirs.emplace(dataDirs.begin(), fs::path(exePath.data()).parent_path());
switch (path) { switch (path) {
case ImHexPath::Patterns: case ImHexPath::Patterns:
addUserDirs(dataDirs); addUserDirs(dataDirs);
@ -226,6 +223,9 @@ namespace hex {
default: default:
__builtin_unreachable(); __builtin_unreachable();
} }
if (!exePath.empty())
dataDirs.emplace(dataDirs.begin(), fs::path(exePath.data()).parent_path());
#endif #endif
if (!listNonExisting) { if (!listNonExisting) {