OpenCores
URL https://opencores.org/ocsvn/socgen/socgen/trunk

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [yp/] [create_yp] - Diff between revs 120 and 124

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 120 Rev 124
eval 'exec `which perl` -S $0 ${1+"$@"}'
eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
   if 0;
#/**********************************************************************/
#/**********************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*             -------                                                */
#/*             -------                                                */
#/*            /   SOC  \                                              */
#/*            /   SOC  \                                              */
#/*           /    GEN   \                                             */
#/*           /    GEN   \                                             */
#/*          /    TOOL    \                                            */
#/*          /    TOOL    \                                            */
#/*          ==============                                            */
#/*          ==============                                            */
#/*          |            |                                            */
#/*          |            |                                            */
#/*          |____________|                                            */
#/*          |____________|                                            */
#/*                                                                    */
#/*                                                                    */
#/*  Traverse a socgen project and link it                             */
#/*  Traverse a socgen project and link it                             */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/*                                                                    */
#/**********************************************************************/
#/**********************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*    Copyright (C) <2010-2011>                */
#/*    Copyright (C) <2010-2011>                */
#/*                                                                    */
#/*                                                                    */
#/*  This source file may be used and distributed without              */
#/*  This source file may be used and distributed without              */
#/*  restriction provided that this copyright statement is not         */
#/*  restriction provided that this copyright statement is not         */
#/*  removed from the file and that any derivative work contains       */
#/*  removed from the file and that any derivative work contains       */
#/*  the original copyright notice and the associated disclaimer.      */
#/*  the original copyright notice and the associated disclaimer.      */
#/*                                                                    */
#/*                                                                    */
#/*  This source file is free software; you can redistribute it        */
#/*  This source file is free software; you can redistribute it        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  Public License as published by the Free Software Foundation;      */
#/*  Public License as published by the Free Software Foundation;      */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  later version.                                                    */
#/*  later version.                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  This source is distributed in the hope that it will be            */
#/*  This source is distributed in the hope that it will be            */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  details.                                                          */
#/*  details.                                                          */
#/*                                                                    */
#/*                                                                    */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  Public License along with this source; if not, download it        */
#/*  Public License along with this source; if not, download it        */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*                                                                    */
#/*                                                                    */
#/**********************************************************************/
#/**********************************************************************/
############################################################################
############################################################################
# General PERL config
# General PERL config
############################################################################
############################################################################
use Getopt::Long;
use Getopt::Long;
use English;
use English;
use File::Basename;
use File::Basename;
use Cwd;
use Cwd;
use XML::LibXML;
use XML::LibXML;
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
############################################################################
############################################################################
### Process the options
### Process the options
############################################################################
############################################################################
Getopt::Long::config("require_order", "prefix=-");
Getopt::Long::config("require_order", "prefix=-");
GetOptions("h","help"
GetOptions("h","help"
) || die "(use '$program_name -h' for help)";
) || die "(use '$program_name -h' for help)";
##############################################################################
##############################################################################
## Help option
## Help option
##############################################################################
##############################################################################
if ( $opt_h or $opt_help  )
if ( $opt_h or $opt_help  )
   {
   {
   print "\n type create_yp\n";
   print "\n type create_yp\n";
   exit 1;
   exit 1;
   }
   }
