ruby_wasm 2.5.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.clang-format +8 -0
- data/CONTRIBUTING.md +126 -0
- data/Gemfile +17 -0
- data/LICENSE +21 -0
- data/NOTICE +1293 -0
- data/README.md +153 -0
- data/Rakefile +163 -0
- data/Steepfile +24 -0
- data/benchmarks/vm_deep_call.rb +55 -0
- data/builders/wasm32-unknown-emscripten/Dockerfile +43 -0
- data/builders/wasm32-unknown-emscripten/entrypoint.sh +7 -0
- data/builders/wasm32-unknown-wasi/Dockerfile +47 -0
- data/builders/wasm32-unknown-wasi/entrypoint.sh +7 -0
- data/docs/api.md +2 -0
- data/docs/cheat_sheet.md +195 -0
- data/docs/faq.md +25 -0
- data/exe/rbwasm +7 -0
- data/ext/.gitignore +2 -0
- data/ext/README.md +11 -0
- data/ext/extinit.c.erb +32 -0
- data/lib/ruby_wasm/3.0/ruby_wasm.bundle +0 -0
- data/lib/ruby_wasm/3.1/ruby_wasm.bundle +0 -0
- data/lib/ruby_wasm/3.2/ruby_wasm.bundle +0 -0
- data/lib/ruby_wasm/build/build_params.rb +3 -0
- data/lib/ruby_wasm/build/downloader.rb +18 -0
- data/lib/ruby_wasm/build/executor.rb +187 -0
- data/lib/ruby_wasm/build/product/baseruby.rb +37 -0
- data/lib/ruby_wasm/build/product/crossruby.rb +330 -0
- data/lib/ruby_wasm/build/product/libyaml.rb +68 -0
- data/lib/ruby_wasm/build/product/openssl.rb +88 -0
- data/lib/ruby_wasm/build/product/product.rb +39 -0
- data/lib/ruby_wasm/build/product/ruby_source.rb +103 -0
- data/lib/ruby_wasm/build/product/wasi_vfs.rb +45 -0
- data/lib/ruby_wasm/build/product/zlib.rb +68 -0
- data/lib/ruby_wasm/build/product.rb +8 -0
- data/lib/ruby_wasm/build/toolchain/wit_bindgen.rb +31 -0
- data/lib/ruby_wasm/build/toolchain.rb +193 -0
- data/lib/ruby_wasm/build.rb +88 -0
- data/lib/ruby_wasm/cli.rb +217 -0
- data/lib/ruby_wasm/packager/core.rb +156 -0
- data/lib/ruby_wasm/packager/file_system.rb +158 -0
- data/lib/ruby_wasm/packager.rb +159 -0
- data/lib/ruby_wasm/rake_task.rb +59 -0
- data/lib/ruby_wasm/util.rb +15 -0
- data/lib/ruby_wasm/version.rb +3 -0
- data/lib/ruby_wasm.rb +33 -0
- data/package-lock.json +9500 -0
- data/package.json +12 -0
- data/rakelib/check.rake +37 -0
- data/rakelib/ci.rake +152 -0
- data/rakelib/doc.rake +29 -0
- data/rakelib/format.rake +35 -0
- data/rakelib/gem.rake +22 -0
- data/rakelib/packaging.rake +151 -0
- data/rakelib/version.rake +40 -0
- data/sig/open_uri.rbs +4 -0
- data/sig/ruby_wasm/build.rbs +318 -0
- data/sig/ruby_wasm/cli.rbs +27 -0
- data/sig/ruby_wasm/ext.rbs +13 -0
- data/sig/ruby_wasm/packager.rbs +91 -0
- data/sig/ruby_wasm/util.rbs +5 -0
- data/tools/clang-format-diff.sh +18 -0
- data/tools/exe/rbminify +12 -0
- data/tools/lib/syntax_tree/minify_ruby.rb +63 -0
- metadata +114 -0
@@ -0,0 +1,318 @@
|
|
1
|
+
module RubyWasm
|
2
|
+
VERSION: String
|
3
|
+
|
4
|
+
interface _Cacheable
|
5
|
+
def cache_key: (Digest::SHA256 digest) -> void
|
6
|
+
end
|
7
|
+
|
8
|
+
class Build
|
9
|
+
include _Cacheable
|
10
|
+
|
11
|
+
@target: String
|
12
|
+
@build_dir: String
|
13
|
+
@rubies_dir: String
|
14
|
+
@toolchain: Toolchain
|
15
|
+
@libyaml: LibYAMLProduct
|
16
|
+
@zlib: ZlibProduct
|
17
|
+
@openssl: OpenSSLProduct
|
18
|
+
@wasi_vfs: WasiVfsProduct
|
19
|
+
@baseruby: BaseRubyProduct
|
20
|
+
@crossruby: CrossRubyProduct
|
21
|
+
@source: BuildSource
|
22
|
+
|
23
|
+
attr_reader toolchain: Toolchain
|
24
|
+
|
25
|
+
def initialize: (
|
26
|
+
string name,
|
27
|
+
target: String,
|
28
|
+
src: Packager::build_source,
|
29
|
+
toolchain: Toolchain?,
|
30
|
+
build_dir: string,
|
31
|
+
rubies_dir: string,
|
32
|
+
**untyped
|
33
|
+
) -> void
|
34
|
+
def crossruby: () -> CrossRubyProduct
|
35
|
+
end
|
36
|
+
|
37
|
+
class BuildParams
|
38
|
+
attr_accessor name: String
|
39
|
+
attr_accessor target: String
|
40
|
+
attr_accessor default_exts: String
|
41
|
+
|
42
|
+
def initialize: (name: string, target: string, default_exts: string) -> void
|
43
|
+
end
|
44
|
+
|
45
|
+
class BuildProduct
|
46
|
+
def name: -> String
|
47
|
+
end
|
48
|
+
|
49
|
+
class AutoconfProduct < BuildProduct
|
50
|
+
@target: String
|
51
|
+
@toolchain: Toolchain
|
52
|
+
|
53
|
+
def initialize: (String target, Toolchain toolchain) -> void
|
54
|
+
def system_triplet_args: -> Array[String]
|
55
|
+
| -> Array[String]
|
56
|
+
def tools_args: -> Array[String]
|
57
|
+
| -> Array[String]
|
58
|
+
def configure_args: -> Array[String]
|
59
|
+
| -> Array[String]
|
60
|
+
end
|
61
|
+
|
62
|
+
class BuildSource < BuildProduct
|
63
|
+
@params: Hash[untyped, untyped]
|
64
|
+
@build_dir: String
|
65
|
+
|
66
|
+
def initialize: (untyped params, String build_dir) -> void
|
67
|
+
def name: -> String
|
68
|
+
def cache_key: (Digest::SHA256 digest) -> void
|
69
|
+
def src_dir: -> String
|
70
|
+
def configure_file: -> String
|
71
|
+
def fetch: (BuildExecutor executor) -> void
|
72
|
+
def build: (BuildExecutor executor) -> void
|
73
|
+
end
|
74
|
+
|
75
|
+
class BaseRubyProduct < BuildProduct
|
76
|
+
@build_dir: String
|
77
|
+
@source: BuildSource
|
78
|
+
@channel: String
|
79
|
+
|
80
|
+
def initialize: (String build_dir, BuildSource source) -> void
|
81
|
+
def product_build_dir: -> String
|
82
|
+
def install_dir: -> String
|
83
|
+
def name: -> String
|
84
|
+
def build: (BuildExecutor executor) -> void
|
85
|
+
end
|
86
|
+
|
87
|
+
class ZlibProduct < AutoconfProduct
|
88
|
+
ZLIB_VERSION: String
|
89
|
+
@build_dir: String
|
90
|
+
|
91
|
+
attr_reader target: String
|
92
|
+
def initialize: (String build_dir, String target, Toolchain toolchain) -> void
|
93
|
+
def product_build_dir: -> String
|
94
|
+
def destdir: -> String
|
95
|
+
def install_root: -> String
|
96
|
+
def name: -> String
|
97
|
+
def configure_args: -> Array[String]
|
98
|
+
def build: (BuildExecutor executor) -> void
|
99
|
+
end
|
100
|
+
|
101
|
+
class LibYAMLProduct < AutoconfProduct
|
102
|
+
LIBYAML_VERSION: String
|
103
|
+
@build_dir: String
|
104
|
+
|
105
|
+
attr_reader target: String
|
106
|
+
def initialize: (String build_dir, String target, Toolchain toolchain) -> void
|
107
|
+
def product_build_dir: -> String
|
108
|
+
def destdir: -> String
|
109
|
+
def install_root: -> String
|
110
|
+
def name: -> String
|
111
|
+
def build: (BuildExecutor executor) -> void
|
112
|
+
end
|
113
|
+
|
114
|
+
class OpenSSLProduct < AutoconfProduct
|
115
|
+
OPENSSL_VERSION: String
|
116
|
+
@build_dir: String
|
117
|
+
|
118
|
+
attr_reader target: String
|
119
|
+
def initialize: (String build_dir, String target, Toolchain toolchain) -> void
|
120
|
+
def product_build_dir: -> String
|
121
|
+
def destdir: -> String
|
122
|
+
def install_root: -> String
|
123
|
+
def name: -> String
|
124
|
+
def configure_args: -> Array[String]
|
125
|
+
def build: (BuildExecutor executor) -> void
|
126
|
+
end
|
127
|
+
|
128
|
+
class WasiVfsProduct < BuildProduct
|
129
|
+
WASI_VFS_VERSION: String
|
130
|
+
@build_dir: String
|
131
|
+
@need_fetch_lib: bool
|
132
|
+
@cli_path: String
|
133
|
+
@need_fetch_cli: bool
|
134
|
+
|
135
|
+
def initialize: (String build_dir) -> void
|
136
|
+
def lib_product_build_dir: -> String
|
137
|
+
def lib_wasi_vfs_a: -> String
|
138
|
+
def name: -> String
|
139
|
+
def build: (BuildExecutor executor) -> void
|
140
|
+
end
|
141
|
+
|
142
|
+
class CrossRubyExtProduct < BuildProduct
|
143
|
+
include RubyWasm::_Cacheable
|
144
|
+
|
145
|
+
@toolchain: Toolchain
|
146
|
+
@srcdir: String
|
147
|
+
@ext_relative_path: String
|
148
|
+
|
149
|
+
attr_reader name: String
|
150
|
+
def initialize: (String srcdir, Toolchain toolchain, ?ext_relative_path: String?) -> void
|
151
|
+
def product_build_dir: (CrossRubyProduct crossruby) -> String
|
152
|
+
def linklist: (CrossRubyProduct crossruby) -> String
|
153
|
+
def metadata_json: (CrossRubyProduct crossruby) -> String
|
154
|
+
def feature_name: (CrossRubyProduct crossruby) -> String
|
155
|
+
|
156
|
+
def make_args: (CrossRubyProduct crossruby) -> Array[String]
|
157
|
+
def build: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
|
158
|
+
def do_extconf: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
|
159
|
+
def do_install_rb: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
|
160
|
+
end
|
161
|
+
|
162
|
+
class CrossRubyProduct < AutoconfProduct
|
163
|
+
include RubyWasm::_Cacheable
|
164
|
+
|
165
|
+
@params: BuildParams
|
166
|
+
@rubies_dir: String
|
167
|
+
@build_dir: String
|
168
|
+
@baseruby: BaseRubyProduct
|
169
|
+
@libyaml: LibYAMLProduct
|
170
|
+
@zlib: ZlibProduct
|
171
|
+
@openssl: OpenSSLProduct
|
172
|
+
@wasi_vfs: WasiVfsProduct
|
173
|
+
|
174
|
+
attr_reader source: BuildSource
|
175
|
+
attr_reader toolchain: Toolchain
|
176
|
+
attr_accessor user_exts: Array[CrossRubyExtProduct]
|
177
|
+
attr_accessor wasmoptflags: Array[String]
|
178
|
+
attr_accessor cppflags: Array[String]
|
179
|
+
attr_accessor cflags: Array[String]
|
180
|
+
attr_accessor ldflags: Array[String]
|
181
|
+
attr_accessor debugflags: Array[String]
|
182
|
+
attr_accessor xcflags: Array[String]
|
183
|
+
attr_accessor xldflags: Array[String]
|
184
|
+
def initialize: (BuildParams params, String build_dir, String rubies_dir, BaseRubyProduct baseruby, BuildSource source, Toolchain toolchain) -> void
|
185
|
+
def configure: (BuildExecutor executor, ?reconfigure: bool) -> void
|
186
|
+
def build_exts: (BuildExecutor executor) -> void
|
187
|
+
def build: (BuildExecutor executor, ?remake: bool, ?reconfigure: bool) -> void
|
188
|
+
def clean: (BuildExecutor executor) -> void
|
189
|
+
def name: -> String
|
190
|
+
def build_dir: -> String
|
191
|
+
def ext_build_dir: -> String
|
192
|
+
def with_libyaml: (LibYAMLProduct libyaml) -> LibYAMLProduct
|
193
|
+
def with_zlib: (ZlibProduct zlib) -> ZlibProduct
|
194
|
+
def with_wasi_vfs: (WasiVfsProduct wasi_vfs) -> WasiVfsProduct
|
195
|
+
def with_openssl: (OpenSSLProduct openssl) -> OpenSSLProduct
|
196
|
+
def dest_dir: -> String
|
197
|
+
def artifact: -> String
|
198
|
+
def extinit_obj: -> String
|
199
|
+
def extinit_c_erb: -> String
|
200
|
+
def baseruby_path: -> String
|
201
|
+
def configure_args: (String build_triple, Toolchain toolchain) -> Array[String]
|
202
|
+
end
|
203
|
+
|
204
|
+
class WitBindgen
|
205
|
+
@build_dir: String
|
206
|
+
@tool_dir: String
|
207
|
+
@revision: String
|
208
|
+
|
209
|
+
attr_reader bin_path: String
|
210
|
+
def initialize: (build_dir: String, ?revision: String) -> void
|
211
|
+
def install: -> void
|
212
|
+
end
|
213
|
+
|
214
|
+
class Toolchain
|
215
|
+
@tools: Hash[untyped, untyped]
|
216
|
+
@tools_cache: Hash[untyped, untyped]
|
217
|
+
|
218
|
+
attr_reader name: String
|
219
|
+
def initialize: -> void
|
220
|
+
def find_tool: (Symbol name) -> String
|
221
|
+
def check_envvar: (untyped name) -> void
|
222
|
+
def self.get: (String target, ?String? build_dir) -> (Toolchain)
|
223
|
+
def self.find_path: (String command) -> String?
|
224
|
+
def self.check_executable: (String command) -> String
|
225
|
+
def cc: -> String
|
226
|
+
def ranlib: -> String
|
227
|
+
def ld: -> String
|
228
|
+
def ar: -> String
|
229
|
+
|
230
|
+
def install: -> void
|
231
|
+
end
|
232
|
+
|
233
|
+
class WASISDK < Toolchain
|
234
|
+
@wasm_opt_path: String
|
235
|
+
@need_fetch_wasi_sdk: bool
|
236
|
+
@need_fetch_binaryen: bool
|
237
|
+
@tools: Hash[Symbol, String]
|
238
|
+
@wasi_sdk_path: String
|
239
|
+
@binaryen_version: Integer
|
240
|
+
@version_major: Integer
|
241
|
+
@version_minor: Integer
|
242
|
+
@binaryen_path: String
|
243
|
+
|
244
|
+
def initialize: (?String? wasi_sdk_path, ?build_dir: String?, ?version_major: Integer, ?version_minor: Integer, ?binaryen_version: Integer) -> void
|
245
|
+
def find_tool: (Symbol name) -> String
|
246
|
+
def wasm_opt: -> String
|
247
|
+
def wasi_sdk_path: -> String
|
248
|
+
def download_url: (Integer? version_major, Integer? version_minor) -> String
|
249
|
+
def binaryen_download_url: (Integer? version) -> String
|
250
|
+
def install_wasi_sdk: -> void
|
251
|
+
def install_binaryen: -> void
|
252
|
+
end
|
253
|
+
|
254
|
+
class Emscripten < Toolchain
|
255
|
+
@tools: Hash[Symbol, String]
|
256
|
+
|
257
|
+
def initialize: -> void
|
258
|
+
def find_tool: (Symbol name) -> String
|
259
|
+
end
|
260
|
+
|
261
|
+
class BuildExecutor
|
262
|
+
@verbose: bool
|
263
|
+
@github_actions_markup: bool
|
264
|
+
@process_count: Integer
|
265
|
+
@start_times: Hash[[Class, String], Time]
|
266
|
+
|
267
|
+
attr_reader process_count: Integer
|
268
|
+
|
269
|
+
def initialize: (?verbose: bool) -> void
|
270
|
+
def system: (*_ToS args, ?chdir: String?, ?env: Hash[String, String]?) -> void
|
271
|
+
def rm_rf: (FileUtils::pathlist list) -> void
|
272
|
+
def rm_f: (FileUtils::pathlist list) -> void
|
273
|
+
def cp_r: (FileUtils::pathlist src, path dest) -> void
|
274
|
+
def mv: (FileUtils::pathlist src, path dest) -> void
|
275
|
+
def mkdir_p: (FileUtils::pathlist list) -> void
|
276
|
+
def write: (String path, _ToS data) -> void
|
277
|
+
|
278
|
+
def begin_section: (Class klass, String name, String note) -> void
|
279
|
+
def end_section: (Class klass, String name) -> void
|
280
|
+
|
281
|
+
private def _print_command: (Array[_ToS] command, Hash[String, String]? env) -> void
|
282
|
+
end
|
283
|
+
|
284
|
+
class StatusPrinter
|
285
|
+
@mutex: Mutex
|
286
|
+
@counter: Integer
|
287
|
+
@indicators: String
|
288
|
+
|
289
|
+
def initialize: () -> void
|
290
|
+
def stdout: (String message) -> void
|
291
|
+
def stderr: (String message) -> void
|
292
|
+
def done: () -> void
|
293
|
+
end
|
294
|
+
|
295
|
+
class Downloader
|
296
|
+
def format_size: (Integer size) -> String
|
297
|
+
|
298
|
+
def download: (String url, String dest, String message) -> void
|
299
|
+
end
|
300
|
+
|
301
|
+
class BuildTask
|
302
|
+
@build_dir: String
|
303
|
+
@rubies_dir: String
|
304
|
+
@openssl: OpenSSLProduct
|
305
|
+
|
306
|
+
attr_accessor name: String
|
307
|
+
attr_reader source: BuildSource
|
308
|
+
attr_reader target: String
|
309
|
+
attr_reader toolchain: Toolchain
|
310
|
+
attr_reader libyaml: LibYAMLProduct
|
311
|
+
attr_reader zlib: ZlibProduct
|
312
|
+
attr_reader wasi_vfs: WasiVfsProduct
|
313
|
+
attr_reader baseruby: BaseRubyProduct
|
314
|
+
attr_reader crossruby: CrossRubyProduct
|
315
|
+
def initialize: (String name, target: String, src: untyped, ?toolchain: Toolchain?, ?build_dir: String?, ?rubies_dir: String?, **untyped) -> void
|
316
|
+
def hexdigest: -> String
|
317
|
+
end
|
318
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module RubyWasm
|
2
|
+
class CLI
|
3
|
+
DEFAULT_RUBIES_DIR: string
|
4
|
+
|
5
|
+
@stdout: IO
|
6
|
+
@stderr: IO
|
7
|
+
|
8
|
+
def initialize: (stdout: IO, stderr: IO) -> void
|
9
|
+
|
10
|
+
def build: (Array[String] args) -> void
|
11
|
+
def pack: (Array[String] args) -> void
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build_config: (Hash[untyped, untyped] options) -> Hash[untyped, untyped]
|
16
|
+
|
17
|
+
def derive_packager: (Hash[untyped, untyped] options) -> Packager
|
18
|
+
def do_print_ruby_cache_key: (Packager) -> void
|
19
|
+
def do_build: (BuildExecutor, string tmpdir, Packager, Hash[untyped, untyped] options) -> void
|
20
|
+
|
21
|
+
def require_extension: () -> void
|
22
|
+
end
|
23
|
+
|
24
|
+
self.@logger: Logger?
|
25
|
+
def self.logger: () -> Logger
|
26
|
+
attr_accessor self.log_level: Symbol
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RubyWasmExt
|
2
|
+
def self.preinitialize: (Array[Integer] module_bytes) -> Array[Integer]
|
3
|
+
|
4
|
+
class WasiVfs
|
5
|
+
def initialize: () -> void
|
6
|
+
|
7
|
+
def self.run_cli: (Array[String] args) -> void
|
8
|
+
|
9
|
+
def map_dir: (String guest_path, String host_path) -> void
|
10
|
+
|
11
|
+
def pack: (Array[Integer] module_bytes) -> Array[Integer]
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
|
2
|
+
class RubyWasm::Packager
|
3
|
+
@definition: untyped
|
4
|
+
@config: Hash[untyped, untyped]
|
5
|
+
|
6
|
+
def initialize: (untyped?, Hash[untyped, untyped]?) -> void
|
7
|
+
|
8
|
+
def package: (RubyWasm::BuildExecutor, string dest_dir, untyped options) -> Array[Integer]
|
9
|
+
|
10
|
+
@ruby_core_build: RubyWasm::Packager::Core?
|
11
|
+
def ruby_core_build: () -> RubyWasm::Packager::Core
|
12
|
+
|
13
|
+
EXCLUDED_GEMS: Array[string]
|
14
|
+
|
15
|
+
def specs: () -> Array[untyped]
|
16
|
+
def support_dynamic_linking?: () -> bool
|
17
|
+
|
18
|
+
def root: () -> string
|
19
|
+
|
20
|
+
type build_source = Hash[Symbol, (String | Array[String])]
|
21
|
+
def self.build_source_aliases: (string root) -> Hash[string, build_source]
|
22
|
+
|
23
|
+
ALL_DEFAULT_EXTS: string
|
24
|
+
|
25
|
+
def build_options: () -> Hash[Symbol, untyped]
|
26
|
+
def full_build_options: () -> Hash[Symbol, untyped]
|
27
|
+
|
28
|
+
class Core
|
29
|
+
include RubyWasm::_Cacheable
|
30
|
+
|
31
|
+
@packager: RubyWasm::Packager
|
32
|
+
def initialize: (RubyWasm::Packager) -> void
|
33
|
+
def build: (RubyWasm::BuildExecutor, untyped options) -> String
|
34
|
+
|
35
|
+
extend Forwardable
|
36
|
+
|
37
|
+
def artifact: () -> string
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
@build_strategy: BuildStrategy?
|
42
|
+
def build_strategy: () -> BuildStrategy
|
43
|
+
|
44
|
+
class BuildStrategy
|
45
|
+
@packager: RubyWasm::Packager
|
46
|
+
def initialize: (RubyWasm::Packager) -> void
|
47
|
+
def build: (RubyWasm::BuildExecutor, untyped options) -> String
|
48
|
+
def specs_with_extensions: () -> Array[[untyped, Array[string]]]
|
49
|
+
end
|
50
|
+
|
51
|
+
class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy
|
52
|
+
end
|
53
|
+
|
54
|
+
class StaticLinking < RubyWasm::Packager::Core::BuildStrategy
|
55
|
+
@build: RubyWasm::Build
|
56
|
+
def derive_build: () -> RubyWasm::Build
|
57
|
+
@user_exts: Array[RubyWasm::CrossRubyExtProduct]?
|
58
|
+
def user_exts: (RubyWasm::Build) -> Array[RubyWasm::CrossRubyExtProduct]
|
59
|
+
|
60
|
+
def name: () -> string
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class FileSystem
|
65
|
+
@dest_dir: string
|
66
|
+
@packager: RubyWasm::Packager
|
67
|
+
@ruby_root: string
|
68
|
+
|
69
|
+
def initialize: (string dest_dir, RubyWasm::Packager) -> void
|
70
|
+
def package_ruby_root: (String tarball, RubyWasm::BuildExecutor) -> void
|
71
|
+
def remove_stdlib: (RubyWasm::BuildExecutor) -> void
|
72
|
+
def package_gems: () -> void
|
73
|
+
|
74
|
+
def setup_rb_content: () -> String
|
75
|
+
|
76
|
+
def remove_non_runtime_files: (RubyWasm::BuildExecutor) -> void
|
77
|
+
|
78
|
+
def bundle_dir: () -> String
|
79
|
+
def ruby_root: () -> string
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def each_gem_content_path: () { (String, String) -> void } -> void
|
84
|
+
def each_gem_require_path: () { (String, String) -> void } -> void
|
85
|
+
def each_gem_extension_path: () { (String, String) -> void } -> void
|
86
|
+
|
87
|
+
def bundle_relative_path: () -> String
|
88
|
+
def ruby_version: () -> String
|
89
|
+
def rubyarchdir: () -> String
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -eo pipefail
|
4
|
+
|
5
|
+
if [ -n "$1" ]; then
|
6
|
+
BASE_BRANCH="$1"
|
7
|
+
elif [ -n "$GITHUB_EVENT_BEFORE" ] && [ "push" = "$GITHUB_EVENT_NAME" ]; then
|
8
|
+
BASE_BRANCH="$GITHUB_EVENT_BEFORE"
|
9
|
+
elif [ -n "$GITHUB_BASE_REF" ]; then
|
10
|
+
BASE_BRANCH="origin/$GITHUB_BASE_REF"
|
11
|
+
else
|
12
|
+
BASE_BRANCH="@{upstream}"
|
13
|
+
fi
|
14
|
+
|
15
|
+
MERGE_BASE=$(git merge-base $BASE_BRANCH HEAD)
|
16
|
+
|
17
|
+
git diff -U0 --no-color $MERGE_BASE -- '*.c' '*.h' | clang-format-diff -i -p1
|
18
|
+
exit $?
|
data/tools/exe/rbminify
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
|
4
|
+
|
5
|
+
require "syntax_tree"
|
6
|
+
require "syntax_tree/cli"
|
7
|
+
require "syntax_tree/minify_ruby"
|
8
|
+
|
9
|
+
# Override the default formatter with our own.
|
10
|
+
SyntaxTree.register_handler(".rb", SyntaxTree::MinifyRuby)
|
11
|
+
|
12
|
+
exit(SyntaxTree::CLI.run(ARGV))
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "syntax_tree"
|
2
|
+
|
3
|
+
module SyntaxTree
|
4
|
+
module MinifyRuby
|
5
|
+
|
6
|
+
# This is a required API for syntax tree which just delegates to SyntaxTree.parse.
|
7
|
+
def self.parse(source)
|
8
|
+
::SyntaxTree.parse(source)
|
9
|
+
end
|
10
|
+
|
11
|
+
# This is the main entrypoint for the formatter. It parses the source,
|
12
|
+
# builds a formatter, then prints the result.
|
13
|
+
def self.format(source, _maxwidth = nil)
|
14
|
+
formatter = Formatter.new(source)
|
15
|
+
program = parse(source)
|
16
|
+
CommentStrippingVisitor.new.visit(program)
|
17
|
+
program.format(formatter)
|
18
|
+
|
19
|
+
formatter.flush
|
20
|
+
formatter.output.join
|
21
|
+
end
|
22
|
+
|
23
|
+
# This is a required API for syntax tree which just delegates to SyntaxTree.read.
|
24
|
+
def self.read(filepath)
|
25
|
+
::SyntaxTree.read(filepath)
|
26
|
+
end
|
27
|
+
|
28
|
+
class CommentStrippingVisitor < SyntaxTree::Visitor
|
29
|
+
def visit(node)
|
30
|
+
if node and node.comments.any?
|
31
|
+
node.comments.clear
|
32
|
+
end
|
33
|
+
super(node)
|
34
|
+
end
|
35
|
+
|
36
|
+
def visit_statements(node)
|
37
|
+
node.body.delete_if { _1.is_a?(SyntaxTree::Comment) }
|
38
|
+
super(node)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Formatter < SyntaxTree::Formatter
|
43
|
+
def initialize(source)
|
44
|
+
super(source, [], Float::INFINITY) do |n|
|
45
|
+
# This block, called `genspace`, is used to generate indentation for `n` depth.
|
46
|
+
""
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def breakable(
|
51
|
+
separator = " ",
|
52
|
+
_width = separator.length,
|
53
|
+
indent: nil,
|
54
|
+
force: nil
|
55
|
+
)
|
56
|
+
# Don't break when already broken
|
57
|
+
return if target.last.is_a?(PrettierPrint::BreakParent)
|
58
|
+
return if not force and separator == ""
|
59
|
+
super(separator, _width, indent: indent, force: force)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_wasm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.5.0
|
5
|
+
platform: arm64-darwin
|
6
|
+
authors:
|
7
|
+
- Yuta Saito
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby to WebAssembly toolkit. This gem takes Ruby code and Gemfile, and
|
14
|
+
packages them with Ruby runtime into a WebAssembly binary.
|
15
|
+
email:
|
16
|
+
- kateinoigakukun@gmail.com
|
17
|
+
executables:
|
18
|
+
- rbwasm
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- ".clang-format"
|
23
|
+
- CONTRIBUTING.md
|
24
|
+
- Gemfile
|
25
|
+
- LICENSE
|
26
|
+
- NOTICE
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- Steepfile
|
30
|
+
- benchmarks/vm_deep_call.rb
|
31
|
+
- builders/wasm32-unknown-emscripten/Dockerfile
|
32
|
+
- builders/wasm32-unknown-emscripten/entrypoint.sh
|
33
|
+
- builders/wasm32-unknown-wasi/Dockerfile
|
34
|
+
- builders/wasm32-unknown-wasi/entrypoint.sh
|
35
|
+
- docs/api.md
|
36
|
+
- docs/cheat_sheet.md
|
37
|
+
- docs/faq.md
|
38
|
+
- exe/rbwasm
|
39
|
+
- ext/.gitignore
|
40
|
+
- ext/README.md
|
41
|
+
- ext/extinit.c.erb
|
42
|
+
- lib/ruby_wasm.rb
|
43
|
+
- lib/ruby_wasm/3.0/ruby_wasm.bundle
|
44
|
+
- lib/ruby_wasm/3.1/ruby_wasm.bundle
|
45
|
+
- lib/ruby_wasm/3.2/ruby_wasm.bundle
|
46
|
+
- lib/ruby_wasm/build.rb
|
47
|
+
- lib/ruby_wasm/build/build_params.rb
|
48
|
+
- lib/ruby_wasm/build/downloader.rb
|
49
|
+
- lib/ruby_wasm/build/executor.rb
|
50
|
+
- lib/ruby_wasm/build/product.rb
|
51
|
+
- lib/ruby_wasm/build/product/baseruby.rb
|
52
|
+
- lib/ruby_wasm/build/product/crossruby.rb
|
53
|
+
- lib/ruby_wasm/build/product/libyaml.rb
|
54
|
+
- lib/ruby_wasm/build/product/openssl.rb
|
55
|
+
- lib/ruby_wasm/build/product/product.rb
|
56
|
+
- lib/ruby_wasm/build/product/ruby_source.rb
|
57
|
+
- lib/ruby_wasm/build/product/wasi_vfs.rb
|
58
|
+
- lib/ruby_wasm/build/product/zlib.rb
|
59
|
+
- lib/ruby_wasm/build/toolchain.rb
|
60
|
+
- lib/ruby_wasm/build/toolchain/wit_bindgen.rb
|
61
|
+
- lib/ruby_wasm/cli.rb
|
62
|
+
- lib/ruby_wasm/packager.rb
|
63
|
+
- lib/ruby_wasm/packager/core.rb
|
64
|
+
- lib/ruby_wasm/packager/file_system.rb
|
65
|
+
- lib/ruby_wasm/rake_task.rb
|
66
|
+
- lib/ruby_wasm/util.rb
|
67
|
+
- lib/ruby_wasm/version.rb
|
68
|
+
- package-lock.json
|
69
|
+
- package.json
|
70
|
+
- rakelib/check.rake
|
71
|
+
- rakelib/ci.rake
|
72
|
+
- rakelib/doc.rake
|
73
|
+
- rakelib/format.rake
|
74
|
+
- rakelib/gem.rake
|
75
|
+
- rakelib/packaging.rake
|
76
|
+
- rakelib/version.rake
|
77
|
+
- sig/open_uri.rbs
|
78
|
+
- sig/ruby_wasm/build.rbs
|
79
|
+
- sig/ruby_wasm/cli.rbs
|
80
|
+
- sig/ruby_wasm/ext.rbs
|
81
|
+
- sig/ruby_wasm/packager.rbs
|
82
|
+
- sig/ruby_wasm/util.rbs
|
83
|
+
- tools/clang-format-diff.sh
|
84
|
+
- tools/exe/rbminify
|
85
|
+
- tools/lib/syntax_tree/minify_ruby.rb
|
86
|
+
homepage: https://github.com/ruby/ruby.wasm
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata:
|
90
|
+
homepage_uri: https://github.com/ruby/ruby.wasm
|
91
|
+
source_code_uri: https://github.com/ruby/ruby.wasm
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '3.0'
|
101
|
+
- - "<"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.3.dev
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubygems_version: 3.4.4
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Ruby to WebAssembly toolkit
|
114
|
+
test_files: []
|