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

Subversion Repositories socgen

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

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 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 94 jt_eaton
 
33
 
34
############################################################################
35
# General PERL config
36
############################################################################
37
use Getopt::Long;
38
use English;
39
use File::Basename;
40 99 jt_eaton
use Cwd;
41
use XML::LibXML;
42 117 jt_eaton
use lib './tools';
43
use sys::lib;
44
use yp::lib;
45 94 jt_eaton
 
46 99 jt_eaton
 
47 94 jt_eaton
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
48
 
49
 
50
 
51
 
52
############################################################################
53
### Process the options
54
############################################################################
55
 
56
Getopt::Long::config("require_order", "prefix=-");
57 99 jt_eaton
GetOptions("h","help",
58 119 jt_eaton
           "prefix=s" => \$prefix,
59 99 jt_eaton
           "vendor=s" => \$vendor,
60 131 jt_eaton
           "library=s" => \$library,
61 94 jt_eaton
           "component=s" => \$component,
62 117 jt_eaton
           "version=s" => \$version
63 119 jt_eaton
 
64 94 jt_eaton
) || die "(use '$program_name -h' for help)";
65
 
66
 
67
##############################################################################
68
## Help option
69
##############################################################################
70 99 jt_eaton
if ( $opt_h or $opt_help  )
71 94 jt_eaton
   {
72 131 jt_eaton
   print "\n type soc_link_child  -prefix /work -vendor vendor_name -library library_name  -component  component_name -version  version_name   ";
73 94 jt_eaton
   print "\n";
74
   exit 1;
75
   }
76
 
77
 
78
##############################################################################
79
##
80
##############################################################################
81
 
82 119 jt_eaton
my $home              = cwd();
83 94 jt_eaton
 
84
 
85 117 jt_eaton
my $parser           = XML::LibXML->new();
86 94 jt_eaton
 
87 131 jt_eaton
 
88 118 jt_eaton
my $variant;
89 117 jt_eaton
 
90 118 jt_eaton
if($version) {$variant = "${component}_${version}";}
91
else         {$variant = "${component}";}
92 117 jt_eaton
 
93
 
94 118 jt_eaton
 
95 94 jt_eaton
#/*********************************************************************************************/
96
#/                                                                                            */
97 131 jt_eaton
#/ link overlay librarys                                                                      */
98 94 jt_eaton
#/                                                                                            */
99 118 jt_eaton
#/*********************************************************************************************/
100
 
101
 
102
 
103
 
104 131 jt_eaton
my $socgen_file     = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
105 118 jt_eaton
 
106
 
107 135 jt_eaton
foreach  my   $i_name ($socgen_file->findnodes("//socgen:syn/socgen:fpgas/socgen:fpga[socgen:variant/text() = '$variant']"))
108 118 jt_eaton
   {
109
   my($replace_vendor)  = $i_name ->findnodes('socgen:target/socgen:vendor/text()')->to_literal ;
110
   my($replace_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
111 130 jt_eaton
   my @replace_components = yp::lib::find_components($replace_vendor,$replace_library);
112 118 jt_eaton
 
113
   foreach my $replace_component (@replace_components)
114
     {
115 131 jt_eaton
      &link_child($vendor, $library,$replace_component, $replace_library ,$replace_vendor);
116 118 jt_eaton
     }
117
   }
118
 
119
 
120
 
121
 
122
 
123 120 jt_eaton
 
124
 
125
 
126 118 jt_eaton
#/*********************************************************************************************/
127 94 jt_eaton
#/                                                                                            */
128
#/                                                                                            */
129
#/                                                                                            */
130
#/                                                                                            */
131 118 jt_eaton
#/                                                                                            */
132
#/                                                                                            */
133 94 jt_eaton
#/*********************************************************************************************/
134
 
135
 
136
 
137
my      @filelist      = (  );
138
 
139 131 jt_eaton
@filelist = yp::lib::parse_component_file("$vendor","$library","$component","$version");
140 120 jt_eaton
 
141 94 jt_eaton
 
142
 
143
 
144
foreach $line (@filelist)
145
   {
146
   $_ = $line;
147 120 jt_eaton
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
148 94 jt_eaton
     {
149 119 jt_eaton
     $new_vendor      = $1;
150
     $new_proj        = $2;
151
     $new_comp        = $3;
152 120 jt_eaton
     $new_version     = $4;
153 131 jt_eaton
     &link_child( $vendor,$library,$new_comp, $new_proj ,$new_vendor);
154 94 jt_eaton
     }
155
   }
156
 
157
 
158
 
159
 
160
 
161
 
162
#/*********************************************************************************************/
163 124 jt_eaton
#/  link the component and software for each child under the parents work/childern dir        */
164 94 jt_eaton
#/                                                                                            */
165
#/                                                                                            */
166
#/                                                                                            */
167
#/                                                                                            */
168
#/                                                                                            */
169
#/*********************************************************************************************/
170
 
171
 
172
 
173
sub link_child {
174 119 jt_eaton
                 my $parent_vendor      = shift;
175
                 my $parent_library      = shift;
176
                 my $child_component = shift;
177
                 my $child_library = shift;
178
                 my $child_vendor = shift;
179
 
180 127 jt_eaton
                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library,$child_component);
181 131 jt_eaton
                 my $repo            = yp::lib::find_component_repo($child_vendor,$child_library,$child_component);
182 135 jt_eaton
                 my $child_dir       = yp::lib::get_child_dir;
183 119 jt_eaton
 
184 135 jt_eaton
                 my $path            = "./${child_dir}";
185
                 mkdir $path,0755      unless( -e $path );
186
                 my $path            = "./${child_dir}/${child_vendor}__${child_library}";
187
                 mkdir $path,0755      unless( -e $path );
188
 
189
                 my $path  = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}";
