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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [tools/] [sys/] [soc_link_child] - Blame information for rev 127

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 94 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 119 jt_eaton
#/*    Copyright (C) <2010-2012>                */
23 94 jt_eaton
#/*                                                                    */
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 99 jt_eaton
use Cwd;
55
use XML::LibXML;
56 117 jt_eaton
use lib './tools';
57
use sys::lib;
58
use yp::lib;
59 94 jt_eaton
 
60 99 jt_eaton
 
61 94 jt_eaton
$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 99 jt_eaton
GetOptions("h","help",
72 119 jt_eaton
           "prefix=s" => \$prefix,
73 99 jt_eaton
           "vendor=s" => \$vendor,
74 94 jt_eaton
           "project=s" => \$project,
75
           "component=s" => \$component,
76 117 jt_eaton
           "version=s" => \$version
77 119 jt_eaton
 
78 94 jt_eaton
) || die "(use '$program_name -h' for help)";
79
 
80
 
81
##############################################################################
82
## Help option
83
##############################################################################
84 99 jt_eaton
if ( $opt_h or $opt_help  )
85 94 jt_eaton
   {
86 119 jt_eaton
   print "\n type soc_link_child  -prefix /work -vendor vendor_name -project project_name  -component  component_name -version  version_name  projects_dir ";
87 94 jt_eaton
   print "\n";
88
   exit 1;
89
   }
90
 
91
 
92
##############################################################################
93
##
94
##############################################################################
95
 
96 119 jt_eaton
my $home              = cwd();
97 94 jt_eaton
 
98
 
99 117 jt_eaton
my $parser           = XML::LibXML->new();
100 94 jt_eaton
 
101 119 jt_eaton
my $projects_dir    = $ARGV[0];
102
chomp($projects_dir);
103 118 jt_eaton
my $variant;
104 117 jt_eaton
 
105 118 jt_eaton
if($version) {$variant = "${component}_${version}";}
106
else         {$variant = "${component}";}
107 117 jt_eaton
 
108
 
109 118 jt_eaton
 
110 94 jt_eaton
#/*********************************************************************************************/
111
#/                                                                                            */
112 118 jt_eaton
#/ link overlay projects                                                                      */
113 94 jt_eaton
#/                                                                                            */
114 118 jt_eaton
#/*********************************************************************************************/
115
 
116
 
117
 
118
 
119 124 jt_eaton
my $sogen_file     = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$vendor,$project,$component));
120 118 jt_eaton
 
121
 
122 127 jt_eaton
foreach  my   $i_name ($sogen_file->findnodes("//socgen:syn/socgen:ise[socgen:variant/text() = '$variant']"))
123 118 jt_eaton
   {
124
   my($replace_vendor)  = $i_name ->findnodes('socgen:target/socgen:vendor/text()')->to_literal ;
125
   my($replace_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
126 119 jt_eaton
   my @replace_components = yp::lib::find_components("spirit:component",$replace_vendor,$replace_library);
127 118 jt_eaton
 
128
   foreach my $replace_component (@replace_components)
129
     {
130 119 jt_eaton
      &link_child($vendor, $project,$replace_component, $replace_library ,$replace_vendor);
131 118 jt_eaton
     }
132
   }
133
 
134
 
135
 
136
 
137
 
138 120 jt_eaton
 
139
 
140
 
141 118 jt_eaton
#/*********************************************************************************************/
142 94 jt_eaton
#/                                                                                            */
143
#/                                                                                            */
144
#/                                                                                            */
145
#/                                                                                            */
146 118 jt_eaton
#/                                                                                            */
147
#/                                                                                            */
148 94 jt_eaton
#/*********************************************************************************************/
149
 
150
 
151
 
152
my      @filelist      = (  );
153
 
154 125 jt_eaton
@filelist = yp::lib::parse_component_file("$vendor","$project","$component","$version");
155 120 jt_eaton
 
156 94 jt_eaton
 
157
 
158
 
159
foreach $line (@filelist)
160
   {
161
   $_ = $line;
162 120 jt_eaton
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
163 94 jt_eaton
     {
164 119 jt_eaton
     $new_vendor      = $1;
165
     $new_proj        = $2;
166
     $new_comp        = $3;
167 120 jt_eaton
     $new_version     = $4;
168 127 jt_eaton
     &link_child( $vendor,$project,$new_comp, $new_proj ,$new_vendor);
169 94 jt_eaton
     }
170
   }
171
 
172
 
173
 
174
 
175
 
176
 
177
#/*********************************************************************************************/
178 124 jt_eaton
#/  link the component and software for each child under the parents work/childern dir        */
179 94 jt_eaton
#/                                                                                            */
180
#/                                                                                            */
181
#/                                                                                            */
182
#/                                                                                            */
183
#/                                                                                            */
184
#/*********************************************************************************************/
185
 
186
 
187
 
188
sub link_child {
189 119 jt_eaton
                 my $parent_vendor      = shift;
190
                 my $parent_library      = shift;
191
                 my $child_component = shift;
192
                 my $child_library = shift;
193
                 my $child_vendor = shift;
194
 
195 127 jt_eaton
                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library,$child_component);
196 119 jt_eaton
 
197
 
198 127 jt_eaton
 
199 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children";
200 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
201 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}";
202 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
203 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
204 94 jt_eaton
 
