aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordwenegar <simone.livieri@gmail.com>2018-02-15 08:16:26 +0900
committerHisham Muhammad <hisham@gobolinux.org>2018-02-14 21:16:26 -0200
commit5022dc08eb9a7a70fcb96a1197ac73674a17b401 (patch)
treedd9ac86ee0ff8082bd4f87febc48b79395138723
parent155c4878708988674444abc2a2920b785980bd77 (diff)
downloadluarocks-5022dc08eb9a7a70fcb96a1197ac73674a17b401.tar.gz
luarocks-5022dc08eb9a7a70fcb96a1197ac73674a17b401.tar.bz2
luarocks-5022dc08eb9a7a70fcb96a1197ac73674a17b401.zip
Fix .def generation on Windows. (#767)
According to the Lua's manual: > Once it finds a C library, this searcher first uses a dynamic link facility to link the application with the library. Then it tries to find a C function inside the library to be used as the loader. The name of this C function is the string "luaopen_" concatenated with a copy of the module name where each dot is replaced by an underscore. Moreover, if the module name has a hyphen, its prefix up to (and including) the first hyphen is removed. For instance, if the module name is a.v1-b.c, the function name will be luaopen_b_c.
-rw-r--r--src/luarocks/build/builtin.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index 403a8aaf..294ff52b 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -122,8 +122,10 @@ function builtin.run(rockspec)
122 local basename = dir.base_name(library):gsub(".[^.]*$", "") 122 local basename = dir.base_name(library):gsub(".[^.]*$", "")
123 local deffile = basename .. ".def" 123 local deffile = basename .. ".def"
124 local def = io.open(dir.path(fs.current_dir(), deffile), "w+") 124 local def = io.open(dir.path(fs.current_dir(), deffile), "w+")
125 local exported_name = name:gsub("%.", "_")
126 exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name
125 def:write("EXPORTS\n") 127 def:write("EXPORTS\n")
126 def:write("luaopen_"..name:gsub("%.", "_").."\n") 128 def:write("luaopen_"..exported_name.."\n")
127 def:close() 129 def:close()
128 local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) 130 local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras))
129 local basedir = "" 131 local basedir = ""