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

Subversion Repositories socgen

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

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
#/*    Copyright (C) <2010>                     */
23
#/*                                                                    */
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
 
55
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
56
 
57
 
58
 
59
 
60
############################################################################
61
### Process the options
62
############################################################################
63
 
64
Getopt::Long::config("require_order", "prefix=-");
65
GetOptions("h",
66
           "project=s" => \$project,
67
           "lib_comp_sep=s" => \$lib_comp_sep,
68
           "component=s" => \$component,
69
           "comp_xml_sep=s" => \$comp_xml_sep,
70
           "variant=s" => \$variant
71
) || die "(use '$program_name -h' for help)";
72
 
73
 
74
##############################################################################
75
## Help option
76
##############################################################################
77
if ( ($opt_h eq "1") )
78
   {
79
   print "\n type soc_link_2  work/project component  variant";
80
   print "\n";
81
   exit 1;
82
   }
83
 
84
 
85
##############################################################################
86
##
87
##############################################################################
88
use Cwd;
89
use XML::LibXML;
90
 
91
$home              = cwd();
92
my $new_sep        = $ARGV[0];
93
 
94
 
95
 
96
 
97
#/*********************************************************************************************/
98
#/                                                                                            */
99
#/                                                                                            */
100
#/                                                                                            */
101
#/                                                                                            */
102
#/                                                                                            */
103
#/                                                                                            */
104
#/*********************************************************************************************/
105
 
106
 
107
 
108
my      @filelist_hier = (  );
109
my      @filelist      = (  );
110
 
111
@filelist_hier = (  );
112
@filelist = (  );
113
@filelist = parse_hier("$project","$component",$new_sep,"$variant");
114
@filelist = trim_sort(@filelist);
115
 
116
 
117
 
118
foreach $line (@filelist)
119
   {
120
   $_ = $line;
121
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
122
     {
123
     $new_proj      = $1;
124
     $new_comp      = $2;
125
     $xxx_sep       = $3;
126
     $new_variant   = $4;
127
     if($new_proj ne $project ) { &link_child( $project,$new_comp, $new_proj ); }
128
     }
129
   }
130
 
131
 
132
 
133
 
134
 
135
 
136
#/*********************************************************************************************/
137
#/                                                                                            */
138
#/                                                                                            */
139
#/                                                                                            */
140
#/                                                                                            */
141
#/                                                                                            */
142
#/                                                                                            */
143
#/*********************************************************************************************/
144
 
145
 
146
 
147
sub link_child {
148
                 my $project      = shift;
149
                 my $child_parent = shift;
150
                 my $child_family = shift;
151
                 my $path  = "work/${project}/children";
152
                 mkdir $path,0755             unless( -e $path );
153
                 my $path  = "work/${project}/children/${child_family}";
154
                 mkdir $path,0755             unless( -e $path );
155
                 my $path  = "work/${project}/children/${child_family}/bin";
156
                 mkdir $path,0755             unless( -e $path );
157
                 $root = "${home}/projects/${child_family}/bin";
158
                 $dest = "${home}/work/${project}/children/${child_family}/bin";
159
                 &link_dir( "$root", "$dest"  );
160
                 symlink( "${home}/tools/bin/Makefile.root", "${home}/work/${project}/children/${child_family}/bin/Makefile.root");
161
                 symlink( "${home}/tools/bin/Makefile",      "${home}/work/${project}/children/${child_family}/bin/Makefile");
162
                 my $path  = "work/${project}/children/${child_family}/sw";
163
                 mkdir $path,0755             unless( -e $path );
164
                 $root = "${home}/projects/${child_family}/sw";
165
                 $dest = "${home}/work/${project}/children/${child_family}/sw";
166
                 &link_dir( "$root", "$dest"  );
167
                 my $path  = "work/${project}/children/${child_family}/ip";
168
                 mkdir $path,0755             unless( -e $path );
169
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}";
170
                 mkdir $path,0755             unless( -e $path );
171
 
172
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
173
                 mkdir $path,0755             unless( -e $path );
174
                 $root = "${home}/projects/${child_family}${lib_comp_sep}${child_parent}/rtl";
175
                 $dest = "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/rtl";
176
                 &link_dir( "$root", "$dest"  );
177
                 my $path  = "work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc";
178
                 mkdir $path,0755             unless( -e $path );
179
                 symlink( "${home}/projects/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v", "${home}/work/${project}/children/${child_family}${lib_comp_sep}${child_parent}/doc/copyright.v");
180
 
181
               }
182
 
