Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two bugs in embed action. #11

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 2 additions & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
trigger = "embed",
description = "Embed scripts in scripts.c; required before release builds",
execute = function ()
_MAIN_SCRIPT_DIR = os.getcwd()
_SCRIPT_DIR = path.join(_MAIN_SCRIPT_DIR, "scripts")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this help?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change, none of my lua scripts would get added to the embed... these two lines are in the premake4.lua script, but not in the premake5.lua script, so I copied them... made it work. Note that this may be because I was using a fairly 'old' premake5.exe to do the embedding... but I would argue that the embed process should remain as backwards compatible as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add those lines to premake4.lua because the 4.x code doesn't set those variables. Premake 5.x does, so these shouldn't be needed. You might want to try again without them, or provide more information about what's going wrong so we can figure out the right fix.

include (path.join(corePath, "scripts/embed.lua"))
end
}
Expand Down
28 changes: 16 additions & 12 deletions scripts/embed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,24 @@
local max = 4096
local start = 1
local len = contents:len()
while start <= len do
local n = len - start
if n > max then n = max end
local finish = start + n

-- make sure I don't cut an escape sequence
while contents:sub(finish, finish) == "\\" do
finish = finish - 1
end
if len > 0 then
while start <= len do
local n = len - start
if n > max then n = max end
local finish = start + n

-- make sure I don't cut an escape sequence
while contents:sub(finish, finish) == "\\" do
finish = finish - 1
end

local s = contents:sub(start, finish)
table.insert(result, "\t\"" .. s .. iif(finish < len, '"', '",'))
local s = contents:sub(start, finish)
table.insert(result, "\t\"" .. s .. iif(finish < len, '"', '",'))

start = finish + 1
start = finish + 1
end
else
table.insert(result, "\t\"\",")
end

table.insert(result, "")
Expand Down