Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Unified Diff: ui/vector_icons/aggregate_vector_icons.py

Issue 2926703002: Remove VectorIconId references from the codebase (Closed)
Patch Set: estade comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/vector_icon_types.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/vector_icons/aggregate_vector_icons.py
diff --git a/ui/vector_icons/aggregate_vector_icons.py b/ui/vector_icons/aggregate_vector_icons.py
index bf46ffd8bcd7cf375e7ba82f1a385f456c6d7bbd..87aa1bea0f6a5159f241479f6bb52547e508fcb3 100644
--- a/ui/vector_icons/aggregate_vector_icons.py
+++ b/ui/vector_icons/aggregate_vector_icons.py
@@ -10,58 +10,6 @@ import shlex
import sys
import textwrap
-def AggregateVectorIconsLegacy(working_directory, file_list, output_cc,
- output_h):
- icon_list = []
- assert file_list is not None
- with open(file_list, 'r') as f:
- file_list_contents = f.read()
- icon_list = shlex.split(file_list_contents)
-
- input_header_template = open(os.path.join(working_directory,
- "vector_icons.h.template"))
- header_template_contents = input_header_template.readlines()
- input_header_template.close()
- output_header = open(output_h, "w")
- for line in header_template_contents:
- if not "TEMPLATE_PLACEHOLDER" in line:
- output_header.write(line)
- continue
-
- for icon_path in icon_list:
- # The icon name should be of the format "foo.icon" or "foo.1x.icon".
- (icon_name, extension) = os.path.splitext(os.path.basename(icon_path))
- (icon_name, scale_factor) = os.path.splitext(icon_name)
- if not scale_factor:
- output_header.write(" {},\n".format(icon_name.upper()))
- output_header.close()
-
- input_cc_template = open(
- os.path.join(working_directory, "vector_icons.cc.template"))
- cc_template_contents = input_cc_template.readlines()
- input_cc_template.close()
- output_cc = open(output_cc, "w")
- for line in cc_template_contents:
- if not "TEMPLATE_PLACEHOLDER" in line:
- output_cc.write(line)
- continue;
-
- for icon_path in icon_list:
- (icon_name, extension) = os.path.splitext(os.path.basename(icon_path))
- (icon_name, scale_factor) = os.path.splitext(icon_name)
- assert not scale_factor or scale_factor == ".1x"
- if (("1X" in line and scale_factor != ".1x") or
- (not "1X" in line and scale_factor == ".1x")):
- continue
-
- icon_file = open(icon_path)
- vector_commands = "".join(icon_file.readlines())
- icon_file.close()
- output_cc.write("ICON_TEMPLATE({}, {})\n".format(icon_name.upper(),
- vector_commands))
- output_cc.close()
-
-
def Error(msg):
print >> sys.stderr, msg
sys.exit(1)
@@ -73,28 +21,17 @@ def CamelCase(name, suffix):
return 'k' + ''.join(words) + suffix
-def AggregateVectorIcons(working_directory, file_list, output_cc, output_h,
- use_legacy_template):
+def AggregateVectorIcons(working_directory, file_list, output_cc, output_h):
"""Compiles all .icon files in a directory into two C++ files.
Args:
working_directory: The path to the directory that holds the .icon files
and C++ templates.
file_list: A file containing the list of vector icon files to process.
- Used for GN only (this argument defaults to None for GYP).
output_cc: The path that should be used to write the .cc file.
output_h: The path that should be used to write the .h file.
- use_legacy_template: If True, |output_cc| and |output_h| are generated
- using .template files which make use of the VectorIconId enum.
"""
- # TODO(tdanderson): Remove this code once all vector icons map to VectorIcon
- # constants rather than VectorIconId values.
- if use_legacy_template:
- AggregateVectorIconsLegacy(working_directory, file_list, output_cc,
- output_h)
- return
-
# For each file in |file_list|, place it in |path_map| if its extension is
# .icon or place it in |path_map_1x| if its extension is .1x.icon. The
# two dictionaries map the icon's name to its path, e.g.,
@@ -202,26 +139,18 @@ def main():
"icon files.")
parser.add_option("--file_list",
help="A response file containing the list of icon files "
- "to be processed (GN only). Defaults to None.",
- default=None)
+ "to be processed.")
parser.add_option("--output_cc",
help="The path to output the CC file to.")
parser.add_option("--output_h",
help="The path to output the header file to.")
- parser.add_option("--use_legacy_template",
- action="store_true",
- help="When set, the VectorIconId enum is populated "
- "with values corresponding to .icon files in "
- "the current working directory.",
- default=False)
(options, args) = parser.parse_args()
AggregateVectorIcons(options.working_directory,
options.file_list,
options.output_cc,
- options.output_h,
- options.use_legacy_template)
+ options.output_h)
if __name__ == "__main__":
« no previous file with comments | « ui/gfx/vector_icon_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698