#!/bin/ruby

basic_filter = "orangepi_test"

def make_raw_list ( filter )
    cmd = "locate *.o | grep #{filter} | grep -v built-in"
    #puts cmd
    #system cmd
    return `#{cmd}`
end

def process ( f )
    n = f.sub /o$/, "c"
    if FileTest.exists? n
        return n
    end
    n = f.sub /o$/, "s"
    if FileTest.exists? n
        return n
    end
    n = f.sub /o$/, "S"
    if FileTest.exists? n
        return n
    end
    return "???  " + f
end

data = make_raw_list basic_filter

data.split.each { |l|
    next if l =~ /standalone/
    next if l =~ /orangepi_test\/spl/
    next if l =~ /orangepi_test\/tools/
    next if l =~ /orangepi_test\/test/
    next if l =~ /orangepi_test\/scripts/
    x = process l.chomp
    x.sub!(/^.*orangepi_test/, ".")
    puts x
}

# THE END
