diff --git a/src/raylua_builder.c b/src/raylua_builder.c index a3b7d99..1c56238 100644 --- a/src/raylua_builder.c +++ b/src/raylua_builder.c @@ -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); diff --git a/src/raylua_builder.lua b/src/raylua_builder.lua index 8e15316..ee27c80 100644 --- a/src/raylua_builder.lua +++ b/src/raylua_builder.lua @@ -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"