205 120 jt_eaton
                 unless( -e $path )
206
                   {
207
                   mkdir $path,0755;
208
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}/bin";
209
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
210
                   &sys::lib::link_dir( "$root", "$dest"  );
211
                   symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile.root");
212
                   symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile");
213
                   }
214 119 jt_eaton
 
215 115 jt_eaton
 
216 127 jt_eaton
 
217
                   my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}";
218
                   mkdir $path,0755             unless( -e $path );
219
 
220
                   my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
221
 
222
 
223
                   unless( -e $path )
224
                   {
225
                   mkdir $path,0755;
226
 
227
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_comp_sep}/${child_component}";
228
                   $dest = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
229
                   &sys::lib::link_dir( "$root", "$dest"  );
230
 
231
 
232
 
233
 
234
                   my $sogen_file               = $parser->parse_file(yp::lib::find_socgen("socgen:componentConfiguration",$child_vendor,$child_library,$child_component));
235
                   my $sim_library_path         = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
236
                   my $sim_full_path            = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${sim_library_path}";
237
 
238
                   if(  $sim_library_path)
239
                     {
240
                   if(-e $sim_full_path)
241
                    {
242
 
243
                    my $cmd = "rm -r    .${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${sim_library_path}  \n";
244
                    if (system($cmd)) {}
245
                    }
246
                     }
247
 
248
 
249
                   my $syn_library_path         = $sogen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:library_path/text()")->to_literal;
250
                   my $syn_full_path            = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${syn_library_path}";
251
 
252
                   if(  $syn_library_path)
253
                     {
254
                   if(-e $syn_full_path)
255
                    {
256
 
257
                    my $cmd = "rm -r    .${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${syn_library_path}  \n";
258
                    if (system($cmd)) {}
259
                    }
260
                    }
261
 
262
 
263
 
264
                 }
265
 
266
 
267 120 jt_eaton
                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);
268 115 jt_eaton
 
269 120 jt_eaton
                 if($lib_sw_dir)
270
                   {
271
                   my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
272
                   unless( -e $path )
273
                     {
274
                     mkdir $path,0755;
275
                     $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_sw_dir}";
276
                     $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
277
                     &sys::lib::link_dir( "$root", "$dest"  );
278
                     }
279
                   }
280
 
281 115 jt_eaton
 
282 127 jt_eaton
 
283
 
284
 
285
 
286
 
287
 
288
 
289 94 jt_eaton
               }
290
 
291
 
292
 
293
 
294
 
295 120 jt_eaton
 

powered by: WebSVN 2.1.0

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