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

Subversion Repositories socgen

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

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 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
           "vendor=s" => \$vendor,
73 94 jt_eaton
           "project=s" => \$project,
74
           "component=s" => \$component,
75 117 jt_eaton
           "version=s" => \$version
76 94 jt_eaton
) || die "(use '$program_name -h' for help)";
77
 
78
 
79
##############################################################################
80
## Help option
81
##############################################################################
82 99 jt_eaton
if ( $opt_h or $opt_help  )
83 94 jt_eaton
   {
84 118 jt_eaton
   print "\n type soc_link_child  -vendor vendor_name -project project_name  -component  component_name -version  version_name   ";
85 94 jt_eaton
   print "\n";
86
   exit 1;
87
   }
88
 
89
 
90
##############################################################################
91
##
92
##############################################################################
93
 
94
$home              = cwd();
95
 
96
 
97 117 jt_eaton
my $parser           = XML::LibXML->new();
98 118 jt_eaton
my $lib_comp_sep    = yp::lib::find_lib_comp_sep($vendor,$project);
99 94 jt_eaton
 
100
 
101 118 jt_eaton
my $variant;
102 117 jt_eaton
 
103 118 jt_eaton
if($version) {$variant = "${component}_${version}";}
104
else         {$variant = "${component}";}
105 117 jt_eaton
 
106
 
107 118 jt_eaton
 
108 94 jt_eaton
#/*********************************************************************************************/
109
#/                                                                                            */
110 118 jt_eaton
#/ link overlay projects                                                                      */
111 94 jt_eaton
#/                                                                                            */
112 118 jt_eaton
#/*********************************************************************************************/
113
 
114
 
115
 
116
 
117
my $socgen_ip_file     = $parser->parse_file(yp::lib::find_socgen("socgen:ip",$vendor,$project,$component));
118
 
119
 
120
 
121
foreach  my   $i_name ($socgen_ip_file->findnodes("//chips/chip[variant/text() = '$variant']"))
122
   {
123
   my($chip)  = $i_name ->findnodes('name/text()')->to_literal ;
124
   my($replace_vendor)  = $i_name ->findnodes('socgen:target/socgen:vendor/text()')->to_literal ;
125
   my($replace_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
126
 
127
   my @replace_components = yp::lib::find_components("spirit:component",$replace_vendor,$replace_library);
128
   foreach my $replace_component (@replace_components)
129
     {
130
#      print " VVVVVV  $replace_vendor $replace_library $replace_component \n" ;
131
      &link_child( $project,$replace_component, $replace_library );
132
     }
133
   }
134
 
135
 
136
 
137
 
138
 
139
#/*********************************************************************************************/
140 94 jt_eaton
#/                                                                                            */
141
#/                                                                                            */
142
#/                                                                                            */
143
#/                                                                                            */
144 118 jt_eaton
#/                                                                                            */
145
#/                                                                                            */
146 94 jt_eaton
#/*********************************************************************************************/
147
 
148
 
149
 
150
my      @filelist_hier = (  );
151
my      @filelist      = (  );
152
 
153
@filelist_hier = (  );
154
@filelist = (  );
155 117 jt_eaton
@filelist = parse_hier("$vendor","$project","$component","$version");
156
@filelist = sys::lib::trim_sort(@filelist);
157 94 jt_eaton
 
158
 
159
 
160
foreach $line (@filelist)
161
   {
162
   $_ = $line;
163 117 jt_eaton
   if(/::(\S+)::(\S+)::/)
164 94 jt_eaton
     {
165
     $new_proj      = $1;
166 117 jt_eaton
     $new_comp      = $2;
167 94 jt_eaton
     if($new_proj ne $project ) { &link_child( $project,$new_comp, $new_proj ); }
168
     }
169
   }
170
 
171
 
172
 
173
 
174
 
175
 
176
#/*********************************************************************************************/
177
#/                                                                                            */
178
#/                                                                                            */
179
#/                                                                                            */
180
#/                                                                                            */
181
#/                                                                                            */
182
#/                                                                                            */
183
#/*********************************************************************************************/
184
 
185
 
186
 
187
sub link_child {
188
                 my $project      = shift;
189
                 my $child_parent = shift;
190
                 my $child_family = shift;
191
                 my $path  = "work/${project}/children";
192
                 mkdir $path,0755             unless( -e $path );
193
                 my $path  = "work/${project}/children/${child_family}";
194
                 mkdir $path,0755             unless( -e $path );
195
                 my $path  = "work/${project}/children/${child_family}/bin";
196
                 mkdir $path,0755             unless( -e $path );
197 99 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}/bin";
198 94 jt_eaton
                 $dest = "${home}/work/${project}/children/${child_family}/bin";
199
                 &link_dir( "$root", "$dest"  );
200
                 symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/children/${child_family}/bin/Makefile.root");
201
                 symlink( "${home}/tools/bin/Makefile",      "${home}/work/${project}/children/${child_family}/bin/Makefile");
202
                 my $path  = "work/${project}/children/${child_family}/sw";
203
                 mkdir $path,0755             unless( -e $path );
204 99 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}/sw";
205 94 jt_eaton
                 $dest = "${home}/work/${project}/children/${child_family}/sw";
