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

Subversion Repositories socgen

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

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 119 jt_eaton
#/*    Copyright (C) <2010-2012>                */
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 117 jt_eaton
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59 94 jt_eaton
 
60 99 jt_eaton
 
61 94 jt_eaton
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
 
65
 
66
############################################################################
67
### Process the options
68
############################################################################
69
 
70
Getopt::Long::config("require_order", "prefix=-");
71 99 jt_eaton
GetOptions("h","help",
72 119 jt_eaton
           "prefix=s" => \$prefix,
73 99 jt_eaton
           "vendor=s" => \$vendor,
74 94 jt_eaton
           "project=s" => \$project,
75
           "component=s" => \$component,
76 117 jt_eaton
           "version=s" => \$version
77 119 jt_eaton
 
78 94 jt_eaton
) || die "(use '$program_name -h' for help)";
79
 
80
 
81
##############################################################################
82
## Help option
83
##############################################################################
84 99 jt_eaton
if ( $opt_h or $opt_help  )
85 94 jt_eaton
   {
86 119 jt_eaton
   print "\n type soc_link_child  -prefix /work -vendor vendor_name -project project_name  -component  component_name -version  version_name  projects_dir ";
87 94 jt_eaton
   print "\n";
88
   exit 1;
89
   }
90
 
91
 
92
##############################################################################
93
##
94
##############################################################################
95
 
96 119 jt_eaton
my $home              = cwd();
97 94 jt_eaton
 
98
 
99 117 jt_eaton
my $parser           = XML::LibXML->new();
100 94 jt_eaton
 
101 119 jt_eaton
my $projects_dir    = $ARGV[0];
102
chomp($projects_dir);
103 118 jt_eaton
my $variant;
104 117 jt_eaton
 
105 118 jt_eaton
if($version) {$variant = "${component}_${version}";}
106
else         {$variant = "${component}";}
107 117 jt_eaton
 
108
 
109 118 jt_eaton
 
110 94 jt_eaton
#/*********************************************************************************************/
111
#/                                                                                            */
112 118 jt_eaton
#/ link overlay projects                                                                      */
113 94 jt_eaton
#/                                                                                            */
114 118 jt_eaton
#/*********************************************************************************************/
115
 
116
 
117
 
118
 
119
my $socgen_ip_file     = $parser->parse_file(yp::lib::find_socgen("socgen:ip",$vendor,$project,$component));
120
 
121
 
122
 
123 119 jt_eaton
foreach  my   $i_name ($socgen_ip_file->findnodes("//socgen:chips/socgen:chip[socgen:name/text() = '$variant']"))
124 118 jt_eaton
   {
125
   my($replace_vendor)  = $i_name ->findnodes('socgen:target/socgen:vendor/text()')->to_literal ;
126
   my($replace_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
127 119 jt_eaton
   my @replace_components = yp::lib::find_components("spirit:component",$replace_vendor,$replace_library);
128 118 jt_eaton
 
129
   foreach my $replace_component (@replace_components)
130
     {
131 119 jt_eaton
      &link_child($vendor, $project,$replace_component, $replace_library ,$replace_vendor);
132 118 jt_eaton
     }
133
   }
134
 
135
 
136
 
137
 
138
 
139 120 jt_eaton
 
140
 
141
 
142 118 jt_eaton
#/*********************************************************************************************/
143 94 jt_eaton
#/                                                                                            */
144
#/                                                                                            */
145
#/                                                                                            */
146
#/                                                                                            */
147 118 jt_eaton
#/                                                                                            */
148
#/                                                                                            */
149 94 jt_eaton
#/*********************************************************************************************/
150
 
151
 
152
 
153
my      @filelist_hier = (  );
154
my      @filelist      = (  );
155
 
156
@filelist_hier = (  );
157
@filelist = (  );
158 120 jt_eaton
 
159
@filelist = parse_component_file("$vendor","$project","$component","$version");
160 117 jt_eaton
@filelist = sys::lib::trim_sort(@filelist);
161 94 jt_eaton
 
162
 
163
 
164
foreach $line (@filelist)
165
   {
166
   $_ = $line;
167 120 jt_eaton
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
168 94 jt_eaton
     {
169 119 jt_eaton
     $new_vendor      = $1;
170
     $new_proj        = $2;
171
     $new_comp        = $3;
172 120 jt_eaton
     $new_version     = $4;
173 119 jt_eaton
     if(($new_vendor ne $vendor ) or  ($new_proj ne $project ) )
174
 
175
       { &link_child( $vendor,$project,$new_comp, $new_proj ,$new_vendor); }
176 94 jt_eaton
     }
177
   }
178
 
179
 
180
 
181
 
182
 
183
 
184
#/*********************************************************************************************/
185
#/                                                                                            */
186
#/                                                                                            */
187
#/                                                                                            */
188
#/                                                                                            */
189
#/                                                                                            */
190
#/                                                                                            */
191
#/*********************************************************************************************/
192
 
193
 
194
 
195
sub link_child {
196 119 jt_eaton
                 my $parent_vendor      = shift;
197
                 my $parent_library      = shift;
198
                 my $child_component = shift;
199
                 my $child_library = shift;
200
                 my $child_vendor = shift;
201
 
202
                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library);
203
 
204
 
205
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children";
206 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
207 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}";
208 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
209 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
210 94 jt_eaton
 
