gnome-build r478 - in trunk: . src/backends/libgbf_am



Author: jhs
Date: Tue Jan 22 12:49:33 2008
New Revision: 478
URL: http://svn.gnome.org/viewvc/gnome-build?rev=478&view=rev

Log:
2008-01-22  Phillip Kerling <k phillip gmail com>

        reviewed by: Johannes Schmid <jhs gnome org>

        * src/backends/libgbf_am/gbf-am-parse.in:
        Improve gnome-build EXTRA_DIST support (#463408)



Modified:
   trunk/ChangeLog
   trunk/src/backends/libgbf_am/gbf-am-parse.in

Modified: trunk/src/backends/libgbf_am/gbf-am-parse.in
==============================================================================
--- trunk/src/backends/libgbf_am/gbf-am-parse.in	(original)
+++ trunk/src/backends/libgbf_am/gbf-am-parse.in	Tue Jan 22 12:49:33 2008
@@ -369,7 +369,7 @@
 		       java            => \&simple_primary_target_writer,
 		       python          => \&simple_primary_target_writer,
 		       generic_rule    => \&unimplemented_writer,
-		       extra           => \&unimplemented_writer,
+		       extra           => \&simple_extra_dist_target_writer,
 		       configure_generated_file 
 		                       => \&unimplemented_writer,
 		       orbit_idl       => \&unimplemented_writer,
@@ -1697,6 +1697,76 @@
     return 0;
 }
 
+sub hidden_in_another_var {
+	my ($makefile, $macro_name, $file) = @_;
+	
+	my @parts = split (/\s+/, $makefile->{macros}->{$macro_name}->{contents});
+	
+	foreach my $part (@parts) {
+		# FIXME: Are there more characters allowed in macro names than a-zA-Z0-9_?
+		if ($part =~ m/^\$\(([a-zA-Z0-9_]*)\)$/) {
+			my $var = $1;
+			my $content = $makefile->{macros}->{$var}->{contents};
+			my @sub_parts = split (/\s+/, $content);
+			foreach my $sub_part (@sub_parts) {
+				if ($sub_part eq $file) {
+					return $var;
+				}
+			}
+		}
+	}
+	
+	return undef;
+}
+
+sub simple_extra_dist_target_writer
+{
+    my ($project, $group, $op, $target, $operand) = @_;
+    my $makefile = $group->{makefile};
+
+    &debug ("simple extra target writer: $op on group $group with $target($operand)");
+
+	if ($op eq "add_target") {
+		if (exists($makefile->{macros}->{EXTRA_DIST}) and $makefile->{macros}->{EXTRA_DIST}->{content} !~ m/^\s*$/) {
+			return &report_error (305, "An extra target already exists for " . $group->{prefix})
+		}
+	}
+	elsif ($op eq "remove_target") {
+		&macro_remove ($makefile, "EXTRA_DIST");
+	}
+	elsif ($op eq "add_source") {
+		my $rel_source;
+	
+		# Note: we expect the operand to be the absolute to the root of the project
+		# i.e. for group /src/, the operand will be /src/file.c
+		$rel_source = path_absolute_to_relative ($group->{prefix}, $operand);
+	
+		&debug ("adding $rel_source to EXTRA_DIST");
+		# Note: we expect the uri to be relative to the group
+		&macro_append_text ($makefile, "EXTRA_DIST", $rel_source);
+    }
+    elsif ($op eq "remove_source") {
+		my $rel_source;
+	
+		# Note: we expect the operand to be the absolute to the root of the project
+		# i.e. for group /src/, the operand will be /src/file.c
+		$rel_source = path_absolute_to_relative ($group->{prefix}, $operand);
+	
+		if (defined(my $original_pkg = hidden_in_another_var($makefile, "EXTRA_DIST", $rel_source))) {
+			return &report_error (305, "Could not remove file because it is part of group '$original_pkg'. Please delete it there.");
+		}
+			
+		&debug ("removing $rel_source from EXTRA_DIST");
+		# Note: we expect the uri to be relative to the group
+		&macro_remove_text ($makefile, "EXTRA_DIST", $rel_source);
+    }
+    else {
+		return &report_error (300, "Invalid operation '$op' to program_target_writer");
+    };
+
+    # Success!
+    return 0;
+}
 
 sub simple_primary_target_writer
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]