Fantastic. I did not know to do this. A quick little script:
use strict;
use warnings;
# This script is intended to change the extension on compiler librarie
+s from .lib (MSVC standard) to .a (GNU standard).
# It does this by grabbing the environment variables U3_DEVICE_PATH an
+d LIB.
# U3_DEVICE_PATH is used to exclude paths to libraries that aren't on
+the U3 Compiler-onna-stick
# LIB is used to provide a list of paths to scan for the libraries to
+be checked.
my $debug = 0;
my $u3_drive = $ENV{'U3_DEVICE_PATH'} or die "HALT: U3_DEVICE_PATH is
+not set or null ($!)\n";
my @lib_paths = split ";", $ENV{'LIB'} or die "HALT: LIB not set or nu
+ll ($!)\n";
if ($debug){
print "U3_DEVICE_PATH is $u3_drive\n";
print "$_ is a LIB path\n" for (@lib_paths);
}
for my $lib_dir (@lib_paths){
-d $lib_dir or die "HALT: $_ not found ($!)\n";
unless ($lib_dir =~ /^$u3_drive/){
print "$lib_dir is not on $u3_drive, skipped.\n" if $debug;
next;
}
print "$lib_dir is on $u3_drive processing...\n" if $debug;
opendir THEDIR, $lib_dir or die "HALT: Can't open $lib_dir ($!)\n"
+;
my @lib_files = readdir THEDIR or die "HALT: Can't read $lib_dir (
+$!)\n";
close THEDIR;
for my $lib_file (@lib_files){
unless($lib_file =~ /\.lib$|\.dll\.a$/i){
print "$lib_file does not end with .lib or .dll.a, skippin
+g.\n" if $debug;
next;
}
my $old_file = $lib_dir."\\".$lib_file;
my $new_file = $old_file;
$new_file =~ s/\.lib$|\.dll\.lib$|\.dll\.a$/.a/i;
print "Renaming $old_file to $new_file\n";
rename $old_file, $new_file or die "HALT: Could not rename $ne
+w_file ($!)\n";
}
}
...and that's done.
Update The code now handles files ending in .dll.lib and renames them to .a as well...(and files that have been misnamed .dll.a, oh and properly escapes the .)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|