def __init__(self, path): self.path = path try: self._parse_file() except Exception: raise errors.BuildError("Can't read cargo file.")
def __init__(self, path): self.data = {} self.path = path try: self._parse_file() except Exception as err: raise errors.BuildError("Can't read or parse [Cargo.toml] file", err)
def perform_build(self): self.build_configuration = ClangBuildConfiguration(self, self.debug) self.unit = self.find_file_globally("*.c") self.file_ll = self.unit.with_suffix(".ll") self.file_o = self.unit.with_suffix(".o") self.file_export = self.unit.with_suffix(".export") try: self._do_clang() self._do_llc() self._do_wasm() except subprocess.CalledProcessError as err: raise errors.BuildError(err.output)
def run_cargo(self): env = self._get_env() if self.debug: args = ["cargo", "build"] else: args = [ "cargo", "build", "--target=wasm32-unknown-unknown", "--release" ] env["RUSTFLAGS"] = "-C link-arg=-s" cwd = path.join(self.directory, "wasm") result = myprocess.run_process_async(args, env=env, cwd=cwd) if result != 0: raise errors.BuildError(f"error code = {result}, see output")
def perform_build(self): self.config = self.load_config() self.ensure_source_files() self.unit = self.get_unit_file() self.file_ll = self.unit.with_suffix('.ll') self.file_o = self.unit.with_suffix('.o') self.file_export = self.unit.with_suffix('.export') self.file_output = self.unit.with_suffix('.wasm') try: self.do_clang() self.do_llvm_link() self.do_llc() self.do_wasm() except subprocess.CalledProcessError as err: raise errors.BuildError(err.output)
def _generate_abi(self): if not self._has_abi(): return args = ["cargo", "run"] self._decorate_cargo_args(args) env = self._get_env() cwd = path.join(self.directory, "abi") sink = myprocess.FileOutputSink(self._get_abi_filepath()) return_code = myprocess.run_process_async(args, env=env, cwd=cwd, stdout_sink=sink) if return_code != 0: raise errors.BuildError(f"error code = {return_code}, see output") utils.prettify_json_file(self._get_abi_filepath())
def run_cargo(self): env = self._get_env() args = [ "cargo", "build", "--target=wasm32-unknown-unknown", "--release", "--out-dir", self._get_output_folder(), "-Z" "unstable-options" ] self._decorate_cargo_args(args) if not self.options.get("wasm_symbols"): env["RUSTFLAGS"] = "-C link-arg=-s" cwd = path.join(self.directory, "wasm") return_code = myprocess.run_process_async(args, env=env, cwd=cwd) if return_code != 0: raise errors.BuildError(f"error code = {return_code}, see output")
def run_cargo(self): env = self._get_env() if self.debug: args = ["cargo", "build"] else: args = [ "cargo", "build", "--manifest-path", self.cargo_file.path, "--target=wasm32-unknown-unknown", "--release" ] env["RUSTFLAGS"] = "-C link-arg=-s" result = myprocess.run_process_async(args, env=env) if result != 0: raise errors.BuildError(f"error code = {result}, see output")
def perform_build(self): """ See https://github.com/second-state/SOLL/blob/master/utils/ll2ewasm_sol """ self.unit = self.find_file_globally("*.sol") self.unit_name = self.unit.stem self.file_ll = self.unit.with_suffix(".ll") self.file_functions = self.unit.with_suffix(".functions") self.file_main_ll = self.unit.with_suffix(".main.ll") self.file_bc = self.unit.with_suffix(".bc") self.file_o = self.unit.with_suffix(".o") try: self._create_main_ll() self._emit_LLVM() self._emit_funcions() self._do_llvm_link() self._do_llvm_opt() self._do_llc() self._do_wasm_ld() except subprocess.CalledProcessError as err: raise errors.BuildError(err.output)
def perform_build(self): try: self.run_cargo() self._generate_abi() except subprocess.CalledProcessError as err: raise errors.BuildError(err.output)
def get_dev_dependency(self, name) -> MutableMapping[str, Any]: dependencies = self.get_dev_dependencies() dependency = dependencies.get(name) if dependency is None: raise errors.BuildError(f"Can't get cargo dev-dependency: {name}") return dependency