Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ Scratchpad.txt
Unix Worksheet.worksheet
project.bbprojectdata
Premake4.tmproj

.git
.git/**
41 changes: 19 additions & 22 deletions scripts/embed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,29 @@
-- issues in Mac OS X Universal builds.
--

local function stripfile(fname)
local f = io.open(fname)
local s = assert(f:read("*a"))
f:close()

-- strip tabs
s = s:gsub("[\t]", "")
local raw_sum = 0
local trim_sum = 0

local function stripfile(fname)
dofile("scripts/luasrcdiet/LuaSrcDiet.lua")
-- Let LuaSrcDiet do its job
local s,l = get_slim_luasrc(fname)
-- Now do some cleanup so we can write these out as C strings
-- strip any CRs
s = s:gsub("[\r]", "")

-- strip out block comments
s = s:gsub("[^\"']%-%-%[%[.-%]%]", "")
s = s:gsub("[^\"']%-%-%[=%[.-%]=%]", "")
s = s:gsub("[^\"']%-%-%[==%[.-%]==%]", "")

-- strip out inline comments
s = s:gsub("\n%-%-[^\n]*", "\n")
-- overall counters
raw_sum = raw_sum + l:len()
trim_sum = trim_sum + s:len()

-- escape backslashes
s = s:gsub("\\", "\\\\")

-- strip duplicate line feeds
s = s:gsub("\n+", "\n")

-- strip out leading comments
s = s:gsub("^%-%-[^\n]*\n", "")

-- escape line feeds
s = s:gsub("\n", "\\n")

-- escape double quote marks
s = s:gsub("\"", "\\\"")

return s
end

Expand Down Expand Up @@ -77,6 +66,9 @@


function doembed()
raw_sum = 0
trim_sum = 0
fnames = "const char* builtin_script_fnames[] = {"
-- load the manifest of script files
scripts = dofile("src/_manifest.lua")

Expand All @@ -93,9 +85,14 @@
for i,fn in ipairs(scripts) do
print(fn)
local s = stripfile("src/" .. fn)
fnames = fnames .. "\n" .. "\t\"@" .. fn .. "\","
writefile(out, fn, s)
end

out:write("\t0\n};\n");
out:write("\t0\n};\n\n");
out:write(fnames);
out:write("\n\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
45 changes: 45 additions & 0 deletions scripts/luasrcdiet/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
LuaSrcDiet License
------------------

LuaSrcDiet is licensed under the terms of the MIT license reproduced
below. This means that LuaSrcDiet is free software and can be used for
both academic and commercial purposes at absolutely no cost.

Think of LuaSrcDiet as a compiler or a text filter; whatever that is
processed by LuaSrcDiet is not affected by its license. It does not add
anything new into your source code; it only transforms code that already
exist.

Hence, there is no need to tag this license onto Lua programs that are
only processed. Given the liberal terms of this kind of license, the
primary purpose is just to claim authorship of LuaSrcDiet.

Parts of LuaSrcDiet is based on Lua 5 code. See the file COPYRIGHT_Lua51
(Lua 5.1.4) for Lua 5's license.

===============================================================================

Copyright (C) 2005-2008,2011 Kein-Hong Man <keinhong@gmail.com>
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

===============================================================================

(end of COPYRIGHT)
34 changes: 34 additions & 0 deletions scripts/luasrcdiet/COPYRIGHT_Lua51
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Lua License
-----------

Lua is licensed under the terms of the MIT license reproduced below.
This means that Lua is free software and can be used for both academic
and commercial purposes at absolutely no cost.

For details and rationale, see http://www.lua.org/license.html .

===============================================================================

Copyright (C) 1994-2008 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

===============================================================================

(end of COPYRIGHT)
Loading