예제 #1
0
    def build(self, parent, filename, args, shared_args, emcc_args,
              native_args, native_exec, lib_builder, has_output_parser):
        self.parent = parent
        if lib_builder:
            env = {
                'CC': self.cc,
                'CXX': self.cxx,
                'CXXFLAGS': "-Wno-c++11-narrowing"
            }
            env.update(shared.get_clang_native_env())
            native_args += lib_builder(self.name, native=True, env_init=env)
        if not native_exec:
            compiler = self.cxx if filename.endswith('cpp') else self.cc
            cmd = [
                compiler, '-fno-math-errno', filename, '-o',
                filename + '.native'
            ] + self.args + shared_args + native_args + shared.get_clang_native_args(
            )
            # print(cmd)
            run_process(cmd, env=shared.get_clang_native_env())
        else:
            shutil.copyfile(native_exec, filename + '.native')
            shutil.copymode(native_exec, filename + '.native')

        final = os.path.dirname(
            filename) + os.path.sep + self.name + '_' + os.path.basename(
                filename) + '.native'
        shutil.move(filename + '.native', final)
        self.filename = final
예제 #2
0
    def build(self, parent, filename, args, shared_args, emcc_args,
              native_args, native_exec, lib_builder, has_output_parser):
        self.parent = parent
        if lib_builder:
            native_args += lib_builder(self.name,
                                       native=True,
                                       env_init={
                                           'CC': self.cc,
                                           'CXX': self.cxx
                                       })
        if not native_exec:
            compiler = self.cxx if filename.endswith('cpp') else self.cc
            cmd = [
                compiler, '-fno-math-errno', filename, '-o',
                filename + '.native'
            ] + self.args + shared_args + native_args + shared.get_clang_native_args(
            )
            proc = run_process(cmd,
                               stdout=PIPE,
                               stderr=parent.stderr_redirect,
                               env=shared.get_clang_native_env())
            if proc.returncode != 0:
                print("Building native executable with command failed",
                      ' '.join(cmd),
                      file=sys.stderr)
                print("Output: " + str(proc.stdout) + '\n' + str(proc.stderr))
        else:
            shutil.copyfile(native_exec, filename + '.native')
            shutil.copymode(native_exec, filename + '.native')

        final = os.path.dirname(
            filename) + os.path.sep + self.name + '_' + os.path.basename(
                filename) + '.native'
        shutil.move(filename + '.native', final)
        self.filename = final
예제 #3
0
    def __enter__(self):
        # compile the server
        # NOTE empty filename support is a hack to support
        # the current test_enet
        if self.filename:
            proc = run_process([
                CLANG_CC,
                path_from_root('tests', self.filename), '-o', 'server',
                '-DSOCKK=%d' % self.target_port
            ] + shared.get_clang_native_args() + self.args,
                               env=shared.get_clang_native_env(),
                               stdout=PIPE,
                               stderr=PIPE)
            print('Socket server build: out:', proc.stdout or '', '/ err:',
                  proc.stderr or '')
            process = Popen([os.path.abspath('server')])
            self.processes.append(process)

        # start the websocket proxy
        print('running websockify on %d, forward to tcp %d' %
              (self.listen_port, self.target_port),
              file=sys.stderr)
        wsp = websockify.WebSocketProxy(verbose=True,
                                        listen_port=self.listen_port,
                                        target_host="127.0.0.1",
                                        target_port=self.target_port,
                                        run_once=True)
        self.websockify = multiprocessing.Process(target=wsp.start_server)
        self.websockify.start()
        self.processes.append(self.websockify)
        # Make sure both the actual server and the websocket proxy are running
        for i in range(10):
            try:
                if self.do_server_check:
                    server_sock = socket.create_connection(
                        ('localhost', self.target_port), timeout=1)
                    server_sock.close()
                proxy_sock = socket.create_connection(
                    ('localhost', self.listen_port), timeout=1)
                proxy_sock.close()
                break
            except:
                time.sleep(1)
        else:
            clean_processes(self.processes)
            raise Exception(
                '[Websockify failed to start up in a timely manner]')

        print('[Websockify on process %s]' % str(self.processes[-2:]))
예제 #4
0
  def build(self, parent, filename, args, shared_args, emcc_args, native_args, native_exec, lib_builder, has_output_parser):
    self.parent = parent
    if lib_builder:
      native_args += lib_builder(self.name, native=True, env_init={'CC': self.cc, 'CXX': self.cxx})
    if not native_exec:
      compiler = self.cxx if filename.endswith('cpp') else self.cc
      cmd = [
        compiler,
        '-fno-math-errno',
        filename,
        '-o', filename + '.native'
      ] + self.args + shared_args + native_args + shared.get_clang_native_args()
      proc = run_process(cmd, stdout=PIPE, stderr=parent.stderr_redirect, env=shared.get_clang_native_env())
      if proc.returncode != 0:
        print("Building native executable with command failed", ' '.join(cmd), file=sys.stderr)
        print("Output: " + str(proc.stdout) + '\n' + str(proc.stderr))
    else:
      shutil.copyfile(native_exec, filename + '.native')
      shutil.copymode(native_exec, filename + '.native')

    final = os.path.dirname(filename) + os.path.sep + self.name + '_' + os.path.basename(filename) + '.native'
    shutil.move(filename + '.native', final)
    self.filename = final
