From b56f41fca47b4276ce56495469657128958d2f55 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 24 Jul 2013 15:54:50 +0200 Subject: 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 Reviewed-by: Andras Becsi --- chromium/tools/grit/grit/node/misc.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chromium/tools/grit/grit/node/misc.py b/chromium/tools/grit/grit/node/misc.py index 345081f5a26..3daf89cfbae 100755 --- a/chromium/tools/grit/grit/node/misc.py +++ b/chromium/tools/grit/grit/node/misc.py @@ -49,6 +49,7 @@ def _ReadFirstIdsFromFile(filename, defines): def ReplaceVariable(matchobj): for key, value in defines.iteritems(): if matchobj.group(1) == key: + value = os.path.abspath(value) return value return '' @@ -431,6 +432,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('\\', '/') -- cgit v1.2.3