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

Subversion Repositories socgen

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

Compare with Previous | Blame | View Log

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

#/****************************************************************************/
#/*                                                                          */
#/*   SOCGEN Design for Reuse toolset                                        */
#/*                                                                          */
#/*   Version 1.0.0                                                          */
#/*                                                                          */
#/*   Author(s):                                                             */
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
#/*                                                                          */
#/****************************************************************************/
#/*                                                                          */
#/*                                                                          */
#/*             Copyright 2016 John T Eaton                                  */ 
#/*                                                                          */
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
#/* you may not use this file except in compliance with the License.         */
#/* You may obtain a copy of the License at                                  */
#/*                                                                          */
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
#/*                                                                          */
#/* Unless required by applicable law or agreed to in writing, software      */
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
#/* See the License for the specific language governing permissions and      */
#/* limitations under the License.                                           */
#/*                                                                          */
#/*                                                                          */
#/****************************************************************************/


############################################################################
# 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,
           "library=s" => \$library,
           "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 -library library_name  -component  component_name -version  version_name   ";
   print "\n";
   exit 1;
   }


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

my $home              = cwd();


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


my $variant;

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



#/*********************************************************************************************/
#/                                                                                            */
#/ link overlay librarys                                                                      */
#/                                                                                            */
#/*********************************************************************************************/




my $socgen_file     = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));


foreach  my   $i_name ($socgen_file->findnodes("//socgen:syn/socgen:fpgas/socgen:fpga[socgen:variant/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($replace_vendor,$replace_library);

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








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



my      @filelist      = (  );

@filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");




foreach $line (@filelist) 
   {
   $_ = $line;
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/) 
     { 
     $new_vendor      = $1;
     $new_proj        = $2;
     $new_comp        = $3;        
     $new_version     = $4;        
     &link_child( $vendor,$library,$new_comp, $new_proj ,$new_vendor); 
     }
   }






#/*********************************************************************************************/
#/  link the component and software for each child under the parents work/childern dir        */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/



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,$child_component);
                 my $repo            = yp::lib::find_component_repo($child_vendor,$child_library,$child_component);
                 my $child_dir       = yp::lib::get_child_dir;

                 my $path            = "./${child_dir}";
                 mkdir $path,0755      unless( -e $path );
                 my $path            = "./${child_dir}/${child_vendor}__${child_library}";
                 mkdir $path,0755      unless( -e $path );
                 
                 my $path  = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}";
                 mkdir $path,0755             unless( -e $path );
                   
                 my $path  = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}${child_component}";


                 unless( -e $path )
                   {
                   mkdir $path,0755;

                   $root = "${home}/${repo}/${child_vendor}/${child_library}${lib_comp_sep}${child_component}";
                   $dest = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}${child_component}";
                   &sys::lib::link_dir( "$root", "$dest"  );
                   
                   my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($child_vendor,$child_library,$child_component));
                   my $sim_library_path ;
                   my $lib_comp_sep             = yp::lib::find_lib_comp_sep($child_vendor,$child_library,$child_component);
                   my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;

                   if ($sim_comp_path)
                      {
                      $sim_library_path            ="${lib_comp_sep}${sim_comp_path}";
                      }
                   else
                      {
                      $sim_library_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
                      }

                   my $sim_full_path            = "./${child_dir}/${child_vendor}__${child_library}${sim_library_path}";     


                   if(  $sim_library_path)
                     {  
                      if(-e $sim_full_path)  
                      { 
                      my $cmd = "rm -r    ./${child_dir}/${child_vendor}__${child_library}${sim_library_path}  \n";     
                      if (system($cmd)) {}
                      }
                     }


                   my $syn_library_path ;

                   my $syn_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:comp_path/text()")->to_literal;

                   if ($syn_comp_path)
                      {
                      $syn_library_path            ="${lib_comp_sep}${syn_comp_path}";
                      }
                   else
                      {
                      $syn_library_path           = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:library_path/text()")->to_literal;
                      }


                   my $syn_full_path            = "./${child_dir}/${child_vendor}__${child_library}${syn_library_path}";     

                   if(  $syn_library_path)
                     {  
                   if(-e $syn_full_path)  
                    { 

                    my $cmd = "rm -r    ./${child_dir}/${child_vendor}__${child_library}${syn_library_path}  \n";     
                    if (system($cmd)) {}
                    }
                    }



                 }


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

                 if(defined $lib_sw_dir & length $lib_sw_dir > 0 )
                   {
                   my $path  = "./code";
                   mkdir $path,0755             unless( -e $path );
                      $path  = "./code/${child_vendor}__${child_library}";
                   unless( -e $path )
                     {
                     mkdir $path,0755;         
                     $root = "${home}/${repo}/${child_vendor}/${child_library}/${lib_sw_dir}";
                     $dest = "${home}/code/${child_vendor}__${child_library}";
                     &sys::lib::link_dir( "$root", "$dest"  );
                     }
                   }









               }






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.