diff --git a/Core/BuildHooks/BuildHooks.lua b/Core/BuildHooks/BuildHooks.lua index 3bec622..d2739af 100644 --- a/Core/BuildHooks/BuildHooks.lua +++ b/Core/BuildHooks/BuildHooks.lua @@ -130,7 +130,7 @@ local function postBuildCommands(name, type, config, platformName, arch) platform.devChainSupportsElfStrip) then debugEx = ".dwarf" debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".dwarf" - postbuildcommands("objcopy --only-keep-debug " .. file .. " " .. debugSymbolPath) + postbuildcommands("objcopy --only-keep-debug " .. debugSymbolPath .. " " .. debugSymbolPath) elseif (isWin) then debugEx = ".pdb" debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".pdb" diff --git a/Core/JSON/JSON.lua b/Core/JSON/JSON.lua index a8dd747..b8556d2 100644 --- a/Core/JSON/JSON.lua +++ b/Core/JSON/JSON.lua @@ -1,3 +1,4 @@ return { - project = auRequire("Core/JSON/jsonProject") + projectHandlers = auRequire("Core/JSON/jsonProjectHandlers"), + projectBase = auRequire("Core/JSON/jsonProjectBase") } \ No newline at end of file diff --git a/Core/JSON/jsonProject.lua b/Core/JSON/jsonProject.lua deleted file mode 100644 index 61f6462..0000000 --- a/Core/JSON/jsonProject.lua +++ /dev/null @@ -1,203 +0,0 @@ - -local function __pushFilter(obj, key, callback, expandArray) - if (not obj) then - return - end - - local function runCallbackFe(value, key, callback, expandArray, isArray) - if (expandArray and isArray) then - auForEach(value, function(val) - __pushFilter(val, key, callback, false) - end) - else - callback(value) - end - end - - if (type(obj) == "table") then - local value = nil - local isArray = false - - if (auIsArray(obj)) then - value = obj - isArray = true - else - value = obj[key] - - if (not value) then - return - end - end - - if (obj.filter) then - filter(auFilterOf(obj.filter)) - end - - runCallbackFe(value, key, callback, expandArray, isArray) - - if (obj.filter) then - filter {} - end - else - if (expandArray) then -- fast path. we can skip this, if false. the if and statment doesnt optimize away the auIsArray anymore - runCallbackFe(obj, key, callback, true, auIsArray(obj)) - else - callback(obj) - end - end -end - -local function __handleIncludeCallback(thisProject, includeProject, callback) - - if (type(project) == "table") - auForEachKV(project, function(projectName, soft) - if (type(projectName) == "number") then - projectName = soft - soft = false - end - - if (type(projectName) ~= "string") then - auFatal("what is my project name?") - end - - callback(projectName, not soft) - - end) - else - if (type(project) ~= "string") then - auFatal("what is my project name? [2]") - end - - callback(projectName, true) - end -end - -local function __translate(project, key) - - if (project.info.translations) then - local override = project.info.translations[key] - if (override) then - key = override - end - end - - return key -end - -local function auBlockProjectKeyDefines(project, value) - __pushFilter(value, "value", defines) -end - -local function auBlockProjectKeyIncludes(project, value) - -end - -local function auBlockProjectKeyFeatures(project, value) - __pushFilter(obj, "feature", auAddFeature, true) -end - -local function auBlockProjectKeyExcludes(project, value) - -end - -local function auBlockProjectKeySources(project, value) - -end - -local function auBlockProjectKeySourcePaths(project, value) - -end - -local function auBlockProjectKeyEval(project, value, tasksMask) - tasksMask:remove("eval") -end - -local function auBlockProjectKeyImplDefines(project, value) - -end - -local function auBlockProjectKeyImplIncludes(project, value) - -end - -local function auBlockProjectKeyClangIgnore(project, value) - -end - -local function auBlockProjectKeyMSVCIgnore(project, value) - -end - -local function auBlockProjectKeyDepends(project, value) - -end - -local function auBlockProjectKeyLinks(obj) - __pushFilter(obj, "value", links) -end - -local function auHeaderProjectKeyIncludeDepends(thisProject, includeProject) - __handleIncludeCallback(jsonProcessor, includeProject, function(projectName, hard) - auIncludeProject(__translate(thisProject, projectName), not hard) - end) -end - -local function auHeaderProjectKeyLinkDepends(thisProject, includeProject) - __handleIncludeCallback(jsonProcessor, includeProject, function(projectName, hard) - auLinkProject(__translate(thisProject, projectName), not hard) - end) -end - -local function auHeaderProjectKeyRequire(project, script) - auUserRequire(script) -end - -local auProjectHeaderHandlers = -{ - require = auHeaderProjectKeyRequire, - linkDepends = auHeaderProjectKeyLinkDepends - includeDepends = auHeaderProjectKeyIncludeDepends -} - -local auProjectBlockHandlers = -{ - links = auBlockProjectKeyLinks, - sourcePaths = auBlockProjectKeySourcePaths, - sources = auBlockProjectKeySources, - excludes = auBlockProjectKeyExcludes, - eval = auBlockProjectKeyEval, - impDefines = auBlockProjectKeyImplDefines, - implDefines = auBlockProjectKeyImplDefines, - implementationDefines = auBlockProjectKeyImplDefines, - impInclude = auBlockProjectKeyImplIncludes, - implInclude = auBlockProjectKeyImplIncludes, - clangIgnore = auBlockProjectKeyClangIgnore, - msvcIgnore = auBlockProjectKeyMSVCIgnore, - depends = auBlockProjectKeyDepends -} - -local kGenericTasks = {"eval", "features", "sourcePaths", "sources", "excludes", - "impDefines", "implDefines", "implementationDefines", - "impInclude", "implInclude", "implInclude", "clangIgnore", - "msvcIgnore", "depends" } - - -local function __pRunTasks(object, tasks) - auForEachKV(object, function(key, value) - if (not auContains(tasks, key)) then - return - end - - auProjectBlockHandlers[key](object, value, tasks) - end) -end - -local function __pRunLinkTasks(object) - __pRunTasks(object, {"eval", "links", "depends"}) -end - -local function __pRunMainTasks(object) - __pRunTasks(object, kGenericTasks) -end - -return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers) \ No newline at end of file diff --git a/Core/JSON/jsonProjectBase.lua b/Core/JSON/jsonProjectBase.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/JSON/jsonProjectHandlers.lua b/Core/JSON/jsonProjectHandlers.lua new file mode 100644 index 0000000..3af667c --- /dev/null +++ b/Core/JSON/jsonProjectHandlers.lua @@ -0,0 +1,402 @@ +local kTargetingCmake = false +local kTargetingWindows = os.host() == "windows" +local kBugHack = kTargetingCmake or kTargetingWindows + +local auProjectBlockHandlers = {} +local kGenericTasks = {} +local __pRunTasks = function(processor, object, map, tasks, inc) +end + +local function __pushFilter(obj, key, callback, expandArray) + if (not obj) then + return + end + + local function runCallbackFe(value, key, callback, expandArray, isArray) + if (expandArray and isArray) then + auForEach(value, function(val) + __pushFilter(val, key, callback, false) + end) + else + callback(value) + end + end + + if (type(obj) == "table") then + local value = nil + local isArray = false + + if (auIsArray(obj)) then + value = obj + isArray = true + else + if (key) then + value = obj[key] + else + value = obj + end + + if (not value) then + return + end + end + + if (obj.filter) then + auFilter(auFilterOf(obj.filter)) + end + + runCallbackFe(value, key, callback, expandArray, isArray) + + if (obj.filter) then + auFilter {} + end + else + if (expandArray) then -- fast path. we can skip this, if false. the if and statment doesnt optimize away the auIsArray anymore + runCallbackFe(obj, key, callback, true, auIsArray(obj)) + else + callback(obj) + end + end +end + +local function __handleIncludeCallback(processor, includeProject, callback) + if (type(processor) == "table") then + auForEachKV(processor, function(processorName, soft) + if (type(processorName) == "number") then + processorName = soft + soft = false + end + + if (type(processorName) ~= "string") then + auFatal("what is my processor name?") + end + + callback(processorName, not soft) + + end) + else + if (type(processor) ~= "string") then + auFatal("what is my processor name? [2]", type(processor)) + end + + callback(processorName, true) + end +end + +local function __translate(processor, key) + return processor:translateDep(key) +end + +local function _includeDirectoryEx(path, incFiles) + includedirs(path) + + if (not incFiles) then + return + end + + files(path .. "/**.h") + files(path .. "/**.hpp") + files(path .. "/**.inl") +end + +local function auBlockProjectKeyDefines(processor, value) + -- Required for dependent and current processor // global library configuration + __pushFilter(value, "value", defines) +end + +local function auBlockProjectKeyIncludes(processor, value, tasks, inc) + _includeDirectoryEx(processor:getMeta().path .. "/" .. value, not inc) +end + +local function auBlockProjectKeyFeatures(processor, value) + -- Runs special features / plugins defined in sAbsScripts/features + __pushFilter(value, "value", auAddFeature, true) +end + +local function auBlockProjectKeyExcludes(processor, value) + __pushFilter(value, "value", removefiles) +end + +local function auBlockProjectKeySources(processor, value) + --files(value) -- NOTE: this was once path .. / .. value + __pushFilter(value, "value", files) +end + +local function auBlockProjectKeySourcePaths(processor, value) + local source = value + local path = processor:getMeta().path + files + { + path .. "/" .. source .. "/**.*pp", + path .. "/" .. source .. "/**.inl", + path .. "/" .. source .. "/**.c", + path .. "/" .. source .. "/**.cc", + path .. "/" .. source .. "/**.h", + path .. "/" .. source .. "/**.masm" + } +end + +local function auBlockProjectKeyEval(processor, value, tasksMask) + if (type(object) == "string") then + auEval(object) + return + end + + __pushFilter(value, nil, function(value) + __pRunTasks(processor, value, auProjectBlockHandlers, kGenericTasks, true) + end) +end + +local function auBlockProjectKeyDefines(processor, value) + __pushFilter(value, "value", defines) +end + +local function auBlockProjectKeyImplDefines(processor, value) + __pushFilter(value, "value", defines) +end + +local function auBlockProjectKeyStaticImplDefines(processor, value) + if (not processor:getMeta().isStatic) then + return + end + __pushFilter(value, "value", defines) +end + +local function auBlockKeyFeature(processor, value) + __pushFilter(value, "value", auAddFeature, true) +end + +local function auBlockProjectKeyImplIncludes(processor, value) + __pushFilter(value, "value", _includeDirectoryEx) +end + +local function auBlockProjectKeyClangIgnore(processor, value) + if (targetingCmake) then + filter {"toolset:clang"} + end + + disablewarnings(value) + + filter {} +end + +local function auBlockProjectKeyMSVCIgnore(processor, value) + if (targetingCmake) then + filter {"toolset:msc"} + end + + disablewarnings(value) + + filter {} +end + +local function _auBlockProjectKeyLinks(value, processor) +end + +local function auBlockProjectKeyLinks(processor, value) + print("LINK?", json.encode(value)) + __pushFilter(value, "value", function(val) + links(__translate(processor, val)) + end, true) +end + +local function auHeaderProjectKeyIncludeDepends(processor, includeProject) + -- Projects that include + __handleIncludeCallback(processor, includeProject, function(processorName, hard) + auIncludeProject(__translate(processor, processorName), not hard) + end) +end + +local function auHeaderProjectKeyLinkDepends(processor, includeProject) + __handleIncludeCallback(processor, includeProject, function(processorName, hard) + auLinkProject(__translate(processor, processorName), not hard) + end) +end + + +local function auBlockProjectKeyBuildEvent(processor, value) + __pushFilter(value, nil, function(value) + local type = "" + + if (value.lua) then + type = "lua" + elseif (value.bin) then + type = "bin" + else + return + end + + auAddBuildAction(obj.when, type, value[type], value.isCwdProjRoot) + end, processor) +end + +local function handleActionCommon(action, cb, ...) + local _if = action["if"] + local _then = action["then"] + + print("EVAL?") + --_G["info"] = info + + if (_if) then + local val = auEval("return " .. _if) + if (not val) then + return + end + + if (_then) then + cb(_then, ...) + end + else + if (not action.eval) then + action.eval = action["then"] + end + + print("RUN?", json.encode(action.eval)) + if (action.eval) then + cb(action.eval, ...) + end + end + + --_G["info"] = nil +end + +local function auBlockProjectKeyBuildAction(processor, value, mask) + __pushFilter(value, nil, function(value) + handleActionCommon(value, function(thenblock) + print("eval... ", json.encode(thenblock)) + auBlockProjectKeyEval(processor, thenblock, auProjectBlockHandlers) + end) + end, processor) +end + + +local function handleDepends(processor, dep, soft) + dep = processor:translateDep(dep) + local macro = ("_auhas_" .. dep):upper():gsub("%-", "_"); + + if (isProjectLoaded(dep)) then + defines(macro .. "=1") + auLinkAndRefProject(dep, soft) + else + defines(macro .. "=0") + if (not soft) then + fatal("missing project: ", dep) + end + end +end + +local function auBlockProjectKeyDepends(processor, value) + __pushFilter(value, "value", function(obj) + auForEach(obj, function(re) + handleDepends(processor, re, false) + end) + end, processor) +end + +local function auBlockProjectKeyLua(processor, script) + auUserRequire(script) +end + +local function auBlockProjectKeyImplNoRootInclude() + -- this is just a stub. + -- set me, the "noRootInclude" key to 'true' if you do not want the processor root to be include in the include dir search path +end + +local auProjectHeaderHandlers = +{ + linkDepends = auHeaderProjectKeyLinkDepends, + includeDepends = auHeaderProjectKeyIncludeDepends +} + +local kAllProjectHeaders = +{ + "linkDepends", "includeDepends" +} + +auProjectBlockHandlers = +{ + links = auBlockProjectKeyLinks, + lua = auBlockProjectKeyLua, + sourcePaths = auBlockProjectKeySourcePaths, + sources = auBlockProjectKeySources, + includes = auBlockProjectKeyIncludes, + include = auBlockProjectKeyIncludes, + excludes = auBlockProjectKeyExcludes, + eval = auBlockProjectKeyEval, + defines = auBlockProjectKeyDefines, + impDefines = auBlockProjectKeyImplDefines, + implDefines = auBlockProjectKeyImplDefines, + implementationDefines = auBlockProjectKeyImplDefines, + staticImpDefines = auBlockProjectKeyStaticImplDefines, + impInclude = auBlockProjectKeyImplIncludes, + implInclude = auBlockProjectKeyImplIncludes, + impIncludes = auBlockProjectKeyImplIncludes, + implIncludes = auBlockProjectKeyImplIncludes, + clangIgnore = auBlockProjectKeyClangIgnore, + msvcIgnore = auBlockProjectKeyMSVCIgnore, + depends = auBlockProjectKeyDepends, + require = auBlockProjectKeyRequire, + noRootInclude = auBlockProjectKeyImplNoRootInclude, + events = auBlockProjectKeyBuildEvent, + actions = auBlockProjectKeyBuildAction, + features = auBlockKeyFeature +} + + kGenericTasks = {"sourcePaths", "includes","include", "sources", + "impDefines", "implDefines", "implementationDefines", + "impInclude", "implInclude", "impIncludes", "implIncludes", "clangIgnore", + "msvcIgnore", "excludes", "depends", "require", + "eval", "lua", "events", "actions", "staticImpDefines", "features", + "links" + } + +local kReferenceTasks = {"eval", "includes", "include"} --, "features"} + + +__pRunTasks = function(processor, object, map, tasks, inc) + auForEachKV(tasks, function(na, key) + local value = object[key] + if (not value) then + return + end + + map[key](processor, value, tasks, inc) + end) +end + +local function __pRunLinkTasks(processor, object) + __pRunTasks(processor, object, auProjectBlockHandlers, { "links", "depends"}) +end + +local function __pRunIncludeTasks(processor, object, isIncludeLocalProject) + __pRunTasks(processor, object, auProjectBlockHandlers, kReferenceTasks, isIncludeLocalProject) + + if (object.type:lower() == "aurora") then + _includeDirectoryEx(processor:getMeta().path .. "/Include") + elseif (object.type:lower() == "lazy_free") then + object.noRootInclude = false + elseif (object.type:lower() == "root") then + _includeDirectoryEx(processor:getMeta().path) + end +end + +local function ___pRunIncludeTasks(processor, object, isIncludeLocalProject) + __pRunIncludeTasks(processor, object, isIncludeLocalProject) + if (not object.noRootInclude) then + _includeDirectoryEx(processor:getMeta().path, isIncludeLocalProject) + end +end + +local function __pRunMainTasks(processor, object) + __pRunIncludeTasks(processor, object, true) + __pRunTasks(processor, object, auProjectBlockHandlers, kGenericTasks, true) + if (not object.noRootInclude) then + _includeDirectoryEx(processor:getMeta().path, isIncludeLocalProject) + end +end + +return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers, { + runProjectBlock = __pRunMainTasks, + runProjectLink = __pRunLinkTasks, + runProjectRef = ___pRunIncludeTasks +}) \ No newline at end of file diff --git a/Core/Legacy/aurora.lua b/Core/Legacy/aurora.lua index dc3b045..95baebc 100644 --- a/Core/Legacy/aurora.lua +++ b/Core/Legacy/aurora.lua @@ -65,6 +65,7 @@ function addVisit(ina) path = ina.path, type = ina.type, out = ina.out, + options = ina.options, translations = ina.translations -- OPT: dictionary of dependency maps } @@ -79,7 +80,8 @@ function addVisit(ina) projectType = args.type, out = args.out, name = args.name, - translations = args.translations + translations = args.translations, + options = args.options } extendInfo(info) @@ -112,6 +114,8 @@ function addVisit(ina) return end + auRequire("Core").project.expendBaseProcessor(project) + projectsprocessor[info.name] = project end @@ -121,7 +125,9 @@ function addScript(ina) script = ina.script, path = ina.path, type = ina.type, - out = ina.out + out = ina.out, + options = ina.options, + translations = ina.translations } local path = normalizeSourceRoot(args.path) @@ -133,7 +139,9 @@ function addScript(ina) namespace = args.namespace, path = path, projectType = args.type, - out = args.out + out = args.out, + translations = args.translations, + options = args.options } extendInfo(info) @@ -395,18 +403,23 @@ function importAndLinkProject(dep, soft) auFatal("missing project: ", dep) end - iface:handleReference() + local circular = isWeakCircularReference(dep) + iface:handleReference(isWeakCircularReference(dep)) + if (getProjectInfo(getCurrentProjectName()).isStatic) then + return true + end + iface:handleLink() return true end function includeAuProject(dep, soft) local proj = _G["projectsprocessor"][dep] + if (not proj) then if (soft) then return false end - auFatal("Missing project", dep) end local iface = proj.processor @@ -430,7 +443,7 @@ function linkAuProject(dep, soft) auFatal("Missing project", dep) end - local iface = proj.processor + local processor = proj.processor if (not isProjectLoaded(dep)) then if (soft) then return false @@ -438,13 +451,16 @@ function linkAuProject(dep, soft) auFatal("missing project: ", dep) end - iface:handleLink() + if (not processor:getMeta().isStatic) then + processor:handleLink() + end return true end -- executes inline under iprocessor::process function addFeature(feature) + print("adding feature ", feature) local script = auGetRoot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua" if (not os.isfile(script)) then diff --git a/Core/Legacy/jsonProcessor.lua b/Core/Legacy/jsonProcessor.lua index 630e0a9..c0be156 100644 --- a/Core/Legacy/jsonProcessor.lua +++ b/Core/Legacy/jsonProcessor.lua @@ -15,20 +15,14 @@ function JsonProcessor(info) result.name = info.name local translateDep = function(this, dep) - if (this.info.translations) then - local override = this.info.translations[dep] - if (override) then - dep = override - end - end - - return dep + return this:translateDep(dep) end + -- ported local includeDirEx = function(path, incFiles) includedirs(path) - if (not incFiles) then + if (not incFiles) then return end @@ -213,11 +207,15 @@ function JsonProcessor(info) local handleReference = function(this, circular) local type = this.result.type + --print("handleReference ", this.info.name) + if ((type:lower() == "utility") or (type:lower() == "blank")) then return end + --print("handleReference function ", this.info.name, getCurrentProjectName()) + local cur = nil if (circular) then cur = getProjectInfo(getCurrentProjectName()) @@ -297,9 +295,9 @@ function JsonProcessor(info) } if (result.noLink) then - print("noLink is deprecated. Use projectType: None") - prj_.projectType = "None" - info.projectType = "None" + print("noLink is deprecated. Use projectType: none") + prj_.projectType = "none" + info.projectType = "none" end if (result.type:lower() == "aurora") then @@ -345,21 +343,7 @@ function JsonProcessor(info) _G["_linkingcur"][name] = true handleInclude(a, true) - - --auForEach(result.defines, defines) - --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 - - local handleFeature = function(feature) - addFeature(feature) - end - - local handleRequire = function(dep) - dep = translateDep(a, dep) - - dependson(dep) - end - + local handleDepends = function(dep, this, soft) dep = translateDep(this, dep) @@ -392,27 +376,6 @@ function JsonProcessor(info) end end - local handleExcludes = function(excludes, path) - removefiles(excludes) - end - - local handleSources = function(source, path) - --files(path .. "/" .. source) - files(source) - end - - local handleSourcePaths = function(source, path) - files - { - path .. "/" .. source .. "/**.*pp", - path .. "/" .. source .. "/**.inl", - path .. "/" .. source .. "/**.c", - path .. "/" .. source .. "/**.cc", - path .. "/" .. source .. "/**.h", - path .. "/" .. source .. "/**.masm" - } - end - info.m4_files = {} local addM4Defines = function(obj) @@ -428,22 +391,9 @@ function JsonProcessor(info) end local processJsonBlock = function(object) - auForEach(object.features, handleFeature, info.path) - auForEach(object.sourcePaths, handleSourcePaths, info.path) - auForEach(object.excludes, handleExcludes, info.path) - auForEach(object.sources, handleSources, info.path) - auForEach(object.depends, handleDepends, a, false) + auRequire("Core/JSON/JSON").projectHandlers.runProjectBlock(a, object) + auForEach(object["soft-depends"], handleDepends, a, true) - auForEach(object.impDefines, defines) - auForEach(object.links, links) - if (usingMSVC) then - auForEach(object.msvcIgnore, disablewarnings) - end - if (usingClang) then - auForEach(object.clangIgnore, disablewarnings) - end - auForEach(object.impInclude, handleUserJsonInclude, info.path, true) - -- this is ran twice. i dont care auForEach(object.unpack, runCopies, info.path, info.name) addM4Defines(object.m4Defines) end @@ -466,8 +416,6 @@ function JsonProcessor(info) handleActionCommon(action, handleEval) end - auForEach(result.require, handleRequire) - if (not isUtility) then processJsonBlock(result) @@ -476,13 +424,6 @@ function JsonProcessor(info) end end - auForEach(result.actions, handleAction, info.path) - auForEach(result.events, handleBuildEvent, info.path) - - if (info.isStatic) then - auForEach(result.staticImpDefines, defines) - end - if (result.valaSrc) then local sources = result.valaSrc local gir = concatArrays(auValaGirs, result.valaGirs) diff --git a/Core/Target/Target.lua b/Core/Target/Target.lua index d9be88a..ec60d06 100644 --- a/Core/Target/Target.lua +++ b/Core/Target/Target.lua @@ -27,9 +27,6 @@ local function start() addTarget("target", Aurora.Platforms, _auCurrentPlatforms) addTarget("target", Aurora.Architectures, _auCurrentArchs) addTarget("flag", Aurora.Flags, _auCurrentFlags) - - _auExtendedConfig = #_auCurrentPlatforms > 1 - _auExtendedArch = #_auCurrentArchs > 1 end local function startProject() @@ -57,6 +54,7 @@ local function startSolution() end configurations(configs) + platforms(_auCurrentPlatforms) end local function auFilterForArchs(callback, ...) @@ -102,6 +100,7 @@ local function auFilterOf(configFilter, ...) local andOptions = {} local test = function(val, orArray, notArray) + if (orArray) then if (type(orArray) == "string") then if (orArray ~= val) then @@ -109,7 +108,7 @@ local function auFilterOf(configFilter, ...) end elseif (#orArray > 0) then if (not auContains(orArray, val)) then - return + return end end end @@ -129,30 +128,33 @@ local function auFilterOf(configFilter, ...) return true end + -- TODO: clean up + local validPlatforms = {} + local validArchs = {} + local validConfigs = {} + + auForEach(Aurora.Settings.aNamesOfConfigs, function(config) + if (not test(config, configFilter.configs, configFilter.notConfigs)) then + return + end + + table.insert(validConfigs, config) + end) + + auForEach(_auCurrentArchs, function(arch) + if (not test(arch, configFilter.archs, configFilter.notArchs)) then + return + end + + table.insert(validArchs, arch) + end) + auForEach(_auCurrentPlatforms, function(platform) - auForEach(_auCurrentArchs, function(arch) - auForEach(Aurora.Settings.aNamesOfConfigs, function(config) + if (not test(platform, configFilter.platforms, configFilter.notPlatforms)) then + return + end - if (not test(config, configFilter.configs, configFilter.notConfigs)) then - return - end - - if (not test(arch, configFilter.archs, configFilter.notArchs)) then - return - end - - if (not test(platform, configFilter.platforms, configFilter.notPlatforms)) then - return - end - - if (not _auExtendedConfig and not _auExtendedArch) then - table.insert(ret, "configurations:" .. config) - else - table.insert(ret, "configurations:" .. platform .. arch .. config) - end - - end) - end) + table.insert(validPlatforms, platform) end) auForEach(configFilter.options, function(option) @@ -162,8 +164,42 @@ local function auFilterOf(configFilter, ...) auForEach(configFilter.notOptions, function(option) table.insert(andOptions, "not options:" .. option) end) + + local supportedArchs = {} + auForEach(validArchs, function(arch) + table.insert(supportedArchs, "architecture:" .. auFetchGlobal("Architectures")[arch].architecture) + end) + if (#supportedArchs == 0) then + table.insert(supportedArchs, "platforms:none") + end + ret = table.concat(supportedArchs, " or ") - return auConcatVararg({table.concat(ret, " or ")}, andOptions, ...) + local supportedPlatforms = {} + auForEach(validPlatforms, function(platform) + table.insert(supportedPlatforms, "platforms:" .. platform) + end) + if (#supportedPlatforms == 0) then + table.insert(supportedPlatforms, "platforms:none") + end + ret = auConcatVararg(ret, {table.concat(supportedPlatforms, " or ")}) + + + local supportedConfigs = {} + auForEach(validConfigs, function(config) + table.insert(supportedConfigs, "configurations:" .. config) + end) + if (#supportedConfigs == 0) then + table.insert(supportedConfigs, "platforms:none") + end + ret = auConcatVararg(ret, {table.concat(supportedConfigs, " or ")}) + + --local ret = {table.concat(ret, " or ")} + if (#andOptions) then + ret = auConcatVararg(ret, andOptions) + end + + --print(json.encode(configFilter), json.encode(ret)) + return auConcatArrays(ret, ...) end return { diff --git a/Core/project.lua b/Core/project.lua index 25bbdc9..2cc45de 100644 --- a/Core/project.lua +++ b/Core/project.lua @@ -152,7 +152,7 @@ local function configureProjectErrors() "4251", -- MSVC's hurrdurr abis will break if you dynamically link classes -- counter: sod off again. we have full control of the build process, and we only link against -- dynamic c/stl runtimes. which brainlet thought this was a good idea? - -- even microsofts own documentation dont state what is guaranteed to be safe. + -- even microsofts own documentation doesn't state what is guaranteed to be safe. -- dont mix optimizations, mitigation flags, and so on. -- rtti works; the stl doesn't abuse inline/module specific globals; who cares? @@ -266,6 +266,37 @@ local function configureProjectForLd(prj) end) end +local function processorDispatchRun(processor) + + processor:process() + -- TODO: m4/protobuf/etc support +end + +local function processorTranslateDep(this, dep) + if (not this._info.translations) then + return dep + end + + local override = this._info.translations[dep] + if (override) then + return override + end + + return dep +end + +local function processorGetInfo(this) + return this._info +end + +local function expendBaseProcessor(prj) + prj.processor._info = prj.info + prj.processor.dispatch = processorDispatchRun + prj.processor.translateDep = processorTranslateDep + prj.processor.getInfo = processorGetInfo + prj.processor.getMeta = processorGetInfo +end + local function setupProject(prj) print("project", prj.name) @@ -377,6 +408,7 @@ end return { + expendBaseProcessor = expendBaseProcessor, setupProjectCompat = setupProjectCompat, startProject = setupProject } \ No newline at end of file diff --git a/Public/api.lua b/Public/api.lua index f0b0198..5767d0b 100644 --- a/Public/api.lua +++ b/Public/api.lua @@ -30,7 +30,7 @@ end function auStartProject(project) auStart() - auRequire("Core").project.start(project) + auRequire("Core").project.startProject(project) end function auFilterForPlatforms(callback, ...) @@ -45,6 +45,10 @@ function auFilterForConfigPlatforms(callback, ...) target.auFilterForConfigPlatforms(callback, ...) end +function auAddVisit(...) + addVisit(...) +end + -- Returns an array of filter tables where each optional table is checked against the current combination of config/platform/arch -- Varargs are logical anded with the final filter table -- in object -> defer to objects.lua @@ -72,4 +76,32 @@ end function auGetSetting(name) return Aurora.Settings[name] +end + +_G.filterStack = {} +function auFilter(filter) + local tbl = _G.filterStack; + if (not filter or #filter == 0) then + table.remove(tbl, #tbl) + else + table.insert(tbl, filter) + end + --print("FILTERING ", json.encode(tbl), json.encode(filter)) + _G.filter(tbl) +end + +function auLinkProject(...) + linkAuProject(...) +end + +function auIncludeProject(...) + includeAuProject(...) +end + +function auLinkAndRefProject(...) + importAndLinkProject(...) +end + +function auAddFeature(...) + addFeature(...) end \ No newline at end of file diff --git a/Public/objects.lua b/Public/objects.lua index 6452062..f0b6b39 100644 --- a/Public/objects.lua +++ b/Public/objects.lua @@ -1,10 +1,12 @@ +-- This file serves as pseudo-documentation for json schemas and internal object requirements + function auEnum(...) return nil end function auBuildActionO() return { - stage = "post" -- pre, post, + stage = "post", -- pre, post, -- filter: ..., -- lua/bin/targetName/command: relative path - lua script; relative path - executable; project name; command line -- args: lua private passthrough; binary or target name command args diff --git a/README_Developers.txt b/README_Developers.txt index 6d89dcb..b2b09e5 100644 --- a/README_Developers.txt +++ b/README_Developers.txt @@ -18,7 +18,7 @@ Entry -> ./Public/base.lua # User Scripts We decided that, instead of gluing together old nasty pipelines, we would write simple JSON files to quickly add -and configure a C++ project for the minimum desired outcome. We started writing JSON files around specific project +and configure C++ projects for the minimum desired outcome. We started writing JSON files around specific project requirements. Overtime, we wish to unify everything, and extend these scripts to testing and deployment. For now, they serve as a simple way to describe a C/C++'s project structure. Advanced users can write user scripts in native lua, using an untouched premake api; however, our experimental clang driver will be limited in its support for your diff --git a/Utilities/Utilities.lua b/Utilities/Utilities.lua index edc2b46..b661a19 100644 --- a/Utilities/Utilities.lua +++ b/Utilities/Utilities.lua @@ -11,4 +11,11 @@ require("./base64") require("./requireAbs") require("./merge") require("./settings") -require("./contains") \ No newline at end of file +require("./contains") + +function table.copy(t) + local u = { } + for k, v in pairs(t) do u[k] = v end + --setmetatable(u, getmetatable(t)) + return u +end \ No newline at end of file diff --git a/Utilities/isArray.lua b/Utilities/isArray.lua index 0c3c1ff..63a3f15 100644 --- a/Utilities/isArray.lua +++ b/Utilities/isArray.lua @@ -3,7 +3,7 @@ function auIsArray(table) local max = 0 local count = 0 - if (type(object) ~= "table") then + if (type(table) ~= "table") then return false end diff --git a/win_x64.bat b/win_x64.bat index 2530d88..772d467 100644 --- a/win_x64.bat +++ b/win_x64.bat @@ -1,4 +1,4 @@ @echo off cd Public -premake5 vs2019 --target-win32 --target-x86_64 \ No newline at end of file +premake5 vs2022 --target-win32 --target-x86_64 \ No newline at end of file diff --git a/win_x86.bat b/win_x86.bat index 62bdc25..ec26a41 100644 --- a/win_x86.bat +++ b/win_x86.bat @@ -1,4 +1,4 @@ @echo off cd Public -premake5 vs2019 --target-win32 --target-x86_32 \ No newline at end of file +premake5 vs2022 --target-win32 --target-x86_32 \ No newline at end of file