Fix execute bit on Unix-likes.
This commit is contained in:
parent
85ef3f07f5
commit
dfbc283fed
@ -102,6 +102,19 @@ static int raylua_builder_new(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int raylua_builder_set_executable(lua_State *L)
|
||||
{
|
||||
const char *path = luaL_checkstring(L, -1);
|
||||
printf("BUILDER: Sets '%s' executable.\n", path);
|
||||
|
||||
#ifndef WIN32
|
||||
/* On Windows, there is no need to set a executable flag. */
|
||||
chmod(path, 0777); /* rwx */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int raylua_builder_close(lua_State *L)
|
||||
{
|
||||
raylua_builder *builder = lua_touserdata(L, -1);
|
||||
@ -193,6 +206,9 @@ int raylua_builder_boot(lua_State *L)
|
||||
lua_pushcfunction(L, raylua_builder_add);
|
||||
lua_setglobal(L, "builder_add");
|
||||
|
||||
lua_pushcfunction(L, raylua_builder_set_executable);
|
||||
lua_setglobal(L, "set_executable");
|
||||
|
||||
if (luaL_dostring(L, raylua_builder_lua))
|
||||
fputs(luaL_checkstring(L, -1), stderr);
|
||||
|
||||
|
@ -67,6 +67,8 @@ end
|
||||
print("BUILDER: Self is " .. self_path)
|
||||
|
||||
if t == "directory" then
|
||||
print "BUILDER: Building from folder."
|
||||
|
||||
local output = arg[2]
|
||||
|
||||
if not output then
|
||||
@ -75,7 +77,7 @@ if t == "directory" then
|
||||
if ffi.os == "Windows" then
|
||||
output = input_path .. ".exe"
|
||||
else
|
||||
output = input_path .. ".elf"
|
||||
output = input_path .. "_out"
|
||||
end
|
||||
end
|
||||
|
||||
@ -125,6 +127,7 @@ if t == "directory" then
|
||||
end
|
||||
|
||||
builder_close(builder)
|
||||
set_executable(output)
|
||||
elseif t == "file" then
|
||||
local ext = input_path:sub(-4)
|
||||
|
||||
@ -134,7 +137,7 @@ elseif t == "file" then
|
||||
if ffi.os == "Windows" then
|
||||
path = path .. ".exe"
|
||||
else
|
||||
path = path .. ".elf"
|
||||
path = path .. "_out"
|
||||
end
|
||||
|
||||
print("BUILDER: Building " .. path)
|
||||
@ -157,7 +160,11 @@ elseif t == "file" then
|
||||
local builder = builder_new(self_path, path)
|
||||
builder_add(builder, input_path, "main.lua")
|
||||
builder_close(builder)
|
||||
else
|
||||
error "Unknown file type."
|
||||
end
|
||||
|
||||
set_executable(path)
|
||||
end
|
||||
|
||||
print "BUILDER: Done"
|
||||
|
Loading…
Reference in New Issue
Block a user