Exemple #1
0
 def get_freealut_library(self):
     if WINDOWS and Building.which('cmake'):
         return self.get_library('freealut',
                                 os.path.join('hello_world.bc'),
                                 configure=['cmake', '.'],
                                 configure_args=['-DBUILD_TESTS=ON'])
     else:
         return self.get_library('freealut', [
             os.path.join('examples', '.libs', 'hello_world.bc'),
             os.path.join('src', '.libs', 'libalut.a')
         ],
                                 make_args=['EXEEXT=.bc'])
Exemple #2
0
def run_binaryen_opts(filename, opts):
    run_process([
        os.path.join(Building.get_binaryen_bin(), 'wasm-opt',
                     '--all-features'), filename, '-o', filename
    ] + opts)
Exemple #3
0
 def cleanup(self):
     os.environ = self.old_env
     Building.clear()
Exemple #4
0
def run_binaryen_opts(filename, opts):
  run_process([
    os.path.join(Building.get_binaryen_bin(), 'wasm-opt'),
    filename,
    '-o', filename
  ] + opts)
Exemple #5
0
 def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder, has_output_parser):
   suffix = filename.split('.')[-1]
   cheerp_temp = filename + '.cheerp.' + suffix
   code = open(filename).read()
   if 'int main()' in code:
     main_args = ''
   else:
     main_args = 'argc, (%(const)s char**)argv' % {
       'const': 'const' if 'const char *argv' in code else ''
     }
   open(cheerp_temp, 'w').write('''
     %(code)s
     void webMain() {
       // TODO: how to read from commandline?
       volatile int argc = 2;
       typedef char** charStarStar;
       volatile charStarStar argv;
       argv[0] = "./cheerp.exe";
       argv[1] = "%(arg)s";
       volatile int exit_code = main(%(main_args)s);
     }
   ''' % {
     'arg': args[-1],
     'code': code,
     'main_args': main_args
   })
   cheerp_args = [
     '-target', 'cheerp',
     '-cheerp-mode=wasm'
   ]
   cheerp_args += self.args
   self.parent = parent
   if lib_builder:
     # build as "native" (so no emcc env stuff), but with all the cheerp stuff
     # set in the env
     cheerp_args = cheerp_args + lib_builder(self.name, native=True, env_init={
       'CC': CHEERP_BIN + 'clang',
       'CXX': CHEERP_BIN + 'clang++',
       'AR': CHEERP_BIN + 'llvm-ar',
       'LD': CHEERP_BIN + 'clang',
       'NM': CHEERP_BIN + 'llvm-nm',
       'LDSHARED': CHEERP_BIN + 'clang',
       'RANLIB': CHEERP_BIN + 'llvm-ranlib',
       'CFLAGS': ' '.join(cheerp_args),
       'CXXFLAGS': ' '.join(cheerp_args),
     })
   # cheerp_args += ['-cheerp-pretty-code'] # get function names, like emcc --profiling
   final = os.path.dirname(filename) + os.path.sep + 'cheerp_' + self.name + ('_' if self.name else '') + os.path.basename(filename) + '.js'
   final = final.replace('.cpp', '')
   try_delete(final)
   dirs_to_delete = []
   try:
     for arg in cheerp_args[:]:
       if arg.endswith('.a'):
         info = self.handle_static_lib(arg)
         cheerp_args += info['files']
         dirs_to_delete += [info['dir']]
     cheerp_args = [arg for arg in cheerp_args if not arg.endswith('.a')]
     # print(cheerp_args)
     cmd = [CHEERP_BIN + 'clang++'] + cheerp_args + [
       '-cheerp-linear-heap-size=256',
       '-cheerp-wasm-loader=' + final,
       cheerp_temp,
       '-Wno-writable-strings', # for how we set up webMain
       '-o', final + '.wasm'
     ] + shared_args
     # print(' '.join(cmd))
     run_process(cmd)
     self.filename = final
     Building.get_binaryen()
     if self.binaryen_opts:
       run_binaryen_opts(final + '.wasm', self.binaryen_opts)
   finally:
     for dir_ in dirs_to_delete:
       try_delete(dir_)
Exemple #6
0
    return {
      'returncode': 1,
      'dir': None,
      'files': []
    }


