mirror of
https://github.com/WerWolv/ImHex
synced 2024-10-21 18:22:26 +00:00
* sys: Updated curl to latest version * sys: Fix macOS compilation * ui: Fix splash screen OpenGL init for macOS * sys: Fix std::min compile errors * git: Re-enabled macos workflow * sys: Remove includes of the range library * build: Find OpenGL using CMake * sys/build: Fix bundled plugins on macOS * build: Copy plugins to bundle when creating a bundle * build: Fixup bundled plugins * sys: Search for plugins in the bundle instead of in Application Support * sys: Allow resources to be placed in multiple directories on macOS * build: Output built plugins to the plugins/ directory when not creating a bundle on macOS * sys: Fix Application Support paths on macOS * sys: Define ftruncate64 on macOS * sys: Fix absolute value computation for std::string::at on macOS Co-authored-by: WerWolv <werwolv98@gmail.com>
This commit is contained in:
parent
21769886fc
commit
72ec6baf79
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
@ -140,7 +140,6 @@ jobs:
|
|||
build/*.msi
|
||||
|
||||
macos:
|
||||
if: false
|
||||
runs-on: macos-11.0
|
||||
name: 🍎 macOS 11.0
|
||||
steps:
|
||||
|
|
|
@ -157,8 +157,15 @@ macro(createPackage)
|
|||
add_subdirectory("plugins/${plugin}")
|
||||
if (TARGET ${plugin})
|
||||
set_target_properties(${plugin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
|
||||
|
||||
if (WIN32)
|
||||
install(TARGETS ${plugin} RUNTIME DESTINATION ${PLUGINS_INSTALL_LOCATION})
|
||||
elseif (APPLE)
|
||||
if (CREATE_BUNDLE)
|
||||
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:imhex>/${PLUGINS_INSTALL_LOCATION})
|
||||
else ()
|
||||
set_target_properties(${plugin} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
|
||||
endif ()
|
||||
else ()
|
||||
install(TARGETS ${plugin} LIBRARY DESTINATION ${PLUGINS_INSTALL_LOCATION})
|
||||
endif ()
|
||||
|
@ -168,7 +175,6 @@ macro(createPackage)
|
|||
endforeach()
|
||||
|
||||
set_target_properties(libimhex PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
install(TARGETS libimhex RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
if (WIN32)
|
||||
# Install binaries directly in the prefix, usually C:\Program Files\ImHex.
|
||||
|
|
|
@ -26,9 +26,8 @@ get_filename_component(BUNDLE_PATH "${BUNDLE_PATH}" ABSOLUTE)
|
|||
message(STATUS "Fixing up application bundle: ${BUNDLE_PATH}")
|
||||
|
||||
|
||||
# Make sure to fix up any additional shared libraries (like plugins) that are
|
||||
# needed.
|
||||
file(GLOB_RECURSE extra_libs "${BUNDLE_PATH}/Contents/MacOS/*.dylib")
|
||||
# Make sure to fix up any included ImHex plugin.
|
||||
file(GLOB_RECURSE extra_libs "${BUNDLE_PATH}/Contents/MacOS/plugins/*.hexplug")
|
||||
|
||||
message(STATUS "Fixing up application bundle: ${extra_dirs}")
|
||||
|
||||
|
|
6
external/ImGui/CMakeLists.txt
vendored
6
external/ImGui/CMakeLists.txt
vendored
|
@ -7,6 +7,10 @@ find_package(PkgConfig REQUIRED)
|
|||
find_package(Freetype REQUIRED)
|
||||
pkg_search_module(GLFW REQUIRED glfw3)
|
||||
|
||||
if (UNIX)
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
|
||||
add_library(imgui STATIC
|
||||
|
@ -43,5 +47,5 @@ target_link_directories(imgui PUBLIC ${GLFW_LIBRARY_DIRS})
|
|||
if (WIN32)
|
||||
target_link_libraries(imgui Freetype::Freetype glfw3 opengl32.lib)
|
||||
elseif (UNIX)
|
||||
target_link_libraries(imgui Freetype::Freetype glfw GL)
|
||||
target_link_libraries(imgui Freetype::Freetype glfw OpenGL::GL)
|
||||
endif()
|
||||
|
|
2
external/curl
vendored
2
external/curl
vendored
|
@ -1 +1 @@
|
|||
Subproject commit bfbde883af33397943df68a3ae01847a634d33bf
|
||||
Subproject commit aceff6088cef70843de1da1dd7cc03c37c094d99
|
|
@ -193,7 +193,14 @@ namespace hex::plugin::builtin {
|
|||
auto string = Token::literalToString(params[0], false);
|
||||
auto index = Token::literalToSigned(params[1]);
|
||||
|
||||
if (std::abs(index) > string.length())
|
||||
#if defined(OS_MACOS)
|
||||
const auto signIndex = index >> (sizeof(index) * 8 - 1);
|
||||
const auto absIndex = (index ^ signIndex) - signIndex;
|
||||
#else
|
||||
const auto absIndex = std::abs(index);
|
||||
#endif
|
||||
|
||||
if (absIndex > string.length())
|
||||
LogConsole::abortEvaluation("character index out of range");
|
||||
|
||||
if (index >= 0)
|
||||
|
|
|
@ -750,8 +750,9 @@ namespace hex::plugin::builtin {
|
|||
size_t fileSize = file.getSize();
|
||||
for (const auto &pattern : overwritePattern) {
|
||||
for (u64 offset = 0; offset < fileSize; offset += 3) {
|
||||
file.write(pattern.data(), std::min(pattern.size(), fileSize - offset));
|
||||
file.write(pattern.data(), std::min<u64>(pattern.size(), fileSize - offset));
|
||||
}
|
||||
|
||||
file.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define fopen64 fopen
|
||||
#define fseeko64 fseek
|
||||
#define ftello64 ftell
|
||||
#define ftruncate64 ftruncate
|
||||
#endif
|
||||
|
||||
namespace hex {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <hex/helpers/paths.hpp>
|
||||
|
||||
namespace hex {
|
||||
std::string getPathForMac(ImHexPath path);
|
||||
std::string getMacExecutableDirectoryPath();
|
||||
std::string getMacApplicationSupportDirectoryPath();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <hex/helpers/concepts.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <functional>
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
#include <hex/pattern_language/evaluator.hpp>
|
||||
#include <hex/pattern_language/pattern_data.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <bit>
|
||||
#include <optional>
|
||||
#include <map>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <ranges>
|
||||
|
||||
#include <hex/pattern_language/ast_node_base.hpp>
|
||||
|
||||
|
@ -1534,9 +1534,9 @@ namespace hex::pl {
|
|||
continue;
|
||||
} else {
|
||||
bool found = false;
|
||||
for (const auto &variable : (searchScope | std::views::reverse)) {
|
||||
if (variable->getVariableName() == name) {
|
||||
auto newPattern = variable->clone();
|
||||
for (auto iter = searchScope.crbegin(); iter != searchScope.crend(); ++iter) {
|
||||
if ((*iter)->getVariableName() == name) {
|
||||
auto newPattern = (*iter)->clone();
|
||||
delete currPattern;
|
||||
currPattern = newPattern;
|
||||
found = true;
|
||||
|
|
|
@ -83,7 +83,39 @@ namespace hex {
|
|||
|
||||
return results;
|
||||
#elif defined(OS_MACOS)
|
||||
return { getPathForMac(path) };
|
||||
// Get path to special directories
|
||||
const std::filesystem::path exeDir(getMacExecutableDirectoryPath());
|
||||
const std::filesystem::path applicationSupportDir(getMacApplicationSupportDirectoryPath());
|
||||
|
||||
std::vector<std::filesystem::path> paths = { exeDir, applicationSupportDir };
|
||||
std::vector<std::string> results;
|
||||
|
||||
switch (path) {
|
||||
case ImHexPath::Patterns:
|
||||
return { (applicationSupportDir / "patterns").string() };
|
||||
case ImHexPath::PatternsInclude:
|
||||
return { (applicationSupportDir / "includes").string() };
|
||||
case ImHexPath::Magic:
|
||||
return { (applicationSupportDir / "magic").string() };
|
||||
case ImHexPath::Python:
|
||||
return { (applicationSupportDir / "python").string() };
|
||||
case ImHexPath::Plugins:
|
||||
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
|
||||
return (path / "plugins").string();
|
||||
});
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
return { (applicationSupportDir / "yara").string() };
|
||||
case ImHexPath::Config:
|
||||
return { (applicationSupportDir / "config").string() };
|
||||
case ImHexPath::Resources:
|
||||
return { (applicationSupportDir / "resources").string() };
|
||||
case ImHexPath::Constants:
|
||||
return { (applicationSupportDir / "constants").string() };
|
||||
default: __builtin_unreachable();
|
||||
}
|
||||
|
||||
return results;
|
||||
#else
|
||||
std::vector<std::filesystem::path> configDirs = xdg::ConfigDirs();
|
||||
std::vector<std::filesystem::path> dataDirs = xdg::DataDirs();
|
||||
|
|
|
@ -1,58 +1,29 @@
|
|||
#if defined(OS_MACOS)
|
||||
#include <hex/helpers/utils_mac.h>
|
||||
#include <hex/helpers/paths_mac.h>
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
namespace hex {
|
||||
std::string getPathForMac(ImHexPath path) {
|
||||
std::string getMacExecutableDirectoryPath() {
|
||||
@autoreleasepool {
|
||||
NSError * error = nil;
|
||||
NSURL * appSupportDir = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:YES
|
||||
error:&error];
|
||||
return {[[[[[NSBundle mainBundle] executableURL] URLByDeletingLastPathComponent] path] UTF8String]};
|
||||
}
|
||||
}
|
||||
|
||||
std::string getMacApplicationSupportDirectoryPath() {
|
||||
@autoreleasepool {
|
||||
NSError* error = nil;
|
||||
NSURL* dirUrl = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
|
||||
inDomain:NSUserDomainMask
|
||||
appropriateForURL:nil
|
||||
create:YES
|
||||
error:&error];
|
||||
|
||||
if (error != nil) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
NSURL * result = nil;
|
||||
switch (path) {
|
||||
case ImHexPath::Patterns:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/patterns"];
|
||||
break;
|
||||
|
||||
case ImHexPath::PatternsInclude:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/patterns"];
|
||||
break;
|
||||
case ImHexPath::Magic:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/magic"];
|
||||
break;
|
||||
case ImHexPath::Python:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex"];
|
||||
break;
|
||||
case ImHexPath::Plugins:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/plugins"];
|
||||
break;
|
||||
case ImHexPath::Yara:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/yara"];
|
||||
break;
|
||||
case ImHexPath::Config:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/config"];
|
||||
break;
|
||||
case ImHexPath::Resources:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/resources"];
|
||||
break;
|
||||
case ImHexPath::Constants:
|
||||
result = [appSupportDir URLByAppendingPathComponent:@"imhex/constants"];
|
||||
break;
|
||||
}
|
||||
|
||||
if (result == nil) {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
return std::string([[result path] UTF8String]);
|
||||
return {[[[dirUrl URLByAppendingPathComponent:(@"imhex")] path] UTF8String]};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,26 +27,28 @@
|
|||
|
||||
#elif defined(OS_MACOS)
|
||||
|
||||
#define RESOURCE_NULL_TERMINATED(name, path) \
|
||||
#define RESOURCE(name, path) \
|
||||
__asm__ ( \
|
||||
".global " #name ";\n" \
|
||||
".global " #name "_size;\n" \
|
||||
#name ":\n" \
|
||||
".global _" #name ";\n" \
|
||||
".global _" #name "_size;\n" \
|
||||
"_" #name ":\n" \
|
||||
".incbin \"" path "\";\n" \
|
||||
#name "_size:\n" \
|
||||
".int " #name "_size - " #name ";\n" \
|
||||
".align 8;\n" \
|
||||
"_" #name "_size:\n" \
|
||||
".int _" #name "_size - _" #name ";\n" \
|
||||
".align 8;\n" \
|
||||
)
|
||||
|
||||
#define RESOURCE_NULL_TERMINATED(name, path) \
|
||||
__asm__ ( \
|
||||
".global " #name ";\n" \
|
||||
".global " #name "_size;\n" \
|
||||
#name ":\n" \
|
||||
".global _" #name ";\n" \
|
||||
".global _" #name "_size;\n" \
|
||||
"_" #name ":\n" \
|
||||
".incbin \"" path "\";\n" \
|
||||
".byte 0\n" \
|
||||
#name "_size:\n" \
|
||||
".int " #name "_size - " #name ";\n" \
|
||||
".align 8;\n" \
|
||||
"_" #name "_size:\n" \
|
||||
".int _" #name "_size - _" #name ";\n" \
|
||||
".align 8;\n" \
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "helpers/encoding_file.hpp"
|
||||
|
||||
#include <ranges>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
@ -17,7 +16,9 @@ namespace hex {
|
|||
}
|
||||
|
||||
std::pair<std::string_view, size_t> EncodingFile::getEncodingFor(const std::vector<u8> &buffer) const {
|
||||
for (const auto &[size, mapping] : this->m_mapping | std::views::reverse) {
|
||||
for (auto riter = this->m_mapping.crbegin(); riter != this->m_mapping.crend(); ++riter) {
|
||||
const auto &[size, mapping] = *riter;
|
||||
|
||||
if (size > buffer.size()) continue;
|
||||
|
||||
auto key = std::vector<u8>(buffer.begin(), buffer.begin() + size);
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace hex::init {
|
|||
ImGui::StyleColorsDark();
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(this->m_window, true);
|
||||
ImGui_ImplOpenGL3_Init("#version 130");
|
||||
ImGui_ImplOpenGL3_Init("#version 150");
|
||||
|
||||
auto &io = ImGui::GetIO();
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace hex {
|
|||
|
||||
std::vector<u8> buffer(0x10000);
|
||||
for (u64 offset = 0; offset < header.size; offset += buffer.size()) {
|
||||
auto readSize = std::min(buffer.size(), header.size - offset);
|
||||
auto readSize = std::min<u64>(buffer.size(), header.size - offset);
|
||||
mtar_read_data(&ctx, buffer.data(), readSize);
|
||||
|
||||
buffer.resize(readSize);
|
||||
|
|
Loading…
Reference in a new issue