automake-patches
[Top][All Lists]
Advanced

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

[PATCH 2/4] Compute dependencies from assembly references


From: Raja R Harinath
Subject: [PATCH 2/4] Compute dependencies from assembly references
Date: Thu, 28 Jun 2007 18:43:17 +0530

* automake.in (handle_cli_assembly): Return true on success.
(handle_cli_assembly_references): New.
(handle_cli): Call it.
* tests/cli2.test: Add test for dependency calculation.
* tests/Makefile.am (TESTS): Update.
---
 ChangeLog         |    7 +++++
 automake.in       |   65 +++++++++++++++++++++++++++++++++++++++++++++++++---
 tests/Makefile.am |    1 +
 tests/cli2.test   |   41 +++++++++++++++++++++++++++++++++
 4 files changed, 110 insertions(+), 4 deletions(-)
 create mode 100755 tests/cli2.test

diff --git a/ChangeLog b/ChangeLog
index b246d80..ec49428 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2007-06-27  Raja R Harinath  <address@hidden>
 
+       Compute dependencies from assembly references
+       * automake.in (handle_cli_assembly): Return true on success.
+       (handle_cli_assembly_references): New.
+       (handle_cli): Call it.
+       * tests/cli2.test: Add test for dependency calculation.
+       * tests/Makefile.am (TESTS): Update.
+
        Add basic support for Mono/.NET
        * automake.in (register_language): Add 'cli'.
        (handle_cli, handle_cli_assembly, lang_cli_rewrite): New.
diff --git a/automake.in b/automake.in
index de33217..9bf8b43 100755
--- a/automake.in
+++ b/automake.in
@@ -4686,7 +4686,6 @@ sub handle_java
 sub handle_cli_assembly ($$$%)
 {
   my ($one_file, $unxformed, $where, %transform) = @_;
-  my $compiler = '';
   my @cmdsrcs = ();
   my $seen_extn = 0;
 
@@ -4736,8 +4735,11 @@ sub handle_cli_assembly ($$$%)
         });
     }
 
-  msg 'error', $where, "`$unxformed' doesn't have any source defined"
-    unless scalar @cmdsrcs;
+  if (scalar @cmdsrcs == 0)
+    {
+      msg 'error', $where, "`$unxformed' doesn't have any source defined";
+      return 0;
+    }
 
   define_pretty_variable ($one_file . '_CMDSRCS', TRUE, $where, sort @cmdsrcs);
 
@@ -4756,6 +4758,53 @@ sub handle_cli_assembly ($$$%)
                   XASSEMBLY => $one_file,
                   LANG => $lang,
                   DIRSTAMP => $dirstamp);
+
+  return 1;
+}
+
+sub handle_cli_assembly_references(\%)
+{
+  my ($known_assemblies) = @_;
+  my ($unxformed, $where);
+  while (($unxformed, $where) = each %$known_assemblies)
+    {
+      my $one_file = &canonicalize ($unxformed);
+      my $var = var $one_file . '_REFERENCES';
+
+      next unless $var;
+
+      $var->transform_variable_recursively
+       ($one_file . '_DEPENDENCIES', 'am__DEPENDENCIES', 0, INTERNAL,
+        sub {
+          my ($subvar, $val, $cond, $full_cond) = @_;
+          if ($val =~ /^-r(eference)?:(.*\.dll)$/)
+            {
+              $val = $2;
+            }
+          elsif ($val =~ /^-addmodule:(.*\.netmodule)$/)
+            {
+              $val = $1;
+            }
+          else
+            {
+              return ();
+            }
+
+          # if it's a bare file name, only add it as a dependency if we know 
we're building it.
+          # So -r:System.Web.dll won't create a dependency on System.Web.dll.
+          if ($val eq basename $val)
+            {
+              return $val
+                if exists $known_assemblies->{$val};
+            }
+          else
+            {
+              return $val
+                unless File::Spec->file_name_is_absolute ($val);
+            }
+          return ();
+        });
+    }
 }
 
 # Handle Mono/.NET
@@ -4763,6 +4812,9 @@ sub handle_cli
 {
   my %targets = ( EXE => 'exe', WINEXE => 'winexe', DLL => 'library', MODULE 
=> 'module' );
   my %outextns = ( EXE => '.exe', WINEXE => '.exe', DLL => '.dll', MODULE => 
'.netmodule' );
+
+  my %known_assemblies = ();
+
   foreach my $target (keys %targets)
     {
       my @assemblies = &am_install_var ('cli', 'CLI' . $target . 'S',
@@ -4786,9 +4838,14 @@ sub handle_cli
          $where->push_context ("while processing CLI assembly '$one_file'");
          $where->set (INTERNAL->get);
 
-         &handle_cli_assembly ($xname, $one_file, $where, TARGET => 
$targets{$target});
+         if (&handle_cli_assembly ($xname, $one_file, $where, TARGET => 
$targets{$target}))
+           {
+             $known_assemblies{$one_file} = $where;
+           }
        }
     }
+
+  handle_cli_assembly_references %known_assemblies;
 }
 
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f5af67f..8708b10 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -92,6 +92,7 @@ checkall.test \
 clean.test \
 clean2.test \
 cli1.test \
+cli2.test \
 colneq.test \
 colneq2.test \
 colon.test \
diff --git a/tests/cli2.test b/tests/cli2.test
new file mode 100755
index 0000000..5d8ecb6
--- /dev/null
+++ b/tests/cli2.test
@@ -0,0 +1,41 @@
+#! /bin/sh
+# Copyright (C) 2002, 2003, 2006  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test that basic CLI functionality works.
+
+. ./defs || exit 1
+
+set -e
+
+cat >Makefile.am <<END
+CSC = mcs
+VBC = vbnc
+noinst_CLIEXES = foo.exe
+noinst_CLIDLLS = foo.dll
+foo_exe_SOURCES = a.cs
+foo_dll_SOURCES = b.cs
+foo_exe_REFERENCES = -r:foo.dll -r:System.Web.dll
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+grep 'foo_exe_DEPENDENCIES =.*System.Web.dll' Makefile.in && exit 1
+grep 'foo_exe_DEPENDENCIES =.*foo.dll' Makefile.in
-- 
1.5.2.1.174.gcd03





reply via email to

[Prev in Thread] Current Thread [Next in Thread]