diff options
author | thestig@chromium.org <thestig@chromium.org@7262f16d-afe8-6277-6482-052fa10e57b1> | 2014-08-06 23:40:21 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@7262f16d-afe8-6277-6482-052fa10e57b1> | 2014-08-06 23:40:21 +0000 |
commit | 206c6aa4450db4e961d20f8367f33df42bba6a85 (patch) | |
tree | e9b6ee1d1b0706ac92ba644efc8a65c31fd5c43c | |
parent | 6a46b04d35eade32b1270392317dca516c9dd56d (diff) | |
download | grit-206c6aa4450db4e961d20f8367f33df42bba6a85.tar.gz |
Respect output_all_resource_defines when generating includes in resource maps.
BUG=chromium:333201
TEST=included unit test.
R=tony@chromium.org
Review URL: https://codereview.chromium.org/444233002
git-svn-id: http://grit-i18n.googlecode.com/svn/trunk@173 7262f16d-afe8-6277-6482-052fa10e57b1
-rw-r--r-- | grit/format/resource_map_unittest.py | 66 | ||||
-rw-r--r-- | grit/node/include.py | 4 |
2 files changed, 68 insertions, 2 deletions
diff --git a/grit/format/resource_map_unittest.py b/grit/format/resource_map_unittest.py index cc6a79b..55de504 100644 --- a/grit/format/resource_map_unittest.py +++ b/grit/format/resource_map_unittest.py @@ -94,7 +94,7 @@ const GritResourceMap kTheRcHeader[] = { }; const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) - def testFormatResourceMapOutputAllEqualsFalse(self): + def testFormatResourceMapWithOutputAllEqualsFalseForStructures(self): grd = grd_reader.Parse(StringIO.StringIO( '''<?xml version="1.0" encoding="UTF-8"?> <grit latest_public_release="2" source_lang_id="en" current_release="3" @@ -153,6 +153,70 @@ const GritResourceMap kTheRcHeader[] = { }; const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) + def testFormatResourceMapWithOutputAllEqualsFalseForIncludes(self): + grd = grd_reader.Parse(StringIO.StringIO( + '''<?xml version="1.0" encoding="UTF-8"?> + <grit latest_public_release="2" source_lang_id="en" current_release="3" + base_dir="." output_all_resource_defines="false"> + <outputs> + <output type="rc_header" filename="the_rc_header.h" /> + <output type="resource_map_header" + filename="the_resource_map_header.h" /> + </outputs> + <release seq="3"> + <structures first_id="300"> + <structure type="menu" name="IDC_KLONKMENU" + file="grit\\testdata\\klonk.rc" encoding="utf-16" /> + </structures> + <includes first_id="10000"> + <include type="foo" file="abc" name="IDS_FIRSTPRESENT" /> + <if expr="False"> + <include type="foo" file="def" name="IDS_MISSING" /> + </if> + <include type="foo" file="mno" name="IDS_THIRDPRESENT" /> + </includes> + </release> + </grit>'''), util.PathFromRoot('.')) + grd.SetOutputLanguage('en') + grd.RunGatherers() + output = util.StripBlankLinesAndComments(''.join( + resource_map.GetFormatter('resource_map_header')(grd, 'en', '.'))) + self.assertEqual('''\ +#include <stddef.h> +#ifndef GRIT_RESOURCE_MAP_STRUCT_ +#define GRIT_RESOURCE_MAP_STRUCT_ +struct GritResourceMap { + const char* const name; + int value; +}; +#endif // GRIT_RESOURCE_MAP_STRUCT_ +extern const GritResourceMap kTheRcHeader[]; +extern const size_t kTheRcHeaderSize;''', output) + output = util.StripBlankLinesAndComments(''.join( + resource_map.GetFormatter('resource_map_source')(grd, 'en', '.'))) + self.assertEqual('''\ +#include "the_resource_map_header.h" +#include "base/basictypes.h" +#include "the_rc_header.h" +const GritResourceMap kTheRcHeader[] = { + {"IDC_KLONKMENU", IDC_KLONKMENU}, + {"IDS_FIRSTPRESENT", IDS_FIRSTPRESENT}, + {"IDS_THIRDPRESENT", IDS_THIRDPRESENT}, +}; +const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) + output = util.StripBlankLinesAndComments(''.join( + resource_map.GetFormatter('resource_file_map_source')(grd, 'en', '.'))) + self.assertEqual('''\ +#include "the_resource_map_header.h" +#include "base/basictypes.h" +#include "the_rc_header.h" +const GritResourceMap kTheRcHeader[] = { + {"grit/testdata/klonk.rc", IDC_KLONKMENU}, + {"abc", IDS_FIRSTPRESENT}, + {"mno", IDS_THIRDPRESENT}, +}; +const size_t kTheRcHeaderSize = arraysize(kTheRcHeader);''', output) + def testFormatStringResourceMap(self): grd = grd_reader.Parse(StringIO.StringIO( '''<?xml version="1.0" encoding="UTF-8"?> diff --git a/grit/node/include.py b/grit/node/include.py index 0f114c3..8d32064 100644 --- a/grit/node/include.py +++ b/grit/node/include.py @@ -119,7 +119,9 @@ class IncludeNode(base.Node): def GeneratesResourceMapEntry(self, output_all_resource_defines, is_active_descendant): # includes always generate resource entries. - return True + if output_all_resource_defines: + return True + return is_active_descendant @staticmethod def Construct(parent, name, type, file, translateable=True, |