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_sw_dir = "";
|
171 |
|
|
}
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:design'))
|
175 |
|
|
{
|
176 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
177 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
178 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
179 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
180 |
|
|
$type = "spirit:design";
|
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_sw_dir = "";
|
194 |
|
|
|
195 |
|
|
}
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
|
201 |
|
|
{
|
202 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
203 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
204 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
205 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
206 |
|
|
$type = "spirit:abstractionDefinition";
|
207 |
|
|
$lib_sw_dir = "";
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
|
212 |
|
|
{
|
213 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
214 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
215 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
216 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
217 |
|
|
$type = "spirit:busDefinition";
|
218 |
|
|
$lib_sw_dir = "";
|
219 |
|
|
}
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
else #/ socgen namespace
|
223 |
|
|
|
224 |
|
|
{
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
|
228 |
|
|
{
|
229 |
|
|
$vendor = $design->findnodes('./socgen:vendor/text()')->to_literal ;
|
230 |
|
|
$library = $design->findnodes('./socgen:library/text()')->to_literal ;
|
231 |
|
|
$name = $design->findnodes('./socgen:component/text()')->to_literal ;
|
232 |
|
|
$version = "";
|
233 |
|
|
$type = "socgen:componentConfiguration";
|
234 |
|
|
$lib_sw_dir = "";
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
|
239 |
|
|
{
|
240 |
|
|
$vendor = $design->findnodes('./socgen:vendor/text()')->to_literal ;
|
241 |
|
|
$library = $design->findnodes('./socgen:name/text()')->to_literal ;
|
242 |
|
|
$name = "";
|
243 |
|
|
$version = "";
|
244 |
|
|
$type = "socgen:libraryConfiguration";
|
245 |
|
|
$lib_sw_dir = $design->findnodes('./socgen:lib_sw_dir/text()')->to_literal ;
|
246 |
|
|
}
|
247 |
125 |
jt_eaton |
|
248 |
|
|
foreach my $comp ($xml_file->findnodes('//spirit:component'))
|
249 |
|
|
{
|
250 |
|
|
$vendor = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
|
251 |
|
|
$library = $comp->findnodes('./spirit:library/text()')->to_literal ;
|
252 |
|
|
$type = "spirit:component";
|
253 |
|
|
$name = $comp->findnodes('./spirit:name/text()')->to_literal ;
|
254 |
|
|
$version = $comp->findnodes('./spirit:version/text()')->to_literal ;
|
255 |
|
|
$lib_sw_dir = "";
|
256 |
|
|
}
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:design'))
|
260 |
|
|
{
|
261 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
262 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
263 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
264 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
265 |
|
|
$type = "spirit:design";
|
266 |
|
|
$lib_sw_dir = "";
|
267 |
|
|
|
268 |
|
|
}
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:designConfiguration'))
|
272 |
|
|
{
|
273 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
274 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
275 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
276 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
277 |
|
|
$type = "spirit:designConfiguration";
|
278 |
|
|
$lib_sw_dir = "";
|
279 |
|
|
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
|
286 |
|
|
{
|
287 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
288 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
289 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
290 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
291 |
|
|
$type = "spirit:abstractionDefinition";
|
292 |
|
|
$lib_sw_dir = "";
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
|
297 |
|
|
{
|
298 |
|
|
$vendor = $design->findnodes('./spirit:vendor/text()')->to_literal ;
|
299 |
|
|
$library = $design->findnodes('./spirit:library/text()')->to_literal ;
|
300 |
|
|
$name = $design->findnodes('./spirit:name/text()')->to_literal ;
|
301 |
|
|
$version = $design->findnodes('./spirit:version/text()')->to_literal ;
|
302 |
|
|
$type = "spirit:busDefinition";
|
303 |
|
|
$lib_sw_dir = "";
|
304 |
|
|
}
|
305 |
|
|
|
306 |
|
|
|
307 |
|
|
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
124 |
jt_eaton |
}
|
319 |
117 |
jt_eaton |
|
320 |
|
|
|
321 |
124 |
jt_eaton |
$vendor_match = "/${vendor}/";
|
322 |
|
|
$library_match = "/${library}/";
|
323 |
|
|
$name_match = "/${name}/";
|
324 |
|
|
|
325 |
|
|
$_ = $t_local;
|
326 |
|
|
if(/\S+($vendor_match)(\S+)/) { $vendor_path = $2; }
|
327 |
|
|
else { $vendor_path = ""; }
|
328 |
|
|
if(/\S+($library_match)(\S+)/) { $library_path = $2; }
|
329 |
|
|
else { $library_path = ""; }
|
330 |
|
|
if(/\S+($library_match)(\S+)($name_match)(\S+)/) { $lib_comp_sep = $2; }
|
331 |
|
|
else { $lib_comp_sep = ""; }
|
332 |
|
|
if(/\S?($name_match)(\S+)/) { $component_path = $2; }
|
333 |
|
|
else { $component_path = ""; }
|
334 |
117 |
jt_eaton |
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
print OUTFILE " \n";
|
338 |
|
|
print OUTFILE " ${type}\n";
|
339 |
|
|
print OUTFILE " ${vendor}\n";
|
340 |
|
|
print OUTFILE " ${library}\n";
|
341 |
|
|
print OUTFILE " ${name}\n";
|
342 |
|
|
print OUTFILE " ${version}\n";
|
343 |
|
|
print OUTFILE " ${t_name}.xml\n";
|
344 |
|
|
print OUTFILE " ${t_local}\n";
|
345 |
|
|
print OUTFILE " ${vendor_path}\n";
|
346 |
|
|
print OUTFILE " ${library_path}\n";
|
347 |
|
|
print OUTFILE " ${component_path}\n";
|
348 |
|
|
print OUTFILE " ${lib_comp_sep}\n";
|
349 |
120 |
jt_eaton |
print OUTFILE " ${lib_sw_dir}\n";
|
350 |
117 |
jt_eaton |
print OUTFILE " \n\n";
|
351 |
120 |
jt_eaton |
|
352 |
117 |
jt_eaton |
}
|
353 |
|
|
|
354 |
|
|
&link_dir("$src/$item" );
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
}
|
358 |
|
|
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|