From 546e7c5c5f59986e3ba517cc848ad37485e335c1 Mon Sep 17 00:00:00 2001 From: ouczbs Date: Wed, 27 Nov 2024 22:33:09 +0800 Subject: [PATCH] update editor --- engine/3rdparty/xmake.lua | 3 ++- engine/include/editor/api.h | 2 -- engine/include/editor/editor.h | 12 ++++++++++++ engine/src/editor/api.cpp | 2 -- engine/src/editor/editor.cpp | 14 ++++++++++++++ engine/xmake.lua | 16 +++++++++------- engine/xmake/rule_api/package_api.lua | 15 +++++++++++++++ engine/xmake/rule_api/xmake.lua | 4 ++++ 8 files changed, 56 insertions(+), 12 deletions(-) delete mode 100644 engine/include/editor/api.h create mode 100644 engine/include/editor/editor.h delete mode 100644 engine/src/editor/api.cpp create mode 100644 engine/src/editor/editor.cpp create mode 100644 engine/xmake/rule_api/package_api.lua diff --git a/engine/3rdparty/xmake.lua b/engine/3rdparty/xmake.lua index 51bbded..e49a569 100644 --- a/engine/3rdparty/xmake.lua +++ b/engine/3rdparty/xmake.lua @@ -1,3 +1,4 @@ add_requires("spdlog", "lemon", "libsdl", "vulkansdk","shaderc","spirv","spirv-cross") -add_requires("mimalloc", {configs = {shared = true, debug = true}}) +add_requires("mimalloc", {configs = {shared = true, debug = true, copy = true}}) +add_requires("imgui",{configs = { shared = false, debug = true, copy = true}}) includes("*/xmake.lua") \ No newline at end of file diff --git a/engine/include/editor/api.h b/engine/include/editor/api.h deleted file mode 100644 index ccba8af..0000000 --- a/engine/include/editor/api.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -EDITOR_API extern int editor_v; \ No newline at end of file diff --git a/engine/include/editor/editor.h b/engine/include/editor/editor.h new file mode 100644 index 0000000..d415d4c --- /dev/null +++ b/engine/include/editor/editor.h @@ -0,0 +1,12 @@ +#pragma once +#include "module/module.h" +namespace api { + class EDITOR_API EditorModule : public api::IDynamicModule + { + public: + void OnLoad(int argc, char** argv) override; + void OnUnload() override; + void InitMetaData(void) override {}; + }; + IMPLEMENT_DYNAMIC_MODULE(EDITOR_API, EditorModule, editor) +} \ No newline at end of file diff --git a/engine/src/editor/api.cpp b/engine/src/editor/api.cpp deleted file mode 100644 index ef3d13d..0000000 --- a/engine/src/editor/api.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "editor/api.h" -int editor_v; \ No newline at end of file diff --git a/engine/src/editor/editor.cpp b/engine/src/editor/editor.cpp new file mode 100644 index 0000000..64c1969 --- /dev/null +++ b/engine/src/editor/editor.cpp @@ -0,0 +1,14 @@ +#include "editor/editor.h" +#include "imgui.h" +namespace api { + void EditorModule::OnLoad(int argc, char** argv) + { + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + } + + void EditorModule::OnUnload() + { + } + +} \ No newline at end of file diff --git a/engine/xmake.lua b/engine/xmake.lua index 04edaf1..d7645e7 100644 --- a/engine/xmake.lua +++ b/engine/xmake.lua @@ -1,10 +1,3 @@ -target("editor") - set_kind("shared") - set_group("Engine") - add_rules("engine.api") - add_headerfiles("include/editor/*.h") - add_includedirs("include") - add_files("src/editor/*.cpp") target("engine") add_defines("ENGINE_ROOT="..os.curdir():gsub("\\", "\\\\"),{public = false}) add_headerfiles("include/*.natvis") @@ -13,6 +6,15 @@ target("engine") set_group("Engine") add_rules("engine.api") add_files("src/engine/*.cpp") +target("editor") + set_kind("shared") + set_group("Engine") + add_rules("engine.api") + add_headerfiles("include/editor/*.h") + add_includedirs("include") + add_files("src/editor/*.cpp") + add_packages("imgui",{public = true}) + add_deps("engine",{public = true}) includes("xmake/xmake.lua") includes("3rdparty/xmake.lua") includes("tools/xmake.lua") diff --git a/engine/xmake/rule_api/package_api.lua b/engine/xmake/rule_api/package_api.lua new file mode 100644 index 0000000..b77eae0 --- /dev/null +++ b/engine/xmake/rule_api/package_api.lua @@ -0,0 +1,15 @@ +import("core.project.project") +function main(target) + for _, pkg in pairs(target:pkgs()) do + if pkg:requireconf("configs","copy") then + local link = pkg:get("links") + local targetdir = target:targetdir() + link = link[1] or link + if link and not os.isfile(path.join(targetdir, link .. ".lib")) then + local linkdirs = pkg:get("linkdirs") + os.trycp(linkdirs.."/*", targetdir) + print("copy",linkdirs, targetdir) + end + end + end +end \ No newline at end of file diff --git a/engine/xmake/rule_api/xmake.lua b/engine/xmake/rule_api/xmake.lua index 6ad9645..be74ffc 100644 --- a/engine/xmake/rule_api/xmake.lua +++ b/engine/xmake/rule_api/xmake.lua @@ -2,4 +2,8 @@ rule("engine.api") on_config(function (target) import("rule_api") rule_api(target) + end) + on_load(function (target) + import("package_api") + package_api(target) end) \ No newline at end of file