parent
94fe6bfed3
commit
bb971a0ae5
4 changed files with 229 additions and 1 deletions
@ -0,0 +1,36 @@ |
||||
name: Monkey |
||||
|
||||
on: |
||||
schedule: # execute every 24 hours |
||||
- cron: "0 */24 * * *": |
||||
|
||||
jobs: |
||||
build: |
||||
strategy: |
||||
matrix: |
||||
os: [ubuntu-latest] |
||||
kind: [static, shared] |
||||
|
||||
runs-on: ${{ matrix.os }} |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
- uses: xmake-io/github-action-setup-xmake@v1 |
||||
with: |
||||
xmake-version: branch@dev |
||||
|
||||
- name: Installation |
||||
run: | |
||||
# TODO we will remove it later |
||||
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev |
||||
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 60 |
||||
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 |
||||
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-9 60 |
||||
sudo update-alternatives --set g++ /usr/bin/g++-9 |
||||
sudo update-alternatives --set gcc /usr/bin/gcc-9 |
||||
sudo update-alternatives --set cpp /usr/bin/cpp-9 |
||||
|
||||
- name: Tests |
||||
run: | |
||||
xmake l ./scripts/monkey.lua -D -k ${{ matrix.kind }} |
||||
|
@ -0,0 +1,23 @@ |
||||
package("irrxml") |
||||
|
||||
set_homepage("https://sourceforge.net/projects/irrlicht/") |
||||
set_description("High speed and easy-to-use XML Parser for C++") |
||||
|
||||
set_urls("https://deac-fra.dl.sourceforge.net/project/irrlicht/irrXML%20SDK/$(version)/irrxml-$(version).zip") |
||||
add_versions("1.2", "9b4f80639b2dee3caddbf75862389de684747df27bea7d25f96c7330606d7079") |
||||
|
||||
on_install(function (package) |
||||
io.writefile("xmake.lua", [[ |
||||
add_rules("mode.debug", "mode.release") |
||||
target("irrxml") |
||||
set_kind("static") |
||||
add_headerfiles("src/*.h") |
||||
add_files("src/*.cpp") |
||||
]]) |
||||
|
||||
import("package.tools.xmake").install(package) |
||||
end) |
||||
|
||||
on_test(function (package) |
||||
assert(package:has_cxxfuncs("irr::io::createIrrXMLReader(\"example.xml\")", {includes = "irrXML.h"})) |
||||
end) |
@ -0,0 +1,169 @@ |
||||
-- imports |
||||
import("core.base.option") |
||||
import("core.platform.platform") |
||||
import("packages", {alias = "get_packages"}) |
||||
|
||||
-- the options |
||||
local options = |
||||
{ |
||||
{'v', "verbose", "k", nil, "Enable verbose information." } |
||||
, {'D', "diagnosis", "k", nil, "Enable diagnosis information." } |
||||
, {nil, "shallow", "k", nil, "Only install the root packages." } |
||||
, {'k', "kind", "kv", nil, "Enable static/shared library." } |
||||
, {'p', "plat", "kv", nil, "Set the given platform." } |
||||
, {'a', "arch", "kv", nil, "Set the given architecture." } |
||||
, {'m', "mode", "kv", nil, "Set the given mode." } |
||||
, {nil, "cflags", "kv", nil, "Set the cflags." } |
||||
, {nil, "cxxflags", "kv", nil, "Set the cxxflags." } |
||||
, {nil, "ldflags", "kv", nil, "Set the ldflags." } |
||||
, {nil, "ndk", "kv", nil, "Set the android NDK directory." } |
||||
, {nil, "sdk", "kv", nil, "Set the SDK directory of cross toolchain." } |
||||
, {nil, "vs_sdkver", "kv", nil, "Set the Windows SDK version." } |
||||
, {nil, "vs_runtime", "kv", nil, "Set the VS Runtime library." } |
||||
, {nil, "mingw", "kv", nil, "Set the MingW directory." } |
||||
, {nil, "toolchain", "kv", nil, "Set the toolchain name." } |
||||
, {nil, "packages", "vs", nil, "The package list." } |
||||
} |
||||
|
||||
|
||||
-- require packages |
||||
function _require_packages(argv, packages) |
||||
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.mode then |
||||
table.insert(config_argv, "--mode=" .. argv.mode) |
||||
end |
||||
if argv.ndk then |
||||
table.insert(config_argv, "--ndk=" .. argv.ndk) |
||||
end |
||||
if argv.sdk then |
||||
table.insert(config_argv, "--sdk=" .. argv.sdk) |
||||
end |
||||
if argv.vs_sdkver then |
||||
table.insert(config_argv, "--vs_sdkver=" .. argv.vs_sdkver) |
||||
end |
||||
if argv.vs_runtime then |
||||
table.insert(config_argv, "--vs_runtime=" .. argv.vs_runtime) |
||||
end |
||||
if argv.mingw then |
||||
table.insert(config_argv, "--mingw=" .. argv.mingw) |
||||
end |
||||
if argv.toolchain then |
||||
table.insert(config_argv, "--toolchain=" .. argv.toolchain) |
||||
end |
||||
if argv.cflags then |
||||
table.insert(config_argv, "--cflags=" .. argv.cflags) |
||||
end |
||||
if argv.cxxflags then |
||||
table.insert(config_argv, "--cxxflags=" .. argv.cxxflags) |
||||
end |
||||
if argv.ldflags then |
||||
table.insert(config_argv, "--ldflags=" .. argv.ldflags) |
||||
end |
||||
os.vexecv("xmake", config_argv) |
||||
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 |
||||
if argv.shallow then |
||||
table.insert(require_argv, "--shallow") |
||||
end |
||||
if argv.mode == "debug" and argv.kind == "shared" then |
||||
table.insert(require_argv, "--extra={debug=true,configs={shared=true}}") |
||||
elseif argv.mode == "debug" then |
||||
table.insert(require_argv, "--extra={debug=true}") |
||||
elseif argv.kind == "shared" then |
||||
table.insert(require_argv, "--extra={configs={shared=true}}") |
||||
end |
||||
table.join2(require_argv, packages) |
||||
os.vexecv("xmake", require_argv) |
||||
end |
||||
|
||||
-- the given package is supported? |
||||
function _package_is_supported(argv, packagename) |
||||
local packages = get_packages() |
||||
if packages then |
||||
local plat = argv.plat or os.subhost() |
||||
local packages_plat = packages[plat] |
||||
for _, package in ipairs(packages_plat) do |
||||
if package and packagename:split("%s+")[1] == package.name then |
||||
local arch = argv.arch or platform.archs(plat)[1] or os.arch() |
||||
for _, package_arch in ipairs(package.archs) do |
||||
if arch == package_arch then |
||||
return true |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
-- the main entry |
||||
function main(...) |
||||
|
||||
-- parse arguments |
||||
local argv = option.parse({...}, options, "Test all the given or changed packages.") |
||||
|
||||
-- get packages |
||||
math.randomseed(os.time()) |
||||
local packages = argv.packages or {} |
||||
if #packages == 0 then |
||||
local files = os.files(path.join(os.scriptdir(), "..", "packages", "*", "*", "xmake.lua")) |
||||
while #packages < 10 do |
||||
local file = files[math.random(#files)] |
||||
if file:find("packages", 1, true) and path.filename(file) == "xmake.lua" then |
||||
assert(file == file:lower(), "%s must be lower case!", file) |
||||
local package = path.filename(path.directory(file)) |
||||
table.insert(packages, package) |
||||
end |
||||
end |
||||
end |
||||
if #packages == 0 then |
||||
table.insert(packages, "tbox dev") |
||||
end |
||||
|
||||
-- remove unsupported packages |
||||
for idx, package in irpairs(packages) do |
||||
assert(package == package:lower(), "package(%s) must be lower case!", package) |
||||
if not _package_is_supported(argv, package) then |
||||
table.remove(packages, idx) |
||||
end |
||||
end |
||||
if #packages == 0 then |
||||
print("no testable packages on %s!", argv.plat or os.subhost()) |
||||
return |
||||
end |
||||
|
||||
-- prepare test project |
||||
local repodir = os.curdir() |
||||
local workdir = path.join(os.tmpdir(), "xmake-repo") |
||||
print(packages) |
||||
os.setenv("XMAKE_STATS", "false") |
||||
os.tryrm(workdir) |
||||
os.mkdir(workdir) |
||||
os.cd(workdir) |
||||
os.exec("xmake create test") |
||||
os.cd("test") |
||||
print(os.curdir()) |
||||
os.exec("xmake repo --add local-repo %s", repodir) |
||||
os.exec("xmake repo -l") |
||||
|
||||
-- require packages |
||||
for _, package in ipairs(packages) do |
||||
_require_packages(argv, package) |
||||
end |
||||
end |
Loading…
Reference in new issue