diff options
author | Torne (Richard Coles) <torne@google.com> | 2014-02-21 12:17:56 +0000 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2014-02-21 12:17:56 +0000 |
commit | d82e4d92be691b62b040f43f79527f5977bf9104 (patch) | |
tree | c6885b114a5be4c11423c7669c542038e0efb0a2 | |
parent | 36d23aad1af37916cdbbca554faa31a509ac1064 (diff) | |
parent | 368e90f2c01201a54124e57f3550d1da5e7dd9cb (diff) | |
download | grit-d82e4d92be691b62b040f43f79527f5977bf9104.tar.gz |
Merge from Chromium at DEPS revision 251904
This commit was generated by merge_to_master.py.
Change-Id: Id3ddf7d306edc4f7424a76da8e9349bd1d740f4f
-rw-r--r-- | grit/format/chrome_messages_json.py | 2 | ||||
-rw-r--r-- | grit/format/chrome_messages_json_unittest.py | 12 | ||||
-rw-r--r-- | grit/format/policy_templates/policy_template_generator.py | 17 | ||||
-rw-r--r-- | grit/format/policy_templates/writers/doc_writer.py | 2 | ||||
-rw-r--r-- | grit/format/policy_templates/writers/doc_writer_unittest.py | 12 | ||||
-rw-r--r-- | grit/format/policy_templates/writers/plist_writer.py | 9 | ||||
-rw-r--r-- | grit/format/resource_map_unittest.py | 4 | ||||
-rw-r--r-- | grit/grd_reader.py | 12 | ||||
-rw-r--r-- | grit/grd_reader_unittest.py | 24 | ||||
-rw-r--r-- | grit/node/base.py | 105 | ||||
-rw-r--r-- | grit/node/base_unittest.py | 61 | ||||
-rw-r--r-- | grit/tool/android2grd.py | 8 | ||||
-rw-r--r-- | grit/tool/build.py | 34 | ||||
-rw-r--r-- | grit/tool/build_unittest.py | 6 | ||||
-rwxr-xr-x | grit_info.py | 2 |
15 files changed, 225 insertions, 85 deletions
diff --git a/grit/format/chrome_messages_json.py b/grit/format/chrome_messages_json.py index 7b370d7..b5af6d4 100644 --- a/grit/format/chrome_messages_json.py +++ b/grit/format/chrome_messages_json.py @@ -25,7 +25,7 @@ def Format(root, lang='en', output_dir='.'): for child in root.ActiveDescendants(): if isinstance(child, message.MessageNode): id = child.attrs['name'] - if id.startswith('IDR_'): + if id.startswith('IDR_') or id.startswith('IDS_'): id = id[4:] loc_message = encoder.encode(child.Translate(lang)) diff --git a/grit/format/chrome_messages_json_unittest.py b/grit/format/chrome_messages_json_unittest.py index 484230f..3dab23e 100644 --- a/grit/format/chrome_messages_json_unittest.py +++ b/grit/format/chrome_messages_json_unittest.py @@ -49,22 +49,22 @@ class ChromeMessagesJsonFormatUnittest(unittest.TestCase): output = buf.getvalue() test = u""" { - "IDS_SIMPLE_MESSAGE": { + "SIMPLE_MESSAGE": { "message": "Simple message." }, - "IDS_QUOTES": { + "QUOTES": { "message": "element\\u2019s \\u201c%s\\u201d attribute" }, - "IDS_PLACEHOLDERS": { + "PLACEHOLDERS": { "message": "%1$d error, %2$d warning" }, - "IDS_STARTS_WITH_SPACE": { + "STARTS_WITH_SPACE": { "message": "(%d)" }, - "IDS_DOUBLE_QUOTES": { + "DOUBLE_QUOTES": { "message": "A \\"double quoted\\" message." }, - "IDS_BACKSLASH": { + "BACKSLASH": { "message": "\\\\" } } diff --git a/grit/format/policy_templates/policy_template_generator.py b/grit/format/policy_templates/policy_template_generator.py index e742b38..3fad8ca 100644 --- a/grit/format/policy_templates/policy_template_generator.py +++ b/grit/format/policy_templates/policy_template_generator.py @@ -78,12 +78,6 @@ class PolicyTemplateGenerator: for supported_on_item in supported_on: product_platform_part, version_part = supported_on_item.split(':') - # TODO(joaodasilva): enable parsing 'android' as a platform and including - # that platform in the generated documentation. Just skip it for now to - # prevent build failures. - if product_platform_part == 'android': - continue - if '.' in product_platform_part: product, platform = product_platform_part.split('.') if platform == '*': @@ -94,11 +88,12 @@ class PolicyTemplateGenerator: platforms = [platform] else: # e.g.: 'chrome_frame:7-' - product = product_platform_part - platform = { - 'chrome_os': 'chrome_os', - 'chrome_frame': 'win' - }[product] + product, platform = { + 'android': ('chrome', 'android'), + 'chrome_os': ('chrome_os', 'chrome_os'), + 'chrome_frame': ('chrome_frame', 'win'), + 'ios': ('chrome', 'ios'), + }[product_platform_part] platforms = [platform] since_version, until_version = version_part.split('-') result.append({ diff --git a/grit/format/policy_templates/writers/doc_writer.py b/grit/format/policy_templates/writers/doc_writer.py index 09362ff..ee45cd5 100644 --- a/grit/format/policy_templates/writers/doc_writer.py +++ b/grit/format/policy_templates/writers/doc_writer.py @@ -626,6 +626,8 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): 'mac': 'Mac', 'linux': 'Linux', 'chrome_os': self.config['os_name'], + 'android': 'Android', + 'ios': 'iOS', } # Human-readable names of supported products. self._PRODUCT_MAP = { diff --git a/grit/format/policy_templates/writers/doc_writer_unittest.py b/grit/format/policy_templates/writers/doc_writer_unittest.py index 96755ca..6c087d5 100644 --- a/grit/format/policy_templates/writers/doc_writer_unittest.py +++ b/grit/format/policy_templates/writers/doc_writer_unittest.py @@ -341,6 +341,16 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex 'platforms': ['win', 'mac', 'linux'], 'since_version': '8', 'until_version': '', + }, { + 'product': 'chrome', + 'platforms': ['android'], + 'since_version': '30', + 'until_version': '', + }, { + 'product': 'chrome', + 'platforms': ['ios'], + 'since_version': '34', + 'until_version': '', }], 'features': {'dynamic_refresh': False}, 'example_value': False @@ -359,6 +369,8 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex '<dd>' '<ul style="style_ul;">' '<li>Chrome (Windows, Mac, Linux) ...8...</li>' + '<li>Chrome (Android) ...30...</li>' + '<li>Chrome (iOS) ...34...</li>' '</ul>' '</dd>' '<dt style="style_dt;">_test_supported_features</dt>' diff --git a/grit/format/policy_templates/writers/plist_writer.py b/grit/format/policy_templates/writers/plist_writer.py index 25a8c0b..46b7ade 100644 --- a/grit/format/policy_templates/writers/plist_writer.py +++ b/grit/format/policy_templates/writers/plist_writer.py @@ -9,6 +9,10 @@ from grit.format.policy_templates.writers import plist_helper from grit.format.policy_templates.writers import xml_formatted_writer +# This writer outputs a Preferences Manifest file as documented at +# https://developer.apple.com/library/mac/documentation/MacOSXServer/Conceptual/Preference_Manifest_Files + + def GetWriter(config): '''Factory method for creating PListWriter objects. See the constructor of TemplateWriter for description of @@ -103,6 +107,11 @@ class PListWriter(xml_formatted_writer.XMLFormattedWriter): else: element_type = 'string' self.AddElement(range_list, element_type, {}, str(item['value'])) + elif policy_type == 'list': + subkeys = self._AddKeyValuePair(dict, 'pfm_subkeys', 'array') + subkeys_dict = self.AddElement(subkeys, 'dict') + subkeys_type = self._AddKeyValuePair(subkeys_dict, 'pfm_type', 'string') + self.AddText(subkeys_type, 'string') def BeginTemplate(self): self._plist.attributes['version'] = '1' diff --git a/grit/format/resource_map_unittest.py b/grit/format/resource_map_unittest.py index 6112e03..8f162b5 100644 --- a/grit/format/resource_map_unittest.py +++ b/grit/format/resource_map_unittest.py @@ -109,13 +109,13 @@ const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) <message name="IDS_PRODUCT_NAME" desc="The application name"> Application </message> - <if expr="1"> + <if expr="True"> <message name="IDS_DEFAULT_TAB_TITLE_TITLE_CASE" desc="In Title Case: The default title in a tab."> New Tab </message> </if> - <if expr="0"> + <if expr="False"> <message name="IDS_DEFAULT_TAB_TITLE" desc="The default title in a tab."> New tab diff --git a/grit/grd_reader.py b/grit/grd_reader.py index 055ad73..87eec5e 100644 --- a/grit/grd_reader.py +++ b/grit/grd_reader.py @@ -24,7 +24,8 @@ class StopParsingException(Exception): class GrdContentHandler(xml.sax.handler.ContentHandler): - def __init__(self, stop_after, debug, dir, defines, tags_to_ignore): + def __init__(self, stop_after, debug, dir, defines, tags_to_ignore, + target_platform): # Invariant of data: # 'root' is the root of the parse tree being created, or None if we haven't # parsed out any elements. @@ -39,6 +40,7 @@ class GrdContentHandler(xml.sax.handler.ContentHandler): self.defines = defines self.tags_to_ignore = tags_to_ignore or set() self.ignore_depth = 0 + self.target_platform = target_platform def startElement(self, name, attrs): if self.ignore_depth or name in self.tags_to_ignore: @@ -61,6 +63,9 @@ class GrdContentHandler(xml.sax.handler.ContentHandler): else: assert self.root is None self.root = node + if isinstance(self.root, misc.GritNode): + if self.target_platform: + self.root.SetTargetPlatform(self.target_platform) node.StartParsing(name, None) if self.defines: node.SetDefines(self.defines) @@ -175,7 +180,8 @@ def Parse(filename_or_stream, dir=None, stop_after=None, first_ids_file=None, dir = util.dirname(filename_or_stream) handler = GrdContentHandler(stop_after=stop_after, debug=debug, dir=dir, - defines=defines, tags_to_ignore=tags_to_ignore) + defines=defines, tags_to_ignore=tags_to_ignore, + target_platform=target_platform) try: xml.sax.parse(filename_or_stream, handler) except StopParsingException: @@ -195,8 +201,6 @@ def Parse(filename_or_stream, dir=None, stop_after=None, first_ids_file=None, handler.root.SetOwnDir(dir) if isinstance(handler.root, misc.GritNode): - if target_platform: - handler.root.SetTargetPlatform(target_platform) if first_ids_file: # Make the path to the first_ids_file relative to the grd file, # unless it begins with GRIT_DIR. diff --git a/grit/grd_reader_unittest.py b/grit/grd_reader_unittest.py index 5a4c7c3..fd4d08b 100644 --- a/grit/grd_reader_unittest.py +++ b/grit/grd_reader_unittest.py @@ -16,6 +16,7 @@ import StringIO from grit import exception from grit import grd_reader from grit import util +from grit.node import base from grit.node import empty @@ -285,6 +286,29 @@ class GrdReaderUnittest(unittest.TestCase): with util.TempDir({'bad.grp': data}) as temp_dir: self.assertRaises(raises, grd_reader.Parse, top_grd, temp_dir.GetPath()) + def testEarlyEnoughPlatformSpecification(self): + # This is a regression test for issue + # https://code.google.com/p/grit-i18n/issues/detail?id=23 + grd_text = u'''<?xml version="1.0" encoding="UTF-8"?> + <grit latest_public_release="1" current_release="1"> + <release seq="1"> + <messages> + <if expr="not pp_ifdef('use_titlecase')"> + <message name="IDS_XYZ">foo</message> + </if> + <!-- The assumption is that use_titlecase is never true for + this platform. When the platform isn't set to 'android' + early enough, we get a duplicate message name. --> + <if expr="os == '%s'"> + <message name="IDS_XYZ">boo</message> + </if> + </messages> + </release> + </grit>''' % sys.platform + with util.TempDir({}) as temp_dir: + grd_reader.Parse(StringIO.StringIO(grd_text), temp_dir.GetPath(), + target_platform='android') + if __name__ == '__main__': unittest.main() diff --git a/grit/node/base.py b/grit/node/base.py index 7541fa4..3de51b6 100644 --- a/grit/node/base.py +++ b/grit/node/base.py @@ -6,9 +6,8 @@ '''Base types for nodes in a GRIT resource tree. ''' -import collections +import ast import os -import sys import types from xml.sax import saxutils @@ -28,11 +27,12 @@ class Node(object): # Default nodes to not whitelist skipped _whitelist_marked_as_skip = False - # A class-static cache to memoize EvaluateExpression(). - # It has a 2 level nested dict structure. The outer dict has keys - # of tuples which define the environment in which the expression - # will be evaluated. The inner dict is map of expr->result. - eval_expr_cache = collections.defaultdict(dict) + # A class-static cache to speed up EvaluateExpression(). + # Keys are expressions (e.g. 'is_ios and lang == "fr"'). Values are tuples + # (code, variables_in_expr) where code is the compiled expression and can be + # directly eval'd, and variables_in_expr is the list of variable and method + # names used in the expression (e.g. ['is_ios', 'lang']). + eval_expr_cache = {} def __init__(self): self.children = [] # A list of child elements @@ -442,33 +442,64 @@ class Node(object): return [] @classmethod - def EvaluateExpression(cls, expr, defs, target_platform, extra_variables=None): + def EvaluateExpression(cls, expr, defs, target_platform, extra_variables={}): '''Worker for EvaluateCondition (below) and conditions in XTB files.''' - cache_dict = cls.eval_expr_cache[ - (tuple(defs.iteritems()), target_platform, extra_variables)] - if expr in cache_dict: - return cache_dict[expr] - def pp_ifdef(symbol): - return symbol in defs - def pp_if(symbol): - return defs.get(symbol, False) - variable_map = { - 'defs' : defs, - 'os': target_platform, - 'is_linux': target_platform.startswith('linux'), - 'is_macosx': target_platform == 'darwin', - 'is_win': target_platform in ('cygwin', 'win32'), - 'is_android': target_platform == 'android', - 'is_ios': target_platform == 'ios', - 'is_posix': (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5', - 'android', 'ios') - or 'bsd' in target_platform), - 'pp_ifdef' : pp_ifdef, - 'pp_if' : pp_if, - } - if extra_variables: - variable_map.update(extra_variables) - eval_result = cache_dict[expr] = eval(expr, {}, variable_map) + if expr in cls.eval_expr_cache: + code, variables_in_expr = cls.eval_expr_cache[expr] + else: + # Get a list of all variable and method names used in the expression. + syntax_tree = ast.parse(expr, mode='eval') + variables_in_expr = [node.id for node in ast.walk(syntax_tree) if + isinstance(node, ast.Name) and node.id not in ('True', 'False')] + code = compile(syntax_tree, filename='<string>', mode='eval') + cls.eval_expr_cache[expr] = code, variables_in_expr + + # Set values only for variables that are needed to eval the expression. + variable_map = {} + for name in variables_in_expr: + if name == 'os': + value = target_platform + elif name == 'defs': + value = defs + + elif name == 'is_linux': + value = target_platform.startswith('linux') + elif name == 'is_macosx': + value = target_platform == 'darwin' + elif name == 'is_win': + value = target_platform in ('cygwin', 'win32') + elif name == 'is_android': + value = target_platform == 'android' + elif name == 'is_ios': + value = target_platform == 'ios' + elif name == 'is_bsd': + value = 'bsd' in target_platform + elif name == 'is_posix': + value = (target_platform in ('darwin', 'linux2', 'linux3', 'sunos5', + 'android', 'ios') + or 'bsd' in target_platform) + + elif name == 'pp_ifdef': + def pp_ifdef(symbol): + return symbol in defs + value = pp_ifdef + elif name == 'pp_if': + def pp_if(symbol): + return defs.get(symbol, False) + value = pp_if + + elif name in defs: + value = defs[name] + elif name in extra_variables: + value = extra_variables[name] + else: + # Undefined variables default to False. + value = False + + variable_map[name] = value + + eval_result = eval(code, {}, variable_map) + assert isinstance(eval_result, bool) return eval_result def EvaluateCondition(self, expr): @@ -492,10 +523,10 @@ class Node(object): context = getattr(root, 'output_context', '') defs = getattr(root, 'defines', {}) target_platform = getattr(root, 'target_platform', '') - extra_variables = ( - ('lang', lang), - ('context', context), - ) + extra_variables = { + 'lang': lang, + 'context': context, + } return Node.EvaluateExpression( expr, defs, target_platform, extra_variables) diff --git a/grit/node/base_unittest.py b/grit/node/base_unittest.py index 63a2033..f7e7b75 100644 --- a/grit/node/base_unittest.py +++ b/grit/node/base_unittest.py @@ -192,6 +192,67 @@ class NodeUnittest(unittest.TestCase): self.failUnlessEqual(output_nodes[2].attrs['filename'], 'de/generated_resources.rc') + def testEvaluateExpression(self): + def AssertExpr(expected_value, expr, defs, target_platform, + extra_variables): + self.failUnlessEqual(expected_value, base.Node.EvaluateExpression( + expr, defs, target_platform, extra_variables)) + + AssertExpr(True, "True", {}, 'linux', {}) + AssertExpr(False, "False", {}, 'linux', {}) + AssertExpr(True, "True or False", {}, 'linux', {}) + AssertExpr(False, "True and False", {}, 'linux', {}) + AssertExpr(True, "os == 'linux'", {}, 'linux', {}) + AssertExpr(False, "os == 'linux'", {}, 'ios', {}) + AssertExpr(True, "'foo' in defs", {'foo': 'bar'}, 'ios', {}) + AssertExpr(False, "'foo' in defs", {'baz': 'bar'}, 'ios', {}) + AssertExpr(False, "'foo' in defs", {}, 'ios', {}) + AssertExpr(True, "is_linux", {}, 'linux2', {}) + AssertExpr(False, "is_linux", {}, 'win32', {}) + AssertExpr(True, "is_macosx", {}, 'darwin', {}) + AssertExpr(False, "is_macosx", {}, 'ios', {}) + AssertExpr(True, "is_win", {}, 'win32', {}) + AssertExpr(False, "is_win", {}, 'darwin', {}) + AssertExpr(True, "is_android", {}, 'android', {}) + AssertExpr(False, "is_android", {}, 'linux3', {}) + AssertExpr(True, "is_ios", {}, 'ios', {}) + AssertExpr(False, "is_ios", {}, 'darwin', {}) + AssertExpr(True, "is_posix", {}, 'linux2', {}) + AssertExpr(True, "is_posix", {}, 'darwin', {}) + AssertExpr(True, "is_posix", {}, 'android', {}) + AssertExpr(True, "is_posix", {}, 'ios', {}) + AssertExpr(True, "is_posix", {}, 'freebsd7', {}) + AssertExpr(False, "is_posix", {}, 'win32', {}) + AssertExpr(True, "pp_ifdef('foo')", {'foo': True}, 'win32', {}) + AssertExpr(True, "pp_ifdef('foo')", {'foo': False}, 'win32', {}) + AssertExpr(False, "pp_ifdef('foo')", {'bar': True}, 'win32', {}) + AssertExpr(True, "pp_if('foo')", {'foo': True}, 'win32', {}) + AssertExpr(False, "pp_if('foo')", {'foo': False}, 'win32', {}) + AssertExpr(False, "pp_if('foo')", {'bar': True}, 'win32', {}) + AssertExpr(True, "foo", {'foo': True}, 'win32', {}) + AssertExpr(False, "foo", {'foo': False}, 'win32', {}) + AssertExpr(False, "foo", {'bar': True}, 'win32', {}) + AssertExpr(True, "foo == 'baz'", {'foo': 'baz'}, 'win32', {}) + AssertExpr(False, "foo == 'baz'", {'foo': True}, 'win32', {}) + AssertExpr(False, "foo == 'baz'", {}, 'win32', {}) + AssertExpr(True, "lang == 'de'", {}, 'win32', {'lang': 'de'}) + AssertExpr(False, "lang == 'de'", {}, 'win32', {'lang': 'fr'}) + AssertExpr(False, "lang == 'de'", {}, 'win32', {}) + + # Test a couple more complex expressions for good measure. + AssertExpr(True, "is_ios and (lang in ['de', 'fr'] or foo)", + {'foo': 'bar'}, 'ios', {'lang': 'fr', 'context': 'today'}) + AssertExpr(False, "is_ios and (lang in ['de', 'fr'] or foo)", + {'foo': False}, 'linux2', {'lang': 'fr', 'context': 'today'}) + AssertExpr(False, "is_ios and (lang in ['de', 'fr'] or foo)", + {'baz': 'bar'}, 'ios', {'lang': 'he', 'context': 'today'}) + AssertExpr(True, "foo == 'bar' or not baz", + {'foo': 'bar', 'fun': True}, 'ios', {'lang': 'en'}) + AssertExpr(True, "foo == 'bar' or not baz", + {}, 'ios', {'lang': 'en', 'context': 'java'}) + AssertExpr(False, "foo == 'bar' or not baz", + {'foo': 'ruz', 'baz': True}, 'ios', {'lang': 'en'}) + if __name__ == '__main__': unittest.main() diff --git a/grit/tool/android2grd.py b/grit/tool/android2grd.py index 333e33d..b4c1363 100644 --- a/grit/tool/android2grd.py +++ b/grit/tool/android2grd.py @@ -194,15 +194,15 @@ OPTIONS may be any of the following: '''<?xml version="1.0" encoding="UTF-8"?> <grit base_dir="." latest_public_release="0" current_release="1" source_lang_id="en"> + <outputs /> + <translations /> <release allow_pseudo="false" seq="1"> <messages fallback_to_english="true" /> </release> - <translations /> - <outputs /> </grit>'''), dir='.') - messages = root.children[0].children[0] + outputs = root.children[0] translations = root.children[1] - outputs = root.children[2] + messages = root.children[2].children[0] assert (isinstance(messages, grit.node.empty.MessagesNode) and isinstance(translations, grit.node.empty.TranslationsNode) and isinstance(outputs, grit.node.empty.OutputsNode)) diff --git a/grit/tool/build.py b/grit/tool/build.py index dbdbed4..64f1d27 100644 --- a/grit/tool/build.py +++ b/grit/tool/build.py @@ -98,8 +98,9 @@ are exported to translation interchange files (e.g. XMB files), etc. first_ids_file = None whitelist_filenames = [] target_platform = None - dep_dir = None - (own_opts, args) = getopt.getopt(args, 'o:D:E:f:w:t:', ('dep-dir=',)) + depfile = None + depdir = None + (own_opts, args) = getopt.getopt(args, 'o:D:E:f:w:t:', ('depdir=','depfile=')) for (key, val) in own_opts: if key == '-o': self.output_directory = val @@ -118,8 +119,10 @@ are exported to translation interchange files (e.g. XMB files), etc. whitelist_filenames.append(val) elif key == '-t': target_platform = val - elif key == '--dep-dir': - dep_dir = val + elif key == '--depdir': + depdir = val + elif key == '--depfile': + depfile = val if len(args): print 'This tool takes no tool-specific arguments.' @@ -151,8 +154,8 @@ are exported to translation interchange files (e.g. XMB files), etc. self.res.RunGatherers() self.Process() - if dep_dir: - self.GenerateDepfile(opts.input, dep_dir) + if depfile and depdir: + self.GenerateDepfile(opts.input, depfile, depdir) return 0 @@ -310,11 +313,10 @@ are exported to translation interchange files (e.g. XMB files), etc. print self.res.UberClique().missing_translations_ sys.exit(-1) - def GenerateDepfile(self, input_filename, dep_dir): + def GenerateDepfile(self, input_filename, depfile, depdir): '''Generate a depfile that contains the imlicit dependencies of the input grd. The depfile will be in the same format as a makefile, and will contain - references to files relative to |dep_dir|. It will be put in the same - directory as the generated outputs. + references to files relative to |depdir|. It will be put in |depfile|. For example, supposing we have three files in a directory src/ @@ -325,23 +327,21 @@ are exported to translation interchange files (e.g. XMB files), etc. and we run - grit -i blah.grd -o ../out/gen --dep-dir ../out + grit -i blah.grd -o ../out/gen --depdir ../out --depfile ../out/gen/blah.rd.d from the directory src/ we will generate a depfile ../out/gen/blah.grd.d that has the contents gen/blah.grd.d: ../src/input1.xtb ../src/input2.xtb - Note that all paths in the depfile are relative to ../out, the dep-dir. + Note that all paths in the depfile are relative to ../out, the depdir. ''' - depsfile_basename = os.path.basename(input_filename + '.d') - depfile = os.path.abspath( - os.path.join(self.output_directory, depsfile_basename)) - dep_dir = os.path.abspath(dep_dir) + depfile = os.path.abspath(depfile) + depdir = os.path.abspath(depdir) # The path prefix to prepend to dependencies in the depfile. - prefix = os.path.relpath(os.getcwd(), dep_dir) + prefix = os.path.relpath(os.getcwd(), depdir) # The path that the depfile refers to itself by. - self_ref_depfile = os.path.relpath(depfile, dep_dir) + self_ref_depfile = os.path.relpath(depfile, depdir) infiles = self.res.GetInputFiles() deps_text = ' '.join([os.path.join(prefix, i) for i in infiles]) depfile_contents = self_ref_depfile + ': ' + deps_text diff --git a/grit/tool/build_unittest.py b/grit/tool/build_unittest.py index 0b557ff..fd640f7 100644 --- a/grit/tool/build_unittest.py +++ b/grit/tool/build_unittest.py @@ -41,9 +41,11 @@ class BuildUnittest(unittest.TestCase): self.input = util.PathFromRoot('grit/testdata/substitute.grd') self.verbose = False self.extra_verbose = False - builder.Run(DummyOpts(), ['-o', output_dir, '--dep-dir', output_dir]) - expected_dep_file = os.path.join(output_dir, 'substitute.grd.d') + builder.Run(DummyOpts(), ['-o', output_dir, + '--depdir', output_dir, + '--depfile', expected_dep_file]) + self.failUnless(os.path.isfile(expected_dep_file)) with open(expected_dep_file) as f: line = f.readline() diff --git a/grit_info.py b/grit_info.py index c2fae76..47a51f7 100755 --- a/grit_info.py +++ b/grit_info.py @@ -57,7 +57,7 @@ def GritSourceFiles(): grit_root_dir = os.path.relpath(os.path.dirname(__file__), os.getcwd()) for root, dirs, filenames in os.walk(grit_root_dir): grit_src = [os.path.join(root, f) for f in filenames - if f.endswith('.py')] + if f.endswith('.py') and not f.endswith('_unittest.py')] files.extend(grit_src) return sorted(files) |