diff options
author | dsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 21:46:06 +0000 |
---|---|---|
committer | dsinclair@chromium.org <dsinclair@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 21:46:06 +0000 |
commit | 479bea2b5cac4accf53c2cd4f15cfa021d329812 (patch) | |
tree | 8f4b8e9d400b00e82e3587892e104b1cdbfb0b04 /content/browser | |
parent | 3cd05bc98b36bac8524f19e305ec1b2ba68301ea (diff) | |
download | chromium_src-479bea2b5cac4accf53c2cd4f15cfa021d329812.zip chromium_src-479bea2b5cac4accf53c2cd4f15cfa021d329812.tar.gz chromium_src-479bea2b5cac4accf53c2cd4f15cfa021d329812.tar.bz2 |
Generate files needed for tracing through the build.
Currently the about_tracing.html and about_tracing.js files are
all committed into the trace-viewer repo. This causes a lot of churn. With
this CL, when combined with the CL on the tracing side, we generate the
needed files during the chromium build.
Pairs with: https://codereview.appspot.com/9126044/
BUG=trace-viewer:152
TBR=dsinclair@chromium.org (for the grit dep)
Review URL: https://chromiumcodereview.appspot.com/14990007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/tracing/DEPS | 4 | ||||
-rwxr-xr-x | content/browser/tracing/generate_trace_viewer_grd.py | 81 | ||||
-rw-r--r-- | content/browser/tracing/tracing_resources.gyp | 81 | ||||
-rw-r--r-- | content/browser/tracing/tracing_ui.cc | 2 |
4 files changed, 167 insertions, 1 deletions
diff --git a/content/browser/tracing/DEPS b/content/browser/tracing/DEPS new file mode 100644 index 0000000..b4d8715 --- /dev/null +++ b/content/browser/tracing/DEPS @@ -0,0 +1,4 @@ +include_rules = [ + # Generated by the local tracing_resources.gyp:tracing_resources + "+grit/tracing_resources.h", +] diff --git a/content/browser/tracing/generate_trace_viewer_grd.py b/content/browser/tracing/generate_trace_viewer_grd.py new file mode 100755 index 0000000..767f5c5 --- /dev/null +++ b/content/browser/tracing/generate_trace_viewer_grd.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# Copyright 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Creates a grd file for packaging the trace-viewer files. + + This file is modified from the devtools generate_devtools_grd.py file. +""" + +import errno +import os +import shutil +import sys +from xml.dom import minidom + +kTracingResourcePrefix = 'IDR_TRACING_' +kGrdTemplate = '''<?xml version="1.0" encoding="UTF-8"?> +<grit latest_public_release="0" current_release="1"> + <outputs> + <output filename="grit/tracing_resources.h" type="rc_header"> + <emit emit_type='prepend'></emit> + </output> + <output filename="tracing_resources.pak" type="data_package" /> + <output filename="tracing_resources.rc" type="rc_all" /> + </outputs> + <release seq="1"> + <includes> + <if expr="not is_android"></if> + </includes> + </release> +</grit> + +''' + + +class ParsedArgs: + def __init__(self, source_files, output_filename): + self.source_files = source_files + self.output_filename = output_filename + + +def parse_args(argv): + output_position = argv.index('--output') + source_files = argv[:output_position] + return ParsedArgs(source_files, argv[output_position + 1]) + + +def make_name_from_filename(filename): + return kTracingResourcePrefix + (os.path.splitext(filename)[1][1:]).upper() + + +def add_file_to_grd(grd_doc, filename): + includes_node = grd_doc.getElementsByTagName('if')[0] + includes_node.appendChild(grd_doc.createTextNode('\n ')) + + new_include_node = grd_doc.createElement('include') + new_include_node.setAttribute('name', make_name_from_filename(filename)) + new_include_node.setAttribute('file', filename) + new_include_node.setAttribute('type', 'BINDATA') + new_include_node.setAttribute('flattenhtml', 'true') + if filename.endswith('.html'): + new_include_node.setAttribute('allowexternalscript', 'true') + includes_node.appendChild(new_include_node) + + +def main(argv): + parsed_args = parse_args(argv[1:]) + + output_directory = os.path.dirname(parsed_args.output_filename) + + doc = minidom.parseString(kGrdTemplate) + for filename in parsed_args.source_files: + add_file_to_grd(doc, os.path.basename(filename)) + + with open(parsed_args.output_filename, 'w') as output_file: + output_file.write(doc.toxml(encoding='UTF-8')) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/content/browser/tracing/tracing_resources.gyp b/content/browser/tracing/tracing_resources.gyp new file mode 100644 index 0000000..f6854b0 --- /dev/null +++ b/content/browser/tracing/tracing_resources.gyp @@ -0,0 +1,81 @@ +# Copyright 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +{ + 'variables': { + 'trace_viewer_src_dir': '../../../third_party/trace-viewer', + 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing', + }, + 'targets': [ + { + 'target_name': 'generate_tracing_grd', + 'type': 'none', + 'dependencies': [ + '<(trace_viewer_src_dir)/trace_viewer.gyp:generate_about_tracing', + ], + 'actions': [ + { + 'action_name': 'generate_tracing_grd', + 'script_name': 'generate_trace_viewer_grd.py', + 'input_pages': [ + '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/about_tracing.html', + '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/about_tracing.js' + ], + 'inputs': [ + '<@(_script_name)', + '<@(_input_pages)' + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/tracing_resources.grd' + ], + 'action': [ + 'python', '<@(_script_name)', '<@(_input_pages)', '--output', '<@(_outputs)' + ] + } + ] + }, + + { + 'target_name': 'tracing_resources', + 'type': 'none', + 'dependencies': [ + '<(trace_viewer_src_dir)/trace_viewer.gyp:generate_about_tracing', + 'generate_tracing_grd', + ], + 'variables': { + 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing', + }, + 'actions': [ + { + 'action_name': 'tracing_resources', + # This can't use build/grit_action.gypi because the grd file + # is generated at build time, so the trick of using grit_info to get + # the real inputs/outputs at GYP time isn't possible. + 'variables': { + 'grit_cmd': ['python', '../../../tools/grit/grit.py'], + 'grit_grd_file': '<(SHARED_INTERMEDIATE_DIR)/content/browser/tracing/tracing_resources.grd', + }, + 'inputs': [ + '<(grit_grd_file)', + '<!@pymod_do_main(grit_info --inputs)', + ], + 'outputs': [ + '<(grit_out_dir)/grit/tracing_resources.h', + '<(grit_out_dir)/tracing_resources.pak', + '<(grit_out_dir)/tracing_resources.rc', + ], + 'action': ['<@(grit_cmd)', + '-i', '<(grit_grd_file)', 'build', + '-f', 'GRIT_DIR/../gritsettings/resource_ids', + '-o', '<(grit_out_dir)', + '-D', 'SHARED_INTERMEDIATE_DIR=<(SHARED_INTERMEDIATE_DIR)', + '<@(grit_defines)' ], + 'message': 'Generating resources from <(grit_grd_file)', + 'msvs_cygwin_shell': 1, + } + ], + 'includes': [ '../../../build/grit_target.gypi' ] + } + ] +} diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc index 8553f8f..aab652d 100644 --- a/content/browser/tracing/tracing_ui.cc +++ b/content/browser/tracing/tracing_ui.cc @@ -29,7 +29,7 @@ #include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_message_handler.h" #include "content/public/common/url_constants.h" -#include "grit/content_resources.h" +#include "grit/tracing_resources.h" #include "ipc/ipc_channel.h" #include "ui/shell_dialogs/select_file_dialog.h" |