Build/Core/ResourceCompiler/ResourceCompiler.lua

37 lines
1.2 KiB
Lua

local function resourceCompile(files, additional, script)
auForEach(files, _G.files)
local absFiles = {}
auForEach(files, function(file)
auForEach(os.matchfiles(file), function(file)
table.insert(absFiles, os.realpath(file))
end)
end)
local cur = auGetCurrentProjectMeta()
local projScript = nil
if (cur and cur.path) then
projScript = path.join(cur.path, script)
end
local userScript = path.join(Aurora.Settings.sAbsRepoScripts, script)
if (os.isfile(userScript)) then
script = userScript
elseif (projScript and os.isfile(projScript)) then
script = projScript
end
local meta = {
script = script,
files = absFiles,
ext = additional,
hash = string.sha1(json.encode(files) .. json.encode(additional or "") .. script .. cur.name)
}
auAddBuildAction("pre", "lua", path.join(Aurora.Settings.sAbsScripts, "Core", "ResourceCompiler", "run.lua"), true, meta)
cleancommands("rm ", path.translate(path.normalize(path.join(Aurora.Settings.sAbsCompilerWd, meta.hash) .. ".rsc"), path.getDefaultSeparator()))
end
return resourceCompile