<commit_before>#!/usr/bin/python
# Copyright (c) 2011 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Enable 'with' statements in Python 2.5
from __future__ import with_statement

import os.path
import sys

from buildbot_lib import (
    BuildContext, BuildStatus, Command, EnsureDirectoryExists,
    ParseStandardCommandLine, RemoveDirectory, RunBuild, SCons, Step, StepLink,
    StepText, TryToCleanContents)


# Windows-specific environment manipulation
def SetupWindowsEnvironment(context):
  context.SetEnv('GYP_MSVS_VERSION', '2008')

  # Blow away path for now if on the bots (to be more hermetic).
  if os.environ.get('BUILDBOT_SLAVENAME'):
    paths = [
        r'c:\b\depot_tools',
        r'c:\b\depot_tools\python_bin',
        r'c:\b\build_internal\tools',
        r'e:\b\depot_tools',
        r'e:\b\depot_tools\python_bin',
        r'e:\b\build_internal\tools',
        r'C:\WINDOWS\system32',
        r'C:\WINDOWS\system32\WBEM',
        ]
    context.SetEnv('PATH', os.pathsep.join(paths))

  # Poke around looking for MSVC.  We should do something more principled in
  # the future.

  # The name of Program Files can differ, depending on the bittage of Windows.
  program_files = r'c:\Program Files (x86)'
  if not os.path.exists(program_files):
    program_files = r'c:\Program Files'
    if not os.path.exists(program_files):
      raise Exception('Cannot find the Program Files directory!')

  # The location of MSVC can differ depending on the version.
  msvc_locs = [
      # TODO(ncbray) use msvc 10.  This will require changing GYP_MSVS_VERSION.
      #('Microsoft Visual Studio 10.0', 'VS100COMNTOOLS'),
      ('Microsoft Visual Studio 9.0', 'VS90COMNTOOLS'),
      ('Microsoft Visual Studio 8.0', 'VS80COMNTOOLS'),
  ]

  for dirname, comntools_var in msvc_locs:
    msvc = os.path.join(program_files, dirname)
    if os.path.exists(msvc):
      break
  else:
    # The break statement did not execute.
    raise Exception('Cannot find MSVC!')

  # Put MSVC in the path.
  vc = os.path.join(msvc, 'VC')
  comntools = os.path.join(msvc, 'Common7', 'Tools')
  perf = os.path.join(msvc, 'Team Tools', 'Performance Tools')
  context.SetEnv('PATH', os.pathsep.join([
      context.GetEnv('PATH'),
      vc,
      comntools,
      perf]))

  # SCons needs this variable to find vsvars.bat.
  # The end slash is needed because the batch files expect it.
  context.SetEnv(comntools_var, comntools + '\\')

  # This environment variable will SCons to print debug info while it searches
  # for MSVC.
  context.SetEnv('SCONS_MSCOMMON_DEBUG', '-')

  # Needed for finding devenv.
  context['msvc'] = msvc


def SetupLinuxEnvironment(context):
  context.SetEnv('GYP_DEFINES', 'target_arch='+context['gyp_arch'])


def SetupMacEnvironment(context):
  pass


def UploadIrtBinary(status, context, branch):
  if context.Linux():
    with Step('archive irt.nexe', status):
      # Upload the integrated runtime (IRT) library so that it can be pulled
      # into the Chromium build, so that a NaCl toolchain will not be needed
      # to build a NaCl-enabled Chromium.  We strip the IRT to save space
      # and download time.
      # TODO(mseaborn): It might be better to do the stripping in Scons.
      irt_path = 'scons-out/nacl_irt-x86-%s/staging/irt.nexe' % context['bits']
      stripped_irt_path = irt_path + '.stripped'

      if os.environ.get('ARCHIVE_IRT') == '1':
        Command(
          context,
          cmd=['toolchain/linux_x86_newlib/bin/nacl-strip',
               '--strip-debug',
               irt_path,
               '-o', stripped_irt_path])

        irt_dir = 'nativeclient-archive2/irt'
        if branch != 'native_client':
          irt_dir = '%s/branches/%s' % (irt_dir, branch)
        gsdview = 'http://gsdview.appspot.com'
        rev = os.environ['BUILDBOT_GOT_REVISION']
        gs_path = '%s/r%s/irt_x86_%s.nexe' % (irt_dir, rev, context['bits'])

        def GSCPCommand(context, cmd):
          gs_util = '/b/build/scripts/slave/gsutil'
          Command(context, cmd=[gs_util, '-h', 'Cache-Control:no-cache', 'cp',
                                '-a', 'public-read'] + cmd)

        # Upload the stripped IRT<commit_msg>Allow branch to get either native_client (as on the buildbots) or '' as on the trybots. Without this, not all the test are being run on the trybots.<commit_after>#!/usr/bin/python
# Copyright (c) 2011 The Native Client Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Enable 'with' statements in Python 2.5
from __future__ import with_statement