211 120 jt_eaton
                 unless( -e $path )
212
                   {
213
                   mkdir $path,0755;
214
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}/bin";
215
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
216
                   &sys::lib::link_dir( "$root", "$dest"  );
217
                   symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile.root");
218
                   symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile");
219
                   }
220 119 jt_eaton
 
221 115 jt_eaton
 
222 120 jt_eaton
                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);
223 115 jt_eaton
 
224 120 jt_eaton
                 if($lib_sw_dir)
225
                   {
226
                   my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
227
                   unless( -e $path )
228
                     {
229
                     mkdir $path,0755;
230
                     $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_sw_dir}";
231
                     $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
232
                     &sys::lib::link_dir( "$root", "$dest"  );
233
                     }
234
                   }
235
 
236
                 #  only works for simple single item paths
237 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}";
238 115 jt_eaton
                 mkdir $path,0755             unless( -e $path );
239 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
240 115 jt_eaton
 
241 120 jt_eaton
                 unless( -e $path )
242
                   {
243
                   mkdir $path,0755;
244
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_comp_sep}/${child_component}";
245
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
246
                   &sys::lib::link_dir( "$root", "$dest"  );
247
                   }
248 94 jt_eaton
               }
249
 
250
 
251
 
252
 
253
 
254 120 jt_eaton
 
255 94 jt_eaton
#/*********************************************************************************************/
256
#/                                                                                            */
257
#/                                                                                            */
258
#/                                                                                            */
259
#/                                                                                            */
260
#/                                                                                            */
261
#/                                                                                            */
262
#/*********************************************************************************************/
263
 
264 120 jt_eaton
 
265
 
266
 
267
sub parse_component_file
268 94 jt_eaton
   {
269
   my @params     = @_;
270 117 jt_eaton
   my $version    = pop(@params);
271 94 jt_eaton
   my $component  = pop(@params);
272 120 jt_eaton
   my $library    = pop(@params);
273 117 jt_eaton
   my $vendor     = pop(@params);
274 120 jt_eaton
   my $spirit_component_file         = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$library,$component,$version ));
275 94 jt_eaton
 
276 120 jt_eaton
 
277
   push(@filelist_hier,"::${vendor}::${library}::${component}::${version}::");
278
 