예제 #5
0
  def __enter__(self):
    # compile the server
    # NOTE empty filename support is a hack to support
    # the current test_enet
    if self.filename:
      proc = run_process([CLANG_CC, path_from_root('tests', self.filename), '-o', 'server', '-DSOCKK=%d' % self.target_port] + shared.get_clang_native_args() + self.args, env=shared.get_clang_native_env(), stdout=PIPE, stderr=PIPE)
      print('Socket server build: out:', proc.stdout or '', '/ err:', proc.stderr or '')
      process = Popen([os.path.abspath('server')])
      self.processes.append(process)

    # start the websocket proxy
    print('running websockify on %d, forward to tcp %d' % (self.listen_port, self.target_port), file=sys.stderr)
    wsp = websockify.WebSocketProxy(verbose=True, listen_port=self.listen_port, target_host="127.0.0.1", target_port=self.target_port, run_once=True)
    self.websockify = multiprocessing.Process(target=wsp.start_server)
    self.websockify.start()
    self.processes.append(self.websockify)
    # Make sure both the actual server and the websocket proxy are running
    for i in range(10):
      try:
        if self.do_server_check:
            server_sock = socket.create_connection(('localhost', self.target_port), timeout=1)
            server_sock.close()
        proxy_sock = socket.create_connection(('localhost', self.listen_port), timeout=1)
        proxy_sock.close()
        break
      except:
        time.sleep(1)
    else:
      clean_processes(self.processes)
      raise Exception('[Websockify failed to start up in a timely manner]')

    print('[Websockify on process %s]' % str(self.processes[-2:]))
예제 #6
0
# System info
system_info = Popen([PYTHON, path_from_root('emrun'), '--system_info'], stdout=PIPE, stderr=PIPE).communicate()

# Native info
native_info = Popen(['clang', '-v'], stdout=PIPE, stderr=PIPE).communicate()

# Emscripten info
emscripten_info = Popen([PYTHON, EMCC, '-v'], stdout=PIPE, stderr=PIPE).communicate()

# Run native build
out_file = os.path.join(temp_dir, 'benchmark_sse1_native')
if WINDOWS: out_file += '.exe'
cmd = [CLANG_CPP] + get_clang_native_args() + [path_from_root('tests', 'benchmark_sse1.cpp'), '-O3', '-o', out_file]
print 'Building native version of the benchmark:'
print ' '.join(cmd)
build = Popen(cmd, env=get_clang_native_env())
out = build.communicate()
if build.returncode != 0:
    sys.exit(1)

native_results = Popen([out_file], stdout=PIPE, stderr=PIPE).communicate()
print native_results[0]

# Run emscripten build
out_file = os.path.join(temp_dir, 'benchmark_sse1_html.html')
cmd = [PYTHON, EMCC, path_from_root('tests', 'benchmark_sse1.cpp'), '-O3', '-msse', '--emrun', '-s', 'TOTAL_MEMORY=536870912', '-o', out_file]
print 'Building Emscripten version of the benchmark:'
print ' '.join(cmd)
build = Popen(cmd)
out = build.communicate()
if build.returncode != 0:
예제 #7
0
# Native info
native_info = Popen(['clang', '-v'], stdout=PIPE, stderr=PIPE).communicate()

# Emscripten info
emscripten_info = Popen([PYTHON, EMCC, '-v'], stdout=PIPE,
                        stderr=PIPE).communicate()

# Run native build
out_file = os.path.join(temp_dir, 'benchmark_sse1_native')
if WINDOWS: out_file += '.exe'
cmd = [CLANG_CPP] + get_clang_native_args() + [
    path_from_root('tests', 'benchmark_sse1.cpp'), '-O3', '-o', out_file
]
print 'Building native version of the benchmark:'
print ' '.join(cmd)
build = Popen(cmd, env=get_clang_native_env())
out = build.communicate()
if build.returncode != 0:
    sys.exit(1)

native_results = Popen([out_file], stdout=PIPE, stderr=PIPE).communicate()
print native_results[0]

# Run emscripten build
out_file = os.path.join(temp_dir, 'benchmark_sse1_html.html')
cmd = [
    PYTHON, EMCC,
    path_from_root('tests', 'benchmark_sse1.cpp'), '-O3', '-msse', '--emrun',
    '-s', 'TOTAL_MEMORY=536870912', '-o', out_file
]
print 'Building Emscripten version of the benchmark:'