build: Make this modules stuff actually mostly work on Clang

This commit is contained in:
WerWolv
2025-02-18 00:39:53 +01:00
parent 3f119b957e
commit ccaf1e33c0
47 changed files with 119 additions and 56 deletions

View File

@@ -32,6 +32,7 @@ include("${IMHEX_BASE_FOLDER}/cmake/ide_helpers.cmake")
# Basic compiler and cmake configurations # Basic compiler and cmake configurations
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake") include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")

View File

@@ -665,6 +665,7 @@ macro(setupCompilerFlags target)
addCCXXFlag("-Wno-array-bounds" ${target}) addCCXXFlag("-Wno-array-bounds" ${target})
addCCXXFlag("-Wno-deprecated-declarations" ${target}) addCCXXFlag("-Wno-deprecated-declarations" ${target})
addCCXXFlag("-Wno-unknown-pragmas" ${target}) addCCXXFlag("-Wno-unknown-pragmas" ${target})
addCXXFlag("-Wno-include-angled-in-module-purview" ${target})
# Enable hardening flags # Enable hardening flags
addCommonFlag("-U_FORTIFY_SOURCE" ${target}) addCommonFlag("-U_FORTIFY_SOURCE" ${target})

View File

@@ -17,22 +17,35 @@ module;
#include <ranges> #include <ranges>
#include <fstream> #include <fstream>
#include <thread> #include <thread>
#include <future>
#include <fmt/format.h> #include <fmt/format.h>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <wolv/io/file.hpp>
#include <imgui.h>
#include <imgui_internal.h>
#include <hex/ui/imgui_imhex_extensions.h>
#include <hex/helpers/auto_reset.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/providers/provider.hpp>
#include <hex/providers/provider_data.hpp>
#include <hex/data_processor/node.hpp>
#include <hex/data_processor/link.hpp>
#include <hex/data_processor/attribute.hpp>
#include <pl/pattern_language.hpp>
export module hex; export module hex;
#define HEX_MODULE_EXPORT #define HEX_MODULE_EXPORT
#include <hex/api/task_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/event_manager.hpp>
#include <hex/api/imhex_api.hpp> #include <hex/api/imhex_api.hpp>
#include <hex/api/layout_manager.hpp> #include <hex/api/layout_manager.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/plugin_manager.hpp> #include <hex/api/plugin_manager.hpp>
#include <hex/api/shortcut_manager.hpp> #include <hex/api/shortcut_manager.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/theme_manager.hpp> #include <hex/api/theme_manager.hpp>
#include <hex/api/tutorial_manager.hpp> #include <hex/api/tutorial_manager.hpp>
#include <hex/api/workspace_manager.hpp> #include <hex/api/workspace_manager.hpp>

View File

