Ejemplo n.º 1
0
def main(args):
    parser = optparse.OptionParser(
        usage="%prog --js=<filename> --css=<filename>",
        epilog="""
A script to takes all of the javascript and css files that comprise trace-viewer
and merges them together into two giant js and css files, taking into account
various ordering restrictions between them.
""")
    parser.add_option("--js",
                      dest="js_file",
                      help="Where to place generated javascript file")
    parser.add_option("--css",
                      dest="css_file",
                      help="Where to place generated css file")
    options, args = parser.parse_args(args)

    if not options.js_file and not options.css_file:
        sys.stderr.write("ERROR: Must specify one of --js=<filename> or "
                         "--css=<filename>\n\n")
        parser.print_help()
        return 1

    project = trace_viewer_project.TraceViewerProject()
    load_sequence = project.CalcLoadSequenceForModuleFilenames(
        ['tracing/standalone_timeline_view.js'])

    if options.js_file:
        with _sopen(options.js_file, 'w') as f:
            f.write(tvcm.GenerateJS(load_sequence))

    if options.css_file:
        with _sopen(options.css_file, 'w') as f:
            f.write(tvcm.GenerateCSS(load_sequence))

    return 0
Ejemplo n.º 2
0
def CheckCommon(file_name, listed_files):
    project = trace_viewer_project.TraceViewerProject()
    build_dir = os.path.join(project.src_path, 'build')

    known_files = GetKnownFiles()
    u = set(listed_files).union(set(known_files))
    i = set(listed_files).intersection(set(known_files))
    diff = list(u - i)

    if len(diff) == 0:
        return ''

    error = 'Entries in ' + file_name + ' do not match files on disk:\n'
    in_file_only = list(set(listed_files) - set(known_files))
    in_known_only = list(set(known_files) - set(listed_files))

    if len(in_file_only) > 0:
        error += '  In file only:\n    ' + '\n    '.join(sorted(in_file_only))
    if len(in_known_only) > 0:
        if len(in_file_only) > 0:
            error += '\n\n'
        error += '  On disk only:\n    ' + '\n    '.join(sorted(in_known_only))

    if in_file_only:
        error += (
            '\n\n'
            '  Note: only files actually used in about:tracing should\n'
            '  be listed in the build files. Try running build/update_gyp_and_gn\n'
            '  to update the files automatically.')

    return error
Ejemplo n.º 3
0
def Main(args):
    parser = argparse.ArgumentParser(
        description='Run tracing development server')
    parser.add_argument('-d',
                        '--data-dir',
                        default=os.path.abspath(
                            os.path.join(_ROOT_PATH, 'test_data')))
    parser.add_argument('-p', '--port', default=8003, type=int)
    args = parser.parse_args()

    project = trace_viewer_project.TraceViewerProject()

    server = tvcm.DevServer(port=args.port, project=project)
    server.data_dir = os.path.abspath(args.data_dir)
    project.source_paths.append(server.data_dir)

    server.AddPathHandler('/json/examples', do_GET_json_examples)
    server.AddPathHandler('/tr/json/tests', do_GET_json_tests)
    server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp)

    server.AddSourcePathMapping(project.trace_viewer_path)
    server.AddTestLink('/examples/skia_debugger.html', 'Skia Debugger')
    server.AddTestLink('/examples/trace_viewer.html', 'Trace File Viewer')

    server.AddPathHandler('/test_automation/notify_test_result',
                          do_POST_report_test_results,
                          supports_post=True)
    server.AddPathHandler('/test_automation/notify_completion',
                          do_POST_report_test_completion,
                          supports_post=True)

    server.serve_forever()
def main(args):
    parser = optparse.OptionParser(usage="%prog --outdir=<directory>")
    parser.add_option("--outdir",
                      dest="out_dir",
                      help="Where to place generated content")
    options, args = parser.parse_args(args)

    if not options.out_dir:
        sys.stderr.write("ERROR: Must specify --outdir=<directory>")
        parser.print_help()
        return 1

    filenames = ["tvcm/__init__.js", "about_tracing/__init__.js"]
    project = trace_viewer_project.TraceViewerProject()
    load_sequence = project.CalcLoadSequenceForModuleFilenames(filenames)

    olddir = os.getcwd()
    try:
        try:
            result_html = generate_html(options.out_dir, load_sequence)
        except tvcm.module.DepsException, ex:
            sys.stderr.write("Error: %s\n\n" % str(ex))
            return 255

        o = open(os.path.join(options.out_dir, "about_tracing.html"), 'w')
        o.write(result_html)
        o.close()

        result_js = GenerateJS(options.out_dir, load_sequence)
        o = open(os.path.join(options.out_dir, "about_tracing.js"), 'w')
        o.write(result_js)
        o.close()
