7
my @fileTypes = ("cpp", "c");
13
my $x = $dirFiles{$dir};
23
my $dir = $File::Find::dir;
24
# Record if a CMake file was found.
25
if ($file eq "CMakeLists.txt") {
26
$dirCMake{$dir} = $File::Find::name;
29
# Grab the extension of the file.
30
$file =~ /\.([^.]+)$/;
33
foreach my $x (@fileTypes) {
35
if (!defined $files) {
36
$files = GetFiles($dir);
47
my $files = $dirFiles{$dir};
49
if (!defined $files) {
53
foreach my $file (sort @$files) {
61
my $cmakeList = shift;
63
my $cmakeListNew = $cmakeList . ".new";
65
open(OUT, ">", $cmakeListNew);
71
if (/^add_clang_library\(/ || /^add_llvm_library\(/ || /^add_llvm_target\(/
72
|| /^add_executable\(/) {
88
open(FILE, $cmakeList) or
89
die("Cannot open $cmakeList when computing digest\n");
91
my $digestA = Digest::MD5->new->addfile(*FILE)->hexdigest;
94
open(FILE, $cmakeListNew) or
95
die("Cannot open $cmakeListNew when computing digest\n");
97
my $digestB = Digest::MD5->new->addfile(*FILE)->hexdigest;
100
if ($digestA ne $digestB) {
101
move($cmakeListNew, $cmakeList);
105
unlink($cmakeListNew);
109
sub UpdateCMakeFiles {
110
foreach my $dir (sort keys %dirCMake) {
111
if (UpdateCMake($dirCMake{$dir}, $dir)) {
112
print "Updated: $dir\n";
117
find({ wanted => \&ProcessFile, follow => 1 }, '.');