ruby_wasm 2.7.1-aarch64-linux → 2.8.1-aarch64-linux

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.
data/lib/ruby_wasm/cli.rb CHANGED
@@ -181,12 +181,12 @@ module RubyWasm
181
181
  private
182
182
 
183
183
  def build_config(options)
184
- build_source, all_default_exts = compute_build_source(options)
185
184
  # @type var config: Packager::build_config
186
- config = { target: options[:target_triplet], src: build_source }
185
+ config = compute_build_alias(options)
186
+ config[:target] = options[:target_triplet]
187
187
  case options[:profile]
188
188
  when "full"
189
- config[:default_exts] = all_default_exts || ""
189
+ config[:default_exts] = config[:all_default_exts] || ""
190
190
  env_additional_exts = ENV["RUBY_WASM_ADDITIONAL_EXTS"] || ""
191
191
  unless env_additional_exts.empty?
192
192
  config[:default_exts] += "," + env_additional_exts
@@ -201,24 +201,32 @@ module RubyWasm
201
201
  config
202
202
  end
203
203
 
204
- def compute_build_source(options)
204
+ def compute_build_alias(options)
205
205
  src_name = options[:ruby_version]
206
- aliases = self.class.build_source_aliases(root)
207
- source = aliases[src_name]
208
- if source.nil?
206
+ aliases = self.class.build_config_aliases(root)
207
+ config = aliases[src_name]
208
+ if config.nil?
209
209
  if File.directory?(src_name)
210
210
  # Treat as a local source if the given name is a source directory.
211
211
  RubyWasm.logger.debug "Using local source: #{src_name}"
212
212
  if options[:patches].any?
213
213
  RubyWasm.logger.warn "Patches specified through --patch are ignored for local sources"
214
214
  end
215
- # @type var local_source: RubyWasm::Packager::build_source_local
216
- local_source = { type: "local", path: src_name }
217
- # @type var local_source: RubyWasm::Packager::build_source
218
- local_source = local_source.merge(name: "local", patches: [])
219
215
  # FIXME: We should have a way to specify extensions to be included by users.
220
216
  # For now, assume all default extensions available in the head revision are available.
221
- return [local_source, RubyWasm::Packager::ALL_DEFAULT_EXTS]
217
+ # @type var patches: Array[String]
218
+ patches = []
219
+ return(
220
+ {
221
+ name: "local",
222
+ src: {
223
+ type: "local",
224
+ path: src_name,
225
+ patches: patches
226
+ },
227
+ all_default_exts: RubyWasm::Packager::ALL_DEFAULT_EXTS
228
+ }
229
+ )
222
230
  end
223
231
  # Otherwise, it's an unknown source.
224
232
  raise(
@@ -226,64 +234,100 @@ module RubyWasm
226
234
  )
227
235
  end
228
236
  # Apply user-specified patches in addition to bundled patches.
229
- source[:patches].concat(options[:patches])
230
- # @type var all_default_exts: String
231
- __skip__ = all_default_exts = source[:all_default_exts]
232
- [source, all_default_exts]
237
+ config[:src][:patches].concat(options[:patches])
238
+ config
233
239
  end
234
240
 
235
241
  # Retrieves the alias definitions for the Ruby sources.
