diff --git a/.gitignore b/.gitignore index 11b20f2..93a9432 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ build .cache cmake-* auto_build -export \ No newline at end of file +export +.xmake \ No newline at end of file diff --git a/fs/lib.cxx b/fs/lib.cxx index 937a9b4..f701639 100644 --- a/fs/lib.cxx +++ b/fs/lib.cxx @@ -1,8 +1,13 @@ #include "lib.h" -#include #include +#ifdef USE_BOOST_FILESYSTEM +#include +namespace fs = boost::filesystem; +#else +#include namespace fs = std::filesystem; +#endif /* return 语句的值代表着你从 C++ 函数返回的 Lua 堆栈上的元素个数。 diff --git a/fs/xmake.lua b/fs/xmake.lua new file mode 100644 index 0000000..a8482d8 --- /dev/null +++ b/fs/xmake.lua @@ -0,0 +1,28 @@ +add_rules("mode.debug", "mode.release") +set_languages("c++17") + +if is_plat("windows") then + add_cxxflags("/source-charset:utf-8", {force = true}) +end +if is_plat("mingw") then + add_cxxflags("-Wno-unused-variable -finput-charset=utf-8 -fexec-charset=gbk") +end +if is_mode("debug") then + set_suffixname("d") +end +target("lua_fs") + add_options("boost") + add_defines("FS_LIB_EXPORT") + set_kind("shared") + add_files("*.cxx") + add_deps("lua") +option("boost") + set_default(false) + set_showmenu(true) + boost_root_dir = os.getenv("BOOST_HEADER_DIR") + boost_lib_dir = os.getenv("BOOST_LIB_DIR") + boost_libs = os.getenv("BOOST_LIBS") + add_includedirs(boost_root_dir) + add_defines("USE_BOOST_FILESYSTEM") + add_linkdirs(boost_lib_dir) + add_links(boost_libs) \ No newline at end of file diff --git a/lua/xmake.lua b/lua/xmake.lua new file mode 100644 index 0000000..ab59ece --- /dev/null +++ b/lua/xmake.lua @@ -0,0 +1,31 @@ +-- 设置最小版本要求 +set_version("5.4.7") + +-- 设置项目语言 +add_rules("mode.debug", "mode.release") + +-- 创建静态库 +target("lua") + add_includedirs("src", { public = true }) + set_kind("static") + add_defines("LUA_COMPAT_5_3") + add_files("src/*.c", { exclude = { "src/lua.c", "src/luac.c" } }) + if is_plat("windows") then + add_cflags("/wd4530") + add_defines("LUA_BUILD_AS_DLL") + -- 在Windows上,如果有额外的链接库,可以在这里添加 + -- add_links("some_library") + elseif is_plat("linux") then + add_defines("LUA_USE_LINUX") + add_links("m", "dl", "E") + end + +-- 创建Lua可执行文件 +target("mlua") + set_kind("binary") + add_files("src/lua.c") + add_deps("lua") +target("mluac") + set_kind("binary") + add_files("src/luac.c") + add_deps("lua") diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..5b317c3 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,3 @@ +add_rules("mode.debug", "mode.release") +set_languages("c++17") +includes("lua", "fs") \ No newline at end of file