]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Subdirs implementation
authorVishal Gupta <vishalgupta7972@gmail.com>
Thu, 12 Jul 2018 15:22:23 +0000 (20:52 +0530)
committerVishal Gupta <vishalgupta7972@gmail.com>
Thu, 12 Jul 2018 15:22:23 +0000 (20:52 +0530)
Added support to recursively call parser.pl on the directories defined in
SUBDIRS variable.
Added test case.

lib/Automake/Parser/Tree.pm
lib/Automake/Parser/input.txt
lib/Automake/Parser/parser.pl
lib/Automake/Parser/t/app/Makefile.am [new file with mode: 0644]
lib/Automake/Parser/t/app1/Makefile.am [new file with mode: 0644]
lib/Automake/Parser/t/app2/Makefile.am [new file with mode: 0644]
lib/Automake/Parser/t/nestedcond.txt
lib/Automake/Parser/t/subdirs.txt [new file with mode: 0644]

index a997db8f419a187885a375fa58a20c577e8c3a9e..abb44ff992ad537144bce69b58a403ef306b5967 100644 (file)
@@ -5,7 +5,7 @@ use Exporter;
 our @ISA = qw(Exporter);
 our @EXPORT = qw(input stmts stmt automakerule makerule conditional ifblock 
 optionalelse optionalcond optionalrhs optionalcomments lhs rhs commentlist primaries 
-optionlist traverse printgraph);
+optionlist traverse printgraph recursesubdirs);
 
 my $isSubdir = 0 , @subdirnodes = ();
 
@@ -15,7 +15,7 @@ sub input($)
 {
        my ( $val ) = @_;
        my %node = ( name => input, childs => [ $val ] );
-       push @{$node -> {childs}}, subdirNode() if $#subdirnodes > -1;
+       push @{$node{childs}}, subdirNode() if $#subdirnodes > -1;
        return \%node;
 }
 
@@ -343,4 +343,23 @@ sub traverse($$)
                }
        }
 }
+
+# Recurse into sub directories to generate AST 
+sub recursesubdirs($)
+{
+       my ($ref) = @_;
+       my %node= %$ref;
+       if( scalar @{ $node{childs} } == 2)
+       {
+               my $subdirRef = $node{childs} -> [1];
+               my %subdirNode = %$subdirRef;
+               foreach $val ( @{ $subdirNode{subdirs} } )
+               {
+                       system( "perl -I. Parser.pl $val/Makefile.am > $val/ast.gv" );
+                       system( "unflatten -f -l 10 -c 10 -o $val/ast1.gv $val/ast.gv" );
+                       system( "dot -Tpng $val/ast1.gv > $val/ast.png" );
+                       system( "rm $val/ast.gv $val/ast1.gv" );
+               }
+       }
+}
 1;
\ No newline at end of file
index 9324ebbca349b350d87b793fb06b2e105cd89aad..618da52619d1bbf1e3da0b08a3a8ee1ac0076e0f 100644 (file)
@@ -1,25 +1,3 @@
-# Process this file with automake to produce Makefile.in
-dist_bin_PROGRAMS = server \
-client
-server_SOURCES = server.c db.c   ## Server Files \
-Database Files  
-#Comment Testing Here
-#a
-#b
-#c
-#END
-
-SUBDIRS = app app1
-SUBDIRS += app2
-
-client_SOURCES =  #Multiline comment \
-Client dependencies
-if installed
-noinst_LIBRARIES = foolib.b
-else
-noinst_LIBRARIES = 
-endif
-noinst_LTLIBRARIES = foolib.a
-files_JAVA = a.java b.java
-files_PYTHON = chk.py app.py test.py
-test_SCRIPTS = t1.sh t2.sh
+bin_PROGRAMS = server client
+server_SOURCES = server.c
+client_SOURCES = client.c
index 99344500429680c3137c3bd1253f9a1be96e469c..d631a9a66019aa7350d48329ebf6ea64136266a5 100644 (file)
@@ -22,6 +22,7 @@ while ( @stack )
        {
                print STDERR "Complete\n";
                printgraph( $stack[-4] );
+               recursesubdirs( $stack[-4] );
                last;
        }
        while( !@tokens )
diff --git a/lib/Automake/Parser/t/app/Makefile.am b/lib/Automake/Parser/t/app/Makefile.am
new file mode 100644 (file)
index 0000000..1566cc4
--- /dev/null
@@ -0,0 +1 @@
+bin_PROGRAMS=apple
\ No newline at end of file
diff --git a/lib/Automake/Parser/t/app1/Makefile.am b/lib/Automake/Parser/t/app1/Makefile.am
new file mode 100644 (file)
index 0000000..1566cc4
--- /dev/null
@@ -0,0 +1 @@
+bin_PROGRAMS=apple
\ No newline at end of file
diff --git a/lib/Automake/Parser/t/app2/Makefile.am b/lib/Automake/Parser/t/app2/Makefile.am
new file mode 100644 (file)
index 0000000..1566cc4
--- /dev/null
@@ -0,0 +1 @@
+bin_PROGRAMS=apple
\ No newline at end of file
index b7141a5e680cb3c8e2aa519c42c635ad150117e5..3eee1f850b3b4cdbc3230134b5b644e922debd70 100644 (file)
@@ -1,20 +1,20 @@
-SUBDIRS = a
+VAR = a
 if CASE_A
-SUBDIRS += b
+VAR += b
 endif
-SUBDIRS += c
+VAR += c
 if CASE_A
-SUBDIRS += d
+VAR += d
 if CASE_B
-SUBDIRS += e
+VAR += e
 endif
-SUBDIRS += f
+VAR += f
 endif
-SUBDIRS += g
+VAR += g
 if CASE_B
-SUBDIRS += h
+VAR += h
 endif
 if CASE_B
-SUBDIRS += iXYZ
-SUBDIRS += jZYX
+VAR += iXYZ
+VAR += jZYX
 endif
diff --git a/lib/Automake/Parser/t/subdirs.txt b/lib/Automake/Parser/t/subdirs.txt
new file mode 100644 (file)
index 0000000..e94b9b6
--- /dev/null
@@ -0,0 +1,2 @@
+SUBDIRS = app app1
+SUBDIRS += app2