Allow the pathVars to return a table that specifies explicitly that a token represents a relative or absolute path.
This commit is contained in:
parent
4f8551b7d0
commit
535e40db5f
@ -18,13 +18,19 @@
|
||||
---
|
||||
|
||||
vstudio.pathVars = {
|
||||
["cfg.objdir"] = "$(IntDir)",
|
||||
["prj.location"] = "$(ProjectDir)",
|
||||
["sln.location"] = "$(SolutionDir)",
|
||||
["wks.location"] = "$(SolutionDir)",
|
||||
["cfg.buildtarget.directory"] = "$(TargetDir)",
|
||||
["cfg.buildtarget.name"] = "$(TargetFileName)",
|
||||
["cfg.buildtarget.basename"] = "$(TargetName)",
|
||||
["cfg.objdir"] = { absolute = true, token = "$(IntDir)" },
|
||||
["prj.location"] = { absolute = true, token = "$(ProjectDir)" },
|
||||
["prj.name"] = { absolute = false, token = "$(ProjectName)" },
|
||||
["sln.location"] = { absolute = true, token = "$(SolutionDir)" },
|
||||
["sln.name"] = { absolute = false, token = "$(SolutionName)" },
|
||||
["wks.location"] = { absolute = true, token = "$(SolutionDir)" },
|
||||
["wks.name"] = { absolute = false, token = "$(SolutionName)" },
|
||||
["cfg.buildtarget.directory"] = { absolute = false, token = "$(TargetDir)" },
|
||||
["cfg.buildtarget.name"] = { absolute = false, token = "$(TargetFileName)" },
|
||||
["cfg.buildtarget.basename"] = { absolute = false, token = "$(TargetName)" },
|
||||
["file.basename"] = { absolute = false, token = "%(Filename)" },
|
||||
["file.abspath"] = { absolute = true, token = "%(FullPath)" },
|
||||
["file.relpath"] = { absolute = false, token = "%(Identity)" },
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,9 +90,15 @@
|
||||
success, result = pcall(result, e)
|
||||
if not success then
|
||||
return nil, result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if (type(result) == "table") then
|
||||
isAbs = result.absolute
|
||||
result = result.token
|
||||
else
|
||||
isAbs = path.isabsolute(result)
|
||||
end
|
||||
isAbs = path.isabsolute(result)
|
||||
end
|
||||
|
||||
-- If the result is an absolute path, and it is being inserted into
|
||||
|
@ -19,9 +19,9 @@ int do_isabsolute(const char* path)
|
||||
{
|
||||
return (
|
||||
path[0] == '/' ||
|
||||
path[0] == '\\' ||
|
||||
path[0] == '$' ||
|
||||
(path[0] == '"' && path[1] == '$') ||
|
||||
(path[0] != '\0' && path[1] == ':')
|
||||
path[0] == '\\' ||
|
||||
path[0] == '$' ||
|
||||
(path[0] == '"' && path[1] == '$') ||
|
||||
(path[0] != '\0' && path[1] == ':')
|
||||
);
|
||||
}
|
||||
|
@ -109,17 +109,23 @@
|
||||
--
|
||||
|
||||
function suite.replacesToken_onSupportedAndMapped()
|
||||
action.pathVars = { ["cfg.objdir"] = "$(IntDir)" }
|
||||
action.pathVars = { ["cfg.objdir"] = { absolute = true, token = "$(IntDir)" }, }
|
||||
x = detoken.expand("cmd %{cfg.objdir}/file", environ, {pathVars=true})
|
||||
test.isequal("cmd $(IntDir)/file", x)
|
||||
end
|
||||
|
||||
function suite.replacesToken_onSupportedAndMapped_inAbsPath()
|
||||
action.pathVars = { ["cfg.objdir"] = "$(IntDir)" }
|
||||
action.pathVars = { ["cfg.objdir"] = { absolute = true, token = "$(IntDir)" }, }
|
||||
x = detoken.expand(os.getcwd() .. "/%{cfg.objdir}/file", environ, {paths=true,pathVars=true})
|
||||
test.isequal("$(IntDir)/file", x)
|
||||
end
|
||||
|
||||
function suite.replacesToken_onSupportedAndMapped_inRelPath()
|
||||
action.pathVars = { ["cfg.objdir"] = { absolute = false, token = "$(IntDir)" }, }
|
||||
x = detoken.expand(os.getcwd() .. "/%{cfg.objdir}/file", environ, {paths=true,pathVars=true})
|
||||
test.isequal(os.getcwd() .. "/$(IntDir)/file", x)
|
||||
end
|
||||
|
||||
--
|
||||
-- Escapes backslashes correctly.
|
||||
--
|
||||
|
Reference in New Issue
Block a user