Ejemplo n.º 5
0
def WriteHTMLForTraceDataToFile(trace_data_list,
                                title,
                                output_file,
                                config_name=None):
    project = trace_viewer_project.TraceViewerProject()

    if config_name == None:
        config_name = project.GetDefaultConfigName()

    modules = [
        'build.trace2html',
        'extras.importer.gzip_importer',  # Must have this regardless of config.
        project.GetModuleNameForConfigName(config_name)
    ]

    load_sequence = project.CalcLoadSequenceForModuleNames(modules)

    scripts = []
    for trace_data in trace_data_list:
        # If the object was previously decoded from valid JSON data (e.g., in
        # WriteHTMLForTracesToFile), it will be a JSON object at this point and we
        # should re-serialize it into a string. Other types of data will be already
        # be strings.
        if not isinstance(trace_data, basestring):
            trace_data = json.dumps(trace_data)
            mime_type = 'application/json'
        else:
            mime_type = 'text/plain'
        scripts.append(ViewerDataScript(trace_data, mime_type))
    generate.GenerateStandaloneHTMLToFile(output_file,
                                          load_sequence,
                                          title,
                                          extra_scripts=scripts)
Ejemplo n.º 6
0
def WriteTraceViewer(output_file,
                     config_name=None,
                     minify=False,
                     report_sizes=False,
                     report_deps=False,
                     output_html_head_and_body=True,
                     extra_search_paths=None,
                     extra_module_names_to_load=None):
    project = trace_viewer_project.TraceViewerProject()
    if extra_search_paths:
        for p in extra_search_paths:
            project.source_paths.append(p)
    if config_name == None:
        config_name = project.GetDefaultConfigName()

    module_names = [
        'trace_viewer',
        project.GetModuleNameForConfigName(config_name)
    ]
    if extra_module_names_to_load:
        module_names += extra_module_names_to_load
    load_sequence = project.CalcLoadSequenceForModuleNames(module_names)

    if report_deps:
        sys.stdout.write(project.GetDepsGraphFromModuleNames(module_names))

    generate.GenerateStandaloneHTMLToFile(
        output_file,
        load_sequence,
        minify=minify,
        report_sizes=report_sizes,
        output_html_head_and_body=output_html_head_and_body)
Ejemplo n.º 7
0
def Main(args):
    parser = optparse.OptionParser(
        usage="%prog <options> trace_file1 [trace_file2 ...]",
        epilog="""Takes the provided trace file and produces a standalone html
file that contains both the trace and the trace viewer.""")

    project = trace_viewer_project.TraceViewerProject()
    project.AddConfigNameOptionToParser(parser)

    parser.add_option(
        "--output",
        dest="output",
        help='Where to put the generated result. If not ' +
        'given, the trace filename is used, with an html suffix.')
    parser.add_option("--quiet",
                      action='store_true',
                      help='Dont print the output file name')
    options, args = parser.parse_args(args)
    if len(args) == 0:
        parser.error('At least one trace file required')

    if options.output:
        output_filename = options.output
    elif len(args) > 1:
        parser.error('Must specify --output if >1 trace file')
    else:
        namepart = os.path.splitext(args[0])[0]
        output_filename = namepart + '.html'

    with codecs.open(output_filename, mode='w', encoding='utf-8') as f:
        WriteHTMLForTracesToFile(args, f, config_name=options.config_name)

    if not options.quiet:
        print output_filename
    return 0
def main(args):
    parser = optparse.OptionParser(usage="%prog --outdir=<directory>")
    parser.add_option("--outdir",
                      dest="out_dir",
                      help="Where to place generated content")
    options, args = parser.parse_args(args)

    if not options.out_dir:
        sys.stderr.write("ERROR: Must specify --outdir=<directory>")
        parser.print_help()
        return 1

    filenames = ["about_tracing.html"]
    project = trace_viewer_project.TraceViewerProject()
    load_sequence = project.CalcLoadSequenceForModuleFilenames(filenames)

    olddir = os.getcwd()
    try:
        o = open(os.path.join(options.out_dir, "about_tracing.html"), 'w')
        try:
            tvcm.GenerateStandaloneHTMLToFile(o,
                                              load_sequence,
                                              title='chrome://tracing',
                                              flattened_js_url='tracing.js')
        except tvcm.module.DepsException, ex:
            sys.stderr.write("Error: %s\n\n" % str(ex))
            return 255
        o.close()

        o = open(os.path.join(options.out_dir, "about_tracing.js"), 'w')
        tvcm.GenerateJSToFile(o,
                              load_sequence,
                              use_include_tags_for_scripts=True,
                              dir_for_include_tag_root=options.out_dir)
        o.close()
