File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed
Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 5050 bin/setup
5151 - name : Check C code formatting
5252 run : |
53+ clang-format --version
5354 bundle exec rake templates
54- bundle exec rake format:c_check
55+ bundle exec rake format:c_verbose || (echo "Run 'rake format:c' locally to fix these issues" && exit 1)
Original file line number Diff line number Diff line change @@ -119,6 +119,47 @@ namespace :format do
119119 puts "✅ All files are properly formatted"
120120 end
121121 end
122+
123+ desc "Verbose check of C source files formatting with diff output"
124+ task :c_verbose do
125+ puts "Checking C file formatting (verbose)..."
126+
127+ # Check if clang-format is installed
128+ unless system ( "which clang-format > /dev/null 2>&1" )
129+ abort "Error: clang-format not found. Please install clang-format first."
130+ end
131+
132+ if files . empty?
133+ puts "No C files found to check"
134+ next
135+ end
136+
137+ puts "Found #{ files . length } files to check (excluding generated files)"
138+
139+ needs_format = false
140+ files . each do |file |
141+ formatted = `clang-format -style=file #{ file } `
142+ original = File . read ( file )
143+
144+ if formatted != original
145+ puts "❌ #{ file } needs formatting"
146+ puts "Diff:"
147+ # Save formatted version to temp file and run diff
148+ temp_file = "#{ file } .formatted"
149+ File . write ( temp_file , formatted )
150+ system ( "diff -u #{ file } #{ temp_file } " )
151+ File . unlink ( temp_file )
152+ needs_format = true
153+ end
154+ end
155+
156+ if needs_format
157+ warn "Some files need formatting. Run 'rake format:c' to format them."
158+ exit 1
159+ else
160+ puts "✅ All files are properly formatted"
161+ end
162+ end
122163end
123164
124165rule ".c" => ".re" do |t |
You can’t perform that action at this time.
0 commit comments