def run(): if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'): print('''\ emcmake is a helper for cmake, setting various environment variables so that emcc etc. are used. Typical usage: emcmake cmake [FLAGS] ''', file=sys.stderr) return 1 args = sys.argv[1:] def has_substr(args, substr): return any(substr in s for s in args) # Append the Emscripten toolchain file if the user didn't specify one. if not has_substr(args, '-DCMAKE_TOOLCHAIN_FILE'): args.append('-DCMAKE_TOOLCHAIN_FILE=' + utils.path_from_root( 'cmake', 'Modules', 'Platform', 'Emscripten.cmake')) if not has_substr(args, '-DCMAKE_CROSSCOMPILING_EMULATOR'): node_js = config.NODE_JS[0] args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js}') # On Windows specify MinGW Makefiles or ninja if we have them and no other # toolchain was specified, to keep CMake from pulling in a native Visual # Studio, or Unix Makefiles. if utils.WINDOWS and '-G' not in args: if utils.which('mingw32-make'): args += ['-G', 'MinGW Makefiles'] elif utils.which('ninja'): args += ['-G', 'Ninja'] else: print( 'emcmake: no compatible cmake generator found; Please install ninja or mingw32-make, or specify a generator explicitly using -G', file=sys.stderr) return 1 # CMake has a requirement that it wants sh.exe off PATH if MinGW Makefiles # is being used. This happens quite often, so do this automatically on # behalf of the user. See # http://www.cmake.org/Wiki/CMake_MinGW_Compiler_Issues if utils.WINDOWS and 'MinGW Makefiles' in args: env = building.remove_sh_exe_from_path(os.environ) else: env = None print('configure: ' + shared.shlex_join(args), file=sys.stderr) try: shared.check_call(args, env=env) return 0 except CalledProcessError as e: return e.returncode
def run(): if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'): print('''\ emmake is a helper for make, setting various environment variables so that emcc etc. are used. Typical usage: emmake make [FLAGS] (but you can run any command instead of make)''', file=sys.stderr) return 1 args = sys.argv[1:] env = building.get_building_env() # On Windows prefer building with mingw32-make instead of make, if it exists. if utils.WINDOWS: if args[0] == 'make': mingw32_make = utils.which('mingw32-make') if mingw32_make: args[0] = mingw32_make if 'mingw32-make' in args[0]: env = building.remove_sh_exe_from_path(env) # On Windows, run the execution through shell to get PATH expansion and # executable extension lookup, e.g. 'sdl2-config' will match with # 'sdl2-config.bat' in PATH. print('make: ' + ' '.join(args), file=sys.stderr) try: shared.check_call(args, shell=utils.WINDOWS, env=env) return 0 except CalledProcessError as e: return e.returncode
def run(): if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'): print('''\ emcmake is a helper for cmake, setting various environment variables so that emcc etc. are used. Typical usage: emcmake cmake [FLAGS] ''', file=sys.stderr) return 1 args = sys.argv[1:] def has_substr(args, substr): return any(substr in s for s in args) # Append the Emscripten toolchain file if the user didn't specify one. if not has_substr(args, '-DCMAKE_TOOLCHAIN_FILE'): args.append( '-DCMAKE_TOOLCHAIN_FILE=' + utils.path_from_root('cmake/Modules/Platform/Emscripten.cmake')) if not has_substr(args, '-DCMAKE_CROSSCOMPILING_EMULATOR'): node_js = config.NODE_JS[0] args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js}') # On Windows specify MinGW Makefiles or ninja if we have them and no other # toolchain was specified, to keep CMake from pulling in a native Visual # Studio, or Unix Makefiles. if utils.WINDOWS and '-G' not in args: if utils.which('mingw32-make'): args += ['-G', 'MinGW Makefiles'] elif utils.which('ninja'): args += ['-G', 'Ninja'] else: print( 'emcmake: no compatible cmake generator found; Please install ninja or mingw32-make, or specify a generator explicitly using -G', file=sys.stderr) return 1 print('configure: ' + shared.shlex_join(args), file=sys.stderr) try: shared.check_call(args) return 0 except CalledProcessError as e: return e.returncode
def run(): if len(sys.argv) < 2 or sys.argv[1] in ('--version', '--help'): print('''\ emcmake is a helper for cmake, setting various environment variables so that emcc etc. are used. Typical usage: emcmake cmake [FLAGS] ''', file=sys.stderr) return 1 args = sys.argv[1:] def has_substr(args, substr): return any(substr in s for s in args) # Append the Emscripten toolchain file if the user didn't specify one. if not has_substr(args, '-DCMAKE_TOOLCHAIN_FILE'): args.append('-DCMAKE_TOOLCHAIN_FILE=' + utils.path_from_root('cmake/Modules/Platform/Emscripten.cmake')) if not has_substr(args, '-DCMAKE_CROSSCOMPILING_EMULATOR'): node_js = config.NODE_JS[0] # In order to allow cmake to run code built with pthreads we need to pass some extra flags to node. # Note that we also need --experimental-wasm-bulk-memory which is true by default and hence not added here # See https://github.com/emscripten-core/emscripten/issues/15522 args.append(f'-DCMAKE_CROSSCOMPILING_EMULATOR={node_js};--experimental-wasm-threads') # On Windows specify MinGW Makefiles or ninja if we have them and no other # toolchain was specified, to keep CMake from pulling in a native Visual # Studio, or Unix Makefiles. if utils.WINDOWS and not any(arg.startswith('-G') for arg in args): if utils.which('mingw32-make'): args += ['-G', 'MinGW Makefiles'] elif utils.which('ninja'): args += ['-G', 'Ninja'] else: print('emcmake: no compatible cmake generator found; Please install ninja or mingw32-make, or specify a generator explicitly using -G', file=sys.stderr) return 1 print('configure: ' + shared.shlex_join(args), file=sys.stderr) try: shared.check_call(args) return 0 except CalledProcessError as e: return e.returncode
def get_freealut_library(self): self.emcc_args += ['-Wno-pointer-sign'] if WINDOWS and which('cmake'): return self.get_library(os.path.join('third_party', 'freealut'), 'libalut.a', configure=['cmake', '.'], configure_args=['-DBUILD_TESTS=ON']) else: return self.get_library(os.path.join('third_party', 'freealut'), os.path.join('src', '.libs', 'libalut.a'), configure_args=['--disable-shared'])
def get_freealut_library(self): if WINDOWS and 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'])
def __init__(self, device, log=None, serial_log=None): # Prefer picocom, fall back to cu. if utils.which('picocom'): cmd = 'picocom --nolock -b 115200 ' + device self._terminal_ready_str = 'Terminal ready.' else: cmd = 'cu -l %s -s 115200' % device self._terminal_ready_str = 'Connected.' super(Shell, self).__init__(cmd, timeout=SHELL_TIMEOUT_DEFAULT, logfile=serial_log) self._ready = False self._log_func = log self.scoreboard = Scoreboard(self, self.log) self._wait_for_ready()