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

Subversion Repositories socgen

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

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 project and link it                             */
#/*                                                                    */
#/*                                                                    */
#/*  Author(s):                                                        */
#/*      - John Eaton, jt_eaton@opencores.org                          */
#/*                                                                    */
#/**********************************************************************/
#/*                                                                    */
#/*    Copyright (C) <2010>  <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 Cwd;
use XML::LibXML;




#/*********************************************************************************************/
#/ 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 $root = "projects";
$home = cwd();
my  $prefix = "/work/";
$lib_comp_sep = "/ip/";
$comp_xml_sep = "/rtl/xml/";
$tb_xml_sep = "/sim/xml/";


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

&link_sub( $root,$root, "work" );


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


@projects = qx(ls  ${home}${prefix}    );


foreach my $project (@projects) 
   {        
   chomp($project);
   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/${project}/bin/* \n";
   if (system($cmd)) {}

   my @components = qx(ls  ${home}/work/${project}/ip    );
   foreach my $component (@components) 
      {
      chomp($component);

      my $parser = XML::LibXML->new();
      my $doc    = $parser->parse_file("${home}${prefix}${project}${lib_comp_sep}${component}/soc/design.soc");

         {

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



         foreach  my   $i_name ($doc->findnodes("//components/component/name"))
            {
            my($comp_name)  = $i_name ->findnodes('./text()')->to_literal ;
            my($comp_version)  = $i_name ->findnodes('../version/text()')->to_literal ;
            my($variant)  = $i_name ->findnodes('../variant/text()')->to_literal ;
            $cmd ="./tools/sys/build_geda   $project  $component  /n";
            if (system($cmd)) {}
            }







         foreach  my   $i_name ($doc->findnodes("//components/component/name"))
            {
            my($comp_name)  = $i_name ->findnodes('./text()')->to_literal ;
            my($comp_version)  = $i_name ->findnodes('../version/text()')->to_literal ;
            my($variant)  = $i_name ->findnodes('../variant/text()')->to_literal ;
            $cmd ="./tools/sys/soc_link_child -project $project -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep -variant $variant $comp_xml_sep /n";
            if (system($cmd)) {}
            }


         foreach  my   $i_name ($doc->findnodes("//testbenchs/testbench/name"))
            {
            my($tb_name)  = $i_name ->findnodes('./text()')->to_literal ;
            my($tb_version)  = $i_name ->findnodes('../version/text()')->to_literal ;
            my($tb_variant)  = $i_name ->findnodes('../variant/text()')->to_literal ;
            $cmd ="./tools/sys/soc_link_child -project $project -lib_comp_sep $lib_comp_sep -component $component -comp_xml_sep $comp_xml_sep -variant $tb_variant $tb_xml_sep /n";
            if (system($cmd)) {}
            }


         #/*********************************************************************************************/
         #/   link chip files for synthesys                                                            */
         #/                                                                                            */
         #/                                                                                            */
         #/                                                                                            */
         #/                                                                                            */
         #/                                                                                            */
         #/*********************************************************************************************/
         
         print "Linking targets for   $project  $component      \n"; 
         foreach  my   $i_name ($doc->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/${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/${chip}/target";
            mkdir $path,0755          unless( -e $path );
         
            &link_dir( "${home}/projects/${project}/targets/${chip_target}", "${home}${prefix}${project}${lib_comp_sep}${component}/syn/${chip}/target"  );
            &link_dir( "${home}/projects/cde/ip",                            "${home}${prefix}${project}${lib_comp_sep}${component}/syn/${chip}/target/lib/ip"  );
            &link_dir( "${home}/tools/Jtag_programmers/debug",               "${home}${prefix}${project}${lib_comp_sep}${component}/syn/${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.