cvsuser 04/09/08 05:42:51
Modified: config/init data.pl
config/init/hints solaris.pl
Log:
[perl #31424] [RESOLVED] PATCH: Fix for parrot linking issue on Solaris 8
Attached is a patch that should fix the solaris link issues without
breaking every other platform, hopefully. ;)
This adds support for setting triggers on specific config variables.
The basic idea is that you can register a named callback for any
specific config variable. When that variable is set, all the
callbacks registrered for that variable will be called to notify them
that the new setting is available. I added subs in
config/init/data.pl to for adding triggers, getting them and deleting
them.
I also fixed the solaris hints file to use the new trigger code. It
sets a trigger on 'gcc_version' and when that gets set later on in the
config, if it's defined, then the link command will be set to 'g++'.
Courtesy of Clayton O'Neill <[EMAIL PROTECTED]>
Revision Changes Path
1.33 +67 -1 parrot/config/init/data.pl
Index: data.pl
===================================================================
RCS file: /cvs/public/parrot/config/init/data.pl,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- data.pl 8 Sep 2004 05:25:13 -0000 1.32
+++ data.pl 8 Sep 2004 12:42:49 -0000 1.33
@@ -1,6 +1,6 @@
#! perl -w
# Copyright: 2001-2003 The Perl Foundation. All Rights Reserved.
-# $Id: data.pl,v 1.32 2004/09/08 05:25:13 sfink Exp $
+# $Id: data.pl,v 1.33 2004/09/08 12:42:49 leo Exp $
=head1 NAME
@@ -143,6 +143,9 @@
ncilib_link_extra => '', # Extra flags needed for libnci.so
);
+
+ my (%triggers);
+
# add profiling if needed
# FIXME gcc syntax
# we should have this in the hints files e.g. cc_profile
@@ -177,6 +180,12 @@
print "\t$key => ", defined($val) ? "'$val'" : 'undef', ",\n"
if ($verbose);
$c{$key}=$val;
+ if (defined $triggers{$key}) {
+ while (my ($trigger, $cb) = each %{$triggers{$key}}) {
+ print "\tcalling trigger $trigger for $key\n" if $verbose;
+ &$cb($key, $val);
+ }
+ }
}
print ");\n" if ($verbose);
};
@@ -239,6 +248,63 @@
*clean=sub {
delete $c{$_} for grep { /^TEMP_/ } keys %c;
};
+
+=item Configure::Data->settrigger($key, $trigger, $cb)
+
+Set a callback on C<$key> named C<$trigger>. Multiple triggers can be
+set on a given key. When the key is set via C<set> or C<add> then all
+callbacks that are defined will be called. Triggers are passed the
+key and value that was set after it has been changed.
+
+=cut
+
+ *settrigger=sub {
+ my ($self, $var, $trigger, $cb) = @_;
+ if (defined $cb) {
+ if (defined $verbose and $verbose == 2) {
+ print "Setting trigger $trigger on configuration key $var\n";
+ }
+ $triggers{$var}{$trigger} = $cb;
+ }
+ };
+
+=item Configure::Data->gettriggers($key)
+
+Get the names of all triggers set for C<$key>.
+
+=cut
+
+ *gettriggers=sub {
+ my ($self, $key) = @_;
+ return keys %{$triggers{$key}};
+ };
+
+=item Configure::Data->gettrigger($key, $trigger)
+
+Get the callback set for C<$key> under the name C<$trigger>
+
+=cut
+
+ *gettrigger=sub {
+ my ($self, $key, $t) = @_;
+ return undef if !defined $triggers{$key} or !defined $triggers{$key}{$t};
+ $triggers{$key}{$t};
+ };
+
+=item Configure::Data->deltrigger($key, $trigger)
+
+Removes the trigger on C<$key> named by C<$trigger>
+
+=cut
+
+ *deltrigger=sub {
+ my ($self, $var, $t) = @_;
+ return if !defined $triggers{$var} or !defined $triggers{$var}{$t};
+ delete $triggers{$var}{$t};
+ if (defined $verbose and $verbose == 2) {
+ print "Removing trigger $t on configuration key $var\n";
+ }
+ };
}
=back
1.4 +18 -10 parrot/config/init/hints/solaris.pl
Index: solaris.pl
===================================================================
RCS file: /cvs/public/parrot/config/init/hints/solaris.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- solaris.pl 2 Sep 2004 00:49:32 -0000 1.3
+++ solaris.pl 8 Sep 2004 12:42:51 -0000 1.4
@@ -9,14 +9,22 @@
libs => $libs,
);
-# my $cc = Configure::Data->get('cc');
my $link = Configure::Data->get('link');
-if (Configure::Data->get('gccversion')) {
- Configure::Data->set('link', 'c++');
-} else {
# Going to assume Sun's compiler
# In which case we need to link with the C++ compiler (CC) rather than the
# C compiler (cc)
$link =~ s/\bcc\b/CC/;
Configure::Data->set('link', $link);
+
+# if it turns out we're using gcc, then we need to make sure we're linking
+# with g++, not gcc. We can't make this decision until later, because the
+# gcc test hasn't been run yet.
+my $solaris_cb = sub {
+ my ($key, $gccversion) = @_;
+ if ($gccversion) {
+ Configure::Data->set('link', 'g++');
+ Configure::Data->deltrigger("gccversion", "solaris_hints");
}
+};
+
+Configure::Data->settrigger("gccversion", "solaris_hints", $solaris_cb);