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

Subversion Repositories socgen

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

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/";


my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);



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                                                              */
#/                                                                                            */
#/                                                                                            */
#/*********************************************************************************************/





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



      foreach  my   $i_name ($socgen_ip_file->findnodes("//socgen:testbenches/socgen: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  -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_name)  = $i_name ->findnodes('./text()')->to_literal ;
         my($chip_target)  = $i_name ->findnodes('../target/text()')->to_literal ;
         my($chip_part)  = $i_name ->findnodes('../socgen:target/socgen:part/text()')->to_literal ;
         my($chip_configuration)  = $i_name ->findnodes('../configuration/text()')->to_literal;
         my($chip_variant)  = $i_name ->findnodes('../variant/text()')->to_literal ;

         chdir  "${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip_variant}";

         $cmd ="echo \"run -ifn ./filelist.syn    -ifmt mixed -top $chip_name  -ofn  ${chip_name}.ngc -ofmt NGC  -p  $chip_part         -opt_mode Speed -opt_level 1 \" > Xst;   \n";

         if (system($cmd)) {}

         chdir $home;



         $outfile ="${home}${prefix}${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_target}_${chip_configuration}\n";
         my $path  = "${home}${prefix}${project}${lib_comp_sep}/${component}/syn/ise/${chip_name}/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_name}/target"  );

         &link_dir( "${home}/tools/Jtag_programmers/debug",               "${home}${prefix}${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);
    }
}


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

# 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.