summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReuben Thomas <rrt@sc3d.org>2014-08-05 13:44:50 +0100
committerReuben Thomas <rrt@sc3d.org>2014-08-05 13:44:50 +0100
commitc50b36c961590fd89e02ad1d96dbfee7fe5d0493 (patch)
treebbc98d0b8b72a75607380a6b19ca624dbedb5351
parentc2cc10463b5265cf613961718a5a56578ddf094d (diff)
downloadlrexlib-c50b36c961590fd89e02ad1d96dbfee7fe5d0493.tar.gz
Update mkrockspecs.lua
-rw-r--r--Makefile2
-rw-r--r--mkrockspecs.lua17
2 files changed, 10 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 9160589..9ea2448 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ install: rockspecs
rockspecs:
rm -f *.rockspec
- $(LUA) mkrockspecs.lua $(VERSION)
+ $(LUA) mkrockspecs.lua $(PROJECT) $(VERSION)
doc/index.txt: README.rst
$(CP) $< $@
diff --git a/mkrockspecs.lua b/mkrockspecs.lua
index d0596e6..e4cbf85 100644
--- a/mkrockspecs.lua
+++ b/mkrockspecs.lua
@@ -1,13 +1,14 @@
--- Generate the rockspecs
+-- Generate rockspecs from a prototype with variants
-require "std"
+local tree = require "std.tree"
-if select ("#", ...) < 1 then
- io.stderr:write "Usage: mkrockspecs VERSION\n"
+if select ("#", ...) < 2 then
+ io.stderr:write "Usage: mkrockspecs PACKAGE VERSION\n"
os.exit ()
end
-version = select (1, ...)
+package_name = select (1, ...)
+version = select (2, ...)
function format (x, indent)
indent = indent or ""
@@ -21,7 +22,7 @@ function format (x, indent)
for i, v in ipairs (x) do
s = s..indent..format (v, indent.." ")..",\n"
end
- return s..indent:sub(1, -3).."}"
+ return s..indent:sub (1, -3).."}"
elseif type (x) == "string" then
return string.format ("%q", x)
else
@@ -31,12 +32,12 @@ end
for f, spec in pairs (loadfile ("rockspecs.lua") ()) do
if f ~= "default" then
- local specfile = "lrexlib-"..f:lower ().."-"..version.."-1.rockspec"
+ local specfile = package_name.."-"..(f ~= "" and f:lower ().."-" or "")..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 spec = tree.merge (tree (specs.default), tree (specs[f]))
local s = ""
for i, v in pairs (spec) do
s = s..i.." = "..format (v, " ").."\n"