summaryrefslogtreecommitdiff
path: root/scripts/context/lua/mtx-context.lua
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/context/lua/mtx-context.lua')
-rw-r--r--scripts/context/lua/mtx-context.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua
index c3454309f..963afcec9 100644
--- a/scripts/context/lua/mtx-context.lua
+++ b/scripts/context/lua/mtx-context.lua
@@ -678,6 +678,7 @@ function scripts.context.run(ctxdata,filename)
local a_purgeall = getargument("purgeall")
local a_purgeresult = getargument("purgeresult")
local a_global = getargument("global")
+ local a_runpath = getargument("runpath")
local a_timing = getargument("timing")
local a_profile = getargument("profile")
local a_batchmode = getargument("batchmode")
@@ -739,6 +740,31 @@ function scripts.context.run(ctxdata,filename)
formatfile, scriptfile = resolvers.locateformat(formatname)
end
--
+ local runpath = a_runpath or analysis.runpath
+ if type(runpath) == "string" and runpath ~= "" then
+ runpath = resolvers.resolve(runpath)
+ local currentdir = dir.current()
+ if not lfs.isdir(runpath) then
+ if dir.makedirs(runpath) then
+ report("runpath %a has been created",runpath)
+ else
+ report("error: runpath %a cannot be created",runpath)
+ os.exit()
+ end
+ end
+ if lfs.chdir(runpath) then
+ report("changing to runpath %a",runpath)
+ else
+ report("error: changing to runpath %a is impossible",runpath)
+ os.exit()
+ end
+ environment.arguments.path = currentdir
+ environment.arguments.runpath = runpath
+ if filepathpart(filename) == "." then
+ filename = filebasename(filename)
+ end
+ end
+ --
a_jithash = validstring(a_jithash or analysis.jithash) or nil
a_permitloadlib = a_permitloadlib or analysis.permitloadlib or nil
--