Hi,

I'd like to propose a small patch for colorgcc.
Although i like the new version that allows to add localizations,
it silently broke my build system. Because right now, it uses the name
it is called with to map to a particular executable. Calling colorgcc
as g++-3.3 thus whould map to /usr/bin/g++, which is version 4.2.

I know there's a 'gccVersion' configuration option, but i think it's
impractical to always change the configuration to switch the compiler
version. I also know that's possible to add additional mappings like:
g++-4.2: /usr/bin/g++-4.2

However, it's very annoying to add those line for all binaries and all
version. I think colorgcc should evaluate to the right version automatically.

The attached patch adds this functionality by removing the version if no
exact match was found, looks up the compiler path, and re-appends the version.

thanks & ciao,
Mario

-- 
 Wo das Chaos auf die Ordnung trifft, gewinnt meist das Chaos,
 weil es besser organisiert ist.
     - Friedrich Nietzsche -

--
    _____    ________
   /     \  /   ____/  Mario Schwalbe
  /  \ /  \ \____  \
 /    Y    \/       \  eMail: [email protected],
 \____|__  /______  /         [email protected]
         \/       \/

          key ID: 7DA9 DAFF
      public key: https://www1.inf.tu-dresden.de/~ms790178/key.asc
 key fingerprint: 2979 AA20 4A93 B527 90CC  45E5 4B28 511A 7DA9 DAFF
--- /usr/bin/colorgcc	2008-05-06 10:58:40.000000000 +0200
+++ local/scripts/colorgcc	2008-11-13 23:27:51.000000000 +0100
@@ -97,6 +97,7 @@ sub initDefaults
    $compilerPaths{"g++"} = "/usr/bin/g++";
    $compilerPaths{"cc"}  = "/usr/bin/gcc";
    $compilerPaths{"c++"} = "/usr/bin/g++";
+   $compilerPaths{"cpp"} = "/usr/bin/cpp";
    $compilerPaths{"g77"} = "/usr/bin/g77";
    $compilerPaths{"f77"} = "/usr/bin/g77";
    $compilerPaths{"gcj"} = "/usr/bin/gcj";
@@ -172,7 +173,8 @@ sub loadPreferences
    close(PREFS);
 
    # Append "-<gccVersion>" to user-defined compilerPaths
-   if ($overrideCompilerPaths && $gccVersion) {
+   if ($overrideCompilerPaths && $gccVersion)
+   {
       $compilerPaths{$_} .= "-$gccVersion" foreach (keys %compilerPaths);
    }
 }
@@ -221,7 +223,31 @@ if (-f $configFile)
 $0 =~ m%.*/(.*)$%;
 $progName = $1 || $0;
 
-$compiler = $compilerPaths{$progName} || $compilerPaths{"gcc"};
+# use exact match if found
+if (exists $compilerPaths{$progName})
+{
+   $compiler = $compilerPaths{$progName};
+}
+# otherwise strip version from key and (re)append to value
+elsif ($progName =~ m/(.*)-(.*)/)
+{
+   if (exists $compilerPaths{$1})
+   {
+      my ($comp, @rest) = split /\s+/, $compilerPaths{$1};
+      $compiler = "$comp-$2 @rest";
+   }
+   # if there is still no entry, use default
+   else
+   {
+      $compiler = $compilerPaths{"gcc"};
+   }
+}
+# if there is no version appended, use default
+else
+{
+   $compiler = $compilerPaths{"gcc"};
+}
+
 @comp_list = split /\s+/, $compiler;
 $compiler = $comp_list[0];
 @comp_args = ( @comp_list[1 .. $#comp_list], @ARGV );
@@ -327,7 +353,3 @@ while(<GCCOUT>)
 waitpid($compiler_pid, 0);
 exit ($? >> 8);
 
-
-
-
-

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
Ubuntu-motu mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-motu

Reply via email to