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 135 jt_eaton
eval 'exec `which perl` -S $0 ${1+"$@"}'
2
   if 0;
3
#/****************************************************************************/
4
#/*                                                                          */
5
#/*   SOCGEN Design for Reuse toolset                                        */
6
#/*                                                                          */
7
#/*   Version 1.0.0                                                          */
8
#/*                                                                          */
9
#/*   Author(s):                                                             */
10
#/*      - John Eaton, z3qmtr45@gmail.com                                    */
11
#/*                                                                          */
12
#/****************************************************************************/
13
#/*                                                                          */
14
#/*                                                                          */
15
#/*             Copyright 2016 John T Eaton                                  */
16
#/*                                                                          */
17
#/* Licensed under the Apache License, Version 2.0 (the "License");          */
18
#/* you may not use this file except in compliance with the License.         */
19
#/* You may obtain a copy of the License at                                  */
20
#/*                                                                          */
21
#/*    http://www.apache.org/licenses/LICENSE-2.0                            */
22
#/*                                                                          */
23
#/* Unless required by applicable law or agreed to in writing, software      */
24
#/* distributed under the License is distributed on an "AS IS" BASIS,        */
25
#/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
26
#/* See the License for the specific language governing permissions and      */
27
#/* limitations under the License.                                           */
28
#/*                                                                          */
29
#/*                                                                          */
30
#/****************************************************************************/
31
 
32
 
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
use lib './tools';
42
use sys::lib;
43
use BerkeleyDB;
44
 
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
   print "\n type Create_YP  $path  \n";
66
   exit 1;
67
   }
68
 
69
 
70
##############################################################################
71
##
72
##############################################################################
73
 
74
my $home           = cwd();
75
my $path           = $ARGV[0];
76
 
77
mkdir $path,0755   unless( -e $path );
78
 
79
 
80
$repo_db                    = new BerkeleyDB::Hash( -Filename => "${path}/repo.dbm",                   -Flags => DB_CREATE ) or die "Cannot open file: $!";
81
my $parser = XML::LibXML->new();
82
 
83
 
84
 
85
my    $workspace    = $parser->parse_file("${home}/workspace.xml");
86
 
87
 
88
 
89
 
90
 
91
 
92
 
93
 
94
 
95
my @repos =();
96
my $repo;
97
 
98
 
99
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:external/socgen:repo'))
100
                  {
101
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
102
                  my $repo_path  = $repo->findnodes('./socgen:path/text()')->to_literal ;
103
                  #print "Linking $repo_name   $repo_path \n";
104
                  if(-e  $repo_name)
105
                   {
106
                   #print "Removing $repo_name  \n";
107
                   my $cmd = "rm -r $repo_name  \n";
108
                   if(system($cmd)){};
109
                   }
110
 
111
                  my $cmd = "mkdir $repo_name ;lndir  $repo_path  $repo_name;";
112
                  if(system($cmd)){};
113
 
114
 
115
 
116
                  }
117
 
118
 
119
 
120
 
121
foreach my $repo ($workspace->findnodes('//socgen:workspace/socgen:repos/socgen:repo'))
122
                  {
123
                  my $repo_name  = $repo->findnodes('./socgen:name/text()')->to_literal ;
124
                  push  @repos,$repo_name;
125
                  }
126
 
127
my $repos_dir ;
128
 
129
 
130
 
