diff options
author | Reuben Thomas <rrt@sc3d.org> | 2012-10-04 18:02:24 +0100 |
---|---|---|
committer | Reuben Thomas <rrt@sc3d.org> | 2012-10-04 18:02:24 +0100 |
commit | 41d9fad85070f354b097b8be9aa34bd588314cdb (patch) | |
tree | 533aeb4f87143f79a1d057c23869f2f10b6573fe /mkrockspecs.lua | |
parent | a3dd13c7a178a58ecabac18af29a38b71ec2e165 (diff) | |
download | lrexlib-41d9fad85070f354b097b8be9aa34bd588314cdb.tar.gz |
Replace build systems with LuaRocks.
A single Makefile remains to take care of tests, distribution, release
and documentation.
As a result, rockspecs are automatically generated for all lrexlib
flavours (previously, only POSIX and PCRE were available).
Diffstat (limited to 'mkrockspecs.lua')
-rw-r--r-- | mkrockspecs.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/mkrockspecs.lua b/mkrockspecs.lua new file mode 100644 index 0000000..6a2506c --- /dev/null +++ b/mkrockspecs.lua @@ -0,0 +1,49 @@ +-- Generate the rockspecs + +require "std" + +if select ("#", ...) < 2 then + io.stderr:write "Usage: mkrockspecs VERSION MD5SUM\n" + os.exit () +end + +version = select (1, ...) +md5sum = select (2, ...) + +function format (x, indent) + indent = indent or "" + if type (x) == "table" then + local s = "{\n" + for i, v in pairs (x) do + if type (i) ~= "number" then + s = s..indent..i.." = "..format (v, indent.." ")..",\n" + end + end + for i, v in ipairs (x) do + s = s..indent..format (v, indent.." ")..",\n" + end + return s..indent:sub(1, -3).."}" + elseif type (x) == "string" then + return string.format ("%q", x) + else + return tostring (x) + end +end + +for f, spec in pairs (loadfile ("rockspecs.lua") ()) do + if f ~= "default" then + local specfile = "lrexlib-"..f:lower ().."-"..version.."-1.rockspec" + h = io.open (specfile, "w") + assert (h) + flavour = f -- a global, visible in loadfile + local specs = loadfile ("rockspecs.lua") () -- reload to get current flavour interpolated + local spec = table.merge (specs.default, specs[f]) + local s = "" + for i, v in pairs (spec) do + s = s..i.." = "..format (v, " ").."\n" + end + h:write (s) + h:close () + os.execute ("luarocks lint " .. specfile) + end +end |