@@ -16,7 +16,7 @@
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/helpers/auto_reset.hpp> #include <hex/helpers/auto_reset.hpp>
namespace hex { EXPORT_MODULE namespace hex {
class AchievementManager; class AchievementManager;

View File

@@ -16,27 +16,31 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <wolv/io/fs.hpp> #include <wolv/io/fs.hpp>
using ImGuiDataType = int; #if !defined(HEX_MODULE_EXPORT)
using ImGuiInputTextFlags = int; using ImGuiDataType = int;
struct ImColor; using ImGuiInputTextFlags = int;
enum ImGuiCustomCol : int; struct ImColor;
typedef int ImGuiColorEditFlags; enum ImGuiCustomCol : int;
typedef int ImGuiColorEditFlags;
#endif
namespace hex { EXPORT_MODULE namespace hex {
class View; #if !defined(HEX_MODULE_EXPORT)
class Task; class View;
class Task;
namespace dp { namespace dp {
class Node; class Node;
} }
namespace prv { namespace prv {
class Provider; class Provider;
} }
namespace LocalizationManager { namespace LocalizationManager {
class LanguageDefinition; class LanguageDefinition;
} }
#endif
/* /*
The Content Registry is the heart of all features in ImHex that are in some way extendable by Plugins. The Content Registry is the heart of all features in ImHex that are in some way extendable by Plugins.

View File

@@ -31,7 +31,7 @@
#define EVENT_DEF_NO_LOG(event_name, ...) EVENT_DEF_IMPL(event_name, #event_name, false, __VA_ARGS__) #define EVENT_DEF_NO_LOG(event_name, ...) EVENT_DEF_IMPL(event_name, #event_name, false, __VA_ARGS__)
namespace hex { EXPORT_MODULE namespace hex {
namespace impl { namespace impl {

View File

@@ -14,21 +14,25 @@
#include <set> #include <set>
#include <memory> #include <memory>
using ImGuiID = unsigned int; #if !defined(HEX_MODULE_EXPORT)
struct ImVec2; using ImGuiID = unsigned int;
struct ImFontAtlas; struct ImVec2;
struct ImFont; struct ImFontAtlas;
struct ImFont;
#endif
struct GLFWwindow; struct GLFWwindow;
EXPORT_MODULE namespace hex { EXPORT_MODULE namespace hex {
namespace impl { #if !defined(HEX_MODULE_EXPORT)
class AutoResetBase; namespace impl {
} class AutoResetBase;
}
namespace prv { namespace prv {
class Provider; class Provider;
} }
#endif
namespace ImHexApi { namespace ImHexApi {

View File

@@ -4,9 +4,11 @@
#include <string> #include <string>
struct ImGuiTextBuffer; #if !defined(HEX_MODULE_EXPORT)
struct ImGuiTextBuffer;
#endif
namespace hex { EXPORT_MODULE namespace hex {
class LayoutManager { class LayoutManager {
public: public:

View File

@@ -10,9 +10,11 @@
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
#include <hex/helpers/auto_reset.hpp> #include <hex/helpers/auto_reset.hpp>
struct ImGuiContext; #if !defined(HEX_MODULE_EXPORT)
struct ImGuiContext;
#endif
namespace hex { EXPORT_MODULE namespace hex {
struct SubCommand { struct SubCommand {
enum class Type : u8 { enum class Type : u8 {

View File

@@ -9,7 +9,7 @@
* that want to store any data to a Project File. * that want to store any data to a Project File.
* *
*/ */
namespace hex { EXPORT_MODULE namespace hex {
namespace prv { namespace prv {
class Provider; class Provider;

View File

@@ -9,7 +9,9 @@
#include <set> #include <set>
#include <string> #include <string>
struct ImGuiWindow; #if !defined(HEX_MODULE_EXPORT)
struct ImGuiWindow;
#endif
struct KeyEquivalent { struct KeyEquivalent {
bool valid; bool valid;
@@ -17,7 +19,7 @@ struct KeyEquivalent {
int key; int key;
}; };
namespace hex { EXPORT_MODULE namespace hex {
class View; class View;

View File

@@ -11,7 +11,7 @@
#include <condition_variable> #include <condition_variable>
#include <source_location> #include <source_location>
namespace hex { EXPORT_MODULE namespace hex {
class TaskHolder; class TaskHolder;
class TaskManager; class TaskManager;

View File

@@ -9,7 +9,7 @@
#include <nlohmann/json_fwd.hpp> #include <nlohmann/json_fwd.hpp>
#include <imgui.h> #include <imgui.h>
namespace hex { EXPORT_MODULE namespace hex {
/** /**
* @brief The Theme Manager takes care of loading and applying themes * @brief The Theme Manager takes care of loading and applying themes

View File

@@ -10,7 +10,7 @@
#include <hex/ui/imgui_imhex_extensions.h> #include <hex/ui/imgui_imhex_extensions.h>
namespace hex { EXPORT_MODULE namespace hex {
class TutorialManager { class TutorialManager {
public: public:

View File

@@ -6,7 +6,7 @@
#include <map> #include <map>
#include <string> #include <string>
namespace hex { EXPORT_MODULE namespace hex {
class WorkspaceManager { class WorkspaceManager {
public: public:

View File

@@ -8,7 +8,7 @@
#include <wolv/io/file.hpp> #include <wolv/io/file.hpp>
#include <wolv/utils/guards.hpp> #include <wolv/utils/guards.hpp>
namespace hex::log { EXPORT_MODULE namespace hex::log {
namespace impl { namespace impl {

View File

@@ -30,9 +30,11 @@
namespace hex { namespace hex {
namespace prv { #if !defined(HEX_MODULE_EXPORT)
class Provider; namespace prv {
} class Provider;
}
#endif
template<typename T> template<typename T>
[[nodiscard]] std::vector<std::vector<T>> sampleChannels(const std::vector<T> &data, size_t count, size_t channels) { [[nodiscard]] std::vector<std::vector<T>> sampleChannels(const std::vector<T> &data, size_t count, size_t channels) {

View File

@@ -4,7 +4,9 @@
#if defined(OS_MACOS) #if defined(OS_MACOS)
struct GLFWwindow; #if !defined(HEX_MODULE_EXPORT)
struct GLFWwindow;
#endif
extern "C" { extern "C" {

View File

@@ -12,9 +12,11 @@
namespace hex { namespace hex {
namespace prv { #if !defined(HEX_MODULE_EXPORT)
class Provider; namespace prv {
} class Provider;
}
#endif
template<typename T> template<typename T>
class PerProvider { class PerProvider {

View File

@@ -2,7 +2,6 @@
#include <hex.hpp> #include <hex.hpp>
#include <hex/api/localization_manager.hpp> #include <hex/api/localization_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/providers/undo_redo/operations/operation.hpp> #include <hex/providers/undo_redo/operations/operation.hpp>
@@ -35,7 +34,6 @@ namespace hex::prv::undo {
template<std::derived_from<Operation> T> template<std::derived_from<Operation> T>
bool add(auto && ... args) { bool add(auto && ... args) {
auto result = this->add(std::make_unique<T>(std::forward<decltype(args)>(args)...)); auto result = this->add(std::make_unique<T>(std::forward<decltype(args)>(args)...));
EventDataChanged::post(m_provider);
return result; return result;
} }

View File

@@ -7,6 +7,7 @@
#include <hex/api/events/requests_lifecycle.hpp> #include <hex/api/events/requests_lifecycle.hpp>
#include <hex/api/events/requests_provider.hpp> #include <hex/api/events/requests_provider.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/helpers/fmt.hpp> #include <hex/helpers/fmt.hpp>

View File

@@ -20,6 +20,7 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <bit> #include <bit>
#include <span>
#if MBEDTLS_VERSION_MAJOR <= 2 #if MBEDTLS_VERSION_MAJOR <= 2

View File

@@ -2,6 +2,7 @@
#include <hex.hpp> #include <hex.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>

View File

@@ -1,5 +1,6 @@
#include <hex/providers/undo_redo/stack.hpp> #include <hex/providers/undo_redo/stack.hpp>
#include <hex/providers/undo_redo/operations/operation_group.hpp> #include <hex/providers/undo_redo/operations/operation_group.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
@@ -122,6 +123,8 @@ namespace hex::prv::undo {
// Do the operation // Do the operation
this->getLastOperation()->redo(m_provider); this->getLastOperation()->redo(m_provider);
EventDataChanged::post(m_provider);
return true; return true;
} }

View File

@@ -6,6 +6,7 @@
#include <hex/api/imhex_api.hpp> #include <hex/api/imhex_api.hpp>
#include <hex/api/events/events_gui.hpp> #include <hex/api/events/events_gui.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/helpers/utils_macos.hpp> #include <hex/helpers/utils_macos.hpp>

View File

@@ -4,6 +4,7 @@
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_lifecycle.hpp> #include <hex/api/events/events_lifecycle.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/helpers/crypto.hpp> #include <hex/helpers/crypto.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>

View File

@@ -7,6 +7,8 @@
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/ui/imgui_imhex_extensions.h> #include <hex/ui/imgui_imhex_extensions.h>
#include <hex/helpers/logger.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <wolv/literals.hpp> #include <wolv/literals.hpp>

View File

@@ -1,6 +1,7 @@
#include <hex/api/imhex_api.hpp> #include <hex/api/imhex_api.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/data_processor/node.hpp> #include <hex/data_processor/node.hpp>

View File

@@ -1,5 +1,6 @@
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_lifecycle.hpp> #include <hex/api/events/events_lifecycle.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/api/events/events_gui.hpp> #include <hex/api/events/events_gui.hpp>
#include <hex/api/events/requests_lifecycle.hpp> #include <hex/api/events/requests_lifecycle.hpp>
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>

View File

@@ -19,6 +19,7 @@
#include <toasts/toast_notification.hpp> #include <toasts/toast_notification.hpp>
#include <popups/popup_text_input.hpp> #include <popups/popup_text_input.hpp>
#include <hex/api/workspace_manager.hpp> #include <hex/api/workspace_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <wolv/io/file.hpp> #include <wolv/io/file.hpp>
#include <wolv/literals.hpp> #include <wolv/literals.hpp>

View File

@@ -22,6 +22,7 @@
#include <toasts/toast_notification.hpp> #include <toasts/toast_notification.hpp>
#include <csignal> #include <csignal>
#include <hex/api/events/events_interaction.hpp>
namespace hex::plugin::builtin { namespace hex::plugin::builtin {
@@ -553,4 +554,4 @@ namespace hex::plugin::builtin {
}); });
} }
} }

View File

@@ -3,6 +3,7 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>

View File

@@ -5,6 +5,7 @@
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/task_manager.hpp> #include <hex/api/task_manager.hpp>
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/helpers/fmt.hpp> #include <hex/helpers/fmt.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>

View File

@@ -3,6 +3,7 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <wolv/utils/guards.hpp> #include <wolv/utils/guards.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include "imstb_textedit.h" #include "imstb_textedit.h"

View File

@@ -4,6 +4,7 @@
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>
#include <hex/helpers/default_paths.hpp> #include <hex/helpers/default_paths.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>
#include <hex/ui/imgui_imhex_extensions.h> #include <hex/ui/imgui_imhex_extensions.h>

View File

@@ -7,6 +7,7 @@
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/logger.hpp> #include <hex/helpers/logger.hpp>

View File

@@ -2,6 +2,7 @@
#include <hex/api/imhex_api.hpp> #include <hex/api/imhex_api.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/providers/buffered_reader.hpp> #include <hex/providers/buffered_reader.hpp>

View File

@@ -3,6 +3,7 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/events/events_provider.hpp> #include <hex/api/events/events_provider.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <wolv/utils/guards.hpp> #include <wolv/utils/guards.hpp>

View File

@@ -3,6 +3,7 @@
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <content/providers/undo_operations/operation_write.hpp> #include <content/providers/undo_operations/operation_write.hpp>

View File

@@ -3,6 +3,7 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/providers/memory_provider.hpp> #include <hex/providers/memory_provider.hpp>
#include <hex/api/events/requests_interaction.hpp> #include <hex/api/events/requests_interaction.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>

View File

@@ -4,6 +4,7 @@
#include <hex/api_urls.hpp> #include <hex/api_urls.hpp>
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <popups/popup_notification.hpp> #include <popups/popup_notification.hpp>
#include <toasts/toast_notification.hpp> #include <toasts/toast_notification.hpp>

View File

@@ -2,6 +2,7 @@
#include <hex/api/content_registry.hpp> #include <hex/api/content_registry.hpp>
#include <hex/api/theme_manager.hpp> #include <hex/api/theme_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <wolv/io/file.hpp> #include <wolv/io/file.hpp>
#include <fonts/vscode_icons.hpp> #include <fonts/vscode_icons.hpp>

View File

@@ -4,6 +4,7 @@
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/events/events_gui.hpp> #include <hex/api/events/events_gui.hpp>
#include <hex/api/events/requests_gui.hpp> #include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>
#include <hex/helpers/utils.hpp> #include <hex/helpers/utils.hpp>

View File

@@ -3,6 +3,7 @@
#include <hex/api/project_file_manager.hpp> #include <hex/api/project_file_manager.hpp>
#include <hex/api/achievement_manager.hpp> #include <hex/api/achievement_manager.hpp>
#include <hex/providers/memory_provider.hpp> #include <hex/providers/memory_provider.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/helpers/crypto.hpp> #include <hex/helpers/crypto.hpp>

View File

@@ -6,6 +6,8 @@
#include <hex/providers/provider.hpp> #include <hex/providers/provider.hpp>
#include <hex/helpers/encoding_file.hpp> #include <hex/helpers/encoding_file.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <imgui.h> #include <imgui.h>
#include <hex/ui/view.hpp> #include <hex/ui/view.hpp>

View File

@@ -7,6 +7,7 @@
#include <content/yara_rule.hpp> #include <content/yara_rule.hpp>
#include <romfs/romfs.hpp> #include <romfs/romfs.hpp>
#include <wolv/io/file.hpp>
namespace hex::plugin::yara { namespace hex::plugin::yara {