diff options
author | Vishal Gupta <vishalgupta7972@gmail.com> | 2018-07-12 20:52:23 +0530 |
---|---|---|
committer | Vishal Gupta <vishalgupta7972@gmail.com> | 2018-07-12 20:52:23 +0530 |
commit | cbbc12007c82265f0802f1e85711e3a0c82cb2bc (patch) | |
tree | dd6bc43cd422a2343d04eba0f3a74a406c327f49 | |
parent | af9641edc78265d69a488869a59bc2c38c00d792 (diff) | |
download | automake-cbbc12007c82265f0802f1e85711e3a0c82cb2bc.tar.gz |
Subdirs implementation
Added support to recursively call parser.pl on the directories defined in
SUBDIRS variable.
Added test case.
-rw-r--r-- | lib/Automake/Parser/Tree.pm | 23 | ||||
-rw-r--r-- | lib/Automake/Parser/input.txt | 28 | ||||
-rw-r--r-- | lib/Automake/Parser/parser.pl | 1 | ||||
-rw-r--r-- | lib/Automake/Parser/t/app/Makefile.am | 1 | ||||
-rw-r--r-- | lib/Automake/Parser/t/app1/Makefile.am | 1 | ||||
-rw-r--r-- | lib/Automake/Parser/t/app2/Makefile.am | 1 | ||||
-rw-r--r-- | lib/Automake/Parser/t/nestedcond.txt | 20 | ||||
-rw-r--r-- | lib/Automake/Parser/t/subdirs.txt | 2 |
8 files changed, 40 insertions, 37 deletions
diff --git a/lib/Automake/Parser/Tree.pm b/lib/Automake/Parser/Tree.pm index a997db8f4..abb44ff99 100644 --- a/lib/Automake/Parser/Tree.pm +++ b/lib/Automake/Parser/Tree.pm @@ -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 diff --git a/lib/Automake/Parser/input.txt b/lib/Automake/Parser/input.txt index 9324ebbca..618da5261 100644 --- a/lib/Automake/Parser/input.txt +++ b/lib/Automake/Parser/input.txt @@ -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 diff --git a/lib/Automake/Parser/parser.pl b/lib/Automake/Parser/parser.pl index 993445004..d631a9a66 100644 --- a/lib/Automake/Parser/parser.pl +++ b/lib/Automake/Parser/parser.pl @@ -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 index 000000000..1566cc4be --- /dev/null +++ b/lib/Automake/Parser/t/app/Makefile.am @@ -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 index 000000000..1566cc4be --- /dev/null +++ b/lib/Automake/Parser/t/app1/Makefile.am @@ -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 index 000000000..1566cc4be --- /dev/null +++ b/lib/Automake/Parser/t/app2/Makefile.am @@ -0,0 +1 @@ +bin_PROGRAMS=apple
\ No newline at end of file diff --git a/lib/Automake/Parser/t/nestedcond.txt b/lib/Automake/Parser/t/nestedcond.txt index b7141a5e6..3eee1f850 100644 --- a/lib/Automake/Parser/t/nestedcond.txt +++ b/lib/Automake/Parser/t/nestedcond.txt @@ -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 index 000000000..e94b9b6bd --- /dev/null +++ b/lib/Automake/Parser/t/subdirs.txt @@ -0,0 +1,2 @@ +SUBDIRS = app app1 +SUBDIRS += app2 |