Skip to content

Instantly share code, notes, and snippets.

View q962's full-sized avatar
🚩
Target

提及 q962

🚩
Target
View GitHub Profile
@q962
q962 / A_luafiles_in_c
Last active August 8, 2024 09:50
c 集成 lua 模块的方法
includes("./luafiles.lua")
--[[
对于这个target就不需要调用 <module_name>_loadmodules 函数了
见 test.c 中的例子
]]
target("lua_require")
set_kind("static")
add_files("require.lua")
add_rules("luafiles", {root_path = ".", module_name = "require"})
@q962
q962 / require.lua
Last active August 1, 2024 09:07
Lua require relative path fix
local realRequire = require;
local function get_source_dir()
local up = debug.getinfo(3).source:gsub("\\", "/");
if up:sub(1, 1) ~= '@' then
return realRequire(name);
end
up = up:sub(2)