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-01-10 06:44:56 +0400
committerOliver Schneider <oliver@assarbad.net>2014-01-10 06:44:56 +0400
commitfde372c6d3935334ffe3596821ed2ef5dda6b2b9 (patch)
tree19a7911c8477cc0c821c9a2dce24abdc05e6c253 /scripts
parent15523cfc399dcb4dd87cdf78bb554094de04a58c (diff)
Adjusting LuaSrcDiet so we can use dofile() and call it, returning the trimmed down source
--HG-- branch : WDS-build
Diffstat (limited to 'scripts')
-rw-r--r--scripts/embed.lua32
-rw-r--r--scripts/luasrcdiet/LuaSrcDiet.lua19
2 files changed, 22 insertions, 29 deletions
diff --git a/scripts/embed.lua b/scripts/embed.lua
index 94b7cbf..f80a3cb 100644
--- a/scripts/embed.lua
+++ b/scripts/embed.lua
@@ -6,34 +6,10 @@
--
local function stripfile(fname)
- local f = io.open(fname)
- local s = assert(f:read("*a"))
- f:close()
-
- -- strip tabs
- s = s:gsub("[\t]", "")
-
- -- strip any CRs
- s = s:gsub("[\r]", "")
-
- -- strip out comments
- s = s:gsub("\n%-%-[^\n]*", "")
-
- -- escape backslashes
- s = s:gsub("\\", "\\\\")
-
- -- strip duplicate line feeds
- s = s:gsub("\n+", "\n")
-
- -- strip out leading comments
- s = s:gsub("^%-%-\n", "")
-
- -- escape line feeds
- s = s:gsub("\n", "\\n")
-
- -- escape double quote marks
- s = s:gsub("\"", "\\\"")
-
+ dofile("scripts/luasrcdiet/LuaSrcDiet.lua")
+ -- Now simply return the file contents after LuaSrcDiet did its job
+ local s,l = get_slim_luasrc(fname)
+ print("\ttrimmed size: ", s:len(), " down from: ", l:len())
return s
end
diff --git a/scripts/luasrcdiet/LuaSrcDiet.lua b/scripts/luasrcdiet/LuaSrcDiet.lua
index c87cee2..4feed22 100644
--- a/scripts/luasrcdiet/LuaSrcDiet.lua
+++ b/scripts/luasrcdiet/LuaSrcDiet.lua
@@ -4097,6 +4097,8 @@ local EOLTYPES = { -- EOL names for token dump
------------------------------------------------------------------------
-- read source code from file
------------------------------------------------------------------------
+local loaded_file_contents = ""
+local saved_file_contents = ""
local function load_file(fname)
local INF = io.open(fname, "rb")
@@ -4104,6 +4106,7 @@ local function load_file(fname)
local dat = INF:read("*a")
if not dat then die('cannot read from "'..fname..'"') end
INF:close()
+ loaded_file_contents = dat
return dat
end
@@ -4112,11 +4115,14 @@ end
------------------------------------------------------------------------
local function save_file(fname, dat)
+ saved_file_contents = dat
+--[[
local OUTF = io.open(fname, "wb")
if not OUTF then die('cannot open "'..fname..'" for writing') end
local status = OUTF:write(dat)
if not status then die('cannot write to "'..fname..'"') end
OUTF:close()
+ ]]
end
------------------------------------------------------------------------
@@ -4457,6 +4463,7 @@ end
-- main functions
----------------------------------------------------------------------]]
+--[[
local arg = {...} -- program arguments
local fspec = {}
set_options(DEFAULT_CONFIG) -- set to default options at beginning
@@ -4594,5 +4601,15 @@ end
if not main() then
die("Please run with option -h or --help for usage information")
end
-
+]]
-- end of script
+
+-- Start of premake4 customizations
+function get_slim_luasrc(fname)
+ set_options(DEFAULT_CONFIG)
+ set_options(MAXIMUM_CONFIG)
+ option.OUTPUT_FILE = "-"
+ option.QUIET = true
+ process_file(fname, "-")
+ return saved_file_contents or "", loaded_file_contents
+end