Skip to content

Commit 96daf01

Browse files
aardvark179eregon
authored andcommitted
Small change to patching code to avoid false matches.
1 parent 24a7be1 commit 96daf01

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/truffle/truffle/cext_preprocessor.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def self.add_gem_patches(patch_hash, gem_patches)
3131
end
3232
processed_patch[:patches] = patch
3333
processed_patch[:gem] = gem
34+
processed_patch[:non_standard_dir_structure] = gem_patches[:non_standard_dir_structure]
3435
raise "Duplicate patch file #{key}." if patch_hash.include?(key)
3536
patch_hash[key] = processed_patch
3637
end
@@ -46,7 +47,11 @@ def self.makefile_matcher(command1, command2)
4647
file_list = Hash.new { |h,k| h[k] = [] }
4748
PATCHED_FILES.each_pair do |file, patch|
4849
dir = if patch[:ext_dir]
49-
File.join('ext', patch[:ext_dir])
50+
if patch[:non_standard_dir_structure]
51+
File.join('ext', patch[:ext_dir])
52+
else
53+
File.join(patch[:gem], 'ext', patch[:ext_dir])
54+
end
5055
else
5156
"/#{patch[:gem]}"
5257
end
@@ -87,7 +92,11 @@ def self.makefile_matcher(command1, command2)
8792
def self.patch(file, contents, directory)
8893
if patched_file = PATCHED_FILES[File.basename(file)]
8994
matched = if patched_file[:ext_dir]
90-
directory.end_with?('ext', patched_file[:ext_dir])
95+
if patched_file[:non_standard_dir_structure]
96+
directory.end_with?('ext', patched_file[:ext_dir])
97+
else
98+
directory.end_with?(File.join(patched_file[:gem], 'ext', patched_file[:ext_dir]))
99+
end
91100
else
92101
regexp = /^#{Regexp.escape(patched_file[:gem])}\b/
93102
directory.split('/').last(3).any? { |part| part =~ regexp } || file.split('/').last(2).any? { |part| part =~ regexp }

lib/truffle/truffle/patches/tk_patches.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class TkPatches
1111

1212
PATCHES = {
1313
gem: 'tk',
14+
non_standard_dir_structure: true,
1415
patches: {
1516
['tk/tkutil', 'tkutil.c'] => [
1617
{

0 commit comments

Comments
 (0)