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

Subversion Repositories socgen

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

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
 
159
             if($@)             #/ Nope, must be spirit  namespace
160
               {
161
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
162
                  {
163
                  $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
164
                  $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
165
                  $type     = "spirit:component";
166
                  $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
167
                  $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
168
                  $lib_ip_dir = "";
169
                  $lib_sw_dir = "";
170
                  }
171
 
172
 
173
               foreach my $design ($xml_file->findnodes('//spirit:design'))
174
                  {
175
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
176
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
177
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
178
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
179
                  $type     = "spirit:design";
180
                  $lib_ip_dir = "";
181
                  $lib_sw_dir = "";
182
 
183
                  }
184
 
185
 
186
               foreach my $design ($xml_file->findnodes('//spirit:designConfiguration'))
187
                  {
188
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
189
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
190
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
191
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
192
                  $type     = "spirit:designConfiguration";
193
                  $lib_ip_dir = "";
194
                  $lib_sw_dir = "";
195
 
196
                  }
197
 
198
 
199
 
200
 
201
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
202
                  {
203
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
204
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
205
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
206
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
207
                  $type     = "spirit:abstractionDefinition";
208
                  $lib_ip_dir = "";
209
                  $lib_sw_dir = "";
210
                  }
211
 
212
 
213
               foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
214
                  {
215
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
216
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
217
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
218
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
219
                  $type     = "spirit:busDefinition";
220
                  $lib_ip_dir = "";
221
                  $lib_sw_dir = "";
222
                  }
223
               }
224
 
225
               else               #/  socgen  namespace
226
 
227
               {
228
 
229
 
230
               foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
231
                  {
232
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
233
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
234
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
235
                  $version  = "";
236
                  $type     = "socgen:componentConfiguration";
237
                  $lib_ip_dir = "";
238
                  $lib_sw_dir = "";
239
                  }
240
 
241
 
242
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
243
                  {
244
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
245
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
246
                  $name     = "";
247
                  $version  = "";
248
                  $type     = "socgen:libraryConfiguration";
249
                  $lib_ip_dir  = $design->findnodes('./socgen:lib_ip_dir/text()')->to_literal ;
250
                  $lib_sw_dir  = $design->findnodes('./socgen:lib_sw_dir/text()')->to_literal ;
251
                  }
252
               }
253 117 jt_eaton
 
254
 
255 124 jt_eaton
             $vendor_match = "/${vendor}/";
256
             $library_match = "/${library}/";
257
             $name_match = "/${name}/";
258
 
259
             $_ = $t_local;
260
             if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
261
             else                                              { $vendor_path      = ""; }
262
             if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
263
             else                                              { $library_path     = ""; }
264
             if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = $2; }
265
             else                                              { $lib_comp_sep     = ""; }
266
             if(/\S?($name_match)(\S+)/)                       { $component_path   = $2; }
267
             else                                              { $component_path   = ""; }
268 117 jt_eaton
 
269
 
270
 
271
             print  OUTFILE "   \n";
272
             print  OUTFILE "   ${type}\n";
273
             print  OUTFILE "   ${vendor}\n";
274
             print  OUTFILE "   ${library}\n";
275
             print  OUTFILE "   ${name}\n";
276
             print  OUTFILE "   ${version}\n";
277
             print  OUTFILE "   ${t_name}.xml\n";
278
             print  OUTFILE "   ${t_local}\n";
279
             print  OUTFILE "   ${vendor_path}\n";
280
             print  OUTFILE "   ${library_path}\n";
281
             print  OUTFILE "   ${component_path}\n";
282
             print  OUTFILE "   ${lib_comp_sep}\n";
283 120 jt_eaton
             print  OUTFILE "   ${lib_ip_dir}\n";
284
             print  OUTFILE "   ${lib_sw_dir}\n";
285 117 jt_eaton
             print  OUTFILE " \n\n";
286 120 jt_eaton
 
287 117 jt_eaton
             }
288
 
289
          &link_dir("$src/$item" );
290
          }
291
 
292
     }
293
 
294
}
295
 
296
 
297
 

powered by: WebSVN 2.1.0

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