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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [yp/] [create_yp] - Blame information for rev 125

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 117 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-2011>                */
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
use Cwd;
55
use XML::LibXML;
56
 
57
 
58
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
59
 
60
 
61
 
62
 
63
############################################################################
64
### Process the options
65
############################################################################
66
 
67
Getopt::Long::config("require_order", "prefix=-");
68
GetOptions("h","help"
69
) || die "(use '$program_name -h' for help)";
70
 
71
 
72
##############################################################################
73
## Help option
74
##############################################################################
75
if ( $opt_h or $opt_help  )
76
   {
77
   print "\n type create_yp\n";
78
   exit 1;
79
   }
80
 
81
 
82
##############################################################################
83
##
84
##############################################################################
85
 
86
my $home                     = cwd();
87
my $index_filename           = "./tools/yp/index.xml";
88
 
89 120 jt_eaton
 
90
 
91
 
92
 
93
 
94 117 jt_eaton
open   OUTFILE,">$index_filename" or die "unable to open $index_filename";
95
 
96
print  OUTFILE "\n";
97
print  OUTFILE "\n";
98
 
99
 
100
 
101
 
102
 
103
 
104
#/*********************************************************************************************/
105
#/                                                                                            */
106
#/                                                                                            */
107
#/                                                                                            */
108
#/                                                                                            */
109
#/                                                                                            */
110
#/                                                                                            */
111
#/*********************************************************************************************/
112
 
113
my $parser = XML::LibXML->new();
114
$root = "${home}/projects";
115
&link_dir( "$root"  );
116
 
117
print  OUTFILE "  \n";
118
 
119
 
120
#/*********************************************************************************************/
121
#/                                                                                            */
122
#/                                                                                            */
123
#/                                                                                            */
124
#/                                                                                            */
125
#/                                                                                            */
126
#/                                                                                            */
127
#/*********************************************************************************************/
128
 
129
# recursively map directory information
130
 
