package An official xmake package repository https://xrepo.xmake.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.2 KiB

6 years ago
-- imports
import("core.base.option")
-- the options
local options =
{
{'v', "verbose", "k", nil, "Enable verbose information." }
, {'D', "diagnosis", "k", nil, "Enable diagnosis information." }
6 years ago
, {'p', "plat", "kv", nil, "Set the given platform." }
, {'a', "arch", "kv", nil, "Set the given architecture." }
, {nil, "ndk", "kv", nil, "Set the android NDK directory."}
6 years ago
, {nil, "packages", "vs", nil, "The package list." }
}
-- the main entry
6 years ago
function main(...)
6 years ago
-- parse arguments
local argv = option.parse({...}, options, "Test all the given or changed packages.")
-- get packages
6 years ago
local packages = argv.packages or {}
6 years ago
if #packages == 0 then
local files = os.iorun("git diff --name-only HEAD^")
for _, file in ipairs(files:split('\n'), string.trim) do
if file:find("packages", 1, true) and path.filename(file) == "xmake.lua" then
local package = path.filename(path.directory(file))
table.insert(packages, package)
end
end
end
6 years ago
if #packages == 0 then
6 years ago
table.insert(packages, "tbox dev")
6 years ago
end
6 years ago
local repodir = os.curdir()
local workdir = path.join(os.tmpdir(), "xmake-repo")
print(packages)
6 years ago
os.setenv("XMAKE_STATS", "false")
6 years ago
os.tryrm(workdir)
os.mkdir(workdir)
os.cd(workdir)
os.exec("xmake create test")
os.cd("test")
6 years ago
print(os.curdir())
6 years ago
local config_argv = {"f", "-c"}
if argv.verbose then
table.insert(config_argv, "-v")
end
if argv.diagnosis then
table.insert(config_argv, "-D")
end
if argv.plat then
table.insert(config_argv, "--plat=" .. argv.plat)
end
if argv.arch then
table.insert(config_argv, "--arch=" .. argv.arch)
end
if argv.ndk then
table.insert(config_argv, "--ndk=" .. argv.ndk)
end
6 years ago
os.execv("xmake", config_argv)
6 years ago
os.exec("xmake repo --add local-repo %s", repodir)
os.exec("xmake repo -l")
6 years ago
local require_argv = {"require", "-f", "-y"}
if argv.verbose then
table.insert(require_argv, "-v")
end
if argv.diagnosis then
table.insert(require_argv, "-D")
end
table.join2(require_argv, packages)
os.execv("xmake", require_argv)
6 years ago
end