ruby_wasm 2.5.0-x64-mingw-ucrt → 2.5.2-x64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +9 -7
- data/Gemfile +1 -1
- data/README.md +12 -11
- data/Rakefile +9 -7
- data/docs/cheat_sheet.md +8 -8
- data/lib/ruby_wasm/3.1/ruby_wasm.so +0 -0
- data/lib/ruby_wasm/3.2/ruby_wasm.so +0 -0
- data/lib/ruby_wasm/3.3/ruby_wasm.so +0 -0
- data/lib/ruby_wasm/build/executor.rb +4 -0
- data/lib/ruby_wasm/build/product/crossruby.rb +59 -25
- data/lib/ruby_wasm/build/product/libyaml.rb +5 -3
- data/lib/ruby_wasm/build/product/openssl.rb +7 -2
- data/lib/ruby_wasm/build/product/product.rb +3 -3
- data/lib/ruby_wasm/build/product/ruby_source.rb +3 -3
- data/lib/ruby_wasm/build/product/wasi_vfs.rb +1 -1
- data/lib/ruby_wasm/build/product/zlib.rb +3 -1
- data/lib/ruby_wasm/build/target.rb +24 -0
- data/lib/ruby_wasm/build/toolchain/wit_bindgen.rb +2 -2
- data/lib/ruby_wasm/build/toolchain.rb +1 -1
- data/lib/ruby_wasm/build.rb +7 -3
- data/lib/ruby_wasm/cli.rb +147 -11
- data/lib/ruby_wasm/feature_set.rb +30 -0
- data/lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.command.wasm +0 -0
- data/lib/ruby_wasm/packager/component_adapter/wasi_snapshot_preview1.reactor.wasm +0 -0
- data/lib/ruby_wasm/packager/component_adapter.rb +14 -0
- data/lib/ruby_wasm/packager/core.rb +199 -5
- data/lib/ruby_wasm/packager/file_system.rb +5 -3
- data/lib/ruby_wasm/packager.rb +22 -82
- data/lib/ruby_wasm/rake_task.rb +1 -0
- data/lib/ruby_wasm/version.rb +1 -1
- data/lib/ruby_wasm.rb +2 -0
- data/package-lock.json +5571 -7015
- data/package.json +3 -3
- data/rakelib/check.rake +23 -10
- data/rakelib/ci.rake +3 -3
- data/rakelib/packaging.rake +44 -15
- data/sig/ruby_wasm/build.rbs +38 -28
- data/sig/ruby_wasm/cli.rbs +27 -3
- data/sig/ruby_wasm/ext.rbs +25 -2
- data/sig/ruby_wasm/feature_set.rbs +12 -0
- data/sig/ruby_wasm/packager.rbs +44 -7
- metadata +10 -7
- data/builders/wasm32-unknown-emscripten/Dockerfile +0 -43
- data/builders/wasm32-unknown-emscripten/entrypoint.sh +0 -7
- data/builders/wasm32-unknown-wasi/Dockerfile +0 -47
- data/builders/wasm32-unknown-wasi/entrypoint.sh +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3affee5bce774ff47a6032388699e8db0bf481170c88e911e38394d3c14749da
|
4
|
+
data.tar.gz: 1dcbb155faa3fa18d21895eec470cd57b1c12f0226acdaef5011cb28b949cbc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9f9d2b040f6c1ef761f8df6d55ff2e301a0ea74a0f1e0506ff73c004e94ac8510ec3ed3dd33aba081a72105f18844557d538c60ea20294ba2e6f9d28414622
|
7
|
+
data.tar.gz: 3127f681e98e8ed4abb24c1a2374dca2a4cce209f5e49261b458f7704f27ac759916d494fa12fa9e8a85c925c57db8c11d676dd05eed92788c4c0bf63e6999a8
|
data/CONTRIBUTING.md
CHANGED
@@ -21,7 +21,7 @@ $ rake --tasks
|
|
21
21
|
$ rake build:download_prebuilt
|
22
22
|
|
23
23
|
# Build Ruby (if you need to build Ruby by yourself)
|
24
|
-
$ rake build:head-wasm32-unknown-
|
24
|
+
$ rake build:head-wasm32-unknown-wasip1-full
|
25
25
|
|
26
26
|
# Build npm package
|
27
27
|
$ rake npm:ruby-head-wasm-wasi
|
@@ -48,15 +48,15 @@ To select a build profile, see [profiles section in README](https://github.com/r
|
|
48
48
|
|
49
49
|
```console
|
50
50
|
# Build only a specific combination of ruby version, profile, and target
|
51
|
-
$ rake build:head-wasm32-unknown-
|
51
|
+
$ rake build:head-wasm32-unknown-wasip1-full
|
52
52
|
# Clean up the build directory
|
53
|
-
$ rake build:head-wasm32-unknown-
|
53
|
+
$ rake build:head-wasm32-unknown-wasip1-full:clean
|
54
54
|
# Force to re-execute "make install"
|
55
|
-
$ rake build:head-wasm32-unknown-
|
55
|
+
$ rake build:head-wasm32-unknown-wasip1-full:remake
|
56
56
|
|
57
57
|
# Output is in the `rubies` directory
|
58
|
-
$ tree -L 3 rubies/head-wasm32-unknown-
|
59
|
-
rubies/head-wasm32-unknown-
|
58
|
+
$ tree -L 3 rubies/head-wasm32-unknown-wasip1-full
|
59
|
+
rubies/head-wasm32-unknown-wasip1-full/
|
60
60
|
├── usr
|
61
61
|
│ └── local
|
62
62
|
│ ├── bin
|
@@ -109,6 +109,8 @@ $ rake 'bump_version[0.6.0]'
|
|
109
109
|
$ git commit -m"Bump version to 0.6.0"
|
110
110
|
$ git tag 0.6.0
|
111
111
|
$ git push origin 0.6.0
|
112
|
+
$ for pkg in pkg/ruby_wasm-*; do gem push $pkg; done
|
113
|
+
$ (cd packages/gems/js/ && gem build && gem push js-*.gem)
|
112
114
|
```
|
113
115
|
|
114
116
|
## Release Channels
|
@@ -122,5 +124,5 @@ $ npm install --save @ruby/wasm-wasi@latest
|
|
122
124
|
# or if you want the nightly snapshot
|
123
125
|
$ npm install --save @ruby/wasm-wasi@next
|
124
126
|
# or you can specify the exact snapshot version
|
125
|
-
$ npm install --save @ruby/wasm-wasi@2.5.
|
127
|
+
$ npm install --save @ruby/wasm-wasi@2.5.2-2024-05-04-a
|
126
128
|
```
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -17,17 +17,17 @@ Try ruby.wasm in [TryRuby](https://try.ruby-lang.org/playground#code=puts+RUBY_D
|
|
17
17
|
- [Complete Examples](https://github.com/ruby/ruby.wasm/tree/main/packages/npm-packages/ruby-wasm-wasi/example)
|
18
18
|
- [Community Showcase](https://github.com/ruby/ruby.wasm/wiki/Showcase)
|
19
19
|
|
20
|
-
## Quick Example: Ruby on browser
|
20
|
+
## Quick Example: Ruby on Web browser
|
21
21
|
|
22
22
|
Create and save `index.html` page with the following contents:
|
23
23
|
|
24
24
|
```html
|
25
25
|
<html>
|
26
|
-
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.
|
26
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/browser.script.iife.js"></script>
|
27
27
|
<script type="text/ruby">
|
28
28
|
require "js"
|
29
29
|
|
30
|
-
puts RUBY_VERSION #
|
30
|
+
puts RUBY_VERSION # (Printed to the Web browser console)
|
31
31
|
JS.global[:document].write "Hello, world!"
|
32
32
|
</script>
|
33
33
|
</html>
|
@@ -35,25 +35,26 @@ Create and save `index.html` page with the following contents:
|
|
35
35
|
|
36
36
|
## Quick Example: How to package your Ruby application as a WASI application
|
37
37
|
|
38
|
-
Dependencies: [
|
38
|
+
Dependencies: [wasmtime](https://github.com/bytecodealliance/wasmtime)
|
39
39
|
|
40
40
|
```console
|
41
|
+
$ gem install ruby_wasm
|
41
42
|
# Download a prebuilt Ruby release
|
42
|
-
$ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.
|
43
|
-
$ tar xfz ruby-3.
|
43
|
+
$ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.3-wasm32-unknown-wasip1-full.tar.gz
|
44
|
+
$ tar xfz ruby-3.3-wasm32-unknown-wasip1-full.tar.gz
|
44
45
|
|
45
46
|
# Extract ruby binary not to pack itself
|
46
|
-
$ mv 3.
|
47
|
+
$ mv ruby-3.3-wasm32-unknown-wasip1-full/usr/local/bin/ruby ruby.wasm
|
47
48
|
|
48
49
|
# Put your app code
|
49
50
|
$ mkdir src
|
50
51
|
$ echo "puts 'Hello'" > src/my_app.rb
|
51
52
|
|
52
53
|
# Pack the whole directory under /usr and your app dir
|
53
|
-
$
|
54
|
+
$ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-3.3-wasm32-unknown-wasip1-full/usr::/usr -o my-ruby-app.wasm
|
54
55
|
|
55
56
|
# Run the packed scripts
|
56
|
-
$ wasmtime my-ruby-app.wasm
|
57
|
+
$ wasmtime my-ruby-app.wasm /src/my_app.rb
|
57
58
|
Hello
|
58
59
|
```
|
59
60
|
|
@@ -109,8 +110,8 @@ A _build_ is a combination of ruby version, _profile_, and _target_.
|
|
109
110
|
</thead>
|
110
111
|
<tbody>
|
111
112
|
<tr>
|
112
|
-
<td><code>wasm32-unknown-
|
113
|
-
<td>Targeting WASI
|
113
|
+
<td><code>wasm32-unknown-wasip1</code></td>
|
114
|
+
<td>Targeting <a href="https://github.com/WebAssembly/WASI/tree/main/legacy/preview1">WASI Preview1</a> compatible environments <br>(e.g. Node.js, browsers with polyfill, <a href="https://github.com/bytecodealliance/wasmtime">wasmtime</a>, and so on)</td>
|
114
115
|
</tr>
|
115
116
|
<tr>
|
116
117
|
<td><code>wasm32-unknown-emscripten</code></td>
|
data/Rakefile
CHANGED
@@ -7,6 +7,7 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), "lib")
|
|
7
7
|
require "bundler/gem_tasks"
|
8
8
|
require "ruby_wasm/rake_task"
|
9
9
|
require "ruby_wasm/packager"
|
10
|
+
require "ruby_wasm/cli"
|
10
11
|
|
11
12
|
BUILD_SOURCES = %w[3.3 3.2 head]
|
12
13
|
BUILD_PROFILES = %w[full minimal]
|
@@ -14,7 +15,7 @@ BUILD_PROFILES = %w[full minimal]
|
|
14
15
|
BUILDS =
|
15
16
|
BUILD_SOURCES
|
16
17
|
.product(BUILD_PROFILES)
|
17
|
-
.map { |src, profile| [src, "wasm32-unknown-
|
18
|
+
.map { |src, profile| [src, "wasm32-unknown-wasip1", profile] } +
|
18
19
|
BUILD_SOURCES.map { |src| [src, "wasm32-unknown-emscripten", "full"] }
|
19
20
|
|
20
21
|
NPM_PACKAGES = [
|
@@ -28,26 +29,27 @@ NPM_PACKAGES = [
|
|
28
29
|
name: "ruby-head-wasm-wasi",
|
29
30
|
ruby_version: "head",
|
30
31
|
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
|
31
|
-
target: "wasm32-unknown-
|
32
|
+
target: "wasm32-unknown-wasip1",
|
33
|
+
enable_component_model: true,
|
32
34
|
},
|
33
35
|
{
|
34
36
|
name: "ruby-3.3-wasm-wasi",
|
35
37
|
ruby_version: "3.3",
|
36
38
|
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
|
37
|
-
target: "wasm32-unknown-
|
39
|
+
target: "wasm32-unknown-wasip1"
|
38
40
|
},
|
39
41
|
{
|
40
42
|
name: "ruby-3.2-wasm-wasi",
|
41
43
|
ruby_version: "3.2",
|
42
44
|
gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile",
|
43
|
-
target: "wasm32-unknown-
|
45
|
+
target: "wasm32-unknown-wasip1"
|
44
46
|
},
|
45
|
-
{ name: "ruby-wasm-wasi", target: "wasm32-unknown-
|
47
|
+
{ name: "ruby-wasm-wasi", target: "wasm32-unknown-wasip1" }
|
46
48
|
]
|
47
49
|
|
48
50
|
STANDALONE_PACKAGES = [
|
49
|
-
{ name: "ruby", build: "head-wasm32-unknown-
|
50
|
-
{ name: "irb", build: "head-wasm32-unknown-
|
51
|
+
{ name: "ruby", build: "head-wasm32-unknown-wasip1-full" },
|
52
|
+
{ name: "irb", build: "head-wasm32-unknown-wasip1-full" }
|
51
53
|
]
|
52
54
|
|
53
55
|
LIB_ROOT = File.dirname(__FILE__)
|
data/docs/cheat_sheet.md
CHANGED
@@ -38,7 +38,7 @@ The easiest way to run Ruby on browser is to use `browser.script.iife.js` script
|
|
38
38
|
|
39
39
|
```html
|
40
40
|
<html>
|
41
|
-
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.
|
41
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/browser.script.iife.js"></script>
|
42
42
|
<script type="text/ruby">
|
43
43
|
require "js"
|
44
44
|
JS.global[:document].write "Hello, world!"
|
@@ -51,8 +51,8 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
|
|
51
51
|
```html
|
52
52
|
<html>
|
53
53
|
<script type="module">
|
54
|
-
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.
|
55
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.
|
54
|
+
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.2/dist/browser/+esm";
|
55
|
+
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/ruby+stdlib.wasm");
|
56
56
|
const module = await WebAssembly.compileStreaming(response);
|
57
57
|
const { vm } = await DefaultRubyVM(module);
|
58
58
|
|
@@ -69,11 +69,11 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
|
|
69
69
|
|
70
70
|
```html
|
71
71
|
<html>
|
72
|
-
<script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.
|
72
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.2/dist/browser.umd.js"></script>
|
73
73
|
<script>
|
74
74
|
const main = async () => {
|
75
75
|
const { DefaultRubyVM } = window["ruby-wasm-wasi"];
|
76
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.
|
76
|
+
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/ruby+stdlib.wasm");
|
77
77
|
const module = await WebAssembly.compileStreaming(response);
|
78
78
|
const { vm } = await DefaultRubyVM(module);
|
79
79
|
|
@@ -128,7 +128,7 @@ end
|
|
128
128
|
|
129
129
|
```html
|
130
130
|
<html>
|
131
|
-
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.
|
131
|
+
<script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/browser.script.iife.js"></script>
|
132
132
|
<script type="text/ruby" data-eval="async">
|
133
133
|
require "js"
|
134
134
|
|
@@ -143,8 +143,8 @@ Or using `@ruby/wasm-wasi` package API `RubyVM#evalAsync`:
|
|
143
143
|
```html
|
144
144
|
<html>
|
145
145
|
<script type="module">
|
146
|
-
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.
|
147
|
-
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.
|
146
|
+
import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.2/dist/browser/+esm";
|
147
|
+
const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/ruby+stdlib.wasm");
|
148
148
|
const module = await WebAssembly.compileStreaming(response);
|
149
149
|
const { vm } = await DefaultRubyVM(module);
|
150
150
|
|
Binary file
|
Binary file
|
Binary file
|
@@ -5,11 +5,12 @@ module RubyWasm
|
|
5
5
|
class CrossRubyExtProduct < BuildProduct
|
6
6
|
attr_reader :name
|
7
7
|
|
8
|
-
def initialize(srcdir, toolchain, ext_relative_path: nil)
|
8
|
+
def initialize(srcdir, toolchain, features:, ext_relative_path: nil)
|
9
9
|
@srcdir, @toolchain = srcdir, toolchain
|
10
10
|
# ext_relative_path is relative path from build dir
|
11
11
|
# e.g. cgi-0.3.6/ext/cgi/escape
|
12
12
|
@ext_relative_path = ext_relative_path || File.basename(srcdir)
|
13
|
+
@features = features
|
13
14
|
@name = @ext_relative_path
|
14
15
|
end
|
15
16
|
|
@@ -37,7 +38,6 @@ module RubyWasm
|
|
37
38
|
make_args << "AR=#{@toolchain.ar}"
|
38
39
|
make_args << "RANLIB=#{@toolchain.ranlib}"
|
39
40
|
|
40
|
-
make_args << "DESTDIR=#{crossruby.dest_dir}"
|
41
41
|
make_args
|
42
42
|
end
|
43
43
|
|
@@ -45,12 +45,15 @@ module RubyWasm
|
|
45
45
|
objdir = product_build_dir crossruby
|
46
46
|
executor.mkdir_p objdir
|
47
47
|
do_extconf executor, crossruby
|
48
|
+
|
49
|
+
executor.system "make", "-C", objdir, *make_args(crossruby), "clean"
|
50
|
+
build_target = crossruby.target.pic? ? "install-so" : "static"
|
48
51
|
executor.system "make",
|
49
52
|
"-j#{executor.process_count}",
|
50
53
|
"-C",
|
51
54
|
"#{objdir}",
|
52
55
|
*make_args(crossruby),
|
53
|
-
|
56
|
+
build_target
|
54
57
|
# A ext can provide link args by link.filelist. It contains only built archive file by default.
|
55
58
|
unless File.exist?(linklist(crossruby))
|
56
59
|
executor.write(
|
@@ -61,9 +64,28 @@ module RubyWasm
|
|
61
64
|
end
|
62
65
|
|
63
66
|
def do_extconf(executor, crossruby)
|
67
|
+
unless crossruby.target.pic?
|
68
|
+
self.do_legacy_extconf(executor, crossruby)
|
69
|
+
return
|
70
|
+
end
|
71
|
+
objdir = product_build_dir crossruby
|
72
|
+
source = crossruby.source
|
73
|
+
rbconfig_rb = Dir.glob(File.join(crossruby.dest_dir, "usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb")).first
|
74
|
+
raise "rbconfig.rb not found" unless rbconfig_rb
|
75
|
+
extconf_args = [
|
76
|
+
"-C", objdir,
|
77
|
+
"#{@srcdir}/extconf.rb",
|
78
|
+
"--target-rbconfig=#{rbconfig_rb}",
|
79
|
+
]
|
80
|
+
extconf_args << "--enable-component-model" if @features.support_component_model?
|
81
|
+
executor.system Gem.ruby, *extconf_args
|
82
|
+
end
|
83
|
+
|
84
|
+
def do_legacy_extconf(executor, crossruby)
|
64
85
|
objdir = product_build_dir crossruby
|
65
86
|
source = crossruby.source
|
66
87
|
extconf_args = [
|
88
|
+
"-C", objdir,
|
67
89
|
"--disable=gems",
|
68
90
|
# HACK: top_srcdir is required to find ruby headers
|
69
91
|
"-e",
|
@@ -71,9 +93,6 @@ module RubyWasm
|
|
71
93
|
# HACK: extout is required to find config.h
|
72
94
|
"-e",
|
73
95
|
%Q($extout="#{crossruby.build_dir}/.ext"),
|
74
|
-
# HACK: skip have_devel check since ruby is not installed yet
|
75
|
-
"-e",
|
76
|
-
"$have_devel = true",
|
77
96
|
# HACK: force static ext build by imitating extmk
|
78
97
|
"-e",
|
79
98
|
"$static = true; trace_var(:$static) {|v| $static = true }",
|
@@ -88,12 +107,13 @@ module RubyWasm
|
|
88
107
|
# like "cgi/escape" instead of "escape"
|
89
108
|
"-e",
|
90
109
|
%Q(require "json"; File.write("#{metadata_json(crossruby)}", JSON.dump({target: $target}))),
|
91
|
-
"-I#{crossruby.build_dir}"
|
110
|
+
"-I#{crossruby.build_dir}",
|
111
|
+
"--",
|
92
112
|
]
|
113
|
+
extconf_args << "--enable-component-model" if @features.support_component_model?
|
93
114
|
# Clear RUBYOPT to avoid loading unrelated bundle setup
|
94
115
|
executor.system crossruby.baseruby_path,
|
95
116
|
*extconf_args,
|
96
|
-
chdir: objdir,
|
97
117
|
env: {
|
98
118
|
"RUBYOPT" => ""
|
99
119
|
}
|
@@ -118,7 +138,7 @@ module RubyWasm
|
|
118
138
|
end
|
119
139
|
|
120
140
|
class CrossRubyProduct < AutoconfProduct
|
121
|
-
attr_reader :source, :toolchain
|
141
|
+
attr_reader :target, :source, :toolchain
|
122
142
|
attr_accessor :user_exts,
|
123
143
|
:wasmoptflags,
|
124
144
|
:cppflags,
|
@@ -155,6 +175,14 @@ module RubyWasm
|
|
155
175
|
executor.system "make", "rbconfig.rb", chdir: build_dir
|
156
176
|
end
|
157
177
|
|
178
|
+
def need_exts_build?
|
179
|
+
@user_exts.any?
|
180
|
+
end
|
181
|
+
|
182
|
+
def need_extinit_obj?
|
183
|
+
need_exts_build? && !@target.pic?
|
184
|
+
end
|
185
|
+
|
158
186
|
def build_exts(executor)
|
159
187
|
@user_exts.each do |prod|
|
160
188
|
executor.begin_section prod.class, prod.name, "Building"
|
@@ -168,6 +196,7 @@ module RubyWasm
|
|
168
196
|
executor.mkdir_p build_dir
|
169
197
|
@toolchain.install
|
170
198
|
[@source, @baseruby, @libyaml, @zlib, @openssl, @wasi_vfs].each do |prod|
|
199
|
+
next unless prod
|
171
200
|
executor.begin_section prod.class, prod.name, "Building"
|
172
201
|
prod.build(executor)
|
173
202
|
executor.end_section prod.class, prod.name
|
@@ -176,17 +205,20 @@ module RubyWasm
|
|
176
205
|
configure(executor, reconfigure: reconfigure)
|
177
206
|
executor.end_section self.class, name
|
178
207
|
|
179
|
-
build_exts(executor)
|
208
|
+
build_exts(executor) if need_exts_build?
|
180
209
|
|
181
210
|
executor.begin_section self.class, name, "Building"
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
211
|
+
|
212
|
+
if need_extinit_obj?
|
213
|
+
executor.mkdir_p File.dirname(extinit_obj)
|
214
|
+
executor.system "ruby",
|
215
|
+
extinit_c_erb,
|
216
|
+
*@user_exts.map { |ext| ext.feature_name(self) },
|
217
|
+
"--cc",
|
218
|
+
toolchain.cc,
|
219
|
+
"--output",
|
220
|
+
extinit_obj
|
221
|
+
end
|
190
222
|
install_dir = File.join(build_dir, "install")
|
191
223
|
if !File.exist?(install_dir) || remake || reconfigure
|
192
224
|
executor.system "make",
|
@@ -216,7 +248,7 @@ module RubyWasm
|
|
216
248
|
end
|
217
249
|
|
218
250
|
def cache_key(digest)
|
219
|
-
|
251
|
+
@params.target.cache_key(digest)
|
220
252
|
digest << @params.default_exts
|
221
253
|
@wasmoptflags.each { |f| digest << f }
|
222
254
|
@cppflags.each { |f| digest << f }
|
@@ -229,11 +261,11 @@ module RubyWasm
|
|
229
261
|
end
|
230
262
|
|
231
263
|
def build_dir
|
232
|
-
File.join(@build_dir, @params.target, name)
|
264
|
+
File.join(@build_dir, @params.target.to_s, name)
|
233
265
|
end
|
234
266
|
|
235
267
|
def ext_build_dir
|
236
|
-
File.join(@build_dir, @params.target, name + "-ext")
|
268
|
+
File.join(@build_dir, @params.target.to_s, name + "-ext")
|
237
269
|
end
|
238
270
|
|
239
271
|
def with_libyaml(libyaml)
|
@@ -274,14 +306,14 @@ module RubyWasm
|
|
274
306
|
end
|
275
307
|
|
276
308
|
def configure_args(build_triple, toolchain)
|
277
|
-
target = @params.target
|
309
|
+
target = @params.target.triple
|
278
310
|
default_exts = @params.default_exts
|
279
311
|
|
280
312
|
ldflags = @ldflags.dup
|
281
313
|
xldflags = @xldflags.dup
|
282
314
|
|
283
315
|
args = self.system_triplet_args + ["--build", build_triple]
|
284
|
-
args << "--with-static-linked-ext"
|
316
|
+
args << "--with-static-linked-ext" unless @params.target.pic?
|
285
317
|
args << %Q(--with-ext=#{default_exts})
|
286
318
|
args << %Q(--with-libyaml-dir=#{@libyaml.install_root})
|
287
319
|
args << %Q(--with-zlib-dir=#{@zlib.install_root})
|
@@ -289,7 +321,7 @@ module RubyWasm
|
|
289
321
|
args << %Q(--with-baseruby=#{baseruby_path})
|
290
322
|
|
291
323
|
case target
|
292
|
-
when
|
324
|
+
when /^wasm32-unknown-wasi/
|
293
325
|
xldflags << @wasi_vfs.lib_wasi_vfs_a if @wasi_vfs
|
294
326
|
# TODO: Find a way to force cast or update API
|
295
327
|
# @type var wasi_sdk_path: untyped
|
@@ -308,8 +340,9 @@ module RubyWasm
|
|
308
340
|
|
309
341
|
args.concat(self.tools_args)
|
310
342
|
(@user_exts || []).each { |lib| xldflags << "@#{lib.linklist(self)}" }
|
311
|
-
xldflags << extinit_obj
|
343
|
+
xldflags << extinit_obj if need_extinit_obj?
|
312
344
|
|
345
|
+
cflags = @cflags.dup
|
313
346
|
xcflags = @xcflags.dup
|
314
347
|
xcflags << "-DWASM_SETJMP_STACK_BUFFER_SIZE=24576"
|
315
348
|
xcflags << "-DWASM_FIBER_STACK_BUFFER_SIZE=24576"
|
@@ -317,6 +350,7 @@ module RubyWasm
|
|
317
350
|
|
318
351
|
args << %Q(LDFLAGS=#{ldflags.join(" ")})
|
319
352
|
args << %Q(XLDFLAGS=#{xldflags.join(" ")})
|
353
|
+
args << %Q(CFLAGS=#{cflags.join(" ")})
|
320
354
|
args << %Q(XCFLAGS=#{xcflags.join(" ")})
|
321
355
|
args << %Q(debugflags=#{@debugflags.join(" ")})
|
322
356
|
args << %Q(cppflags=#{@cppflags.join(" ")})
|
@@ -13,7 +13,7 @@ module RubyWasm
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def product_build_dir
|
16
|
-
File.join(@build_dir, target, "yaml-#{LIBYAML_VERSION}")
|
16
|
+
File.join(@build_dir, target.to_s, "yaml-#{LIBYAML_VERSION}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def destdir
|
@@ -52,12 +52,14 @@ module RubyWasm
|
|
52
52
|
executor.system "curl",
|
53
53
|
"-o",
|
54
54
|
"#{product_build_dir}/config/config.guess",
|
55
|
-
"https://
|
55
|
+
"https://cdn.jsdelivr.net/gh/gcc-mirror/gcc@master/config.guess"
|
56
56
|
executor.system "curl",
|
57
57
|
"-o",
|
58
58
|
"#{product_build_dir}/config/config.sub",
|
59
|
-
"https://
|
59
|
+
"https://cdn.jsdelivr.net/gh/gcc-mirror/gcc@master/config.sub"
|
60
60
|
|
61
|
+
configure_args = self.configure_args.dup
|
62
|
+
configure_args << "CFLAGS=-fPIC" if target.pic?
|
61
63
|
executor.system "./configure", *configure_args, chdir: product_build_dir
|
62
64
|
executor.system "make",
|
63
65
|
"install",
|
@@ -13,7 +13,7 @@ module RubyWasm
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def product_build_dir
|
16
|
-
File.join(@build_dir, target, "openssl-#{OPENSSL_VERSION}")
|
16
|
+
File.join(@build_dir, target.to_s, "openssl-#{OPENSSL_VERSION}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def destdir
|
@@ -42,7 +42,7 @@ module RubyWasm
|
|
42
42
|
--libdir=lib
|
43
43
|
-Wl,--allow-undefined
|
44
44
|
]
|
45
|
-
if @target
|
45
|
+
if @target.triple.start_with?("wasm32-unknown-wasi")
|
46
46
|
args.concat %w[
|
47
47
|
-D_WASI_EMULATED_SIGNAL
|
48
48
|
-D_WASI_EMULATED_PROCESS_CLOCKS
|
@@ -52,6 +52,11 @@ module RubyWasm
|
|
52
52
|
-DHAVE_FORK=0
|
53
53
|
]
|
54
54
|
end
|
55
|
+
|
56
|
+
if @target.pic?
|
57
|
+
args << "-fPIC"
|
58
|
+
end
|
59
|
+
|
55
60
|
args + tools_args
|
56
61
|
end
|
57
62
|
|
@@ -12,13 +12,13 @@ module RubyWasm
|
|
12
12
|
end
|
13
13
|
def system_triplet_args
|
14
14
|
args = []
|
15
|
-
case @target
|
16
|
-
when
|
15
|
+
case @target.triple
|
16
|
+
when /^wasm32-unknown-wasi/
|
17
17
|
args.concat(%W[--host wasm32-wasi])
|
18
18
|
when "wasm32-unknown-emscripten"
|
19
19
|
args.concat(%W[--host wasm32-emscripten])
|
20
20
|
else
|
21
|
-
raise "unknown target: #{@target}"
|
21
|
+
raise "unknown target: #{@target.triple}"
|
22
22
|
end
|
23
23
|
args
|
24
24
|
end
|
@@ -19,7 +19,7 @@ module RubyWasm
|
|
19
19
|
when "tarball"
|
20
20
|
digest << @params[:url]
|
21
21
|
when "local"
|
22
|
-
digest << File.mtime(@params[:
|
22
|
+
digest << File.mtime(@params[:path]).to_i.to_s
|
23
23
|
else
|
24
24
|
raise "unknown source type: #{@params[:type]}"
|
25
25
|
end
|
@@ -75,12 +75,12 @@ module RubyWasm
|
|
75
75
|
)
|
76
76
|
when "local"
|
77
77
|
executor.mkdir_p File.dirname(src_dir)
|
78
|
-
executor.
|
78
|
+
executor.ln_s File.expand_path(@params[:path]), src_dir
|
79
79
|
else
|
80
80
|
raise "unknown source type: #{@params[:type]}"
|
81
81
|
end
|
82
82
|
(@params[:patches] || []).each do |patch_path|
|
83
|
-
executor.system "patch", "-p1", patch_path, chdir: src_dir
|
83
|
+
executor.system "patch", "-p1", "-i", patch_path, chdir: src_dir
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -13,7 +13,7 @@ module RubyWasm
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def product_build_dir
|
16
|
-
File.join(@build_dir, target, "zlib-#{ZLIB_VERSION}")
|
16
|
+
File.join(@build_dir, target.to_s, "zlib-#{ZLIB_VERSION}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def destdir
|
@@ -54,6 +54,8 @@ module RubyWasm
|
|
54
54
|
product_build_dir,
|
55
55
|
"--strip-components=1"
|
56
56
|
|
57
|
+
configure_args = self.configure_args.dup
|
58
|
+
configure_args << "CFLAGS=-fPIC" if target.pic?
|
57
59
|
executor.system "env",
|
58
60
|
*configure_args,
|
59
61
|
"./configure",
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RubyWasm
|
2
|
+
# A build target representation
|
3
|
+
class Target
|
4
|
+
attr_reader :triple
|
5
|
+
|
6
|
+
def initialize(triple, pic: false)
|
7
|
+
@triple = triple
|
8
|
+
@pic = pic
|
9
|
+
end
|
10
|
+
|
11
|
+
def pic?
|
12
|
+
@pic
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
"#{@triple}#{@pic ? "-pic" : ""}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def cache_key(digest)
|
20
|
+
digest << @triple
|
21
|
+
digest << "pic" if @pic
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -4,10 +4,10 @@ module RubyWasm
|
|
4
4
|
|
5
5
|
def initialize(
|
6
6
|
build_dir:,
|
7
|
-
revision: "
|
7
|
+
revision: "v0.24.0"
|
8
8
|
)
|
9
9
|
@build_dir = build_dir
|
10
|
-
@tool_dir = File.join(@build_dir, "toolchain", "wit-bindgen")
|
10
|
+
@tool_dir = File.join(@build_dir, "toolchain", "wit-bindgen-#{revision}")
|
11
11
|
@bin_path = File.join(@tool_dir, "bin", "wit-bindgen")
|
12
12
|
@revision = revision
|
13
13
|
end
|
@@ -18,7 +18,7 @@ module RubyWasm
|
|
18
18
|
|
19
19
|
def self.get(target, build_dir = nil)
|
20
20
|
case target
|
21
|
-
when
|
21
|
+
when /^wasm32-unknown-wasi/
|
22
22
|
return RubyWasm::WASISDK.new(build_dir: build_dir)
|
23
23
|
when "wasm32-unknown-emscripten"
|
24
24
|
return RubyWasm::Emscripten.new
|