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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [soc_link_child] - Blame information for rev 99

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

Line No. Rev Author Line
1 94 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
 
4
#/**********************************************************************/
5
#/*                                                                    */
6
#/*             -------                                                */
7
#/*            /   SOC  \                                              */
8
#/*           /    GEN   \                                             */
9
#/*          /    TOOL    \                                            */
10
#/*          ==============                                            */
11
#/*          |            |                                            */
12
#/*          |____________|                                            */
13
#/*                                                                    */
14
#/*  Traverse a socgen project and link it                             */
15
#/*                                                                    */
16
#/*                                                                    */
17
#/*  Author(s):                                                        */
18
#/*      - John Eaton, jt_eaton@opencores.org                          */
19
#/*                                                                    */
20
#/**********************************************************************/
21
#/*                                                                    */
22 99 jt_eaton
#/*    Copyright (C) <2010-2011>                */
23 94 jt_eaton
#/*                                                                    */
24
#/*  This source file may be used and distributed without              */
25
#/*  restriction provided that this copyright statement is not         */
26
#/*  removed from the file and that any derivative work contains       */
27
#/*  the original copyright notice and the associated disclaimer.      */
28
#/*                                                                    */
29
#/*  This source file is free software; you can redistribute it        */
30
#/*  and/or modify it under the terms of the GNU Lesser General        */
31
#/*  Public License as published by the Free Software Foundation;      */
32
#/*  either version 2.1 of the License, or (at your option) any        */
33
#/*  later version.                                                    */
34
#/*                                                                    */
35
#/*  This source is distributed in the hope that it will be            */
36
#/*  useful, but WITHOUT ANY WARRANTY; without even the implied        */
37
#/*  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR           */
38
#/*  PURPOSE.  See the GNU Lesser General Public License for more      */
39
#/*  details.                                                          */
40
#/*                                                                    */
41
#/*  You should have received a copy of the GNU Lesser General         */
42
#/*  Public License along with this source; if not, download it        */
43
#/*  from http://www.opencores.org/lgpl.shtml                          */
44
#/*                                                                    */
45
#/**********************************************************************/
46
 
47
 
48
############################################################################
49
# General PERL config
50
############################################################################
51
use Getopt::Long;
52
use English;
53
use File::Basename;
54 99 jt_eaton
use Cwd;
55
use XML::LibXML;
56 94 jt_eaton
 
57 99 jt_eaton
 
58 94 jt_eaton
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
59
 
60
 
61
 
62
 
63
############################################################################
64
### Process the options
65
############################################################################
66
 
67
Getopt::Long::config("require_order", "prefix=-");
68 99 jt_eaton
GetOptions("h","help",
69
           "vendor=s" => \$vendor,
70 94 jt_eaton
           "project=s" => \$project,
71
           "lib_comp_sep=s" => \$lib_comp_sep,
72
           "component=s" => \$component,
73
           "comp_xml_sep=s" => \$comp_xml_sep,
74
           "variant=s" => \$variant
75
) || die "(use '$program_name -h' for help)";
76
 
77
 
78
##############################################################################
79
## Help option
80
##############################################################################
81 99 jt_eaton
if ( $opt_h or $opt_help  )
82 94 jt_eaton
   {
83 99 jt_eaton
   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";
84 94 jt_eaton
   print "\n";
85
   exit 1;
86
   }
87
 
88
 
89
##############################################################################
90
##
91
##############################################################################
92
 
93
$home              = cwd();
94
my $new_sep        = $ARGV[0];
95
 
96
 
97
 
98
 
99
#/*********************************************************************************************/
100
#/                                                                                            */
101
#/                                                                                            */
102
#/                                                                                            */
103
#/                                                                                            */
104
#/                                                                                            */
105
#/                                                                                            */
106
#/*********************************************************************************************/
107
 
108
 
109
 
110
my      @filelist_hier = (  );
111
my      @filelist      = (  );
112
 
113
@filelist_hier = (  );
114
@filelist = (  );
115 99 jt_eaton
@filelist = parse_hier("$vendor","$project","$component",$new_sep,"$variant");
116 94 jt_eaton
@filelist = trim_sort(@filelist);
117
 
118
 
119
 
120
foreach $line (@filelist)
121
   {
122
   $_ = $line;
123
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
124
     {
125
     $new_proj      = $1;
126
     $new_comp      = $2;
127
     $xxx_sep       = $3;
128
     $new_variant   = $4;
129
     if($new_proj ne $project ) { &link_child( $project,$new_comp, $new_proj ); }
130
     }
131
   }
132
 
133
 
134
 
135
 
136
 
137
 
138
#/*********************************************************************************************/
139
#/                                                                                            */
140
#/                                                                                            */
141
#/                                                                                            */
142
#/                                                                                            */
143
#/                                                                                            */
144
#/                                                                                            */
145
#/*********************************************************************************************/
146
 
147
 
148
 
149
sub link_child {
150
                 my $project      = shift;
151
                 my $child_parent = shift;
152
                 my $child_family = shift;
153
                 my $path  = "work/${project}/children";
154
                 mkdir $path,0755             unless( -e $path );
155
                 my $path  = "work/${project}/children/${child_family}";
156
                 mkdir $path,0755             unless( -e $path );
157
                 my $path  = "work/${project}/children/${child_family}/bin";
158
                 mkdir $path,0755             unless( -e $path );
159 99 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}/bin";
160 94 jt_eaton
                 $dest = "${home}/work/${project}/children/${child_family}/bin";
