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

Subversion Repositories socgen

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

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 131 jt_eaton
use lib './tools';
57
use sys::lib;
58
use BerkeleyDB;
59 117 jt_eaton
 
60
 
61
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
62
 
63
 
64
 
65
 
66
############################################################################
67
### Process the options
68
############################################################################
69
 
70
Getopt::Long::config("require_order", "prefix=-");
71
GetOptions("h","help"
72
) || die "(use '$program_name -h' for help)";
73
 
74
 
75
##############################################################################
76
## Help option
77
##############################################################################
78
if ( $opt_h or $opt_help  )
79
   {
80 131 jt_eaton
   print "\n type create_yp  $path  \n";
81 117 jt_eaton
   exit 1;
82
   }
83
 
84
 
85
##############################################################################
86
##
87
##############################################################################
88
 
89 131 jt_eaton
my $home           = cwd();
90
my $path           = $ARGV[0];
91 117 jt_eaton
 
92 131 jt_eaton
mkdir $path,0755   unless( -e $path );
93 120 jt_eaton
 
94
 
95 131 jt_eaton
$repo_db                    = new BerkeleyDB::Hash( -Filename => "${path}/repo.dbm",                   -Flags => DB_CREATE ) or die "Cannot open file: $!";
96
$component_db               = new BerkeleyDB::Hash( -Filename => "${path}/component.dbm",              -Flags => DB_CREATE ) or die "Cannot open file: $!";
97
$design_db                  = new BerkeleyDB::Hash( -Filename => "${path}/design.dbm",                 -Flags => DB_CREATE ) or die "Cannot open file: $!";
98
$busDefinition_db           = new BerkeleyDB::Hash( -Filename => "${path}/busDefinition.dbm",          -Flags => DB_CREATE ) or die "Cannot open file: $!";
99
$abstractionDefinition_db   = new BerkeleyDB::Hash( -Filename => "${path}/abstractionDefinition.dbm",  -Flags => DB_CREATE ) or die "Cannot open file: $!";
100
$libraryConfiguration_db    = new BerkeleyDB::Hash( -Filename => "${path}/libraryConfiguration.dbm",   -Flags => DB_CREATE ) or die "Cannot open file: $!";
101
$componentConfiguration_db  = new BerkeleyDB::Hash( -Filename => "${path}/componentConfiguration.dbm", -Flags => DB_CREATE ) or die "Cannot open file: $!";
102 120 jt_eaton
 
103
 
104 117 jt_eaton
 
105 131 jt_eaton
my $parser = XML::LibXML->new();
106 117 jt_eaton
 
107
 
108
 
109 131 jt_eaton
my    $workspace    = $parser->parse_file("${home}/workspace.xml");
110 117 jt_eaton
 
111
 
112 130 jt_eaton
 
113
 
114
 
115
 
116
 
117
 
118
 
119 131 jt_eaton
my @repos =();
120
my $repo;
121
 
122
 
123
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:external/socgen:repo'))
124
                  {
125
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
126
                  my $repo_path  = $repo->findnodes('./socgen:path/text()')->to_literal ;
127
                  print "Linking $repo_name   $repo_path \n";
128
                  if(-e  $repo_name)
129
                   {
130
                   print "Removing $repo_name  \n";
131
                   my $cmd = "rm -r $repo_name  \n";
132
                   if(system($cmd)){};
133
                   }
134
 
135
                  my $cmd = "mkdir $repo_name ;lndir  $repo_path  $repo_name;";
136
                  if(system($cmd)){};
137
 
138
 
139
 
140
                  }
141
 
142
 
143
 
144
 
145
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:repos/socgen:repo'))
146
                  {
147
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
148
                  push  @repos,$repo_name;
149
                  }
150
 
151
my $repos_dir ;
152
 
153
 
154
 
