Skip to content

Commit

Permalink
Fix generated paths to be relative to the workspace.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao authored and Jarod42 committed Sep 30, 2024
1 parent 88d8e79 commit 9bb7911
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ninja.lua
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ local function compilation_rules(cfg, toolset, pch)
local link = toolset.gettoolname(cfg, iif(cfg.language == "C", "cc", "cxx"))
local rc = toolset.gettoolname(cfg, "rc")

-- all paths need to be relative to the workspace output location,
-- and not relative to the project output location.
-- override the toolset getrelative function to achieve this

local getrelative = p.tools.getrelative
p.tools.getrelative = function(cfg, value)
return p.workspace.getrelative(cfg.workspace, value)
end

local all_cflags = getcflags(toolset, cfg, cfg)
local all_cxxflags = getcxxflags(toolset, cfg, cfg)
local all_ldflags = getldflags(toolset, cfg)
Expand Down Expand Up @@ -456,6 +465,8 @@ local function compilation_rules(cfg, toolset, pch)
p.outln("")
end
end

p.tools.getrelative = getrelative
end

local function custom_command_rule()
Expand Down

0 comments on commit 9bb7911

Please sign in to comment.