diff --git a/Core/Actions/Actions.lua b/Core/Actions/Actions.lua index 53ecfb3..a158f61 100644 --- a/Core/Actions/Actions.lua +++ b/Core/Actions/Actions.lua @@ -75,6 +75,7 @@ local getPremakeExec = function() end local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args) + local scriptPath = path local cwd = auGetRoot() @@ -97,20 +98,16 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args) command = command .. getPremakeExec() local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts - local bootstrapPrefix = _G.path.getrelative(Aurora.Settings.sAbsCompilerWd .. "/" .. auGetCurrentProjectName(), Aurora.Settings.sAbsRepoScripts) - local bootstrap = bootstrapPrefix .. "/Core/Actions/buildActionBootstrap.lua" + local bootstrap = Aurora.Settings.sAbsScripts .. "/Core/Actions/buildActionBootstrap.lua" + command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\"" - if (cdAware) then - command = command .. " --file=\"" .. bootstrap .. "\"" - else - command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\"" - end --command = command .. " --project_name=\"%{prj.name}\"" command = command .. " --project_name=\"" .. cur.name .. "\"" command = command .. " --project_type=\"" .. cur.projectType .. "\"" + command = command .. " --project_config=\"%{cfg.longname}\"" command = command .. " --project_arch=\"%{cfg.architecture}\"" - command = command .. " --project_platform=\"%{cfg.system}\"" + command = command .. " --project_platform=\"%{cfg.platform}\"" -- Aurora.Settings could take up too much of the win32 max command line buffer (8191 characters) -- This seems like a lot, but it should be well within the 9k limit @@ -152,18 +149,31 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args) cliArgs = " " .. argsEscaped end + if (args) then + command = command .. " --additional=\"" .. base64.encode(args) .. "\"" + end + if (scriptType == "lua") then + if (os.isfile(Aurora.Settings.sAbsRepoScripts .. path)) then command = command .. " --luascript=\"" .. path .. "\"" else command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\"" end - if (args) then - command = command .. " --additional=\"" .. base64.encode(args) .. "\"" - end + elseif (scriptType == "bin") then command = command .. " --binscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. cliArgs .. "\"" + + elseif (scriptType == "cmd") then + command = command .. " --cmd=\"" .. base64.encode(path) .. "\"" + + elseif (scriptType == "project") then + + command = command .. " --projectbins_=\"%{cfg.targetdir}\"" + command = command .. " --projectname_=" .. path + command = command .. " --projectnameex_=" .. tostring(Aurora.Settings.bDefinePartialABIInTargetName) + end if (when == "post") then diff --git a/Core/Actions/buildActionBootstrap.lua b/Core/Actions/buildActionBootstrap.lua index 5c3ca70..f006f5f 100644 --- a/Core/Actions/buildActionBootstrap.lua +++ b/Core/Actions/buildActionBootstrap.lua @@ -7,6 +7,13 @@ function auFetchGlobal(name) return ret end +local function escapeBinaryPath(path) + if (os.host() == "windows") then + return "\"" .. path .. "\"" + end + return path:gsub(" ", "\\ ") +end + require("./../../Utilities/Utilities") local triggers = @@ -22,7 +29,12 @@ local triggers = "project_root", "additional", "project_type", - "luaabsscript" + "luaabsscript", + "projectname_", + "projectbins_", + "projectnameex_", + "project_config", + "project_name" } auForEach(triggers, function(trigger) @@ -35,19 +47,27 @@ end) local settings = _OPTIONS["settings"] if (settings) then + Aurora.Settings = json.decode(base64.decode(settings)) - require("./../../Public/Paths") + require("./../../Public/paths") end +require("./../Target/platform") + local preconfig = path.join(Aurora.Settings.sAbsRoot, "preconfig.lua") -if (os.isfile(preconfig) then +if (os.isfile(preconfig)) then auRequireAbs(preconfig) end local projRoot = path.join(Aurora.Settings.sAbsRoot, _OPTIONS["project_root"] or "./") -local cwd =_OPTIONS["cwd"] +local projectBins = _OPTIONS["projectbins_"] +if (projectBins) then + projectBins = os.realpath(path.join(projRoot, projectBins)) +end + +local cwd = _OPTIONS["cwd"] if (cwd) then os.chdir(projRoot) else @@ -61,7 +81,7 @@ end local binSuffx = "" if (args) then - binSuffx = " " .. binSuffx + binSuffx = " " .. args end local binScript = _OPTIONS["binscript"] @@ -69,23 +89,44 @@ if (binScript) then os.exit(os.execute(path.join(Aurora.Settings.sAbsRoot, binScript) .. binSuffx)) end - local cmd = _OPTIONS["cmd"] if (cmd) then - os.exit(os.execute(cmd .. binSuffx)) + os.exit(os.execute(base64.decode(cmd))) end local projName = _OPTIONS["project_name"] local projType = _OPTIONS["project_type"] local projPlatform = _OPTIONS["project_platform"] +local projCfg = _OPTIONS["project_config"] local projArch = _OPTIONS["project_arch"] -local targetName = projName .. "." .. projPlatform .. "." .. projArch +if (string.find(projCfg, "|")) then + projCfg = projCfg:match("([^,]+)|([^,]+)") +end + +local targetName = projName .. "." .. projCfg .. "." .. projPlatform .. "." .. projArch local fileName = targetName -local platform = Aurora.Platforms[platformName] +local platform = Aurora.Platforms[projPlatform] if (platform) then - fileName = fileName .. (platform.exts or {})[type] or "" + fileName = fileName .. (platform.exts or {})[projType] or "" +end + +if (projectBins) then + local projectName = _OPTIONS["projectname_"] + local projectNameEx = _OPTIONS["projectnameex_"] == "true" + local extension = (platform.exts or {})["ConsoleApp"] + + local binName = projectName + + if (projectNameEx) then + binName = string.format("%s.%s.%s.%s", binName, projCfg, projPlatform, projArch) + end + + binName = binName .. extension + local cmd = escapeBinaryPath(path.join(projectBins, binName)) .. binSuffx + + os.exit(os.execute(cmd)) end auBuild = @@ -101,12 +142,10 @@ auBuild = root = cwd } -_G["build"] = auBuild - local luaScript = _OPTIONS["luascript"] local luaAbsScript = _OPTIONS["luaabsscript"] if (luaScript) then - auRequireAbs(os.realpath(build.root .. Aurora.Settings.sRelRepoScripts .. "/" .. luaScript)) + auRequireAbs(path.join(Aurora.Settings.sAbsRepoScripts, luaScript)) elseif (luaAbsScript) then auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript)) end diff --git a/Core/JSON/jsonProjectHandlers.lua b/Core/JSON/jsonProjectHandlers.lua index caff221..12c3ca3 100644 --- a/Core/JSON/jsonProjectHandlers.lua +++ b/Core/JSON/jsonProjectHandlers.lua @@ -221,11 +221,15 @@ local function auBlockProjectKeyBuildEvent(processor, value) type = "lua" elseif (value.bin) then type = "bin" + elseif (value.project) then + type = "project" + elseif (value.cmd) then + type = "cmd" else return end - auAddBuildAction(obj.when, type, value[type], value.isCwdProjRoot) + auAddBuildAction(value.when, type, value[type], value.isCwdProjRoot, value.args) end, processor) end @@ -381,7 +385,6 @@ local auProjectRefHandlers = { linkDepends = auHeaderProjectKeyLinkDepends, eval = auBlockProjectKeyEval, - events = auBlockProjectKeyBuildEvent, actions = auBlockProjectKeyBuildAction, links = auBlockProjectKeyLinks, defines = auBlockProjectKeyDefines, diff --git a/Core/main.lua b/Core/main.lua index 2cd5923..7d25968 100644 --- a/Core/main.lua +++ b/Core/main.lua @@ -9,6 +9,7 @@ _auNamespacesEmitted = {} _auResolvedDep = {} _auCurrentProject = {} _auCurrentBaseProject = {} +_auFatalMsg = {} ------------------------------------------------------- -- utils @@ -321,6 +322,7 @@ processProject = function(name, required, noNs) _auFatalMsg = {} _auFatalMsg["processing project"] = a.info.name a.processor:process() + _auFatalMsg = {} end) -- cont @@ -409,10 +411,9 @@ local function includeAuProject(dep, soft) end pushProject(a, function() - _auFatalMsg = {} _auFatalMsg["processing project ref"] = a.info.name - - processor:handleReference(isWeakCircularReference(dep)) + processor:handleReference(isWeakCircularReference(dep)) + _auFatalMsg["processing project ref"] = nil end) return true end @@ -443,9 +444,9 @@ local function linkAuProject(dep, soft) --if (not processor:getMeta().isStatic) then pushProject(a, function() - _auFatalMsg = {} _auFatalMsg["processing project link"] = a.info.name processor:handleLink() + _auFatalMsg["processing project link"] = nil end) --end return true diff --git a/Public/api.lua b/Public/api.lua index c18efde..8503ad4 100644 --- a/Public/api.lua +++ b/Public/api.lua @@ -8,7 +8,7 @@ function auAddBuildAction(...) buildAction(...) end -function auAddBuildAction(...) +function auAddBuildActionO(...) local type = { -- stage: pre, post -- filter: ... diff --git a/Public/objects.lua b/Public/objects.lua index f0b6b39..a789ecf 100644 --- a/Public/objects.lua +++ b/Public/objects.lua @@ -8,7 +8,7 @@ function auBuildActionO() return { stage = "post", -- pre, post, -- filter: ..., - -- lua/bin/targetName/command: relative path - lua script; relative path - executable; project name; command line + -- lua/bin/project/cmd: relative path - lua script; relative path - executable; project name; command line -- args: lua private passthrough; binary or target name command args cwd = "sln" -- sln, prj } diff --git a/Public/paths.lua b/Public/paths.lua index 2f1e2ad..eca1a14 100644 --- a/Public/paths.lua +++ b/Public/paths.lua @@ -1,3 +1,4 @@ +print("hello paths") if (not Aurora.Settings.sAbsRoot) then Aurora.Settings.sAbsRoot = os.realpath(os.getcwd() .. "/../..") .. "/" @@ -21,11 +22,17 @@ end local function resolvePathAbs(key) local path = resolvePathAbs2(key, "sAbsRoot") + + if (not path) then + return + end + if (not os.isdir(path)) then os.mkdir(path) end end + resolvePathAbs("sRelDebug") resolvePathAbs("sRelStage") resolvePathAbs("sRelShip") @@ -34,6 +41,7 @@ resolvePathAbs("sRelSymbols") resolvePathAbs("sRelLinkLibs") resolvePathAbs("sRelCompilerWd") + local function resolveAuPathAbs(key) return resolvePathAbs2(key, "sAbsAuRoot") end