1From 8eec6045850c5786b18f89b4444c5e2c68b64a31 Mon Sep 17 00:00:00 2001
2From: Samuli Piippo <samuli.piippo@qt.io>
3Date: Thu, 30 Mar 2017 11:37:24 +0300
4Subject: [PATCH] chromium: workaround for too long .rps file name
5
6Ninja may fail when the build directory is too long:
7
8ninja: error: WriteFile(__third_party_WebKit_Source_bindings_modules_\
9interfaces_info_individual_modules__home_qt_work_build_build-nitrogen\
106x_tmp_work_cortexa9hf-neon-mx6qdl-poky-linux-gnueabi_qtwebengine_5.9\
11.0_gitAUTOINC_29afdb0a34_049134677a-r0_build_src_toolchain_target__ru\
12le.rsp): Unable to create file. File name too long
13
14Task-number: QTBUG-59769
15Change-Id: I73c5e64ae5174412be2a675e35b0b6047f2bf4c1
16Upstream-Status: Pending
17Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
18---
19 gn/tools/gn/ninja_action_target_writer.cc | 9 +++++++++
20 1 file changed, 9 insertions(+)
21
22diff --git a/gn/tools/gn/ninja_action_target_writer.cc b/gn/tools/gn/ninja_action_target_writer.cc
23index 5f4fbaad882..1c074a2193b 100644
24--- a/gn/tools/gn/ninja_action_target_writer.cc
25+++ b/gn/tools/gn/ninja_action_target_writer.cc
26@@ -119,9 +119,18 @@ std::string NinjaActionTargetWriter::WriteRuleDefinition() {
27     // strictly necessary for regular one-shot actions, but it's easier to
28     // just always define unique_name.
29     std::string rspfile = custom_rule_name;
30+
31+    //quick workaround if filename length > 255 - ".rsp", just cut the dirs starting from the end
32+    //please note ".$unique_name" is not used at the moment
33+    int pos = 0;
34+    std::string delimiter("_");
35+    while (rspfile.length() > 250 && (pos = rspfile.find_last_of(delimiter)) != std::string::npos)
36+        rspfile = rspfile.substr(0,pos);
37+
38     if (!target_->sources().empty())
39       rspfile += ".$unique_name";
40     rspfile += ".rsp";
41+
42     out_ << "  rspfile = " << rspfile << std::endl;
43
44     // Response file contents.
45