206
                 &link_dir( "$root", "$dest"  );
207
                 my $path  = "work/${project}/children/${child_family}/ip";
208
                 mkdir $path,0755             unless( -e $path );
209 117 jt_eaton
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}/${child_parent}";
210 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
211
 
212 117 jt_eaton
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}/${child_parent}/rtl";
213 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
214 117 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}${lib_comp_sep}/${child_parent}/rtl";
215
                 $dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}/${child_parent}/rtl";
216 94 jt_eaton
                 &link_dir( "$root", "$dest"  );
217 115 jt_eaton
 
218
 
219 117 jt_eaton
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}/${child_parent}/ip-xact";
220 115 jt_eaton
                 mkdir $path,0755             unless( -e $path );
221 117 jt_eaton
                 $root = "${home}/projects/${vendor}/${child_family}${lib_comp_sep}/${child_parent}/ip-xact";
222
                 $dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}/${child_parent}/ip-xact";
223 115 jt_eaton
                 &link_dir( "$root", "$dest"  );
224
 
225
 
226
 
227 117 jt_eaton
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}/${child_parent}/doc";
228 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
229 115 jt_eaton
 
230 117 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");
231 94 jt_eaton
 
232
               }
233
 
234
 
235
#/*********************************************************************************************/
236
#/                                                                                            */
237
#/                                                                                            */
238
#/                                                                                            */
239
#/                                                                                            */
240
#/                                                                                            */
241
#/                                                                                            */
242
#/*********************************************************************************************/
243
 
244
# recursively map directory information
245
 
246
sub link_dir {
247
    my $src  = shift;
248
    my $dest = shift;
249
    return unless( -e $src );
250
 
251
    if( -d $src )
252
        {
253
 
254
        mkdir $dest,0755;
255
        my @contents = (  );
256
        opendir( DIR, $src );
257
        while( my $item = readdir( DIR ))
258
            {
259
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
260
            push( @contents, $item );
261
            }
262
        closedir( DIR );
263
 
264
        # recurse on items in the directory
265
        foreach my $item ( @contents )          { &link_dir("$src/$item", "$dest/$item" );}
266
 
267
 
268
       }
269
       else  {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
270
}
271
 
272
 
273
 
274
 
275
 
276
 
277
 
278
#/*********************************************************************************************/
279
#/                                                                                            */
280
#/                                                                                            */
281
#/                                                                                            */
282
#/                                                                                            */
283
#/                                                                                            */
284
#/                                                                                            */
285
#/*********************************************************************************************/
286
 
287
sub parse_hier
288
   {
289
   my @params     = @_;
290 117 jt_eaton
   my $version    = pop(@params);
291 94 jt_eaton
   my $component  = pop(@params);
292
   my $project    = pop(@params);
293 117 jt_eaton
   my $vendor     = pop(@params);
294 94 jt_eaton
 
295
   $home = cwd();
296
 
297 117 jt_eaton
   push(@filelist_hier,"::${project}::${component}::");
298 94 jt_eaton
 
299 118 jt_eaton
   my $spirit_design_file = yp::lib::find_ipxact_design_file($vendor,$project,$component,$version );
300
   my $spirit_padring_design_file = yp::lib::find_ipxact_padring_design_file($vendor,$project,$component,$version );
301 94 jt_eaton
 
302 101 jt_eaton
   #/*********************************************************************************************/
303
   #/                                                                                            */
304
   #/  Create filelists for simulation, code coverage, linting and synthesis                     */
305
   #/                                                                                            */
306
   #/                                                                                            */
307
   #/*********************************************************************************************/
308 94 jt_eaton
 
309 118 jt_eaton
   if($spirit_design_file)
310
    {
311 101 jt_eaton
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
312 118 jt_eaton
        {
313
        my($vendor_name)         = $i_name  ->to_literal ;
314
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
315
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
316
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
317 94 jt_eaton
 
318 118 jt_eaton
        my  @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$version_name");
319
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
320
        }
321
    }
322 94 jt_eaton
 
323 118 jt_eaton
   if($spirit_padring_design_file)
324
    {
325
   foreach  my   $i_name ($spirit_padring_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
326
        {
327
        my($vendor_name)         = $i_name  ->to_literal ;
328
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
329
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
330
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
331 94 jt_eaton
 
332 118 jt_eaton
        my  @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$version_name");
333
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
334
        }
335
    }
336 94 jt_eaton
 
337 101 jt_eaton
 
338
 
339 117 jt_eaton
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
340 94 jt_eaton
   return(@filelist_hier);
341
   }
342 117 jt_eaton
 
343
 
344
 

powered by: WebSVN 2.1.0

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