Skip to content

Instantly share code, notes, and snippets.

@kaka19ace
Last active December 25, 2015 05:59
Show Gist options
  • Save kaka19ace/6928924 to your computer and use it in GitHub Desktop.
Save kaka19ace/6928924 to your computer and use it in GitHub Desktop.
--[[
rootDir = "/opt/project"
this script is at /opt/project/sample.lua
if you want to lua sample.lua and require your custom lua module.
eg:
/opt/project/dep/lua/xxx.lua
/opt/project/dep/lib/lua/xxx.so # some lua module c lib
--]]
-- may be fix bug
local rootPath = string.gsub(debug.getinfo(1).source, "^@(.+/).*%.lua$", "%1")
-- rootPath is /opt/project/
depLuaDir = rootPath.."dep/"
depLuaPath = depLuaDir .. "lua/?.lua;"
depLuaCPath = depLuaDir .. "lib/lua/?.so;"
package.path = table.concat({depLuaPath, package.path})
package.cpath = table.concat({depLuaCPath..";", package.cpath})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment