Skip to content

Commit

Permalink
fix: 修复so导出符号
Browse files Browse the repository at this point in the history
  • Loading branch information
engsr6982 committed Dec 21, 2024
1 parent 9a44563 commit f4bb633
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
6 changes: 5 additions & 1 deletion src/Entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ endstone::PluginDescription const& Entry::getDescription() const { return descri

} // namespace jse

extern "C" __declspec(dllexport) endstone::Plugin* init_endstone_plugin() { return jse::Entry::getInstance(); }
#if defined(_WIN32)
extern "C" __declspec(dllexport) endstone::Plugin* init_endstone_plugin() { return jse::Entry::getInstance(); }
else
extern "C" __attribute__((visibility("default"))) endstone::Plugin* init_endstone_plugin() { return jse::Entry::getInstance(); }
#endif
39 changes: 18 additions & 21 deletions xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@ package_end()


add_requires(
"fmt >=10.0.0 <11.0.0",
"expected-lite 0.8.0",
"entt 3.14.0",
"microsoft-gsl 4.0.0",
"nlohmann_json 3.11.3",
"boost 1.85.0",
"glm 1.0.1",
"concurrentqueue 1.0.4",
"endstone 0.5.6"
"endstone 0.5.6",
"magic_enum 0.9.7"
)
add_requires("magic_enum 0.9.7")

if is_plat("linux") then
-- EndStone Linux Toolchain: LLVM5(Clang & libc++)
if is_plat("windows") then
add_requires("fmt >=10.0.0 <11.0.0")
elseif is_plat("linux") then
set_toolchains("clang") -- LLVM15(Clang & libc++)
add_requires("libelf 0.8.13")
set_toolchains("clang")
add_requires("fmt >=10.0.0 <11.0.0", {configs = {header_only = true}})
end

if is_plat("windows") then
Expand All @@ -64,9 +65,9 @@ target("Js_Engine")
"boost",
"glm",
"concurrentqueue",
"endstone"
"endstone",
"magic_enum"
)
add_packages("magic_enum")
set_kind("shared")
set_languages("cxx20")
set_symbols("debug")
Expand All @@ -76,7 +77,7 @@ target("Js_Engine")
add_defines("ENTT_SPARSE_PAGE=2048")
add_defines("ENTT_PACKED_PAGE=128")

-- ScriptX & QuickJs
-- ScriptX
add_includedirs("third-party/scriptx/src/include")
add_files(
"third-party/scriptx/src/**.cc",
Expand All @@ -95,32 +96,28 @@ target("Js_Engine")
add_cxflags(
"/EHa",
"/utf-8",
-- "/W4", -- 开启警告
-- "/W4",
"/sdl"
)
elseif is_plat("linux") then
add_includedirs("./third-party/quickjs/linux/include")
add_links("./third-party/quickjs/linux/lib/quickjs.a")
add_ldflags("-Wl,--whole-archive ./third-party/quickjs/linux/lib/quickjs.a -Wl,--no-whole-archive", {force = true})
add_files("./third-party/quickjs/linux/lib/quickjs.a")

add_cxflags(
"-fPIC",
"-stdlib=libc++",
"-fdeclspec",
-- "-fexceptions",
-- "-frtti",
{force = true}
)
-- add_ldflags(
-- "-stdlib=libc++",
-- {force = true}
-- )
-- add_syslinks("dl", "pthread", "c++", "c++abi")
-- add_defines("_LIBCPP_VERSION") -- 指示使用 libc++
-- add_syslinks("dl", "stdc++fs")
add_ldflags(
"-stdlib=libc++",
{force = true}
)
add_syslinks("dl", "pthread", "c++", "c++abi")
add_packages("libelf")
end


if is_mode("debug") then
add_defines("DEBUG")
end
Expand Down

0 comments on commit f4bb633

Please sign in to comment.