From knarf at cct.lsu.edu Tue Feb 2 12:34:35 2010 From: knarf at cct.lsu.edu (Frank Loeffler) Date: Tue, 2 Feb 2010 12:34:35 -0600 Subject: [Patches] deep arrangments Message-ID: <20100202183435.GX18541@numrel07.cct.lsu.edu> Hi, this patch adds Cactus support for deep arrangements. This means that thorns can be located deeper in the directory tree than Cactus/arrangements/THORN, e.g. Cactus/arrangements/carpet/Carpet/CarpetLib This allows to checkout git/mercurial repositories directly into Cactus/arrangements without any symlinks. Frank -------------- next part -------------- ? make/autom4te.cache Index: make/new_thorn.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/make/new_thorn.pl,v retrieving revision 1.23 diff -u -r1.23 new_thorn.pl --- make/new_thorn.pl 26 Jan 2010 15:06:19 -0000 1.23 +++ make/new_thorn.pl 2 Feb 2010 18:31:57 -0000 @@ -1,4 +1,5 @@ #!/usr/bin/perl -s +use File::Path qw(make_path); #/*@@ # @file new_thorn.pl # @date Wed Feb 3 16:28:43 1999 @@ -33,7 +34,7 @@ print "$package\n"; } print "Pick one, or create a new one.\n"; - while (&TestName(0,$package)==0) + while (&TestName(0,$package,"/")==0) { $package = &prompt("arrangement"); } @@ -53,7 +54,7 @@ { print "Creating new arrangement $package\n"; - mkdir($package, 0755); + make_path($package, { mode => 0755 }); } @@ -280,11 +281,17 @@ sub TestName { - local($thorn,$name) = @_; + local($thorn,$name,$extra_chars) = @_; local($valid); $valid = 1; + if (!defined($extra_chars)) + { + $extra_chars = ""; + } + $extra_chars = quotemeta($extra_chars); + if (!$name) { $valid = 0; @@ -294,7 +301,7 @@ print STDERR "Name must begin with a letter!\n\n"; $valid = 0; } - elsif ($name !~ /^[a-zA-Z0-9_]*$/) + elsif ($name !~ /^[a-zA-Z${extra_chars}0-9_]*$/) { print STDERR "Name can only contain letters, numbers or underscores!\n\n"; $valid = 0; Index: sbin/CST =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/CST,v retrieving revision 1.81 diff -u -r1.81 CST --- sbin/CST 11 Sep 2009 22:15:48 -0000 1.81 +++ sbin/CST 2 Feb 2010 18:31:57 -0000 @@ -140,7 +140,7 @@ # Create header files of compiled thorns for the code ($thornsheader, $definethornsheader, $definethisthornheader) = -&CreateThornsHeaders(%source_thorns); +&CreateThornsHeaders($cctk_home, %source_thorns); &WriteFile("$bindings_dir/include/thornlist.h", \$thornsheader); &WriteFile("$bindings_dir/include/cctk_DefineThorn.h", \$definethornsheader); &WriteFile("$bindings_dir/include/definethisthorn.h", \$definethisthornheader); @@ -152,7 +152,7 @@ &CreateLogFile($config_dir, $configuration_database,\%thorns); # Finally (must be last), create the make.thornlist file. -$make_thornlist = &CreateMakeThornlist(\%thorns, \%interface_database, $configuration_database); +$make_thornlist = &CreateMakeThornlist($cctk_home, \%thorns, \%interface_database, $configuration_database); # Stop the make process if there were any errors if ($CST_errors) @@ -223,7 +223,7 @@ foreach $thorn (split(' ')) { - $thorn =~ m:(.*)[/\\](.*):; + $thorn =~ m:(.*)[/\\]([^/\\]*):; $package = $1; $thorn_name = $2; @@ -319,7 +319,7 @@ sub CreateMakeThornlist { - my($thorns ,$interface, $config) = @_; + my($cctk_home, $thorns ,$interface, $config) = @_; my($thorn); my($thornlist); my($thorn_linklist); @@ -335,7 +335,8 @@ if($config->{"\U$thorn\E OPTIONS"} ne 'NO_SOURCE' && $thorn ne 'Cactus') { - $thorns->{$thorn} =~ m:.*/(.*/.*):; + my $tmp = quotemeta($cctk_home); + $thorns{$thorn} =~ m:$tmp/arrangements/(.*):; $thornlist .= " $1"; } @@ -483,7 +484,7 @@ #@@*/ sub CreateThornsHeaders { - my(%thorns) = @_; + my($cctk_home, %thorns) = @_; my($header1,$header2,$header3,$thorn,$nthorns); $header1 = "\/* List of compiled thorns in the code. *\/\n\n"; @@ -495,20 +496,28 @@ foreach $thorn (sort keys %thorns) { # Only place package_name/thorn_name in the file. - $thorns{$thorn} =~ m:.*/(.*)/(.*):; + my $tmp = quotemeta($cctk_home); + $thorns{$thorn} =~ m:$tmp(/arrangements/)?(.*)/([^/]*):; + $this_arr = $2; + $this_thorn = $3; + if ($thorn eq 'Cactus') + { + $thorns{$thorn} =~ m:.*/(.*)/(.*):; + $this_arr = $1 + } $header3 .= "#ifdef THORN_IS_$thorn\n" . - "#define CCTK_THORN $2\n" . - "#define CCTK_THORNSTRING \"$2\"\n" . - "#define CCTK_ARRANGEMENT $1\n" . - "#define CCTK_ARRANGEMENTSTRING \"$1\"\n" . + "#define CCTK_THORN $this_thorn\n" . + "#define CCTK_THORNSTRING \"$this_thorn\"\n" . + "#define CCTK_ARRANGEMENT $this_arr\n" . + "#define CCTK_ARRANGEMENTSTRING \"$this_arr\"\n" . "#endif\n\n"; # Ignore the main sources for the other headers - they may confuse next if ($thorn eq 'Cactus'); - $header1 .= "\"$1/$2\",\n"; - $header2 .= "#define \U$1_$2\E\n"; + $header1 .= "\"$this_arr/$this_thorn\",\n"; + $header2 .= "#define \U$this_arr_$this_thorn\E\n"; $nthorns++; } Index: sbin/InterLatex.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/InterLatex.pl,v retrieving revision 1.5 diff -u -r1.5 InterLatex.pl --- sbin/InterLatex.pl 20 Aug 2004 11:33:00 -0000 1.5 +++ sbin/InterLatex.pl 2 Feb 2010 18:31:57 -0000 @@ -178,7 +178,7 @@ # drop the keys to lower-case, as they are all upper-case tr/A-Z/a-z/; - /^(.*?)\/(.*?)( |$)/; + /^(.*?)\/([^\/]*?)( |$)/; my ($arrangement, $thorn) = ($1, $2); @@ -236,7 +236,9 @@ my $thorn = $_[2]; # open up the output file - my $ofh = ThornUtils::StartDocument("inter", $thorn, $outdir, $arrangement, "Interfaces", $document_type); + my $flat_arrangement = $arrangement; + $flat_arrangement =~ s/\//_/g; + my $ofh = ThornUtils::StartDocument("inter", $thorn, $outdir, $flat_arrangement, "Interfaces", $document_type); # print out the table &LatexTableElement(\%thorn); Index: sbin/MakeUtils.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/MakeUtils.pl,v retrieving revision 1.20 diff -u -r1.20 MakeUtils.pl --- sbin/MakeUtils.pl 17 Jun 2008 17:13:10 -0000 1.20 +++ sbin/MakeUtils.pl 2 Feb 2010 18:31:57 -0000 @@ -38,64 +38,25 @@ chdir "$arrangement_dir" || die "Can't change directory to $arrangement_dir\n"; - open(ARRANGEMENTS, "ls|"); - - while() + my @thorn_arr = `find $arrangement_dir -name interface.ccl | sed -e 's/^\\.\\///' -e 's/\\/[^/]*\$//g'`; + my $tmp = join("", @thorn_arr); + my $esc = quotemeta($arrangement_dir); + $tmp =~ s/^$esc\///gm; + if ($choice !~ "thorns") { - chomp; - - # Ignore CVS and backup stuff - next if (m:^CVS$:); - next if (m:^\#:); - next if (m:~$:); - next if (m:\.bak$:i); - next if (m:^\.:); - - # Just pick directories - if( -d $_) - { - push (@arrangements, $_); - } + # remove thorn name + $tmp =~ s/\/([^\/])*$//g; } - - close ARRANGEMENTS; - if ($choice =~ "thorns") { - - foreach $arrangement (@arrangements) - { - chdir $arrangement; - - open(THORNLIST, "ls|"); - - while() - { - chomp; - - # Ignore CVS and backup stuff - next if (m:^CVS$:); - next if (m:^\#:); - next if (m:~$:); - next if (m:\.bak$:i); - next if (m:^\.:); - - # Allow each arrangement to have a documentation directory. - next if (m:^doc$:); - - # Just pick directories - if( -d $_) - { - push(@total_list, "$arrangement/$_"); - } - } - chdir ($arrangement_dir) || die "Can't change directory to $arrangement_dir\n"; - } - + push(@total_list, split(/\n/, $tmp)); } else { - @total_list = @arrangements; + # remove duplicates + undef %tmp; + @tmp{split(/\n/, $tmp)} = (); + @arrangements = keys(%tmp); } if($choice =~ "thorns") Index: sbin/ParamLatex.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/ParamLatex.pl,v retrieving revision 1.14 diff -u -r1.14 ParamLatex.pl --- sbin/ParamLatex.pl 7 Oct 2003 14:50:37 -0000 1.14 +++ sbin/ParamLatex.pl 2 Feb 2010 18:31:57 -0000 @@ -283,7 +283,9 @@ my $thorn = $_[2]; my $latex_output = ""; - my $ofh = ThornUtils::StartDocument("param", $thorn, $outdir, $arrangement, "Parameters", $document_type); + my $flat_arrangement = $arrangement; + $flat_arrangement =~ s/\//_/g; + my $ofh = ThornUtils::StartDocument("param", $thorn, $outdir, $flat_arrangement, "Parameters", $document_type); # go get the latex for setting the width of the columns based on the longest variable we have # (contained in the vaor $paragraph_len Index: sbin/SchedLatex.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/SchedLatex.pl,v retrieving revision 1.5 diff -u -r1.5 SchedLatex.pl --- sbin/SchedLatex.pl 7 Oct 2003 14:50:37 -0000 1.5 +++ sbin/SchedLatex.pl 2 Feb 2010 18:31:57 -0000 @@ -235,7 +235,9 @@ my $arrangement = $_[1]; my $thorn = $_[2]; - my $ofh = ThornUtils::StartDocument("schedule", $thorn, $outdir, $arrangement, "Schedule", $document_type); + my $flat_arrangement = $arrangement; + $flat_arrangement =~ s/\//_/g; + my $ofh = ThornUtils::StartDocument("schedule", $thorn, $outdir, $flat_arrangement, "Schedule", $document_type); # go print out all the good stuff for any given thorn &CreateLatexTable(\%thorn, "$arrangement/$thorn"); Index: sbin/ThornDoc =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/ThornDoc,v retrieving revision 1.5 diff -u -r1.5 ThornDoc --- sbin/ThornDoc 11 Nov 2009 22:32:53 -0000 1.5 +++ sbin/ThornDoc 2 Feb 2010 18:31:57 -0000 @@ -8,38 +8,35 @@ # Selected thorn; process all thorns if this is empty selection="$1" -for arr in `cd arrangements; echo *`; do - if test -d arrangements/$arr; then - for th in `cd arrangements/$arr; echo *`; do - if test -d arrangements/$arr/$th; then - if test -z "$selection" || test "$th" == "$selection"; then - if test -e arrangements/$arr/$th/doc/documentation.tex; then - echo " Processing thorn $arr/$th..." - - mkdir doc/ThornDoc 2> /dev/null - mkdir doc/ThornDoc/$arr 2> /dev/null - mkdir doc/ThornDoc/$arr/$th 2> /dev/null - ( - cd doc/ThornDoc/$arr/$th - rm -f documentation.tex documentation.pdf - path=../../../../arrangements/$arr/$th/doc - < $path/documentation.tex sed -e 's+\(\\includegraphics.*\){ *\(.*\) *}+\1{'"$path"'/\2}+g' | - sed -e 's+\(\\input *\)\(.*\)+\1'"$path"'/\2+g' > documentation.tex - - { - pdflatex documentation < /dev/null > LATEX_MESSAGES 2>&1 - pdflatex documentation < /dev/null > LATEX_MESSAGES 2>&1 - pdflatex documentation < /dev/null > LATEX_MESSAGES 2>&1 - } || - echo " ERROR: Could not create documentation (check for latex errors)" - ) - - fi # if thorn has documentation - fi # if thorn is enabled - fi - done # for thorns +pwd=`pwd`; + +for th in `cd arrangements; find . -name interface.ccl | sed -e 's/^\.\///' -e 's/\/[^/]*$//g'`; do + if test -d arrangements/$th; then + if test -z "$selection" || test "$th" == "$selection"; then + if test -e arrangements/$th/doc/documentation.tex; then + echo " Processing thorn $th..." + mkdir -p doc/ThornDoc/$th 2> /dev/null + ( + cd doc/ThornDoc/$th + rm -f documentation.tex documentation.pdf + path=$pwd/arrangements/$th/doc + < $path/documentation.tex \ + sed -e 's+\(\\includegraphics.*\){ *\(.*\) *}+\1{'"$path"'/\2}+g' \ + -e 's+\(\\input *\)\(.*\)+\1'"$path"'/\2+g' \ + -e 's+\.\./\.\./\.\./\.\./doc/+'"$pwd"'/doc/+g'\ + > documentation.tex + + { + pdflatex documentation < /dev/null > LATEX_MESSAGES 2>&1 + pdflatex documentation < /dev/null > LATEX_MESSAGES 2>&1 + pdflatex documentation < /dev/null > LATEX_MESSAGES 2>&1 + } || + echo " ERROR: Could not create documentation (check for latex errors)" + ) + fi # if thorn has documentation + fi # if thorn is enabled fi -done # for arrangements +done # for thorns echo " Created thorn documentations in doc/ThornDoc directory." echo " Done." Index: sbin/ThornGuide.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/ThornGuide.pl,v retrieving revision 1.38 diff -u -r1.38 ThornGuide.pl --- sbin/ThornGuide.pl 3 Feb 2009 00:54:05 -0000 1.38 +++ sbin/ThornGuide.pl 2 Feb 2010 18:31:57 -0000 @@ -209,6 +209,9 @@ my $path = "$arrangements_dir$arrangement/$thorn/doc"; my $pathandfile = "$path/$file"; + my $flat_arrangement = $arrangement; + $flat_arrangement =~ s/\//_/g; + my $title = ""; my $author = ""; my $date = ""; @@ -257,9 +260,9 @@ } } - $contents .= "\n\\include{${arrangement}_${thorn}_param}\n"; - $contents .= "\n\\include{" . ThornUtils::ToLower("${arrangement}_${thorn}_inter") . "\}\n"; - $contents .= "\n\\include{${arrangement}_${thorn}_schedule}\n"; + $contents .= "\n\\include{${flat_arrangement}_${thorn}_param}\n"; + $contents .= "\n\\include{" . ThornUtils::ToLower("${flat_arrangement}_${thorn}_inter") . "\}\n"; + $contents .= "\n\\include{${flat_arrangement}_${thorn}_schedule}\n"; # If it never started reading, then return 0. # (It is probably an older documentation.doc.) @@ -324,6 +327,9 @@ my $document_has_begun = 0; my $path = "$arrangements_dir$arrangement/$thorn/doc"; + my $flat_arrangement = $arrangement; + $flat_arrangement =~ s/\//_/g; + my $pathandfile = "$path/$file"; my $title = ""; @@ -350,9 +356,9 @@ if (/\\end\{document\}/) { # stop reading $stop = 1; - $contents .= "\n\\include{${arrangement}_${thorn}_param}\n"; - $contents .= "\n\\include{" . ThornUtils::ToLower("${arrangement}_${thorn}_inter") . "\}\n"; - $contents .= "\n\\include{${arrangement}_${thorn}_schedule}\n"; + $contents .= "\n\\include{${flat_arrangement}_${thorn}_param}\n"; + $contents .= "\n\\include{" . ThornUtils::ToLower("${flat_arrangement}_${thorn}_inter") . "\}\n"; + $contents .= "\n\\include{${flat_arrangement}_${thorn}_schedule}\n"; } if ($start && ! $stop) { # add to $contents @@ -385,9 +391,9 @@ } else { $contents = "Could not find latex documentation for $tmp ($file)"; } - $contents .= "\n\n\\include{${arrangement}\_${thorn}\_param}\n"; - $contents .= "\n\\include{" . ThornUtils::ToLower("${arrangement}_${thorn}_inter") . "\}\n"; - $contents .= "\n\\include{${arrangement}\_${thorn}\_schedule}\n"; + $contents .= "\n\n\\include{${flat_arrangement}\_${thorn}\_param}\n"; + $contents .= "\n\\include{" . ThornUtils::ToLower("${flat_arrangement}_${thorn}_inter") . "\}\n"; + $contents .= "\n\\include{${flat_arrangement}\_${thorn}\_schedule}\n"; } } else { # we sucessfully parsed the information. So we print out the author & title & date, etc. Index: sbin/ThornList.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/ThornList.pl,v retrieving revision 1.6 diff -u -r1.6 ThornList.pl --- sbin/ThornList.pl 4 Aug 2005 15:05:45 -0000 1.6 +++ sbin/ThornList.pl 2 Feb 2010 18:31:57 -0000 @@ -72,16 +72,13 @@ # if we are building a thornlist from thorns in $arrangements_dir elsif (! defined $thornlist) { - @arrangements = &FindDirectories($arrangements_dir); - - foreach my $arrangement (@arrangements) - { - @thorns = &FindDirectories("$arrangements_dir$arrangement"); - - foreach my $thorn (@thorns) { - print "$arrangement/$thorn\n" if ($thorn ne "doc"); - } - } + my @ret = `find $arrangements_dir -name interface.ccl | sed -e 's/^\\.\\///' -e 's/\\/[^/]*\$//g'`; + my $tmp = join("", @ret); + my $esc = quotemeta($arrangements_dir); + $tmp =~ s/^$esc//gm; + # remove 'doc' + $tmp =~ s/\n.*\/doc\n/\n/gm; + print $tmp; } # if we are printing all the thorn directories on one line # for use by the ThornGuide makefile Index: sbin/ThornUtils.pm =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/ThornUtils.pm,v retrieving revision 1.11 diff -u -r1.11 ThornUtils.pm --- sbin/ThornUtils.pm 8 Dec 2006 19:08:52 -0000 1.11 +++ sbin/ThornUtils.pm 2 Feb 2010 18:31:57 -0000 @@ -33,9 +33,8 @@ # @date Sun Mar 3 01:54:37 CET 2002 # @author Ian Kelley # @desc -# Takes an input directory (arrangements directory), calls &FindDirectories to get all -# the sub-directories (arrangements), then calls &FindDirectories once more to get all -# the sub-sub-directories (thorns), then returns a thornlist. +# Takes an input directory (arrangements directory), looks for thorns (assuming every +# thorn contains a file 'interface.ccl' and returns the resulting thornlist. # @thorns = &CreateThornlist($arrangements_dir); # @enddesc # @version @@ -44,20 +43,11 @@ { my ($arrangementsDir) = shift; - my (@foundThorns, @arrangements, @thorns); - - @arrangements = &FindDirectories($arrangementsDir); - - foreach my $arrangement (@arrangements) - { - @thorns = &FindDirectories("${arrangementsDir}${arrangement}"); - - foreach my $thorn (@thorns) { - push @foundThorns, "${arrangement}/${thorn}"; - } - } - - return @foundThorns; + my @ret = `find $arrangementsDir -name interface.ccl | sed -e 's/^\\.\\///' -e 's/\\/[^/]*\$//g'`; + my $tmp = join("", @ret); + my $esc = quotemeta($arrangementsDir); + $tmp =~ s/^$esc\///g; + return split(/\n/, $tmp); } #/*@@ @@ -208,7 +198,7 @@ # We add keys (arrangements) to the hash passed in ($rhArr) which are references # to a list of thorns for each arrangement. foreach (@_) { - /^(.*?)\/(.*?)$/; + /^(.*)\/([^\/]*?)$/; push @{$$rhArr{$1}}, $2; } } @@ -241,7 +231,7 @@ my %paths; foreach (@$rlListOfThorns) { - /^(.*?)\/(.*?)$/; + /^(.*)\/([^\/]*?)$/; if (($interestingFile eq "") || (-e "${arrangementsDir}${_}/${interestingFile}")) { my $key = $keepArrInKey ? "$1/$2" : "$1"; $paths{$key} = "$arrangementsDir$_"; Index: sbin/interface_parser.pl =================================================================== RCS file: /cactusdevcvs/Cactus/lib/sbin/interface_parser.pl,v retrieving revision 1.89 diff -u -r1.89 interface_parser.pl --- sbin/interface_parser.pl 11 Sep 2009 16:07:35 -0000 1.89 +++ sbin/interface_parser.pl 2 Feb 2010 18:31:57 -0000 @@ -35,7 +35,7 @@ { print " $thorn\n"; # Get the arrangement name for the thorn - $thorns{$thorn} =~ m:.*/arrangements/([^/]*)/[^/]*:; + $thorns{$thorn} =~ m:.*/arrangements/(.*)/[^/]*:; my $arrangement = $1; # Read the data -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available Url : http://www.cactuscode.org/pipermail/patches/attachments/20100202/b41f4974/attachment.bin