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:
authorstarkos <none@none>2010-01-07 18:36:03 +0300
committerstarkos <none@none>2010-01-07 18:36:03 +0300
commit6a97bbd0b4c66bda54431a7246eb17162754fc33 (patch)
treedcc133ec7ab666c49dc452bbc192bea08d491013 /scripts
parent0b9764c245bcf5e24afc139088f0dbd4b1301a2d (diff)
Bug 2927604: Unable to build Premake with Visual Studio
Diffstat (limited to 'scripts')
-rw-r--r--scripts/embed.lua65
1 files changed, 46 insertions, 19 deletions
diff --git a/scripts/embed.lua b/scripts/embed.lua
index d84ca33..ddb5ba4 100644
--- a/scripts/embed.lua
+++ b/scripts/embed.lua
@@ -5,7 +5,7 @@
-- issues in Mac OS X Universal builds.
--
- local function embedfile(out, fname)
+ local function stripfile(fname)
local f = io.open(fname)
local s = f:read("*a")
f:close()
@@ -34,29 +34,56 @@
-- escape double quote marks
s = s:gsub("\"", "\\\"")
+ return s
+ end
+
+
+ local function writeline(out, s)
out:write("\t\"")
out:write(s)
out:write("\",\n")
end
+
+
+ local function writefile(out, fname, contents)
+ -- cut smaller than max, so I don't wind up with tiny strings at end of files
+ local cut = 8192
+ local max = 9216
+
+ -- break up large strings to fit in Visual Studio's string length limit
+ local start = 1
+ local len = contents:len()
+ while start <= len do
+ local n = len - start
+ if n > max then n = cut end
+ writeline(out, contents:sub(start, start + n))
+ start = start + n + 1
+ end
+
+ writeline(out, "EOF:" .. fname)
+ end
function doembed()
- -- load the manifest of script files
- scripts = dofile("src/_manifest.lua")
- 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)
- s = embedfile(out, "src/"..fn)
- end
-
- out:write("\t0\n};\n");
- out:close()
+ -- 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:close()
end