<commit_before>#!/usr/bin/python


import gyp
import gyp.common
# TODO(sgk):  create a separate "project module" for SCons?
#import gyp.SCons as SCons
import os
import pprint
import re


generator_default_variables = {
    'EXECUTABLE_PREFIX': '',
    'EXECUTABLE_SUFFIX': '',
    'INTERMEDIATE_DIR': '$OBJ_DIR/$COMPONENT_NAME/$TARGET_NAME/intermediate',
    'SHARED_INTERMEDIATE_DIR': '$OBJ_DIR/global_intermediate',
    'OS': 'linux',
    'PRODUCT_DIR': '$TOP_BUILDDIR',
    'RULE_INPUT_ROOT': '${SOURCE.filebase}',
    'RULE_INPUT_EXT': '${SOURCE.suffix}',
    'RULE_INPUT_NAME': '${SOURCE.file}',
    'RULE_INPUT_PATH': '${SOURCE}',
}


header = """\
# This file is generated; do not edit.
"""


def WriteList(fp, list, prefix='',
                        separator=',\n    ',
                        preamble=None,
                        postamble=None):
  fp.write(preamble or '')
  fp.write((separator or ' ').join([prefix + l for l in list]))
  fp.write(postamble or '')


def full_product_name(spec, prefix='', suffix=''):
  name = spec.get('product_name') or spec['target_name']
  name = prefix + name + suffix
  product_dir = spec.get('product_dir')
  if product_dir:
    name = os.path.join(product_dir, name)
  return name


def _SCons_null_writer(fp, spec):
  pass

def _SCons_writer(fp, spec, builder, pre=''):
  fp.write('\n' + pre)
  fp.write('_outputs = %s\n' % builder)
  fp.write('target_files.extend(_outputs)\n')

def _SCons_program_writer(fp, spec):
  # On Linux, an executable name like 'chrome' could be either the
  # on-disk executable or the Alias that represents the 'chrome' target.
  # Disambiguate that the program we're building is, in fact, the
  # on-disk target, so other dependent targets can't get confused.
  name = full_product_name(spec)
  pre = '_program = env.File(\'${PROGPREFIX}%s${PROGSUFFIX}\')\n' % name
  builder = 'env.ChromeProgram(_program, input_files)'
  return _SCons_writer(fp, spec, builder, pre)

def _SCons_static_library_writer(fp, spec):
  name = full_product_name(spec)
  builder = 'env.ChromeStaticLibrary(\'%s\', input_files)' % name
  return _SCons_writer(fp, spec, builder)

def _SCons_shared_library_writer(fp, spec):
  name = full_product_name(spec)
  builder = 'env.ChromeSharedLibrary(\'%s\', input_files)' % name
  return _SCons_writer(fp, spec, builder)

def _SCons_loadable_module_writer(fp, spec):
  name = full_product_name(spec)
  builder = 'env.ChromeLoadableModule(\'%s\', input_files)' % name
  return _SCons_writer(fp, spec, builder)

SConsTypeWriter = {
  None : _SCons_null_writer,
  'none' : _SCons_null_writer,
  'executable' : _SCons_program_writer,
  'static_library' : _SCons_static_library_writer,
  'shared_library' : _SCons_shared_library_writer,
  'loadable_module' : _SCons_loadable_module_writer,
}

_command_template = """
if GetOption('verbose'):
  _action = Action([%(action)s])
else:
  _action = Action([%(action)s], %(message)s)
_outputs = env.Command(
  %(outputs)s,
  %(inputs)s,
  _action
)
"""

_rule_template = """
%(name)s_additional_inputs = %(inputs)s
%(name)s_outputs = %(outputs)s
def %(name)s_emitter(target, source, env):
  return (%(name)s_outputs, source + %(name)s_additional_inputs)
if GetOption('verbose'):
  %(name)s_action = Action([%(action)s])
else:
  %(name)s_action = Action([%(action)s], %(message)s)
env['BUILDERS']['%(name)s'] = Builder(action=%(name)s_action, emitter=%(name)s_emitter)
%(name)s_files = [f for f in input_files if str(f).endswith('.%(extension)s')]
for %(name)s_file in %(name)s_files:
  _outputs = env.%(name)s(%(name)s_file)
"""

_spawn_hack = """
import re
import SCons.Platform.posix
needs_shell = re.compile('["\\'><!^&]')
def my_spawn(sh, escape, cmd, args, env):
  def strip_scons_quotes(arg):
    if arg[0] == '"' and arg[-1] == '#':
      return arg[1:-1]
    return arg
  cmd_line = ' '.join(args)
  if needs_shell.search(cmd_line):
    return SCons.Platform.posix.exec_spawnvpe([sh, '-c', cmd_line], env)
  else:
    return SCons.Platform.posix.exec_spawnvpe(args, env)
env['SPAWN'] = my_spawn
"""<commit_msg>Fix quote stripping in the line-length workaround. Review URL: http://codereview.chromium.org/57041<commit_after>#!/usr/bin/python


