premake/scripts/release.lua

214 lines
4.5 KiB
Lua
Raw Normal View History

2009-07-16 15:20:15 +00:00
--
-- Prepare a new Premake release. This is still incomplete and some manual
-- work is needed to get everything packaged up. See RELEASE.txt in this
-- folder for the full checklist.
--
2010-08-11 18:33:14 +00:00
-- Info on using Mercurial to manage releases:
-- http://hgbook.red-bean.com/read/managing-releases-and-branchy-development.html
-- http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
--
2009-07-16 15:20:15 +00:00
2009-12-09 21:03:29 +00:00
2009-07-16 15:20:15 +00:00
function dorelease()
2009-12-05 18:00:46 +00:00
local z
2009-12-09 21:03:29 +00:00
--
2009-12-09 21:03:29 +00:00
-- Helper function: runs a command (formatted, with optional arguments) and
-- suppresses any output. Works on both Windows and POSIX. Might be a good
-- candidate for a core function.
--
local function exec(cmd, ...)
cmd = string.format(cmd, unpack(arg))
local z = os.execute(cmd .. " > output.log 2> error.log")
os.remove("output.log")
os.remove("error.log")
return z
end
2009-07-16 15:20:15 +00:00
--
-- Make sure a version was specified
--
2009-12-09 21:03:29 +00:00
if #_ARGS ~= 2 then
error("** Usage: release [version] [source | binary]", 0)
2009-07-16 15:20:15 +00:00
end
2009-12-09 21:03:29 +00:00
local version = _ARGS[1]
local kind = _ARGS[2]
2010-11-03 00:17:01 +00:00
local pkgname = "premake-" .. version
2009-12-09 21:03:29 +00:00
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
-- Look for required utilities
2009-07-16 15:20:15 +00:00
--
2011-05-09 19:42:11 +00:00
local required = { "hg", "make", "gcc" }
2009-12-09 21:03:29 +00:00
for _, value in ipairs(required) do
z = exec("%s --version", value)
2009-12-05 18:00:46 +00:00
if z ~= 0 then
2009-12-09 21:03:29 +00:00
error("** '" .. value .. "' not found", 0)
2009-12-05 18:00:46 +00:00
end
end
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
-- Pre-release checklist
2009-07-16 15:20:15 +00:00
--
2010-11-03 00:17:01 +00:00
print( "")
print( "BEFORE RUNNING THIS SCRIPT follow the checklist in RELEASE.txt" )
2010-11-03 00:17:01 +00:00
print( "")
print( "Press [Enter] to begin.")
2011-08-19 12:58:23 +00:00
io.read()
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
2010-08-11 18:33:14 +00:00
---------------------------------------------------------------------------
2009-12-05 18:00:46 +00:00
--
2010-08-11 18:33:14 +00:00
-- Everything below this needs to be reworked for Mercurial
2009-07-16 15:20:15 +00:00
--
2010-08-11 18:33:14 +00:00
---------------------------------------------------------------------------
2009-07-16 15:20:15 +00:00
--
2010-08-11 18:33:14 +00:00
-- Check out the release tagged sources to releases/
2009-07-16 15:20:15 +00:00
--
2010-08-11 18:33:14 +00:00
print("Downloading release tag...")
2010-11-03 00:17:01 +00:00
os.mkdir("release")
os.chdir("release")
2010-11-03 00:17:01 +00:00
os.rmdir(pkgname)
2011-05-09 19:42:11 +00:00
z = exec( "hg clone -r %s .. %s", version, pkgname)
2010-11-03 00:17:01 +00:00
if z ~= 0 then
error("** Failed to download tagged sources", 0)
end
2010-11-03 00:17:01 +00:00
os.chdir(pkgname)
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
-- Update the version number in premake.c
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
print("Updating version number...")
2009-12-09 21:03:29 +00:00
2010-08-11 18:33:14 +00:00
io.input("src/host/premake.c")
local text = io.read("*a")
text = text:gsub("HEAD", version)
io.output("src/host/premake.c")
io.write(text)
io.close()
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
-- Make absolutely sure the embedded scripts have been updated
2009-07-16 15:20:15 +00:00
--
2009-12-05 18:00:46 +00:00
print("Updating embedded scripts...")
2009-07-16 15:20:15 +00:00
z = exec("premake5 embed")
2009-12-05 18:00:46 +00:00
if z ~= 0 then
2009-12-09 21:03:29 +00:00
error("** Failed to update the embedded scripts", 0)
2009-12-05 18:00:46 +00:00
end
2009-07-16 15:20:15 +00:00
--
2009-12-09 21:03:29 +00:00
-- Generate source packaging
2009-07-16 15:20:15 +00:00
--
2009-12-09 21:03:29 +00:00
if kind == "source" then
2009-12-05 18:00:46 +00:00
--
2009-12-09 21:03:29 +00:00
-- Remove extra directories
2009-12-05 18:00:46 +00:00
--
print("Cleaning up the source tree...")
2009-12-09 21:03:29 +00:00
os.rmdir("samples")
os.rmdir("packages")
2010-08-11 18:33:14 +00:00
os.rmdir(".hg")
os.rmdir(".hgignore")
os.rmdir(".hgtags")
2009-12-05 18:00:46 +00:00
2009-12-05 18:00:46 +00:00
--
-- Generate project files to the build directory
--
print("Generating project files...")
exec("premake5 /to=build/vs2005 vs2005")
exec("premake5 /to=build/vs2008 vs2008")
exec("premake5 /to=build/vs2010 vs2010")
exec("premake5 /to=build/gmake.windows /os=windows gmake")
exec("premake5 /to=build/gmake.unix /os=linux gmake")
exec("premake5 /to=build/gmake.macosx /os=macosx /platform=universal32 gmake")
exec("premake5 /to=build/codeblocks.windows /os=windows codeblocks")
exec("premake5 /to=build/codeblocks.unix /os=linux codeblocks")
exec("premake5 /to=build/codeblocks.macosx /os=macosx /platform=universal32 codeblocks")
exec("premake5 /to=build/codelite.windows /os=windows codelite")
exec("premake5 /to=build/codelite.unix /os=linux codelite")
exec("premake5 /to=build/codelite.macosx /os=macosx /platform=universal32 codelite")
exec("premake5 /to=build/xcode3 /platform=universal32 xcode3")
2009-12-09 21:03:29 +00:00
2009-12-05 18:00:46 +00:00
--
-- Create source package
--
print("Creating source code package...")
2009-07-16 15:42:50 +00:00
2009-12-09 21:03:29 +00:00
os.chdir("..")
2010-11-03 00:17:01 +00:00
exec("zip -r9 %s-src.zip %s/*", pkgname, pkgname)
2009-07-16 15:20:15 +00:00
--
-- Create a binary package for this platform. This step requires a working
-- GNU/Make/GCC environment. I use MinGW on Windows.
--
else
2009-12-09 21:03:29 +00:00
print("Building platform binary release...")
exec("premake5 /platform=universal32 gmake")
2009-12-09 21:03:29 +00:00
exec("make config=%s", iif(os.is("macosx"), "releaseuniv32", "release"))
local fname
os.chdir("bin/release")
if os.is("windows") then
2010-11-03 00:17:01 +00:00
fname = string.format("%s-windows.zip", pkgname)
exec("zip -9 %s premake5.exe", fname)
2009-12-09 21:03:29 +00:00
else
2010-11-03 00:17:01 +00:00
fname = string.format("%s-%s.tar.gz", pkgname, os.get())
exec("tar czvf %s premake5", fname)
2009-12-09 21:03:29 +00:00
end
os.copyfile(fname, "../../../" .. fname)
os.chdir("../../..")
2009-07-16 15:20:15 +00:00
end
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
--
-- Upload files to SourceForge
--
2009-12-09 21:03:29 +00:00
2009-07-16 15:20:15 +00:00
2009-12-05 18:00:46 +00:00
--
-- Clean up
--
os.rmdir(pkgname)
2009-12-05 18:00:46 +00:00
print("")
2010-11-03 00:17:01 +00:00
print( "Finished.")
2009-12-05 18:00:46 +00:00
2009-07-16 15:20:15 +00:00
end