eval 'exec `which perl` -S $0 ${1+"$@"}'
|
eval 'exec `which perl` -S $0 ${1+"$@"}'
|
if 0;
|
if 0;
|
|
|
#/**********************************************************************/
|
#/**********************************************************************/
|
#/* */
|
#/* */
|
#/* ------- */
|
#/* ------- */
|
#/* / SOC \ */
|
#/* / SOC \ */
|
#/* / GEN \ */
|
#/* / GEN \ */
|
#/* / TOOL \ */
|
#/* / TOOL \ */
|
#/* ============== */
|
#/* ============== */
|
#/* | | */
|
#/* | | */
|
#/* |____________| */
|
#/* |____________| */
|
#/* */
|
#/* */
|
#/* Traverse a socgen project and link it */
|
#/* Traverse a socgen project and link it */
|
#/* */
|
#/* */
|
#/* */
|
#/* */
|
#/* Author(s): */
|
#/* Author(s): */
|
#/* - John Eaton, jt_eaton@opencores.org */
|
#/* - John Eaton, jt_eaton@opencores.org */
|
#/* */
|
#/* */
|
#/**********************************************************************/
|
#/**********************************************************************/
|
#/* */
|
#/* */
|
#/* Copyright (C) <2010> */
|
#/* Copyright (C) <2010-2011> */
|
#/* */
|
#/* */
|
#/* This source file may be used and distributed without */
|
#/* This source file may be used and distributed without */
|
#/* restriction provided that this copyright statement is not */
|
#/* restriction provided that this copyright statement is not */
|
#/* removed from the file and that any derivative work contains */
|
#/* removed from the file and that any derivative work contains */
|
#/* the original copyright notice and the associated disclaimer. */
|
#/* the original copyright notice and the associated disclaimer. */
|
#/* */
|
#/* */
|
#/* This source file is free software; you can redistribute it */
|
#/* This source file is free software; you can redistribute it */
|
#/* and/or modify it under the terms of the GNU Lesser General */
|
#/* and/or modify it under the terms of the GNU Lesser General */
|
#/* Public License as published by the Free Software Foundation; */
|
#/* Public License as published by the Free Software Foundation; */
|
#/* either version 2.1 of the License, or (at your option) any */
|
#/* either version 2.1 of the License, or (at your option) any */
|
#/* later version. */
|
#/* later version. */
|
#/* */
|
#/* */
|
#/* This source is distributed in the hope that it will be */
|
#/* This source is distributed in the hope that it will be */
|
#/* useful, but WITHOUT ANY WARRANTY; without even the implied */
|
#/* useful, but WITHOUT ANY WARRANTY; without even the implied */
|
#/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
|
#/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
|
#/* PURPOSE. See the GNU Lesser General Public License for more */
|
#/* PURPOSE. See the GNU Lesser General Public License for more */
|
#/* details. */
|
#/* details. */
|
#/* */
|
#/* */
|
#/* You should have received a copy of the GNU Lesser General */
|
#/* You should have received a copy of the GNU Lesser General */
|
#/* Public License along with this source; if not, download it */
|
#/* Public License along with this source; if not, download it */
|
#/* from http://www.opencores.org/lgpl.shtml */
|
#/* 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 XML::LibXML;
|
|
|
|
|
$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",
|
GetOptions("h","help",
|
|
"vendor=s" => \$vendor,
|
"project=s" => \$project,
|
"project=s" => \$project,
|
"lib_comp_sep=s" => \$lib_comp_sep,
|
"lib_comp_sep=s" => \$lib_comp_sep,
|
"component=s" => \$component,
|
"component=s" => \$component,
|
"comp_xml_sep=s" => \$comp_xml_sep,
|
"comp_xml_sep=s" => \$comp_xml_sep,
|
"variant=s" => \$variant
|
"variant=s" => \$variant
|
) || die "(use '$program_name -h' for help)";
|
) || die "(use '$program_name -h' for help)";
|
|
|
|
|
##############################################################################
|
##############################################################################
|
## Help option
|
## Help option
|
##############################################################################
|
##############################################################################
|
if ( ($opt_h eq "1") )
|
if ( $opt_h or $opt_help )
|
{
|
{
|
print "\n type soc_link_2 work/project component variant";
|
print "\n type soc_link_child -vendor vendor_name -project project_name -lib_comp_sep /ip/ -component component_name -comp_xml_sep /rtl/xml/ -variant variant_name new_seperator";
|
print "\n";
|
print "\n";
|
exit 1;
|
exit 1;
|
}
|
}
|
|
|
|
|
##############################################################################
|
##############################################################################
|
##
|
##
|
##############################################################################
|
##############################################################################
|
use Cwd;
|
|
use XML::LibXML;
|
|
|
|
$home = cwd();
|
$home = cwd();
|
my $new_sep = $ARGV[0];
|
my $new_sep = $ARGV[0];
|
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
|
|
|
|
my @filelist_hier = ( );
|
my @filelist_hier = ( );
|
my @filelist = ( );
|
my @filelist = ( );
|
|
|
@filelist_hier = ( );
|
@filelist_hier = ( );
|
@filelist = ( );
|
@filelist = ( );
|
@filelist = parse_hier("$project","$component",$new_sep,"$variant");
|
@filelist = parse_hier("$vendor","$project","$component",$new_sep,"$variant");
|
@filelist = trim_sort(@filelist);
|
@filelist = trim_sort(@filelist);
|
|
|
|
|
|
|
foreach $line (@filelist)
|
foreach $line (@filelist)
|
{
|
{
|
$_ = $line;
|
$_ = $line;
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
{
|
{
|
$new_proj = $1;
|
$new_proj = $1;
|
$new_comp = $2;
|
$new_comp = $2;
|
$xxx_sep = $3;
|
$xxx_sep = $3;
|
$new_variant = $4;
|
$new_variant = $4;
|
if($new_proj ne $project ) { &link_child( $project,$new_comp, $new_proj ); }
|
if($new_proj ne $project ) { &link_child( $project,$new_comp, $new_proj ); }
|
}
|
}
|
}
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
|
|
|
|
sub link_child {
|
sub link_child {
|
my $project = shift;
|
my $project = shift;
|
my $child_parent = shift;
|
my $child_parent = shift;
|
my $child_family = shift;
|
my $child_family = shift;
|
my $path = "work/${project}/children";
|
my $path = "work/${project}/children";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
my $path = "work/${project}/children/${child_family}";
|
my $path = "work/${project}/children/${child_family}";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
my $path = "work/${project}/children/${child_family}/bin";
|
my $path = "work/${project}/children/${child_family}/bin";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
$root = "${home}/projects/${child_family}/bin";
|
$root = "${home}/projects/${vendor}/${child_family}/bin";
|
$dest = "${home}/work/${project}/children/${child_family}/bin";
|
$dest = "${home}/work/${project}/children/${child_family}/bin";
|
&link_dir( "$root", "$dest" );
|
&link_dir( "$root", "$dest" );
|
symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/children/${child_family}/bin/Makefile.root");
|
symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/children/${child_family}/bin/Makefile.root");
|
symlink( "${home}/tools/bin/Makefile", "${home}/work/${project}/children/${child_family}/bin/Makefile");
|
symlink( "${home}/tools/bin/Makefile", "${home}/work/${project}/children/${child_family}/bin/Makefile");
|
my $path = "work/${project}/children/${child_family}/sw";
|
my $path = "work/${project}/children/${child_family}/sw";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
$root = "${home}/projects/${child_family}/sw";
|
$root = "${home}/projects/${vendor}/${child_family}/sw";
|
$dest = "${home}/work/${project}/children/${child_family}/sw";
|
$dest = "${home}/work/${project}/children/${child_family}/sw";
|
&link_dir( "$root", "$dest" );
|
&link_dir( "$root", "$dest" );
|
my $path = "work/${project}/children/${child_family}/ip";
|
my $path = "work/${project}/children/${child_family}/ip";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}";
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
|
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
$root = "${home}/projects/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
$root = "${home}/projects/${vendor}/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
$dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
$dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
|
&link_dir( "$root", "$dest" );
|
&link_dir( "$root", "$dest" );
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc";
|
my $path = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc";
|
mkdir $path,0755 unless( -e $path );
|
mkdir $path,0755 unless( -e $path );
|
symlink( "${home}/projects/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v", "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v");
|
symlink( "${home}/projects/${vendor}/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v", "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v");
|
|
|
}
|
}
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
# recursively map directory information
|
# recursively map directory information
|
|
|
sub link_dir {
|
sub link_dir {
|
my $src = shift;
|
my $src = shift;
|
my $dest = shift;
|
my $dest = shift;
|
return unless( -e $src );
|
return unless( -e $src );
|
|
|
if( -d $src )
|
if( -d $src )
|
{
|
{
|
|
|
mkdir $dest,0755;
|
mkdir $dest,0755;
|
my @contents = ( );
|
my @contents = ( );
|
opendir( DIR, $src );
|
opendir( DIR, $src );
|
while( my $item = readdir( DIR ))
|
while( my $item = readdir( DIR ))
|
{
|
{
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
next if( $item eq '.' or $item eq '..' or $item eq '.svn' );
|
push( @contents, $item );
|
push( @contents, $item );
|
}
|
}
|
closedir( DIR );
|
closedir( DIR );
|
|
|
# recurse on items in the directory
|
# recurse on items in the directory
|
foreach my $item ( @contents ) { &link_dir("$src/$item", "$dest/$item" );}
|
foreach my $item ( @contents ) { &link_dir("$src/$item", "$dest/$item" );}
|
|
|
|
|
}
|
}
|
else {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
|
else {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
|
}
|
}
|
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
sub trim_sort {
|
sub trim_sort {
|
my @output_files = @_;
|
my @output_files = @_;
|
my %trim = ();
|
my %trim = ();
|
foreach $descriptor (@output_files) { $trim{$descriptor} = 1; }
|
foreach $descriptor (@output_files) { $trim{$descriptor} = 1; }
|
my @k = keys %trim;
|
my @k = keys %trim;
|
@output_files = sort(sort @k);
|
@output_files = sort(sort @k);
|
return(@output_files);
|
return(@output_files);
|
}
|
}
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
sub parse_hier
|
sub parse_hier
|
{
|
{
|
my @params = @_;
|
my @params = @_;
|
my $variant = pop(@params);
|
my $variant = pop(@params);
|
my $comp_xml = pop(@params);
|
my $comp_xml = pop(@params);
|
my $component = pop(@params);
|
my $component = pop(@params);
|
my $project = pop(@params);
|
my $project = pop(@params);
|
|
my $vendor = pop(@params);
|
|
|
$home = cwd();
|
$home = cwd();
|
|
|
|
|
|
|
my $parser = XML::LibXML->new();
|
my $parser = XML::LibXML->new();
|
my $doc = $parser->parse_file("${home}/projects/${project}${lib_comp_sep}${component}${comp_xml}${variant}.xml");
|
my $doc = $parser->parse_file("${home}/projects/${vendor}/${project}${lib_comp_sep}${component}${comp_xml}${variant}.xml");
|
|
|
foreach my $comp ($doc->findnodes('//spirit:component'))
|
foreach my $comp ($doc->findnodes('//spirit:component'))
|
{
|
{
|
|
|
my($vendor) = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
|
my($vendor) = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
|
my($library) = $comp->findnodes('./spirit:library/text()')->to_literal ;
|
my($library) = $comp->findnodes('./spirit:library/text()')->to_literal ;
|
my($name) = $comp->findnodes('./spirit:name/text()')->to_literal ;
|
my($name) = $comp->findnodes('./spirit:name/text()')->to_literal ;
|
my($version) = $comp->findnodes('./spirit:version/text()')->to_literal ;
|
my($version) = $comp->findnodes('./spirit:version/text()')->to_literal ;
|
|
|
my $variant = "";
|
my $variant = "";
|
if($version) {$variant = "${name}_${version}"}
|
if($version) {$variant = "${name}_${version}"}
|
else {$variant = "${name}"}
|
else {$variant = "${name}"}
|
|
|
|
|
|
|
|
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
#/ */
|
#/ */
|
#/ Create filelists for simulation, code coverage, linting and synthesis */
|
#/ Create filelists for simulation, code coverage, linting and synthesis */
|
#/ */
|
#/ */
|
#/ */
|
#/ */
|
#/*********************************************************************************************/
|
#/*********************************************************************************************/
|
|
|
push(@filelist_hier,"::${library}::${name}::${comp_xml}::${variant}::");
|
push(@filelist_hier,"::${library}::${name}::${comp_xml}::${variant}::");
|
|
|
foreach my $i_name ($doc->findnodes("//spirit:component/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
|
foreach my $i_name ($doc->findnodes("//spirit:component/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
|
{
|
{
|
|
my($vendor_name) = $i_name ->findnodes('../spirit:componentRef/spirit:vendor/text()')->to_literal ;
|
my($library_name) = $i_name ->findnodes('../spirit:componentRef/spirit:library/text()')->to_literal ;
|
my($library_name) = $i_name ->findnodes('../spirit:componentRef/spirit:library/text()')->to_literal ;
|
my($component_name) = $i_name ->findnodes('../spirit:componentRef/spirit:name/text()')->to_literal ;
|
my($component_name) = $i_name ->findnodes('../spirit:componentRef/spirit:name/text()')->to_literal ;
|
my($version_name) = $i_name ->findnodes('../spirit:componentRef/spirit:version/text()')->to_literal ;
|
my($version_name) = $i_name ->findnodes('../spirit:componentRef/spirit:version/text()')->to_literal ;
|
|
|
my $variant_name = "";
|
my $variant_name = "";
|
if($version_name) {$variant_name = "${component_name}_${version_name}";}
|
if($version_name) {$variant_name = "${component_name}_${version_name}";}
|
else {$variant_name = "${component_name}";}
|
else {$variant_name = "${component_name}";}
|
|
|
my @filelist_sub = parse_hier("$library_name","$component_name","$comp_xml_sep","$variant_name");
|
my @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$comp_xml_sep","$variant_name");
|
foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
|
foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
|
|
|
}
|
}
|
}
|
}
|
|
|
@filelist_hier = trim_sort(@filelist_hier);
|
@filelist_hier = trim_sort(@filelist_hier);
|
return(@filelist_hier);
|
return(@filelist_hier);
|
}
|
}
|
|
|