Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

119 lines
2.2 KiB
Perl
Executable File

#!/usr/bin/env perl
use strict;
use File::Find;
use File::Copy;
use Digest::MD5;
my @fileTypes = ("cpp", "c");
my %dirFiles;
my %dirCMake;
sub GetFiles {
my $dir = shift;
my $x = $dirFiles{$dir};
if (!defined $x) {
$x = [];
$dirFiles{$dir} = $x;
}
return $x;
}
sub ProcessFile {
my $file = $_;
my $dir = $File::Find::dir;
# Record if a CMake file was found.
if ($file eq "CMakeLists.txt") {
$dirCMake{$dir} = $File::Find::name;
return 0;
}
# Grab the extension of the file.
$file =~ /\.([^.]+)$/;
my $ext = $1;
my $files;
foreach my $x (@fileTypes) {
if ($ext eq $x) {
if (!defined $files) {
$files = GetFiles($dir);
}
push @$files, $file;
return 0;
}
}
return 0;
}
sub EmitCMakeList {
my $dir = shift;
my $files = $dirFiles{$dir};
if (!defined $files) {
return;
}
foreach my $file (sort @$files) {
print OUT " ";
print OUT $file;
print OUT "\n";
}
}
sub UpdateCMake {
my $cmakeList = shift;
my $dir = shift;
my $cmakeListNew = $cmakeList . ".new";
open(IN, $cmakeList);
open(OUT, ">", $cmakeListNew);
my $foundLibrary = 0;
while(<IN>) {
if (!$foundLibrary) {
print OUT $_;
if (/^add_[^_]+_library\(/ || /^add_llvm_target\(/ || /^add_[^_]+_executable\(/) {
$foundLibrary = 1;
EmitCMakeList($dir);
}
}
else {
if (/\)/) {
print OUT $_;
$foundLibrary = 0;
}
}
}
close(IN);
close(OUT);
open(FILE, $cmakeList) or
die("Cannot open $cmakeList when computing digest\n");
binmode FILE;
my $digestA = Digest::MD5->new->addfile(*FILE)->hexdigest;
close(FILE);
open(FILE, $cmakeListNew) or
die("Cannot open $cmakeListNew when computing digest\n");
binmode FILE;
my $digestB = Digest::MD5->new->addfile(*FILE)->hexdigest;
close(FILE);
if ($digestA ne $digestB) {
move($cmakeListNew, $cmakeList);
return 1;
}
unlink($cmakeListNew);
return 0;
}
sub UpdateCMakeFiles {
foreach my $dir (sort keys %dirCMake) {
if (UpdateCMake($dirCMake{$dir}, $dir)) {
print "Updated: $dir\n";
}
}
}
find({ wanted => \&ProcessFile, follow => 1 }, '.');
UpdateCMakeFiles();