Bug 2953594: includedirs / libdirs converting absolute paths to relative
This commit is contained in:
parent
96b28c3146
commit
8f3411d708
@ -8,6 +8,7 @@
|
||||
* Bug 2942438: Wrong runtime library linked
|
||||
* Bug 2931722: pchheader handling not consistent between tools
|
||||
* Bug 2958829: Files pattern matching including too many files
|
||||
* Bug 2953594: includedirs / libdirs converting absolute paths to relative
|
||||
|
||||
|
||||
-----
|
||||
|
@ -441,7 +441,7 @@
|
||||
|
||||
function makeabsolute(value)
|
||||
if (type(value) == "table") then
|
||||
for _,item in ipairs(value) do
|
||||
for _, item in ipairs(value) do
|
||||
makeabsolute(item)
|
||||
end
|
||||
else
|
||||
|
@ -125,9 +125,9 @@
|
||||
end
|
||||
|
||||
-- different drives? Must use absolute path
|
||||
if path.getdrive(src) ~= path.getdrive(dst) then
|
||||
return dst
|
||||
end
|
||||
-- if path.getdrive(src) ~= path.getdrive(dst) then
|
||||
-- return dst
|
||||
-- end
|
||||
|
||||
-- dollar macro? Can't tell what the real path is; use absolute
|
||||
-- This enables paths like $(SDK_ROOT)/include to work correctly.
|
||||
@ -137,8 +137,33 @@
|
||||
|
||||
src = src .. "/"
|
||||
dst = dst .. "/"
|
||||
|
||||
|
||||
-- find the common leading directories
|
||||
local idx = 0
|
||||
while (true) do
|
||||
local tst = src:find("/", idx + 1, true)
|
||||
if tst then
|
||||
if src:sub(1,tst) == dst:sub(1,tst) then
|
||||
idx = tst
|
||||
else
|
||||
break
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- if they have nothing in common return absolute path
|
||||
local first = src:find("/", 0, true)
|
||||
if idx <= first then
|
||||
return dst:sub(1, -2)
|
||||
end
|
||||
|
||||
-- trim off the common directories from the front
|
||||
src = src:sub(idx + 1)
|
||||
dst = dst:sub(idx + 1)
|
||||
|
||||
--[[
|
||||
local i = src:find("/")
|
||||
while (i) do
|
||||
if (src:sub(1,i) == dst:sub(1,i)) then
|
||||
@ -149,13 +174,14 @@
|
||||
end
|
||||
i = src:find("/")
|
||||
end
|
||||
]]
|
||||
|
||||
-- back up from dst to get to this common parent
|
||||
local result = ""
|
||||
i = src:find("/")
|
||||
while (i) do
|
||||
idx = src:find("/")
|
||||
while (idx) do
|
||||
result = result .. "../"
|
||||
i = src:find("/", i + 1)
|
||||
idx = src:find("/", idx + 1)
|
||||
end
|
||||
|
||||
-- tack on the path down to the dst from here
|
||||
|
@ -125,6 +125,9 @@
|
||||
test.isequal("$(SDK_HOME)/include", path.getrelative("C:/Code/Premake4", "$(SDK_HOME)/include"))
|
||||
end
|
||||
|
||||
function suite.getrelative_ReturnsAbsPath_OnRootedPath()
|
||||
test.isequal("/opt/include", path.getrelative("/home/me/src/project", "/opt/include"))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user