From 9bb7911547bcce870c330c350aabfa2801b79f54 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Thu, 5 Sep 2024 12:14:58 +0100 Subject: [PATCH] Fix generated paths to be relative to the workspace. --- ninja.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ninja.lua b/ninja.lua index 5e9b1ac..a0f70c4 100644 --- a/ninja.lua +++ b/ninja.lua @@ -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) @@ -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()