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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [soc_link_child] - Rev 121

Go to most recent revision | Compare with Previous | Blame | View Log

eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;

#/**********************************************************************/
#/*                                                                    */
#/*             -------                                                */
#/*            /   SOC  \                                              */
#/*           /    GEN   \                                             */
#/*          /    TOOL    \                                            */
#/*          ==============                                            */
#/*          |            |                                            */
#/*          |____________|                                            */
#/*                                                                    */
#/*  Traverse a socgen project and link it                             */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/**********************************************************************/
#/*                                                                    */
#/*    Copyright (C) <2010-2012>  <Ouabache Design Works>              */
#/*                                                                    */
#/*  This source file may be used and distributed without              */
#/*  restriction provided that this copyright statement is not         */
#/*  removed from the file and that any derivative work contains       */
#/*  the original copyright notice and the associated disclaimer.      */
#/*                                                                    */
#/*  This source file is free software; you can redistribute it        */
#/*  and/or modify it under the terms of the GNU Lesser General        */
#/*  Public License as published by the Free Software Foundation;      */
#/*  either version 2.1 of the License, or (at your option) any        */
#/*  later version.                                                    */
#/*                                                                    */
#/*  This source is distributed in the hope that it will be            */
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
#/*  details.                                                          */
#/*                                                                    */
#/*  You should have received a copy of the GNU Lesser General         */
#/*  Public License along with this source; if not, download it        */
#/*  from http://www.opencores.org/lgpl.shtml                          */
#/*                                                                    */
#/**********************************************************************/


############################################################################
# General PERL config
############################################################################
use Getopt::Long;
use English;
use File::Basename;
use Cwd;
use XML::LibXML;
use lib './tools';
use sys::lib;
use yp::lib;


$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.




############################################################################
### Process the options
############################################################################

Getopt::Long::config("require_order", "prefix=-");
GetOptions("h","help",
           "prefix=s" => \$prefix,
           "vendor=s" => \$vendor,
           "project=s" => \$project,
           "component=s" => \$component,
           "version=s" => \$version

) || die "(use '$program_name -h' for help)";


##############################################################################
## Help option
##############################################################################
if ( $opt_h or $opt_help  ) 
   { 
   print "\n type soc_link_child  -prefix /work -vendor vendor_name -project project_name  -component  component_name -version  version_name  projects_dir ";
   print "\n";
   exit 1;
   }


##############################################################################
## 
##############################################################################

my $home              = cwd();


my $parser           = XML::LibXML->new();

my $projects_dir    = $ARGV[0];
chomp($projects_dir);
my $variant;

if($version) {$variant = "${component}_${version}";}
else         {$variant = "${component}";}



#/*********************************************************************************************/
#/                                                                                            */
#/ link overlay projects                                                                      */
#/                                                                                            */
#/*********************************************************************************************/




my $socgen_ip_file     = $parser->parse_file(yp::lib::find_socgen("socgen:ip",$vendor,$project,$component));



foreach  my   $i_name ($socgen_ip_file->findnodes("//socgen:chips/socgen:chip[socgen:name/text() = '$variant']"))
   {
   my($replace_vendor)  = $i_name ->findnodes('socgen:target/socgen:vendor/text()')->to_literal ;
   my($replace_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
   my @replace_components = yp::lib::find_components("spirit:component",$replace_vendor,$replace_library);

   foreach my $replace_component (@replace_components)
     {
      &link_child($vendor, $project,$replace_component, $replace_library ,$replace_vendor); 
     }
   }








#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/



my      @filelist_hier = (  );
my      @filelist      = (  );

@filelist_hier = (  );
@filelist = (  );

@filelist = parse_component_file("$vendor","$project","$component","$version");
@filelist = sys::lib::trim_sort(@filelist);



foreach $line (@filelist) 
   {
   $_ = $line;
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/) 
     { 
     $new_vendor      = $1;
     $new_proj        = $2;
     $new_comp        = $3;        
     $new_version     = $4;        
     if(($new_vendor ne $vendor ) or  ($new_proj ne $project ) )

       { &link_child( $vendor,$project,$new_comp, $new_proj ,$new_vendor); }
     }
   }






#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/



sub link_child {
                 my $parent_vendor      = shift;
                 my $parent_library      = shift;
                 my $child_component = shift;
                 my $child_library = shift;
                 my $child_vendor = shift;

                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library);


                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children";
                 mkdir $path,0755             unless( -e $path );
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}";
                 mkdir $path,0755             unless( -e $path );
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";

                 unless( -e $path )
                   {
                   mkdir $path,0755;
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}/bin";
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
                   &sys::lib::link_dir( "$root", "$dest"  );
                   symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile.root");
                   symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile");
                   }


                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);

                 if($lib_sw_dir)
                   {
                   my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
                   unless( -e $path )
                     {
                     mkdir $path,0755;         
                     $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_sw_dir}";
                     $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
                     &sys::lib::link_dir( "$root", "$dest"  );
                     }
                   }

                 #  only works for simple single item paths
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}";
                 mkdir $path,0755             unless( -e $path );
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";

                 unless( -e $path )
                   {
                   mkdir $path,0755;   
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_comp_sep}/${child_component}";
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
                   &sys::lib::link_dir( "$root", "$dest"  );
                   }
               }






#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/




sub parse_component_file
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);
   my $spirit_component_file         = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$library,$component,$version )); 


   push(@filelist_hier,"::${vendor}::${library}::${component}::${version}::");

foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef")) 
   {
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
            my $hier_ref_type      = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;

     if($hier_ref_type eq "spirit:component")
     {
     my  @filelist_sub = parse_component_file($new_vendor,$new_library,$new_name,$new_version);
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
     }


     elsif($hier_ref_type eq "spirit:designConfiguration")
     {

        my $spirit_designCfg_file    
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version )); 

        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration')) 
           {
           $new_vendor         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
           $new_library        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
           $new_name           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
           $new_version        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
           $hier_ref_type                ="spirit:design";
           }
     }

     if($hier_ref_type eq "spirit:design")
     {
     my  @filelist_sub = parse_design_file($new_vendor,$new_library,$new_name,$new_version);
     foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
     }
  }

   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
   return(@filelist_hier);

}

#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/

sub parse_design_file 
   {
   my @params     = @_;
   my $version    = pop(@params);
   my $component  = pop(@params);
   my $library    = pop(@params);
   my $vendor     = pop(@params);

   $home = cwd();

   push(@filelist_hier,"::${vendor}::${library}::${component}::${version}::");


   my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$vendor,$library,$component,$version )); 


   #/*********************************************************************************************/
   #/                                                                                            */
   #/  Create filelists for simulation, code coverage, linting and synthesis                     */
   #/                                                                                            */
   #/                                                                                            */
   #/*********************************************************************************************/

   if($spirit_design_file)
    {
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
        {
        my($vendor_name)         = $i_name  ->to_literal ;
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;

   my  @filelist_sub = parse_component_file($vendor_name,$library_name,$component_name,$version_name);
   foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }

        }       
    }


   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
   return(@filelist_hier);

   
   }



Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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