{"id":285655,"date":"2023-11-01T09:00:34","date_gmt":"2023-11-01T01:00:34","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=285655"},"modified":"2023-10-30T22:05:45","modified_gmt":"2023-10-30T14:05:45","slug":"skyrjrdmzhcw","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/skyrjrdmzhcw.html","title":{"rendered":"Shopify \u5f00\u6e90 Ruvy\uff0c\u5c06 Ruby \u4ee3\u7801\u8f6c\u6362\u6210 WebAssembly"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nShopify \u6700\u8fd1\u5f00\u6e90\u4e86\u4e00\u4e2a\u540d\u4e3a Ruvy \u7684\u9879\u76ee\u3002Ruvy \u662f\u4e00\u4e2a\u5de5\u5177\u94fe\uff0c\u5b83\u63a5\u53d7 Ruby \u4ee3\u7801\u4f5c\u4e3a\u8f93\u5165\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u5c06\u6267\u884c\u8be5 Ruby \u4ee3\u7801\u7684 WebAssembly \u6a21\u5757\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u76ee\u524d\u5df2\u6709\u4ece Ruby \u4ee3\u7801\u521b\u5efa Wasm \u6a21\u5757\u7684\u9879\u76ee\uff0c\u6700\u5e38\u89c1\u7684\u662f ruby.wasm\uff0cRuvy \u4e5f\u662f\u57fa\u4e8e ruby.wasm \u6784\u5efa\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e00\u4e9b\u7279\u5b9a\u7684\u4f18\u52bf\u3002<\/p>\n

\u5b98\u65b9\u79f0\u521b\u5efa Ruvy \u65e8\u5728\u5229\u7528\u9884\u521d\u59cb\u5316 Ruby \u865a\u62df\u673a\u548c Ruby \u811a\u672c\u5305\u542b\u7684 Ruby \u6587\u4ef6\u5e26\u6765\u7684\u6027\u80fd\u6539\u8fdb\u3002\u6b64\u5916\uff0cRuvy \u4e0d\u9700\u8981\u5728\u8fd0\u884c\u65f6\u63d0\u4f9b WASI \u53c2\u6570\uff0c\u4ece\u800c\u7b80\u5316\u4e86 Wasm \u6a21\u5757\u7684\u6267\u884c\u3002<\/p>\n

\"\"<\/p>\n

WASI \u662f\u4e00\u7ec4\u5bfc\u5165\u7684 Wasm \u51fd\u6570\u7684\u6807\u51c6\u5316\u96c6\u5408\uff0c\u65e8\u5728\u4e3a Wasm \u6a21\u5757\u63d0\u4f9b\u4e00\u4e2a\u6807\u51c6\u63a5\u53e3\uff0c\u4ee5\u5b9e\u73b0\u8bb8\u591a\u5178\u578b\u8bed\u8a00\u6807\u51c6\u5e93\u4e2d\u5b58\u5728\u7684\u7cfb\u7edf\u8c03\u7528\u3002<\/p>\n

\u76ee\u524d\uff0cRuvy \u5e76\u672a\u968f\u9884\u7f16\u8bd1\u7684\u4e8c\u8fdb\u5236\u6587\u4ef6\u4e00\u8d77\u53d1\u5e03\uff0c\u56e0\u6b64\u9700\u8981\u5b89\u88c5\u5b83\u7684\u6784\u5efa\u4f9d\u8d56\u9879\uff0c\u7136\u540e\u7f16\u8bd1 Ruvy \u624d\u80fd\u4f7f\u7528\u3002<\/p>\n

\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u9879\u7684\u8be6\u7ec6\u4fe1\u606f\u8bf7\u67e5\u770b README\u3002<\/p>\n

\u6784\u5efa Ruvy \u540e\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6253\u5370\u51fa Hello World\u3002<\/p>\n

$ cargo run -- package=cli ruby_examples \/ hello_world.rb - o index.wasm \r\n$ wasmtime index.wasm \r\nHello world<\/pre>\n

\u4e0a\u8ff0\u547d\u4ee4\u5c06\u6784\u5efa\u5e76\u6267\u884c CLI\uff0c\u9996\u5148\u83b7\u53d6 ruby_examples\/hello_world.rb \u7684\u5185\u5bb9\uff0c\u5e76\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a index.wasm \u7684 Wasm \u6a21\u5757\u3002\u5f53\u8c03\u7528 index.wasm \u7684\u5bfc\u51fa_start \u7684\u51fd\u6570\u65f6\uff0c\u5c06\u6267\u884c puts \u201cHello world\u201d\u3002<\/p>\n

\u5982\u679c\u8981\u4f7f\u7528\u989d\u5916\u7684 Ruby \u6587\u4ef6\uff0c\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

$ cargo run -- package=cli -- -- preload=prelude \/ ruby_examples \/ use_preludes_and_stdin.rb \r\n$ echo \"this is my input\" | wasmtime index.wasm \r\n{:discount_input=>\"this is my input\", :value=>100.0}<\/pre>\n

\u8fd9\u5c31\u662f Shopify \u65b0\u63a8\u51fa Ruvy \u9879\u76ee\u7684\u7b80\u8981\u4ecb\u7ecd\u3002\u5b83\u4e3a Ruby \u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b0\u5de5\u5177\uff0c\u4f7f\u5f97\u4ed6\u4eec\u53ef\u4ee5\u66f4\u65b9\u4fbf\u5730\u5c06 Ruby \u4ee3\u7801\u8f6c\u6362\u4e3a WebAssembly \u6a21\u5757\uff0c\u5e76\u4ece\u4e2d\u83b7\u5f97\u6027\u80fd\u6539\u8fdb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u76ee\u524d\u5df2\u6709\u4ece Ruby \u4ee3\u7801\u521b\u5efa Wasm \u6a21\u5757\u7684\u9879\u76ee\uff0c\u6700\u5e38\u89c1\u7684\u662f ruby.wasm\uff0cRuvy \u4e5f\u662f\u57fa\u4e8e ru […]<\/p>\n","protected":false},"author":668,"featured_media":203380,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-285655","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/285655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=285655"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/285655\/revisions"}],"predecessor-version":[{"id":286273,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/285655\/revisions\/286273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/203380"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=285655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=285655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=285655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}