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

Subversion Repositories socgen

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

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 135 jt_eaton
#/****************************************************************************/
5
#/*                                                                          */
6
#/*   SOCGEN Design for Reuse toolset                                        */
7
#/*                                                                          */
8
#/*   Version 1.0.0                                                          */
9
#/*                                                                          */
10
#/*   Author(s):                                                             */
11
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
12
#/*                                                                          */
13
#/****************************************************************************/
14
#/*                                                                          */
15
#/*                                                                          */
16
#/*             Copyright 2016 John T Eaton                                  */
17
#/*                                                                          */
18
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
19
#/* you may not use this file except in compliance with the License.         */
20
#/* You may obtain a copy of the License at                                  */
21
#/*                                                                          */
22
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
23
#/*                                                                          */
24
#/* Unless required by applicable law or agreed to in writing, software      */
25
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
26
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
27
#/* See the License for the specific language governing permissions and      */
28
#/* limitations under the License.                                           */
29
#/*                                                                          */
30
#/*                                                                          */
31
#/****************************************************************************/
32 117 jt_eaton
 
33
############################################################################
34
# General PERL config
35
############################################################################
36
use Getopt::Long;
37
use English;
38
use File::Basename;
39
use Cwd;
40
use XML::LibXML;
41 131 jt_eaton
use lib './tools';
42
use sys::lib;
43
use BerkeleyDB;
44 117 jt_eaton
 
45
 
46
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
47
 
48
 
49
 
50
 
51
############################################################################
52
### Process the options
53
############################################################################
54
 
55
Getopt::Long::config("require_order", "prefix=-");
56
GetOptions("h","help"
57
) || die "(use '$program_name -h' for help)";
58
 
59
 
60
##############################################################################
61
## Help option
62
##############################################################################
63
if ( $opt_h or $opt_help  )
64
   {
65 131 jt_eaton
   print "\n type create_yp  $path  \n";
66 117 jt_eaton
   exit 1;
67
   }
68
 
69
 
70
##############################################################################
71
##
72
##############################################################################
73
 
74 131 jt_eaton
my $home           = cwd();
75
my $path           = $ARGV[0];
76 117 jt_eaton
 
77 131 jt_eaton
mkdir $path,0755   unless( -e $path );
78 120 jt_eaton
 
79
 
80 131 jt_eaton
$repo_db                    = new BerkeleyDB::Hash( -Filename => "${path}/repo.dbm",                   -Flags => DB_CREATE ) or die "Cannot open file: $!";
81
$component_db               = new BerkeleyDB::Hash( -Filename => "${path}/component.dbm",              -Flags => DB_CREATE ) or die "Cannot open file: $!";
82
$design_db                  = new BerkeleyDB::Hash( -Filename => "${path}/design.dbm",                 -Flags => DB_CREATE ) or die "Cannot open file: $!";
83 135 jt_eaton
$designConfiguration_db     = new BerkeleyDB::Hash( -Filename => "${path}/designConfiguration.dbm",    -Flags => DB_CREATE ) or die "Cannot open file: $!";
84 131 jt_eaton
$busDefinition_db           = new BerkeleyDB::Hash( -Filename => "${path}/busDefinition.dbm",          -Flags => DB_CREATE ) or die "Cannot open file: $!";
85
$abstractionDefinition_db   = new BerkeleyDB::Hash( -Filename => "${path}/abstractionDefinition.dbm",  -Flags => DB_CREATE ) or die "Cannot open file: $!";
86
$libraryConfiguration_db    = new BerkeleyDB::Hash( -Filename => "${path}/libraryConfiguration.dbm",   -Flags => DB_CREATE ) or die "Cannot open file: $!";
87
$componentConfiguration_db  = new BerkeleyDB::Hash( -Filename => "${path}/componentConfiguration.dbm", -Flags => DB_CREATE ) or die "Cannot open file: $!";
88 120 jt_eaton
 
89
 
