update
This commit is contained in:
parent
f5e2424f0f
commit
a552c5d8e4
7
.vscode/emmyrc.json
vendored
Normal file
7
.vscode/emmyrc.json
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"diagnostics": {
|
||||||
|
"disable": [
|
||||||
|
"undefined-global"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"tangzx.emmylua"
|
||||||
|
]
|
||||||
|
}
|
||||||
5
.vscode/launch.json
vendored
5
.vscode/launch.json
vendored
@ -17,5 +17,10 @@
|
|||||||
],
|
],
|
||||||
"ideConnectDebugger": true
|
"ideConnectDebugger": true
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"diagnostics": {
|
||||||
|
"disable": [
|
||||||
|
"undefined-global"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
}
|
}
|
||||||
@ -5,4 +5,4 @@ static_component("asset","engine")
|
|||||||
add_includedirs("include/asset")
|
add_includedirs("include/asset")
|
||||||
add_headerfiles("include/**.h","include/**.inl")
|
add_headerfiles("include/**.h","include/**.inl")
|
||||||
add_files("src/**.cpp")
|
add_files("src/**.cpp")
|
||||||
add_deps("core", {public = true})
|
add_deps("core", "zlib")
|
||||||
@ -20,7 +20,7 @@ namespace zlog {
|
|||||||
m_logger->flush();
|
m_logger->flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
extern zloger zlog;
|
CORE_API inline zloger zlog;
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void info(format_with_location fmt, Args &&...args) {
|
void info(format_with_location fmt, Args &&...args) {
|
||||||
zlog.log(level_enum::info, fmt, std::forward<Args>(args)...);
|
zlog.log(level_enum::info, fmt, std::forward<Args>(args)...);
|
||||||
@ -43,5 +43,7 @@ namespace zlog {
|
|||||||
const std::string format_str = fmt::format(std::forward<Args>(args)...);
|
const std::string format_str = fmt::format(std::forward<Args>(args)...);
|
||||||
throw std::runtime_error(format_str);
|
throw std::runtime_error(format_str);
|
||||||
};
|
};
|
||||||
void flush();
|
inline void flush() {
|
||||||
|
zlog.flush();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@ -11,9 +11,8 @@ namespace api {
|
|||||||
using Write = yyjson_mut_val*(*)(yyjson_mut_doc*, const void*);
|
using Write = yyjson_mut_val*(*)(yyjson_mut_doc*, const void*);
|
||||||
};
|
};
|
||||||
struct JsonArchive {
|
struct JsonArchive {
|
||||||
private:
|
public:
|
||||||
static bool InitJsonSerde();
|
static void InitJsonSerde();
|
||||||
inline static bool HasInit = InitJsonSerde();
|
|
||||||
public:
|
public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void Register();
|
static void Register();
|
||||||
|
|||||||
@ -27,13 +27,12 @@ namespace api {
|
|||||||
alc.ctx = mr;
|
alc.ctx = mr;
|
||||||
return alc;
|
return alc;
|
||||||
}
|
}
|
||||||
inline bool JsonArchive::InitJsonSerde()
|
inline void JsonArchive::InitJsonSerde()
|
||||||
{
|
{
|
||||||
using std::string_view;
|
using std::string_view;
|
||||||
#define RegisterAny(T) Register<T>();
|
#define RegisterAny(T) Register<T>();
|
||||||
#include "../register.inl"
|
#include "../register.inl"
|
||||||
#undef RegisterAny
|
#undef RegisterAny
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
constexpr size_t VJsonSerdeRead() {
|
constexpr size_t VJsonSerdeRead() {
|
||||||
return string_hash("JsonSerdeRead");
|
return string_hash("JsonSerdeRead");
|
||||||
|
|||||||
@ -3,8 +3,6 @@
|
|||||||
#include "enum_macro.h"
|
#include "enum_macro.h"
|
||||||
#include "os/shared_library.h"
|
#include "os/shared_library.h"
|
||||||
#include "refl/pch.h"
|
#include "refl/pch.h"
|
||||||
//可变生命周期,回收内存
|
|
||||||
inline thread_local pmr::unsynchronized_pool_resource MemPool;
|
|
||||||
// 默认对齐方式 new
|
// 默认对齐方式 new
|
||||||
void* operator new(std::size_t size);
|
void* operator new(std::size_t size);
|
||||||
// 默认对齐方式 delete
|
// 默认对齐方式 delete
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
namespace api {
|
namespace api {
|
||||||
class DLL_API ModuleManager
|
class CORE_API ModuleManager
|
||||||
{
|
{
|
||||||
friend struct IModule;
|
friend struct IModule;
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
namespace zlog {
|
namespace zlog {
|
||||||
zloger zlog;
|
|
||||||
zloger::zloger()
|
zloger::zloger()
|
||||||
{
|
{
|
||||||
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
auto console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
|
||||||
@ -33,7 +32,4 @@ namespace zlog {
|
|||||||
m_logger->flush();
|
m_logger->flush();
|
||||||
spdlog::drop_all();
|
spdlog::drop_all();
|
||||||
}
|
}
|
||||||
void flush(){
|
|
||||||
zlog.flush();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ struct MemDetail {
|
|||||||
int new_count{ 0 };
|
int new_count{ 0 };
|
||||||
int del_count{ 0 };
|
int del_count{ 0 };
|
||||||
};
|
};
|
||||||
|
thread_local pmr::unsynchronized_pool_resource MemPool;
|
||||||
thread_local MemDetail detail;
|
thread_local MemDetail detail;
|
||||||
void* operator new(std::size_t size) {
|
void* operator new(std::size_t size) {
|
||||||
std::size_t alignment = alignof(std::max_align_t);
|
std::size_t alignment = alignof(std::max_align_t);
|
||||||
|
|||||||
@ -5,5 +5,5 @@ static_component("core","engine")
|
|||||||
add_includedirs("include", "include/3rdparty", {public = true})
|
add_includedirs("include", "include/3rdparty", {public = true})
|
||||||
add_headerfiles("include/**.h","include/**.inl")
|
add_headerfiles("include/**.h","include/**.inl")
|
||||||
add_files("src/**.cpp")
|
add_files("src/**.cpp")
|
||||||
add_deps("zlib", {public = true})
|
add_deps("zlib")
|
||||||
add_packages("spdlog", {public = true})
|
add_packages("spdlog", {public = true})
|
||||||
@ -48,18 +48,10 @@ inline void* operator new(size_t size, pmr::FrameAllocatorPool* pool, size_t ali
|
|||||||
return pool->allocate(size, alignment);
|
return pool->allocate(size, alignment);
|
||||||
}
|
}
|
||||||
#include "frame_allocator.inl"
|
#include "frame_allocator.inl"
|
||||||
#ifdef DLL_API_VALUE
|
|
||||||
//全局生命周期,不回收内存
|
//全局生命周期,不回收内存
|
||||||
extern DLL_API inline pmr::FrameAllocatorPool* GlobalPool;
|
ZLIB_API inline pmr::FrameAllocatorPool* GlobalPool;
|
||||||
//局部生命周期,每帧回收内存
|
//局部生命周期,每帧回收内存
|
||||||
extern DLL_API inline pmr::FrameAllocatorPool* FramePool;
|
ZLIB_API inline pmr::FrameAllocatorPool* FramePool;
|
||||||
DLL_API pmr::FrameAllocatorPool* GetGlobalPool();
|
|
||||||
DLL_API pmr::FrameAllocatorPool* GetFramePool();
|
|
||||||
#else
|
|
||||||
//全局生命周期,不回收内存
|
|
||||||
inline pmr::FrameAllocatorPool* GlobalPool;
|
|
||||||
//局部生命周期,每帧回收内存
|
|
||||||
inline pmr::FrameAllocatorPool* FramePool;
|
|
||||||
inline pmr::FrameAllocatorPool* GetGlobalPool() {
|
inline pmr::FrameAllocatorPool* GetGlobalPool() {
|
||||||
if (!GlobalPool) {
|
if (!GlobalPool) {
|
||||||
GlobalPool = new pmr::FrameAllocatorPool();
|
GlobalPool = new pmr::FrameAllocatorPool();
|
||||||
@ -72,4 +64,3 @@ inline pmr::FrameAllocatorPool* GetFramePool() {
|
|||||||
}
|
}
|
||||||
return FramePool;
|
return FramePool;
|
||||||
}
|
}
|
||||||
#endif // DLL_API
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
#include "name.h"
|
|
||||||
namespace pmr {
|
namespace pmr {
|
||||||
using NameTable_t = table<size_t,const string>;
|
using NameTable_t = table<size_t,const string>;
|
||||||
struct NameTable {
|
struct ZLIB_API NameTable {
|
||||||
static const string& Find(size_t id);
|
static const string& Find(size_t id);
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static std::string_view MakePair(size_t id, T&& str);
|
static std::string_view MakePair(size_t id, T&& str);
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "module/module.h"
|
#include "module/module.h"
|
||||||
#include "asset/asset.h"
|
|
||||||
class VULKAN_API VulkanModule : public api::IDynamicModule
|
class VULKAN_API VulkanModule : public api::IDynamicModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -1,24 +1,22 @@
|
|||||||
function header_component(name, owner, opt)
|
function header_component(name, owner, opt)
|
||||||
target(owner)
|
target(owner)
|
||||||
add_deps(name, { public = opt and opt.public or true })
|
add_deps(name)
|
||||||
target_end()
|
target_end()
|
||||||
target(name)
|
target(name)
|
||||||
set_kind("headeronly")
|
set_kind("headeronly")
|
||||||
set_group("Engine/"..owner.."__comp")
|
set_group("Engine/"..owner.."__comp")
|
||||||
|
add_rules("engine.api")
|
||||||
add_includedirs("include", {public = true})
|
add_includedirs("include", {public = true})
|
||||||
end
|
end
|
||||||
function static_component(name, owner, opt)
|
function static_component(name, owner, opt)
|
||||||
target(owner)
|
target(owner)
|
||||||
add_deps(name)
|
add_deps(name)
|
||||||
add_defines("DLL_API_VALUE", {public = true})
|
|
||||||
add_includedirs("include", {public = true})
|
|
||||||
target_end()
|
target_end()
|
||||||
target(name)
|
target(name)
|
||||||
set_kind("static")
|
set_kind("moduleonly")
|
||||||
set_group("Engine/"..owner.."__comp")
|
set_group("Engine/"..owner.."__comp")
|
||||||
add_rules("engine.api")
|
add_rules("engine.api")
|
||||||
add_defines("DLL_API=")
|
add_includedirs("include", {public = true})
|
||||||
add_includedirs("include")
|
|
||||||
end
|
end
|
||||||
function shared_module(name, owner, opt)
|
function shared_module(name, owner, opt)
|
||||||
target(name)
|
target(name)
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
#include "api.h"
|
#include "api.h"
|
||||||
|
#include "pmr/frame_allocator.h"
|
||||||
|
#include "pmr/name.h"
|
||||||
class ENGINE_API EngineModule : public api::IDynamicModule
|
class ENGINE_API EngineModule : public api::IDynamicModule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
target("editor")
|
target("editor")
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_group("Engine")
|
set_group("Engine")
|
||||||
add_rules("engine.api", {targets = {"dll", "editor"}})
|
add_rules("engine.api")
|
||||||
add_headerfiles("include/editor/*.h")
|
add_headerfiles("include/editor/*.h")
|
||||||
add_includedirs("include/editor")
|
add_includedirs("include/editor")
|
||||||
add_files("src/editor/*.cpp")
|
add_files("src/editor/*.cpp")
|
||||||
@ -9,7 +9,7 @@ target("engine")
|
|||||||
add_includedirs("include", {public = true})
|
add_includedirs("include", {public = true})
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_group("Engine")
|
set_group("Engine")
|
||||||
add_rules("engine.api", {targets = {"dll", "engine"}})
|
add_rules("engine.api")
|
||||||
add_headerfiles("include/engine/*.h")
|
add_headerfiles("include/engine/*.h")
|
||||||
add_includedirs("include/engine")
|
add_includedirs("include/engine")
|
||||||
add_files("src/engine/*.cpp")
|
add_files("src/engine/*.cpp")
|
||||||
|
|||||||
26
engine/xmake/rule_api/rule_api.lua
Normal file
26
engine/xmake/rule_api/rule_api.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import("core.project.project")
|
||||||
|
function add_define(target, name, is_static)
|
||||||
|
local api = string.upper(name) .. "_API"
|
||||||
|
if is_static then
|
||||||
|
target:add("defines", api .. "=", api .. "_VAL", {public = false})
|
||||||
|
else
|
||||||
|
target:add("defines", api.."=__declspec(dllimport)", {interface=true})
|
||||||
|
target:add("defines", api.."=__declspec(dllexport)", api .. "_VAL", {public=false})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function is_static_f(kind)
|
||||||
|
return kind == "static" or kind == "headeronly" or kind == "moduleonly"
|
||||||
|
end
|
||||||
|
function main(target)
|
||||||
|
local name = target:name()
|
||||||
|
local is_static = is_static_f(target:kind())
|
||||||
|
add_define(target, name, is_static)
|
||||||
|
local deps = target:get("deps")
|
||||||
|
if not deps then return end
|
||||||
|
for _,dep in ipairs(deps) do
|
||||||
|
local deptarget = project.target(dep)
|
||||||
|
if is_static_f(deptarget:kind()) then
|
||||||
|
add_define(target, dep, is_static)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
5
engine/xmake/rule_api/xmake.lua
Normal file
5
engine/xmake/rule_api/xmake.lua
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
rule("engine.api")
|
||||||
|
on_config(function (target)
|
||||||
|
import("rule_api")
|
||||||
|
rule_api(target)
|
||||||
|
end)
|
||||||
@ -1,13 +1,7 @@
|
|||||||
import("core.project.depend")
|
import("core.project.depend")
|
||||||
local loadTable = {}
|
|
||||||
function cmd_compile(target, genfile, file)
|
function cmd_compile(target, genfile, file)
|
||||||
local name = target:name()
|
|
||||||
if loadTable[name] then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
loadTable[name] = true
|
|
||||||
import("core.project.project")
|
import("core.project.project")
|
||||||
target:data_set("compile", true)
|
local name = target:name()
|
||||||
local pub_deps = target:values("module.public_dependencies")
|
local pub_deps = target:values("module.public_dependencies")
|
||||||
local cpp_content = "inline void __" .. name .. "__module::InitMetaData(void){\n"
|
local cpp_content = "inline void __" .. name .. "__module::InitMetaData(void){\n"
|
||||||
cpp_content = cpp_content.."\tmInfo.name = \"" .. name.."\";\n"
|
cpp_content = cpp_content.."\tmInfo.name = \"" .. name.."\";\n"
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
rule("engine.plugin")
|
rule("engine.plugin")
|
||||||
set_extensions(".h")
|
set_extensions(".h")
|
||||||
on_load(function (target)
|
on_config(function (target)
|
||||||
import("make_plugin")
|
import("make_plugin")
|
||||||
local file = target:extraconf("rules", "engine.plugin", "file")
|
local file = target:extraconf("rules", "engine.plugin", "file")
|
||||||
make_plugin(target, file or "module.h")
|
make_plugin(target, file or "module.h")
|
||||||
|
|||||||
@ -7,13 +7,3 @@ rule("engine.tool")
|
|||||||
local exefile = target:targetfile()
|
local exefile = target:targetfile()
|
||||||
os.cp(exefile, path.join(tooldir, path.filename(exefile)))
|
os.cp(exefile, path.join(tooldir, path.filename(exefile)))
|
||||||
end)
|
end)
|
||||||
rule("engine.api")
|
|
||||||
on_load(function (target)
|
|
||||||
local deps = target:extraconf("rules", "engine.api", "targets")
|
|
||||||
deps = deps or {target:name()}
|
|
||||||
for k,v in ipairs(deps) do
|
|
||||||
local api = string.upper(v) .. "_API"
|
|
||||||
target:add("defines", api.."=__declspec(dllimport)", {interface=true})
|
|
||||||
target:add("defines", api.."=__declspec(dllexport)", {public=false})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
Loading…
Reference in New Issue
Block a user