155
foreach $repos_dir (@repos)
156
{
157
print "Project_dir  $repos_dir  \n";
158
 
159
 
160
 
161
 
162 117 jt_eaton
#/*********************************************************************************************/
163
#/                                                                                            */
164
#/                                                                                            */
165
#/                                                                                            */
166
#/                                                                                            */
167
#/                                                                                            */
168
#/                                                                                            */
169
#/*********************************************************************************************/
170
 
171
 
172 131 jt_eaton
$root = "${home}${repos_dir}";
173
&link_dir( "$root","$repos_dir"  );
174 117 jt_eaton
 
175
 
176 131 jt_eaton
 
177 117 jt_eaton
#/*********************************************************************************************/
178
#/                                                                                            */
179
#/                                                                                            */
180
#/                                                                                            */
181
#/                                                                                            */
182
#/                                                                                            */
183
#/                                                                                            */
184
#/*********************************************************************************************/
185
 
186
# recursively map directory information
187
 
188
sub link_dir {
189
    my $src  = shift;
190 131 jt_eaton
    my $repos_dir  = shift;
191
 
192
 
193 117 jt_eaton
    return unless( -e $src );
194
 
195
    if( -d $src )
196
        {
197
        my @contents = (  );
198
        opendir( DIR, $src );
199
        while( my $item = readdir( DIR ))
200
            {
201
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
202
            push( @contents, $item );
203
            }
204
        closedir( DIR );
205
 
206
        # recurse on items in the directory
207
        foreach my $item ( @contents )
208
          {
209
          $_ = $item;
210 124 jt_eaton
          if(/(\S+)\.xml/)
211 117 jt_eaton
             {
212
             my $t_name                = $1;
213 120 jt_eaton
             $_ = $src;
214
             if(/${home}(\S+)/) { $t_local = $1; }
215 117 jt_eaton
 
216 124 jt_eaton
             my    $xml_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
217 125 jt_eaton
 
218 131 jt_eaton
            if(${t_name} eq "libraryCfg"  )
219 124 jt_eaton
               {
220 131 jt_eaton
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
221 124 jt_eaton
                  {
222 131 jt_eaton
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
223
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
224
                  $name     = "";
225
                  $version  = "";
226
                  $type     = "socgen:libraryConfiguration";
227 124 jt_eaton
                  }
228 131 jt_eaton
                }
229
             elsif(${t_name} eq "componentCfg"  )
230
              {
231
              foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
232 124 jt_eaton
                  {
233
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
234
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
235
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
236
                  $version  = "";
237
                  $type     = "socgen:componentConfiguration";
238
                  }
239 131 jt_eaton
              }
240
 
241
             else
242
             {
243 124 jt_eaton
 
244 125 jt_eaton
               foreach my $comp ($xml_file->findnodes('//spirit:component'))
245
                  {
246
                  $vendor   = $comp->findnodes('./spirit:vendor/text()')->to_literal ;
247
                  $library  = $comp->findnodes('./spirit:library/text()')->to_literal ;
248
                  $type     = "spirit:component";
249
                  $name     = $comp->findnodes('./spirit:name/text()')->to_literal ;
250
                  $version  = $comp->findnodes('./spirit:version/text()')->to_literal ;
251
                  }
252
 
253
 
254
               foreach my $design ($xml_file->findnodes('//spirit:design'))
255
                  {
256
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
257
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
258
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
259
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
260
                  $type     = "spirit:design";
261
 
262
                  }
263
 
264 131 jt_eaton
 
265 125 jt_eaton
 
266
               foreach my $design ($xml_file->findnodes('//spirit:abstractionDefinition'))
267
                  {
268
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
269
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
270
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
271
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
272
                  $type     = "spirit:abstractionDefinition";
273
                  }
274
 
275
 
276
               foreach my $design ($xml_file->findnodes('//spirit:busDefinition'))
277
                  {
278
                  $vendor   = $design->findnodes('./spirit:vendor/text()')->to_literal ;
279
                  $library  = $design->findnodes('./spirit:library/text()')->to_literal ;
280
                  $name     = $design->findnodes('./spirit:name/text()')->to_literal ;
281
                  $version  = $design->findnodes('./spirit:version/text()')->to_literal ;
282
                  $type     = "spirit:busDefinition";
283
                  }
284
 
285
 
286 131 jt_eaton
 
287
 
288 125 jt_eaton
 
289 131 jt_eaton
 
290 117 jt_eaton
 
291 131 jt_eaton
               }
292 117 jt_eaton
 
293 124 jt_eaton
             $vendor_match = "/${vendor}/";
294
             $library_match = "/${library}/";
295
             $name_match = "/${name}/";
296
 
297
             $_ = $t_local;
298
             if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
299
             else                                              { $vendor_path      = ""; }
300
             if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
301
             else                                              { $library_path     = ""; }
302 130 jt_eaton
             if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = "/${2}/"; }
303
             else                                              { $lib_comp_sep     = "/"; }
304
             if(/(\S+)($name_match)(\S+)/)
305
               {
306
               $component_path   = "/${3}";
307
               $environment_path = $1;
308
               }
309
             else                                              { $component_path   = "/"; }
310 117 jt_eaton
 
311
 
312
 
313 131 jt_eaton
 
314
#               print "${vendor}__${library}_${name}_${version}     $t_local  $library_match  $lib_comp_sep  $name_match    \n";
315 130 jt_eaton
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
316
 
317
 
318
 
319
             if($type eq "spirit:component")
320
               {
321
 
322
               my $V = "${vendor}"    ;
323 131 jt_eaton
               my @repo_info  = ("vendor","$vendor","idle","$repos_dir" );
324 130 jt_eaton
               $repo_db->db_put( $V, join(':', @repo_info) );
325
 
326
 
327
               my $V_L = "${vendor}__${library}"    ;
328 131 jt_eaton
               @repo_info  = ("library","$library","$library_path" ,"idle","$repos_dir");
329 130 jt_eaton
               $repo_db->db_put( $V_L, join(':', @repo_info) );
330
 
331
 
332
 
333
               my $V_L_N = "${vendor}__${library}_${name}"    ;
334 131 jt_eaton
               @repo_info  = ("component","$name","$lib_comp_sep","$repos_dir" );
335 130 jt_eaton
               $repo_db->db_put( $V_L_N, join(':', @repo_info) );
336
 
337
 
338
 
339
               my @comp_info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
340
               $component_db->db_put( $V_L_N_V, join(':', @comp_info) );
341
 
342 131 jt_eaton
 
343 130 jt_eaton
#               print " .${t_local}/${t_name}.xml , ${component_path}                     \n  ";
344
 
345
 
346
               }
347
 
348
 
349
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
350
 
351
 
352
 
353
             if($type eq "spirit:design")
354
               {
355
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
356
               $design_db->db_put( $V_L_N_V, join(':', @info) );
357
               }
358
 
359
 
360
             elsif($type eq "spirit:abstractionDefinition")
361
               {
362 131 jt_eaton
#               print "ABSDEF  $V_L_N_V    \n";
363
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}","${name}","${library}","${vendor}"         );
364 130 jt_eaton
               $abstractionDefinition_db->db_put( $V_L_N_V, join(':', @info) );
365
               }
366
 
367
 
368
             elsif($type eq "spirit:busDefinition")
369
               {
370
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
371
               $busDefinition_db->db_put( $V_L_N_V, join(':', @info) );
372
               }
373
 
374
 
375 131 jt_eaton
 
376
 
377
 
378
 
379 130 jt_eaton
             if($type eq "socgen:libraryConfiguration")
380
               {
381
               $V_L  = "${vendor}__${library}"    ;
382
               @info  = (".${t_local}/${t_name}.xml" );
383
               $libraryConfiguration_db->db_put( $V_L, join(':', @info) );
384
               }
385
 
386
 
387
             if($type eq "socgen:componentConfiguration")
388
               {
389
               my $V_L_N = "${vendor}__${library}_${name}"    ;
390
               @info  = (".${t_local}/${t_name}.xml" );
391
               $componentConfiguration_db->db_put( $V_L_N, join(':', @info) );
392
               }
393
 
394
 
395 131 jt_eaton
my $uplift_data;
396
$repo_db->db_get("log_name", $uplift_data );
397 130 jt_eaton
 
398
 
399
 
400
 
401 117 jt_eaton
             }
402
 
403 131 jt_eaton
          &link_dir("$src/$item","$repos_dir" );
404 117 jt_eaton
          }
405
 
406
     }
407
 
408
}
409
 
410
 
411
 
412 131 jt_eaton
}
413 130 jt_eaton
 
414
 
415
$repo_db->db_close();
416
$component_db->db_close();
417
$design_db->db_close();
418
$abstractionDefinition_db->db_close();
419
$busDefinition_db->db_close();
420
$libraryConfiguration_db->db_close();
421
$componentConfiguration_db->db_close();

powered by: WebSVN 2.1.0

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