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

Subversion Repositories socgen

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

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
 
123 124 jt_eaton
foreach  my   $i_name ($sogen_file->findnodes("//socgen:syn/socgen:ise[socgen:name/text() = '$variant']"))
124 118 jt_eaton
   {
125
   my($replace_vendor)  = $i_name ->findnodes('socgen:target/socgen:vendor/text()')->to_literal ;
126
   my($replace_library)  = $i_name ->findnodes('socgen:target/socgen:library/text()')->to_literal ;
127 119 jt_eaton
   my @replace_components = yp::lib::find_components("spirit:component",$replace_vendor,$replace_library);
128 118 jt_eaton
 
129
   foreach my $replace_component (@replace_components)
130
     {
131 119 jt_eaton
      &link_child($vendor, $project,$replace_component, $replace_library ,$replace_vendor);
132 118 jt_eaton
     }
133
   }
134
 
135
 
136
 
137
 
138
 
139 120 jt_eaton
 
140
 
141
 
142 118 jt_eaton
#/*********************************************************************************************/
143 94 jt_eaton
#/                                                                                            */
144
#/                                                                                            */
145
#/                                                                                            */
146
#/                                                                                            */
147 118 jt_eaton
#/                                                                                            */
148
#/                                                                                            */
149 94 jt_eaton
#/*********************************************************************************************/
150
 
151
 
152
 
153
my      @filelist      = (  );
154
 
155 125 jt_eaton
@filelist = yp::lib::parse_component_file("$vendor","$project","$component","$version");
156 120 jt_eaton
 
157 94 jt_eaton
 
158
 
159
 
160
foreach $line (@filelist)
161
   {
162
   $_ = $line;
163 120 jt_eaton
   if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
164 94 jt_eaton
     {
165 119 jt_eaton
     $new_vendor      = $1;
166
     $new_proj        = $2;
167
     $new_comp        = $3;
168 120 jt_eaton
     $new_version     = $4;
169 119 jt_eaton
     if(($new_vendor ne $vendor ) or  ($new_proj ne $project ) )
170
 
171
       { &link_child( $vendor,$project,$new_comp, $new_proj ,$new_vendor); }
172 94 jt_eaton
     }
173
   }
174
 
175
 
176
 
177
 
178
 
179
 
180
#/*********************************************************************************************/
181 124 jt_eaton
#/  link the component and software for each child under the parents work/childern dir        */
182 94 jt_eaton
#/                                                                                            */
183
#/                                                                                            */
184
#/                                                                                            */
185
#/                                                                                            */
186
#/                                                                                            */
187
#/*********************************************************************************************/
188
 
189
 
190
 
191
sub link_child {
192 119 jt_eaton
                 my $parent_vendor      = shift;
193
                 my $parent_library      = shift;
194
                 my $child_component = shift;
195
                 my $child_library = shift;
196
                 my $child_vendor = shift;
197
 
198
                 my $lib_comp_sep    = yp::lib::find_lib_comp_sep($child_vendor,$child_library);
199
 
200
 
201
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children";
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}";
204 94 jt_eaton
                 mkdir $path,0755             unless( -e $path );
205 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
206 94 jt_eaton
 
207 120 jt_eaton
                 unless( -e $path )
208
                   {
209
                   mkdir $path,0755;
210
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}/bin";
211
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin";
212
                   &sys::lib::link_dir( "$root", "$dest"  );
213
                   symlink( "${home}/tools/bin/Makefile.root", "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile.root");
214
                   symlink( "${home}/tools/bin/Makefile",      "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}/bin/Makefile");
215
                   }
216 119 jt_eaton
 
217 115 jt_eaton
 
218 120 jt_eaton
                 my $lib_sw_dir     = yp::lib::find_lib_sw_dir($child_vendor,$child_library);
219 115 jt_eaton
 
220 120 jt_eaton
                 if($lib_sw_dir)
221
                   {
222
                   my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
223
                   unless( -e $path )
224
                     {
225
                     mkdir $path,0755;
226
                     $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_sw_dir}";
227
                     $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_sw_dir}";
228
                     &sys::lib::link_dir( "$root", "$dest"  );
229
                     }
230
                   }
231
 
232
                 #  only works for simple single item paths
233 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}";
234 115 jt_eaton
                 mkdir $path,0755             unless( -e $path );
235 119 jt_eaton
                 my $path  = ".${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
236 115 jt_eaton
 
237 120 jt_eaton
                 unless( -e $path )
238
                   {
239
                   mkdir $path,0755;
240
                   $root = "${home}/${projects_dir}/${child_vendor}/${child_library}${lib_comp_sep}/${child_component}";
241
                   $dest = "${home}${prefix}/${parent_vendor}__${parent_library}/children/${child_vendor}__${child_library}${lib_comp_sep}/${child_component}";
242
                   &sys::lib::link_dir( "$root", "$dest"  );
243
                   }
244 94 jt_eaton
               }
245
 
246
 
247
 
248
 
249
 
250 120 jt_eaton
 

powered by: WebSVN 2.1.0

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