90 117 jt_eaton
 
91 131 jt_eaton
my $parser = XML::LibXML->new();
92 117 jt_eaton
 
93
 
94
 
95 131 jt_eaton
my    $workspace    = $parser->parse_file("${home}/workspace.xml");
96 117 jt_eaton
 
97
 
98 130 jt_eaton
 
99
 
100
 
101
 
102
 
103
 
104
 
105 131 jt_eaton
my @repos =();
106
my $repo;
107
 
108
 
109
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:external/socgen:repo'))
110
                  {
111
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
112
                  my $repo_path  = $repo->findnodes('./socgen:path/text()')->to_literal ;
113
                  print "Linking $repo_name   $repo_path \n";
114
                  if(-e  $repo_name)
115
                   {
116
                   print "Removing $repo_name  \n";
117
                   my $cmd = "rm -r $repo_name  \n";
118
                   if(system($cmd)){};
119
                   }
120
 
121 135 jt_eaton
                  my $cmd = "mkdir $repo_name ;lndir -silent  $repo_path  $repo_name;";
122 131 jt_eaton
                  if(system($cmd)){};
123
 
124
 
125
 
126
                  }
127
 
128
 
129
 
130
 
131
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:repos/socgen:repo'))
132
                  {
133
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
134
                  push  @repos,$repo_name;
135
                  }
136
 
137
my $repos_dir ;
138
 
139
 
140
 