190 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
191 127 jt_eaton
 
192 135 jt_eaton
                 my $path  = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}${child_component}";
193 127 jt_eaton
 
194
 
195 135 jt_eaton
                 unless( -e $path )
196 127 jt_eaton
                   {
197
                   mkdir $path,0755;
198
 
199 131 jt_eaton
                   $root = "${home}/${repo}/${child_vendor}/${child_library}${lib_comp_sep}${child_component}";
200 135 jt_eaton
                   $dest = "./${child_dir}/${child_vendor}__${child_library}${lib_comp_sep}${child_component}";
201 127 jt_eaton
                   &sys::lib::link_dir( "$root", "$dest"  );
202
 
203 130 jt_eaton
                   my $socgen_file               = $parser->parse_file(yp::lib::find_componentConfiguration($child_vendor,$child_library,$child_component));
204
                   my $sim_library_path ;
205
                   my $lib_comp_sep             = yp::lib::find_lib_comp_sep($child_vendor,$child_library,$child_component);
206
                   my $sim_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
207 127 jt_eaton
 
208 130 jt_eaton
                   if ($sim_comp_path)
209
                      {
210
                      $sim_library_path            ="${lib_comp_sep}${sim_comp_path}";
211
                      }
212
                   else
213
                      {
214
                      $sim_library_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;
215
                      }
216 127 jt_eaton
 
217 135 jt_eaton
                   my $sim_full_path            = "./${child_dir}/${child_vendor}__${child_library}${sim_library_path}";
218 127 jt_eaton
 
219 130 jt_eaton
 
220 127 jt_eaton
                   if(  $sim_library_path)
221
                     {
222 130 jt_eaton
                      if(-e $sim_full_path)
223
                      {
224 135 jt_eaton
                      my $cmd = "rm -r    ./${child_dir}/${child_vendor}__${child_library}${sim_library_path}  \n";
225 130 jt_eaton
                      if (system($cmd)) {}
226
                      }
227 127 jt_eaton
                     }
228
 
229
 
230 130 jt_eaton
                   my $syn_library_path ;
231
 
232
                   my $syn_comp_path            = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:comp_path/text()")->to_literal;
233
 
234
                   if ($syn_comp_path)
235
                      {
236
                      $syn_library_path            ="${lib_comp_sep}${syn_comp_path}";
237
                      }
238
                   else
239
                      {
240
                      $syn_library_path           = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:syn/socgen:library_path/text()")->to_literal;
241
                      }
242
 
243
 
244 135 jt_eaton
                   my $syn_full_path            = "./${child_dir}/${child_vendor}__${child_library}${syn_library_path}";
245 127 jt_eaton
 
246
                   if(  $syn_library_path)
247
                     {
248
                   if(-e $syn_full_path)
249
                    {
250
 
251 135 jt_eaton
                    my $cmd = "rm -r    ./${child_dir}/${child_vendor}__${child_library}${syn_library_path}  \n";
252 127 jt_eaton
                    if (system($cmd)) {}
253
                    }
254
                    }
255
 
256
 
257
 
258
                 }
259
 
260
 
261 120 jt_eaton
                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);
262 115 jt_eaton
 
263 135 jt_eaton
                 if(defined $lib_sw_dir & length $lib_sw_dir > 0 )
264 120 jt_eaton
                   {
265 135 jt_eaton
                   my $path  = "./code";
266
                   mkdir $path,0755             unless( -e $path );
267
                      $path  = "./code/${child_vendor}__${child_library}";
268 120 jt_eaton
                   unless( -e $path )
269
                     {
270
                     mkdir $path,0755;
271 135 jt_eaton
                     $root = "${home}/${repo}/${child_vendor}/${child_library}/${lib_sw_dir}";
272
                     $dest = "${home}/code/${child_vendor}__${child_library}";
273 120 jt_eaton
                     &sys::lib::link_dir( "$root", "$dest"  );
274
                     }
275
                   }
276
 
277 115 jt_eaton
 
278 127 jt_eaton
 
279
 
280
 
281
 
282
 
283
 
284
 
285 94 jt_eaton
               }
286
 
287
 
288
 
289
 
290
 
291 120 jt_eaton
 

powered by: WebSVN 2.1.0

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