##############################################################################
##############################################################################
##
##
##############################################################################
##############################################################################
my $home                     = cwd();
my $home                     = cwd();
my $index_filename           = "./tools/yp/index.xml";
my $index_filename           = "./tools/yp/index.xml";
open   OUTFILE,">$index_filename" or die "unable to open $index_filename";
open   OUTFILE,">$index_filename" or die "unable to open $index_filename";
 
 
 
 
print  OUTFILE "\n";
print  OUTFILE "\n";
print  OUTFILE "\n";
print  OUTFILE "\n";
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
my $parser = XML::LibXML->new();
my $parser = XML::LibXML->new();
$root = "${home}/projects";
$root = "${home}/projects";
&link_dir( "$root"  );
&link_dir( "$root"  );
print  OUTFILE "  \n";
print  OUTFILE "  \n";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
# recursively map directory information
# recursively map directory information
sub link_dir {
sub link_dir {
    my $src  = shift;
    my $src  = shift;
    return unless( -e $src );
    return unless( -e $src );
    if( -d $src )
    if( -d $src )
        {
        {
 
 
        my @contents = (  );
        my @contents = (  );
        opendir( DIR, $src );
        opendir( DIR, $src );
        while( my $item = readdir( DIR ))
        while( my $item = readdir( DIR ))
            {
            {
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
            push( @contents, $item );
            push( @contents, $item );
            }
            }
        closedir( DIR );
        closedir( DIR );
        # recurse on items in the directory
        # recurse on items in the directory
        foreach my $item ( @contents )
        foreach my $item ( @contents )
          {
          {
          $_ = $item;
          $_ = $item;
          if(/(\S+).xml/)
          if(/(\S+)\.xml/)
             {
             {
             my $t_name                = $1;
             my $t_name                = $1;
             $_ = $src;
             $_ = $src;
             if(/${home}(\S+)/) { $t_local = $1; }
             if(/${home}(\S+)/) { $t_local = $1; }
 
 
 
             my    $xml_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
 
             eval {$xml_file->  findnodes('//socgen:componentConfiguration');};  #/ check for socgen namespace
 
 
 
             if($@)             #/ Nope, must be spirit  namespace
 
 
 
 
 
 
 
 
if($t_name eq "design")
 
{
{
my $socgen_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
foreach my $design ($socgen_file->findnodes('//socgen:ip'))
 
   {
   {
   $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
 
   $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
 
   $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
 
   $version  = "";
 
   $type     = "socgen:ip";
 
   }
 
}
 
 
 
 
 
elsif($t_name eq "library")
 
{
 
my $socgen_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
 
 
 
 
 
foreach my $design ($socgen_file->findnodes('//socgen:lib'))
 
   {
 
   $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
 
   $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
 
   $lib_ip_dir  = $design->findnodes('./socgen:lib_ip_dir/text()')->to_literal ;
 
   $lib_sw_dir  = $design->findnodes('./socgen:lib_sw_dir/text()')->to_literal ;
 
   $version  = "";
 
   $name     = "";
 
   $type     = "socgen:lib";
 
 
 
 
 
 
 
   }
 
}
 
 
 
 
 
 
 
 
 
else
 
{
 
my $spirit_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
 
 
 
 
 
foreach my $comp ($spirit_file->findnodes('//spirit:component'))
 
   {
 
   $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
 
   $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
 
   $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
   $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
   $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
                  $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
   $type     = "spirit:component";
   $type     = "spirit:component";
 
                  $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
 
                  $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
 
                  $lib_ip_dir = "";
 
                  $lib_sw_dir = "";
   }
   }
 
 
foreach my $design ($spirit_file->findnodes('//spirit:design'))
               foreach my $design ($xml_file->findnodes('//spirit:design'))
   {
   {
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
 
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
 
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
   $type     = "spirit:design";
   $type     = "spirit:design";
 
                  $lib_ip_dir = "";
 
                  $lib_sw_dir = "";
 
 
   }
                  }
 
 
foreach my $design ($spirit_file->findnodes('//spirit:designConfiguration'))
               foreach my $design ($xml_file->findnodes('//spirit:designConfiguration'))
   {
   {
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
 
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
 
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
   $type     = "spirit:designConfiguration";
   $type     = "spirit:designConfiguration";
 
                  $lib_ip_dir = "";
 
                  $lib_sw_dir = "";
 
 
   }
                  }
 
 
foreach my $design ($spirit_file->findnodes('//spirit:abstractionDefinition'))
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
   {
   {
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
 
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
 
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
   $type     = "spirit:abstractionDefinition";
   $type     = "spirit:abstractionDefinition";
 
                  $lib_ip_dir = "";
 
                  $lib_sw_dir = "";
   }
   }
 
 
foreach my $design ($spirit_file->findnodes('//spirit:busDefinition'))
               foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
   {
   {
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
 
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
 
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
 
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
   $type     = "spirit:busDefinition";
   $type     = "spirit:busDefinition";
 
                  $lib_ip_dir = "";
 
                  $lib_sw_dir = "";
 
                  }
   }
   }
 
 
 
               else               #/  socgen  namespace
 
 
 
               {
 
 
 
 
 
               foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
 
                  {
 
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
 
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
 
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
 
                  $version  = "";
 
                  $type     = "socgen:componentConfiguration";
 
                  $lib_ip_dir = "";
 
                  $lib_sw_dir = "";
 
                  }
 
 
 
 
 
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
 
                  {
 
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
 
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
 
                  $name     = "";
 
                  $version  = "";
 
                  $type     = "socgen:libraryConfiguration";
 
                  $lib_ip_dir  = $design->findnodes('./socgen:lib_ip_dir/text()')->to_literal ;
 
                  $lib_sw_dir  = $design->findnodes('./socgen:lib_sw_dir/text()')->to_literal ;
 
                  }
}
}
          $vendor_match = "/${vendor}/";
             $vendor_match = "/${vendor}/";
          $library_match = "/${library}/";
             $library_match = "/${library}/";
          $name_match = "/${name}/";
             $name_match = "/${name}/";
          $_ = $t_local;
             $_ = $t_local;
          if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
             if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
          else                                              { $vendor_path      = ""; }
             else                                              { $vendor_path      = ""; }
          if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
             if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
          else                                              { $library_path     = ""; }
             else                                              { $library_path     = ""; }
          if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = $2; }
             if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = $2; }
          else                                              { $lib_comp_sep     = ""; }
             else                                              { $lib_comp_sep     = ""; }
          if(/\S?($name_match)(\S+)/)                       { $component_path   = $2; }
             if(/\S?($name_match)(\S+)/)                       { $component_path   = $2; }
          else                                              { $component_path   = ""; }
             else                                              { $component_path   = ""; }
             print  OUTFILE "   \n";
             print  OUTFILE "   \n";
             print  OUTFILE "   ${type}\n";
             print  OUTFILE "   ${type}\n";
             print  OUTFILE "   ${vendor}\n";
             print  OUTFILE "   ${vendor}\n";
             print  OUTFILE "   ${library}\n";
             print  OUTFILE "   ${library}\n";
             print  OUTFILE "   ${name}\n";
             print  OUTFILE "   ${name}\n";
             print  OUTFILE "   ${version}\n";
             print  OUTFILE "   ${version}\n";
             print  OUTFILE "   ${t_name}.xml\n";
             print  OUTFILE "   ${t_name}.xml\n";
             print  OUTFILE "   ${t_local}\n";
             print  OUTFILE "   ${t_local}\n";
             print  OUTFILE "   ${vendor_path}\n";
             print  OUTFILE "   ${vendor_path}\n";
             print  OUTFILE "   ${library_path}\n";
             print  OUTFILE "   ${library_path}\n";
             print  OUTFILE "   ${component_path}\n";
             print  OUTFILE "   ${component_path}\n";
             print  OUTFILE "   ${lib_comp_sep}\n";
             print  OUTFILE "   ${lib_comp_sep}\n";
             print  OUTFILE "   ${lib_ip_dir}\n";
             print  OUTFILE "   ${lib_ip_dir}\n";
             print  OUTFILE "   ${lib_sw_dir}\n";
             print  OUTFILE "   ${lib_sw_dir}\n";
             print  OUTFILE " \n\n";
             print  OUTFILE " \n\n";
 
 
          $lib_ip_dir = "";
 
          $lib_sw_dir = "";
 
             }
             }
          &link_dir("$src/$item" );
          &link_dir("$src/$item" );
          }
          }
     }
     }
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.