#!/usr/bin/env ruby

result = 0
files = Dir.glob("src/**/*.h") + Dir.glob("src/**/*.cpp") \
      + Dir.glob("lib/**/*.h") + Dir.glob("lib/**/*.cpp") \
      + Dir.glob("plugins/**/*.h") + Dir.glob("plugins/**/*.cpp")

puts 'Checking licenses...'
files.each { |name|
    File.open(name) { |file|
        if file.grep(/SPDX-License-Identifier/).empty? then
            puts "Missing or incorrect license header: #{name}"
            result += 1
        end
    }
}

exit result