236
- def self.build_source_aliases(root)
237
- # @type var sources: Hash[string, RubyWasm::Packager::build_source]
238
- sources = {
239
- "head" => {
240
- type: "github",
241
- repo: "ruby/ruby",
242
- rev: "master",
242
+ def self.build_config_aliases(root)
243
+ # @type var aliases: Array[RubyWasm::Packager::build_source]
244
+ aliases = [
245
+ {
246
+ name: "head",
247
+ src: {
248
+ type: "github",
249
+ repo: "ruby/ruby",
250
+ rev: "master"
251
+ },
243
252
  all_default_exts: RubyWasm::Packager::ALL_DEFAULT_EXTS,
253
+ wasi_sdk_version: "24.0"
254
+ },
255
+ {
256
+ name: "4.0",
257
+ src: {
258
+ type: "tarball",
259
+ url: "https://cache.ruby-lang.org/pub/ruby/4.0/ruby-4.0.0.tar.gz"
260
+ },
261
+ all_default_exts:
262
+ "cgi/escape,continuation,coverage,date,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,json,json/generator,json/parser,objspace,pathname,psych,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
263
+ wasi_sdk_version: "24.0"
244
264
  },
245
- "3.4" => {
246
- type: "tarball",
247
- url: "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.1.tar.gz",
248
- all_default_exts: "cgi/escape,continuation,coverage,date,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,json,json/generator,json/parser,objspace,pathname,psych,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
265
+ {
266
+ name: "3.4",
267
+ src: {
268
+ type: "tarball",
269
+ url: "https://cache.ruby-lang.org/pub/ruby/3.4/ruby-3.4.1.tar.gz"
270
+ },
271
+ all_default_exts:
272
+ "cgi/escape,continuation,coverage,date,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,json,json/generator,json/parser,objspace,pathname,psych,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
273
+ wasi_sdk_version: "22.0"
249
274
  },
250
- "3.3" => {
251
- type: "tarball",
252
- url: "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.3.tar.gz",
253
- all_default_exts: "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
275
+ {
276
+ name: "3.3",
277
+ src: {
278
+ type: "tarball",
279
+ url: "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.3.tar.gz"
280
+ },
281
+ all_default_exts:
282
+ "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
283
+ wasi_sdk_version: "22.0"
254
284
  },
255
- "3.2" => {
256
- type: "tarball",
257
- url: "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.4.tar.gz",
258
- all_default_exts: "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
285
+ {
286
+ name: "3.2",
287
+ src: {
288
+ type: "tarball",
289
+ url: "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.4.tar.gz"
290
+ },
291
+ all_default_exts:
292
+ "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
293
+ wasi_sdk_version: "22.0"
259
294
  }
260
- }
295
+ ]
296
+
297
+ # Set the name in the source config.
298
+ aliases.each { |config| config[:src][:name] = config[:name] }
261
299
 
262
300
  # Apply bundled and user-specified `<root>/patches` directories.
263
- sources.each do |name, source|
264
- source[:name] = name
301
+ aliases.each do |config|
265
302
  patches_dirs = [bundled_patches_path, File.join(root, "patches")]
266
- source[:patches] = patches_dirs.flat_map do |patches_dir|
267
- Dir[File.join(patches_dir, name, "*.patch")]
268
- .map { |p| File.expand_path(p) }
269
- end
303
+ config[:src][:patches] = patches_dirs
304
+ .flat_map do |patches_dir|
305
+ Dir[File.join(patches_dir, config[:name], "*.patch")].map do |p|
306
+ File.expand_path(p)
307
+ end
308
+ end
309
+ .uniq
270
310
  end
271
311
 
312
+ aliases_by_name = aliases.to_h { |config| [config[:name], config] }
313
+
314
+ # Pin the revisions based on build_manifest.json if available.
272
315
  build_manifest = File.join(root, "build_manifest.json")
273
316
  if File.exist?(build_manifest)
274
317
  begin
275
318
  manifest = JSON.parse(File.read(build_manifest))
276
319
  manifest["ruby_revisions"].each do |name, rev|
277
- source = sources[name]
320
+ source = aliases_by_name[name][:src]
278
321
  next unless source[:type] == "github"
279
322
  # @type var source: RubyWasm::Packager::build_source_github
280
323
  source[:rev] = rev
281
324
  end
282
325
  rescue StandardError => e
283
326
  RubyWasm.logger.warn "Failed to load build_manifest.json: #{e}"
327
+ raise e
284
328
  end
285
329
  end
286
- sources
330
+ aliases_by_name
287
331
  end
288
332
 
289
333
  # Retrieves the root directory of the Ruby project.
@@ -1,10 +1,8 @@
1
1
  module RubyWasm::Packager::ComponentAdapter
2
- module_function
3
-
4
2
  # The path to the component adapter for the given WASI execution model.
5
3
  #
6
4
  # @param exec_model [String] "command" or "reactor"
7
- def wasi_snapshot_preview1(exec_model)
5
+ def self.wasi_snapshot_preview1(exec_model)
8
6
  File.join(
9
7
  File.dirname(__FILE__),
10
8
  "component_adapter",
@@ -179,7 +179,7 @@ class RubyWasm::Packager::Core
179
179
  end
180
180
 
181
181
  def _build_gem_exts(executor, build, gem_home)
182
- build.toolchain.install
182
+ build.toolchain.install(executor)
183
183
  baseruby = build.baseruby
184
184
  unless Dir.exist?(baseruby.install_dir)
185
185
  baseruby.build(executor)
@@ -111,7 +111,7 @@ class RubyWasm::Packager
111
111
  options = build_options
112
112
  build_dir = File.join(@root, "build")
113
113
  rubies_dir = File.join(@root, "rubies")
114
- toolchain = RubyWasm::Toolchain.get(options[:target], build_dir)
114
+ toolchain = RubyWasm::Toolchain.get(options[:target], options, build_dir)
115
115
  options.merge(
116
116
  toolchain: toolchain,
117
117
  build_dir: build_dir,
@@ -1,3 +1,3 @@
1
1
  module RubyWasm
2
- VERSION = "2.7.1"
2
+ VERSION = "2.8.1"
3
3
  end