279
foreach my $new_comp ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:hierarchyRef"))
280
   {
281
            my($new_vendor)        = $new_comp->findnodes('./@spirit:vendor')->to_literal ;
282
            my($new_library)       = $new_comp->findnodes('./@spirit:library')->to_literal ;
283
            my($new_name)          = $new_comp->findnodes('./@spirit:name')->to_literal ;
284
            my($new_version)       = $new_comp->findnodes('./@spirit:version')->to_literal ;
285
            my $hier_ref_type      = yp::lib::find_file_type($new_vendor,$new_library,$new_name,$new_version) ;
286
 
287
     if($hier_ref_type eq "spirit:component")
288
     {
289
     my  @filelist_sub = parse_component_file($new_vendor,$new_library,$new_name,$new_version);
290
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
291
     }
292
 
293
 
294
     elsif($hier_ref_type eq "spirit:designConfiguration")
295
     {
296
 
297
        my $spirit_designCfg_file
298
         = $parser->parse_file(yp::lib::find_ipxact("spirit:designConfiguration",$new_vendor,$new_library,$new_name,$new_version ));
299
 
300
        foreach my $design_ref_view ($spirit_designCfg_file->findnodes('//spirit:designConfiguration'))
301
           {
302
           $new_vendor         = $design_ref_view->findnodes('./spirit:designRef/@spirit:vendor')->to_literal ;
303
           $new_library        = $design_ref_view->findnodes('./spirit:designRef/@spirit:library')->to_literal ;
304 121 jt_eaton
           $new_name           = $design_ref_view->findnodes('./spirit:designRef/@spirit:name')->to_literal ;
305 120 jt_eaton
           $new_version        = $design_ref_view->findnodes('./spirit:designRef/@spirit:version')->to_literal ;
306
           $hier_ref_type                ="spirit:design";
307
           }
308
     }
309
 
310
     if($hier_ref_type eq "spirit:design")
311
     {
312 121 jt_eaton
     my  @filelist_sub = parse_design_file($new_vendor,$new_library,$new_name,$new_version);
313 120 jt_eaton
     foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
314
     }
315
  }
316
 
317
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
318
   return(@filelist_hier);
319
 
320
}
321
 
322
#/*********************************************************************************************/
323
#/                                                                                            */
324
#/                                                                                            */
325
#/                                                                                            */
326
#/                                                                                            */
327
#/                                                                                            */
328
#/                                                                                            */
329
#/*********************************************************************************************/
330
 
331
sub parse_design_file
332
   {
333
   my @params     = @_;
334
   my $version    = pop(@params);
335
   my $component  = pop(@params);
336
   my $library    = pop(@params);
337
   my $vendor     = pop(@params);
338
 
339 94 jt_eaton
   $home = cwd();
340
 
341 120 jt_eaton
   push(@filelist_hier,"::${vendor}::${library}::${component}::${version}::");
342 94 jt_eaton
 
343 121 jt_eaton
 
344 120 jt_eaton
   my $spirit_design_file = $parser->parse_file(yp::lib::find_ipxact("spirit:design",$vendor,$library,$component,$version ));
345 94 jt_eaton
 
346 120 jt_eaton
 
347 101 jt_eaton
   #/*********************************************************************************************/
348
   #/                                                                                            */
349
   #/  Create filelists for simulation, code coverage, linting and synthesis                     */
350
   #/                                                                                            */
351
   #/                                                                                            */
352
   #/*********************************************************************************************/
353 94 jt_eaton
 
354 118 jt_eaton
   if($spirit_design_file)
355
    {
356 101 jt_eaton
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
357 118 jt_eaton
        {
358
        my($vendor_name)         = $i_name  ->to_literal ;
359
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
360
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
361
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
362 94 jt_eaton
 
363 120 jt_eaton
   my  @filelist_sub = parse_component_file($vendor_name,$library_name,$component_name,$version_name);
364
   foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
365 94 jt_eaton
 
366 118 jt_eaton
        }
367
    }
368 94 jt_eaton
 
369 101 jt_eaton
 
370 117 jt_eaton
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
371 94 jt_eaton
   return(@filelist_hier);
372 120 jt_eaton
 
373
 
374 94 jt_eaton
   }
375 117 jt_eaton
 
376
 
377
 

powered by: WebSVN 2.1.0

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