1 |
128 |
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 |
|
|
#/* */
|
15 |
|
|
#/* */
|
16 |
|
|
#/* */
|
17 |
|
|
#/* Author(s): */
|
18 |
|
|
#/* - John Eaton, jt_eaton@opencores.org */
|
19 |
|
|
#/* */
|
20 |
|
|
#/**********************************************************************/
|
21 |
|
|
#/* */
|
22 |
|
|
#/* Copyright (C) <2010-2011> */
|
23 |
|
|
#/* */
|
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 |
|
|
use Cwd;
|
55 |
|
|
use XML::LibXML;
|
56 |
|
|
use lib './tools';
|
57 |
|
|
use sys::lib;
|
58 |
|
|
use yp::lib;
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
############################################################################
|
65 |
|
|
### Process the options
|
66 |
|
|
############################################################################
|
67 |
|
|
|
68 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
69 |
|
|
GetOptions("h","help",
|
70 |
|
|
) || die "(use '$program_name -h' for help)";
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
##############################################################################
|
74 |
|
|
## Help option
|
75 |
|
|
##############################################################################
|
76 |
|
|
if ( $opt_h or $opt_help )
|
77 |
|
|
{ print "\n create_lib_doc vendor_name library_name [component_name]";
|
78 |
|
|
print "\n";
|
79 |
|
|
exit 1;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
##############################################################################
|
84 |
|
|
##
|
85 |
|
|
##############################################################################
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
my $parser = XML::LibXML->new();
|
90 |
|
|
|
91 |
|
|
$home = cwd();
|
92 |
|
|
|
93 |
131 |
jt_eaton |
|
94 |
128 |
jt_eaton |
#############################################################################
|
95 |
|
|
##
|
96 |
|
|
##
|
97 |
|
|
#############################################################################
|
98 |
|
|
|
99 |
131 |
jt_eaton |
my $vendor = $ARGV[0];
|
100 |
|
|
my $library = $ARGV[1];
|
101 |
|
|
my $work_dir = $ARGV[2];
|
102 |
|
|
my $repo = yp::lib::find_library_repo($vendor,$library);
|
103 |
128 |
jt_eaton |
|
104 |
|
|
|
105 |
131 |
jt_eaton |
my $doc_dir = yp::lib::get_doc_dir();
|
106 |
|
|
|
107 |
|
|
|
108 |
128 |
jt_eaton |
if(defined $work_dir)
|
109 |
130 |
jt_eaton |
{chomp($work_dir);}
|
110 |
128 |
jt_eaton |
else
|
111 |
131 |
jt_eaton |
{$work_dir ="/${doc_dir}";}
|
112 |
128 |
jt_eaton |
|
113 |
131 |
jt_eaton |
|
114 |
|
|
|
115 |
128 |
jt_eaton |
my $path = "${home}${work_dir}";
|
116 |
|
|
mkdir $path,0755 unless( -e $path );
|
117 |
|
|
my $path = "${home}${work_dir}/${vendor}__${library}";
|
118 |
|
|
mkdir $path,0755 unless( -e $path );
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
131 |
jt_eaton |
$root = "${home}${repo}/${vendor}/${library}";
|
123 |
128 |
jt_eaton |
$dest = "${home}${work_dir}/${vendor}__${library}";
|
124 |
|
|
&sys::lib::link_dir( "$root", "$dest" );
|
125 |
|
|
|
126 |
130 |
jt_eaton |
my @components = yp::lib::find_components($vendor,$library);
|
127 |
128 |
jt_eaton |
|
128 |
|
|
foreach my $component (@components)
|
129 |
131 |
jt_eaton |
{
|
130 |
|
|
unless (yp::lib::find_componentConfiguration($vendor,$library,$component)) {print "Missing ComponentCfg $vendor, $library, $component \n"; }
|
131 |
128 |
jt_eaton |
|
132 |
131 |
jt_eaton |
my $socgen_filename = yp::lib::find_componentConfiguration($vendor,$library,$component);
|
133 |
|
|
|
134 |
|
|
if($socgen_filename)
|
135 |
|
|
|
136 |
128 |
jt_eaton |
{
|
137 |
131 |
jt_eaton |
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
my $socgen_file = $parser->parse_file($socgen_filename);
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
130 |
jt_eaton |
my $doc_library_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:doc/socgen:library_path/text()")->to_literal;
|
146 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
147 |
128 |
jt_eaton |
|
148 |
131 |
jt_eaton |
my $path = "${home}${repo}/${vendor}/${library}${doc_library_path}";
|
149 |
130 |
jt_eaton |
mkdir $path,0755 unless( -e $path );
|
150 |
128 |
jt_eaton |
|
151 |
130 |
jt_eaton |
$doc_library_path = "${doc_library_path}/Geda";
|
152 |
128 |
jt_eaton |
|
153 |
131 |
jt_eaton |
my $path = "${home}${repo}/${vendor}/${library}${doc_library_path}";
|
154 |
130 |
jt_eaton |
mkdir $path,0755 unless( -e $path );
|
155 |
128 |
jt_eaton |
|
156 |
131 |
jt_eaton |
my $path = "${home}${repo}/${vendor}/${library}${doc_library_path}/sym";
|
157 |
130 |
jt_eaton |
mkdir $path,0755 unless( -e $path );
|
158 |
128 |
jt_eaton |
|
159 |
131 |
jt_eaton |
my $path = "${home}${repo}/${vendor}/${library}${doc_library_path}/sch";
|
160 |
130 |
jt_eaton |
mkdir $path,0755 unless( -e $path );
|
161 |
128 |
jt_eaton |
|
162 |
131 |
jt_eaton |
my $path = "${home}${repo}/${vendor}/${library}${doc_library_path}/png";
|
163 |
130 |
jt_eaton |
mkdir $path,0755 unless( -e $path );
|
164 |
128 |
jt_eaton |
|
165 |
131 |
jt_eaton |
my $path = "${home}${repo}/${vendor}/${library}${doc_library_path}/src";
|
166 |
130 |
jt_eaton |
mkdir $path,0755 unless( -e $path );
|
167 |
128 |
jt_eaton |
|
168 |
130 |
jt_eaton |
my @versions = yp::lib::find_component_versions($vendor,$library,$component);
|
169 |
128 |
jt_eaton |
|
170 |
|
|
foreach my $version (@versions)
|
171 |
|
|
{
|
172 |
|
|
my $variant;
|
173 |
|
|
if($version) {$variant = "${component}_${version}"}
|
174 |
|
|
else {$variant = "${component}"}
|
175 |
130 |
jt_eaton |
my $module_name = yp::lib::get_module_name($vendor,$library,$component, $version);
|
176 |
128 |
jt_eaton |
print "gEDA directories for $vendor $library - $component $version $variant == $module_name \n";
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
#/*********************************************************************************************/
|
180 |
|
|
#/ */
|
181 |
|
|
#/ Create filelists for simulation, synthesis and linting */
|
182 |
|
|
#/ */
|
183 |
|
|
#/ */
|
184 |
|
|
#/*********************************************************************************************/
|
185 |
|
|
|
186 |
|
|
my @filelist = yp::lib::parse_component_brothers("$vendor","$library","$component","$version");
|
187 |
|
|
|
188 |
|
|
foreach $line (@filelist)
|
189 |
|
|
{
|
190 |
|
|
$_ = $line;
|
191 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
192 |
|
|
{
|
193 |
131 |
jt_eaton |
$new_library = $2;
|
194 |
128 |
jt_eaton |
$new_component = $3;
|
195 |
|
|
$new_vendor = $1;
|
196 |
|
|
$new_version = $4;
|
197 |
131 |
jt_eaton |
print "Seeking $new_vendor $new_library $new_component $new_version \n";
|
198 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
|
199 |
128 |
jt_eaton |
|
200 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:componentGenerator/spirit:name"))
|
201 |
|
|
{
|
202 |
|
|
my($gen_name) = $i_name ->findnodes('../spirit:name/text()')->to_literal ;
|
203 |
|
|
my($gen_generatorExe) = $i_name ->findnodes('../spirit:generatorExe/text()')->to_literal ;
|
204 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:componentGenerator[spirit:name/text() = '$gen_name']/spirit:vendorExtensions/socgen:envIdentifier"))
|
205 |
|
|
{
|
206 |
|
|
my($gen_envidentifier) = $i_name ->findnodes('./text()')->to_literal ;
|
207 |
|
|
|
208 |
|
|
if($gen_envidentifier eq ":*Documentation:*" )
|
209 |
|
|
{
|
210 |
131 |
jt_eaton |
my $cmd = "./tools/sys/build_generate -prefix /doc_dir -vendor $vendor -library $library -component $component -version $version \n";
|
211 |
130 |
jt_eaton |
if (system($cmd)) {}
|
212 |
|
|
my $filename = find_filename("fs-sim", ${vendor}, ${library} , ${component} , ${version} );
|
213 |
131 |
jt_eaton |
my $cmd = "cp ${home}${work_dir}/${filename}.v ${home}${repo}/${vendor}/${library}${doc_library_path}/src/${module_name}.v \n";
|
214 |
130 |
jt_eaton |
if (system($cmd)) {}
|
215 |
128 |
jt_eaton |
my $filename = find_filename("fs-doc", ${vendor}, ${library} , ${component} , ${version} );
|
216 |
131 |
jt_eaton |
my $outfile ="${home}${repo}/${vendor}/${library}${doc_library_path}/sym/";
|
217 |
128 |
jt_eaton |
my $cmd = "./tools/documentation/ver2gedasym ${home}${work_dir}/${filename} $outfile \n";
|
218 |
|
|
if (system($cmd)) {}
|
219 |
131 |
jt_eaton |
my $outfile ="${home}${repo}/${vendor}/${library}${doc_library_path}/sch/";
|
220 |
128 |
jt_eaton |
my $cmd = "./tools/documentation/ver2gedasch ${home}${work_dir}/${filename} $outfile \n";
|
221 |
|
|
if (system($cmd)) {}
|
222 |
131 |
jt_eaton |
my $symfile ="${home}${repo}/${vendor}/${library}${doc_library_path}/sym/${module_name}.sym";
|
223 |
|
|
my $pngfile ="${home}${repo}/${vendor}/${library}${doc_library_path}/png/${module_name}_sym.png";
|
224 |
128 |
jt_eaton |
my $cmd ="gaf export -c -s auto -m 5px --dpi 600 --no-color -o $pngfile $symfile \n";
|
225 |
|
|
if (system($cmd)) {}
|
226 |
131 |
jt_eaton |
my $schfile ="${home}${repo}/${vendor}/${library}${doc_library_path}/sch/${module_name}.sch";
|
227 |
|
|
my $pngfile ="${home}${repo}/${vendor}/${library}${doc_library_path}/png/${module_name}_sch.png";
|
228 |
128 |
jt_eaton |
my $cmd ="gaf export -c -s auto -m 5px --dpi 600 --no-color -o $pngfile $schfile \n";
|
229 |
|
|
if (system($cmd)) {}
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
|
233 |
|
|
}
|
234 |
|
|
}
|
235 |
|
|
}
|
236 |
|
|
}
|
237 |
|
|
|
238 |
|
|
}
|
239 |
|
|
|
240 |
|
|
}
|
241 |
|
|
|
242 |
131 |
jt_eaton |
}
|
243 |
128 |
jt_eaton |
|
244 |
|
|
|
245 |
|
|
|
246 |
131 |
jt_eaton |
|
247 |
128 |
jt_eaton |
#/*********************************************************************************************/
|
248 |
|
|
#/ find filename */
|
249 |
|
|
#/ */
|
250 |
|
|
#/ returns gloabal name of the file */
|
251 |
|
|
#/ */
|
252 |
|
|
#/ */
|
253 |
|
|
#/*********************************************************************************************/
|
254 |
|
|
|
255 |
|
|
sub find_filename
|
256 |
|
|
{
|
257 |
|
|
my @params = @_;
|
258 |
|
|
my $version = pop(@params);
|
259 |
|
|
my $component = pop(@params);
|
260 |
131 |
jt_eaton |
my $library = pop(@params);
|
261 |
128 |
jt_eaton |
my $vendor = pop(@params);
|
262 |
|
|
my $filesetref_name = pop(@params);
|
263 |
|
|
|
264 |
|
|
|
265 |
130 |
jt_eaton |
my $variant;
|
266 |
|
|
if($version) {$variant = "${component}_${version}";}
|
267 |
|
|
else {$variant = "${component}";}
|
268 |
128 |
jt_eaton |
|
269 |
131 |
jt_eaton |
my @filelist = yp::lib::parse_component_brothers("$vendor","$library","$component","$version");
|
270 |
|
|
my $comp_xml_sep = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
|
271 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
272 |
130 |
jt_eaton |
my $library_path = "${lib_comp_sep}${component}${comp_xml_sep}";
|
273 |
128 |
jt_eaton |
|
274 |
|
|
|
275 |
130 |
jt_eaton |
foreach $line (@filelist)
|
276 |
|
|
{
|
277 |
|
|
$_ = $line;
|
278 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
279 |
|
|
{
|
280 |
|
|
$new_vendor = $1;
|
281 |
131 |
jt_eaton |
$new_library = $2;
|
282 |
130 |
jt_eaton |
$new_component = $3;
|
283 |
|
|
$new_version = $4;
|
284 |
131 |
jt_eaton |
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
|
285 |
128 |
jt_eaton |
|
286 |
130 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
|
287 |
128 |
jt_eaton |
{
|
288 |
|
|
my($file_name) = $i_name ->findnodes('./text()')->to_literal ;
|
289 |
|
|
my($file_type) = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal ;
|
290 |
|
|
my($logical_name) = $i_name ->findnodes('../spirit:logicalName/text()')->to_literal ;
|
291 |
|
|
my($view_file) = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
|
292 |
|
|
if(($file_type eq "libraryDir") && ($logical_name eq "dest_dir") )
|
293 |
|
|
{
|
294 |
131 |
jt_eaton |
if( $view_file eq $filesetref_name ) { return ("${vendor}__${library}${library_path}/${file_name}${variant}"); };
|
295 |
128 |
jt_eaton |
}
|
296 |
|
|
}
|
297 |
130 |
jt_eaton |
}
|
298 |
|
|
}
|
299 |
|
|
}
|
300 |
128 |
jt_eaton |
|