Commit bd93f35c authored by Samuel Huang's avatar Samuel Huang Committed by Commit Bot

[GRIT] update_resource_ids: Add support to control start ID alignment of items.

This CL adds the "META": {"align": align_value} field for resource_ids
items, to specify that start ID of the item should be a multiple of
align_value (preexisting default = 10).

Also update the main resource_ids (and fix some missing "join"s), so
that sections has a greater (>= 100) "align" value. In addition to
making numbers look nicer, this also reduces the likelihood of large
diffs in resource_ids when using update_resource_ids.

Bug: 979886
Change-Id: Icd3b57a9670556d0858368ee14f2776aa6a9b530
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1921212
Commit-Queue: Samuel Huang <huangs@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716309}
parent 365eaf92
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
}, },
"ui/base/strings/app_locale_settings.grd": { "ui/base/strings/app_locale_settings.grd": {
"META": {"join": 2},
"messages": [7500], "messages": [7500],
}, },
"chrome/app/resources/locale_settings.grd": { "chrome/app/resources/locale_settings.grd": {
...@@ -87,6 +88,7 @@ ...@@ -87,6 +88,7 @@
}, },
"ui/base/strings/ui_strings.grd": { "ui/base/strings/ui_strings.grd": {
"META": {"join": 4},
"messages": [9500], "messages": [9500],
}, },
# Chromium strings and Google Chrome strings must start at the same id. # Chromium strings and Google Chrome strings must start at the same id.
...@@ -101,6 +103,7 @@ ...@@ -101,6 +103,7 @@
# Leave lots of space for generated_resources since it has most of our # Leave lots of space for generated_resources since it has most of our
# strings. # strings.
"chrome/app/generated_resources.grd": { "chrome/app/generated_resources.grd": {
"META": {"join": 2},
"structures": [10500], "structures": [10500],
"messages": [11000], "messages": [11000],
}, },
...@@ -151,6 +154,7 @@ ...@@ -151,6 +154,7 @@
}, },
# This file is generated during the build. # This file is generated during the build.
"chrome/browser/debugger/frontend/devtools_frontend_resources.grd": { "chrome/browser/debugger/frontend/devtools_frontend_resources.grd": {
"META": {"join": 2},
"includes": [21500], "includes": [21500],
}, },
"cloud_print/virtual_driver/win/install/virtual_driver_setup_resources.grd": { "cloud_print/virtual_driver/win/install/virtual_driver_setup_resources.grd": {
......
...@@ -158,9 +158,9 @@ class _Args: ...@@ -158,9 +158,9 @@ class _Args:
class UpdateResourceIds(interface.Tool): class UpdateResourceIds(interface.Tool):
"""Updates all starting IDs in an resource_ids file by reading all GRD files """Updates all start IDs in an resource_ids file by reading all GRD files it
it refers to, estimating the number of required IDs of each type, then rewrites refers to, estimating the number of required IDs of each type, then rewrites
starting IDs while preserving structure. start IDs while preserving structure.
Usage: grit update_resource_ids [--parse|-p] [--read-grd|-r] [--tokenize|-t] Usage: grit update_resource_ids [--parse|-p] [--read-grd|-r] [--tokenize|-t]
[--naive] [--fake] [-o OUTPUT_FILE] [--naive] [--fake] [-o OUTPUT_FILE]
......
...@@ -261,6 +261,8 @@ Additional comments for (1b) and other steps are detailed below. ...@@ -261,6 +261,8 @@ Additional comments for (1b) and other steps are detailed below.
else: else:
node.new_id = node.old_id # Initial S. node.new_id = node.old_id # Initial S.
trace.append(node) # Add B. trace.append(node) # Add B.
align = meta['align'].val if meta and 'align' in meta else self._align
node.new_id = common.AlignUp(node.new_id, align)
yield node.item, node.new_id yield node.item, node.new_id
# Expect caller to calling FreedWeight() and update |node.weight|. # Expect caller to calling FreedWeight() and update |node.weight|.
......
...@@ -14,7 +14,7 @@ if __name__ == '__main__': ...@@ -14,7 +14,7 @@ if __name__ == '__main__':
from grit.tool.update_resource_ids import assigner, common, parser from grit.tool.update_resource_ids import assigner, common, parser
# |spec| format: A comma-separated list of (old) starting IDs. Modifiers: # |spec| format: A comma-separated list of (old) start IDs. Modifiers:
# * Prefix with n '*' to assign the item's META "join" field to n + 1. # * Prefix with n '*' to assign the item's META "join" field to n + 1.
# * Suffix with "+[usage]" to assign |usage| for the item (else default=10) # * Suffix with "+[usage]" to assign |usage| for the item (else default=10)
......
...@@ -41,6 +41,9 @@ class TagInfo: ...@@ -41,6 +41,9 @@ class TagInfo:
""" """
# Tag name, e.g., 'include' (no "s" at end). # Tag name, e.g., 'include' (no "s" at end).
self.name = StripPlural(raw_key.val) self.name = StripPlural(raw_key.val)
# |len(raw_value) > 1| is possible, e.g., see grd_reader_unittest.py's
# testAssignFirstIdsMultipleMessages. This feature seems unused though.
# TODO(huangs): Reconcile this (may end up removing multi-value feature).
assert len(raw_value) == 1 assert len(raw_value) == 1
# Inclusive start *position* of the tag's start ID in resource_ids. # Inclusive start *position* of the tag's start ID in resource_ids.
self.lo = raw_value[0].lo self.lo = raw_value[0].lo
......
...@@ -55,17 +55,22 @@ ...@@ -55,17 +55,22 @@
# Leave lots of space for generated_resources since it has most of our # Leave lots of space for generated_resources since it has most of our
# strings. # strings.
"chrome/app/generated_resources.grd": { "chrome/app/generated_resources.grd": {
"META": {"join": 2}, # Big alignment since strings (previous item) are frequently added.
"META": {"join": 2, "align": 200},
"messages": [800], "messages": [800],
}, },
"chrome/app/resources/locale_settings.grd": { "chrome/app/resources/locale_settings.grd": {
# Big alignment since strings (previous item) are frequently added.
"META": {"align": 1000},
"messages": [10000], "messages": [10000],
}, },
# These each start with the same resource id because we only use one # These each start with the same resource id because we only use one
# file for each build (chromiumos, google_chromeos, linux, mac, or win). # file for each build (chromiumos, google_chromeos, linux, mac, or win).
"chrome/app/resources/locale_settings_chromiumos.grd": { "chrome/app/resources/locale_settings_chromiumos.grd": {
# Big alignment since strings (previous item) are frequently added.
"META": {"align": 100},
"messages": [10100], "messages": [10100],
}, },
"chrome/app/resources/locale_settings_google_chromeos.grd": { "chrome/app/resources/locale_settings_google_chromeos.grd": {
...@@ -94,6 +99,8 @@ ...@@ -94,6 +99,8 @@
# START chrome/browser section. # START chrome/browser section.
"chrome/browser/browser_resources.grd": { "chrome/browser/browser_resources.grd": {
# Big alignment at start of section.
"META": {"align": 100},
"includes": [11000], "includes": [11000],
"structures": [11800], "structures": [11800],
}, },
...@@ -186,6 +193,8 @@ ...@@ -186,6 +193,8 @@
# START chrome/ WebUI resources section # START chrome/ WebUI resources section
"chrome/browser/resources/bluetooth_internals/resources.grd": { "chrome/browser/resources/bluetooth_internals/resources.grd": {
# Big alignment at start of section.
"META": {"align": 100},
"includes": [13970], "includes": [13970],
}, },
"chrome/browser/resources/omnibox/resources.grd": { "chrome/browser/resources/omnibox/resources.grd": {
...@@ -201,6 +210,8 @@ ...@@ -201,6 +210,8 @@
# START chrome/ miscellaneous section. # START chrome/ miscellaneous section.
"chrome/android/features/test_dummy/internal/resources/resources.grd": { "chrome/android/features/test_dummy/internal/resources/resources.grd": {
# Big alignment at start of section.
"META": {"align": 100},
"includes": [14090], "includes": [14090],
}, },
"chrome/common/common_resources.grd": { "chrome/common/common_resources.grd": {
...@@ -221,6 +232,8 @@ ...@@ -221,6 +232,8 @@
# START chromeos/ section. # START chromeos/ section.
"chromeos/chromeos_strings.grd": { "chromeos/chromeos_strings.grd": {
# Big alignment at start of section.
"META": {"align": 100},
"messages": [14530], "messages": [14530],
}, },
"chromeos/components/help_app_ui/resources/help_app_resources.grd": { "chromeos/components/help_app_ui/resources/help_app_resources.grd": {
...@@ -251,6 +264,8 @@ ...@@ -251,6 +264,8 @@
# We only use one file depending on whether we're building Chromium or # We only use one file depending on whether we're building Chromium or
# Google Chrome. # Google Chrome.
"components/components_chromium_strings.grd": { "components/components_chromium_strings.grd": {
# Big alignment at start of section.
"META": {"align": 100},
"messages": [15060], "messages": [15060],
}, },
"components/components_google_chrome_strings.grd": { "components/components_google_chrome_strings.grd": {
...@@ -258,6 +273,7 @@ ...@@ -258,6 +273,7 @@
}, },
"components/components_locale_settings.grd": { "components/components_locale_settings.grd": {
"META": {"join": 2},
"includes": [15080], "includes": [15080],
"messages": [15090], "messages": [15090],
}, },
...@@ -329,13 +345,15 @@ ...@@ -329,13 +345,15 @@
"ios/chrome/content_widget_extension/strings/ios_content_widget_extension_google_chrome_strings.grd": { "ios/chrome/content_widget_extension/strings/ios_content_widget_extension_google_chrome_strings.grd": {
"messages": [3080], "messages": [3080],
}, },
# END ios/ section. # END ios/ section.
# START content/ section. # START content/ section.
# content/ and ios/web/ must start at the same id. # content/ and ios/web/ must start at the same id.
# App only use one file depending on whether it is iOS or other platform. # App only use one file depending on whether it is iOS or other platform.
"content/app/resources/content_resources.grd": { "content/app/resources/content_resources.grd": {
"META": {"join": 3}, # Big alignment at start of section.
"META": {"join": 3, "align": 100},
"structures": [20000], "structures": [20000],
}, },
"content/browser/webrtc/resources/resources.grd": { "content/browser/webrtc/resources/resources.grd": {
...@@ -369,6 +387,8 @@ ...@@ -369,6 +387,8 @@
# START "everything else" section. # START "everything else" section.
# Everything but chrome/, components/, content/, and ios/ # Everything but chrome/, components/, content/, and ios/
"android_webview/ui/aw_resources.grd": { "android_webview/ui/aw_resources.grd": {
# Big alignment at start of section.
"META": {"join": 2, "align": 100},
"includes": [23100], "includes": [23100],
}, },
"android_webview/ui/aw_strings.grd": { "android_webview/ui/aw_strings.grd": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment