Merge branch 'switch-bytecode-flag' into release-alpha8

This commit is contained in:
Jason Perkins 2016-02-16 18:56:43 -05:00
commit 0c655706eb
5 changed files with 23 additions and 11 deletions

View File

@ -74,8 +74,8 @@
} }
newoption { newoption {
trigger = "no-bytecode", trigger = "bytecode",
description = "Don't embed bytecode, but instead use the stripped souce code." description = "Embed scripts as bytecode instead of stripped souce code"
} }
-- --

View File

@ -1,8 +1,8 @@
-- --
-- Embed the Lua scripts into src/host/scripts.c as static data buffers. -- Embed the Lua scripts into src/host/scripts.c as static data buffers.
-- I embed the actual scripts, rather than Lua bytecodes, because the -- Embeds minified versions of the actual scripts by default, rather than
-- bytecodes are not portable to different architectures, which causes -- bytecode, as bytecodes are not portable to different architectures. Use
-- issues in Mac OS X Universal builds. -- the `--bytecode` flag to override.
-- --
local scriptCount = 0 local scriptCount = 0
@ -67,7 +67,7 @@
local function addScript(result, filename, name, data) local function addScript(result, filename, name, data)
if not data then if not data then
if not _OPTIONS["no-bytecode"] then if _OPTIONS["bytecode"] then
verbosef("Compiling... " .. filename) verbosef("Compiling... " .. filename)
local output = path.replaceextension(filename, ".luac") local output = path.replaceextension(filename, ".luac")
local res, err = os.compile(filename, output); local res, err = os.compile(filename, output);

View File

@ -111,7 +111,11 @@
-- --
print("Updating embedded scripts...") print("Updating embedded scripts...")
z = execQuiet("premake5 embed") if kind == "source" then
z = execQuiet("premake5 embed")
else
z = execQuiet("premake5 --bytecode embed")
end
if z ~= 0 then if z ~= 0 then
error("failed to update the embedded scripts", 0) error("failed to update the embedded scripts", 0)
end end

View File

@ -118,6 +118,8 @@
function p.project.bake(self) function p.project.bake(self)
verbosef(' Baking %s...', self.name)
self.solution = self.workspace self.solution = self.workspace
local wks = self.workspace local wks = self.workspace

View File

@ -19,12 +19,18 @@ int os_isfile(lua_State* L)
int do_isfile(const char* filename) int do_isfile(const char* filename)
{ {
struct stat buf; struct stat buf;
#if PLATFORM_WINDOWS
DWORD attrib = GetFileAttributesA(filename);
if (attrib != INVALID_FILE_ATTRIBUTES)
{
return (attrib & FILE_ATTRIBUTE_DIRECTORY) == 0;
}
#else
if (stat(filename, &buf) == 0) if (stat(filename, &buf) == 0)
{ {
return ((buf.st_mode & S_IFDIR) == 0); return ((buf.st_mode & S_IFDIR) == 0);
} }
else #endif
{
return 0; return 0;
}
} }