<commit_before># Copyright (c) 2012 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.

from master.factory import gclient_factory
from master.factory import chromium_commands

import config


class WebRTCFactory(gclient_factory.GClientFactory):

  CUSTOM_VARS_ROOT_DIR = ('root_dir', 'src')
  # Can't use the same Valgrind constant as in chromium_factory.py, since WebRTC
  # uses another path (use_relative_paths=True in DEPS).
  CUSTOM_DEPS_VALGRIND = ('third_party/valgrind',
     config.Master.trunk_url + '/deps/third_party/valgrind/binaries')

  def __init__(self, build_dir, target_platform, svn_root_url, branch,
               custom_deps_list=None):
    """Creates a WebRTC factory.

    This factory can also be used to build stand-alone projects.

    Args:
      build_dir: Directory to perform the build relative to. Usually this is
        trunk/build for WebRTC and other projects.
      target_platform: Platform, one of 'win32', 'darwin', 'linux2'
      svn_root_url: Subversion root URL (i.e. without branch/trunk part).
      branch: Branch name to checkout.
      custom_deps_list: Content to be put in the custom_deps entry of the
        .gclient file for the default solution. The parameter must be a list
        of tuples with two strings in each: path and remote URL.
    """
    svn_url = svn_root_url + branch
    # Use root_dir=src since many Chromium scripts rely on that path.
    custom_vars_list = [self.CUSTOM_VARS_ROOT_DIR]
    solutions = []
    solutions.append(gclient_factory.GClientSolution(
        svn_url, name='src', custom_vars_list=custom_vars_list,
        custom_deps_list=custom_deps_list))
    self._branch = branch
    gclient_factory.GClientFactory.__init__(self, build_dir, solutions,
                                            target_platform=target_platform)

  def WebRTCFactory(self, target='Debug', clobber=False, tests=None, mode=None,
                    slave_type='BuilderTester', options=None,
                    compile_timeout=1200, build_url=None, project=None,
                    factory_properties=None, gclient_deps=None, webcam=False):
    options = options or ''
    tests = tests or []
    factory_properties = factory_properties or {}

    # Make sure the gclient_env dict exists with key GYP_DEFINES.
    if not 'GYP_DEFINES' in factory_properties.get('gclient_env', ''):
      factory_properties['gclient_env'] = {'GYP_DEFINES': ''}

    # Always use fastbuild=1
    if 'fastbuild=1' not in factory_properties['gclient_env']['GYP_DEFINES']:
      factory_properties['gclient_env']['GYP_DEFINES'] += ' fastbuild=1'

    if factory_properties.get('needs_valgrind'):
      self._solutions[0].custom_deps_list = [self.CUSTOM_DEPS_VALGRIND]
    factory = self.BuildFactory(target, clobber, tests, mode, slave_type,
                                options, compile_timeout, build_url, project,
                                factory_properties, gclient_deps)

    # Get the factory command object to create new steps to the factory.
    cmds = chromium_commands.ChromiumCommands(factory, target,
                                                 self._build_dir,
                                                 self._target_platform)
    # Override test runner script paths with our own that can run any test and
    # have our suppressions configured.
    cmds._posix_memory_tests_runner = cmds.PathJoin(
        cmds._repository_root, 'tools', 'valgrind-webrtc', 'webrtc_tests.sh')
    cmds._win_memory_tests_runner = cmds.PathJoin(
        cmds._repository_root, 'tools', 'valgrind-webrtc', 'webrtc_tests.bat')

    cmds.AddWebRTCTests(tests, factory_properties)
    return factory<commit_msg>Disable pylint warning for accessing _repository_root.<commit_after># Copyright (c) 2012 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.

from master.factory import gclient_factory
from master.factory import chromium_commands

import config


class WebRTCFactory(gclient_factory.GClientFactory):

  CUSTOM_VARS_ROOT_DIR = ('root_dir', 'src')
  # Can't use the same Valgrind constant as in chromium_factory.py, since WebRTC
  # uses another path (use_relative_paths=True in DEPS).
  CUSTOM_DEPS_VALGRIND = ('third_party/valgrind',
     config.Master.trunk_url + '/deps/third_party/valgrind/binaries')

  def __init__(self, build_dir, target_platform, svn_root_url, branch,
               custom_deps_list=None):
    """Creates a WebRTC factory.

    This factory can also be used to build stand-alone projects.

    Args:
      build_dir: Directory to perform the build relative to. Usually this is
        trunk/build for WebRTC and other projects.
      target_platform: Platform, one of 'win32', 'darwin', 'linux2'
      svn_root_url: Subversion root URL (i.e. without branch/trunk part).
      branch: Branch name to checkout.
      custom_deps_list: Content to be put in the custom_deps entry of the
        .gclient file for the default solution. The parameter must be a list
        of tuples with two strings in each: path and remote URL.
    """
    svn_url = svn_root_url + branch
    # Use root_dir=src since many Chromium scripts rely on that path.
    custom_vars_list = [self.CUSTOM_VARS_ROOT_DIR]
    solutions = []
    solutions.append(gclient_factory.GClientSolution(
        svn_url, name='src', custom_vars_list=custom_vars_list,
        custom_deps_list=custom_deps_list))
    self._branch = branch
    gclient_factory.GClientFactory.__init__(self, build_dir, solutions,
                                            target_platform=target_platform)

  def WebRTCFactory(self, target='Debug', clobber=False, tests=None, mode=None,
                    slave_type='BuilderTester', options=None,
                    compile_timeout=1200, build_url=None, project=None,
                    factory_properties=None, gclient_deps=None, webcam=False):
    options = options or ''
    tests = tests or []
    factory_properties = factory_properties or {}

    # Make sure the gclient_env dict exists with key GYP_DEFINES.
    if not 'GYP_DEFINES' in factory_properties.get('gclient_env', ''):
      factory_properties['gclient_env'] = {'GYP_DEFINES': ''}

    # Always use fastbuild=1
    if 'fastbuild=1' not in factory_properties['gclient_env']['GYP_DEFINES']:
      factory_properties['gclient_env']['GYP_DEFINES'] += ' fastbuild=1'

    if factory_properties.get('needs_valgrind'):
      self._solutions[0].custom_deps_list = [self.CUSTOM_DEPS_VALGRIND]
    factory = self.BuildFactory(target, clobber, tests, mode, slave_type,
                                options, compile_timeout, build_url, project,
                                factory_properties, gclient_deps)

    # Get the factory command object to create new steps to the factory.
    cmds = chromium_commands.ChromiumCommands(factory, target,
                                                 self._build_dir,
                                                 self._target_platform)
    # Override test runner script paths with our own that can run any test and
    # have our suppressions configured.
    # pylint: disable=W0212
    cmds._posix_memory_tests_runner = cmds.PathJoin(
        cmds._repository_root, 'tools', 'valgrind-webrtc', 'webrtc_tests.sh')
    cmds._win_memory_tests_runner = cmds.PathJoin(
        cmds._repository_root, 'tools', 'valgrind-webrtc', 'webrtc_tests.bat')

    cmds.AddWebRTCTests(tests, factory_properties)
    return factory
{'fraction_non_alphanumeric': 0.08106329780234241, 'fraction_numerical': 0.0044742729306487695, 'mean_word_length': 3.0816326530612246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5312096', 'n_tokens_mistral': 2276, 'n_tokens_neox': 2194, 'n_words': 608}