[-] /Legacy/*

This commit is contained in:
Reece Wilson 2022-03-07 00:32:19 +00:00
parent 4657a14fe7
commit ee8c26f058
3 changed files with 208 additions and 217 deletions

View File

@ -0,0 +1,207 @@
local auProject = auRequire("Core/project").startProject
local projectHandlers = auRequire("Core/JSON/jsonProjectHandlers")
function JsonProcessor(info)
local result, err = json.decode(io.readfile(info.jpath))
if (not result) then
auFatal("parse error", info.path, err)
return
end
if (not info.name) then
info.name = result.name
end
result.name = info.name
-- ported
local includeDirEx = function(path, incFiles)
includedirs(path)
if (not incFiles) then
return
end
files(path .. "/**.h")
files(path .. "/**.hpp")
files(path .. "/**.inl")
end
local handleJSONInclude = function(this, val, incFiles)
projectHandlers.runProjectImport(this, result, {"include", "includes", "actions"}, function(dep, soft)
auIncludeProject(this:translateDep(dep), soft)
end)
end
local handleInclude = function(this, incFiles)
local result = this.result
auForEach(result.defines, defines)
if (result.type:lower() == "aurora") then
includeDirEx(info.path .. "/Include")
elseif (result.type:lower() == "lazy_free") then
includeDirEx(info.path)
handleJSONInclude(this, false, incFiles)
elseif (result.type:lower() == "root") then
includeDirEx(info.path)
handleJSONInclude(this, result.noRootInclude, incFiles)
elseif (result.type:lower() == "generic") then
handleJSONInclude(this, false, incFiles)
end
end
local handleLink = function(this)
dependson(this.info.name)
auForEach(result.linkSources, function(source)
files(path.join(this:getMeta().path, source))
end)
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "blank")) then
return
end
if ((not this.result.noLink)) then
links(this.info.name)
end
projectHandlers.runProjectLink(this, result, function(dep, soft)
auLinkProject(this:translateDep(dep), soft)
end)
end
local handleReference = function(this, circular)
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "blank")) then
return
end
local cur = auGetCurrentProjectMeta()
local staticImport = circular
local jsonKeys = {}
if (cur and cur.isShared and not circular) then
table.insert(jsonKeys, "dllimport")
elseif (cur and cur.isStatic and not circular) then
table.insert(jsonKeys, "dllexport")
table.insert(jsonKeys, "staticImport")
table.insert(jsonKeys, "staticImpDefines")
elseif (circular) then
table.insert(jsonKeys, "staticImport")
table.insert(jsonKeys, "staticImpDefines")
end
table.insert(jsonKeys, "include")
table.insert(jsonKeys, "include-depends")
table.insert(jsonKeys, "include-soft-depends")
handleInclude(this, false)
defines(("_auhas_" .. this.result.name):upper():gsub("%-", "_") .. "=1")
projectHandlers.runProjectImport(this, result, jsonKeys, function(dep, soft)
auIncludeProject(this:translateDep(dep), soft)
end)
end
local resolveDependencies = function(this, resolve)
projectHandlers.runProjectLink(this, result, resolve)
end
local handleProcess = function (this)
local result = this.result
local name = this:getMeta().name
local path = this:getMeta().path
local isUtility = false
local project = {
name = info.name,
projectType = info.projectType or result.projectType,
dest = info.out,
noLink = result.noLink
}
if (result.noLink) then
print("noLink is deprecated. Use projectType: none")
project.projectType = "none"
info.projectType = "none"
end
if (result.type:lower() == "aurora") then
local srcPath = path .. "/Source"
local incPath = path .. "/Include" -- /Source is emitted by design. Use it as a prefix in <> includes; eg, #include <Source/MyLib.hpp>
project.src = srcPath
project.inc = {incPath, path}
auProject(project)
elseif (result.type:lower() == "lazy_free") then
project.src = path .. "/*.*"
project.inc = path
auProject(project)
elseif (result.type:lower() == "root") then
project.src = path
project.inc = path
auProject(project)
elseif (result.type:lower() == "generic") then
auProject(project)
elseif (result.type:lower() == "utility") then
project(name)
kind "utility"
isUtility = true
elseif (result.type:lower() == "blank") then
return
else
auFatal("invalid project type", result.type)
end
handleInclude(this, true)
if (not isUtility) then
projectHandlers.runProjectBlock(this, result)
if (this:getMeta().projectType:lower() == "sharedlib") then
auForEach(result.dllexport, defines)
end
end
end
auForEach(result.subprojs, function(subproj)
local subinfo = {
namespace = info.namespace,
path = path.join(info.path, subproj.path),
projectType = subproj.projectType,
out = info.out,
name = subproj.name,
translations = auCopyTables(info.translations, subproj.translations)
}
auAddVist(subinfo)
end)
local interface = {}
interface.result = result
interface.info = info
interface.resolveDependencies = resolveDependencies
interface.process = handleProcess
interface.handleLink = handleLink
interface.handleReference = handleReference
return interface
end
return JsonProcessor

View File

@ -1,216 +0,0 @@
local auProject = auRequire("Core/project").startProject
local projectHandlers = auRequire("Core/JSON/JSON").projectHandlers
function JsonProcessor(info)
local result, err = json.decode(io.readfile(info.jpath))
if (not result) then
auFatal("parse error", info.path, err)
return
end
if (not info.name) then
info.name = result.name
end
result.name = info.name
-- ported
local includeDirEx = function(path, incFiles)
includedirs(path)
if (not incFiles) then
return
end
files(path .. "/**.h")
files(path .. "/**.hpp")
files(path .. "/**.inl")
end
local handleUserJsonInclude = function(path, prefix, inc)
includeDirEx(prefix .. "/" .. path, inc)
end
local publicDepends = function(name, this, soft)
auIncludeProject(this:translateDep(name), soft) -- evil recursion
end
local handleJSONInclude = function(this, val, incFiles)
projectHandlers.runProjectImport(this, result, {"include", "includes", "actions"}, function(dep, soft)
publicDepends(dep, this, soft)
end)
end
local handleInclude = function(this, incFiles)
local result = this.result
auForEach(result.defines, defines)
if (result.type:lower() == "aurora") then
includeDirEx(info.path .. "/Include")
elseif (result.type:lower() == "lazy_free") then
includeDirEx(info.path)
handleJSONInclude(this, false, incFiles)
elseif (result.type:lower() == "root") then
includeDirEx(info.path)
handleJSONInclude(this, result.noRootInclude, incFiles)
elseif (result.type:lower() == "generic") then
handleJSONInclude(this, false, incFiles)
end
end
local handleLink = function(this)
dependson(this.info.name)
auForEach(result.linkSources, function(source)
files(path.join(this:getMeta().path, source))
end)
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "blank")) then
return
end
if ((not this.result.noLink)) then
links(this.info.name)
end
projectHandlers.runProjectLink(this, result, function(dep, soft)
auLinkProject(this:translateDep(dep), soft)
end)
end
local handleReference = function(this, circular)
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "blank")) then
return
end
local cur = auGetCurrentProjectMeta()
local staticImport = circular
local jsonKeys = {}
if (cur and cur.isShared and not circular) then
table.insert(jsonKeys, "dllimport")
elseif (cur and cur.isStatic and not circular) then
table.insert(jsonKeys, "dllexport")
table.insert(jsonKeys, "staticImport")
table.insert(jsonKeys, "staticImpDefines")
elseif (circular) then
table.insert(jsonKeys, "staticImport")
table.insert(jsonKeys, "staticImpDefines")
end
table.insert(jsonKeys, "include")
table.insert(jsonKeys, "include-depends")
table.insert(jsonKeys, "include-soft-depends")
handleInclude(this, false)
defines(("_auhas_" .. this.result.name):upper():gsub("%-", "_") .. "=1")
projectHandlers.runProjectImport(this, result, jsonKeys, function(dep, soft)
publicDepends(dep, this, soft)
end)
end
local resolveDependencies = function(this, resolve)
projectHandlers.runProjectLink(this, result, resolve)
end
local handleProcess = function (a)
local result = a.result
local name = a.info.name
local path = a.info.path
local isUtility = false
local project = {
name = info.name,
projectType = info.projectType or result.projectType,
dest = info.out,
noLink = result.noLink
}
if (result.noLink) then
print("noLink is deprecated. Use projectType: none")
project.projectType = "none"
info.projectType = "none"
end
if (result.type:lower() == "aurora") then
local srcPath = path .. "/Source"
local incPath = path .. "/Include" -- /Source is emitted by design. Use it as a prefix in <> includes; eg, #include <Source/MyLib.hpp>
project.src = srcPath
project.inc = {incPath, path}
auProject(project)
elseif (result.type:lower() == "lazy_free") then
project.src = path .. "/*.*"
project.inc = path
auProject(project)
elseif (result.type:lower() == "root") then
project.src = path
project.inc = path
auProject(project)
elseif (result.type:lower() == "generic") then
auProject(project)
elseif (result.type:lower() == "utility") then
project(name)
kind "utility"
isUtility = true
elseif (result.type:lower() == "blank") then
return
else
auFatal("invalid project type", result.type)
end
handleInclude(a, true)
if (not isUtility) then
projectHandlers.runProjectBlock(a, result)
if (a.info.projectType:lower() == "sharedlib") then
auForEach(result.dllexport, defines)
end
end
end
auForEach(result.subprojs, function(subproj)
local subinfo = {
namespace = info.namespace,
path = path.join(info.path, subproj.path),
projectType = subproj.projectType,
out = info.out,
name = subproj.name,
translations = auCopyTables(info.translations, subproj.translations)
}
auAddVist(subinfo)
end)
local interface = {}
interface.result = result
interface.info = info
interface.resolveDependencies = resolveDependencies
interface.process = handleProcess
interface.handleLink = handleLink
interface.handleReference = handleReference
return interface
end
return JsonProcessor

View File

@ -1,4 +1,4 @@
local jsonProcessor = auRequire("Core/Legacy/jsonProcessor") local jsonProcessor = auRequire("Core/JSON").projectBase
------------------------------------------------------- -------------------------------------------------------
-- globals -- globals