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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [soc_link_child] - Diff between revs 134 and 135

Only display areas with differences | Details | Blame | View Log

Rev 134 Rev 135
eval 'exec `which perl` -S $0 ${1+"$@"}'
eval 'exec `which perl` -S $0 ${1+"$@"}'
   if 0;
   if 0;
 
 
#/**********************************************************************/
#/****************************************************************************/
#/*                                                                    */
#/*                                                                    */
#/*             -------                                                */
#/*   SOCGEN Design for Reuse toolset                                        */
#/*            /   SOC  \                                              */
 
#/*           /    GEN   \                                             */
 
#/*          /    TOOL    \                                            */
 
#/*          ==============                                            */
 
#/*          |            |                                            */
 
#/*          |____________|                                            */
 
#/*                                                                    */
 
#/*  Traverse a socgen library and link it                             */
 
#/*                                                                    */
#/*                                                                    */
 
#/*   Version 1.0.0                                                          */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*      - 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                            */
#/*                                                                    */
#/*                                                                    */
#/*    Copyright (C) <2010-2012>                */
#/* 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.                                           */
#/*                                                                    */
#/*                                                                    */
#/*  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
# 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;
use lib './tools';
use lib './tools';
use sys::lib;
use sys::lib;
use yp::lib;
use yp::lib;
$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",
           "prefix=s" => \$prefix,
           "prefix=s" => \$prefix,
           "vendor=s" => \$vendor,
           "vendor=s" => \$vendor,
           "library=s" => \$library,
           "library=s" => \$library,
           "component=s" => \$component,
           "component=s" => \$component,
           "version=s" => \$version
           "version=s" => \$version
) || 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 soc_link_child  -prefix /work -vendor vendor_name -library library_name  -component  component_name -version  version_name   ";
   print "\n type soc_link_child  -prefix /work -vendor vendor_name -library library_name  -component  component_name -version  version_name   ";
   print "\n";
   print "\n";
   exit 1;
   exit 1;
   }
   }
##############################################################################
##############################################################################
##
##
##############################################################################
##############################################################################
my $home              = cwd();
my $home              = cwd();
my $parser           = XML::LibXML->new();
my $parser           = XML::LibXML->new();
my $variant;
my $variant;
if($version) {$variant = "${component}_${version}";}
if($version) {$variant = "${component}_${version}";}
else         {$variant = "${component}";}
else         {$variant = "${component}";}
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/ link overlay librarys                                                                      */
#/ link overlay librarys                                                                      */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
my $socgen_file     = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
my $socgen_file     = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
 
 
foreach  my   $i_name ($socgen_file->findnodes("//socgen:syn/socgen:ise/socgen:chip[socgen:variant/text() = '$variant']"))
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_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_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
   my @replace_components = yp::lib::find_components($replace_vendor,$replace_library);
   my @replace_components = yp::lib::find_components($replace_vendor,$replace_library);
   foreach my $replace_component (@replace_components)
   foreach my $replace_component (@replace_components)
     {
     {
      &link_child($vendor, $library,$replace_component, $replace_library ,$replace_vendor);
      &link_child($vendor, $library,$replace_component, $replace_library ,$replace_vendor);
     }
     }
   }
   }
#/*********************************************************************************************/
#/*********************************************************************************************/
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
my      @filelist      = (  );
my      @filelist      = (  );
@filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");
@filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");
foreach $line (@filelist)
foreach $line (@filelist)
   {
   {
   $_ = $line;
   $_ = $line;
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
     {
     {
     $new_vendor      = $1;
     $new_vendor      = $1;
     $new_proj        = $2;
     $new_proj        = $2;
     $new_comp        = $3;
     $new_comp        = $3;
     $new_version     = $4;
     $new_version     = $4;
     &link_child( $vendor,$library,$new_comp, $new_proj ,$new_vendor);
     &link_child( $vendor,$library,$new_comp, $new_proj ,$new_vendor);
     }
     }
   }
   }
