From 37a2c165d6e4c5097352dc71b11fb918ff1d5434 Mon Sep 17 00:00:00 2001 From: dwenegar Date: Thu, 15 Feb 2018 08:16:26 +0900 Subject: 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. --- src/luarocks/build/builtin.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') 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) local basename = dir.base_name(library):gsub(".[^.]*$", "") local deffile = basename .. ".def" local def = io.open(dir.path(fs.current_dir(), deffile), "w+") + local exported_name = name:gsub("%.", "_") + exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name def:write("EXPORTS\n") - def:write("luaopen_"..name:gsub("%.", "_").."\n") + def:write("luaopen_"..exported_name.."\n") def:close() local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) local basedir = "" -- cgit v1.2.3-55-g6feb