183
 
184
#/*********************************************************************************************/
185
#/                                                                                            */
186
#/                                                                                            */
187
#/                                                                                            */
188
#/                                                                                            */
189
#/                                                                                            */
190
#/                                                                                            */
191
#/*********************************************************************************************/
192
 
193
# recursively map directory information
194
 
195
sub link_dir {
196
    my $src  = shift;
197
    my $dest = shift;
198
    return unless( -e $src );
199
 
200
    if( -d $src )
201
        {
202
 
203
        mkdir $dest,0755;
204
        my @contents = (  );
205
        opendir( DIR, $src );
206
        while( my $item = readdir( DIR ))
207
            {
208
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
209
            push( @contents, $item );
210
            }
211
        closedir( DIR );
212
 
213
        # recurse on items in the directory
214
        foreach my $item ( @contents )          { &link_dir("$src/$item", "$dest/$item" );}
215
 
216
 
217
       }
218
       else  {symlink( "${src}", "${dest}") unless( -e "${dest}" ); }
219
}
220
 
221
 
222
 
223
 
224
#/*********************************************************************************************/
225
#/                                                                                            */
226
#/                                                                                            */
227
#/                                                                                            */
228
#/                                                                                            */
229
#/                                                                                            */
230
#/                                                                                            */
231
#/*********************************************************************************************/
232
 
233
sub trim_sort {
234
   my @output_files  = @_;
235
   my %trim = ();
236
   foreach $descriptor (@output_files) { $trim{$descriptor}  = 1; }
237
   my @k = keys %trim;
238
   @output_files =  sort(sort @k);
239
   return(@output_files);
240
   }
241
 
242
 
243
 
244
#/*********************************************************************************************/
245
#/                                                                                            */
246
#/                                                                                            */
247
#/                                                                                            */
248
#/                                                                                            */
249
#/                                                                                            */
250
#/                                                                                            */
251
#/*********************************************************************************************/
252
 
253
sub parse_hier
254
   {
255
   my @params     = @_;
256
   my $variant    = pop(@params);
257
   my $comp_xml   = pop(@params);
258
   my $component  = pop(@params);
259
   my $project    = pop(@params);
260
 
261
   $home = cwd();
262
 
263
 
264
 
265
   my $parser = XML::LibXML->new();
266
   my $doc    = $parser->parse_file("${home}/projects/${project}${lib_comp_sep}${component}${comp_xml}${variant}.xml");
267
 
268
   foreach my $comp ($doc->findnodes('//spirit:component'))
269
      {
270
 
271
      my($vendor)   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
272
      my($library)  = $comp->findnodes('./spirit:library/text()')->to_literal ;
273
      my($name)     = $comp->findnodes('./spirit:name/text()')->to_literal ;
274
      my($version)  = $comp->findnodes('./spirit:version/text()')->to_literal ;
275
 
276
      my $variant = "";
277
      if($version) {$variant = "${name}_${version}"}
278
      else         {$variant = "${name}"}
279
 
280
 
281
 
282
 
283
      #/*********************************************************************************************/
284
      #/                                                                                            */
285
      #/  Create filelists for simulation, code coverage, linting and synthesis                     */
286
      #/                                                                                            */
287
      #/                                                                                            */
288
      #/*********************************************************************************************/
289
 
290
      push(@filelist_hier,"::${library}::${name}::${comp_xml}::${variant}::");
291
 
292
      foreach  my   $i_name ($doc->findnodes("//spirit:component/spirit:componentInstances/spirit:componentInstance/spirit:instanceName"))
293
         {
294
         my($library_name)        = $i_name ->findnodes('../spirit:componentRef/spirit:library/text()')->to_literal ;
295
         my($component_name)      = $i_name ->findnodes('../spirit:componentRef/spirit:name/text()')->to_literal ;
296
         my($version_name)        = $i_name ->findnodes('../spirit:componentRef/spirit:version/text()')->to_literal ;
297
 
298
         my $variant_name   = "";
299
         if($version_name)  {$variant_name = "${component_name}_${version_name}";}
300
         else               {$variant_name = "${component_name}";}
301
 
302
         my  @filelist_sub = parse_hier("$library_name","$component_name","$comp_xml_sep","$variant_name");
303
         foreach $line (@filelist_sub) { push(@filelist_hier,"$line"); }
304
 
305
         }
306
      }
307
 
308
   @filelist_hier     =       trim_sort(@filelist_hier);
309
   return(@filelist_hier);
310
   }

powered by: WebSVN 2.1.0

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