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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [workspace] - Rev 123

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

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

#/**********************************************************************/
#/*                                                                    */
#/*             -------                                                */
#/*            /   SOC  \                                              */
#/*           /    GEN   \                                             */
#/*          /    TOOL    \                                            */
#/*          ==============                                            */
#/*          |            |                                            */
#/*          |____________|                                            */
#/*                                                                    */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/**********************************************************************/
#/*                                                                    */
#/*    Copyright (C) <2010-2011>  <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                          */
#/*                                                                    */
#/**********************************************************************/

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.




#/*********************************************************************************************/
#/ We never generate files into a RCS database.                                               */
#/                                                                                            */
#/ A special work area is created that is the image of the database using symbolic links      */
#/                                                                                            */
#/*********************************************************************************************/

my $home    = cwd();
my $root    = $ARGV[0];
my $prefix  = $ARGV[1];

chomp($root);
chomp($prefix);


$_ = $root;

if(/\/(\S+)\/(\S+)\/(\S+)/) 
     { 
     $projects_dir   = $1;
     $vendor         = $2;
     $project        = $3;
     }

$root = "${projects_dir}/${vendor}/${project}/";


unless ( -e $root )
     { 
     print "ERROR: Project   $root  does not exist \n";
     exit(0);
     }


unless (  $prefix )
     { 
     $prefix   = "/work";
     }


my $path = "${home}${prefix}";

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


$path    = "${home}${prefix}/${vendor}__${project}";
mkdir $path,0755          unless( -e $path );


print "Building Workspace ${prefix}/${vendor}__${project} from   ./${projects_dir}/${vendor}/${project}/   \n";


&link_sub( $root,$root, ".${prefix}/${vendor}__${project}" );


#/*********************************************************************************************/
#/                                                                                            */
#/ Each project is given access to the system tools by giving each of them a link to the      */
#/ Master Makefiles in tools/bin                                                              */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/



if (system("chmod 755    ${home}/${projects_dir}/${vendor}/${project}/bin/* \n"   )) {}


symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/${vendor}__${project}/bin/Makefile.root");
symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/${vendor}__${project}/bin/Makefile");



my $path  = "${home}${prefix}/${vendor}__${project}/children";
mkdir $path,0755          unless( -e $path );



my @components =       yp::lib::find_components("socgen:ip",$vendor,$project);
foreach my $component (@components) 
   {
   my $parser = XML::LibXML->new();

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

   foreach $comp_version (@versions)
     {
     $cmd ="./tools/sys/soc_link_child -prefix $prefix -vendor $vendor -project $project  -component $component -version $comp_version $projects_dir  \n";
     if (system($cmd)) {}
     }

   print "Linking simulations for  $vendor  $project  $component      \n";

   foreach  my   $i_name ($socgen_ip_file->findnodes("//socgen:testbenches/socgen:testbench/socgen:version"))
      {

      my($tb_version)  = $i_name ->findnodes('./text()')->to_literal ;

      $cmd ="./tools/sys/soc_link_child -prefix $prefix -vendor ${vendor}  -project $project  -component $component       -version $tb_version  $projects_dir  \n";
      if (system($cmd)) {}
      }

   #/*********************************************************************************************/
   #/   link chip files for synthesys                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/                                                                                            */
   #/*********************************************************************************************/
   
   print "Linking synthesys targets for  $vendor  $project  $component      \n";
   my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);

 
   foreach  my   $i_name ($socgen_ip_file->findnodes("//socgen:chips/socgen:chip/socgen:name"))
      {
      my($chip_name)  = $i_name ->findnodes('./text()')->to_literal ;
      my($chip_target)  = $i_name ->findnodes('../socgen:target/socgen:library/text()')->to_literal ;
      my($chip_part)  = $i_name ->findnodes('../socgen:target/socgen:part/text()')->to_literal ;
      $outfile ="${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}/syn/ise/${chip_name}/Makefile";
      open  MAKSYNFILE,">$outfile" or die "unable to open $outfile";
      print MAKSYNFILE  "include ../../../../../bin/Makefile.root\n";
      print MAKSYNFILE  "Part=${chip_part}\n";
      print MAKSYNFILE  "board=${chip_target}\n";
      print MAKSYNFILE  "Design=${chip_name}\n";
      my $path  = "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}/syn/ise/${chip_name}/target";
      mkdir $path,0755          unless( -e $path );
      &sys::lib::link_dir( "${home}/tools/synthesys/targets/ip/${chip_target}", "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}/syn/ise/${chip_name}/target"  );
      &sys::lib::link_dir( "${home}/tools/Jtag_programmers/debug", "${home}${prefix}/${vendor}__${project}${lib_comp_sep}/${component}/syn/ise/${chip_name}/debug"  );
      }
   }
   




#/*********************************************************************************************/
#/   recursively map directory information                                                    */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/
 

sub link_sub {
    my $root = shift;
    my $path = shift;
    my $dest = shift;
    return unless( -e $path );
 
    my $dest_path = $path;
      $dest_path =~ s/$root/$dest/;

    if( -d $path ) 
      {
      mkdir $dest_path,0755;

      my @contents = (  );
      opendir( DIR, $path );
      while( my $item = readdir( DIR )) 
           {
           next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
           push( @contents, $item );
           }
      closedir( DIR );
 
      # recurse on items in the directory
      foreach my $item ( @contents )          { &link_sub($root, "$path/$item", $dest );}
 

      } 
    else 
      {
       symlink( "${home}/${path}", $dest_path);
      }
}


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.