131
sub link_dir {
132
    my $src  = shift;
133
    return unless( -e $src );
134
 
135
    if( -d $src )
136
        {
137
        my @contents = (  );
138
        opendir( DIR, $src );
139
        while( my $item = readdir( DIR ))
140
            {
141
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
142
            push( @contents, $item );
143
            }
144
        closedir( DIR );
145
 
146
        # recurse on items in the directory
147
        foreach my $item ( @contents )
148
          {
149
          $_ = $item;
150 124 jt_eaton
          if(/(\S+)\.xml/)
151 117 jt_eaton
             {
152
             my $t_name                = $1;
153 120 jt_eaton
             $_ = $src;
154
             if(/${home}(\S+)/) { $t_local = $1; }
155 117 jt_eaton
 
156 124 jt_eaton
             my    $xml_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
157
             eval {$xml_file->  findnodes('//socgen:componentConfiguration');};  #/ check for socgen namespace
158 125 jt_eaton
 
159
#             print ("Name  ${t_local}/${t_name}.xml  \n");
160 124 jt_eaton
 
161
             if($@)             #/ Nope, must be spirit  namespace
162
               {
163
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
164
                  {
165
                  $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
166
                  $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
167
                  $type     = "spirit:component";
168
                  $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
169
                  $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
170
                  $lib_ip_dir = "";
171
                  $lib_sw_dir = "";
172
                  }
173
 
174
 
175
               foreach my $design ($xml_file->findnodes('//spirit:design'))
176
                  {
177
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
178
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
179
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
180
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
181
                  $type     = "spirit:design";
182
                  $lib_ip_dir = "";
183
                  $lib_sw_dir = "";
184
 
185
                  }
186
 
187
 
188
               foreach my $design ($xml_file->findnodes('//spirit:designConfiguration'))
189
                  {
190
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
191
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
192
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
193
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
194
                  $type     = "spirit:designConfiguration";
195
                  $lib_ip_dir = "";
196
                  $lib_sw_dir = "";
197
 
198
                  }
199
 
200
 
201
 
202
 
203
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
204
                  {
205
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
206
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
207
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
208
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
209
                  $type     = "spirit:abstractionDefinition";
210
                  $lib_ip_dir = "";
211
                  $lib_sw_dir = "";
212
                  }
213
 
214
 
215
               foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
216
                  {
217
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
218
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
219
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
220
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
221
                  $type     = "spirit:busDefinition";
222
                  $lib_ip_dir = "";
223
                  $lib_sw_dir = "";
224
                  }
225
               }
226
 
227
               else               #/  socgen  namespace
228
 
229
               {
230
 
231
 
232
               foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
233
                  {
234
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
235
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
236
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
237
                  $version  = "";
238
                  $type     = "socgen:componentConfiguration";
239
                  $lib_ip_dir = "";
240
                  $lib_sw_dir = "";
241
                  }
242
 
243
 
244
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
245
                  {
246
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
247
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
248
                  $name     = "";
249
                  $version  = "";
250
                  $type     = "socgen:libraryConfiguration";
251
                  $lib_ip_dir  = $design->findnodes('./socgen:lib_ip_dir/text()')->to_literal ;
252
                  $lib_sw_dir  = $design->findnodes('./socgen:lib_sw_dir/text()')->to_literal ;
253
                  }
254 125 jt_eaton
 
255
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
256
                  {
257
                  $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
258
                  $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
259
                  $type     = "spirit:component";
260
                  $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
261
                  $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
262
                  $lib_ip_dir = "";
263
                  $lib_sw_dir = "";
264
                  }
265
 
266
 
267
               foreach my $design ($xml_file->findnodes('//spirit:design'))
268
                  {
269
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
270
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
271
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
272
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
273
                  $type     = "spirit:design";
274
                  $lib_ip_dir = "";
275
                  $lib_sw_dir = "";
276
 
277
                  }
278
 
279
 
280
               foreach my $design ($xml_file->findnodes('//spirit:designConfiguration'))
281
                  {
282
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
283
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
284
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
285
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
286
                  $type     = "spirit:designConfiguration";
287
                  $lib_ip_dir = "";
288
                  $lib_sw_dir = "";
289
 
290
                  }
291
 
292
 
293
 
294
 
295
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
296
                  {
297
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
298
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
299
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
300
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
301
                  $type     = "spirit:abstractionDefinition";
302
                  $lib_ip_dir = "";
303
                  $lib_sw_dir = "";
304
                  }
305
 
306
 
307
               foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
308
                  {
309
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
310
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
311
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
312
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
313
                  $type     = "spirit:busDefinition";
314
                  $lib_ip_dir = "";
315
                  $lib_sw_dir = "";
316
                  }
317
 
318
 
319
 
320
 
321
 
322
 
323
 
324
 
325
 
326
 
327
 
328
 
329
 
330 124 jt_eaton
               }
331 117 jt_eaton
 
332
 
333 124 jt_eaton
             $vendor_match = "/${vendor}/";
334
             $library_match = "/${library}/";
335
             $name_match = "/${name}/";
336
 
337
             $_ = $t_local;
338
             if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
339
             else                                              { $vendor_path      = ""; }
340
             if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
341
             else                                              { $library_path     = ""; }
342
             if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = $2; }
343
             else                                              { $lib_comp_sep     = ""; }
344
             if(/\S?($name_match)(\S+)/)                       { $component_path   = $2; }
345
             else                                              { $component_path   = ""; }
346 117 jt_eaton
 
347
 
348
 
349
             print  OUTFILE "   \n";
350
             print  OUTFILE "   ${type}\n";
351
             print  OUTFILE "   ${vendor}\n";
352
             print  OUTFILE "   ${library}\n";
353
             print  OUTFILE "   ${name}\n";
354
             print  OUTFILE "   ${version}\n";
355
             print  OUTFILE "   ${t_name}.xml\n";
356
             print  OUTFILE "   ${t_local}\n";
357
             print  OUTFILE "   ${vendor_path}\n";
358
             print  OUTFILE "   ${library_path}\n";
359
             print  OUTFILE "   ${component_path}\n";
360
             print  OUTFILE "   ${lib_comp_sep}\n";
361 120 jt_eaton
             print  OUTFILE "   ${lib_ip_dir}\n";
362
             print  OUTFILE "   ${lib_sw_dir}\n";
363 117 jt_eaton
             print  OUTFILE " \n\n";
364 120 jt_eaton
 
365 117 jt_eaton
             }
366
 
367
          &link_dir("$src/$item" );
368
          }
369
 
370
     }
371
 
372
}
373
 
374
 
375
 

powered by: WebSVN 2.1.0

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