1 |
117 |
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 |
|
|
############################################################################
|
66 |
|
|
### Process the options
|
67 |
|
|
############################################################################
|
68 |
|
|
|
69 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
70 |
|
|
GetOptions("h","help",
|
71 |
|
|
"prefix=s" => \$prefix,
|
72 |
|
|
"vendor=s" => \$vendor,
|
73 |
|
|
"project=s" => \$project,
|
74 |
|
|
"component=s" => \$component,
|
75 |
|
|
"version=s" => \$version
|
76 |
|
|
) || die "(use '$program_name -h' for help)";
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
##############################################################################
|
80 |
|
|
## Help option
|
81 |
|
|
##############################################################################
|
82 |
118 |
jt_eaton |
if ( $opt_h or $opt_help ) { print "\n build_generate -prefix /work/ -vendor vendor_name -project project_name -component component_name -version version_name ";
|
83 |
117 |
jt_eaton |
print "\n";
|
84 |
|
|
exit 1;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
##############################################################################
|
89 |
|
|
##
|
90 |
|
|
##############################################################################
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
my $home = cwd();
|
94 |
|
|
my $tool_path ="./tools/generators/";
|
95 |
|
|
|
96 |
|
|
#############################################################################
|
97 |
|
|
##
|
98 |
|
|
##
|
99 |
|
|
#############################################################################
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
118 |
jt_eaton |
print " GENERATE $prefix $vendor $project $component $version \n" ;
|
105 |
117 |
jt_eaton |
|
106 |
|
|
|
107 |
|
|
my $parser = XML::LibXML->new();
|
108 |
|
|
|
109 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$project);
|
110 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact("spirit:component",$vendor,$project,$component,$version));
|
111 |
|
|
|
112 |
|
|
foreach my $view ($spirit_component_file->findnodes('//spirit:component/spirit:model/spirit:views/spirit:view'))
|
113 |
|
|
{
|
114 |
|
|
my($view_name) = $view->findnodes('./spirit:name/text()')->to_literal ;
|
115 |
|
|
|
116 |
|
|
#/**********************************************************************/
|
117 |
|
|
#/* */
|
118 |
|
|
#/* */
|
119 |
|
|
#/* */
|
120 |
|
|
#/* */
|
121 |
|
|
#/* */
|
122 |
|
|
#/**********************************************************************/
|
123 |
|
|
|
124 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:componentGenerator/spirit:name"))
|
125 |
|
|
{
|
126 |
|
|
my($gen_name) = $i_name ->findnodes('./text()')->to_literal ;
|
127 |
|
|
my($gen_phase) = $i_name ->findnodes('../spirit:phase/text()')->to_literal ;
|
128 |
|
|
my($gen_apiType) = $i_name ->findnodes('../spirit:apiType/text()')->to_literal ;
|
129 |
|
|
my($gen_generatorExe) = $i_name ->findnodes('../spirit:generatorExe/text()')->to_literal ;
|
130 |
|
|
my($gen_group) = $i_name ->findnodes('../spirit:group/text()')->to_literal ;
|
131 |
|
|
|
132 |
|
|
my $cmd;
|
133 |
|
|
$cmd =
|
134 |
118 |
jt_eaton |
"${tool_path}${gen_generatorExe} -view $view_name -prefix $prefix -vendor $vendor -project $project -component $component -version $version ";
|
135 |
117 |
jt_eaton |
|
136 |
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:componentGenerator[spirit:name/text() = '$gen_name']/spirit:parameters/spirit:parameter"))
|
137 |
|
|
{
|
138 |
|
|
my($gen_param) = $i_name ->findnodes('./spirit:value/text()')->to_literal ;
|
139 |
|
|
my($gen_param_name) = $i_name ->findnodes('./spirit:name/text()')->to_literal ;
|
140 |
|
|
|
141 |
|
|
if ($gen_param_name eq "in_pipe") {$cmd = "$cmd <${home}${prefix}${project}${lib_comp_sep}/${component}/${gen_param}";}
|
142 |
|
|
elsif($gen_param_name eq "out_pipe") {$cmd = "$cmd >${home}${prefix}${project}${lib_comp_sep}/${component}/${gen_param}";}
|
143 |
|
|
elsif($gen_param_name) {$cmd = "$cmd -${gen_param_name} $gen_param ";}
|
144 |
|
|
else {$cmd = "$cmd $gen_param";}
|
145 |
|
|
}
|
146 |
|
|
$cmd = "${cmd}\n";
|
147 |
|
|
|
148 |
|
|
if($gen_group)
|
149 |
|
|
{
|
150 |
|
|
if($gen_group eq $view_name )
|
151 |
|
|
{
|
152 |
|
|
if (system($cmd)) {}
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
else
|
156 |
|
|
{
|
157 |
|
|
if (system($cmd)) {}
|
158 |
|
|
}
|
159 |
|
|
}
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
|
|
1
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|