diff options
| author | V1K1NGbg <victor@ilchev.com> | 2024-08-15 14:57:17 +0300 |
|---|---|---|
| committer | V1K1NGbg <victor@ilchev.com> | 2024-08-15 14:57:17 +0300 |
| commit | ed3cc55fd5de00ce71cb6b77325ac48a63b6f577 (patch) | |
| tree | fa8ff9f8c0abca41ab1f13d2a0a3d7bc7da9e502 /src | |
| parent | 23743dddc7619e728b47e6c765006d0da2a3aa16 (diff) | |
| download | luarocks-ed3cc55fd5de00ce71cb6b77325ac48a63b6f577.tar.gz luarocks-ed3cc55fd5de00ce71cb6b77325ac48a63b6f577.tar.bz2 luarocks-ed3cc55fd5de00ce71cb6b77325ac48a63b6f577.zip | |
sanity check 2
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build/builtin-incomplete.lua (renamed from src/luarocks/build/builtin-original.lua) | 182 | ||||
| -rw-r--r-- | src/luarocks/build/builtin.lua | 184 |
2 files changed, 183 insertions, 183 deletions
diff --git a/src/luarocks/build/builtin-original.lua b/src/luarocks/build/builtin-incomplete.lua index 4c15d2bf..76b50d9f 100644 --- a/src/luarocks/build/builtin-original.lua +++ b/src/luarocks/build/builtin-incomplete.lua | |||
| @@ -1,13 +1,24 @@ | |||
| 1 | local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local io = _tl_compat and _tl_compat.io or io; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local os = _tl_compat and _tl_compat.os or os; local package = _tl_compat and _tl_compat.package or package; local pairs = _tl_compat and _tl_compat.pairs or pairs; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table; local _tl_table_unpack = unpack or table.unpack | ||
| 1 | 2 | ||
| 2 | --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. | ||
| 3 | local builtin = {} | 3 | local builtin = {} |
| 4 | 4 | ||
| 5 | -- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand, | 5 | |
| 6 | -- so that pure-Lua rocks don't need to have development headers | 6 | |
| 7 | -- installed. | 7 | |
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 8 | builtin.skip_lua_inc_lib_check = true | 20 | builtin.skip_lua_inc_lib_check = true |
| 9 | 21 | ||
| 10 | local unpack = unpack or table.unpack | ||
| 11 | local dir_sep = package.config:sub(1, 1) | 22 | local dir_sep = package.config:sub(1, 1) |
| 12 | 23 | ||
| 13 | local fs = require("luarocks.fs") | 24 | local fs = require("luarocks.fs") |
| @@ -57,7 +68,7 @@ do | |||
| 57 | local copy_directories | 68 | local copy_directories |
| 58 | 69 | ||
| 59 | local prefix = "" | 70 | local prefix = "" |
| 60 | for _, parent in ipairs({"src", "lua", "lib"}) do | 71 | for _, parent in ipairs({ "src", "lua", "lib" }) do |
| 61 | if fs.is_dir(parent) then | 72 | if fs.is_dir(parent) then |
| 62 | fs.change_dir(parent) | 73 | fs.change_dir(parent) |
| 63 | prefix = parent .. dir_sep | 74 | prefix = parent .. dir_sep |
| @@ -67,16 +78,16 @@ do | |||
| 67 | 78 | ||
| 68 | for _, file in ipairs(fs.find()) do | 79 | for _, file in ipairs(fs.find()) do |
| 69 | local base = file:match("^([^\\/]*)") | 80 | local base = file:match("^([^\\/]*)") |
| 70 | if not skiplist[base] then | 81 | if not (skiplist)[base] then |
| 71 | local luamod = file:match("(.*)%.lua$") | 82 | local luamod = file:match("(.*)%.lua$") |
| 72 | if luamod then | 83 | if luamod then |
| 73 | modules[path.path_to_module(file)] = prefix .. file | 84 | modules[path.path_to_module(file)] = prefix .. file |
| 74 | else | 85 | else |
| 75 | local cmod = file:match("(.*)%.c$") | 86 | local cmod = file:match("(.*)%.c$") |
| 76 | if cmod then | 87 | if cmod then |
| 77 | local modname = get_cmod_name(file) or path.path_to_module(file:gsub("%.c$", ".lua")) | 88 | local modname = get_cmod_name(file) or path.path_to_module((file:gsub("%.c$", ".lua"))) |
| 78 | modules[modname] = { | 89 | modules[modname] = { |
| 79 | sources = prefix..file, | 90 | sources = prefix .. file, |
| 80 | libraries = libs, | 91 | libraries = libs, |
| 81 | incdirs = incdirs, | 92 | incdirs = incdirs, |
| 82 | libdirs = libdirs, | 93 | libdirs = libdirs, |
| @@ -90,8 +101,8 @@ do | |||
| 90 | fs.pop_dir() | 101 | fs.pop_dir() |
| 91 | end | 102 | end |
| 92 | 103 | ||
| 93 | local bindir = (fs.is_dir(dir.path("src", "bin")) and dir.path("src", "bin")) | 104 | local bindir = (fs.is_dir(dir.path("src", "bin")) and dir.path("src", "bin")) or |
| 94 | or (fs.is_dir("bin") and "bin") | 105 | (fs.is_dir("bin") and "bin") |
| 95 | if bindir then | 106 | if bindir then |
| 96 | install = { bin = {} } | 107 | install = { bin = {} } |
| 97 | for _, file in ipairs(fs.list_dir(bindir)) do | 108 | for _, file in ipairs(fs.list_dir(bindir)) do |
| @@ -112,33 +123,34 @@ do | |||
| 112 | end | 123 | end |
| 113 | end | 124 | end |
| 114 | 125 | ||
| 115 | --- Run a command displaying its execution on standard output. | 126 | |
| 116 | -- @return boolean: true if command succeeds (status code 0), false | 127 | |
| 117 | -- otherwise. | 128 | |
| 118 | local function execute(...) | 129 | local function execute(...) |
| 119 | io.stdout:write(table.concat({...}, " ").."\n") | 130 | io.stdout:write(table.concat({ ... }, " ") .. "\n") |
| 120 | return fs.execute(...) | 131 | return fs.execute(...) |
| 121 | end | 132 | end |
| 122 | 133 | ||
| 123 | --- Driver function for the builtin build back-end. | 134 | |
| 124 | -- @param rockspec table: the loaded rockspec. | 135 | |
| 125 | -- @return boolean or (nil, string): true if no errors occurred, | 136 | |
| 126 | -- nil and an error message otherwise. | 137 | |
| 127 | function builtin.run(rockspec, no_install) | 138 | function builtin.run(rockspec, no_install) |
| 128 | assert(rockspec:type() == "rockspec") | 139 | local compile_object |
| 129 | local compile_object, compile_library, compile_static_library | 140 | local compile_library |
| 141 | local compile_static_library | ||
| 130 | 142 | ||
| 131 | local build = rockspec.build | 143 | local build = rockspec.build |
| 132 | local variables = rockspec.variables | 144 | local variables = rockspec.variables |
| 133 | local checked_lua_h = false | 145 | local checked_lua_h = false |
| 134 | 146 | ||
| 135 | for _, var in ipairs{ "CC", "CFLAGS", "LDFLAGS" } do | 147 | for _, var in ipairs({ "CC", "CFLAGS", "LDFLAGS" }) do |
| 136 | variables[var] = variables[var] or os.getenv(var) or "" | 148 | variables[var] = variables[var] or os.getenv(var) or "" |
| 137 | end | 149 | end |
| 138 | 150 | ||
| 139 | local function add_flags(extras, flag, flags) | 151 | local function add_flags(extras, flag, flags) |
| 140 | if flags then | 152 | if flags then |
| 141 | if type(flags) ~= "table" then | 153 | if not (type(flags) == "table") then |
| 142 | flags = { tostring(flags) } | 154 | flags = { tostring(flags) } |
| 143 | end | 155 | end |
| 144 | util.variable_substitutions(flags, variables) | 156 | util.variable_substitutions(flags, variables) |
| @@ -153,43 +165,43 @@ function builtin.run(rockspec, no_install) | |||
| 153 | local extras = {} | 165 | local extras = {} |
| 154 | add_flags(extras, "-D%s", defines) | 166 | add_flags(extras, "-D%s", defines) |
| 155 | add_flags(extras, "-I%s", incdirs) | 167 | add_flags(extras, "-I%s", incdirs) |
| 156 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-o", object, "-I"..variables.LUA_INCDIR, source, unpack(extras)) | 168 | return execute(variables.CC .. " " .. variables.CFLAGS, "-c", "-o", object, "-I" .. variables.LUA_INCDIR, source, _tl_table_unpack(extras)) |
| 157 | end | 169 | end |
| 158 | compile_library = function(library, objects, libraries, libdirs, name) | 170 | compile_library = function(library, objects, libraries, libdirs, name) |
| 159 | local extras = { unpack(objects) } | 171 | local extras = { _tl_table_unpack(objects) } |
| 160 | add_flags(extras, "-L%s", libdirs) | 172 | add_flags(extras, "-L%s", libdirs) |
| 161 | add_flags(extras, "-l%s", libraries) | 173 | add_flags(extras, "-l%s", libraries) |
| 162 | extras[#extras+1] = dir.path(variables.LUA_LIBDIR, variables.LUALIB) | 174 | extras[#extras + 1] = dir.path(variables.LUA_LIBDIR, variables.LUALIB) |
| 163 | 175 | ||
| 164 | if variables.CC == "clang" or variables.CC == "clang-cl" then | 176 | if variables.CC == "clang" or variables.CC == "clang-cl" then |
| 165 | local exported_name = name:gsub("%.", "_") | 177 | local exported_name = name:gsub("%.", "_") |
| 166 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name | 178 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name |
| 167 | extras[#extras+1] = string.format("-Wl,-export:luaopen_%s", exported_name) | 179 | extras[#extras + 1] = string.format("-Wl,-export:luaopen_%s", exported_name) |
| 168 | else | 180 | else |
| 169 | extras[#extras+1] = "-l" .. (variables.MSVCRT or "m") | 181 | extras[#extras + 1] = "-l" .. (variables.MSVCRT or "m") |
| 170 | end | 182 | end |
| 171 | 183 | ||
| 172 | local ok = execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, unpack(extras)) | 184 | local ok = execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) |
| 173 | return ok | ||
| 174 | end | ||
| 175 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | ||
| 176 | compile_static_library = function(library, objects, libraries, libdirs, name) | ||
| 177 | local ok = execute(variables.AR, "rc", library, unpack(objects)) | ||
| 178 | if ok then | ||
| 179 | ok = execute(variables.RANLIB, library) | ||
| 180 | end | ||
| 181 | return ok | 185 | return ok |
| 182 | end | 186 | end |
| 183 | ]] | 187 | |
| 188 | |||
| 189 | |||
| 190 | |||
| 191 | |||
| 192 | |||
| 193 | |||
| 194 | |||
| 195 | |||
| 184 | elseif cfg.is_platform("win32") then | 196 | elseif cfg.is_platform("win32") then |
| 185 | compile_object = function(object, source, defines, incdirs) | 197 | compile_object = function(object, source, defines, incdirs) |
| 186 | local extras = {} | 198 | local extras = {} |
| 187 | add_flags(extras, "-D%s", defines) | 199 | add_flags(extras, "-D%s", defines) |
| 188 | add_flags(extras, "-I%s", incdirs) | 200 | add_flags(extras, "-I%s", incdirs) |
| 189 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-Fo"..object, "-I"..variables.LUA_INCDIR, source, unpack(extras)) | 201 | return execute(variables.CC .. " " .. variables.CFLAGS, "-c", "-Fo" .. object, "-I" .. variables.LUA_INCDIR, source, _tl_table_unpack(extras)) |
| 190 | end | 202 | end |
| 191 | compile_library = function(library, objects, libraries, libdirs, name) | 203 | compile_library = function(library, objects, libraries, libdirs, name) |
| 192 | local extras = { unpack(objects) } | 204 | local extras = { _tl_table_unpack(objects) } |
| 193 | add_flags(extras, "-libpath:%s", libdirs) | 205 | add_flags(extras, "-libpath:%s", libdirs) |
| 194 | add_flags(extras, "%s.lib", libraries) | 206 | add_flags(extras, "%s.lib", libraries) |
| 195 | local basename = dir.base_name(library):gsub(".[^.]*$", "") | 207 | local basename = dir.base_name(library):gsub(".[^.]*$", "") |
| @@ -198,49 +210,49 @@ function builtin.run(rockspec, no_install) | |||
| 198 | local exported_name = name:gsub("%.", "_") | 210 | local exported_name = name:gsub("%.", "_") |
| 199 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name | 211 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name |
| 200 | def:write("EXPORTS\n") | 212 | def:write("EXPORTS\n") |
| 201 | def:write("luaopen_"..exported_name.."\n") | 213 | def:write("luaopen_" .. exported_name .. "\n") |
| 202 | def:close() | 214 | def:close() |
| 203 | local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) | 215 | local ok = execute(variables.LD, "-dll", "-def:" .. deffile, "-out:" .. library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), _tl_table_unpack(extras)) |
| 204 | local basedir = "" | 216 | local basedir = "" |
| 205 | if name:find("%.") ~= nil then | 217 | if name:find("%.") ~= nil then |
| 206 | basedir = name:gsub("%.%w+$", "\\") | 218 | basedir = name:gsub("%.%w+$", "\\") |
| 207 | basedir = basedir:gsub("%.", "\\") | 219 | basedir = basedir:gsub("%.", "\\") |
| 208 | end | 220 | end |
| 209 | local manifestfile = basedir .. basename..".dll.manifest" | 221 | local manifestfile = basedir .. basename .. ".dll.manifest" |
| 210 | 222 | ||
| 211 | if ok and fs.exists(manifestfile) then | 223 | if ok and fs.exists(manifestfile) then |
| 212 | ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:"..basedir..basename..".dll;2") | 224 | ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:" .. basedir .. basename .. ".dll;2") |
| 213 | end | 225 | end |
| 214 | return ok | 226 | return ok |
| 215 | end | 227 | end |
| 216 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | 228 | |
| 217 | compile_static_library = function(library, objects, libraries, libdirs, name) | 229 | |
| 218 | local ok = execute(variables.AR, "-out:"..library, unpack(objects)) | 230 | |
| 219 | return ok | 231 | |
| 220 | end | 232 | |
| 221 | ]] | 233 | |
| 222 | else | 234 | else |
| 223 | compile_object = function(object, source, defines, incdirs) | 235 | compile_object = function(object, source, defines, incdirs) |
| 224 | local extras = {} | 236 | local extras = {} |
| 225 | add_flags(extras, "-D%s", defines) | 237 | add_flags(extras, "-D%s", defines) |
| 226 | add_flags(extras, "-I%s", incdirs) | 238 | add_flags(extras, "-I%s", incdirs) |
| 227 | return execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR, "-c", source, "-o", object, unpack(extras)) | 239 | return execute(variables.CC .. " " .. variables.CFLAGS, "-I" .. variables.LUA_INCDIR, "-c", source, "-o", object, _tl_table_unpack(extras)) |
| 228 | end | 240 | end |
| 229 | compile_library = function (library, objects, libraries, libdirs) | 241 | compile_library = function(library, objects, libraries, libdirs) |
| 230 | local extras = { unpack(objects) } | 242 | local extras = { _tl_table_unpack(objects) } |
| 231 | add_flags(extras, "-L%s", libdirs) | 243 | add_flags(extras, "-L%s", libdirs) |
| 232 | if cfg.gcc_rpath then | 244 | if cfg.gcc_rpath then |
| 233 | add_flags(extras, "-Wl,-rpath,%s", libdirs) | 245 | add_flags(extras, "-Wl,-rpath,%s", libdirs) |
| 234 | end | 246 | end |
| 235 | add_flags(extras, "-l%s", libraries) | 247 | add_flags(extras, "-l%s", libraries) |
| 236 | if cfg.link_lua_explicitly then | 248 | if cfg.link_lua_explicitly then |
| 237 | extras[#extras+1] = "-L"..variables.LUA_LIBDIR | 249 | extras[#extras + 1] = "-L" .. variables.LUA_LIBDIR |
| 238 | extras[#extras+1] = "-llua" | 250 | extras[#extras + 1] = "-llua" |
| 239 | end | 251 | end |
| 240 | return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, unpack(extras)) | 252 | return execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) |
| 241 | end | 253 | end |
| 242 | compile_static_library = function(library, objects, libraries, libdirs, name) -- luacheck: ignore 211 | 254 | compile_static_library = function(library, objects, libraries, libdirs, name) |
| 243 | local ok = execute(variables.AR, "rc", library, unpack(objects)) | 255 | local ok = execute(variables.AR, "rc", library, _tl_table_unpack(objects)) |
| 244 | if ok then | 256 | if ok then |
| 245 | ok = execute(variables.RANLIB, library) | 257 | ok = execute(variables.RANLIB, library) |
| 246 | end | 258 | end |
| @@ -285,15 +297,15 @@ function builtin.run(rockspec, no_install) | |||
| 285 | if ext == "lua" then | 297 | if ext == "lua" then |
| 286 | local filename = dir.base_name(info) | 298 | local filename = dir.base_name(info) |
| 287 | if filename == "init.lua" and not name:match("%.init$") then | 299 | if filename == "init.lua" and not name:match("%.init$") then |
| 288 | moddir = path.module_to_path(name..".init") | 300 | moddir = path.module_to_path(name .. ".init") |
| 289 | else | 301 | else |
| 290 | local basename = name:match("([^.]+)$") | 302 | local basename = name:match("([^.]+)$") |
| 291 | filename = basename..".lua" | 303 | filename = basename .. ".lua" |
| 292 | end | 304 | end |
| 293 | local dest = dir.path(luadir, moddir, filename) | 305 | local dest = dir.path(luadir, moddir, filename) |
| 294 | lua_modules[info] = dest | 306 | lua_modules[info] = dest |
| 295 | else | 307 | else |
| 296 | info = {info} | 308 | info = { info } |
| 297 | end | 309 | end |
| 298 | end | 310 | end |
| 299 | if type(info) == "table" then | 311 | if type(info) == "table" then |
| @@ -314,21 +326,21 @@ function builtin.run(rockspec, no_install) | |||
| 314 | local objects = {} | 326 | local objects = {} |
| 315 | local sources = info.sources | 327 | local sources = info.sources |
| 316 | if info[1] then sources = info end | 328 | if info[1] then sources = info end |
| 317 | if type(sources) == "string" then sources = {sources} end | 329 | if type(sources) == "string" then sources = { sources } end |
| 318 | if type(sources) ~= "table" then | 330 | if not (type(sources) == "table") then |
| 319 | return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" | 331 | return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" |
| 320 | end | 332 | end |
| 321 | for _, source in ipairs(sources) do | 333 | for _, source in ipairs(sources) do |
| 322 | if type(source) ~= "string" then | 334 | if not (type(source) == "string") then |
| 323 | return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." | 335 | return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." |
| 324 | end | 336 | end |
| 325 | local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension) | 337 | local object = source:gsub("%.[^.]*$", "." .. cfg.obj_extension) |
| 326 | if not object then | 338 | if not object then |
| 327 | object = source.."."..cfg.obj_extension | 339 | object = source .. "." .. cfg.obj_extension |
| 328 | end | 340 | end |
| 329 | ok = compile_object(object, source, info.defines, info.incdirs or autoincdirs) | 341 | ok = compile_object(object, source, info.defines, info.incdirs or autoincdirs) |
| 330 | if not ok then | 342 | if not ok then |
| 331 | return nil, "Failed compiling object "..object | 343 | return nil, "Failed compiling object " .. object |
| 332 | end | 344 | end |
| 333 | table.insert(objects, object) | 345 | table.insert(objects, object) |
| 334 | end | 346 | end |
| @@ -338,7 +350,7 @@ function builtin.run(rockspec, no_install) | |||
| 338 | util.schedule_function(fs.delete, compile_temp_dir) | 350 | util.schedule_function(fs.delete, compile_temp_dir) |
| 339 | end | 351 | end |
| 340 | 352 | ||
| 341 | local module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension) | 353 | local module_name = name:match("([^.]*)$") .. "." .. util.matchquote(cfg.lib_extension) |
| 342 | if moddir ~= "" then | 354 | if moddir ~= "" then |
| 343 | module_name = dir.path(moddir, module_name) | 355 | module_name = dir.path(moddir, module_name) |
| 344 | end | 356 | end |
| @@ -350,42 +362,42 @@ function builtin.run(rockspec, no_install) | |||
| 350 | lib_modules[build_name] = dir.path(libdir, module_name) | 362 | lib_modules[build_name] = dir.path(libdir, module_name) |
| 351 | ok = compile_library(build_name, objects, info.libraries, info.libdirs or autolibdirs, name) | 363 | ok = compile_library(build_name, objects, info.libraries, info.libdirs or autolibdirs, name) |
| 352 | if not ok then | 364 | if not ok then |
| 353 | return nil, "Failed compiling module "..module_name | 365 | return nil, "Failed compiling module " .. module_name |
| 354 | end | 366 | end |
| 355 | 367 | ||
| 356 | -- for backwards compatibility, try keeping a copy of the module | 368 | |
| 357 | -- in the old location (luasec-1.3.2-1 rockspec breaks otherwise) | 369 | |
| 358 | if cached_make_dir(dir.dir_name(module_name)) then | 370 | if cached_make_dir(dir.dir_name(module_name)) then |
| 359 | fs.copy(build_name, module_name) | 371 | fs.copy(build_name, module_name) |
| 360 | end | 372 | end |
| 361 | 373 | ||
| 362 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | 374 | |
| 363 | module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.static_lib_extension) | 375 | |
| 364 | if moddir ~= "" then | 376 | |
| 365 | module_name = dir.path(moddir, module_name) | 377 | |
| 366 | end | 378 | |
| 367 | lib_modules[module_name] = dir.path(libdir, module_name) | 379 | |
| 368 | ok = compile_static_library(module_name, objects, info.libraries, info.libdirs, name) | 380 | |
| 369 | if not ok then | 381 | |
| 370 | return nil, "Failed compiling static library "..module_name | 382 | |
| 371 | end | 383 | |
| 372 | ]] | 384 | |
| 373 | end | 385 | end |
| 374 | end | 386 | end |
| 375 | if not no_install then | 387 | if not no_install then |
| 376 | for _, mods in ipairs({{ tbl = lua_modules, perms = "read" }, { tbl = lib_modules, perms = "exec" }}) do | 388 | for _, mods in ipairs({ { tbl = lua_modules, perms = "read" }, { tbl = lib_modules, perms = "exec" } }) do |
| 377 | for name, dest in pairs(mods.tbl) do | 389 | for name, dest in pairs(mods.tbl) do |
| 378 | cached_make_dir(dir.dir_name(dest)) | 390 | cached_make_dir(dir.dir_name(dest)) |
| 379 | ok, err = fs.copy(name, dest, mods.perms) | 391 | ok, err = fs.copy(name, dest, mods.perms) |
| 380 | if not ok then | 392 | if not ok then |
| 381 | return nil, "Failed installing "..name.." in "..dest..": "..err | 393 | return nil, "Failed installing " .. name .. " in " .. dest .. ": " .. err |
| 382 | end | 394 | end |
| 383 | end | 395 | end |
| 384 | end | 396 | end |
| 385 | if fs.is_dir("lua") then | 397 | if fs.is_dir("lua") then |
| 386 | ok, err = fs.copy_contents("lua", luadir) | 398 | ok, err = fs.copy_contents("lua", luadir) |
| 387 | if not ok then | 399 | if not ok then |
| 388 | return nil, "Failed copying contents of 'lua' directory: "..err | 400 | return nil, "Failed copying contents of 'lua' directory: " .. err |
| 389 | end | 401 | end |
| 390 | end | 402 | end |
| 391 | end | 403 | end |
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 76b50d9f..14d13eb4 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
| @@ -1,24 +1,13 @@ | |||
| 1 | local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local io = _tl_compat and _tl_compat.io or io; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local os = _tl_compat and _tl_compat.os or os; local package = _tl_compat and _tl_compat.package or package; local pairs = _tl_compat and _tl_compat.pairs or pairs; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table; local _tl_table_unpack = unpack or table.unpack | ||
| 2 | 1 | ||
| 2 | --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. | ||
| 3 | local builtin = {} | 3 | local builtin = {} |
| 4 | 4 | ||
| 5 | 5 | -- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand, | |
| 6 | 6 | -- so that pure-Lua rocks don't need to have development headers | |
| 7 | 7 | -- installed. | |
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | builtin.skip_lua_inc_lib_check = true | 8 | builtin.skip_lua_inc_lib_check = true |
| 21 | 9 | ||
| 10 | local unpack = unpack or table.unpack | ||
| 22 | local dir_sep = package.config:sub(1, 1) | 11 | local dir_sep = package.config:sub(1, 1) |
| 23 | 12 | ||
| 24 | local fs = require("luarocks.fs") | 13 | local fs = require("luarocks.fs") |
| @@ -68,7 +57,7 @@ do | |||
| 68 | local copy_directories | 57 | local copy_directories |
| 69 | 58 | ||
| 70 | local prefix = "" | 59 | local prefix = "" |
| 71 | for _, parent in ipairs({ "src", "lua", "lib" }) do | 60 | for _, parent in ipairs({"src", "lua", "lib"}) do |
| 72 | if fs.is_dir(parent) then | 61 | if fs.is_dir(parent) then |
| 73 | fs.change_dir(parent) | 62 | fs.change_dir(parent) |
| 74 | prefix = parent .. dir_sep | 63 | prefix = parent .. dir_sep |
| @@ -78,16 +67,16 @@ do | |||
| 78 | 67 | ||
| 79 | for _, file in ipairs(fs.find()) do | 68 | for _, file in ipairs(fs.find()) do |
| 80 | local base = file:match("^([^\\/]*)") | 69 | local base = file:match("^([^\\/]*)") |
| 81 | if not (skiplist)[base] then | 70 | if not skiplist[base] then |
| 82 | local luamod = file:match("(.*)%.lua$") | 71 | local luamod = file:match("(.*)%.lua$") |
| 83 | if luamod then | 72 | if luamod then |
| 84 | modules[path.path_to_module(file)] = prefix .. file | 73 | modules[path.path_to_module(file)] = prefix .. file |
| 85 | else | 74 | else |
| 86 | local cmod = file:match("(.*)%.c$") | 75 | local cmod = file:match("(.*)%.c$") |
| 87 | if cmod then | 76 | if cmod then |
| 88 | local modname = get_cmod_name(file) or path.path_to_module((file:gsub("%.c$", ".lua"))) | 77 | local modname = get_cmod_name(file) or path.path_to_module(file:gsub("%.c$", ".lua")) |
| 89 | modules[modname] = { | 78 | modules[modname] = { |
| 90 | sources = prefix .. file, | 79 | sources = prefix..file, |
| 91 | libraries = libs, | 80 | libraries = libs, |
| 92 | incdirs = incdirs, | 81 | incdirs = incdirs, |
| 93 | libdirs = libdirs, | 82 | libdirs = libdirs, |
| @@ -101,8 +90,8 @@ do | |||
| 101 | fs.pop_dir() | 90 | fs.pop_dir() |
| 102 | end | 91 | end |
| 103 | 92 | ||
| 104 | local bindir = (fs.is_dir(dir.path("src", "bin")) and dir.path("src", "bin")) or | 93 | local bindir = (fs.is_dir(dir.path("src", "bin")) and dir.path("src", "bin")) |
| 105 | (fs.is_dir("bin") and "bin") | 94 | or (fs.is_dir("bin") and "bin") |
| 106 | if bindir then | 95 | if bindir then |
| 107 | install = { bin = {} } | 96 | install = { bin = {} } |
| 108 | for _, file in ipairs(fs.list_dir(bindir)) do | 97 | for _, file in ipairs(fs.list_dir(bindir)) do |
| @@ -123,34 +112,33 @@ do | |||
| 123 | end | 112 | end |
| 124 | end | 113 | end |
| 125 | 114 | ||
| 126 | 115 | --- Run a command displaying its execution on standard output. | |
| 127 | 116 | -- @return boolean: true if command succeeds (status code 0), false | |
| 128 | 117 | -- otherwise. | |
| 129 | local function execute(...) | 118 | local function execute(...) |
| 130 | io.stdout:write(table.concat({ ... }, " ") .. "\n") | 119 | io.stdout:write(table.concat({...}, " ").."\n") |
| 131 | return fs.execute(...) | 120 | return fs.execute(...) |
| 132 | end | 121 | end |
| 133 | 122 | ||
| 134 | 123 | --- Driver function for the builtin build back-end. | |
| 135 | 124 | -- @param rockspec table: the loaded rockspec. | |
| 136 | 125 | -- @return boolean or (nil, string): true if no errors occurred, | |
| 137 | 126 | -- nil and an error message otherwise. | |
| 138 | function builtin.run(rockspec, no_install) | 127 | function builtin.run(rockspec, no_install) |
| 139 | local compile_object | 128 | assert(rockspec:type() == "rockspec") |
| 140 | local compile_library | 129 | local compile_object, compile_library, compile_static_library |
| 141 | local compile_static_library | ||
| 142 | 130 | ||
| 143 | local build = rockspec.build | 131 | local build = rockspec.build |
| 144 | local variables = rockspec.variables | 132 | local variables = rockspec.variables |
| 145 | local checked_lua_h = false | 133 | local checked_lua_h = false |
| 146 | 134 | ||
| 147 | for _, var in ipairs({ "CC", "CFLAGS", "LDFLAGS" }) do | 135 | for _, var in ipairs{ "CC", "CFLAGS", "LDFLAGS" } do |
| 148 | variables[var] = variables[var] or os.getenv(var) or "" | 136 | variables[var] = variables[var] or os.getenv(var) or "" |
| 149 | end | 137 | end |
| 150 | 138 | ||
| 151 | local function add_flags(extras, flag, flags) | 139 | local function add_flags(extras, flag, flags) |
| 152 | if flags then | 140 | if flags then |
| 153 | if not (type(flags) == "table") then | 141 | if type(flags) ~= "table" then |
| 154 | flags = { tostring(flags) } | 142 | flags = { tostring(flags) } |
| 155 | end | 143 | end |
| 156 | util.variable_substitutions(flags, variables) | 144 | util.variable_substitutions(flags, variables) |
| @@ -165,43 +153,43 @@ function builtin.run(rockspec, no_install) | |||
| 165 | local extras = {} | 153 | local extras = {} |
| 166 | add_flags(extras, "-D%s", defines) | 154 | add_flags(extras, "-D%s", defines) |
| 167 | add_flags(extras, "-I%s", incdirs) | 155 | add_flags(extras, "-I%s", incdirs) |
| 168 | return execute(variables.CC .. " " .. variables.CFLAGS, "-c", "-o", object, "-I" .. variables.LUA_INCDIR, source, _tl_table_unpack(extras)) | 156 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-o", object, "-I"..variables.LUA_INCDIR, source, unpack(extras)) |
| 169 | end | 157 | end |
| 170 | compile_library = function(library, objects, libraries, libdirs, name) | 158 | compile_library = function(library, objects, libraries, libdirs, name) |
| 171 | local extras = { _tl_table_unpack(objects) } | 159 | local extras = { unpack(objects) } |
| 172 | add_flags(extras, "-L%s", libdirs) | 160 | add_flags(extras, "-L%s", libdirs) |
| 173 | add_flags(extras, "-l%s", libraries) | 161 | add_flags(extras, "-l%s", libraries) |
| 174 | extras[#extras + 1] = dir.path(variables.LUA_LIBDIR, variables.LUALIB) | 162 | extras[#extras+1] = dir.path(variables.LUA_LIBDIR, variables.LUALIB) |
| 175 | 163 | ||
| 176 | if variables.CC == "clang" or variables.CC == "clang-cl" then | 164 | if variables.CC == "clang" or variables.CC == "clang-cl" then |
| 177 | local exported_name = name:gsub("%.", "_") | 165 | local exported_name = name:gsub("%.", "_") |
| 178 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name | 166 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name |
| 179 | extras[#extras + 1] = string.format("-Wl,-export:luaopen_%s", exported_name) | 167 | extras[#extras+1] = string.format("-Wl,-export:luaopen_%s", exported_name) |
| 180 | else | 168 | else |
| 181 | extras[#extras + 1] = "-l" .. (variables.MSVCRT or "m") | 169 | extras[#extras+1] = "-l" .. (variables.MSVCRT or "m") |
| 182 | end | 170 | end |
| 183 | 171 | ||
| 184 | local ok = execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) | 172 | local ok = execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, unpack(extras)) |
| 185 | return ok | 173 | return ok |
| 186 | end | 174 | end |
| 187 | 175 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | |
| 188 | 176 | compile_static_library = function(library, objects, libraries, libdirs, name) | |
| 189 | 177 | local ok = execute(variables.AR, "rc", library, unpack(objects)) | |
| 190 | 178 | if ok then | |
| 191 | 179 | ok = execute(variables.RANLIB, library) | |
| 192 | 180 | end | |
| 193 | 181 | return ok | |
| 194 | 182 | end | |
| 195 | 183 | ]] | |
| 196 | elseif cfg.is_platform("win32") then | 184 | elseif cfg.is_platform("win32") then |
| 197 | compile_object = function(object, source, defines, incdirs) | 185 | compile_object = function(object, source, defines, incdirs) |
| 198 | local extras = {} | 186 | local extras = {} |
| 199 | add_flags(extras, "-D%s", defines) | 187 | add_flags(extras, "-D%s", defines) |
| 200 | add_flags(extras, "-I%s", incdirs) | 188 | add_flags(extras, "-I%s", incdirs) |
| 201 | return execute(variables.CC .. " " .. variables.CFLAGS, "-c", "-Fo" .. object, "-I" .. variables.LUA_INCDIR, source, _tl_table_unpack(extras)) | 189 | return execute(variables.CC.." "..variables.CFLAGS, "-c", "-Fo"..object, "-I"..variables.LUA_INCDIR, source, unpack(extras)) |
| 202 | end | 190 | end |
| 203 | compile_library = function(library, objects, libraries, libdirs, name) | 191 | compile_library = function(library, objects, libraries, libdirs, name) |
| 204 | local extras = { _tl_table_unpack(objects) } | 192 | local extras = { unpack(objects) } |
| 205 | add_flags(extras, "-libpath:%s", libdirs) | 193 | add_flags(extras, "-libpath:%s", libdirs) |
| 206 | add_flags(extras, "%s.lib", libraries) | 194 | add_flags(extras, "%s.lib", libraries) |
| 207 | local basename = dir.base_name(library):gsub(".[^.]*$", "") | 195 | local basename = dir.base_name(library):gsub(".[^.]*$", "") |
| @@ -210,49 +198,49 @@ function builtin.run(rockspec, no_install) | |||
| 210 | local exported_name = name:gsub("%.", "_") | 198 | local exported_name = name:gsub("%.", "_") |
| 211 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name | 199 | exported_name = exported_name:match('^[^%-]+%-(.+)$') or exported_name |
| 212 | def:write("EXPORTS\n") | 200 | def:write("EXPORTS\n") |
| 213 | def:write("luaopen_" .. exported_name .. "\n") | 201 | def:write("luaopen_"..exported_name.."\n") |
| 214 | def:close() | 202 | def:close() |
| 215 | local ok = execute(variables.LD, "-dll", "-def:" .. deffile, "-out:" .. library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), _tl_table_unpack(extras)) | 203 | local ok = execute(variables.LD, "-dll", "-def:"..deffile, "-out:"..library, dir.path(variables.LUA_LIBDIR, variables.LUALIB), unpack(extras)) |
| 216 | local basedir = "" | 204 | local basedir = "" |
| 217 | if name:find("%.") ~= nil then | 205 | if name:find("%.") ~= nil then |
| 218 | basedir = name:gsub("%.%w+$", "\\") | 206 | basedir = name:gsub("%.%w+$", "\\") |
| 219 | basedir = basedir:gsub("%.", "\\") | 207 | basedir = basedir:gsub("%.", "\\") |
| 220 | end | 208 | end |
| 221 | local manifestfile = basedir .. basename .. ".dll.manifest" | 209 | local manifestfile = basedir .. basename..".dll.manifest" |
| 222 | 210 | ||
| 223 | if ok and fs.exists(manifestfile) then | 211 | if ok and fs.exists(manifestfile) then |
| 224 | ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:" .. basedir .. basename .. ".dll;2") | 212 | ok = execute(variables.MT, "-manifest", manifestfile, "-outputresource:"..basedir..basename..".dll;2") |
| 225 | end | 213 | end |
| 226 | return ok | 214 | return ok |
| 227 | end | 215 | end |
| 228 | 216 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | |
| 229 | 217 | compile_static_library = function(library, objects, libraries, libdirs, name) | |
| 230 | 218 | local ok = execute(variables.AR, "-out:"..library, unpack(objects)) | |
| 231 | 219 | return ok | |
| 232 | 220 | end | |
| 233 | 221 | ]] | |
| 234 | else | 222 | else |
| 235 | compile_object = function(object, source, defines, incdirs) | 223 | compile_object = function(object, source, defines, incdirs) |
| 236 | local extras = {} | 224 | local extras = {} |
| 237 | add_flags(extras, "-D%s", defines) | 225 | add_flags(extras, "-D%s", defines) |
| 238 | add_flags(extras, "-I%s", incdirs) | 226 | add_flags(extras, "-I%s", incdirs) |
| 239 | return execute(variables.CC .. " " .. variables.CFLAGS, "-I" .. variables.LUA_INCDIR, "-c", source, "-o", object, _tl_table_unpack(extras)) | 227 | return execute(variables.CC.." "..variables.CFLAGS, "-I"..variables.LUA_INCDIR, "-c", source, "-o", object, unpack(extras)) |
| 240 | end | 228 | end |
| 241 | compile_library = function(library, objects, libraries, libdirs) | 229 | compile_library = function (library, objects, libraries, libdirs) |
| 242 | local extras = { _tl_table_unpack(objects) } | 230 | local extras = { unpack(objects) } |
| 243 | add_flags(extras, "-L%s", libdirs) | 231 | add_flags(extras, "-L%s", libdirs) |
| 244 | if cfg.gcc_rpath then | 232 | if cfg.gcc_rpath then |
| 245 | add_flags(extras, "-Wl,-rpath,%s", libdirs) | 233 | add_flags(extras, "-Wl,-rpath,%s", libdirs) |
| 246 | end | 234 | end |
| 247 | add_flags(extras, "-l%s", libraries) | 235 | add_flags(extras, "-l%s", libraries) |
| 248 | if cfg.link_lua_explicitly then | 236 | if cfg.link_lua_explicitly then |
| 249 | extras[#extras + 1] = "-L" .. variables.LUA_LIBDIR | 237 | extras[#extras+1] = "-L"..variables.LUA_LIBDIR |
| 250 | extras[#extras + 1] = "-llua" | 238 | extras[#extras+1] = "-llua" |
| 251 | end | 239 | end |
| 252 | return execute(variables.LD .. " " .. variables.LDFLAGS .. " " .. variables.LIBFLAG, "-o", library, _tl_table_unpack(extras)) | 240 | return execute(variables.LD.." "..variables.LDFLAGS.." "..variables.LIBFLAG, "-o", library, unpack(extras)) |
| 253 | end | 241 | end |
| 254 | compile_static_library = function(library, objects, libraries, libdirs, name) | 242 | compile_static_library = function(library, objects, libraries, libdirs, name) -- luacheck: ignore 211 |
| 255 | local ok = execute(variables.AR, "rc", library, _tl_table_unpack(objects)) | 243 | local ok = execute(variables.AR, "rc", library, unpack(objects)) |
| 256 | if ok then | 244 | if ok then |
| 257 | ok = execute(variables.RANLIB, library) | 245 | ok = execute(variables.RANLIB, library) |
| 258 | end | 246 | end |
| @@ -297,15 +285,15 @@ function builtin.run(rockspec, no_install) | |||
| 297 | if ext == "lua" then | 285 | if ext == "lua" then |
| 298 | local filename = dir.base_name(info) | 286 | local filename = dir.base_name(info) |
| 299 | if filename == "init.lua" and not name:match("%.init$") then | 287 | if filename == "init.lua" and not name:match("%.init$") then |
| 300 | moddir = path.module_to_path(name .. ".init") | 288 | moddir = path.module_to_path(name..".init") |
| 301 | else | 289 | else |
| 302 | local basename = name:match("([^.]+)$") | 290 | local basename = name:match("([^.]+)$") |
| 303 | filename = basename .. ".lua" | 291 | filename = basename..".lua" |
| 304 | end | 292 | end |
| 305 | local dest = dir.path(luadir, moddir, filename) | 293 | local dest = dir.path(luadir, moddir, filename) |
| 306 | lua_modules[info] = dest | 294 | lua_modules[info] = dest |
| 307 | else | 295 | else |
| 308 | info = { info } | 296 | info = {info} |
| 309 | end | 297 | end |
| 310 | end | 298 | end |
| 311 | if type(info) == "table" then | 299 | if type(info) == "table" then |
| @@ -326,21 +314,21 @@ function builtin.run(rockspec, no_install) | |||
| 326 | local objects = {} | 314 | local objects = {} |
| 327 | local sources = info.sources | 315 | local sources = info.sources |
| 328 | if info[1] then sources = info end | 316 | if info[1] then sources = info end |
| 329 | if type(sources) == "string" then sources = { sources } end | 317 | if type(sources) == "string" then sources = {sources} end |
| 330 | if not (type(sources) == "table") then | 318 | if type(sources) ~= "table" then |
| 331 | return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" | 319 | return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" |
| 332 | end | 320 | end |
| 333 | for _, source in ipairs(sources) do | 321 | for _, source in ipairs(sources) do |
| 334 | if not (type(source) == "string") then | 322 | if type(source) ~= "string" then |
| 335 | return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." | 323 | return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." |
| 336 | end | 324 | end |
| 337 | local object = source:gsub("%.[^.]*$", "." .. cfg.obj_extension) | 325 | local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension) |
| 338 | if not object then | 326 | if not object then |
| 339 | object = source .. "." .. cfg.obj_extension | 327 | object = source.."."..cfg.obj_extension |
| 340 | end | 328 | end |
| 341 | ok = compile_object(object, source, info.defines, info.incdirs or autoincdirs) | 329 | ok = compile_object(object, source, info.defines, info.incdirs or autoincdirs) |
| 342 | if not ok then | 330 | if not ok then |
| 343 | return nil, "Failed compiling object " .. object | 331 | return nil, "Failed compiling object "..object |
| 344 | end | 332 | end |
| 345 | table.insert(objects, object) | 333 | table.insert(objects, object) |
| 346 | end | 334 | end |
| @@ -350,7 +338,7 @@ function builtin.run(rockspec, no_install) | |||
| 350 | util.schedule_function(fs.delete, compile_temp_dir) | 338 | util.schedule_function(fs.delete, compile_temp_dir) |
| 351 | end | 339 | end |
| 352 | 340 | ||
| 353 | local module_name = name:match("([^.]*)$") .. "." .. util.matchquote(cfg.lib_extension) | 341 | local module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.lib_extension) |
| 354 | if moddir ~= "" then | 342 | if moddir ~= "" then |
| 355 | module_name = dir.path(moddir, module_name) | 343 | module_name = dir.path(moddir, module_name) |
| 356 | end | 344 | end |
| @@ -362,46 +350,46 @@ function builtin.run(rockspec, no_install) | |||
| 362 | lib_modules[build_name] = dir.path(libdir, module_name) | 350 | lib_modules[build_name] = dir.path(libdir, module_name) |
| 363 | ok = compile_library(build_name, objects, info.libraries, info.libdirs or autolibdirs, name) | 351 | ok = compile_library(build_name, objects, info.libraries, info.libdirs or autolibdirs, name) |
| 364 | if not ok then | 352 | if not ok then |
| 365 | return nil, "Failed compiling module " .. module_name | 353 | return nil, "Failed compiling module "..module_name |
| 366 | end | 354 | end |
| 367 | 355 | ||
| 368 | 356 | -- for backwards compatibility, try keeping a copy of the module | |
| 369 | 357 | -- in the old location (luasec-1.3.2-1 rockspec breaks otherwise) | |
| 370 | if cached_make_dir(dir.dir_name(module_name)) then | 358 | if cached_make_dir(dir.dir_name(module_name)) then |
| 371 | fs.copy(build_name, module_name) | 359 | fs.copy(build_name, module_name) |
| 372 | end | 360 | end |
| 373 | 361 | ||
| 374 | 362 | --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. | |
| 375 | 363 | module_name = name:match("([^.]*)$").."."..util.matchquote(cfg.static_lib_extension) | |
| 376 | 364 | if moddir ~= "" then | |
| 377 | 365 | module_name = dir.path(moddir, module_name) | |
| 378 | 366 | end | |
| 379 | 367 | lib_modules[module_name] = dir.path(libdir, module_name) | |
| 380 | 368 | ok = compile_static_library(module_name, objects, info.libraries, info.libdirs, name) | |
| 381 | 369 | if not ok then | |
| 382 | 370 | return nil, "Failed compiling static library "..module_name | |
| 383 | 371 | end | |
| 384 | 372 | ]] | |
| 385 | end | 373 | end |
| 386 | end | 374 | end |
| 387 | if not no_install then | 375 | if not no_install then |
| 388 | for _, mods in ipairs({ { tbl = lua_modules, perms = "read" }, { tbl = lib_modules, perms = "exec" } }) do | 376 | for _, mods in ipairs({{ tbl = lua_modules, perms = "read" }, { tbl = lib_modules, perms = "exec" }}) do |
| 389 | for name, dest in pairs(mods.tbl) do | 377 | for name, dest in pairs(mods.tbl) do |
| 390 | cached_make_dir(dir.dir_name(dest)) | 378 | cached_make_dir(dir.dir_name(dest)) |
| 391 | ok, err = fs.copy(name, dest, mods.perms) | 379 | ok, err = fs.copy(name, dest, mods.perms) |
| 392 | if not ok then | 380 | if not ok then |
| 393 | return nil, "Failed installing " .. name .. " in " .. dest .. ": " .. err | 381 | return nil, "Failed installing "..name.." in "..dest..": "..err |
| 394 | end | 382 | end |
| 395 | end | 383 | end |
| 396 | end | 384 | end |
| 397 | if fs.is_dir("lua") then | 385 | if fs.is_dir("lua") then |
| 398 | ok, err = fs.copy_contents("lua", luadir) | 386 | ok, err = fs.copy_contents("lua", luadir) |
| 399 | if not ok then | 387 | if not ok then |
| 400 | return nil, "Failed copying contents of 'lua' directory: " .. err | 388 | return nil, "Failed copying contents of 'lua' directory: "..err |
| 401 | end | 389 | end |
| 402 | end | 390 | end |
| 403 | end | 391 | end |
| 404 | return true | 392 | return true |
| 405 | end | 393 | end |
| 406 | 394 | ||
| 407 | return builtin | 395 | return builtin \ No newline at end of file |
