def handle_symbol_file(args, symbol_file):
    """Regenerate the contents of a given symbol file."""

    if args.filter_in_place:
        output = open(symbol_file).read()
    else:
        basename = os.path.splitext(os.path.basename(symbol_file))[0]
        if not basename.startswith('lib'):
            basename = 'lib' + basename
        if basename.endswith('_asmjs'):
            basename = basename.rsplit('_asmjs', 1)[0]
        basename = basename.replace('cxx', 'c++')
        cache_dir = cache.Cache().dirname
        pattern = os.path.join(cache_dir, basename + '.*')
        libs = glob.glob(pattern)
        if basename == 'libgl':
            # For libgl we generate the symbol list based on a superset of all
            # library variants.
            pattern = os.path.join(cache_dir, basename + '-*.*')
            libs += glob.glob(pattern)
        if not libs:
            print(cache_dir)
            print("%s: Unable to find library to generate symbols from" %
                  symbol_file)
            return
        print('Generating %s based on syms from: %s' % (basename, libs))
        output = ''
        for lib in libs:
            output += shared.run_process([shared.LLVM_NM, '-g', lib],
                                         stdout=shared.PIPE).stdout
    new_symbols = filter_and_sort(output)

    with open(symbol_file, 'w') as f:
        f.write(new_symbols)
Exemple #2
0
def get_lib_file(symbol_file):
    basename = os.path.splitext(os.path.basename(symbol_file))[0]
    cache_dir = cache.Cache().dirname
    lib_extension = 'a' if shared.Settings.WASM_BACKEND else 'bc'
    return os.path.join(cache_dir, basename + '.' + lib_extension)
Exemple #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,
    ))
Exemple #4
0
def get_lib_file(symbol_file):
    basename = os.path.splitext(os.path.basename(symbol_file))[0]
    cache_dir = cache.Cache().dirname
    return os.path.join(cache_dir, basename + '.a')