@@ -31,6 +31,7 @@ def self.add_gem_patches(patch_hash, gem_patches)
31
31
end
32
32
processed_patch [ :patches ] = patch
33
33
processed_patch [ :gem ] = gem
34
+ processed_patch [ :non_standard_dir_structure ] = gem_patches [ :non_standard_dir_structure ]
34
35
raise "Duplicate patch file #{ key } ." if patch_hash . include? ( key )
35
36
patch_hash [ key ] = processed_patch
36
37
end
@@ -46,7 +47,11 @@ def self.makefile_matcher(command1, command2)
46
47
file_list = Hash . new { |h , k | h [ k ] = [ ] }
47
48
PATCHED_FILES . each_pair do |file , patch |
48
49
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
50
55
else
51
56
"/#{ patch [ :gem ] } "
52
57
end
@@ -87,7 +92,11 @@ def self.makefile_matcher(command1, command2)
87
92
def self . patch ( file , contents , directory )
88
93
if patched_file = PATCHED_FILES [ File . basename ( file ) ]
89
94
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
91
100
else
92
101
regexp = /^#{ Regexp . escape ( patched_file [ :gem ] ) } \b /
93
102
directory . split ( '/' ) . last ( 3 ) . any? { |part | part =~ regexp } || file . split ( '/' ) . last ( 2 ) . any? { |part | part =~ regexp }
0 commit comments