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

Subversion Repositories socgen

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

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

powered by: WebSVN 2.1.0

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