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

Do not erase but update compilation database. #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/xcpretty/reporters/json_compilation_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ def format_compile_command(compiler_command, file_path)
end

def write_report
if File.exist?(@filepath)
begin
json = JSON.parse(File.read(@filepath))
rescue JSON::ParserError
# drop the current database if it is not valid.
json = []
end
json.each do |c|
found = @compilation_units.detect do |u|
u[:file] == c["file"] && u[:directory] == c["directory"]
end
unless found
@compilation_units << {command: c["command"],
file: c["file"],
directory: c["directory"]}
end
end
end
File.open(@filepath, 'w') do |f|
f.write(@compilation_units.to_json)
end
Expand Down