Ejemplo n.º 9
0
def GetKnownFiles():
  p = trace_viewer_project.TraceViewerProject()
  m = p.loader.LoadModule(module_name='extras.about_tracing.about_tracing')
  absolute_filenames = m.GetAllDependentFilenamesRecursive(
      include_raw_scripts=False)

  return list(set([os.path.relpath(f, p.trace_viewer_path)
                   for f in absolute_filenames]))
Ejemplo n.º 10
0
def Main(args):
    tvp = trace_viewer_project.TraceViewerProject()
    input_api = InputAPI(tvp)
    results = RunChecks(input_api)
    print '\n\n'.join(results)

    if len(results):
        return 255
    return 0
Ejemplo n.º 11
0
def WriteHTMLForTracesToFile(trace_filenames, output_file):
  project = trace_viewer_project.TraceViewerProject()
  load_sequence = project.CalcLoadSequenceForModuleNames(
      ['build.trace2html'])

  scripts = [ViewerDataScript(x) for x in trace_filenames]

  title = "Trace from %s" % ','.join(trace_filenames)
  generate.GenerateStandaloneHTMLToFile(
      output_file, load_sequence, title, extra_scripts=scripts)
Ejemplo n.º 12
0
def GypCheck():
  f = open(GYP_FILE, 'r')
  gyp = f.read()
  f.close()

  data = eval(gyp)
  gyp_files = []
  for group in FILE_GROUPS:
    gyp_files.extend(map(os.path.normpath, data["variables"][group]))

  project = trace_viewer_project.TraceViewerProject()
  known_files = []
  build_dir = os.path.join(project.src_path, 'build')
  def handle(dirpath, dirnames, filenames):
    for name in filenames:
      if not (name.endswith(("_test.js",
                             "_test_data.js",
                             "tests.html",
                             ".py",
                             ".pyc")) or
         name.startswith((".")) or
         dirpath == build_dir):
        x = os.path.relpath(os.path.normpath(os.path.join(dirpath, name)),
                            project.trace_viewer_path)
        known_files.append(x)
    if '.svn' in dirnames:
      dirnames.remove('.svn')

  for (dirpath, dirnames, filenames) in os.walk(project.src_path):
    handle(dirpath, dirnames, filenames)

  for (dirpath, dirnames, filenames) in os.walk(
      os.path.join(project.tvcm_path, 'src')):
    handle(dirpath, dirnames, filenames)

  u = set(gyp_files).union(set(known_files))
  i = set(gyp_files).intersection(set(known_files))
  diff = list(u - i)

  if len(diff) == 0:
    return ''

  error = 'Entries in ' + GYP_FILE + ' do not match files on disk:\n'
  in_gyp_only = list(set(gyp_files) - set(known_files))
  in_known_only = list(set(known_files) - set(gyp_files))

  if len(in_gyp_only) > 0:
    error += '  In GYP only:\n    ' + '\n    '.join(sorted(in_gyp_only))
  if len(in_known_only) > 0:
    if len(in_gyp_only) > 0:
      error += '\n\n'
    error += '  On disk only:\n    ' + '\n    '.join(sorted(in_known_only))

  return error
Ejemplo n.º 13
0
def Main(port, args):
  project = trace_viewer_project.TraceViewerProject()

  server = tvcm.DevServer(port=port, project=project)
  server.AddPathHandler('/json/examples', do_GET_json_examples)
  server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp)

  server.AddSourcePathMapping(project.trace_viewer_path)
  server.AddTestLink('/examples/skia_debugger.html', 'Skia Debugger')
  server.AddTestLink('/examples/trace_viewer.html', 'Trace File Viewer')
  server.serve_forever()
