File tree Expand file tree Collapse file tree 4 files changed +54
-3
lines changed Expand file tree Collapse file tree 4 files changed +54
-3
lines changed Original file line number Diff line number Diff line change 4
4
require_relative "product/baseruby"
5
5
require_relative "product/zlib"
6
6
require_relative "product/libyaml"
7
+ require_relative "product/wasi_vfs"
7
8
require_relative "product/crossruby"
Original file line number Diff line number Diff line change @@ -165,6 +165,11 @@ def with_zlib(zlib)
165
165
@dep_tasks << zlib . install_task
166
166
end
167
167
168
+ def with_wasi_vfs ( wasi_vfs )
169
+ @wasi_vfs = wasi_vfs
170
+ @dep_tasks << wasi_vfs . install_task
171
+ end
172
+
168
173
def dest_dir
169
174
File . join ( @rubies_dir , name )
170
175
end
@@ -209,9 +214,7 @@ def configure_args(build_triple, toolchain)
209
214
210
215
case target
211
216
when "wasm32-unknown-wasi"
212
- unless toolchain . lib_wasi_vfs_a . nil?
213
- xldflags << toolchain . lib_wasi_vfs_a
214
- end
217
+ xldflags << @wasi_vfs . lib_wasi_vfs_a if @wasi_vfs
215
218
when "wasm32-unknown-emscripten"
216
219
ldflags . concat ( %w[ -s MODULARIZE=1 ] )
217
220
args . concat ( %w[ CC=emcc LD=emcc AR=emar RANLIB=emranlib ] )
Original file line number Diff line number Diff line change
1
+ require "rake"
2
+ require_relative "./product"
3
+
4
+ module RubyWasm
5
+ class WasiVfsProduct < BuildProduct
6
+ attr_reader :install_task
7
+
8
+ WASI_VFS_VERSION = "0.1.1"
9
+
10
+ def initialize ( build_dir )
11
+ @build_dir = build_dir
12
+ end
13
+
14
+ def lib_product_build_dir
15
+ File . join (
16
+ @build_dir ,
17
+ "wasm32-unknown-wasi" ,
18
+ "wasi-vfs-#{ WASI_VFS_VERSION } "
19
+ )
20
+ end
21
+
22
+ def lib_wasi_vfs_a
23
+ File . join ( lib_product_build_dir , "libwasi_vfs.a" )
24
+ end
25
+
26
+ def name
27
+ lib_product_build_dir
28
+ end
29
+
30
+ def define_task
31
+ @install_task =
32
+ file ( lib_wasi_vfs_a ) do
33
+ require "tmpdir"
34
+ lib_wasi_vfs_url =
35
+ "https://github.com/kateinoigakukun/wasi-vfs/releases/download/v#{ WASI_VFS_VERSION } /libwasi_vfs-wasm32-unknown-unknown.zip"
36
+ Dir . mktmpdir do |tmpdir |
37
+ sh "curl -L #{ lib_wasi_vfs_url } -o #{ tmpdir } /libwasi_vfs.zip"
38
+ sh "unzip #{ tmpdir } /libwasi_vfs.zip -d #{ tmpdir } "
39
+ mkdir_p File . dirname ( lib_wasi_vfs_a )
40
+ mv File . join ( tmpdir , "libwasi_vfs.a" ) , lib_wasi_vfs_a
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ def initialize(
43
43
add_product RubyWasm ::LibYAMLProduct . new ( @build_dir , @target , @toolchain )
44
44
@zlib =
45
45
add_product RubyWasm ::ZlibProduct . new ( @build_dir , @target , @toolchain )
46
+ @wasi_vfs = add_product RubyWasm ::WasiVfsProduct . new ( @build_dir )
46
47
@source = add_product RubyWasm ::BuildSource . new ( src , @build_dir )
47
48
@baseruby = add_product RubyWasm ::BaseRubyProduct . new ( @build_dir , @source )
48
49
@@ -64,6 +65,7 @@ def initialize(
64
65
65
66
@crossruby . with_libyaml @libyaml
66
67
@crossruby . with_zlib @zlib
68
+ @crossruby . with_wasi_vfs @wasi_vfs
67
69
68
70
@crossruby . define_task
69
71
end
You can’t perform that action at this time.
0 commit comments