161
                 &link_dir( "$root", "$dest"  );
162
                 symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/children/${child_family}/bin/Makefile.root");
163
                 symlink( "${home}/tools/bin/Makefile",      "${home}/work/${project}/children/${child_family}/bin/Makefile");
164
                 my $path  = "work/${project}/children/${child_family}/sw";
165
                 mkdir $path,0755             unless( -e $path );
166 99 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}/sw";
167 94 jt_eaton
                 $dest = "${home}/work/${project}/children/${child_family}/sw";
168
                 &link_dir( "$root", "$dest"  );
169
                 my $path  = "work/${project}/children/${child_family}/ip";
170
                 mkdir $path,0755             unless( -e $path );
171
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}";
172
                 mkdir $path,0755             unless( -e $path );
173
 
174
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
175
                 mkdir $path,0755             unless( -e $path );
176 99 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}${lib_comp_sep}${child_parent}/rtl";
177 94 jt_eaton
                 $dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
178
                 &link_dir( "$root", "$dest"  );
179
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc";
180
                 mkdir $path,0755             unless( -e $path );
181 99 jt_eaton
                 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");
182 94 jt_eaton
 
183
               }
184
 
185
 
186
#/*********************************************************************************************/
187
#/                                                                                            */
188
#/                                                                                            */
189
#/                                                                                            */
190
#/                                                                                            */
191
#/                                                                                            */
192
#/                                                                                            */
193
#/*********************************************************************************************/
194
 
195
# recursively map directory information
196
 
197
sub link_dir {
198
    my $src  = shift;
199
    my $dest = shift;
200
    return unless( -e $src );
201
 
202
    if( -d $src )
203
        {
204
 
205
        mkdir $dest,0755;
206
        my @contents = (  );
207
        opendir( DIR, $src );
208
        while( my $item = readdir( DIR ))
209
            {
210
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
211
            push( @contents, $item );
212
            }
213
        closedir( DIR );
214
 
215
        # recurse on items in the directory
216
        foreach my $item ( @contents )          { &link_dir("$src/$item", "$dest/$item" );}
217
 
218
 
219
       }
220
       else  {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
221
}
222
 
223
 
224
 
225
 
226
#/*********************************************************************************************/
227
#/                                                                                            */
228
#/                                                                                            */
229
#/                                                                                            */
230
#/                                                                                            */
231
#/                                                                                            */
232
#/                                                                                            */
233
#/*********************************************************************************************/
234
 
235
sub trim_sort {
236
   my @output_files  = @_;
237
   my %trim = ();
238
   foreach $descriptor (@output_files) { $trim{$descriptor}  = 1; }
239
   my @k = keys %trim;
240
   @output_files =  sort(sort @k);
241
   return(@output_files);
242
   }
243
 
244
 
245
 
246
#/*********************************************************************************************/
247
#/                                                                                            */
248
#/                                                                                            */
249
#/                                                                                            */
250
#/                                                                                            */
251
#/                                                                                            */
252
#/                                                                                            */
253
#/*********************************************************************************************/
254
 
255
sub parse_hier
256
   {
257
   my @params     = @_;
258
   my $variant    = pop(@params);
259
   my $comp_xml   = pop(@params);
260
   my $component  = pop(@params);
261
   my $project    = pop(@params);
262 99 jt_eaton
   my $vendor    = pop(@params);
263 94 jt_eaton
 
264
   $home = cwd();
265
 
266
 
267
 
268
   my $parser = XML::LibXML->new();
269 99 jt_eaton
   my $doc    = $parser->parse_file("${home}/projects/${vendor}/${project}${lib_comp_sep}${component}${comp_xml}${variant}.xml");
270 94 jt_eaton
 
271
   foreach my $comp ($doc->findnodes('//spirit:component'))
272
      {
273
 
274
      my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
275
      my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
276
      my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
277
      my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
278
 
279
      my $variant = "";
280
      if($version) {$variant = "${name}_${version}"}
281
      else         {$variant = "${name}"}
282
 
283
 
284
 
285
 
286
      #/*********************************************************************************************/
287
      #/                                                                                            */
288
      #/  Create filelists for simulation, code coverage, linting and synthesis                     */
289
      #/                                                                                            */
290
      #/                                                                                            */
291
      #/*********************************************************************************************/
292
 
293
      push(@filelist_hier,"::${library}::${name}::${comp_xml}::${variant}::");
294
 
295
      foreach  my   $i_name ($doc->findnodes("//spirit:component/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
296
         {
297 99 jt_eaton
         my($vendor_name)        = $i_name ->findnodes('../spirit:componentRef/spirit:vendor/text()')->to_literal ;
298 94 jt_eaton
         my($library_name)        = $i_name ->findnodes('../spirit:componentRef/spirit:library/text()')->to_literal ;
299
         my($component_name)      = $i_name ->findnodes('../spirit:componentRef/spirit:name/text()')->to_literal ;
300
         my($version_name)        = $i_name ->findnodes('../spirit:componentRef/spirit:version/text()')->to_literal ;
301
 
302
         my $variant_name   = "";
303
         if($version_name)  {$variant_name = "${component_name}_${version_name}";}
304
         else               {$variant_name = "${component_name}";}
305
 
306 99 jt_eaton
         my  @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$comp_xml_sep","$variant_name");
307 94 jt_eaton
         foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
308
 
309
         }
310
      }
311
 
312
   @filelist_hier     =       trim_sort(@filelist_hier);
313
   return(@filelist_hier);
314
   }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.