| 1 |
131 |
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 |
131 |
jt_eaton |
|
| 33 |
|
|
############################################################################
|
| 34 |
|
|
# General PERL config
|
| 35 |
|
|
############################################################################
|
| 36 |
|
|
use Getopt::Long;
|
| 37 |
|
|
use English;
|
| 38 |
|
|
use File::Basename;
|
| 39 |
|
|
use Cwd;
|
| 40 |
|
|
use XML::LibXML;
|
| 41 |
|
|
use lib './tools';
|
| 42 |
|
|
use sys::lib;
|
| 43 |
|
|
use yp::lib;
|
| 44 |
133 |
jt_eaton |
use Parallel::ForkManager;
|
| 45 |
131 |
jt_eaton |
|
| 46 |
133 |
jt_eaton |
|
| 47 |
131 |
jt_eaton |
$OUTPUT_AUTOFLUSH = 1; # set autoflush of stdout to TRUE.
|
| 48 |
|
|
|
| 49 |
|
|
|
| 50 |
|
|
############################################################################
|
| 51 |
|
|
### Process the options
|
| 52 |
|
|
############################################################################
|
| 53 |
|
|
Getopt::Long::config("require_order", "prefix=-");
|
| 54 |
|
|
GetOptions("h","help",
|
| 55 |
|
|
) || die "(use '$program_name -h' for help)";
|
| 56 |
|
|
|
| 57 |
|
|
|
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
|
|
##############################################################################
|
| 61 |
|
|
## Help option
|
| 62 |
|
|
##############################################################################
|
| 63 |
|
|
if ( $opt_h or $opt_help )
|
| 64 |
|
|
{ print "\n build_master";
|
| 65 |
|
|
print "\n";
|
| 66 |
|
|
exit 1;
|
| 67 |
|
|
}
|
| 68 |
|
|
|
| 69 |
|
|
|
| 70 |
|
|
my $parser = XML::LibXML->new();
|
| 71 |
|
|
|
| 72 |
|
|
|
| 73 |
|
|
|
| 74 |
|
|
|
| 75 |
|
|
#/**********************************************************************/
|
| 76 |
|
|
#/* Process each library by finding any ip-xact file in any component */
|
| 77 |
|
|
#/* */
|
| 78 |
|
|
#/* Each ip-xact file is parsed and it's filename and the names of any*/
|
| 79 |
|
|
#/* modules that it uses are saved. */
|
| 80 |
|
|
#/* */
|
| 81 |
|
|
#/* */
|
| 82 |
|
|
#/**********************************************************************/
|
| 83 |
|
|
|
| 84 |
|
|
my $home = cwd();
|
| 85 |
|
|
|
| 86 |
|
|
my $prefix = yp::lib::get_workspace();
|
| 87 |
135 |
jt_eaton |
$prefix = "/code";
|
| 88 |
131 |
jt_eaton |
|
| 89 |
133 |
jt_eaton |
my $number_of_cpus = yp::lib::get_number_of_cpus();
|
| 90 |
|
|
|
| 91 |
131 |
jt_eaton |
my @vendors = yp::lib::find_vendors();
|
| 92 |
|
|
|
| 93 |
|
|
foreach my $vendor (@vendors)
|
| 94 |
|
|
{
|
| 95 |
|
|
print "$vendor \n ";
|
| 96 |
|
|
my $vendor_status = yp::lib::get_vendor_status($vendor);
|
| 97 |
|
|
if($vendor_status eq "active")
|
| 98 |
|
|
{
|
| 99 |
|
|
my @libraries = yp::lib::find_libraries($vendor);
|
| 100 |
|
|
foreach my $library (@libraries)
|
| 101 |
|
|
{
|
| 102 |
|
|
print "$vendor $library \n ";
|
| 103 |
|
|
my $library_status = yp::lib::get_library_status($vendor,$library);
|
| 104 |
|
|
if($library_status eq "active")
|
| 105 |
|
|
{
|
| 106 |
|
|
print "$vendor $library \n ";
|
| 107 |
|
|
run_vendor_library ( $vendor , $library)
|
| 108 |
|
|
}
|
| 109 |
|
|
}
|
| 110 |
|
|
}
|
| 111 |
|
|
}
|
| 112 |
|
|
|
| 113 |
|
|
|
| 114 |
|
|
|
| 115 |
|
|
|
| 116 |
|
|
sub run_vendor_library
|
| 117 |
|
|
{
|
| 118 |
|
|
my @params = @_;
|
| 119 |
|
|
my $library = pop(@params);
|
| 120 |
|
|
my $vendor = pop(@params);
|
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
my @components = yp::lib::find_components($vendor,$library);
|
| 124 |
|
|
|
| 125 |
|
|
foreach my $component (@components)
|
| 126 |
|
|
{
|
| 127 |
|
|
my $socgen_filename = yp::lib::find_componentConfiguration($vendor,$library,$component);
|
| 128 |
|
|
if($socgen_filename)
|
| 129 |
|
|
{
|
| 130 |
|
|
my $socgen_file = $parser->parse_file($socgen_filename);
|
| 131 |
|
|
|
| 132 |
|
|
#/*********************************************************************************************/
|
| 133 |
|
|
#/ files for simulation */
|
| 134 |
|
|
#/ */
|
| 135 |
|
|
#/*********************************************************************************************/
|
| 136 |
|
|
|
| 137 |
|
|
foreach my $i_name ($socgen_file->findnodes("//socgen:codeSets/socgen:codeSet/socgen:name"))
|
| 138 |
|
|
{
|
| 139 |
|
|
my $codeSet_name = $i_name ->findnodes('./text()')->to_literal ;
|
| 140 |
|
|
my $codeSet_vendor = $i_name ->findnodes('../socgen:vendor/text()')->to_literal ;
|
| 141 |
|
|
my $codeSet_library = $i_name ->findnodes('../socgen:library/text()')->to_literal ;
|
| 142 |
|
|
my $codeSet_component = $i_name ->findnodes('../socgen:component/text()')->to_literal ;
|
| 143 |
|
|
my $codeSet_version = $i_name ->findnodes('../socgen:version/text()')->to_literal ;
|
| 144 |
135 |
jt_eaton |
my $codeSet_prefix = "./code";
|
| 145 |
131 |
jt_eaton |
|
| 146 |
|
|
|
| 147 |
133 |
jt_eaton |
print "$codeSet_name $codeSet_prefix $codeSet_vendor $codeSet_library $codeSet_component $codeSet_version \n ";
|
| 148 |
131 |
jt_eaton |
|
| 149 |
133 |
jt_eaton |
|
| 150 |
|
|
|
| 151 |
|
|
|
| 152 |
|
|
|
| 153 |
|
|
|
| 154 |
|
|
|
| 155 |
|
|
|
| 156 |
|
|
|
| 157 |
|
|
##############################################################################
|
| 158 |
|
|
##
|
| 159 |
|
|
##############################################################################
|
| 160 |
|
|
|
| 161 |
|
|
|
| 162 |
|
|
|
| 163 |
|
|
my @cmd_list = ();
|
| 164 |
|
|
|
| 165 |
|
|
|
| 166 |
|
|
|
| 167 |
|
|
|
| 168 |
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($codeSet_vendor,$codeSet_library,$codeSet_component);
|
| 169 |
|
|
|
| 170 |
|
|
|
| 171 |
|
|
|
| 172 |
|
|
|
| 173 |
|
|
#/*********************************************************************************************/
|
| 174 |
|
|
#/ */
|
| 175 |
|
|
#/ Create filelists for simulation, synthesis and linting */
|
| 176 |
|
|
#/ */
|
| 177 |
|
|
#/ */
|
| 178 |
|
|
#/*********************************************************************************************/
|
| 179 |
|
|
|
| 180 |
|
|
my @filelist = yp::lib::parse_component_brothers("$codeSet_vendor","$codeSet_library","$codeSet_component","$codeSet_version");
|
| 181 |
|
|
|
| 182 |
|
|
foreach $line (@filelist)
|
| 183 |
|
|
{
|
| 184 |
|
|
$_ = $line;
|
| 185 |
|
|
if(/::(\S+)::(\S+)::(\S+)::(\S+)::/)
|
| 186 |
|
|
{
|
| 187 |
|
|
$new_library = $2;
|
| 188 |
|
|
$new_component = $3;
|
| 189 |
|
|
$new_vendor = $1;
|
| 190 |
|
|
$new_version = $4;
|
| 191 |
|
|
|
| 192 |
|
|
|
| 193 |
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($new_vendor,$new_library,$new_component,$new_version));
|
| 194 |
|
|
|
| 195 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:componentGenerator/ipxact:name"))
|
| 196 |
133 |
jt_eaton |
{
|
| 197 |
135 |
jt_eaton |
my($gen_name) = $i_name ->findnodes('../ipxact:name/text()')->to_literal ;
|
| 198 |
|
|
my($gen_generatorExe) = $i_name ->findnodes('../ipxact:generatorExe/text()')->to_literal ;
|
| 199 |
|
|
my($gen_phase) = $i_name ->findnodes('../ipxact:phase/text()')->to_literal ;
|
| 200 |
133 |
jt_eaton |
|
| 201 |
|
|
my $cmd;
|
| 202 |
|
|
$cmd = " -prefix $codeSet_prefix -vendor $codeSet_vendor -library $codeSet_library -component $codeSet_component -version $codeSet_version ";
|
| 203 |
|
|
|
| 204 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:componentGenerator[ipxact:name/text() = '$gen_name']/ipxact:parameters/ipxact:parameter"))
|
| 205 |
133 |
jt_eaton |
{
|
| 206 |
135 |
jt_eaton |
my($gen_param) = $i_name ->findnodes('./ipxact:value/text()')->to_literal ;
|
| 207 |
|
|
my($gen_param_name) = $i_name ->findnodes('./ipxact:name/text()')->to_literal ;
|
| 208 |
133 |
jt_eaton |
|
| 209 |
135 |
jt_eaton |
if ($gen_param_name eq "in_pipe") {$cmd = "$cmd <${home}${codeSet_prefix}/${codeSet_vendor}__${codeSet_library}/${codeSet_component}/${gen_param}";}
|
| 210 |
|
|
elsif($gen_param_name eq "out_pipe") {$cmd = "$cmd >${home}${codeSet_prefix}/${codeSet_vendor}__${codeSet_library}/${codeSet_component}/${gen_param}";}
|
| 211 |
133 |
jt_eaton |
elsif($gen_param_name) {$cmd = "$cmd -${gen_param_name} $gen_param ";}
|
| 212 |
|
|
else {$cmd = "$cmd $gen_param";}
|
| 213 |
|
|
}
|
| 214 |
|
|
|
| 215 |
135 |
jt_eaton |
foreach my $i_name ($spirit_component_file->findnodes("//ipxact:componentGenerator[ipxact:name/text() = '$gen_name']/ipxact:vendorExtensions/socgen:envIdentifier"))
|
| 216 |
133 |
jt_eaton |
{
|
| 217 |
|
|
my($gen_envidentifier) = $i_name ->findnodes('./text()')->to_literal ;
|
| 218 |
|
|
|
| 219 |
|
|
my $New_cmd = " ${gen_generatorExe} -envidentifier $gen_envidentifier ${cmd}\n";
|
| 220 |
|
|
if(${gen_generatorExe} )
|
| 221 |
|
|
{
|
| 222 |
|
|
push @cmd_list, "${gen_phase}::$New_cmd";
|
| 223 |
|
|
}
|
| 224 |
|
|
}
|
| 225 |
|
|
}
|
| 226 |
|
|
}
|
| 227 |
|
|
}
|
| 228 |
|
|
|
| 229 |
|
|
|
| 230 |
|
|
|
| 231 |
|
|
my $manager = new Parallel::ForkManager( $number_of_cpus );
|
| 232 |
|
|
@cmd_list = sys::lib::trim_sort(@cmd_list);
|
| 233 |
|
|
my $cmd;
|
| 234 |
|
|
my $phase;
|
| 235 |
|
|
|
| 236 |
|
|
foreach my $Cmd_line (@cmd_list)
|
| 237 |
|
|
{
|
| 238 |
|
|
( $phase,$cmd) = split( /\::/ , $Cmd_line);
|
| 239 |
|
|
$manager->start and next;
|
| 240 |
|
|
if (system($cmd)) {}
|
| 241 |
|
|
$manager->finish;
|
| 242 |
|
|
}
|
| 243 |
|
|
|
| 244 |
|
|
$manager->wait_all_children;
|
| 245 |
|
|
print "Software COMPLETE \n";
|
| 246 |
|
|
}
|
| 247 |
|
|
|
| 248 |
131 |
jt_eaton |
}
|
| 249 |
|
|
|
| 250 |
|
|
}
|
| 251 |
|
|
|
| 252 |
|
|
|
| 253 |
|
|
|
| 254 |
|
|
return(0);
|
| 255 |
133 |
jt_eaton |
}
|
| 256 |
131 |
jt_eaton |
|
| 257 |
133 |
jt_eaton |
|
| 258 |
|
|
|
| 259 |
|
|
|
| 260 |
|
|
|
| 261 |
|
|
|
| 262 |
|
|
|
| 263 |
|
|
|
| 264 |
|
|
|
| 265 |
|
|
|
| 266 |
|
|
|
| 267 |
|
|
|
| 268 |
|
|
|
| 269 |
|
|
|
| 270 |
|
|
|
| 271 |
|
|
|
| 272 |
|
|
|
| 273 |
|
|
|
| 274 |
|
|
|
| 275 |
|
|
|
| 276 |
|
|
|
| 277 |
|
|
|