Skip to content

Commit e1ba0f7

Browse files
committed
Fix generated paths to be relative to the workspace.
1 parent 0c7092a commit e1ba0f7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

ninja.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,15 @@ local function compilation_rules(cfg, toolset, pch)
350350
local link = toolset.gettoolname(cfg, iif(cfg.language == "C", "cc", "cxx"))
351351
local rc = toolset.gettoolname(cfg, "rc")
352352

353+
-- all paths need to be relative to the workspace output location,
354+
-- and not relative to the project output location.
355+
-- override the toolset getrelative function to achieve this
356+
357+
local getrelative = p.tools.getrelative
358+
p.tools.getrelative = function(cfg, value)
359+
return p.workspace.getrelative(cfg.workspace, value)
360+
end
361+
353362
local all_cflags = getcflags(toolset, cfg, cfg)
354363
local all_cxxflags = getcxxflags(toolset, cfg, cfg)
355364
local all_ldflags = getldflags(toolset, cfg)
@@ -426,6 +435,8 @@ local function compilation_rules(cfg, toolset, pch)
426435
p.outln("")
427436
end
428437
end
438+
439+
p.tools.getrelative = getrelative
429440
end
430441

431442
local function custom_command_rule()

0 commit comments

Comments
 (0)