ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/scripts/filepp
(Generate patch)

Comparing trunk/scripts/filepp (file contents):
Revision 26 by tim, Fri Oct 1 21:11:29 2004 UTC vs.
Revision 59 by tim, Mon Oct 11 14:51:57 2004 UTC

# Line 1 | Line 1
1   #!/usr/bin/perl -w
2
3 package FileEntry;
4
5 sub new {
6    my $type = shift;
7    my $filename = shift;
8    my $path = shift;
9    my $self = {};
10    $self->{'source_file'} = $filename;
11    $self->{'filepath'} = $path;
12    $self->{'includes'} = {};
13    $self->{'uses'} = {};
14    $self->{'modules'} = {};
15    bless $self;
16 }
17
2   ########################################################################
3   #
4   # filepp is free software; you can redistribute it and/or modify
# Line 37 | Line 21 | sub new {
21   #  Filename     :  $RCSfile: filepp,v $
22   #  Author       :  $Author: tim $
23   #  Maintainer   :  Darren Miller: darren@cabaret.demon.co.uk
24 < #  File version :  $Revision: 1.1 $
25 < #  Last changed :  $Date: 2004-10-01 21:11:29 $
24 > #  File version :  $Revision: 1.4 $
25 > #  Last changed :  $Date: 2004-10-11 14:51:57 $
26   #  Description  :  Main program
27   #  Licence      :  GNU copyleft
28   #
# Line 48 | Line 32 | use strict "subs";
32  
33   use strict "vars";
34   use strict "subs";
51 #use Graph;
35   # Used to all filepp to work with any char, not just ascii,
36   # feel free to remove this if it causes you problems
37 < use bytes;
37 > #use bytes;
38  
39   # version number of program
40   my $VERSION = '1.7.1';
41  
42   # list of paths to search for modules, normal Perl list + module dir
43 < push(@INC, "/home/maul/gezelter/tim/code/OOPSE-2.0/scripts/filepp-1.7.1/modules/f90dpend/");
43 > #push(@INC, "/home/maul/gezelter/tim/code/OOPSE-2.0/scripts/filepp-1.7.1/modules/f90dpend/");
44  
45   # index of keywords supported and functions to deal with them
46   my %Keywords = (
# Line 312 | Line 295 | my %f90ModList = ();
295   #
296   my %f90ModList = ();
297  
298 < #
298 > # suffix of fortran object file
299   my $objExt = '.o';
300 +
301 + # suffix of fortran 90 module
302 + my $modSuffix = "mod";
303 +
304 + # case of basename of fortran 90 module
305 + my $modBasenameCase = "lower";
306   ##############################################################################
307   # SetDebug - controls debugging level
308   ##############################################################################
# Line 2453 | Line 2442 | sub Module{
2442      my $file;
2443      if ($modulename !~ /^procedure/){
2444          
2445 <        $parsedModList{uc($modulename) . ".mod"} =  Filepp::GetDefine('__FILE__');
2445 >        $modulename =~ s/\s+$//;
2446 >        $parsedModList{GetModBasename($modulename) .  "." . $modSuffix}
2447 >                    =  Filepp::GetDefine('__FILE__');
2448          
2449          #$modulefile = Filepp::GetDefine('__BASE_FILE__');
2450          #print $modulefile;
# Line 2474 | Line 2465 | sub Use{
2465      my $line = shift;
2466      $line =~ /^(\w+).*/;
2467      my $f90module = $1;
2468 +    $f90module =~ s/\s+$//;
2469      $f90module = uc($f90module);
2470      
2471 <    print " " . $objDir . $f90module . '.mod \\', "\n";
2480 <    #addModule($f90module);
2471 >    print " " . $objDir . GetModBasename($f90module) . "." . $modSuffix . "\\\n";
2472   }
2473  
2474   ##############################################################################
# Line 2491 | Line 2482 | Filepp::AddKeyword("include", "Filepp::Include");
2482   Filepp::AddKeyword("include", "Filepp::Include");
2483  
2484   ##############################################################################
2485 < # add RecordFileInfo info Filepp. Every time a file is opened, an entry
2495 < # of this file is created  
2485 > # test whether a file is visited or not
2486   ##############################################################################
2497
2498 sub RecordFileInfo{
2499    my $file = Filepp::GetDefine('__FILE__');
2500 #    dependenyGraph->add_vertex(new );
2501    
2502    #if it is not base file, we need to add an edge
2503    if ($include_level > 0) {
2504    
2505    }
2506
2507 }
2508
2509 Filepp::AddOpenInputFunc("Filepp::RecordFileInfo");
2510
2487   sub IsVisited {
2488          my $fullfile = shift;
2489          
# Line 2531 | Line 2507 | sub AddModule {
2507  
2508   }
2509  
2510 <
2510 > ##############################################################################
2511 > # Generate rules for fortran 90 module
2512 > ##############################################################################
2513   sub printModule {
2514          my $modname;
2515          my $objname;
# Line 2542 | Line 2520 | sub printModule {
2520          }
2521   }
2522  
2523 + ##############################################################################
2524 + # Get the object file name
2525 + ##############################################################################
2526   sub GetObjFile {
2527          use File::Basename;
2528          my $fullname = shift;
# Line 2551 | Line 2532 | sub GetObjFile {
2532          ($filename, $dir, $suffix) = fileparse($fullname, '\.[^.]*');  
2533          return $filename . $objExt;
2534   }
2535 +
2536   ##############################################################################
2537 + # Get the base name of fortran 90 module
2538 + ##############################################################################
2539 + sub GetModBasename {
2540 +        my $modname = shift;
2541 +        
2542 +        if ($modBasenameCase eq "lower") {
2543 +            $modname = lc($modname);
2544 +            
2545 +        } elsif ($modBasenameCase eq "upper") {
2546 +            $modname = uc($modname);
2547 +        } elsif ($modBasenameCase eq "mixed") {
2548 +            $modname = ucfirst(lc($modname));
2549 +        }
2550 +        
2551 +        return $modname;
2552 + }
2553 +
2554 + ##############################################################################
2555   # Main routine
2556   ##############################################################################
2557  
# Line 2746 | Line 2746 | while($ARGV[$i]) {
2746          }
2747          UseModule($ARGV[++$i]);
2748      }
2749 <
2749 >    
2750 >    #case of basename of fortran module
2751 >    elsif($ARGV[$i] eq "-mc") {
2752 >        my $tempVar = lc($ARGV[++$i]);
2753 >        if ($modBasenameCase ne 'lower' && $modBasenameCase ne 'upper'
2754 >                                        && $modBasenameCase ne 'mixed'){
2755 >            Error("Valid argument for `-om' are lower, upper or mixed");
2756 >        }
2757 >        $modBasenameCase = $tempVar;
2758 >    }
2759 >    
2760 >    #the suffix of fortran module
2761 >    elsif($ARGV[$i] eq "-ms") {
2762 >        $modSuffix = $ARGV[++$i];
2763 >    }
2764 >    
2765      # set macro prefix
2766      elsif($ARGV[$i] eq "-mp") {
2767          if($i+1 >= $argc) {
# Line 2764 | Line 2779 | while($ARGV[$i]) {
2779      # module files will be built in a separate directory from the sources.
2780      elsif($ARGV[$i] eq "-od") {
2781          $objDir = $ARGV[++$i];
2782 <    }    
2782 >    }
2783 >    
2784      # turn on overwrite mode
2785      elsif($ARGV[$i] eq "-ov") {
2786          $overwrite = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines