aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Roman <30772943+georgeroman@users.noreply.github.com>2018-06-05 17:36:57 +0300
committerHisham Muhammad <hisham@gobolinux.org>2018-06-05 11:36:57 -0300
commitd25d70512faf81a4fe2c6764e771ee3290f88a37 (patch)
tree3d9ccd496a639db51e11a9b978df1983f2827e4e
parentdb066d68e0355b98106a6e1f5f2573047363f851 (diff)
downloadluarocks-d25d70512faf81a4fe2c6764e771ee3290f88a37.tar.gz
luarocks-d25d70512faf81a4fe2c6764e771ee3290f88a37.tar.bz2
luarocks-d25d70512faf81a4fe2c6764e771ee3290f88a37.zip
build.builtin: Remove EXEWRAPPER sections (#812)
-rw-r--r--src/luarocks/build/builtin.lua84
1 files changed, 1 insertions, 83 deletions
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua
index 68fb75ed..e8b0943d 100644
--- a/src/luarocks/build/builtin.lua
+++ b/src/luarocks/build/builtin.lua
@@ -18,38 +18,13 @@ local function execute(...)
18 return fs.execute(...) 18 return fs.execute(...)
19end 19end
20 20
21--- Makes an RC file with an embedded Lua script, for building .exes on Windows
22-- @return nil if could open files, error otherwise
23local function make_rc(luafilename, rcfilename)
24 --TODO EXEWRAPPER
25 local rcfile = io.open(rcfilename, "w")
26 if not rcfile then
27 error("Could not open "..rcfilename.." for writing.")
28 end
29 rcfile:write("STRINGTABLE\r\nBEGIN\r\n")
30
31 local i = 1
32 for line in io.lines(luafilename) do
33 if not line:match("^#!") then
34 rcfile:write(i .. " \"")
35 line = line:gsub("\\", "\\\\"):gsub('"', '""'):gsub("[\r\n]+", "")
36 rcfile:write(line .. "\\r\\n\"\r\n")
37 i = i + 1
38 end
39 end
40
41 rcfile:write("END\r\n")
42
43 rcfile:close()
44end
45
46--- Driver function for the builtin build back-end. 21--- Driver function for the builtin build back-end.
47-- @param rockspec table: the loaded rockspec. 22-- @param rockspec table: the loaded rockspec.
48-- @return boolean or (nil, string): true if no errors ocurred, 23-- @return boolean or (nil, string): true if no errors ocurred,
49-- nil and an error message otherwise. 24-- nil and an error message otherwise.
50function builtin.run(rockspec) 25function builtin.run(rockspec)
51 assert(type(rockspec) == "table") 26 assert(type(rockspec) == "table")
52 local compile_object, compile_library, compile_static_library, compile_wrapper_binary --TODO EXEWRAPPER 27 local compile_object, compile_library, compile_static_library
53 28
54 local build = rockspec.build 29 local build = rockspec.build
55 local variables = rockspec.variables 30 local variables = rockspec.variables
@@ -92,22 +67,6 @@ function builtin.run(rockspec)
92 return ok 67 return ok
93 end 68 end
94 ]] 69 ]]
95 compile_wrapper_binary = function(fullname, name)
96 --TODO EXEWRAPPER
97 local fullbasename = fullname:gsub("%.lua$", ""):gsub("/", "\\")
98 local basename = name:gsub("%.lua$", ""):gsub("/", "\\")
99 local rcname = basename..".rc"
100 local resname = basename..".o"
101 local wrapname = basename..".exe"
102 make_rc(fullname, fullbasename..".rc")
103 local ok = execute(variables.RC, "-o", resname, rcname)
104 if not ok then return ok end
105 ok = execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR,
106 "-o", wrapname, resname, variables.WRAPPER,
107 dir.path(variables.LUA_LIBDIR, variables.LUALIB),
108 "-l" .. (variables.MSVCRT or "m"), "-luser32")
109 return ok, wrapname
110 end
111 elseif cfg.is_platform("win32") then 70 elseif cfg.is_platform("win32") then
112 compile_object = function(object, source, defines, incdirs) 71 compile_object = function(object, source, defines, incdirs)
113 local extras = {} 72 local extras = {}
@@ -146,28 +105,6 @@ function builtin.run(rockspec)
146 return ok 105 return ok
147 end 106 end
148 ]] 107 ]]
149 compile_wrapper_binary = function(fullname, name)
150 --TODO EXEWRAPPER
151 local fullbasename = fullname:gsub("%.lua$", ""):gsub("/", "\\")
152 local basename = name:gsub("%.lua$", ""):gsub("/", "\\")
153 local object = basename..".obj"
154 local rcname = basename..".rc"
155 local resname = basename..".res"
156 local wrapname = basename..".exe"
157 make_rc(fullname, fullbasename..".rc")
158 local ok = execute(variables.RC, "-nologo", "-r", "-fo"..resname, rcname)
159 if not ok then return ok end
160 ok = execute(variables.CC.." "..variables.CFLAGS, "-c", "-Fo"..object,
161 "-I"..variables.LUA_INCDIR, variables.WRAPPER)
162 if not ok then return ok end
163 ok = execute(variables.LD, "-out:"..wrapname, resname, object,
164 dir.path(variables.LUA_LIBDIR, variables.LUALIB), "user32.lib")
165 local manifestfile = wrapname..".manifest"
166 if ok and fs.exists(manifestfile) then
167 ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:"..wrapname..";1")
168 end
169 return ok, wrapname
170 end
171 else 108 else
172 compile_object = function(object, source, defines, incdirs) 109 compile_object = function(object, source, defines, incdirs)
173 local extras = {} 110 local extras = {}
@@ -194,8 +131,6 @@ function builtin.run(rockspec)
194 end 131 end
195 return ok 132 return ok
196 end 133 end
197 compile_wrapper_binary = function(_, name) return true, name end
198 --TODO EXEWRAPPER
199 end 134 end
200 135
201 local ok, err 136 local ok, err
@@ -203,23 +138,6 @@ function builtin.run(rockspec)
203 local lib_modules = {} 138 local lib_modules = {}
204 local luadir = path.lua_dir(rockspec.name, rockspec.version) 139 local luadir = path.lua_dir(rockspec.name, rockspec.version)
205 local libdir = path.lib_dir(rockspec.name, rockspec.version) 140 local libdir = path.lib_dir(rockspec.name, rockspec.version)
206 --TODO EXEWRAPPER
207 -- On Windows, compiles an .exe for each Lua file in build.install.bin, and
208 -- replaces the filename with the .exe name. Strips the .lua extension if it exists,
209 -- otherwise just appends .exe to the name. Only if `cfg.exewrapper = true`
210 if build.install and build.install.bin then
211 for key, name in pairs(build.install.bin) do
212 local fullname = dir.path(fs.current_dir(), name)
213 if cfg.exewrapper and fs.is_lua(fullname) then
214 ok, name = compile_wrapper_binary(fullname, name)
215 if ok then
216 build.install.bin[key] = name
217 else
218 return nil, "Build error in wrapper binaries"
219 end
220 end
221 end
222 end
223 141
224 if not build.modules then 142 if not build.modules then
225 return nil, "Missing build.modules table" 143 return nil, "Missing build.modules table"