Sha256: 52371d17ef7643715693a0b71b9c43e36e4ed764419bda445bc7e868a1a124df
Contents?: true
Size: 1.45 KB
Versions: 13
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module Script module Layers module Infrastructure module Languages class RustTaskRunner attr_reader :ctx BUILD_TARGET = "wasm32-unknown-unknown" METADATA_FILE = "build/metadata.json" CARGO_BUILD_CMD = "cargo build --target=#{BUILD_TARGET} --release" def initialize(ctx, _) @ctx = ctx end def dependencies_installed? true end def install_dependencies end def build compile bytecode end def compiled_type "wasm" end def metadata unless @ctx.file_exist?(METADATA_FILE) msg = @ctx.message("script.error.metadata_not_found_cause", METADATA_FILE) raise Domain::Errors::MetadataNotFoundError, msg end raw_contents = File.read(METADATA_FILE) Domain::Metadata.create_from_json(@ctx, raw_contents) end private def compile CommandRunner.new(ctx: ctx).call(CARGO_BUILD_CMD) end def bytecode binary_name = "script.wasm" binary_path = "target/#{BUILD_TARGET}/release/#{binary_name}" raise Errors::WebAssemblyBinaryNotFoundError unless ctx.file_exist?(binary_path) ctx.binread(binary_path) end end end end end end
Version data entries
13 entries across 13 versions & 1 rubygems