Ejemplo n.º 1
0
    def record_subprocess_spawn(process_pid, process_cmdline):
      response_cmdline = []
      for item in process_cmdline:
        if item.startswith('@'):
          response_cmdline += response_file.read_response_file(item)

      with ToolchainProfiler.log_access() as f:
        f.write(',\n{"pid":' + ToolchainProfiler.mypid_str + ',"subprocessPid":' + str(os.getpid()) + ',"op":"spawn","targetPid":' + str(process_pid) + ',"time":' + ToolchainProfiler.timestamp() + ',"cmdLine":["' + '","'.join(ToolchainProfiler.escape_args(process_cmdline + response_cmdline)) + '"]}')
Ejemplo n.º 2
0
def _main(environ):
  response_file = True
  while response_file:
    response_file = None
    for index in range(1, len(sys.argv)):
      if sys.argv[index][0] == '@':
        # found one, loop again next time
        response_file = True
        response_file_args = read_response_file(sys.argv[index])
        # slice in extra_args in place of the response file arg
        sys.argv[index:index+1] = response_file_args
        break

  parser = optparse.OptionParser(
    usage='usage: %prog [-h] [-H HEADERS] [-o OUTFILE] [-c COMPILER_ENGINE] [-s FOO=BAR]* infile',
    description=('You should normally never use this! Use emcc instead. '
                 'This is a wrapper around the JS compiler, converting .ll to .js.'),
    epilog='')
  parser.add_option('-H', '--headers',
                    default=[],
                    action='append',
                    help='System headers (comma separated) whose #defines should be exposed to the compiled code.')
  parser.add_option('-L', '--libraries',
                    default=[],
                    action='append',
                    help='Library files (comma separated) to use in addition to those in emscripten src/library_*.')
  parser.add_option('-o', '--outfile',
                    default=sys.stdout,
                    help='Where to write the output; defaults to stdout.')
  parser.add_option('-c', '--compiler',
                    default=None,
                    help='Which JS engine to use to run the compiler; defaults to the one in ~/.emscripten.')
  parser.add_option('--relooper',
                    default=None,
                    help='Which relooper file to use if RELOOP is enabled.')
  parser.add_option('-s', '--setting',
                    dest='settings',
                    default=[],
                    action='append',
                    metavar='FOO=BAR',
                    help=('Overrides for settings defined in settings.js. '
                          'May occur multiple times.'))
  parser.add_option('-j', '--jcache',
                    action='store_true',
                    default=False,
                    help=('Enable jcache (ccache-like caching of compilation results, for faster incremental builds).'))
  parser.add_option('-T', '--temp-dir',
                    default=None,
                    help=('Where to create temporary files.'))
  parser.add_option('-v', '--verbose',
                    action='store_true',
                    dest='verbose',
                    help='Displays debug output')
  parser.add_option('-q', '--quiet',
                    action='store_false',
                    dest='verbose',
                    help='Hides debug output')
  parser.add_option('--suppressUsageWarning',
                    action='store_true',
                    default=environ.get('EMSCRIPTEN_SUPPRESS_USAGE_WARNING'),
                    help=('Suppress usage warning'))

  # Convert to the same format that argparse would have produced.
  keywords, positional = parser.parse_args()

  if not keywords.suppressUsageWarning:
    print >> sys.stderr, '''
==============================================================
WARNING: You should normally never use this! Use emcc instead.
==============================================================
  '''

  if len(positional) != 1:
    raise RuntimeError('Must provide exactly one positional argument. Got ' + str(len(positional)) + ': "' + '", "'.join(positional) + '"')
  keywords.infile = os.path.abspath(positional[0])
  if isinstance(keywords.outfile, basestring):
    keywords.outfile = open(keywords.outfile, 'w')

  if keywords.relooper:
    relooper = os.path.abspath(keywords.relooper)
  else:
    relooper = None # use the cache

  if keywords.temp_dir is None:
    temp_files = get_configuration().get_temp_files()
    temp_dir = get_configuration().TEMP_DIR
  else:
    temp_dir = os.path.abspath(keywords.temp_dir)
    if not os.path.exists(temp_dir):
      os.makedirs(temp_dir)
    temp_files = tempfiles.TempFiles(temp_dir)

  if keywords.compiler is None:
    from tools import shared
    keywords.compiler = shared.COMPILER_ENGINE

  if keywords.verbose is None:
    DEBUG = get_configuration().DEBUG
    DEBUG_CACHE = get_configuration().DEBUG_CACHE
  else:
    DEBUG = keywords.verbose
    DEBUG_CACHE = keywords.verbose

  cache = cache_module.Cache()
  temp_files.run_and_clean(lambda: main(
    keywords,
    compiler_engine=keywords.compiler,
    cache=cache,
    jcache=cache_module.JCache(cache) if keywords.jcache else None,
    relooper=relooper,
    temp_files=temp_files,
    DEBUG=DEBUG,
    DEBUG_CACHE=DEBUG_CACHE,
  ))
