URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [tools/] [sys/] [soc_link_child] - Rev 133
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 library 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,
"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:ise/socgen:chip[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 $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}/${repo}/${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 $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}/${repo}/${child_vendor}/${child_library}${lib_comp_sep}${child_component}";
$dest = ".${prefix}/${parent_vendor}__${parent_library}/children/${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 = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${sim_library_path}";
if( $sim_library_path)
{
if(-e $sim_full_path)
{
my $cmd = "rm -r .${prefix}/${parent_vendor}__${parent_library}/children/${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 = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${syn_library_path}";
if( $syn_library_path)
{
if(-e $syn_full_path)
{
my $cmd = "rm -r .${prefix}/${parent_vendor}__${parent_library}/children/${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($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}/${repo}/${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" );
}
}
}
Go to most recent revision | Compare with Previous | Blame | View Log