colorgcc patch
Ryan Niebur
ryanryan52 at gmail.com
Thu Nov 5 23:57:13 GMT 2009
On Thu, Nov 05, 2009 at 04:28:12PM +0100, Mario Schwalbe wrote:
> Hi,
>
> I'm using colorgcc 1.3.2 (Ubuntu package version 1.3.2.0-10).
>
> While I generally like this tool, I think 2 issues are somewhat
> annoying.
>
please make bug report(s), I don't handle these things over email.
> (1) One has to define all different kinds of compiler binaries
> (cpp, gcc, cc, c++, g++, ...) of all versions (3.3, 3.4, 4.0, ...)
> explicitly in its configuration file. I know the 'gccVersion'
> option, but it isn't of much use if using several different
> versions at once.
> (2) colorgcc silently defaults to a default binary (/usr/bin/gcc, ...),
> which is the standard version on a platform, if nothing else
> is configured.
>
> This took me several hours of searching, because I silently compiled
> using the wrong compiler, that was already known to break builds.
>
> So why doesn't colorgcc just search the compiler binary itself,
> skipping those that are again symlinks to itself? This way one doesn't
> have to configure the paths in colorgcc anymore and can fully rely on
> the usual environment variables and build systems.
>
> The attached patch tries to accomplish that and also lets the script die,
> if it doesn't find a compiler.
>
> ciao,
> Mario
>
> --
> Wo das Chaos auf die Ordnung trifft, gewinnt meist das Chaos,
> weil es besser organisiert ist.
> - Friedrich Nietzsche -
>
> --
> _____ ________
> / \ / ____/ Mario Schwalbe
> / \ / \ \____ \
> / Y \/ \ eMail: schwalbe at inf.tu-dresden.de,
> \____|__ /______ / s4700588 at inf.tu-dresden.de
> \/ \/
>
> key ID: 7DA9 DAFF
> key fingerprint: 2979 AA20 4A93 B527 90CC 45E5 4B28 511A 7DA9 DAFF
> --- /usr/bin/colorgcc 2009-04-29 09:55:55.000000000 +0200
> +++ local/scripts/colorgcc 2009-11-05 16:11:16.965312475 +0100
> @@ -177,6 +177,32 @@ sub loadPreferences
> }
> }
>
> +sub searchCompiler($$)
> +{
> +# Usage: searchCompiler($progName, $realName)
> +# $progName -- the compiler to look for without any path
> +# $realName -- the scripts' real name after following any symlinks
> +
> + my ($progName, $realName) = @_;
> +
> + foreach my $dir (split ':', $ENV{'PATH'})
> + {
> + my $compiler = $dir."/".$progName;
> + next unless (-l $compiler) || (-f $compiler);
> +
> + if (defined (my $target = readlink $compiler)) {
> + # a link, but not to ourselves: use it
> + return $compiler if $target ne $realName;
> + }
> + else {
> + # not a link: use it
> + return $compiler;
> + }
> + }
> +
> + return undef;
> +}
> +
> sub srcscan
> {
> # Usage: srcscan($text, $normalColor)
> @@ -221,7 +247,15 @@ if (-f $configFile)
> $0 =~ m%.*/(.*)$%;
> $progName = $1 || $0;
>
> -$compiler = $compilerPaths{$progName} || $compilerPaths{"gcc"};
> +# Figure out which is our real script name. Might be an absolute path
> +# depending on the symlink.
> +$realName = readlink $0;
> +
> +# Maybe it's better to not use $compilerPaths{"gcc"} as default if the search
> +# yields nothing and output an error message instead.
> +$compiler = $compilerPaths{$progName} || searchCompiler($progName, $realName);
> +die "$realName: no compiler found that provides '$progName'\n" unless defined $compiler;
> +
> @comp_list = split /\s+/, $compiler;
> $compiler = $comp_list[0];
> @comp_args = ( @comp_list[1 .. $#comp_list], @ARGV );
> @@ -274,7 +308,7 @@ while(<GCCOUT>)
> print($colors{"warningNumberColor"}, "$field2:", color("reset"));
> srcscan($field3, $colors{"warningMessageColor"});
> }
> - else
> + else
> {
> # Error
> print($colors{"errorFileNameColor"}, "$field1:", color("reset"));
> @@ -329,7 +363,3 @@ while(<GCCOUT>)
> waitpid($compiler_pid, 0);
> exit ($? >> 8);
>
> -
> -
> -
> -
--
_________________________
Ryan Niebur
ryanryan52 at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/ubuntu-motu/attachments/20091105/0c6f63cb/attachment.pgp
More information about the Ubuntu-motu
mailing list