Ejemplo n.º 14
0
def WriteHTMLForTraceDataToFile(trace_data_list, title, output_file):
    project = trace_viewer_project.TraceViewerProject()
    load_sequence = project.CalcLoadSequenceForModuleNames(
        ['build.trace2html'])
    scripts = [
        ViewerDataScript(json.dumps(trace_data))
        for trace_data in trace_data_list
    ]
    generate.GenerateStandaloneHTMLToFile(output_file,
                                          load_sequence,
                                          title,
                                          extra_scripts=scripts)
Ejemplo n.º 15
0
def main():
    project = trace_viewer_project.TraceViewerProject()

    sys.path.append(
        os.path.join(project.trace_viewer_third_party_path, 'python_gflags'))
    sys.path.append(
        os.path.join(project.trace_viewer_third_party_path, 'closure_linter'))

    from closure_linter import fixjsstyle

    os.chdir(project.src_path)

    fixjsstyle.main()
Ejemplo n.º 16
0
def Main(args):

    parser = optparse.OptionParser(
        usage="%prog <options>",
        epilog="""Produces a standalone html import that contains the
trace viewer.""")

    project = trace_viewer_project.TraceViewerProject()
    project.AddConfigNameOptionToParser(parser)

    parser.add_option('--no-min',
                      dest='no_min',
                      default=False,
                      action='store_true',
                      help='skip minification')
    parser.add_option('--report-sizes',
                      dest='report_sizes',
                      default=False,
                      action='store_true',
                      help='Explain what makes trace_viewer big.')
    parser.add_option('--report-deps',
                      dest='report_deps',
                      default=False,
                      action='store_true',
                      help='Print a dot-formatted deps graph.')
    parser.add_option("--output",
                      dest="output",
                      help='Where to put the generated result. If not ' +
                      'given, $TRACE_VIEWER/bin/trace_viewer.html is used.')

    options, args = parser.parse_args(args)
    if len(args) != 0:
        parser.error('No arguments needed.')

    trace_viewer_dir = os.path.relpath(
        os.path.join(os.path.dirname(__file__), '..', '..'))
    if options.output:
        output_filename = options.output
    else:
        output_filename = os.path.join(
            trace_viewer_dir, 'bin/trace_viewer_%s.html' % options.config_name)

    with codecs.open(output_filename, 'w', encoding='utf-8') as f:
        WriteTraceViewer(f,
                         config_name=options.config_name,
                         minify=not options.no_min,
                         report_sizes=options.report_sizes,
                         report_deps=options.report_deps)

    return 0
def main(args):
    parser = optparse.OptionParser(usage="%prog --outdir=<directory>")
    parser.add_option("--outdir",
                      dest="out_dir",
                      help="Where to place generated content")
    parser.add_option('--no-min',
                      dest='no_min',
                      default=False,
                      action='store_true',
                      help='skip minification')
    options, args = parser.parse_args(args)

    if not options.out_dir:
        sys.stderr.write("ERROR: Must specify --outdir=<directory>")
        parser.print_help()
        return 1

    filenames = ["extras/about_tracing/about_tracing.html"]
    project = trace_viewer_project.TraceViewerProject()
    load_sequence = project.CalcLoadSequenceForModuleFilenames(filenames)

    olddir = os.getcwd()
    try:
        if not os.path.exists(options.out_dir):
            os.makedirs(options.out_dir)
        o = codecs.open(os.path.join(options.out_dir, "about_tracing.html"),
                        'w',
                        encoding='utf-8')
        try:
            tvcm.GenerateStandaloneHTMLToFile(o,
                                              load_sequence,
                                              title='chrome://tracing',
                                              flattened_js_url='tracing.js',
                                              minify=not options.no_min)
        except tvcm.module.DepsException, ex:
            sys.stderr.write("Error: %s\n\n" % str(ex))
            return 255
        o.close()

        o = codecs.open(os.path.join(options.out_dir, "about_tracing.js"),
                        'w',
                        encoding='utf-8')
        assert o.encoding == 'utf-8'
        tvcm.GenerateJSToFile(o,
                              load_sequence,
                              use_include_tags_for_scripts=False,
                              dir_for_include_tag_root=options.out_dir,
                              minify=not options.no_min)
        o.close()
Ejemplo n.º 18
0
def Main(paths_to_lint):
    project = trace_viewer_project.TraceViewerProject()
    new_paths = [
        os.path.abspath(
            os.path.join(project.trace_viewer_third_party_path,
                         'python_gflags')),
        os.path.abspath(
            os.path.join(project.trace_viewer_third_party_path,
                         'closure_linter'))
    ]
    sys.path += new_paths
    try:
        _MainImpl(paths_to_lint)
    finally:
        for p in new_paths:
            sys.path.remove(p)
