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\(/) {
87 open(FILE
, $cmakeList) or
88 die("Cannot open $cmakeList when computing digest\n");
90 my $digestA = Digest
::MD5
->new->addfile(*FILE
)->hexdigest;
93 open(FILE
, $cmakeListNew) or
94 die("Cannot open $cmakeListNew when computing digest\n");
96 my $digestB = Digest
::MD5
->new->addfile(*FILE
)->hexdigest;
99 if ($digestA ne $digestB) {
100 move
($cmakeListNew, $cmakeList);
104 unlink($cmakeListNew);
108 sub UpdateCMakeFiles
{
109 foreach my $dir (sort keys %dirCMake) {
110 if (UpdateCMake
($dirCMake{$dir}, $dir)) {
111 print "Updated: $dir\n";
116 find
({ wanted
=> \
&ProcessFile
, follow
=> 1 }, '.');