import os.path
import sys

from buildbot_lib import (
    BuildContext, BuildStatus, Command, EnsureDirectoryExists,
    ParseStandardCommandLine, RemoveDirectory, RunBuild, SCons, Step, StepLink,
    StepText, TryToCleanContents)


# Windows-specific environment manipulation
def SetupWindowsEnvironment(context):
  context.SetEnv('GYP_MSVS_VERSION', '2008')

  # Blow away path for now if on the bots (to be more hermetic).
  if os.environ.get('BUILDBOT_SLAVENAME'):
    paths = [
        r'c:\b\depot_tools',
        r'c:\b\depot_tools\python_bin',
        r'c:\b\build_internal\tools',
        r'e:\b\depot_tools',
        r'e:\b\depot_tools\python_bin',
        r'e:\b\build_internal\tools',
        r'C:\WINDOWS\system32',
        r'C:\WINDOWS\system32\WBEM',
        ]
    context.SetEnv('PATH', os.pathsep.join(paths))

  # Poke around looking for MSVC.  We should do something more principled in
  # the future.

  # The name of Program Files can differ, depending on the bittage of Windows.
  program_files = r'c:\Program Files (x86)'
  if not os.path.exists(program_files):
    program_files = r'c:\Program Files'
    if not os.path.exists(program_files):
      raise Exception('Cannot find the Program Files directory!')

  # The location of MSVC can differ depending on the version.
  msvc_locs = [
      # TODO(ncbray) use msvc 10.  This will require changing GYP_MSVS_VERSION.
      #('Microsoft Visual Studio 10.0', 'VS100COMNTOOLS'),
      ('Microsoft Visual Studio 9.0', 'VS90COMNTOOLS'),
      ('Microsoft Visual Studio 8.0', 'VS80COMNTOOLS'),
  ]

  for dirname, comntools_var in msvc_locs:
    msvc = os.path.join(program_files, dirname)
    if os.path.exists(msvc):
      break
  else:
    # The break statement did not execute.
    raise Exception('Cannot find MSVC!')

  # Put MSVC in the path.
  vc = os.path.join(msvc, 'VC')
  comntools = os.path.join(msvc, 'Common7', 'Tools')
  perf = os.path.join(msvc, 'Team Tools', 'Performance Tools')
  context.SetEnv('PATH', os.pathsep.join([
      context.GetEnv('PATH'),
      vc,
      comntools,
      perf]))

  # SCons needs this variable to find vsvars.bat.
  # The end slash is needed because the batch files expect it.
  context.SetEnv(comntools_var, comntools + '\\')

  # This environment variable will SCons to print debug info while it searches
  # for MSVC.
  context.SetEnv('SCONS_MSCOMMON_DEBUG', '-')

  # Needed for finding devenv.
  context['msvc'] = msvc


def SetupLinuxEnvironment(context):
  context.SetEnv('GYP_DEFINES', 'target_arch='+context['gyp_arch'])


def SetupMacEnvironment(context):
  pass


def UploadIrtBinary(status, context, branch):
  if context.Linux():
    with Step('archive irt.nexe', status):
      # Upload the integrated runtime (IRT) library so that it can be pulled
      # into the Chromium build, so that a NaCl toolchain will not be needed
      # to build a NaCl-enabled Chromium.  We strip the IRT to save space
      # and download time.
      # TODO(mseaborn): It might be better to do the stripping in Scons.
      irt_path = 'scons-out/nacl_irt-x86-%s/staging/irt.nexe' % context['bits']
      stripped_irt_path = irt_path + '.stripped'

      if os.environ.get('ARCHIVE_IRT') == '1':
        Command(
          context,
          cmd=['toolchain/linux_x86_newlib/bin/nacl-strip',
               '--strip-debug',
               irt_path,
               '-o', stripped_irt_path])

        irt_dir = 'nativeclient-archive2/irt'
        # The branch is set to native_client on the main bots,
        # on the trybots its set to ''. Otherwise, we should assume a
        # particular branch is being used.
        if branch not in ['native_client', '']:
          irt_dir = '%s/branches/%s' % (irt_dir, branch)
        gsdview = 'http://gsdview.appspot.com'
        rev = os.environ['BUILDBOT_GOT_REVISION']
        gs_path = '%s/r%s/irt_x86_%s.nexe' % (irt_dir, rev, context['bits'])

        def GSCPCommand(context, cmd):
          gs_util = '/b/build/scripts/slave/gsutil'
          Command(context, cmd=[gs_util, '-h', 'Cache-Control:no-cache', 'cp',
                                '-a', 'public-read'] + cmd)

        # Upload the stripped IRT
{'fraction_non_alphanumeric': 0.1156140943374986, 'fraction_numerical': 0.009231115614094338, 'mean_word_length': 3.0054102795311093, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2335436', 'n_tokens_mistral': 2983, 'n_tokens_neox': 2863, 'n_words': 813}