diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-02-19 22:29:28 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-02-19 22:29:28 +0100 |
| commit | da00fef086b63d1c01641fec5f42718eeb7b7dd1 (patch) | |
| tree | 4a5ab1a7076102939ecb2192bb9ccd237087aaff /booster.pl | |
| parent | d276b2d3af6aefae8d13a9b3b841ceb56f49f0ec (diff) | |
feat: add booster.pl for fix.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'booster.pl')
| -rwxr-xr-x | booster.pl | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/booster.pl b/booster.pl new file mode 100755 index 0000000..e7d9b04 --- /dev/null +++ b/booster.pl @@ -0,0 +1,68 @@ +#!/usr/bin/perl -w + +use strict; +use File::Path qw(make_path); +use File::Basename; +use Getopt::Long; + +if (@ARGV == 0) { + exit 0; +} + +my @files; + +for my $path (@ARGV) { + if (-f $path) { + push @files, $path; + } elsif (-d $path) { + find_files($path, \@files); + } else { + warn "Skipping '$path': not a file or directory\n"; + } +} + +make_path("boostified/include/boost/fix"); + +for my $file (@files) { + process_file($file); +} + +sub find_files { + my ($dir, $list) = @_; + opendir(my $dh, $dir) or die "Cannot open directory $dir: $!\n"; + while (my $entry = readdir($dh)) { + next if $entry eq '.' || $entry eq '..'; + my $full = "$dir/$entry"; + if (-d $full) { + find_files($full, $list); + } elsif (-f $full && $full =~ /\.(cpp|inl|hpp|h|cc|hh|cxx|hxx)$/i) { + push @$list, [ $entry, $full, dirname($full) ]; + } + } + closedir($dh); +} + +sub process_file { + my $info = shift; + my ($name, $fullpath, $srcdir) = @$info; + + open(my $fh, '<', $fullpath) or die "Cannot read $fullpath: $!\n"; + my $content = do { local $/; <$fh> }; + close($fh); + + my $original = $content; + + $content =~ s/\bocl::/boost::/g; + $content =~ s/\bocl\//boost\//g; + $content =~ s/\bOCL_/BOOST_/g; + + if ($content ne $original) { + my $reldir = substr($srcdir, length($ARGV[0]) + 1); + my $outdir = "boostified/include/boost/$reldir"; + make_path($outdir) unless -d $outdir; + + open(my $out, '>', "$outdir/$name") or die "Cannot write $outdir/$name: $!\n"; + print $out $content; + close($out); + } +} |
