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

Subversion Repositories socgen

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

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
 
97
print  OUTFILE "\n";
98
print  OUTFILE "\n";
99
 
100
 
101
 
102
 
103
 
104
 
105
#/*********************************************************************************************/
106
#/                                                                                            */
107
#/                                                                                            */
108
#/                                                                                            */
109
#/                                                                                            */
110
#/                                                                                            */
111
#/                                                                                            */
112
#/*********************************************************************************************/
113
 
114
my $parser = XML::LibXML->new();
115
$root = "${home}/projects";
116
&link_dir( "$root"  );
117
 
118
print  OUTFILE "  \n";
119
 
120
 
121
 
122
 
123
 
124
 
125
 
126
 
127
 
128
 
129
 
130
 
131
 
132
 
133
 
134
 
135
 
136
 
137
#/*********************************************************************************************/
138
#/                                                                                            */
139
#/                                                                                            */
140
#/                                                                                            */
141
#/                                                                                            */
142
#/                                                                                            */
143
#/                                                                                            */
144
#/*********************************************************************************************/
145
 
146
# recursively map directory information
147
 
148
sub link_dir {
149
    my $src  = shift;
150
    return unless( -e $src );
151
 
152
    if( -d $src )
153
        {
154
 
155
        my @contents = (  );
156
        opendir( DIR, $src );
157
        while( my $item = readdir( DIR ))
158
            {
159
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
160
            push( @contents, $item );
161
            }
162
        closedir( DIR );
163
 
164
        # recurse on items in the directory
165
        foreach my $item ( @contents )
166
          {
167
          $_ = $item;
168
          if(/(\S+).xml/)
169
             {
170
             my $t_name                = $1;
171 120 jt_eaton
             $_ = $src;
172
             if(/${home}(\S+)/) { $t_local = $1; }
173 117 jt_eaton
 
174
 
175
 
176
 
177
 
178
 
179
 
180
if($t_name eq "design")
181
{
182
my $socgen_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
183
foreach my $design ($socgen_file->findnodes('//socgen:ip'))
184
   {
185
   $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
186
   $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
187
   $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
188
   $version  = "";
189
   $type     = "socgen:ip";
190
   }
191
}
192 120 jt_eaton
 
193
 
194
elsif($t_name eq "library")
195
{
196
my $socgen_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
197
 
198
 
199
foreach my $design ($socgen_file->findnodes('//socgen:lib'))
200
   {
201
   $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
202
   $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
203
   $lib_ip_dir  = $design->findnodes('./socgen:lib_ip_dir/text()')->to_literal ;
204
   $lib_sw_dir  = $design->findnodes('./socgen:lib_sw_dir/text()')->to_literal ;
205
   $version  = "";
206
   $name     = "";
207
   $type     = "socgen:lib";
208
 
209
 
210
 
211
   }
212
}
213
 
214
 
215
 
216
 
217 117 jt_eaton
else
218
{
219
my $spirit_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
220
 
221
 
222
foreach my $comp ($spirit_file->findnodes('//spirit:component'))
223
   {
224
   $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
225
   $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
226
   $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
227
   $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
228
   $type     = "spirit:component";
229
   }
230
 
231
 
232
foreach my $design ($spirit_file->findnodes('//spirit:design'))
233
   {
234
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
235
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
236
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
237
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
238
   $type     = "spirit:design";
239
 
240
 
241
   }
242
 
243
 
244
foreach my $design ($spirit_file->findnodes('//spirit:designConfiguration'))
245
   {
246
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
247
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
248
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
249
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
250
   $type     = "spirit:designConfiguration";
251
 
252
 
253
   }
254
 
255
 
256
 
257
 
258
foreach my $design ($spirit_file->findnodes('//spirit:abstractionDefinition'))
259
   {
260
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
261
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
262
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
263
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
264
   $type     = "spirit:abstractionDefinition";
265
 
266
 
267
   }
268
 
269
 
270
foreach my $design ($spirit_file->findnodes('//spirit:busDefinition'))
271
   {
272
   $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
273
   $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
274
   $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
275
   $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
276
   $type     = "spirit:busDefinition";
277
   }
278
 
279
 
280
 
281
}
282
 
283
 
284
          $vendor_match = "/${vendor}/";
285
          $library_match = "/${library}/";
286
          $name_match = "/${name}/";
287
 
288
          $_ = $t_local;
289 118 jt_eaton
          if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
290
          else                                              { $vendor_path      = ""; }
291
          if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
292
          else                                              { $library_path     = ""; }
293
          if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = $2; }
294 120 jt_eaton
          else                                              { $lib_comp_sep     = ""; }
295 118 jt_eaton
          if(/\S?($name_match)(\S+)/)                       { $component_path   = $2; }
296
          else                                              { $component_path   = ""; }
297 117 jt_eaton
 
298
 
299
 
300
             print  OUTFILE "   \n";
301
             print  OUTFILE "   ${type}\n";
302
             print  OUTFILE "   ${vendor}\n";
303
             print  OUTFILE "   ${library}\n";
304
             print  OUTFILE "   ${name}\n";
305
             print  OUTFILE "   ${version}\n";
306
             print  OUTFILE "   ${t_name}.xml\n";
307
             print  OUTFILE "   ${t_local}\n";
308
             print  OUTFILE "   ${vendor_path}\n";
309
             print  OUTFILE "   ${library_path}\n";
310
             print  OUTFILE "   ${component_path}\n";
311
             print  OUTFILE "   ${lib_comp_sep}\n";
312 120 jt_eaton
             print  OUTFILE "   ${lib_ip_dir}\n";
313
             print  OUTFILE "   ${lib_sw_dir}\n";
314 117 jt_eaton
             print  OUTFILE " \n\n";
315 120 jt_eaton
 
316
          $lib_ip_dir = "";
317
          $lib_sw_dir = "";
318 117 jt_eaton
             }
319
 
320
          &link_dir("$src/$item" );
321
          }
322
 
323
     }
324
 
325
}
326
 
327
 
328
 

powered by: WebSVN 2.1.0

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