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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [yp/] [create_yp] - Diff between revs 130 and 131

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 130 Rev 131
Line 51... Line 51...
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;
 
use lib './tools';
 
use sys::lib;
 
use BerkeleyDB;
 
 
 
 
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
 
 
 
 
Line 72... Line 75...
##############################################################################
##############################################################################
## 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  $path  \n";
   exit 1;
   exit 1;
   }
   }
 
 
 
 
##############################################################################
##############################################################################
##
##
##############################################################################
##############################################################################
 
 
my $home                     = cwd();
my $home                     = cwd();
 
my $path           = $ARGV[0];
 
 
 
mkdir $path,0755   unless( -e $path );
 
 
 
 
 
$repo_db                    = new BerkeleyDB::Hash( -Filename => "${path}/repo.dbm",                   -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$component_db               = new BerkeleyDB::Hash( -Filename => "${path}/component.dbm",              -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$design_db                  = new BerkeleyDB::Hash( -Filename => "${path}/design.dbm",                 -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$busDefinition_db           = new BerkeleyDB::Hash( -Filename => "${path}/busDefinition.dbm",          -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$abstractionDefinition_db   = new BerkeleyDB::Hash( -Filename => "${path}/abstractionDefinition.dbm",  -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$libraryConfiguration_db    = new BerkeleyDB::Hash( -Filename => "${path}/libraryConfiguration.dbm",   -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$componentConfiguration_db  = new BerkeleyDB::Hash( -Filename => "${path}/componentConfiguration.dbm", -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
 
 
 
my $projects_dir    = $ARGV[0];
 
chomp($projects_dir);
 
$projects_dir = "/${projects_dir}";
 
 
 
 
my $parser = XML::LibXML->new();
 
 
 
 
 
 
use BerkeleyDB;
my    $workspace    = $parser->parse_file("${home}/workspace.xml");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
my @repos =();
 
my $repo;
 
 
 
 
 
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:external/socgen:repo'))
 
                  {
 
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
 
                  my $repo_path  = $repo->findnodes('./socgen:path/text()')->to_literal ;
 
                  print "Linking $repo_name   $repo_path \n";
 
                  if(-e  $repo_name)
 
                   {
 
                   print "Removing $repo_name  \n";
 
                   my $cmd = "rm -r $repo_name  \n";
 
                   if(system($cmd)){};
 
                   }
 
 
 
                  my $cmd = "mkdir $repo_name ;lndir  $repo_path  $repo_name;";
 
                  if(system($cmd)){};
 
 
 
 
 
 
 
                  }
 
 
$repo_db                  = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/repo.dbm',                  -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$component_db             = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/component.dbm',             -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$design_db                = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/design.dbm',                -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$busDefinition_db         = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/busDefinition.dbm',         -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$abstractionDefinition_db = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/abstractionDefinition.dbm', -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$libraryConfiguration_db  = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/libraryConfiguration.dbm',  -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
$componentConfiguration_db  = new BerkeleyDB::Hash( -Filename => 'tools/yp/Berkeley/componentConfiguration.dbm',  -Flags => DB_CREATE ) or die "Cannot open file: $!";
 
 
 
 
 
 
 
 
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:repos/socgen:repo'))
 
                  {
 
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
 
                  push  @repos,$repo_name;
 
                  }
 
 
 
my $repos_dir ;
 
 
 
 
 
 
 
foreach $repos_dir (@repos)
 
{
 
print "Project_dir  $repos_dir  \n";
 
 
 
 
 
 
 
 
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
Line 121... Line 166...
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
 
 
my $parser = XML::LibXML->new();
 
$root = "${home}${projects_dir}";
$root = "${home}${repos_dir}";
&link_dir( "$root"  );
&link_dir( "$root","$repos_dir"  );
 
 
 
 
 
 
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
Line 140... Line 185...
 
 
# recursively map directory information
# recursively map directory information
 
 
sub link_dir {
sub link_dir {
    my $src  = shift;
    my $src  = shift;
 
    my $repos_dir  = shift;
 
 
 
 
    return unless( -e $src );
    return unless( -e $src );
 
 
    if( -d $src )
    if( -d $src )
        {
        {
        my @contents = (  );
        my @contents = (  );
Line 164... Line 212...
             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");
             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
 
               {
 
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
 
                  {
 
                  $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
 
                  $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
 
                  $type     = "spirit:component";
 
                  $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
 
                  $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
 
                  }
 
 
 
 
 
               foreach my $design ($xml_file->findnodes('//spirit:design'))
 
                  {
 
                  $vendor   = $design->findnodes('./spirit:vendor/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";
 
 
 
                  }
 
 
 
 
 
 
            if(${t_name} eq "libraryCfg"  )
 
 
 
 
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
 
                  {
                  {
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
                  $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";
 
                  }
 
 
 
 
 
               foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
 
                  {
                  {
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
                  $name     = "";
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
                  $version  = "";
                  $type     = "spirit:busDefinition";
                  $type     = "socgen:libraryConfiguration";
                  }
                  }
               }
               }
 
             elsif(${t_name} eq "componentCfg"  )
               else               #/  socgen  namespace
 
 
 
               {
               {
 
 
 
 
               foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
               foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
                  {
                  {
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
                  $version  = "";
                  $version  = "";
                  $type     = "socgen:componentConfiguration";
                  $type     = "socgen:componentConfiguration";
                  }
                  }
 
              }
 
 
 
             else
               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";
 
                  }
 
 
 
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
                  {
                  {
                  $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 ;
Line 260... Line 261...
 
 
                  }
                  }
 
 
 
 
 
 
 
 
 
 
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
                  {
                  {
                  $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 ;
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
Line 283... Line 282...
                  $type     = "spirit:busDefinition";
                  $type     = "spirit:busDefinition";
                  }
                  }
 
 
 
 
 
 
               }
 
 
 
 
 
 
 
 
 
 
               }
 
 
             $vendor_match = "/${vendor}/";
             $vendor_match = "/${vendor}/";
             $library_match = "/${library}/";
             $library_match = "/${library}/";
             $name_match = "/${name}/";
             $name_match = "/${name}/";
 
 
             $_ = $t_local;
             $_ = $t_local;
Line 307... Line 309...
             else                                              { $component_path   = "/"; }
             else                                              { $component_path   = "/"; }
 
 
 
 
 
 
 
 
 
#               print "${vendor}__${library}_${name}_${version}     $t_local  $library_match  $lib_comp_sep  $name_match    \n";
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
 
 
 
 
 
 
             if($type eq "spirit:component")
             if($type eq "spirit:component")
               {
               {
 
 
               my $V = "${vendor}"    ;
               my $V = "${vendor}"    ;
               my @repo_info  = ("vendor","$vendor","$vendor_path" );
               my @repo_info  = ("vendor","$vendor","idle","$repos_dir" );
               $repo_db->db_put( $V, join(':', @repo_info) );
               $repo_db->db_put( $V, join(':', @repo_info) );
 
 
 
 
               my $V_L = "${vendor}__${library}"    ;
               my $V_L = "${vendor}__${library}"    ;
               @repo_info  = ("library","$library","$library_path" );
               @repo_info  = ("library","$library","$library_path" ,"idle","$repos_dir");
               $repo_db->db_put( $V_L, join(':', @repo_info) );
               $repo_db->db_put( $V_L, join(':', @repo_info) );
 
 
 
 
 
 
               my $V_L_N = "${vendor}__${library}_${name}"    ;
               my $V_L_N = "${vendor}__${library}_${name}"    ;
               @repo_info  = ("component","$name","$lib_comp_sep" );
               @repo_info  = ("component","$name","$lib_comp_sep","$repos_dir" );
               $repo_db->db_put( $V_L_N, join(':', @repo_info) );
               $repo_db->db_put( $V_L_N, join(':', @repo_info) );
 
 
 
 
 
 
               my @comp_info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
               my @comp_info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
               $component_db->db_put( $V_L_N_V, join(':', @comp_info) );
               $component_db->db_put( $V_L_N_V, join(':', @comp_info) );
 
 
#               print "${vendor}__${library}_${name}_${version} \n";
 
#               print " .${t_local}/${t_name}.xml , ${component_path}                     \n  ";
#               print " .${t_local}/${t_name}.xml , ${component_path}                     \n  ";
 
 
 
 
               }
               }
 
 
Line 355... Line 357...
               }
               }
 
 
 
 
             elsif($type eq "spirit:abstractionDefinition")
             elsif($type eq "spirit:abstractionDefinition")
               {
               {
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
#               print "ABSDEF  $V_L_N_V    \n";
 
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}","${name}","${library}","${vendor}"         );
               $abstractionDefinition_db->db_put( $V_L_N_V, join(':', @info) );
               $abstractionDefinition_db->db_put( $V_L_N_V, join(':', @info) );
               }
               }
 
 
 
 
             elsif($type eq "spirit:busDefinition")
             elsif($type eq "spirit:busDefinition")
Line 367... Line 370...
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
               $busDefinition_db->db_put( $V_L_N_V, join(':', @info) );
               $busDefinition_db->db_put( $V_L_N_V, join(':', @info) );
               }
               }
 
 
 
 
 
 
 
 
 
 
 
 
             if($type eq "socgen:libraryConfiguration")
             if($type eq "socgen:libraryConfiguration")
               {
               {
               $V_L  = "${vendor}__${library}"    ;
               $V_L  = "${vendor}__${library}"    ;
               @info  = (".${t_local}/${t_name}.xml" );
               @info  = (".${t_local}/${t_name}.xml" );
               $libraryConfiguration_db->db_put( $V_L, join(':', @info) );
               $libraryConfiguration_db->db_put( $V_L, join(':', @info) );
Line 383... Line 390...
               @info  = (".${t_local}/${t_name}.xml" );
               @info  = (".${t_local}/${t_name}.xml" );
               $componentConfiguration_db->db_put( $V_L_N, join(':', @info) );
               $componentConfiguration_db->db_put( $V_L_N, join(':', @info) );
               }
               }
 
 
 
 
 
my $uplift_data;
 
$repo_db->db_get("log_name", $uplift_data );
 
 
 
 
 
 
 
 
             }
             }
 
 
          &link_dir("$src/$item" );
          &link_dir("$src/$item","$repos_dir" );
          }
          }
 
 
     }
     }
 
 
}
}
 
 
 
 
 
 
 
}
 
 
 
 
$repo_db->db_close();
$repo_db->db_close();
$component_db->db_close();
$component_db->db_close();
$design_db->db_close();
$design_db->db_close();

powered by: WebSVN 2.1.0

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