Skip to content

Commit b56f41f

Browse files
zenoalbisserbbandix
authored andcommitted
<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: Zeno Albisser <[email protected]> Reviewed-by: Andras Becsi <[email protected]>
1 parent 4392380 commit b56f41f

File tree

1 file changed

+6
-0
lines changed
  • chromium/tools/grit/grit/node

1 file changed

+6
-0
lines changed

chromium/tools/grit/grit/node/misc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def _ReadFirstIdsFromFile(filename, defines):
4949
def ReplaceVariable(matchobj):
5050
for key, value in defines.iteritems():
5151
if matchobj.group(1) == key:
52+
value = os.path.abspath(value)
5253
return value
5354
return ''
5455

@@ -431,6 +432,11 @@ def AssignFirstIds(self, filename_or_stream, defines):
431432
abs_filename = os.path.abspath(filename_or_stream)
432433
if abs_filename[:len(src_root_dir)] != src_root_dir:
433434
filename = os.path.basename(filename_or_stream)
435+
# If the file is not within src_root_dir and the basename is not
436+
# found as a key, fall back to using the absolute file name.
437+
if not filename in first_ids:
438+
filename = abs_filename
439+
filename = filename.replace('\\', '/')
434440
else:
435441
filename = abs_filename[len(src_root_dir) + 1:]
436442
filename = filename.replace('\\', '/')

0 commit comments

Comments
 (0)