diff --git a/Actions/buildAction.lua b/Actions/buildAction.lua index cb1f134..3ea623e 100644 --- a/Actions/buildAction.lua +++ b/Actions/buildAction.lua @@ -39,7 +39,7 @@ local getPremakeExec = function() return premake_exe end -local addBuildCommand = function(when, scriptType, path) +local addBuildCommand = function(when, scriptType, path, cwdRelToProject) local scriptPath = path local cwd = getroot() @@ -51,11 +51,16 @@ local addBuildCommand = function(when, scriptType, path) command = command .. getPremakeExec() command = command .. " --file=\"" .. os.realpath(cwd .. "/Build_Scripts/Actions/buildActionBootstrap.lua") .. "\"" - command = command .. " --actualcwd=\"" .. os.realpath(cwd) .. "\"" command = command .. " --project_name=\"%{prj.name}\"" command = command .. " --project_arch=\"%{cfg.architecture}\"" command = command .. " --project_platform=\"%{cfg.system}\"" + if (cwdRelToProject) then + command = command .. " --actualcwd=\"" .. cur.path .. "\"" + else + command = command .. " --actualcwd=\"" .. os.realpath(cwd) .. "\"" + end + local cur = getProjectInfo(getCurrentProjectName()) if (cur and cur.path) then command = command .. " --project_root=\"" .. cur.path .. "\"" diff --git a/Actions/buildActionBootstrap.lua b/Actions/buildActionBootstrap.lua index b2e749a..4c88307 100644 --- a/Actions/buildActionBootstrap.lua +++ b/Actions/buildActionBootstrap.lua @@ -48,38 +48,24 @@ newoption description = "" } -local binScript = _OPTIONS["binscript"] -if (binScript) then - local command = ""; +newoption +{ + trigger = "cwd_project_root", + description = "" +} - local cwd =_OPTIONS["actualcwd"] - if (cwd) then - command = command .. string.format("cd \"%s\" && ", cwd:gsub("\\","\\\\")) - end - command = command .. binScript - - os.exit(os.execute(command)) +local cwd =_OPTIONS["actualcwd"] +if (cwd) then + os.chdir(cwd) end -local getRoot = function() - local path = os.realpath(os.getcwd()) - if (path:ends("/") or path:ends("\\")) then - path = path:sub(1, #path - 1) - end +local binScript = _OPTIONS["binscript"] +if (binScript) then + os.exit(os.execute(binScript)) +end - if (path:ends("Actions")) then - path = path:sub(1, #path - #"/Actions") - end - - if (path:ends("Build_Scripts")) then - path = path:sub(1, #path - #"/Build_Scripts") - end - - return path -end - -_G["_overloadRoot"] = getRoot() +_G["_overloadRoot"] = _OPTIONS["actualcwd"] _G["build"] = { diff --git a/Boilerplate/jsonProcessor.lua b/Boilerplate/jsonProcessor.lua index ebc0d49..b05c391 100644 --- a/Boilerplate/jsonProcessor.lua +++ b/Boilerplate/jsonProcessor.lua @@ -55,7 +55,7 @@ function JsonProcessor(info) tryAddDefine(result.defines) end - local handlePostBuild = function(obj) + local handleBuildEvent = function(obj) local type = "" if ( obj.lua) then type = "lua" @@ -65,7 +65,7 @@ function JsonProcessor(info) return end - addBuildAction(obj.when, type, obj[type]) + addBuildAction(obj.when, type, obj[type], obj.isCwdProjRoot) end local handleDllImportMaybe = function(this) @@ -264,8 +264,7 @@ function JsonProcessor(info) end forEach(result.actions, handleAction, info.path) - forEach(result.postBuild, handlePostBuild, info.path) - forEach(result.preBuild, handlePreBuild, info.path) + forEach(result.events, handleBuildEvent, info.path) end diff --git a/JSON Schema.json b/JSON Schema.json index c7c94aa..81c75ec 100644 --- a/JSON Schema.json +++ b/JSON Schema.json @@ -120,33 +120,11 @@ } } }, - "postBuild": + "isCwdProjRoot": { - "type": "array", - "items": - { - "type": "object", - "properties": - { - "when": - { - "type": "string", - "enum": ["pre", "post"] - }, - "lua": - { - "type": "string", - "description": "executes lua script under Build_UserScripts/%s.lua" - }, - "bin": - { - "type": "string", - "description": "shell script" - } - } - } + "type": "boolean" }, - "preBuild": + "events": { "type": "array", "items":