1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
--
-- Copyright (c) 2009 Nokia Corporation.
--
-- Licensed under MIT licence
--
-- This script reads in argvmods_xxx.lua file (xxx being here
-- gcc or misc) and writes out lua table containing generated
-- argvmods rules.
--
argvmods = {}
local argvmods_source_file = session_dir .. "/lua_scripts/" ..
os.getenv("SBOX_ARGVMODS_SOURCE_FILE")
do_file(argvmods_source_file)
local allowed_rulenames = {
"name",
"path_prefixes",
"add_head",
"add_tail",
"remove",
"new_filename",
"disable_mapping",
"drivers",
}
print("--")
print("-- Generator: create_argvmods_rules.lua")
print("-- Source file: " .. argvmods_source_file)
print("-- Automatically generated rules. Do not modify:")
print("--")
local count = 0
for binary_name, rule in pairs(argvmods) do
print(string.format("argvmods[\"%s\"] = {", binary_name))
for name, value in pairs(rule) do
--
-- Check that rulename is valid.
--
local found = 0
for i = 1, #allowed_rulenames do
if name == allowed_rulenames[i] then
found = 1
break
end
end
if found == 0 then
io.stderr:write(string.format(
"invalid rulename '%s'\n", name))
end
io.write(string.format("\t%s = ", name))
if type(value) == "string" then
io.write(string.format("\"%s\"", value))
elseif type(value) == "number" then
io.write(string.format("%d", value))
elseif type(value) == "table" then
if #value == 0 then
io.write("{}")
else
io.write("{\n")
for i = 1, #value do
assert(type(value[i]) == "string")
io.write(
string.format("\t\t\"%s\",\n",
value[i]))
end
io.write("\t}");
end
else
io.stderr:write(string.format(
"unsupported type '%s' in argvmod rule\n",
type(value)))
assert(false)
end
io.write(",\n")
end
print("}")
count = count + 1
end
print("--")
print(string.format("-- Total %d rule(s).", count))
print("-- End of rules created by argvmods expander.")
print("--")
|