summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-07-24 15:54:50 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-03-16 15:19:03 +0100
commitfcc58cc405d0e68d7b7ee56e100a13ee0203d634 (patch)
treee1e4ba3e65b12fe05e2a15c84fba7dd6906a4e20
parent485b00eeead3fb5f39a7d7ee8a34a20f327fed11 (diff)
downloadqtwebengine-chromium-fcc58cc405d0e68d7b7ee56e100a13ee0203d634.tar.gz
<tools/grit> GRIT: Allow grd files outside of chromium source dir.
When replacing substrings with values from a dictionary, the replacements should not be truncated to the length of src_root_dir. If the basename does not exist as a key in the resource_ids file, then fall back to an absolute path. The precedence is like: file in chromium > file basename > absolute file name. THIS SHOULD BE UPSTREAMABLE. Change-Id: I7d1da8c04515807000742aac4a6fa4db7616fd13 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com> Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
-rw-r--r--chromium/tools/grit/grit/node/misc.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/chromium/tools/grit/grit/node/misc.py b/chromium/tools/grit/grit/node/misc.py
index d43f676f9b3..3816b2daa7b 100644
--- a/chromium/tools/grit/grit/node/misc.py
+++ b/chromium/tools/grit/grit/node/misc.py
@@ -60,6 +60,7 @@ def _ReadFirstIdsFromFile(filename, defines):
def ReplaceVariable(matchobj):
for key, value in defines.items():
if matchobj.group(1) == key:
+ value = os.path.abspath(value)
return value
return ''
@@ -596,6 +597,11 @@ class GritNode(base.Node):
abs_filename = os.path.abspath(filename_or_stream)
if abs_filename[:len(src_root_dir)] != src_root_dir:
filename = os.path.basename(filename_or_stream)
+ # If the file is not within src_root_dir and the basename is not
+ # found as a key, fall back to using the absolute file name.
+ if not filename in first_ids:
+ filename = abs_filename
+ filename = filename.replace('\\', '/')
else:
filename = abs_filename[len(src_root_dir) + 1:]
filename = filename.replace('\\', '/')