# Benchmarkers
try:
  benchmarkers_error = ''
  benchmarkers = [
    NativeBenchmarker('clang', CLANG_CC, CLANG),
    # NativeBenchmarker('gcc',   'gcc',    'g++')
  ]
  if SPIDERMONKEY_ENGINE and Building.which(SPIDERMONKEY_ENGINE[0]):
    benchmarkers += [
      EmscriptenBenchmarker('sm-asmjs', SPIDERMONKEY_ENGINE, ['-s', 'PRECISE_F32=2', '-s', 'WASM=0']),
      EmscriptenBenchmarker('sm-asm2wasm',  SPIDERMONKEY_ENGINE + ['--no-wasm-baseline'], []),
      # EmscriptenBenchmarker('sm-asm2wasm-lto',  SPIDERMONKEY_ENGINE + ['--no-wasm-baseline'], ['--llvm-lto', '1']),
      # EmscriptenBenchmarker('sm-wasmbackend',  SPIDERMONKEY_ENGINE + ['--no-wasm-baseline'], [env={
      #   'LLVM': '/home/alon/Dev/llvm/build/bin',
      #   'EMCC_WASM_BACKEND': '1',
      # }),
    ]
  if V8_ENGINE and Building.which(V8_ENGINE[0]):
    benchmarkers += [
      EmscriptenBenchmarker('v8-wasm',  V8_ENGINE),
    ]
  if os.path.exists(CHEERP_BIN):
    benchmarkers += [
Exemple #7
0
 def build(self, parent, filename, args, shared_args, emcc_args,
           native_args, native_exec, lib_builder, has_output_parser):
     suffix = filename.split('.')[-1]
     cheerp_temp = filename + '.cheerp.' + suffix
     code = open(filename).read()
     if 'int main()' in code:
         main_args = ''
     else:
         main_args = 'argc, (%(const)s char**)argv' % {
             'const': 'const' if 'const char *argv' in code else ''
         }
     open(cheerp_temp, 'w').write('''
   %(code)s
   void webMain() {
     // TODO: how to read from commandline?
     volatile int argc = 2;
     typedef char** charStarStar;
     volatile charStarStar argv;
     argv[0] = "./cheerp.exe";
     argv[1] = "%(arg)s";
     volatile int exit_code = main(%(main_args)s);
   }
 ''' % {
         'arg': args[-1],
         'code': code,
         'main_args': main_args
     })
     cheerp_args = ['-target', 'cheerp', '-cheerp-mode=wasm']
     cheerp_args += self.args
     self.parent = parent
     if lib_builder:
         # build as "native" (so no emcc env stuff), but with all the cheerp stuff
         # set in the env
         cheerp_args = cheerp_args + lib_builder(
             self.name,
             native=True,
             env_init={
                 'CC': CHEERP_BIN + 'clang',
                 'CXX': CHEERP_BIN + 'clang++',
                 'AR': CHEERP_BIN + 'llvm-ar',
                 'LD': CHEERP_BIN + 'clang',
                 'NM': CHEERP_BIN + 'llvm-nm',
                 'LDSHARED': CHEERP_BIN + 'clang',
                 'RANLIB': CHEERP_BIN + 'llvm-ranlib',
                 'CFLAGS': ' '.join(cheerp_args),
                 'CXXFLAGS': ' '.join(cheerp_args),
             })
     # cheerp_args += ['-cheerp-pretty-code'] # get function names, like emcc --profiling
     final = os.path.dirname(
         filename) + os.path.sep + 'cheerp_' + self.name + (
             '_' if self.name else '') + os.path.basename(filename) + '.js'
     final = final.replace('.cpp', '')
     try_delete(final)
     dirs_to_delete = []
     try:
         for arg in cheerp_args[:]:
             if arg.endswith('.a'):
                 info = self.handle_static_lib(arg)
                 cheerp_args += info['files']
                 dirs_to_delete += [info['dir']]
         cheerp_args = [
             arg for arg in cheerp_args if not arg.endswith('.a')
         ]
         # print(cheerp_args)
         cmd = [CHEERP_BIN + 'clang++'] + cheerp_args + [
             '-cheerp-linear-heap-size=256',
             '-cheerp-wasm-loader=' + final,
             cheerp_temp,
             '-Wno-writable-strings',  # for how we set up webMain
             '-o',
             final + '.wasm'
         ] + shared_args
         # print(' '.join(cmd))
         run_process(cmd)
         self.filename = final
         Building.get_binaryen()
         if self.binaryen_opts:
             run_binaryen_opts(final + '.wasm', self.binaryen_opts)
     finally:
         for dir_ in dirs_to_delete:
             try_delete(dir_)
Exemple #8
0
                'returncode': proc.returncode,
                'dir': temp_dir,
                'files': contents
            }

        return {'returncode': 1, 'dir': None, 'files': []}


# Benchmarkers
try:
    benchmarkers_error = ''
    benchmarkers = [
        NativeBenchmarker('clang', CLANG_CC, CLANG),
        # NativeBenchmarker('gcc',   'gcc',    'g++')
    ]
    if SPIDERMONKEY_ENGINE and Building.which(SPIDERMONKEY_ENGINE[0]):
        benchmarkers += [
            EmscriptenBenchmarker('sm-asmjs', SPIDERMONKEY_ENGINE,
                                  ['-s', 'PRECISE_F32=2', '-s', 'WASM=0']),
            EmscriptenBenchmarker('sm-asm2wasm',
                                  SPIDERMONKEY_ENGINE + ['--no-wasm-baseline'],
                                  []),
            # EmscriptenBenchmarker('sm-asm2wasm-lto',  SPIDERMONKEY_ENGINE + ['--no-wasm-baseline'], ['--llvm-lto', '1']),
            # EmscriptenBenchmarker('sm-wasmbackend',  SPIDERMONKEY_ENGINE + ['--no-wasm-baseline'], [env={
            #   'LLVM': '/home/alon/Dev/llvm/build/bin',
            #   'EMCC_WASM_BACKEND': '1',
            # }),
        ]
    if V8_ENGINE and Building.which(V8_ENGINE[0]):
        benchmarkers += [
            EmscriptenBenchmarker('v8-wasm', V8_ENGINE),
Exemple #9
0
 def get_freealut_library(self):
   if WINDOWS and Building.which('cmake'):
     return self.get_library('freealut', os.path.join('hello_world.bc'), configure=['cmake', '.'], configure_args=['-DBUILD_TESTS=ON'])
   else:
     return self.get_library('freealut', [os.path.join('examples', '.libs', 'hello_world.bc'), os.path.join('src', '.libs', 'libalut.a')], make_args=['EXEEXT=.bc'])
#!/usr/bin/env python2
# Copyright 2011 The Emscripten Authors.  All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License.  Both these licenses can be
# found in the LICENSE file.

"""This is a helper script for emmaken.py. See docs in that file for more info.
"""

from __future__ import print_function
import os
import sys

__rootpath__ = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(__rootpath__)

from tools.shared import Building  # noqa

print('\n\nemconfiguren.py is deprecated! use "emconfigure"\n\n', file=sys.stderr)

Building.configure(sys.argv[1:])