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.
|
|
|
|
---
|
|
|
|
|
2019-05-02 19:21:15 +00:00
|
|
|
local allowedCompilers = {}
|
|
|
|
|
|
|
|
if os.ishost("windows") then
|
|
|
|
allowedCompilers = {
|
|
|
|
"vs2019",
|
|
|
|
"vs2017",
|
|
|
|
"vs2015",
|
|
|
|
"vs2013",
|
|
|
|
"vs2012",
|
|
|
|
"vs2010",
|
|
|
|
"vs2008",
|
|
|
|
"vs2005",
|
|
|
|
}
|
|
|
|
elseif os.ishost("linux") or os.ishost("bsd") then
|
|
|
|
allowedCompilers = {
|
|
|
|
"gcc",
|
|
|
|
"clang",
|
|
|
|
}
|
|
|
|
elseif os.ishost("macosx") then
|
|
|
|
allowedCompilers = {
|
|
|
|
"clang",
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error("Unsupported host os", 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
local usage = 'usage is: package <branch> <type> [<compiler>]\n' ..
|
2015-02-23 00:02:09 +00:00
|
|
|
' <branch> is the name of the release branch to target\n' ..
|
2019-05-02 19:21:15 +00:00
|
|
|
' <type> is one of "source" or "binary"\n' ..
|
|
|
|
' <compiler> (default: ' .. allowedCompilers[1] .. ') is one of ' .. table.implode(allowedCompilers, "", "", " ")
|
2015-02-23 00:02:09 +00:00
|
|
|
|
2019-05-02 19:21:15 +00:00
|
|
|
if #_ARGS ~= 2 and #_ARGS ~= 3 then
|
2015-02-23 00:02:09 +00:00
|
|
|
error(usage, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
local branch = _ARGS[1]
|
|
|
|
local kind = _ARGS[2]
|
2019-05-02 19:21:15 +00:00
|
|
|
local compiler = _ARGS[3] or allowedCompilers[1]
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
if kind ~= "source" and kind ~= "binary" then
|
2019-05-02 19:21:15 +00:00
|
|
|
print("Invalid package kind: "..kind)
|
2015-02-23 00:02:09 +00:00
|
|
|
error(usage, 0)
|
|
|
|
end
|
|
|
|
|
2019-05-02 19:21:15 +00:00
|
|
|
if not table.contains(allowedCompilers, compiler) then
|
|
|
|
print("Invalid compiler: "..compiler)
|
|
|
|
error(usage, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
local compilerIsVS = compiler:startswith("vs")
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Make sure I've got what I've need to be happy.
|
|
|
|
--
|
|
|
|
|
2019-05-01 17:09:23 +00:00
|
|
|
local required = { "git" }
|
|
|
|
|
2019-05-02 19:21:15 +00:00
|
|
|
if not compilerIsVS then
|
2019-05-01 17:09:23 +00:00
|
|
|
table.insert(required, "make")
|
2019-05-02 19:21:15 +00:00
|
|
|
table.insert(required, compiler)
|
2019-05-01 17:09:23 +00:00
|
|
|
end
|
|
|
|
|
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")
|
2019-05-01 18:40:52 +00:00
|
|
|
local z = execQuiet("git clone .. %s -b %s --recurse-submodules --depth 1 --shallow-submodules", pkgName, branch)
|
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)
|
|
|
|
|
2019-05-01 17:07:39 +00:00
|
|
|
--
|
|
|
|
-- Bootstrap Premake in the newly cloned repository
|
|
|
|
--
|
2015-04-27 21:32:59 +00:00
|
|
|
|
2020-04-21 21:01:55 +00:00
|
|
|
print("Bootstrapping Premake...")
|
2019-05-02 19:21:15 +00:00
|
|
|
if compilerIsVS then
|
|
|
|
z = os.execute("Bootstrap.bat " .. compiler)
|
2019-05-01 17:07:39 +00:00
|
|
|
else
|
2019-05-02 19:21:15 +00:00
|
|
|
z = os.execute("make -j -f Bootstrap.mak " .. os.host())
|
2019-05-01 17:07:39 +00:00
|
|
|
end
|
2017-08-22 14:50:30 +00:00
|
|
|
if not z then
|
2019-05-01 17:07:39 +00:00
|
|
|
error("Failed to Bootstrap Premake", 0)
|
2015-05-03 22:56:29 +00:00
|
|
|
end
|
2019-05-04 14:03:07 +00:00
|
|
|
local premakeBin = path.translate("./bin/release/premake5")
|
2015-05-03 22:56:29 +00:00
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Make absolutely sure the embedded scripts have been updated
|
|
|
|
--
|
|
|
|
|
|
|
|
print("Updating embedded scripts...")
|
2019-05-01 17:08:33 +00:00
|
|
|
|
|
|
|
local z = execQuiet("%s embed %s", premakeBin, iif(kind == "source", "", "--bytecode"))
|
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
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2019-05-01 17:08:33 +00:00
|
|
|
-- Generate a source package.
|
2015-02-23 00:02:09 +00:00
|
|
|
--
|
|
|
|
|
2019-05-01 17:08:33 +00:00
|
|
|
if kind == "source" then
|
2015-02-23 00:02:09 +00:00
|
|
|
|
2019-05-01 17:08:33 +00:00
|
|
|
local function genProjects(parameters)
|
|
|
|
if not execQuiet("%s %s", premakeBin, parameters) then
|
|
|
|
error("failed to generate project for "..parameters, 0)
|
2015-02-23 00:02:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-01 17:08:33 +00:00
|
|
|
os.rmdir("build")
|
2015-02-23 22:34:16 +00:00
|
|
|
|
2015-02-23 00:02:09 +00:00
|
|
|
print("Generating project files...")
|
2019-05-01 17:08:33 +00:00
|
|
|
|
2019-05-02 19:21:51 +00:00
|
|
|
local ignoreActions = {
|
|
|
|
"clean",
|
|
|
|
"embed",
|
|
|
|
"package",
|
2020-04-21 21:01:55 +00:00
|
|
|
"self-test",
|
2019-05-02 19:21:51 +00:00
|
|
|
"test",
|
2019-05-04 15:16:52 +00:00
|
|
|
"gmake", -- deprecated
|
2019-05-04 15:22:56 +00:00
|
|
|
}
|
2019-05-02 19:21:51 +00:00
|
|
|
|
2019-05-04 15:22:56 +00:00
|
|
|
local perOSActions = {
|
|
|
|
"gmake2",
|
|
|
|
"codelite"
|
2019-05-02 19:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for action in premake.action.each() do
|
|
|
|
|
|
|
|
if not table.contains(ignoreActions, action.trigger) then
|
2019-05-04 15:22:56 +00:00
|
|
|
if table.contains(perOSActions, action.trigger) then
|
2019-05-02 19:21:51 +00:00
|
|
|
|
2019-05-04 15:22:56 +00:00
|
|
|
local osList = {
|
2019-05-02 19:21:51 +00:00
|
|
|
{ "windows", },
|
|
|
|
{ "unix", "linux" },
|
|
|
|
{ "macosx", },
|
|
|
|
{ "bsd", },
|
|
|
|
}
|
|
|
|
|
2019-05-04 15:22:56 +00:00
|
|
|
for _, os in ipairs(osList) do
|
2019-05-02 19:21:51 +00:00
|
|
|
local osTarget = os[2] or os[1]
|
2019-05-04 15:22:56 +00:00
|
|
|
genProjects(string.format("--to=build/%s.%s --os=%s %s", action.trigger, os[1], osTarget, action.trigger))
|
2019-05-02 19:21:51 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
genProjects(string.format("--to=build/%s %s", action.trigger, action.trigger))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-02-23 00:02:09 +00:00
|
|
|
|
|
|
|
print("Creating source code package...")
|
|
|
|
|
2019-05-30 17:10:03 +00:00
|
|
|
local excludeList = {
|
|
|
|
".gitignore",
|
|
|
|
".gitattributes",
|
|
|
|
".gitmodules",
|
|
|
|
".travis.yml",
|
|
|
|
".editorconfig",
|
|
|
|
"appveyor.yml",
|
|
|
|
"Bootstrap.*",
|
|
|
|
"packages/*",
|
|
|
|
}
|
|
|
|
local includeList = {
|
|
|
|
"build",
|
2019-05-30 17:10:28 +00:00
|
|
|
"src/scripts.c",
|
2019-05-30 17:10:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if not execQuiet("git rm --cached -r -f --ignore-unmatch "..table.concat(excludeList, ' ')) or
|
|
|
|
not execQuiet("git add -f "..table.concat(includeList, ' ')) or
|
2019-05-01 17:08:33 +00:00
|
|
|
not execQuiet("git stash") or
|
|
|
|
not execQuiet("git archive --format=zip -9 -o ../%s-src.zip --prefix=%s/ stash@{0}", pkgName, pkgName) or
|
|
|
|
not execQuiet("git stash drop stash@{0}")
|
|
|
|
then
|
|
|
|
error("failed to archive release", 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
os.chdir("..")
|
2015-02-23 00:02:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Create a binary package for this platform. This step requires a working
|
2020-04-21 21:01:55 +00:00
|
|
|
-- GNU/Make/GCC environment.
|
2015-02-23 00:02:09 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
if kind == "binary" then
|
|
|
|
|
|
|
|
print("Building binary...")
|
|
|
|
|
|
|
|
os.chdir("bin/release")
|
|
|
|
|
2019-05-01 17:08:33 +00:00
|
|
|
local addCommand = "git add -f premake5%s"
|
|
|
|
local archiveCommand = "git archive --format=%s -o ../../../%s-%s%s stash@{0} -- ./premake5%s"
|
|
|
|
|
2017-04-11 21:41:07 +00:00
|
|
|
if os.ishost("windows") then
|
2019-05-01 17:08:33 +00:00
|
|
|
addCommand = string.format(addCommand, ".exe")
|
|
|
|
archiveCommand = string.format(archiveCommand, "zip -9", pkgName, os.host(), pkgExt, ".exe")
|
2015-02-23 00:02:09 +00:00
|
|
|
else
|
2019-05-01 17:08:33 +00:00
|
|
|
addCommand = string.format(addCommand, "")
|
|
|
|
archiveCommand = string.format(archiveCommand, "tar.gz", pkgName, os.host(), pkgExt, "")
|
|
|
|
end
|
|
|
|
|
|
|
|
if not execQuiet(addCommand) or
|
|
|
|
not execQuiet("git stash") or
|
|
|
|
not execQuiet(archiveCommand) or
|
|
|
|
not execQuiet("git stash drop stash@{0}")
|
|
|
|
then
|
|
|
|
error("failed to archive release", 0)
|
2015-02-23 00:02:09 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
os.chdir("../../..")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Clean up
|
|
|
|
--
|
|
|
|
|
2019-05-01 18:30:23 +00:00
|
|
|
-- Use RMDIR token instead of os.rmdir to force remove .git dir which has read only files
|
|
|
|
execQuiet(os.translateCommands("{RMDIR} "..pkgName))
|