Ejemplo n.º 19
0
def WriteHTMLForTraceDataToFile(trace_data_list, title, output_file):
    project = trace_viewer_project.TraceViewerProject()
    load_sequence = project.CalcLoadSequenceForModuleNames(
        ['build.trace2html'])
    scripts = []
    for trace_data in trace_data_list:
        # If the object was previously decoded from valid JSON data (e.g., in
        # WriteHTMLForTracesToFile), it will be a JSON object at this point and we
        # should re-serialize it into a string. Other types of data will be already
        # be strings.
        if not isinstance(trace_data, basestring):
            trace_data = json.dumps(trace_data)
            mime_type = 'application/json'
        else:
            mime_type = 'text/plain'
        scripts.append(ViewerDataScript(trace_data, mime_type))
    generate.GenerateStandaloneHTMLToFile(output_file,
                                          load_sequence,
                                          title,
                                          extra_scripts=scripts)
def Main(args):
    port = 8003
    project = trace_viewer_project.TraceViewerProject()

    server = tvcm.DevServer(port=port, project=project)
    server.AddPathHandler('/json/examples', do_GET_json_examples)
    server.AddPathHandler('/tv/json/tests', do_GET_json_tests)
    server.AddPathHandler('/json/examples/skp', do_GET_json_examples_skp)

    server.AddSourcePathMapping(project.trace_viewer_path)
    server.AddTestLink('/examples/skia_debugger.html', 'Skia Debugger')
    server.AddTestLink('/examples/trace_viewer.html', 'Trace File Viewer')

    server.AddPathHandler('/test_automation/notify_test_result',
                          do_POST_report_test_results,
                          supports_post=True)
    server.AddPathHandler('/test_automation/notify_completion',
                          do_POST_report_test_completion,
                          supports_post=True)

    server.serve_forever()
Ejemplo n.º 21
0
def CheckCommon(file_name, listed_files):
    project = trace_viewer_project.TraceViewerProject()
    build_dir = os.path.join(project.src_path, 'build')

    known_files = GetKnownFiles()
    u = set(listed_files).union(set(known_files))
    i = set(listed_files).intersection(set(known_files))
    diff = list(u - i)

    if len(diff) == 0:
        return ''

    error = 'Entries in ' + file_name + ' do not match files on disk:\n'
    in_file_only = list(set(listed_files) - set(known_files))
    in_known_only = list(set(known_files) - set(listed_files))

    if len(in_file_only) > 0:
        error += '  In file only:\n    ' + '\n    '.join(sorted(in_file_only))
    if len(in_known_only) > 0:
        if len(in_file_only) > 0:
            error += '\n\n'
        error += '  On disk only:\n    ' + '\n    '.join(sorted(in_known_only))

    return error
Ejemplo n.º 22
0
def CheckModules():
  p = trace_viewer_project.TraceViewerProject()
  try:
    p.CalcLoadSequenceForAllModules()
  except Exception, ex:
    return str(ex)
Ejemplo n.º 23
0
def UpdateGn():
    tvp = trace_viewer_project.TraceViewerProject()
    _UpdateBuildFile(os.path.join(tvp.trace_viewer_path, 'BUILD.gn'), GnFile)
Ejemplo n.º 24
0
def GetResults(diff_base):
    tvp = trace_viewer_project.TraceViewerProject()
    input_api = InputAPI(tvp, diff_base)
    return RunChecks(input_api)
def load_tests(loader, tests, pattern):
    project = trace_viewer_project.TraceViewerProject()
    return module_test_case.DiscoverTestsInModule(project, project.src_path)
Ejemplo n.º 26
0
def UpdateGypi():
    tvp = trace_viewer_project.TraceViewerProject()
    _UpdateBuildFile(os.path.join(tvp.trace_viewer_path, 'trace_viewer.gypi'),
                     GypiFile)
Ejemplo n.º 27
0
 def Run(self):
     project = trace_viewer_project.TraceViewerProject()
     load_sequence = project.CalcLoadSequenceForAllModules()
Ejemplo n.º 28
0
 def SetUp():
     self.project = trace_viewer_project.TraceViewerProject()
     self.load_sequence = project.CalcLoadSequenceForAllModules()
Ejemplo n.º 29
0
 def Run(self):
     project = trace_viewer_project.TraceViewerProject()
     filenames = project.FindAllModuleFilenames()