aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordwenegar <simone.livieri@gmail.com>2018-02-15 08:16:26 +0900
committerHisham Muhammad <hisham@gobolinux.org>2018-03-12 21:06:58 -0300
commit37a2c165d6e4c5097352dc71b11fb918ff1d5434 (patch)
tree582537ddeadacf63299c30bc5114b4ed7b93bf25
parentbeb4e60108f14a87a58edcddace5187d31896d38 (diff)
downloadluarocks-37a2c165d6e4c5097352dc71b11fb918ff1d5434.tar.gz
luarocks-37a2c165d6e4c5097352dc71b11fb918ff1d5434.tar.bz2
luarocks-37a2c165d6e4c5097352dc71b11fb918ff1d5434.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 ccefaa3b..b8f3cc39 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -113,8 +113,10 @@ function builtin.run(rockspec)
113 local basename = dir.base_name(library):gsub(".[^.]*$", "") 113 local basename = dir.base_name(library):gsub(".[^.]*$", "")
114 local deffile = basename .. ".def" 114 local deffile = basename .. ".def"
115 local def = io.open(dir.path(fs.current_dir(), deffile), "w+") 115 local def = io.open(dir.path(fs.current_dir(), deffile), "w+")
116 local exported_name = name:gsub("%.", "_")
117 exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name
116 def:write("EXPORTS\n") 118 def:write("EXPORTS\n")
117 def:write("luaopen_"..name:gsub("%.", "_").."\n") 119 def:write("luaopen_"..exported_name.."\n")
118 def:close() 120 def:close()
119 local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) 121 local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras))
120 local basedir = "" 122 local basedir = ""