Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Schneider <oliver@assarbad.net>2014-02-04 07:54:29 +0400
committerOliver Schneider <oliver@assarbad.net>2014-02-04 07:54:29 +0400
commit0a6504eef0caf34b4ab51523cd1e0c5f4339b48a (patch)
tree27d9e2de9bd56a0df8d1440568e88988db86b1ac
parent9358ccbb8f60d59c11ef1f35324851aa533daedb (diff)
Giving summary of the Lua source diet, instead of individual lineshg/LuaSrcDiet_in_embed_action
--HG-- branch : LuaSrcDiet_in_embed_action
-rw-r--r--scripts/embed.lua34
1 files changed, 21 insertions, 13 deletions
diff --git a/scripts/embed.lua b/scripts/embed.lua
index 57f1034..5dd08c5 100644
--- a/scripts/embed.lua
+++ b/scripts/embed.lua
@@ -1,10 +1,13 @@
--
-- Embed the Lua scripts into src/host/scripts.c as static data buffers.
--- I embed the actual scripts, rather than Lua bytecodes, because the
--- bytecodes are not portable to different architectures, which causes
+-- I embed the actual scripts, rather than Lua bytecodes, because the
+-- bytecodes are not portable to different architectures, which causes
-- issues in Mac OS X Universal builds.
--
+ local raw_sum = 0
+ local trim_sum = 0
+
local function stripfile(fname)
dofile("scripts/luasrcdiet/LuaSrcDiet.lua")
-- Let LuaSrcDiet do its job
@@ -13,7 +16,9 @@
-- strip any CRs
s = s:gsub("[\r]", "")
- print("\ttrimmed size: ", s:len(), " down from: ", l:len()) -- we report the "raw" length
+ -- overall counters
+ raw_sum = raw_sum + l:len()
+ trim_sum = trim_sum + s:len()
-- escape backslashes
s = s:gsub("\\", "\\\\")
@@ -32,14 +37,14 @@
out:write(s)
out:write(iif(continues, "\"\n", "\",\n"))
end
-
-
+
+
local function writefile(out, fname, contents)
local max = 1024
out:write("\t/* " .. fname .. " */\n")
-
- -- break up large strings to fit in Visual Studio's string length limit
+
+ -- break up large strings to fit in Visual Studio's string length limit
local start = 1
local len = contents:len()
while start <= len do
@@ -50,36 +55,39 @@
-- make sure I don't cut an escape sequence
while contents:sub(finish, finish) == "\\" do
finish = finish - 1
- end
+ end
writeline(out, contents:sub(start, finish), finish < len)
start = finish + 1
- end
+ end
out:write("\n")
end
function doembed()
+ raw_sum = 0
+ trim_sum = 0
-- load the manifest of script files
scripts = dofile("src/_manifest.lua")
-
+
-- main script always goes at the end
table.insert(scripts, "_premake_main.lua")
-
+
-- open scripts.c and write the file header
local out = io.open("src/host/scripts.c", "w+b")
out:write("/* Premake's Lua scripts, as static data buffers for release mode builds */\n")
out:write("/* DO NOT EDIT - this file is autogenerated - see BUILD.txt */\n")
out:write("/* To regenerate this file, run: premake4 embed */ \n\n")
out:write("const char* builtin_scripts[] = {\n")
-
+
for i,fn in ipairs(scripts) do
print(fn)
local s = stripfile("src/" .. fn)
writefile(out, fn, s)
end
- out:write("\t0\n};\n");
+ out:write("\t0\n};\n");
out:close()
+ print(string.format("Lua scripts trimmed down to %2.1f%% of original size (%d/%d)", (trim_sum / raw_sum) * 100, trim_sum, raw_sum))
end