bugfix
This commit is contained in:
parent
10423e024f
commit
0e1684de03
@ -1,4 +1,8 @@
|
||||
#pragma once
|
||||
#include "zlib.h"
|
||||
ENGINE_API const char* engine();
|
||||
inline Module engine_module{engine(), true};
|
||||
#ifdef ENGINE_API_VAL
|
||||
ENGINE_API inline Module engine_module{ engine(), false };
|
||||
#else
|
||||
ENGINE_API extern Module engine_module;
|
||||
#endif
|
||||
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "zlib.h"
|
||||
#include "core.h"
|
||||
const char* asset();
|
||||
inline Module asset_module{ asset(), false};
|
||||
@ -1,4 +1,14 @@
|
||||
#pragma once
|
||||
#include "zlib.h"
|
||||
const char* core();
|
||||
inline Module core_module{ core(), false};
|
||||
inline Module core_module{ core(), false};
|
||||
struct ModuleManager;
|
||||
struct ModuleManagerPtr {
|
||||
ModuleManager* ptr;
|
||||
ModuleManagerPtr();
|
||||
};
|
||||
CORE_API inline ModuleManagerPtr ms_instance;
|
||||
struct ModuleManager {
|
||||
ModuleManager();
|
||||
static ModuleManager* Ptr();
|
||||
};
|
||||
@ -3,3 +3,20 @@ const char* core()
|
||||
{
|
||||
return "core";
|
||||
}
|
||||
|
||||
ModuleManager::ModuleManager()
|
||||
{
|
||||
std::cout << "ModuleManager::" << uintptr_t(this) << std::endl;
|
||||
}
|
||||
|
||||
ModuleManager* ModuleManager::Ptr()
|
||||
{
|
||||
static ModuleManager module;
|
||||
auto* ptr = &module;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
ModuleManagerPtr::ModuleManagerPtr()
|
||||
{
|
||||
ptr = ModuleManager::Ptr();
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ struct Detail {
|
||||
int del_count = 0;
|
||||
};
|
||||
struct Module;
|
||||
inline Detail detail{};
|
||||
inline std::vector<Module*>* pModuleList{};
|
||||
ZLIB_API inline Detail detail;
|
||||
ZLIB_API inline std::vector<Module*>* pModuleList;
|
||||
struct Module {
|
||||
std::string name;
|
||||
bool kind;
|
||||
|
||||
@ -6,3 +6,4 @@ target("zlib")
|
||||
add_includedirs("include", {public = true})
|
||||
add_packages("spdlog", {public = true})
|
||||
add_rules("engine.api")
|
||||
add_defines("ZLIB_API_TEST")
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
function main(target, name)
|
||||
local api = string.upper(name) .. "_API"
|
||||
if target:kind() == "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)", {public=false})
|
||||
end
|
||||
end
|
||||
37
engine/xmake/modules/find_sdk.lua
Normal file
37
engine/xmake/modules/find_sdk.lua
Normal file
@ -0,0 +1,37 @@
|
||||
function find_exe_dir()
|
||||
local os_name = os.host()
|
||||
local arch_name = os.arch()
|
||||
local mode_name = is_mode("debug") and "debug" or "release"
|
||||
|
||||
-- 构建生成目录路径
|
||||
return path.join(os.projectdir(), "build", os_name, arch_name, mode_name)
|
||||
end
|
||||
function find_my_program(name, sdkdir, use_next)
|
||||
import("lib.detect.find_file")
|
||||
import("lib.detect.find_program")
|
||||
import("lib.detect.find_tool")
|
||||
|
||||
local sdkdir = sdkdir or path.join(os.projectdir(), "tools")
|
||||
local exedir = find_exe_dir()
|
||||
local tool = find_tool(name, {pathes = {sdkdir, exedir, "/usr/local/bin"}})
|
||||
local prog = tool and tool.program or find_program(name, {pathes = {sdkdir, exedir, "/usr/local/bin"}})
|
||||
prog = prog or find_file(name, {sdkdir, exedir})
|
||||
if (prog == nil) then
|
||||
if os.host() ~= "windows" then
|
||||
local outdata, errdata = os.iorun("which " .. name)
|
||||
if (errdata ~= nil or errdata ~= "") then
|
||||
prog = string.gsub(outdata, "%s+", "")
|
||||
end
|
||||
else
|
||||
prog = find_file(name .. ".exe", {sdkdir})
|
||||
end
|
||||
end
|
||||
if (prog == nil) then
|
||||
if not use_next then
|
||||
return find_my_program(name, path.join(sdkdir, name), true)
|
||||
end
|
||||
print(name .. " not found! under " .. sdkdir, exedir)
|
||||
return
|
||||
end
|
||||
return {program = prog, sdkdir = sdkdir}
|
||||
end
|
||||
23
engine/xmake/rule_api/rule_api.lua
Normal file
23
engine/xmake/rule_api/rule_api.lua
Normal file
@ -0,0 +1,23 @@
|
||||
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)", {public=false})
|
||||
end
|
||||
end
|
||||
function main(target)
|
||||
local name = target:name()
|
||||
local is_static = target:kind() == "static"
|
||||
add_define(target, name, is_static)
|
||||
local deps = target:get("deps")
|
||||
if not deps then return end
|
||||
import("core.project.project")
|
||||
for _,dep in ipairs(deps) do
|
||||
local deptarget = project.target(dep)
|
||||
if deptarget:kind() == "static" 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,16 +1,2 @@
|
||||
rule("engine.api")
|
||||
on_load(function (target)
|
||||
print(target:name())
|
||||
import("api_define")
|
||||
api_define(target, target:name())
|
||||
local deps = target:get("deps")
|
||||
if not deps then return end
|
||||
import("core.project.project")
|
||||
local is_static = target:kind() == "static"
|
||||
for _,name in ipairs(deps) do
|
||||
local deptarget = project.target(name)
|
||||
if deptarget:kind() == "static" then
|
||||
api_define(target, name)
|
||||
end
|
||||
end
|
||||
end)
|
||||
includes("*/xmake.lua")
|
||||
add_moduledirs(path.join(os.projectdir(), "engine/xmake/modules"))
|
||||
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "zlib.h"
|
||||
#include "core.h"
|
||||
VULKAN_API const char* vulkan();
|
||||
inline Module vulkan_module{vulkan(), true};
|
||||
inline Module vulkan_module{vulkan(), true};
|
||||
|
||||
@ -1,4 +1,9 @@
|
||||
#pragma once
|
||||
#include "zlib.h"
|
||||
#include "core.h"
|
||||
ZWORLD_API const char* zworld();
|
||||
inline Module zworld_module{zworld(), true};
|
||||
#ifdef ZWORLD_API_VAL
|
||||
ZWORLD_API inline Module zworld_module{ zworld(), false };
|
||||
#else
|
||||
ZWORLD_API extern Module zworld_module;
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user