Ejemplo n.º 3
0
def _main(environ):
    response_file = True
    while response_file:
        response_file = None
        for index in range(1, len(sys.argv)):
            if sys.argv[index][0] == '@':
                # found one, loop again next time
                response_file = True
                response_file_args = read_response_file(sys.argv[index])
                # slice in extra_args in place of the response file arg
                sys.argv[index:index + 1] = response_file_args
                break

    parser = optparse.OptionParser(
        usage=
        'usage: %prog [-h] [-H HEADERS] [-o OUTFILE] [-c COMPILER_ENGINE] [-s FOO=BAR]* infile',
        description=(
            'You should normally never use this! Use emcc instead. '
            'This is a wrapper around the JS compiler, converting .ll to .js.'
        ),
        epilog='')
    parser.add_option(
        '-H',
        '--headers',
        default=[],
        action='append',
        help=
        'System headers (comma separated) whose #defines should be exposed to the compiled code.'
    )
    parser.add_option(
        '-L',
        '--libraries',
        default=[],
        action='append',
        help=
        'Library files (comma separated) to use in addition to those in emscripten src/library_*.'
    )
    parser.add_option('-o',
                      '--outfile',
                      default=sys.stdout,
                      help='Where to write the output; defaults to stdout.')
    parser.add_option(
        '-c',
        '--compiler',
        default=None,
        help=
        'Which JS engine to use to run the compiler; defaults to the one in ~/.emscripten.'
    )
    parser.add_option('--relooper',
                      default=None,
                      help='Which relooper file to use if RELOOP is enabled.')
    parser.add_option('-s',
                      '--setting',
                      dest='settings',
                      default=[],
                      action='append',
                      metavar='FOO=BAR',
                      help=('Overrides for settings defined in settings.js. '
                            'May occur multiple times.'))
    parser.add_option(
        '-j',
        '--jcache',
        action='store_true',
        default=False,
        help=
        ('Enable jcache (ccache-like caching of compilation results, for faster incremental builds).'
         ))
    parser.add_option('-T',
                      '--temp-dir',
                      default=None,
                      help=('Where to create temporary files.'))
    parser.add_option('-v',
                      '--verbose',
                      action='store_true',
                      dest='verbose',
                      help='Displays debug output')
    parser.add_option('-q',
                      '--quiet',
                      action='store_false',
                      dest='verbose',
                      help='Hides debug output')
    parser.add_option('--suppressUsageWarning',
                      action='store_true',
                      default=environ.get('EMSCRIPTEN_SUPPRESS_USAGE_WARNING'),
                      help=('Suppress usage warning'))

    # Convert to the same format that argparse would have produced.
    keywords, positional = parser.parse_args()

    if not keywords.suppressUsageWarning:
        print >> sys.stderr, '''
==============================================================
WARNING: You should normally never use this! Use emcc instead.
==============================================================
  '''

    if len(positional) != 1:
        raise RuntimeError(
            'Must provide exactly one positional argument. Got ' +
            str(len(positional)) + ': "' + '", "'.join(positional) + '"')
    keywords.infile = os.path.abspath(positional[0])
    if isinstance(keywords.outfile, basestring):
        keywords.outfile = open(keywords.outfile, 'w')

    if keywords.relooper:
        relooper = os.path.abspath(keywords.relooper)
    else:
        relooper = None  # use the cache

    if keywords.temp_dir is None:
        temp_files = get_configuration().get_temp_files()
        temp_dir = get_configuration().TEMP_DIR
    else:
        temp_dir = os.path.abspath(keywords.temp_dir)
        if not os.path.exists(temp_dir):
            os.makedirs(temp_dir)
        temp_files = tempfiles.TempFiles(temp_dir)

    if keywords.compiler is None:
        from tools import shared
        keywords.compiler = shared.COMPILER_ENGINE

    if keywords.verbose is None:
        DEBUG = get_configuration().DEBUG
        DEBUG_CACHE = get_configuration().DEBUG_CACHE
    else:
        DEBUG = keywords.verbose
        DEBUG_CACHE = keywords.verbose

    cache = cache_module.Cache()
    temp_files.run_and_clean(lambda: main(
        keywords,
        compiler_engine=keywords.compiler,
        cache=cache,
        jcache=cache_module.JCache(cache) if keywords.jcache else None,
        relooper=relooper,
        temp_files=temp_files,
        DEBUG=DEBUG,
        DEBUG_CACHE=DEBUG_CACHE,
    ))