Remove assets from repository and download them using xmake

This commit is contained in:
SirLynix
2022-05-27 08:34:36 +02:00
parent 03e2801dbe
commit 5507b98f2f
51 changed files with 189 additions and 313 deletions

View File

@@ -1,5 +1,5 @@
-- Compile shaders to includables headers
rule("compile_shaders")
rule("nzsl.compile.shaders")
on_load(function (target)
target:add("packages", "nzsl")
end)

View File

@@ -1,7 +1,7 @@
-- Adds -d as a debug suffix
rule("debug_suffix")
rule("debug.suffix")
on_load(function (target)
if target:kind() ~= "binary" then
target:set("basename", target:basename() .. "-d")
target:set("suffixname", "-d")
end
end)

View File

@@ -0,0 +1,42 @@
local baseDownloadURL = "https://nazara.digitalpulse.software"
local function downloadAssetsRule(name)
rule("download.assets." .. name)
set_kind("project")
before_build(function (opt)
import("net.http")
import("utils.archive")
local referenceVersion = io.readfile("assets/" .. name .. "_version.txt")
local currentVersion = os.exists("assets/" .. name .. "/version.txt") and io.readfile("assets/" .. name .. "/version.txt")
if referenceVersion == currentVersion then
utils.vprintf(name .. " assets are up-to-date, ignoring\n")
return
end
local text = {}
table.insert(text, currentVersion and "update " or "download ")
table.insert(text, name)
table.insert(text, " assets?")
if currentVersion then
table.insert(text, " current version is " .. currentVersion .. " and remote version is " .. referenceVersion)
end
table.insert(text, "\nthis is required to run them")
local confirm = utils.confirm({description = table.concat(text), default = true})
if not confirm then
utils.vprintf("aborting " .. name .. " assets downloading\n")
return
end
os.rm("assets/" .. name)
http.download(baseDownloadURL .. "/assets_" .. name .. ".zip", "assets_" .. name .. ".zip")
archive.extract("assets_" .. name .. ".zip", "assets")
os.rm("assets_" .. name .. ".zip")
print(name .. " assets downloaded!")
end)
end
downloadAssetsRule("examples")
downloadAssetsRule("tests")

View File

@@ -1,5 +1,5 @@
-- Turns resources into includables headers
rule("embed_resources")
rule("embed.resources")
before_build(function (target, opt)
import("core.base.option")
if xmake.version():ge("2.5.9") then
@@ -42,7 +42,7 @@ rule("embed_resources")
end
for _, sourcebatch in pairs(target:sourcebatches()) do
if sourcebatch.rulename == "embed_resources" then
if sourcebatch.rulename == "embed.resources" then
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
local targetpath = sourcefile .. ".h"
if option.get("rebuild") or os.mtime(sourcefile) >= os.mtime(targetpath) then

View File

@@ -1,7 +1,7 @@
local modules = NazaraModules
-- Builds renderer plugins if linked to NazaraRenderer
rule("build_rendererplugins")
rule("build.rendererplugins")
on_load(function (target)
local deps = table.wrap(target:get("deps"))