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

Subversion Repositories socgen

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

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
#/*********************************************************************************************/
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 119 jt_eaton
   if(/::(\S+)::(\S+)::(\S+)::/)
164 94 jt_eaton
     {
165 119 jt_eaton
     $new_vendor      = $1;
166
     $new_proj        = $2;
167
     $new_comp        = $3;
168
     if(($new_vendor ne $vendor ) or  ($new_proj ne $project ) )
169
 
170
       { &link_child( $vendor,$project,$new_comp, $new_proj ,$new_vendor); }
171 94 jt_eaton
     }
172
   }
173
 
174
 
175
 
176
 
177
 
178
 
179
#/*********************************************************************************************/
180
#/                                                                                            */
181
#/                                                                                            */
182
#/                                                                                            */
183
#/                                                                                            */
184
#/                                                                                            */
185
#/                                                                                            */
186
#/*********************************************************************************************/
187
 
188
 
189
 
190
sub link_child {
191 119 jt_eaton
                 my $parent_vendor      = shift;
192
                 my $parent_library      = shift;
193
                 my $child_component = shift;
194
                 my $child_library = shift;
195
                 my $child_vendor = shift;
196
 
197
                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library);
198
 
199
 
200
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children";
201 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
202 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}";
203 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
204 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
205 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
206 119 jt_eaton
                 $root = "${home}/${projects_dir}/${child_vendor}/${child_library}/bin";
207
                 $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
208
                 &sys::lib::link_dir( "$root", "$dest"  );
209
                 symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile.root");
210
                 symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile");
211 94 jt_eaton
 
212 119 jt_eaton
 
213
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/sw";
214 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
215 119 jt_eaton
                 $root = "${home}/${projects_dir}/${child_vendor}/${child_library}/sw";
216
                 $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/sw";
217
                 &sys::lib::link_dir( "$root", "$dest"  );
218 115 jt_eaton
 
219
 
220 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}";
221
 
222
#  only works for simple single item paths
223
 
224 115 jt_eaton
                 mkdir $path,0755             unless( -e $path );
225
 
226 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
227 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
228 119 jt_eaton
                 $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_comp_sep}/${child_component}";
229
                 $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
230
                 &sys::lib::link_dir( "$root", "$dest"  );
231 115 jt_eaton
 
232 94 jt_eaton
 
233
               }
234
 
235
 
236
 
237
 
238
 
239
#/*********************************************************************************************/
240
#/                                                                                            */
241
#/                                                                                            */
242
#/                                                                                            */
243
#/                                                                                            */
244
#/                                                                                            */
245
#/                                                                                            */
246
#/*********************************************************************************************/
247
 
248
sub parse_hier
249
   {
250
   my @params     = @_;
251 117 jt_eaton
   my $version    = pop(@params);
252 94 jt_eaton
   my $component  = pop(@params);
253
   my $project    = pop(@params);
254 117 jt_eaton
   my $vendor     = pop(@params);
255 94 jt_eaton
 
256
   $home = cwd();
257
 
258 119 jt_eaton
   push(@filelist_hier,"::${vendor}::${project}::${component}::");
259 94 jt_eaton
 
260 118 jt_eaton
   my $spirit_design_file = yp::lib::find_ipxact_design_file($vendor,$project,$component,$version );
261
   my $spirit_padring_design_file = yp::lib::find_ipxact_padring_design_file($vendor,$project,$component,$version );
262 94 jt_eaton
 
263 101 jt_eaton
   #/*********************************************************************************************/
264
   #/                                                                                            */
265
   #/  Create filelists for simulation, code coverage, linting and synthesis                     */
266
   #/                                                                                            */
267
   #/                                                                                            */
268
   #/*********************************************************************************************/
269 94 jt_eaton
 
270 118 jt_eaton
   if($spirit_design_file)
271
    {
272 101 jt_eaton
   foreach  my   $i_name ($spirit_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
273 118 jt_eaton
        {
274
        my($vendor_name)         = $i_name  ->to_literal ;
275
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
276
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
277
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
278 94 jt_eaton
 
279 118 jt_eaton
        my  @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$version_name");
280
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
281
        }
282
    }
283 94 jt_eaton
 
284 118 jt_eaton
   if($spirit_padring_design_file)
285
    {
286
   foreach  my   $i_name ($spirit_padring_design_file->findnodes("//spirit:design/spirit:componentInstances/spirit:componentInstance/spirit:componentRef/\@spirit:vendor"))
287
        {
288
        my($vendor_name)         = $i_name  ->to_literal ;
289
        my($library_name)        = $i_name  ->findnodes('../@spirit:library')->to_literal ;
290
        my($component_name)      = $i_name  ->findnodes('../@spirit:name')->to_literal ;
291
        my($version_name)        = $i_name  ->findnodes('../@spirit:version')->to_literal ;
292 94 jt_eaton
 
293 118 jt_eaton
        my  @filelist_sub = parse_hier("$vendor_name","$library_name","$component_name","$version_name");
294
        foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
295
        }
296
    }
297 94 jt_eaton
 
298 101 jt_eaton
 
299
 
300 117 jt_eaton
   @filelist_hier     =       sys::lib::trim_sort(@filelist_hier);
301 94 jt_eaton
   return(@filelist_hier);
302
   }
303 117 jt_eaton
 
304
 
305
 

powered by: WebSVN 2.1.0

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