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

Subversion Repositories socgen

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

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.

my $home         = cwd();


#/*********************************************************************************************/
#/ 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 $project = $ARGV[0];
my $vendor  = $ARGV[1];
chomp($project);
chomp($vendor);

unless ($project) {$project ="fpgas";}
unless ($vendor)  {$vendor  ="opencores.org";}


my $root      = "projects/${vendor}/${project}";

my  $prefix   = "/work/";
$lib_comp_sep = "/ip";



my $path  = "${home}${prefix}";
mkdir $path,0755          unless( -e $path );



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


print "Building a work area for ${home}/${root} in ${home}${prefix}  \n" ;

&link_sub( $root,$root, "work/${project}" );


#/*********************************************************************************************/
#/                                                                                            */
#/ Each project is given access to the system tools by giving each of them a link to the      */
#/ Master Makefiles in tools/bin                                                              */
#/                                                                                            */
#/ Every component in a project is given access to the system testbench/models and CDE        */
#/ library files via symbolic links                                                           */
#/                                                                                            */
#/*********************************************************************************************/





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

   $cmd ="chmod 755    ${home}/projects/${vendor}/${project}/bin/* \n";
   if (system($cmd)) {}

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



   my @components =       yp::lib::find_components("socgen:ip",$vendor,$project);
   foreach my $component (@components) 
      {
      $cmd ="./tools/sys/build_geda   $project  $component $vendor /n";
      if (system($cmd)) {}

      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 -vendor $vendor -project $project -lib_comp_sep $lib_comp_sep -component $component -version $comp_version   /n";
        if (system($cmd)) {}
        }



      foreach  my   $i_name ($socgen_ip_file->findnodes("//testbenchs/testbench/name"))
         {
         my($tb_name)  = $i_name ->findnodes('./text()')->to_literal ;
         my($tb_version)  = $i_name ->findnodes('../version/text()')->to_literal ;

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

      #/*********************************************************************************************/
      #/   link chip files for synthesys                                                            */
      #/                                                                                            */
      #/                                                                                            */
      #/                                                                                            */
      #/                                                                                            */
      #/                                                                                            */
      #/*********************************************************************************************/
      
      print "Linking targets for   $project  $component      \n"; 
      foreach  my   $i_name ($socgen_ip_file->findnodes("//chips/chip/name"))
         {
         my($chip)  = $i_name ->findnodes('./text()')->to_literal ;
         my($chip_target)  = $i_name ->findnodes('../target/text()')->to_literal ;
         my($configuration)  = $i_name ->findnodes('../configuration/text()')->to_literal;
         my($variant)  = $i_name ->findnodes('../variant/text()')->to_literal ;
      
         $outfile ="${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip}/Makefile";
         open  MAKSYNFILE,">$outfile" or die "unable to open $outfile";
      
         print MAKSYNFILE  "include ../../../../../bin/Makefile.root\n";
         print MAKSYNFILE  "include ./target/Makefile.brd\n";
         print MAKSYNFILE  "board=${chip_target}\n";
         print MAKSYNFILE  "Design=${chip_target}_${configuration}\n";
         my $path  = "${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip}/target";
         mkdir $path,0755          unless( -e $path );
      
         &link_dir( "${home}/projects/${vendor}/targets/ip/${chip_target}", "${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip}/target"  );
         &link_dir( "${home}/projects/${vendor}/cde/ip",                            "${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip}/target/lib/ip"  );
         &link_dir( "${home}/tools/Jtag_programmers/debug",               "${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip}/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);
    }
}


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

# recursively map directory information 

sub link_dir {
    my $src  = shift;
    my $dest = shift;
    return unless( -e $src );

    if( -d $src ) 
        {

        mkdir $dest,0755;
        my @contents = (  );
        opendir( DIR, $src );
        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_dir("$src/$item", "$dest/$item" );}
 
       } 
       else  {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
}

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.