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

Subversion Repositories socgen

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

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

powered by: WebSVN 2.1.0

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