Added new project types:utility,blank

blank = does nothing / not a project. will use for extensions and including subprojects later
utility = performs pre/post build commands only
completely untested. just noticed this was missing
This commit is contained in:
Reece Wilson 2021-05-21 20:15:38 +01:00
parent 615bcb53b9
commit 48ab27d1f6
2 changed files with 63 additions and 33 deletions

View File

@ -1,4 +1,4 @@
local project = require("project") local auProject = require("project")
function JsonProcessor(info) function JsonProcessor(info)
local result, err = json.decode(io.readfile(info.path .. "/Aurora.json")) local result, err = json.decode(io.readfile(info.path .. "/Aurora.json"))
@ -25,8 +25,15 @@ function JsonProcessor(info)
forEach(result.include, handleUserJsonInclude) forEach(result.include, handleUserJsonInclude)
end end
local tryAddDefine = function(aaa)
if (aaa) then
defines(aaa)
end
end
local handleInclude = function(this) local handleInclude = function(this)
local result = this.result local result = this.result
if (result.type:lower() == "aurora") then if (result.type:lower() == "aurora") then
includedirs (info.path .. "/Include") includedirs (info.path .. "/Include")
elseif (result.type:lower() == "lazy_free") then elseif (result.type:lower() == "lazy_free") then
@ -41,7 +48,11 @@ function JsonProcessor(info)
handleJSONInclude(result) handleJSONInclude(result)
elseif (result.type:lower() == "empty") then elseif (result.type:lower() == "empty") then
handleJSONInclude(result) handleJSONInclude(result)
elseif ((result.type:lower() == "utility") or (result.type:lower() == "null")) then
return
end end
tryAddDefine(result.defines)
end end
local handlePostBuild = function(obj) local handlePostBuild = function(obj)
@ -71,11 +82,21 @@ function JsonProcessor(info)
local handleLink = function(this) local handleLink = function(this)
dependson(this.info.name) dependson(this.info.name)
if ((type:lower() == "utility") or (type:lower() == "null")) then
return
end
links(this.info.name) links(this.info.name)
handleDllImportMaybe(this) handleDllImportMaybe(this)
end end
local handleReference = function(this) local handleReference = function(this)
local type = this.result.type
if ((type:lower() == "utility") or (type:lower() == "null")) then
return
end
local cur = getProjectInfo(getCurrentProjectName()) local cur = getProjectInfo(getCurrentProjectName())
if (cur and cur.isShared) then if (cur and cur.isShared) then
@ -89,44 +110,50 @@ function JsonProcessor(info)
handleInclude(this) handleInclude(this)
end end
local tryAddDefine = function (aaa)
if (aaa) then
defines(aaa)
end
end
local handleProcess = function (a) local handleProcess = function (a)
local result = a.result local result = a.result
local name = a.info.name local name = a.info.name
local path = a.info.path local path = a.info.path
local isBlank = false
if (result.type:lower() == "aurora") then if (result.type:lower() == "aurora") then
local srcPath = path .. "/Source" local srcPath = path .. "/Source"
local incPath = path .. "/Include" local incPath = path .. "/Include"
project(name, a.info.projectType, {srcPath}, {srcPath, incPath}, a.info.out, path) auProject(name, a.info.projectType, {srcPath}, {srcPath, incPath}, a.info.out, path)
elseif (result.type:lower() == "lazy_free") then elseif (result.type:lower() == "lazy_free") then
project(name, a.info.projectType, {path .. "/*.*"}, {path .. "/"}, a.info.out, path) auProject(name, a.info.projectType, {path .. "/*.*"}, {path .. "/"}, a.info.out, path)
elseif (result.type:lower() == "root") then elseif (result.type:lower() == "root") then
project(name, a.info.projectType, {path .. "/**.*"}, {path .. "/"}, a.info.out, path) auProject(name, a.info.projectType, {path .. "/**.*"}, {path .. "/"}, a.info.out, path)
elseif (result.type:lower() == "pair") then elseif (result.type:lower() == "pair") then
project(name, a.info.projectType, {path .. "/" .. result.srcSource .. "/**.*"}, {path .. "/" .. result.srcInclude}, a.info.out, path) auProject(name, a.info.projectType, {path .. "/" .. result.srcSource .. "/**.*"}, {path .. "/" .. result.srcInclude}, a.info.out, path)
elseif (result.type:lower() == "generic") then elseif (result.type:lower() == "generic") then
project(name, a.info.projectType, nil, nil, a.info.out, path) print("type 'generic' is deprecated, use 'empty' instead")
print("'generic' will soon be replaced by the behaviour of 'aurora'")
auProject(name, a.info.projectType, nil, nil, a.info.out, path)
elseif (result.type:lower() == "empty") then elseif (result.type:lower() == "empty") then
project(name, a.info.projectType, nil, nil, a.info.out, path) auProject(name, a.info.projectType, nil, nil, a.info.out, path)
elseif (result.type:lower() == "utility") then
project(name)
kind "utility"
isBlank = true
elseif (result.type:lower() == "null") then
return
else else
print "invalid project type" print "invalid auProject type"
os.exit() os.exit()
end end
handleJSONInclude(result) -- include project public headers, do not use handleInclude, that could reinclude a header included in `project` handleJSONInclude(result) -- include auProject public headers, do not use handleInclude, that could reinclude a header included in `project`
-- that could potentially fuck with #include_next -- that could potentially fuck with #include_next
local handleFeature = function(feature) local handleFeature = function(feature)
@ -221,12 +248,14 @@ function JsonProcessor(info)
files(path .. "/" .. source) files(path .. "/" .. source)
end end
forEach(result.depends, handleDepends, info.path) forEach(result.require, handleRequire)
if (not isBlank) then
forEach(result.features, handleFeature, info.path) forEach(result.features, handleFeature, info.path)
forEach(result.excludes, handleExcludes, info.path) forEach(result.excludes, handleExcludes, info.path)
forEach(result.sources, handleSources, info.path) forEach(result.sources, handleSources, info.path)
forEach(result.depends, handleDepends, info.path)
forEach(result["soft-depends"], handleSoftDepends) forEach(result["soft-depends"], handleSoftDepends)
forEach(result.require, handleRequire)
if (a.info.projectType:lower() == "sharedlib") then if (a.info.projectType:lower() == "sharedlib") then
tryAddDefine(result.dllexport) tryAddDefine(result.dllexport)
@ -235,6 +264,7 @@ function JsonProcessor(info)
tryAddDefine(result.impdefines) tryAddDefine(result.impdefines)
defines(result.defines) defines(result.defines)
end
forEach(result.actions, handleAction, info.path) forEach(result.actions, handleAction, info.path)
forEach(result.postBuild, handlePostBuild, info.path) forEach(result.postBuild, handlePostBuild, info.path)
@ -247,7 +277,7 @@ function JsonProcessor(info)
local subinfo = { local subinfo = {
namespace = info.namespace, namespace = info.namespace,
path = info.path .. "/" .. subproj.path, path = info.path .. "/" .. subproj.path,
projectType = subproj.type, projectType = subproj.projectType,
out = info.out, out = info.out,
name = nil, name = nil,
translations = info.translations translations = info.translations

View File

@ -7,7 +7,7 @@
"type": "type":
{ {
"type": "string", "type": "string",
"enum": ["pair", "empty", "root", "lazy_free"], "enum": ["pair", "empty", "root", "lazy_free", "utility", "blank"],
"description": "https://pastebin.com/ThE2t9EJ" "description": "https://pastebin.com/ThE2t9EJ"
}, },
"srcSource": "srcSource":