Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 16 beta 5 compatibility #568

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ DerivedData

# Test output
report.llcov
report.json
report.json

# VSCode
.vscode
.rdbgrc*
36 changes: 25 additions & 11 deletions lib/slather/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,26 @@ def profdata_coverage_files

def pathnames_per_binary(binary_path)
coverage_json_string = llvm_cov_export_output(binary_path)
coverage_json = JSON.parse(coverage_json_string)
coverage_json["data"].reduce([]) do |result, chunk|
result.concat(chunk["files"].map do |file|
filename = file["filename"]
path = Pathname(filename)
# Don't crash if the file doesn't exist on disk.
# This may happen for autogenerated files that have been deleted.
filename = path.exist? ? path.realpath : filename
{"filename" => filename, "segments" => file["segments"]}
end)
if coverage_json_string.strip != ""
# JSON.parse will crash on an empty string, so just skip everything if the string is empty.
coverage_json = JSON.parse(coverage_json_string)
coverage_json["data"].reduce([]) do |result, chunk|
result.concat(chunk["files"].map do |file|
filename = file["filename"]
path = Pathname(filename)
# Don't crash if the file doesn't exist on disk.
# This may happen for autogenerated files that have been deleted.
filename = path.exist? ? path.realpath : filename
{"filename" => filename, "segments" => file["segments"]}
end)
end
end
end
private :pathnames_per_binary

def create_coverage_files_for_binary(binary_path, pathnames_per_binary)
return [] unless pathnames_per_binary != nil

coverage_files = []

begin
Expand Down Expand Up @@ -482,7 +487,16 @@ def decimal_f decimal_arg
def find_binary_file_in_bundle(bundle_file)
if File.directory? bundle_file
bundle_file_noext = File.basename(bundle_file, File.extname(bundle_file))
Dir["#{bundle_file}/**/#{bundle_file_noext}"].first

# Search for .debug.dylib binaries
# See https://developer.apple.com/documentation/xcode/build-settings-reference#Enable-Debug-Dylib-Support for details
debug_dylib_matches = Dir["#{bundle_file}/**/#{bundle_file_noext}.debug.dylib"]

if debug_dylib_matches.length() > 0
debug_dylib_matches.first
else
Dir["#{bundle_file}/**/#{bundle_file_noext}"].first
end
else
bundle_file
end
Expand Down