2015-02-23 00:02:09 +00:00
|
|
|
---
|
|
|
|
-- Create a source or binary release package.
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
-- Helper function: run a command while hiding its output.
|
|
|
|
---
|
|
|
|
|
|
|
|
local function execQuiet(cmd, ...)
|
2015-03-24 23:15:39 +00:00
|
|
|
cmd = string.format(cmd, ...) .. " > _output_.log 2> _error_.log"
|
2015-02-23 00:02:09 +00:00
|
|
|
local z = os.execute(cmd)
|
|
|
|
os.remove("_output_.log")
|
|
|
|
os.remove("_error_.log")
|
|
|
|
return z
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
-- Check the command line arguments, and show some help if needed.
|
|
|
|
---
|
|
|
|
|
|
|
|
local usage = 'usage is: package <branch> <type>\n' ..
|
|
|
|
' <branch> is the name of the release branch to target\n' ..
|
|
|
|
' <type> is one of "source" or "binary"\n'
|
|
|
|
|
|
|
|
if #_ARGS ~= 2 then
|
|
|
|
error(usage, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
local branch = _ARGS[1]
|
|
|
|
local kind = _ARGS[2]
|
|
|
|
|
|
|
|
if kind ~= "source" and kind ~= "binary" then
|
|
|
|
error(usage, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Make sure I've got what I've need to be happy.
|
|
|
|
--
|
|
|
|
|
2015-04-27 21:32:59 +00:00
|
|
|
local required = { "git", "make", "gcc", "premake5", "zip" }
|
2015-02-23 00:02:09 +00:00
|
|
|
for _, value in ipairs(required) do
|
|
|
|
local z = execQuiet("%s --version", value)
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2015-02-23 00:02:09 +00:00
|
|
|
error("required tool '" .. value .. "' not found", 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Figure out what I'm making.
|
|
|
|
--
|
|
|
|
|
2015-02-23 22:34:16 +00:00
|
|
|
os.chdir("..")
|
2016-06-06 22:41:14 +00:00
|
|
|
local text = os.outputof(string.format('git show %s:src/host/premake.h', branch))
|
2015-02-23 00:02:09 +00:00
|
|
|
local _, _, version = text:find('VERSION%s*"([%w%p]+)"')
|
|
|
|
|
|
|
|
local pkgName = "premake-" .. version
|
|
|
|
local pkgExt = ".zip"
|
|
|
|
|
2017-04-11 20:39:25 +00:00
|
|
|
if not os.istarget("windows") and kind == "binary" then
|
2015-02-23 00:02:09 +00:00
|
|
|
pkgExt = ".tar.gz"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Make sure I'm sure.
|
|
|
|
--
|
|
|
|
|
|
|
|
printf("")
|
|
|
|
printf("I am about to create a %s package", kind:upper())
|
|
|
|
printf(" ...named release/%s%s", pkgName, pkgExt)
|
|
|
|
printf(" ...from the %s branch", branch)
|
|
|
|
printf("")
|
|
|
|
printf("Does this look right to you? If so, press [Enter] to begin.")
|
|
|
|
io.read()
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Pull down the release branch.
|
|
|
|
--
|
|
|
|
|
|
|
|
print("Preparing release folder")
|
|
|
|
os.mkdir("release")
|
|
|
|
os.chdir("release")
|
|
|
|
os.rmdir(pkgName)
|
|
|
|
|
|
|
|
print("Cloning source code")
|
2015-04-27 21:32:59 +00:00
|
|
|
z = os.executef("git clone .. %s", pkgName)
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2015-02-23 00:02:09 +00:00
|
|
|
error("clone failed", 0)
|
|
|
|
end
|
|
|
|
|
2015-04-27 21:32:59 +00:00
|
|
|
os.chdir(pkgName)
|
|
|
|
|
|
|
|
z = os.executef("git checkout %s", branch)
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2015-04-27 21:32:59 +00:00
|
|
|
error("unable to checkout branch " .. branch, 0)
|
|
|
|
end
|
|
|
|
|
2015-05-03 22:56:29 +00:00
|
|
|
z = os.executef("git submodule update --init")
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2015-05-03 22:56:29 +00:00
|
|
|
error("unable to clone submodules", 0)
|
|
|
|
end
|
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Make absolutely sure the embedded scripts have been updated
|
|
|
|
--
|
|
|
|
|
|
|
|
print("Updating embedded scripts...")
|
2016-02-15 00:05:40 +00:00
|
|
|
if kind == "source" then
|
|
|
|
z = execQuiet("premake5 embed")
|
|
|
|
else
|
|
|
|
z = execQuiet("premake5 --bytecode embed")
|
|
|
|
end
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2015-02-23 00:02:09 +00:00
|
|
|
error("failed to update the embedded scripts", 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2015-02-23 22:34:16 +00:00
|
|
|
-- Clear out files I don't want included in any packages.
|
2015-02-23 00:02:09 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
print("Cleaning up the source tree...")
|
|
|
|
os.rmdir("packages")
|
2017-04-20 16:37:31 +00:00
|
|
|
os.rmdir(".git")
|
2015-02-23 00:02:09 +00:00
|
|
|
|
2017-04-20 16:37:31 +00:00
|
|
|
local removelist = { ".DS_Store", ".git", ".gitignore", ".gitmodules", ".travis.yml", ".editorconfig", "appveyor.yml", "Bootstrap.mak" }
|
|
|
|
for _, removeitem in ipairs(removelist) do
|
|
|
|
local founditems = os.matchfiles("**" .. removeitem)
|
|
|
|
for _, item in ipairs(founditems) do
|
|
|
|
os.remove(item)
|
2015-02-23 00:02:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-23 22:34:16 +00:00
|
|
|
--
|
|
|
|
-- Generate a source package.
|
|
|
|
--
|
|
|
|
|
|
|
|
if kind == "source" then
|
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
print("Generating project files...")
|
|
|
|
execQuiet("premake5 /to=build/vs2005 vs2005")
|
|
|
|
execQuiet("premake5 /to=build/vs2008 vs2008")
|
|
|
|
execQuiet("premake5 /to=build/vs2010 vs2010")
|
|
|
|
execQuiet("premake5 /to=build/vs2012 vs2012")
|
|
|
|
execQuiet("premake5 /to=build/vs2013 vs2013")
|
2016-08-08 10:10:51 +00:00
|
|
|
execQuiet("premake5 /to=build/vs2015 vs2015")
|
2017-04-20 16:37:31 +00:00
|
|
|
execQuiet("premake5 /to=build/vs2017 vs2017")
|
2015-02-23 00:02:09 +00:00
|
|
|
execQuiet("premake5 /to=build/gmake.windows /os=windows gmake")
|
|
|
|
execQuiet("premake5 /to=build/gmake.unix /os=linux gmake")
|
|
|
|
execQuiet("premake5 /to=build/gmake.macosx /os=macosx gmake")
|
2017-04-20 16:37:31 +00:00
|
|
|
execQuiet("premake5 /to=build/gmake.bsd /os=bsd gmake")
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
print("Creating source code package...")
|
|
|
|
os.chdir("..")
|
|
|
|
execQuiet("zip -r9 %s-src.zip %s/*", pkgName, pkgName)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Create a binary package for this platform. This step requires a working
|
|
|
|
-- GNU/Make/GCC environment. I use MinGW on Windows as it produces the
|
|
|
|
-- smallest binaries.
|
|
|
|
--
|
|
|
|
|
|
|
|
if kind == "binary" then
|
|
|
|
|
|
|
|
print("Building binary...")
|
|
|
|
execQuiet("premake5 gmake")
|
|
|
|
z = execQuiet("make config=release")
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2015-02-23 00:02:09 +00:00
|
|
|
error("build failed")
|
|
|
|
end
|
|
|
|
|
|
|
|
os.chdir("bin/release")
|
|
|
|
|
2017-04-11 21:41:07 +00:00
|
|
|
local name = string.format("%s-%s%s", pkgName, os.host(), pkgExt)
|
|
|
|
if os.ishost("windows") then
|
2015-02-23 00:02:09 +00:00
|
|
|
execQuiet("zip -9 %s premake5.exe", name)
|
|
|
|
else
|
|
|
|
execQuiet("tar czvf %s premake5", name)
|
|
|
|
end
|
|
|
|
|
|
|
|
os.copyfile(name, path.join("../../../", name))
|
|
|
|
os.chdir("../../..")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Clean up
|
|
|
|
--
|
|
|
|
|
|
|
|
os.rmdir(pkgName)
|