Radix cross Linux Toolchains

Toolchains for all supported by Radix cross Linux devices

65 Commits   2 Branches   12 Tags
     5         kx #!/usr/bin/perl
     5         kx 
     5         kx use FindBin;
     5         kx use lib $FindBin::Bin;
     5         kx 
     5         kx use strict;
     5         kx use warnings FATAL => 'all';
     5         kx 
     5         kx use File::Basename;
     5         kx use File::Temp;
     5         kx use _kxLab;
     5         kx 
     5         kx # Global variables
     5         kx my $header_printed = 0;
     5         kx 
     5         kx my $cleanup = $ENV{DO_CREATE_DIST_FILES} ? 0 : 1;
     5         kx my ($tempfd, $tempname) = File::Temp::tempfile(".dist.XXXXXX", UNLINK => $cleanup);
     5         kx 
     5         kx # cleanpath( path )
     5         kx sub cleanpath
     5         kx {
     5         kx   my $path = shift;
     5         kx   $path =~ s!/{2,}!/!g;
     5         kx   return $path;
     5         kx }
     5         kx 
     5         kx # dist( file )
     5         kx sub dist
     5         kx {
     5         kx   my $file = cleanpath(shift);
     5         kx   $file =~ s!^.*dist/!!;
     5         kx   print $tempfd "$file\n";
     5         kx }
     5         kx 
     5         kx # newer_than( file1, file2 )
     5         kx sub newer_than
     5         kx {
     5         kx   my $file1 = shift;
     5         kx   my $file2 = shift;
     5         kx   _kxLab::error( "install_targets: Source file missing: $file1" ) if ( ! -f $file1 );
     5         kx   return( ! -f $file2 or -M $file1 < -M $file2 );
     5         kx }
     5         kx 
     5         kx # install_tree( install_dir, file, target, verbose )
     5         kx sub install_tree
     5         kx {
     5         kx   my $install_dir = cleanpath(shift);
     5         kx   my $file = shift;
     5         kx   my $target = shift;
     5         kx   my $verbose = shift;
     5         kx 
     5         kx   opendir(DIR, "$target");
     5         kx   my @files = readdir(DIR);
     5         kx   closedir DIR;
     5         kx   foreach my $f ( @files )
     5         kx   {
     5         kx     next if ($f eq "." or $f eq "..");
     5         kx     if( -d "$target/$f" )
     5         kx     {
     5         kx       install_tree( "$install_dir/$f", "$file/$f", "$target/$f", $verbose );
     5         kx     }
     5         kx     elsif( newer_than( "$target/$f", "$install_dir/$f" ) )
     5         kx     {
     5         kx       if( !$header_printed )
     5         kx       {
     5         kx         print "\n======= Installing files =======\n";
     5         kx         $header_printed = 1;
     5         kx       }
     5         kx       print "Installing $f in $install_dir\n" if ( $verbose );
     5         kx       _kxLab::system( "mkdir -p $install_dir" );
     5         kx       _kxLab::system( "cp -fa $target/$f $install_dir" );
     5         kx       dist( "$install_dir/$f" );
     5         kx     }
     5         kx   }
     5         kx }
     5         kx 
     5         kx # install( install_dir, preserve_source_dir, verbose, targets )
     5         kx sub install
     5         kx {
     5         kx   my $install_dir = cleanpath(shift);
     5         kx   my $preserve_source_dir = shift;
     5         kx   my $verbose = shift;
     5         kx   my $targets = shift;
     5         kx 
     5         kx   foreach my $target ( @{$targets} )
     5         kx   {
     5         kx     my $file = basename($target);
     5         kx     my $path = "";
     5         kx     if( $preserve_source_dir eq "true" )
     5         kx     {
     5         kx       $path = dirname( $target );
     5         kx     }
     5         kx 
     5         kx     if( -d $target )
     5         kx     {
     5         kx       install_tree( "$install_dir/$path/$file", "$file", "$target", $verbose );
     5         kx     }
     5         kx     elsif( newer_than( $target, "$install_dir/$path/$file" ) )
     5         kx     {
     5         kx       if( !$header_printed )
     5         kx       {
     5         kx         print "\n======= Installing files =======\n";
     5         kx         $header_printed = 1;
     5         kx       }
     5         kx       print "Installing $file in $install_dir/$path\n" if ( $verbose );
     5         kx       _kxLab::system( "mkdir -p $install_dir/$path" );
     5         kx       _kxLab::system( "cp -fa $target $install_dir/$path" );
     5         kx       dist( "$install_dir/$path/$file" );
     5         kx     }
     5         kx   }
     5         kx }
     5         kx 
     5         kx my $preserve_source_dir = "";
     5         kx my $dest_dir;
     5         kx my @targets;
     5         kx my $verbose = $ENV{VERBOSE};
     5         kx 
     5         kx foreach ( @ARGV )
     5         kx {
     5         kx   if( /--preserve-source-dir=(\S*)/ )
     5         kx   {
     5         kx     $preserve_source_dir = $1;
     5         kx   }
     5         kx   else
     5         kx   {
     5         kx     push @targets, $_;
     5         kx   }
     5         kx }
     5         kx $dest_dir = pop @targets;
     5         kx 
     5         kx install( $dest_dir, $preserve_source_dir, $verbose, \@targets );