import gyp
import gyp.common
# TODO(sgk):  create a separate "project module" for SCons?
#import gyp.SCons as SCons
import os
import pprint
import re


generator_default_variables = {
    'EXECUTABLE_PREFIX': '',
    'EXECUTABLE_SUFFIX': '',
    'INTERMEDIATE_DIR': '$OBJ_DIR/$COMPONENT_NAME/$TARGET_NAME/intermediate',
    'SHARED_INTERMEDIATE_DIR': '$OBJ_DIR/global_intermediate',
    'OS': 'linux',
    'PRODUCT_DIR': '$TOP_BUILDDIR',
    'RULE_INPUT_ROOT': '${SOURCE.filebase}',
    'RULE_INPUT_EXT': '${SOURCE.suffix}',
    'RULE_INPUT_NAME': '${SOURCE.file}',
    'RULE_INPUT_PATH': '${SOURCE}',
}


header = """\
# This file is generated; do not edit.
"""


def WriteList(fp, list, prefix='',
                        separator=',\n    ',
                        preamble=None,
                        postamble=None):
  fp.write(preamble or '')
  fp.write((separator or ' ').join([prefix + l for l in list]))
  fp.write(postamble or '')


def full_product_name(spec, prefix='', suffix=''):
  name = spec.get('product_name') or spec['target_name']
  name = prefix + name + suffix
  product_dir = spec.get('product_dir')
  if product_dir:
    name = os.path.join(product_dir, name)
  return name


def _SCons_null_writer(fp, spec):
  pass

def _SCons_writer(fp, spec, builder, pre=''):
  fp.write('\n' + pre)
  fp.write('_outputs = %s\n' % builder)
  fp.write('target_files.extend(_outputs)\n')

def _SCons_program_writer(fp, spec):
  # On Linux, an executable name like 'chrome' could be either the
  # on-disk executable or the Alias that represents the 'chrome' target.
  # Disambiguate that the program we're building is, in fact, the
  # on-disk target, so other dependent targets can't get confused.
  name = full_product_name(spec)
  pre = '_program = env.File(\'${PROGPREFIX}%s${PROGSUFFIX}\')\n' % name
  builder = 'env.ChromeProgram(_program, input_files)'
  return _SCons_writer(fp, spec, builder, pre)

def _SCons_static_library_writer(fp, spec):
  name = full_product_name(spec)
  builder = 'env.ChromeStaticLibrary(\'%s\', input_files)' % name
  return _SCons_writer(fp, spec, builder)

def _SCons_shared_library_writer(fp, spec):
  name = full_product_name(spec)
  builder = 'env.ChromeSharedLibrary(\'%s\', input_files)' % name
  return _SCons_writer(fp, spec, builder)

def _SCons_loadable_module_writer(fp, spec):
  name = full_product_name(spec)
  builder = 'env.ChromeLoadableModule(\'%s\', input_files)' % name
  return _SCons_writer(fp, spec, builder)

SConsTypeWriter = {
  None : _SCons_null_writer,
  'none' : _SCons_null_writer,
  'executable' : _SCons_program_writer,
  'static_library' : _SCons_static_library_writer,
  'shared_library' : _SCons_shared_library_writer,
  'loadable_module' : _SCons_loadable_module_writer,
}

_command_template = """
if GetOption('verbose'):
  _action = Action([%(action)s])
else:
  _action = Action([%(action)s], %(message)s)
_outputs = env.Command(
  %(outputs)s,
  %(inputs)s,
  _action
)
"""

_rule_template = """
%(name)s_additional_inputs = %(inputs)s
%(name)s_outputs = %(outputs)s
def %(name)s_emitter(target, source, env):
  return (%(name)s_outputs, source + %(name)s_additional_inputs)
if GetOption('verbose'):
  %(name)s_action = Action([%(action)s])
else:
  %(name)s_action = Action([%(action)s], %(message)s)
env['BUILDERS']['%(name)s'] = Builder(action=%(name)s_action, emitter=%(name)s_emitter)
%(name)s_files = [f for f in input_files if str(f).endswith('.%(extension)s')]
for %(name)s_file in %(name)s_files:
  _outputs = env.%(name)s(%(name)s_file)
"""

_spawn_hack = """
import re
import SCons.Platform.posix
needs_shell = re.compile('["\\'><!^&]')
def my_spawn(sh, escape, cmd, args, env):
  def strip_scons_quotes(arg):
    if arg[0] == '"' and arg[-1] == '"':
      return arg[1:-1]
    return arg
  args = [strip_scons_quotes(a) for a in args]
  cmd_line = ' '.join(args)
  if needs_shell.search(cmd_line):
    return SCons.Platform.posix.exec_spawnvpe([sh, '-c', cmd_line], env)
  else:
    return SCons.Platform.posix.exec_spawnvpe(args, env)
env['SPAWN'] = my_spawn
"""
{'fraction_non_alphanumeric': 0.1591762568140521, 'fraction_numerical': 0.0015748031496062992, 'mean_word_length': 4.70954356846473, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2824773', 'n_tokens_mistral': 3074, 'n_tokens_neox': 2998, 'n_words': 623}