141
foreach $repos_dir (@repos)
142
{
143
print "Project_dir  $repos_dir  \n";
144
 
145
 
146
 
147
 
148 117 jt_eaton
#/*********************************************************************************************/
149
#/                                                                                            */
150
#/                                                                                            */
151
#/                                                                                            */
152
#/                                                                                            */
153
#/                                                                                            */
154
#/                                                                                            */
155
#/*********************************************************************************************/
156
 
157
 
158 131 jt_eaton
$root = "${home}${repos_dir}";
159
&link_dir( "$root","$repos_dir"  );
160 117 jt_eaton
 
161
 
162 131 jt_eaton
 
163 117 jt_eaton
#/*********************************************************************************************/
164
#/                                                                                            */
165
#/                                                                                            */
166
#/                                                                                            */
167
#/                                                                                            */
168
#/                                                                                            */
169
#/                                                                                            */
170
#/*********************************************************************************************/
171
 
172
# recursively map directory information
173
 
174
sub link_dir {
175
    my $src  = shift;
176 131 jt_eaton
    my $repos_dir  = shift;
177
 
178
 
179 117 jt_eaton
    return unless( -e $src );
180
 
181
    if( -d $src )
182
        {
183
        my @contents = (  );
184
        opendir( DIR, $src );
185
        while( my $item = readdir( DIR ))
186
            {
187
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
188
            push( @contents, $item );
189
            }
190
        closedir( DIR );
191
 
192
        # recurse on items in the directory
193
        foreach my $item ( @contents )
194
          {
195 135 jt_eaton
          $_ = $item;
196 124 jt_eaton
          if(/(\S+)\.xml/)
197 117 jt_eaton
             {
198
             my $t_name                = $1;
199 120 jt_eaton
             $_ = $src;
200
             if(/${home}(\S+)/) { $t_local = $1; }
201 135 jt_eaton
      #       print "creat_yp: Parsing ${home}${t_local}/${t_name}.xml \n";
202
 
203 124 jt_eaton
             my    $xml_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
204 125 jt_eaton
 
205 135 jt_eaton
#             print "creat_yp: Parsed \n";
206
 
207 131 jt_eaton
            if(${t_name} eq "libraryCfg"  )
208 124 jt_eaton
               {
209 131 jt_eaton
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
210 124 jt_eaton
                  {
211 135 jt_eaton
#                 print "creat_yp: Parsed socgen \n";
212 131 jt_eaton
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
213
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
214
                  $name     = "";
215
                  $version  = "";
216
                  $type     = "socgen:libraryConfiguration";
217 124 jt_eaton
                  }
218 131 jt_eaton
                }
219
             elsif(${t_name} eq "componentCfg"  )
220
              {
221
              foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
222 124 jt_eaton
                  {
223 135 jt_eaton
#                                 print "creat_yp: Parsed socgen \n";
224 124 jt_eaton
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
225
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
226
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
227
                  $version  = "";
228
                  $type     = "socgen:componentConfiguration";
229
                  }
230 131 jt_eaton
              }
231
 
232
             else
233
             {
234 135 jt_eaton
#                                 print "creat_yp: Parsing spirit \n";
235
               foreach my $comp ($xml_file->findnodes('//ipxact:component'))
236 125 jt_eaton
                  {
237 135 jt_eaton
#                                                 print "creat_yp: Parsed spirit \n";
238
                  $vendor   = $comp->findnodes('./ipxact:vendor/text()')->to_literal ;
239
                  $library  = $comp->findnodes('./ipxact:library/text()')->to_literal ;
240
                  $type     = "ipxact:component";
241
                  $name     = $comp->findnodes('./ipxact:name/text()')->to_literal ;
242
                  $version  = $comp->findnodes('./ipxact:version/text()')->to_literal ;
243 125 jt_eaton
                  }
244
 
245
 
246 135 jt_eaton
               foreach my $design ($xml_file->findnodes('//ipxact:design'))
247 125 jt_eaton
                  {
248 135 jt_eaton
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
249
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
250
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
251
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
252
                  $type     = "ipxact:design";
253 125 jt_eaton
                  }
254 135 jt_eaton
 
255
 
256
               foreach my $design ($xml_file->findnodes('//ipxact:designConfiguration'))
257
                  {
258
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
259
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
260
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
261
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
262
                  $type     = "ipxact:designConfiguration";
263
                  }
264
 
265 131 jt_eaton
 
266 125 jt_eaton
 
267 135 jt_eaton
               foreach my $design ($xml_file->findnodes('//ipxact:abstractionDefinition'))
268 125 jt_eaton
                  {
269 135 jt_eaton
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
270
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
271
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
272
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
273
                  $type     = "ipxact:abstractionDefinition";
274 125 jt_eaton
                  }
275
 
276
 
277 135 jt_eaton
               foreach my $design ($xml_file->findnodes('//ipxact:busDefinition'))
278 125 jt_eaton
                  {
279 135 jt_eaton
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
280
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
281
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
282
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
283
                  $type     = "ipxact:busDefinition";
284 125 jt_eaton
                  }
285
 
286
 
287 131 jt_eaton
 
288
 
289 125 jt_eaton
 
290 131 jt_eaton
 
291 117 jt_eaton
 
292 131 jt_eaton
               }
293 117 jt_eaton
 
294 124 jt_eaton
             $vendor_match = "/${vendor}/";
295
             $library_match = "/${library}/";
296
             $name_match = "/${name}/";
297
 
298
             $_ = $t_local;
299
             if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
300
             else                                              { $vendor_path      = ""; }
301
             if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
302
             else                                              { $library_path     = ""; }
303 130 jt_eaton
             if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = "/${2}/"; }
304
             else                                              { $lib_comp_sep     = "/"; }
305
             if(/(\S+)($name_match)(\S+)/)
306
               {
307
               $component_path   = "/${3}";
308
               $environment_path = $1;
309
               }
310
             else                                              { $component_path   = "/"; }
311 117 jt_eaton
 
312
 
313
 
314 131 jt_eaton
 
315 135 jt_eaton
#               print "${vendor}__${library}_${name}_${version}   $type  ---  $t_local  $library_match  $lib_comp_sep  $name_match    \n";
316 130 jt_eaton
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
317
 
318
 
319
 
320 135 jt_eaton
             if($type eq "ipxact:component")
321 130 jt_eaton
               {
322
 
323
               my $V = "${vendor}"    ;
324 131 jt_eaton
               my @repo_info  = ("vendor","$vendor","idle","$repos_dir" );
325 130 jt_eaton
               $repo_db->db_put( $V, join(':', @repo_info) );
326
 
327
 
328
               my $V_L = "${vendor}__${library}"    ;
329 131 jt_eaton
               @repo_info  = ("library","$library","$library_path" ,"idle","$repos_dir");
330 130 jt_eaton
               $repo_db->db_put( $V_L, join(':', @repo_info) );
331
 
332
 
333
 
334
               my $V_L_N = "${vendor}__${library}_${name}"    ;
335 131 jt_eaton
               @repo_info  = ("component","$name","$lib_comp_sep","$repos_dir" );
336 130 jt_eaton
               $repo_db->db_put( $V_L_N, join(':', @repo_info) );
337
 
338
 
339
 
340
               my @comp_info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
341
               $component_db->db_put( $V_L_N_V, join(':', @comp_info) );
342
 
343 131 jt_eaton
 
344 130 jt_eaton
#               print " .${t_local}/${t_name}.xml , ${component_path}                     \n  ";
345
 
346
 
347
               }
348
 
349
 
350
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
351
 
352
 
353
 
354 135 jt_eaton
             if($type eq "ipxact:design")
355 130 jt_eaton
               {
356
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
357
               $design_db->db_put( $V_L_N_V, join(':', @info) );
358
               }
359
 
360 135 jt_eaton
             elsif($type eq "ipxact:designConfiguration")
361
               {
362
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}","${name}","${library}","${vendor}"         );
363
               $designConfiguration_db->db_put( $V_L_N_V, join(':', @info) );
364
               }
365 130 jt_eaton
 
366 135 jt_eaton
 
367
             elsif($type eq "ipxact:abstractionDefinition")
368 130 jt_eaton
               {
369 131 jt_eaton
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}","${name}","${library}","${vendor}"         );
370 130 jt_eaton
               $abstractionDefinition_db->db_put( $V_L_N_V, join(':', @info) );
371
               }
372
 
373
 
374 135 jt_eaton
             elsif($type eq "ipxact:busDefinition")
375 130 jt_eaton
               {
376
               @info  = (".${t_local}/${t_name}.xml","${component_path}","${version}" );
377
               $busDefinition_db->db_put( $V_L_N_V, join(':', @info) );
378
               }
379
 
380
 
381 131 jt_eaton
 
382
 
383
 
384
 
385 130 jt_eaton
             if($type eq "socgen:libraryConfiguration")
386
               {
387
               $V_L  = "${vendor}__${library}"    ;
388
               @info  = (".${t_local}/${t_name}.xml" );
389
               $libraryConfiguration_db->db_put( $V_L, join(':', @info) );
390
               }
391
 
392
 
393
             if($type eq "socgen:componentConfiguration")
394
               {
395
               my $V_L_N = "${vendor}__${library}_${name}"    ;
396
               @info  = (".${t_local}/${t_name}.xml" );
397
               $componentConfiguration_db->db_put( $V_L_N, join(':', @info) );
398
               }
399
 
400
 
401 131 jt_eaton
my $uplift_data;
402
$repo_db->db_get("log_name", $uplift_data );
403 130 jt_eaton
 
404
 
405
 
406
 
407 117 jt_eaton
             }
408
 
409 131 jt_eaton
          &link_dir("$src/$item","$repos_dir" );
410 117 jt_eaton
          }
411
 
412
     }
413
 
414
}
415
 
416
 
417
 
418 131 jt_eaton
}
419 130 jt_eaton
 
420
 
421
$repo_db->db_close();
422
$component_db->db_close();
423
$design_db->db_close();
424
$abstractionDefinition_db->db_close();
425
$busDefinition_db->db_close();
426
$libraryConfiguration_db->db_close();
427
$componentConfiguration_db->db_close();

powered by: WebSVN 2.1.0

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