#/*********************************************************************************************/
#/*********************************************************************************************/
#/  link the component and software for each child under the parents work/childern dir        */
#/  link the component and software for each child under the parents work/childern dir        */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
#/*********************************************************************************************/
sub link_child {
sub link_child {
                 my $parent_vendor      = shift;
                 my $parent_vendor      = shift;
                 my $parent_library      = shift;
                 my $parent_library      = shift;
                 my $child_component = shift;
                 my $child_component = shift;
                 my $child_library = shift;
                 my $child_library = shift;
                 my $child_vendor = shift;
                 my $child_vendor = shift;
                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library,$child_component);
                 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 $repo            = yp::lib::find_component_repo($child_vendor,$child_library,$child_component);
 
                 my $child_dir       = yp::lib::get_child_dir;
 
 
 
                 my $path            = "./${child_dir}";
 
 
                 my $path  = ".${prefix}/children";
 
                 mkdir $path,0755             unless( -e $path );
                 mkdir $path,0755             unless( -e $path );
                 my $path  = ".${prefix}/children/${child_vendor}__${child_library}";
                 my $path            = "./${child_dir}/${child_vendor}__${child_library}";
                 mkdir $path,0755             unless( -e $path );
                 mkdir $path,0755             unless( -e $path );
                 my $path  = ".${prefix}/children/${child_vendor}__${child_library}/bin";
 
 
 
                 unless( -e $path )
                 my $path  = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}";
                   {
 
                   mkdir $path,0755;
 
                   $root = "${home}/${repo}/${child_vendor}/${child_library}/bin";
 
                   $dest = "${home}${prefix}/children/${child_vendor}__${child_library}/bin";
 
                   &sys::lib::link_dir( "$root", "$dest"  );
 
                   symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/children/${child_vendor}__${child_library}/bin/Makefile.root");
 
                   symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/children/${child_vendor}__${child_library}/bin/Makefile");
 
                   }
 
 
 
 
 
 
 
                   my $path  = ".${prefix}/children/${child_vendor}__${child_library}${lib_comp_sep}";
 
                   mkdir $path,0755             unless( -e $path );
                   mkdir $path,0755             unless( -e $path );
 
 
                   my $path  = ".${prefix}/children/${child_vendor}__${child_library}${lib_comp_sep}${child_component}";
                 my $path  = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}${child_component}";
 
 
                   unless( -e $path )
                 unless( -e $path )
                   {
                   {
                   mkdir $path,0755;
                   mkdir $path,0755;
                   $root = "${home}/${repo}/${child_vendor}/${child_library}${lib_comp_sep}${child_component}";
                   $root = "${home}/${repo}/${child_vendor}/${child_library}${lib_comp_sep}${child_component}";
                   $dest = ".${prefix}/children/${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"  );
                   &sys::lib::link_dir( "$root", "$dest"  );
 
 
 
 
                   my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($child_vendor,$child_library,$child_component));
                   my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($child_vendor,$child_library,$child_component));
                   my $sim_library_path ;
                   my $sim_library_path ;
                   my $lib_comp_sep             = yp::lib::find_lib_comp_sep($child_vendor,$child_library,$child_component);
                   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;
                   my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
                   if ($sim_comp_path)
                   if ($sim_comp_path)
                      {
                      {
                      $sim_library_path            ="${lib_comp_sep}${sim_comp_path}";
                      $sim_library_path            ="${lib_comp_sep}${sim_comp_path}";
                      }
                      }
                   else
                   else
                      {
                      {
                      $sim_library_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
                      $sim_library_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
                      }
                      }
 
 
                   my $sim_full_path            = ".${prefix}/children/${child_vendor}__${child_library}${sim_library_path}";
                   my $sim_full_path            = "./${child_dir}/${child_vendor}__${child_library}${sim_library_path}";
 
 
                   if(  $sim_library_path)
                   if(  $sim_library_path)
                     {
                     {
                      if(-e $sim_full_path)
                      if(-e $sim_full_path)
                      {
                      {
                      my $cmd = "rm -r    .${prefix}/children/${child_vendor}__${child_library}${sim_library_path}  \n";
                      my $cmd = "rm -r    ./${child_dir}/${child_vendor}__${child_library}${sim_library_path}  \n";
                      if (system($cmd)) {}
                      if (system($cmd)) {}
                      }
                      }
                     }
                     }
                   my $syn_library_path ;
                   my $syn_library_path ;
                   my $syn_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:comp_path/text()")->to_literal;
                   my $syn_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:comp_path/text()")->to_literal;
                   if ($syn_comp_path)
                   if ($syn_comp_path)
                      {
                      {
                      $syn_library_path            ="${lib_comp_sep}${syn_comp_path}";
                      $syn_library_path            ="${lib_comp_sep}${syn_comp_path}";
                      }
                      }
                   else
                   else
                      {
                      {
                      $syn_library_path           = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:library_path/text()")->to_literal;
                      $syn_library_path           = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:library_path/text()")->to_literal;
                      }
                      }
 
 
                   my $syn_full_path            = ".${prefix}/children/${child_vendor}__${child_library}${syn_library_path}";
                   my $syn_full_path            = "./${child_dir}/${child_vendor}__${child_library}${syn_library_path}";
 
 
                   if(  $syn_library_path)
                   if(  $syn_library_path)
                     {
                     {
                   if(-e $syn_full_path)
                   if(-e $syn_full_path)
                    {
                    {
 
 
                    my $cmd = "rm -r    .${prefix}/children/${child_vendor}__${child_library}${syn_library_path}  \n";
                    my $cmd = "rm -r    ./${child_dir}/${child_vendor}__${child_library}${syn_library_path}  \n";
                    if (system($cmd)) {}
                    if (system($cmd)) {}
                    }
                    }
                    }
                    }
                 }
                 }
                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);
                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);
 
 
                 if($lib_sw_dir)
                 if(defined $lib_sw_dir & length $lib_sw_dir > 0 )
                   {
                   {
                   my $path  = ".${prefix}/children/${child_vendor}__${child_library}${lib_sw_dir}";
                   my $path  = "./code";
 
                   mkdir $path,0755             unless( -e $path );
 
                      $path  = "./code/${child_vendor}__${child_library}";
                   unless( -e $path )
                   unless( -e $path )
                     {
                     {
                     mkdir $path,0755;
                     mkdir $path,0755;
                     $root = "${home}/${repo}/${child_vendor}/${child_library}${lib_sw_dir}";
                     $root = "${home}/${repo}/${child_vendor}/${child_library}/${lib_sw_dir}";
                     $dest = "${home}${prefix}/children/${child_vendor}__${child_library}${lib_sw_dir}";
                     $dest = "${home}/code/${child_vendor}__${child_library}";
                     &sys::lib::link_dir( "$root", "$dest"  );
                     &sys::lib::link_dir( "$root", "$dest"  );
                     }
                     }
                   }
                   }
               }
               }
 
 

powered by: WebSVN 2.1.0

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