@@ -191,7 +191,7 @@ def compute_build_source(options)
191
191
"Unknown Ruby source: #{ src_name } (available: #{ aliases . keys . join ( ", " ) } or a local directory)"
192
192
)
193
193
end
194
- # Apply user-specified patches in addition to <root>/ patches.
194
+ # Apply user-specified patches in addition to bundled patches.
195
195
source [ :patches ] . concat ( options [ :patches ] )
196
196
source
197
197
end
@@ -214,11 +214,15 @@ def self.build_source_aliases(root)
214
214
url : "https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.3.tar.gz"
215
215
}
216
216
}
217
+
218
+ # Apply bundled and user-specified `<root>/patches` directories.
217
219
sources . each do |name , source |
218
220
source [ :name ] = name
219
- patches = Dir [ File . join ( root , "patches" , name , "*.patch" ) ]
220
- . map { |p | File . expand_path ( p ) }
221
- source [ :patches ] = patches
221
+ patches_dirs = [ bundled_patches_path , File . join ( root , "patches" ) ]
222
+ source [ :patches ] = patches_dirs . flat_map do |patches_dir |
223
+ Dir [ File . join ( patches_dir , name , "*.patch" ) ]
224
+ . map { |p | File . expand_path ( p ) }
225
+ end
222
226
end
223
227
224
228
build_manifest = File . join ( root , "build_manifest.json" )
@@ -255,12 +259,20 @@ def root
255
259
end
256
260
end
257
261
262
+ # Path to the directory containing the bundled patches, which is shipped
263
+ # as part of ruby_wasm gem to backport fixes or try experimental features
264
+ # before landing them to the ruby/ruby repository.
265
+ def self . bundled_patches_path
266
+ lib_source_root = File . join ( __dir__ , ".." , ".." )
267
+ File . join ( lib_source_root , "patches" )
268
+ end
269
+
258
270
def derive_packager ( options )
259
271
__skip__ =
260
272
if defined? ( Bundler ) && !options [ :disable_gems ]
261
273
definition = Bundler . definition
262
274
end
263
- RubyWasm ::Packager . new ( build_config ( options ) , definition )
275
+ RubyWasm ::Packager . new ( root , build_config ( options ) , definition )
264
276
end
265
277
266
278
def do_print_ruby_cache_key ( packager )
0 commit comments