add:添加xmake脚本。

This commit is contained in:
taynpg 2025-02-14 22:13:55 +08:00
parent 2ac80fc6a8
commit b94fbfb742
5 changed files with 70 additions and 2 deletions

3
.gitignore vendored
View File

@ -3,4 +3,5 @@ build
.cache
cmake-*
auto_build
export
export
.xmake

View File

@ -1,8 +1,13 @@
#include "lib.h"
#include <filesystem>
#include <iostream>
#ifdef USE_BOOST_FILESYSTEM
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;
#endif
/*
return C++ Lua

28
fs/xmake.lua Normal file
View File

@ -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)

31
lua/xmake.lua Normal file
View File

@ -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")

3
xmake.lua Normal file
View File

@ -0,0 +1,3 @@
add_rules("mode.debug", "mode.release")
set_languages("c++17")
includes("lua", "fs")