131
foreach $repos_dir (@repos)
132
{
133
print "Project_dir  $repos_dir  \n";
134
 
135
 
136
 
137
 
138
#/*********************************************************************************************/
139
#/                                                                                            */
140
#/                                                                                            */
141
#/                                                                                            */
142
#/                                                                                            */
143
#/                                                                                            */
144
#/                                                                                            */
145
#/*********************************************************************************************/
146
 
147
 
148
$root = "${home}${repos_dir}";
149
&link_dir( "$root","$repos_dir"  );
150
 
151
 
152
 
153
#/*********************************************************************************************/
154
#/                                                                                            */
155
#/                                                                                            */
156
#/                                                                                            */
157
#/                                                                                            */
158
#/                                                                                            */
159
#/                                                                                            */
160
#/*********************************************************************************************/
161
 
162
# recursively map directory information
163
 
164
sub link_dir {
165
    my $src  = shift;
166
    my $repos_dir  = shift;
167
 
168
 
169
    return unless( -e $src );
170
 
171
    if( -d $src )
172
        {
173
        my @contents = (  );
174
        opendir( DIR, $src );
175
        while( my $item = readdir( DIR ))
176
            {
177
            next if( $item eq '.' or $item eq '..'   or $item eq '.svn'    );
178
            push( @contents, $item );
179
            }
180
        closedir( DIR );
181
 
182
        # recurse on items in the directory
183
        foreach my $item ( @contents )
184
          {
185
          $_ = $item;
186
          if(/(\S+)\.xml/)
187
             {
188
             my $t_name                = $1;
189
             $_ = $src;
190
             if(/${home}(\S+)/) { $t_local = $1; }
191
 
192
             my    $xml_file    = $parser->parse_file("${home}${t_local}/${t_name}.xml");
193
 
194
            $cmd = "r   ${home}${t_local}/${t_name}.xml\n";
195
           print "${home}${t_local}/${t_name}.xml\n";
196
 
197
            if(system($cmd)){};
198
 
199
 
200
            if(${t_name} eq "libraryCfg"  )
201
               {
202
               foreach my $design ($xml_file->findnodes('//socgen:libraryConfiguration'))
203
                  {
204
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
205
                  $library  = $design->findnodes('./socgen:name/text()')->to_literal ;
206
                  $name     = "";
207
                  $version  = "";
208
                  $type     = "socgen:libraryConfiguration";
209
                  }
210
                }
211
             elsif(${t_name} eq "componentCfg"  )
212
              {
213
              foreach my $design ($xml_file->findnodes('//socgen:componentConfiguration'))
214
                  {
215
                  $vendor   = $design->findnodes('./socgen:vendor/text()')->to_literal ;
216
                  $library  = $design->findnodes('./socgen:library/text()')->to_literal ;
217
                  $name     = $design->findnodes('./socgen:component/text()')->to_literal ;
218
                  $version  = "";
219
                  $type     = "socgen:componentConfiguration";
220
                  }
221
              }
222
 
223
             else
224
             {
225
 
226
               foreach my $comp ($xml_file->findnodes('//ipxact:component'))
227
                  {
228
                  $vendor   = $comp->findnodes('./ipxact:vendor/text()')->to_literal ;
229
                  $library  = $comp->findnodes('./ipxact:library/text()')->to_literal ;
230
                  $type     = "ipxact:component";
231
                  $name     = $comp->findnodes('./ipxact:name/text()')->to_literal ;
232
                  $version  = $comp->findnodes('./ipxact:version/text()')->to_literal ;
233
                  }
234
 
235
 
236
               foreach my $design ($xml_file->findnodes('//ipxact:design'))
237
                  {
238
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
239
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
240
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
241
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
242
                  $type     = "ipxact:design";
243
 
244
                  }
245
 
246
 
247
 
248
               foreach my $design ($xml_file->findnodes('//ipxact:abstractionDefinition'))
249
                  {
250
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
251
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
252
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
253
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
254
                  $type     = "ipxact:abstractionDefinition";
255
                  }
256
 
257
 
258
               foreach my $design ($xml_file->findnodes('//ipxact:busDefinition'))
259
                  {
260
                  $vendor   = $design->findnodes('./ipxact:vendor/text()')->to_literal ;
261
                  $library  = $design->findnodes('./ipxact:library/text()')->to_literal ;
262
                  $name     = $design->findnodes('./ipxact:name/text()')->to_literal ;
263
                  $version  = $design->findnodes('./ipxact:version/text()')->to_literal ;
264
                  $type     = "ipxact:busDefinition";
265
                  }
266
 
267
 
268
 
269
 
270
 
271
 
272
 
273
               }
274
 
275
             $vendor_match = "/${vendor}/";
276
             $library_match = "/${library}/";
277
             $name_match = "/${name}/";
278
 
279
             $_ = $t_local;
280
             if(/\S+($vendor_match)(\S+)/)                     { $vendor_path      = $2; }
281
             else                                              { $vendor_path      = ""; }
282
             if(/\S+($library_match)(\S+)/)                    { $library_path     = $2; }
283
             else                                              { $library_path     = ""; }
284
             if(/\S+($library_match)(\S+)($name_match)(\S+)/)  { $lib_comp_sep     = "/${2}/"; }
285
             else                                              { $lib_comp_sep     = "/"; }
286
             if(/(\S+)($name_match)(\S+)/)
287
               {
288
               $component_path   = "/${3}";
289
               $environment_path = $1;
290
               }
291
             else                                              { $component_path   = "/"; }
292
 
293
 
294
 
295
 
296
 
297
               $V_L_N_V  = "${vendor}__${library}_${name}_${version}"    ;
298
 
299
 
300
 
301
             if($type eq "ipxact:component")
302
               {
303
 
304
               my $V = "${vendor}"    ;
305
               my @repo_info  = ("vendor","$vendor","idle","$repos_dir" );
306
               $repo_db->db_put( $V, join(':', @repo_info) );
307
 
308
 
309
               my $V_L = "${vendor}__${library}"    ;
310
               @repo_info  = ("library","$library","$library_path" ,"idle","$repos_dir");
311
               $repo_db->db_put( $V_L, join(':', @repo_info) );
312
 
313
 
314
 
315
               my $V_L_N = "${vendor}__${library}_${name}"    ;
316
               @repo_info  = ("component","$name","$lib_comp_sep","$repos_dir" );
317
               $repo_db->db_put( $V_L_N, join(':', @repo_info) );
318
 
319
 
320
 
321
 
322
 
323
 
324
 
325
 
326
 
327
               }
328
 
329
 
330
 
331
 
332
 
333
 
334
 
335
 
336
 
337
 
338
 
339
 
340
 
341
 
342
 
343
 
344
 
345
 
346
 
347
 
348
 
349
 
350
 
351
 
352
 
353
             }
354
 
355
          &link_dir("$src/$item","$repos_dir" );
356
          }
357
 
358
     }
359
 
360
}
361
 
362
 
363
 
364
}
365
 
366
 
367
$repo_db->db_close();

powered by: WebSVN 2.1.0

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