@@ -334,6 +334,7 @@ def check_cpuid_instruction(formula)
334
334
"No `cpuid` instruction detected. #{ formula } should not use `ENV.runtime_cpu_detection`."
335
335
end
336
336
337
+ sig { params ( formula : Formula ) . returns ( T . nilable ( String ) ) }
337
338
def check_binary_arches ( formula )
338
339
return unless formula . prefix . directory?
339
340
@@ -347,19 +348,31 @@ def check_binary_arches(formula)
347
348
348
349
compatible_universal_binaries , mismatches = mismatches . partition do |file , arch |
349
350
arch == :universal && file . archs . include? ( Hardware ::CPU . arch )
350
- end . map ( &:to_h ) # To prevent transformation into nested arrays
351
+ end
352
+ # To prevent transformation into nested arrays
353
+ compatible_universal_binaries = compatible_universal_binaries . to_h
354
+ mismatches = mismatches . to_h
351
355
352
- universal_binaries_expected = if formula . tap . present? && formula . tap . core_tap?
353
- formula . tap . audit_exception ( :universal_binary_allowlist , formula . name )
356
+ universal_binaries_expected = if ( formula_tap = formula . tap ) . present? && formula_tap . core_tap?
357
+ formula_tap . audit_exception ( :universal_binary_allowlist , formula . name )
354
358
else
355
359
true
356
360
end
357
- return if T . must ( mismatches ) . empty? && universal_binaries_expected
358
361
359
- mismatches_expected = formula . tap . blank? ||
360
- formula . tap . audit_exception ( :mismatched_binary_allowlist , formula . name )
361
- return if T . must ( compatible_universal_binaries ) . empty? && mismatches_expected
362
+ mismatches_expected = ( formula_tap = formula . tap ) . blank? ||
363
+ formula_tap . audit_exception ( :mismatched_binary_allowlist , formula . name )
364
+ mismatches_expected = [ mismatches_expected ] if mismatches_expected . is_a? ( String )
365
+ if mismatches_expected . is_a? ( Array )
366
+ glob_flags = File ::FNM_DOTMATCH | File ::FNM_EXTGLOB | File ::FNM_PATHNAME
367
+ mismatches . delete_if do |file , _arch |
368
+ mismatches_expected . any? { |pattern | file . fnmatch? ( "#{ formula . prefix . realpath } /#{ pattern } " , glob_flags ) }
369
+ end
370
+ mismatches_expected = false
371
+ return if mismatches . empty? && compatible_universal_binaries . empty?
372
+ end
362
373
374
+ return if mismatches . empty? && universal_binaries_expected
375
+ return if compatible_universal_binaries . empty? && mismatches_expected
363
376
return if universal_binaries_expected && mismatches_expected
364
377
365
378
s = ""
0 commit comments