2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
-- Premake 4.x build configuration script
|
|
|
|
--
|
|
|
|
|
2008-11-13 00:54:41 +00:00
|
|
|
if (_ACTION == "vs2002" or _ACTION == "vs2003") then
|
|
|
|
error(
|
|
|
|
"\nBecause of compiler limitations, Visual Studio 2002 and 2003 aren't able to\n" ..
|
|
|
|
"build this version of Premake. Use the free Visual Studio Express instead.", 0)
|
|
|
|
end
|
|
|
|
|
2008-06-17 18:45:11 +00:00
|
|
|
|
2008-12-27 13:34:58 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Use the --to=path option to control where the project files get generated. I use
|
|
|
|
-- this to create project files for each supported toolset, each in their own folder,
|
|
|
|
-- in preparation for deployment.
|
|
|
|
--
|
|
|
|
|
|
|
|
newoption {
|
|
|
|
trigger = "to",
|
|
|
|
value = "path",
|
|
|
|
description = "Set the output location for the generated files"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-12-27 13:33:10 +00:00
|
|
|
--
|
2008-12-27 13:34:58 +00:00
|
|
|
-- Define the project. Put the release configuration first so it will be the
|
|
|
|
-- default when folks build using the makefile. That way they don't have to
|
|
|
|
-- worry about the /scripts argument and all that.
|
2008-12-27 13:33:10 +00:00
|
|
|
--
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2008-12-27 13:33:10 +00:00
|
|
|
solution "Premake4"
|
|
|
|
configurations { "Release", "Debug" }
|
2008-12-27 13:34:58 +00:00
|
|
|
location ( _OPTIONS["to"] )
|
2008-12-27 13:33:10 +00:00
|
|
|
|
|
|
|
project "Premake4"
|
|
|
|
targetname "premake4"
|
|
|
|
language "C"
|
|
|
|
kind "ConsoleApp"
|
2009-01-04 16:09:14 +00:00
|
|
|
flags { "No64BitChecks", "ExtraWarnings" }
|
2008-12-30 01:15:38 +00:00
|
|
|
includedirs { "src/host/lua-5.1.4/src" }
|
2008-12-27 13:34:58 +00:00
|
|
|
location ( _OPTIONS["to"] )
|
2008-12-27 13:33:10 +00:00
|
|
|
|
|
|
|
files
|
|
|
|
{
|
2009-04-24 13:40:28 +00:00
|
|
|
"src/**.h", "src/**.c", "src/**.lua",
|
2008-12-27 13:33:10 +00:00
|
|
|
"tests/**.lua"
|
|
|
|
}
|
|
|
|
|
|
|
|
excludes
|
|
|
|
{
|
|
|
|
"src/premake.lua",
|
2008-12-30 01:15:38 +00:00
|
|
|
"src/host/lua-5.1.4/src/lua.c",
|
|
|
|
"src/host/lua-5.1.4/src/luac.c",
|
|
|
|
"src/host/lua-5.1.4/src/print.c",
|
|
|
|
"src/host/lua-5.1.4/**.lua",
|
|
|
|
"src/host/lua-5.1.4/etc/*.c"
|
2008-12-27 13:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
configuration "Debug"
|
|
|
|
targetdir "bin/debug"
|
|
|
|
defines "_DEBUG"
|
|
|
|
flags { "Symbols" }
|
|
|
|
|
|
|
|
configuration "Release"
|
|
|
|
targetdir "bin/release"
|
|
|
|
defines "NDEBUG"
|
2009-01-13 19:33:21 +00:00
|
|
|
flags { "OptimizeSize" }
|
2008-12-27 13:33:10 +00:00
|
|
|
|
|
|
|
configuration "vs*"
|
|
|
|
defines { "_CRT_SECURE_NO_WARNINGS" }
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2008-12-30 01:58:19 +00:00
|
|
|
configuration "linux"
|
2009-01-11 21:50:11 +00:00
|
|
|
defines { "LUA_USE_LINUX" }
|
|
|
|
links { "m", "dl" }
|
|
|
|
|
|
|
|
configuration "macosx"
|
|
|
|
defines { "LUA_USE_MACOSX" }
|
2008-10-31 18:38:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2008-12-27 13:34:58 +00:00
|
|
|
-- A more thorough cleanup.
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
2008-12-27 13:33:10 +00:00
|
|
|
|
2008-12-27 13:34:58 +00:00
|
|
|
if _ACTION == "clean" then
|
|
|
|
os.rmdir("bin")
|
|
|
|
os.rmdir("build")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2009-01-19 01:45:47 +00:00
|
|
|
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
2009-01-19 01:45:47 +00:00
|
|
|
-- Embed the Lua scripts into src/host/scripts.c as static data buffers.
|
|
|
|
-- I embed the actual scripts, rather than Lua bytecodes, because the
|
|
|
|
-- bytecodes are not portable to different architectures.
|
2008-10-31 18:38:05 +00:00
|
|
|
--
|
|
|
|
|
2009-06-15 18:36:09 +00:00
|
|
|
local function embedfile(out, fname)
|
2008-10-31 18:38:05 +00:00
|
|
|
local f = io.open(fname)
|
2009-01-19 01:45:47 +00:00
|
|
|
local s = f:read("*a")
|
2008-10-31 18:38:05 +00:00
|
|
|
f:close()
|
|
|
|
|
2009-06-15 18:36:09 +00:00
|
|
|
-- strip tabs
|
|
|
|
s = s:gsub("[\t]", "")
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2009-01-19 01:45:47 +00:00
|
|
|
-- strip any CRs
|
|
|
|
s = s:gsub("[\r]", "")
|
2008-10-31 18:38:05 +00:00
|
|
|
|
2009-06-15 18:36:09 +00:00
|
|
|
-- strip out comments
|
|
|
|
s = s:gsub("\n%-%-[^\n]*", "")
|
|
|
|
|
2009-01-19 01:45:47 +00:00
|
|
|
-- escape backslashes
|
|
|
|
s = s:gsub("\\", "\\\\")
|
2009-01-19 16:56:40 +00:00
|
|
|
|
2009-06-15 18:36:09 +00:00
|
|
|
-- strip duplicate line feeds
|
|
|
|
s = s:gsub("\n+", "\n")
|
|
|
|
|
|
|
|
-- strip out leading comments
|
|
|
|
s = s:gsub("^%-%-\n", "")
|
|
|
|
|
2009-01-19 01:45:47 +00:00
|
|
|
-- escape line feeds
|
|
|
|
s = s:gsub("\n", "\\n")
|
|
|
|
|
|
|
|
-- escape double quote marks
|
|
|
|
s = s:gsub("\"", "\\\"")
|
2009-01-19 16:56:40 +00:00
|
|
|
|
2009-01-19 01:45:47 +00:00
|
|
|
out:write("\t\"")
|
|
|
|
out:write(s)
|
|
|
|
out:write("\",\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
premake.actions["embed"] = {
|
|
|
|
description = "Embed scripts in scripts.c; required before release builds",
|
|
|
|
execute = function ()
|
|
|
|
-- load the manifest of script files
|
2009-04-23 22:55:10 +00:00
|
|
|
scripts = dofile("src/_manifest.lua")
|
2009-01-19 01:45:47 +00:00
|
|
|
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("/* 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()
|
|
|
|
end
|
2008-10-31 18:38:05 +00:00
|
|
|
}
|