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
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake")

View File

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

View File

@@ -17,22 +17,35 @@ module;
#include <ranges>
#include <fstream>
#include <thread>
#include <future>
#include <fmt/format.h>
#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;
#define HEX_MODULE_EXPORT
#include <hex/api/task_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/layout_manager.hpp>
#include <hex/api/localization_manager.hpp>
#include <hex/api/plugin_manager.hpp>
#include <hex/api/shortcut_manager.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/theme_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/helpers/auto_reset.hpp>
namespace hex {
EXPORT_MODULE namespace hex {
class AchievementManager;

View File

@@ -16,27 +16,31 @@
#include <nlohmann/json.hpp>
#include <wolv/io/fs.hpp>
using ImGuiDataType = int;
using ImGuiInputTextFlags = int;
struct ImColor;
enum ImGuiCustomCol : int;
typedef int ImGuiColorEditFlags;
#if !defined(HEX_MODULE_EXPORT)
using ImGuiDataType = int;
using ImGuiInputTextFlags = int;
struct ImColor;
enum ImGuiCustomCol : int;
typedef int ImGuiColorEditFlags;
#endif
namespace hex {
EXPORT_MODULE namespace hex {
class View;
class Task;
#if !defined(HEX_MODULE_EXPORT)
class View;
class Task;
namespace dp {
class Node;
}
namespace prv {
class Provider;
}
namespace dp {
class Node;
}
namespace prv {
class Provider;
}
namespace LocalizationManager {
class LanguageDefinition;
}
namespace LocalizationManager {
class LanguageDefinition;
}
#endif
/*
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__)
namespace hex {
EXPORT_MODULE namespace hex {
namespace impl {

View File

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

View File

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

View File

@@ -10,9 +10,11 @@
#include <hex/helpers/logger.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 {
enum class Type : u8 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -30,9 +30,11 @@
namespace hex {
namespace prv {
class Provider;
}
#if !defined(HEX_MODULE_EXPORT)
namespace prv {
class Provider;
}
#endif
template<typename T>
[[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)
struct GLFWwindow;
#if !defined(HEX_MODULE_EXPORT)
struct GLFWwindow;
#endif
extern "C" {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,6 +6,7 @@
#include <hex/api/imhex_api.hpp>
#include <hex/api/events/events_gui.hpp>
#include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/api/task_manager.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_lifecycle.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/helpers/crypto.hpp>
#include <hex/providers/provider.hpp>

View File

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

View File

@@ -1,6 +1,7 @@
#include <hex/api/imhex_api.hpp>
#include <hex/api/content_registry.hpp>
#include <hex/api/achievement_manager.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/providers/provider.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_lifecycle.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <hex/api/events/events_gui.hpp>
#include <hex/api/events/requests_lifecycle.hpp>
#include <hex/api/events/requests_interaction.hpp>

View File

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

View File

@@ -22,6 +22,7 @@
#include <toasts/toast_notification.hpp>
#include <csignal>
#include <hex/api/events/events_interaction.hpp>
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/task_manager.hpp>
#include <hex/api/events/requests_gui.hpp>
#include <hex/api/events/events_interaction.hpp>
#include <fonts/vscode_icons.hpp>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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