mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 17:22:52 +00:00
Merge branch 'makeMaster' that splits up CP into several executable
components.
This commit is contained in:
commit
13268aae32
@ -16,7 +16,7 @@ if ( -f "S_define" ) {
|
||||
print "CP aborted\n" ;
|
||||
exit 1 ;
|
||||
}
|
||||
unlink "Makefile_sim", "makefile" ;
|
||||
unlink "build/Makefile_sim", "makefile" ;
|
||||
$makefile_text = do { local $/; <main::DATA> } ;
|
||||
$makefile_text =~ s/SUB_TRICK_HOME/$trick_home/ ;
|
||||
$makefile_text =~ s/SUB_TRICK_BIN/$trick_bin/ ;
|
||||
|
@ -1,232 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use strict ;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
use Pod::Text;
|
||||
use lib "$RealBin/pm" ;
|
||||
use ICG ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
use get_headers ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
##############################################################################
|
||||
# Main program
|
||||
##############################################################################
|
||||
|
||||
my $icg_operation ;
|
||||
my @icg_h_files ;
|
||||
my %sim ;
|
||||
my $ret ;
|
||||
my $help ;
|
||||
my @defs ;
|
||||
my ($valid_types_ref,$icg_depends_ref, $mis_entries_ref,$mis_depends_ref) ;
|
||||
my ($head_depends_ref,$rcs_tags_ref) ;
|
||||
|
||||
# override the print format for help message
|
||||
*Pod::Text::seq_i = sub { return "[04m" . $_[1] . "[00m" } ;
|
||||
|
||||
# set stdout to unbuffered so we see printout immediately.
|
||||
$| = 1 ;
|
||||
|
||||
# set the default verbose level to 2
|
||||
$sim{args}{v} = 2 ;
|
||||
$sim{args}{force} = 0 ;
|
||||
|
||||
# default operation
|
||||
$icg_operation = "full" ;
|
||||
$ICG::arg_lang = 0 ;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "D=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } ,
|
||||
"U=s" => sub { my $temp = join "" , @_ ; push @defs , "-$temp" ; } ,
|
||||
"cpp|p" => sub { $ICG::arg_lang = "CPP" } ,
|
||||
"debug|d|g" => sub { $sim{args}{v} = 3 } ,
|
||||
"help|h|?" => \$help ,
|
||||
"force|f" => sub { $sim{args}{force} = 1} ,
|
||||
"outfile|o=s" => \$sim{args}{o} ,
|
||||
"sim_services|s" => sub { $icg_operation = "sim_services" } ,
|
||||
"single" => sub { $icg_operation = "single" } ,
|
||||
"s_source" => sub { $icg_operation = "s_source" } ,
|
||||
"tree|t" => sub { $icg_operation = "tree" } ,
|
||||
"unit_summary|u" => \&unit_summary ,
|
||||
"verbose|v=i" => \$sim{args}{v}
|
||||
) or pod2usage(1) ;
|
||||
|
||||
pod2usage(1) if $help ;
|
||||
|
||||
#if ( -e "S_overrides.mk" ) {
|
||||
#
|
||||
# open CFLAGS, "make -p -n -f S_overrides.mk fake_target 2>&1 |" ;
|
||||
#
|
||||
# while ( <CFLAGS> ) {
|
||||
#
|
||||
# if ( /^TRICK_CFLAGS\s*\:?=\s*(.*)/ ) {
|
||||
# $ENV{TRICK_CFLAGS} = $1 ;
|
||||
# }
|
||||
# elsif ( /^TRICK_ICG_EXCLUDE\s*\:?=\s*(.*)/ ) {
|
||||
# $ENV{TRICK_ICG_EXCLUDE} = $1 ;
|
||||
# $ENV{TRICK_ICG_EXCLUDE} =~ s/\$[{(]([^})]+)[})]/$ENV{$1}/ge ;
|
||||
# }
|
||||
# }
|
||||
# close CFLAGS ;
|
||||
#}
|
||||
|
||||
$ENV{TRICK_CFLAGS} =~ s/\$[{(](\w+)[})]/$ENV{$1}/g ;
|
||||
$ENV{TRICK_CFLAGS} =~ s/\"//g ;
|
||||
|
||||
# set and open the output file
|
||||
if ( $sim{args}{o} ne "" ) {
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
local *OUTFILE ;
|
||||
open OUTFILE , ">$sim{args}{o}"
|
||||
or warn "ICG cannot open $sim{args}{o} for writing\n" ;
|
||||
$sim{fh} = *OUTFILE ;
|
||||
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
|
||||
}
|
||||
|
||||
push @icg_h_files , (grep !/(^-|(\.d|\.dd)$)/ , @ARGV) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Get all headers used by the sim and their modification dates
|
||||
#if ( $icg_operation eq "s_source" ) {
|
||||
# get_headers(\%sim, abs_path("S_source.hh")) ;
|
||||
#}
|
||||
|
||||
$ret = ICG(@icg_h_files, $icg_operation, \@defs, \%sim) ;
|
||||
|
||||
if ($ret eq -1) {
|
||||
trick_print($sim{fh},
|
||||
"\nICG No files specified or found\n" ,
|
||||
"normal_yellow" , $sim{args}{v}) ;
|
||||
}
|
||||
|
||||
sub unit_summary() {
|
||||
print "
|
||||
Trick Measurement Units Summary
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Standard Units |Description
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Time: s min hr day |second, minute, hour, day
|
||||
Angular Displacement: r d as am rev |radian, degree, arc-second, arc-minute, revolution
|
||||
Voltage: v |volt
|
||||
Amperage: amp |ampere
|
||||
Resistance: ohm |ohm
|
||||
Sound: dB |decibel
|
||||
Unitless: -- cnt one mol |no unit, count, one, mole
|
||||
|
|
||||
---------------------------------------------------------------------------------------------------
|
||||
English System Units |Description
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Linear Displacement: ft kft in yd mi n.m. |foot, kilofoot, inch, yard, mile, nautical mile
|
||||
Mass: sl lbm |slug, pound(mass)
|
||||
Force: oz lbf |ounce, pound(force)
|
||||
Temperature: R F |Rankine, Fahrenheit
|
||||
Energy: BTU |British Thermal Unit
|
||||
Power: hp |horsepower
|
||||
Pressure: psi |pound per square inch
|
||||
Volume: gal floz |gallon, fluid ounce
|
||||
|
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Metric System Units |Description
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Linear Displacement: m |meter
|
||||
Mass: g mt |gram, metric ton
|
||||
Force: N |Newton
|
||||
Temperature: C K |Celsius, Kelvin
|
||||
Energy: J TNT |Joule, ton of TNT
|
||||
Power: W |Watt
|
||||
Pressure: Pa atm mHg |Pascal, atmosphere, meter of mercury
|
||||
Frequency: Hz |Herz
|
||||
Volume: l |liter
|
||||
|
||||
---------------------------------------------------------------------------------------------------
|
||||
|
||||
---------------------------------------------------------
|
||||
You can use these prefixes for Multiples and Submultiples
|
||||
(Only valid for units: r v amp ohm m g N J W Pa mHg Hz)
|
||||
---------------------------------------------------------
|
||||
10**-1 d 10 da
|
||||
10**-2 c 10**2 h
|
||||
10**-3 m 10**3 k
|
||||
10**-6 u 10**6 M
|
||||
10**-9 n 10**9 G
|
||||
10**-12 p 10**12 T
|
||||
---------------------------------------------------------
|
||||
\n\n" ;
|
||||
|
||||
exit() ;
|
||||
}
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
ICG - Trick Interface Code Generator
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
ICG [-D B<label>] [-U B<label>] [--cpp] [--debug] [-d] [-g] [-h] [--help]
|
||||
[-l] [--library] [-o I<outfile>] [--outfile=I<outfile>] [-p] [-s] [--sim_services]
|
||||
[-t] [--tree] [-u] [--unit_summary] [-v I<level>] [--verbose=I<level>] [I<file> ...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
See the Trick User's guide for B<ICG>.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-D> I<label>
|
||||
|
||||
Define a label
|
||||
|
||||
=item B<-U> I<label>
|
||||
|
||||
Undefine a label
|
||||
|
||||
=item B<-d> | B<-g> | B<--debug>
|
||||
|
||||
Set verbose level = 3
|
||||
|
||||
=item B<-h> | B<-?> | B<--help>
|
||||
|
||||
This help screen
|
||||
|
||||
=item B<-l> | B<--library>
|
||||
|
||||
Use this option in a SIM directory. ICG will execute on all files listed in the
|
||||
S_library_list file
|
||||
|
||||
=item B<-o> I<outfile> | B<--outfile>=I<outfile>
|
||||
|
||||
Direct output of ICG to outfile. ( Note: Does not affect screen output ).
|
||||
|
||||
=item B<-s> | B<--sim_services>
|
||||
|
||||
Run ICG on all required header files in the sim_services directory
|
||||
|
||||
=item B<-t> | B<--tree>
|
||||
|
||||
Print out a hierarchical tree of all header file dependcies for B<file>
|
||||
|
||||
=item B<-u> | B<--unit_summary>
|
||||
|
||||
Print out the list of known units to ICG
|
||||
|
||||
=item B<-v> I<level> | B<--verbose>=I<level>
|
||||
|
||||
Set the verbose level. Valid entries are 0-3.
|
||||
|
||||
=item B<-DTRICK_VER=x.x>
|
||||
|
||||
Note: -DTRICK_VER=x.x is automatically used when parsing header files and the S_define file
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
20
libexec/trick/ICG_lib_deps_helper
Executable file
20
libexec/trick/ICG_lib_deps_helper
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/pm" ;
|
||||
|
||||
use strict ;
|
||||
use get_lib_deps ;
|
||||
|
||||
my $header ;
|
||||
my @resolved_files ;
|
||||
|
||||
# Read in the Trick comment to be processed.
|
||||
while ( <STDIN> ) {
|
||||
last if ( $_ =~ /END ICG PROCESSING/ ) ;
|
||||
$header .= $_ ;
|
||||
}
|
||||
|
||||
(@resolved_files) = get_lib_deps($header, @ARGV[0]) ;
|
||||
|
||||
print map { "$_\n" } @resolved_files ;
|
@ -1,217 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict ;
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/pm" ;
|
||||
use Getopt::Long ;
|
||||
use Pod::Usage ;
|
||||
use Pod::Text ;
|
||||
use File::Basename ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path' ;
|
||||
use mis_dep ;
|
||||
use html ;
|
||||
use cp_cache ;
|
||||
use MIS ;
|
||||
use gte ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
|
||||
my $wd ;
|
||||
my (@all_files , $src_dir , @c_files , @cpp_files ) ;
|
||||
my $num_files ;
|
||||
my $contents ;
|
||||
my $curr_file ;
|
||||
my $size ;
|
||||
my ( @inc_paths , $subme ) ;
|
||||
my @all_lines ;
|
||||
my %sim ;
|
||||
my $help ;
|
||||
my ($vt_ref, $icg_dep_ref, $mod_ref, $md_ref, $rcs_tags_ref) ;
|
||||
|
||||
# override the print format for help message
|
||||
*Pod::Text::seq_i = sub { return "[04m" . $_[1] . "[00m" } ;
|
||||
|
||||
# set stdout to unbuffered so we see printout immediately.
|
||||
$| = 1 ;
|
||||
|
||||
# set the default verbose level to 2
|
||||
$sim{args}{v} = 2 ;
|
||||
$sim{args}{l} = 0 ;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "debug|d|g" => sub { $sim{args}{v} = 3 } ,
|
||||
"help|h|?" => \$help ,
|
||||
"library|l" => \$sim{args}{l} ,
|
||||
"outfile|o=s" => \$sim{args}{o} ,
|
||||
"verbose|v=i" => \$sim{args}{v}
|
||||
) or pod2usage(1) ;
|
||||
|
||||
pod2usage(1) if $help ;
|
||||
|
||||
if ( $sim{args}{o} ne "" ) {
|
||||
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
local *OUTFILE ;
|
||||
|
||||
open OUTFILE , ">$sim{args}{o}"
|
||||
or warn "ICG cannot open $sim{args}{o} for writing\n" ;
|
||||
|
||||
$sim{fh} = *OUTFILE ;
|
||||
|
||||
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
|
||||
}
|
||||
|
||||
$wd = abs_path(cwd()) ;
|
||||
|
||||
#if ( $ARGV[0] eq "-l" ) {
|
||||
if ( $sim{args}{l} ) {
|
||||
open FILE , "S_library_list" or die "Could not open S_library_list\n" ;
|
||||
@all_lines = <FILE> ;
|
||||
@c_files = grep /\.c$/ , @all_lines;
|
||||
chomp @c_files ;
|
||||
$wd = "" ;
|
||||
|
||||
} elsif ( $#ARGV eq -1 ) {
|
||||
|
||||
opendir thisdir, $wd or die "Could not open the directory $wd";
|
||||
@all_files = grep !/^\.\.\./ , readdir thisdir;
|
||||
$src_dir = grep /^src$/ , @all_files;
|
||||
@c_files = grep /\.c$/ , @all_files;
|
||||
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ , @all_files;
|
||||
$num_files = scalar @c_files ;
|
||||
if ( $num_files ne 0 and $src_dir eq 1 ) {
|
||||
print "\nMIS ERROR: All source files must reside in the\n" ;
|
||||
print " 'src' directory. Either place all \n" ;
|
||||
print " source files in the 'src' directory, \n" ;
|
||||
print " OR move any source file out of 'src'\n" ;
|
||||
print " into $wd and remove the 'src' directory." ;
|
||||
print "\n\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( $src_dir eq 1 ) {
|
||||
opendir thisdir, $wd . "/src";
|
||||
@all_files = grep !/^\.\.\./ , readdir thisdir;
|
||||
closedir thisdir;
|
||||
|
||||
@c_files = grep /\.c$/ , @all_files;
|
||||
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ ,
|
||||
@all_files;
|
||||
$wd .= "/src" ;
|
||||
}
|
||||
|
||||
foreach (@c_files , @cpp_files ) {
|
||||
$_ = "$wd/$_" if ( /^[^\/]/ ) ;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@c_files = grep /\.c$/ , @ARGV;
|
||||
@cpp_files = grep /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ , @ARGV;
|
||||
foreach (@c_files , @cpp_files ) {
|
||||
$_ = "$wd/$_" if ( /^[^\/]/ ) ;
|
||||
}
|
||||
$wd = "" ;
|
||||
}
|
||||
|
||||
my @non_yacc_files ;
|
||||
foreach (@c_files) {
|
||||
(my $test = $_) =~ s/c$/y/ ;
|
||||
if ( ! -e $test ) {
|
||||
push @non_yacc_files , $_ ;
|
||||
}
|
||||
}
|
||||
@c_files = @non_yacc_files ;
|
||||
|
||||
|
||||
if ($#c_files eq -1 and $#cpp_files eq -1 ) {
|
||||
trick_print($sim{fh},
|
||||
"No files specified or found\n" ,
|
||||
"normal_yellow" , $sim{args}{v});
|
||||
exit(0);
|
||||
}
|
||||
|
||||
trick_print($sim{fh}, "MIS-ing...", "title_cyan" , $sim{args}{v}) ;
|
||||
trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ;
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
|
||||
push @inc_paths , ("$ENV{\"TRICK_HOME\"}/trick_source" , "../include") ;
|
||||
foreach (@inc_paths) {
|
||||
$subme = quotemeta (abs_path(dirname($_)) . "/" . basename($_)) ;
|
||||
}
|
||||
|
||||
($vt_ref, $icg_dep_ref, $mod_ref, $md_ref, $rcs_tags_ref ) = read_cache() ;
|
||||
%{$sim{icg_types}} = %$vt_ref ;
|
||||
%{$sim{all_icg_depends}} = %$icg_dep_ref ;
|
||||
%{$sim{module_entries}} = %$mod_ref ;
|
||||
%{$sim{all_mis_depends}} = %$md_ref ;
|
||||
%{$sim{rcs_tags}} = %$rcs_tags_ref ;
|
||||
|
||||
push @c_files , @cpp_files ;
|
||||
foreach $curr_file (@c_files ) {
|
||||
|
||||
open FILE, $curr_file or die "Couldn't find file: $curr_file\n";
|
||||
seek FILE , 0 , 2 ;
|
||||
$size = tell FILE ;
|
||||
seek FILE , 0 , 0 ;
|
||||
read FILE , $contents , $size;
|
||||
|
||||
mis_c($curr_file , $contents, \%sim) ;
|
||||
}
|
||||
|
||||
#if ( $sim{args}{l} == 0 ) {
|
||||
# write_local_cat( $wd , \@inc_paths , \%sim ) ;
|
||||
#}
|
||||
|
||||
if ( $sim{args}{v} == 1 ) {
|
||||
print " [32mComplete[00m\n" ;
|
||||
}
|
||||
trick_print($sim{fh}, "\nAll MIS complete\n\n" , "normal_green" , $sim{args}{v}) ;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MIS - Trick Module Interface Specification
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
MIS [--debug] [-d] [-g] [-h] [--help] [-l] [--library]
|
||||
[-o I<outfile>] [--outfile=I<outfile>]
|
||||
[-v I<level>] [--verbose=I<level>] [B<file> ...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
See the Trick User's guide for B<MIS>.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-d> | B<-g> | B<--debug>
|
||||
|
||||
Set verbose level = 3
|
||||
|
||||
=item B<-h> | B<-?> | B<--help>
|
||||
|
||||
This help screen
|
||||
|
||||
=item B<-l> | B<--library>
|
||||
|
||||
Use this option in a SIM directory. MIS will execute on all files listed in the
|
||||
S_library_list file
|
||||
|
||||
=item B<-o> I<outfile> | B<--outfile>=I<outfile>
|
||||
|
||||
Direct output of MIS to outfile. ( Note: Does not affect screen output ).
|
||||
|
||||
=item B<-v> I<level> | B<--verbose>=I<level>
|
||||
|
||||
et the verbose level. Valid entries are 0-3.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
@ -12,32 +12,18 @@ use FindBin qw($RealBin);
|
||||
use lib "$RealBin/pm" ;
|
||||
|
||||
use parse_s_define ;
|
||||
use get_headers ;
|
||||
use ICG ;
|
||||
use MIS ;
|
||||
use mis_dep ;
|
||||
use make_makefile ;
|
||||
use make_swig_makefile ;
|
||||
use make_no_swig_makefile ;
|
||||
use gte ;
|
||||
use s_source ;
|
||||
use auto_doc ;
|
||||
use default_data ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
|
||||
my %sim ;
|
||||
my $cwd = cwd();
|
||||
my $saved_cflags ;
|
||||
my (@paths , $cc , $cc_found) ;
|
||||
my $make_cmd;
|
||||
|
||||
# override the print format for help message
|
||||
*Pod::Text::seq_i = sub { return "[04m" . $_[1] . "[00m" } ;
|
||||
|
||||
# set stdout to unbuffered so we see printout immediately.
|
||||
$| = 1 ;
|
||||
|
||||
# set default verbose level
|
||||
$sim{args}{v} = 2 ;
|
||||
$sim{args}{o} = "build/CP_out" ;
|
||||
@ -46,44 +32,16 @@ $sim{args}{p} = 1 ;
|
||||
#--------------------------------------------------------------
|
||||
# Process command line arguments
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "d" => \$sim{args}{d} ,
|
||||
"e" => \$sim{args}{e} ,
|
||||
"f" => \$sim{args}{f} ,
|
||||
"model_dirs|z" => \$sim{args}{z} ,
|
||||
"no_python|p" => sub { $sim{args}{p} = 0 } ,
|
||||
GetOptions ( "no_python|p" => sub { $sim{args}{p} = 0 } ,
|
||||
"debug|g" => sub { $sim{args}{v} = 3 ; } ,
|
||||
"help|h|?" => \$sim{args}{h} ,
|
||||
"m" => \$sim{args}{m} ,
|
||||
"outfile|o=s" => \$sim{args}{o} ,
|
||||
"r" => \$sim{args}{r} ,
|
||||
"s" => \$sim{args}{s} ,
|
||||
"t" => \$sim{args}{t} ,
|
||||
"verbose|v=i" => \$sim{args}{v}
|
||||
) or pod2usage(1) ;
|
||||
|
||||
pod2usage(1) if $sim{args}{h} ;
|
||||
|
||||
$ENV{TRICK_HOST_CPU} = gte("TRICK_HOST_CPU") ;
|
||||
chomp $ENV{TRICK_HOST_CPU} ;
|
||||
|
||||
# look to see if TRICK_CC set properly
|
||||
@paths = split /:/ , $ENV{PATH} ;
|
||||
$cc = gte("TRICK_CC") ;
|
||||
chomp $cc ;
|
||||
$cc =~ s/.*?ccache\s+// ;
|
||||
$cc_found = 0 ;
|
||||
foreach my $p ( @paths ) {
|
||||
if ( -x "$p/$cc" or -x $cc ) {
|
||||
$cc_found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $cc_found == 0 ) {
|
||||
trick_print( $sim{fh}, "CP can't find TRICK_CC = $cc.\n", "title_red", $sim{args}{v} ) ;
|
||||
exit ;
|
||||
}
|
||||
|
||||
# Get Trick version
|
||||
my ($version, $thread) = get_trick_version() ;
|
||||
$thread =~ s/\d+\.// ;
|
||||
@ -98,10 +56,6 @@ $sim{fh} = *OUTFILE ;
|
||||
print OUTFILE "Output for $0 version $version-$thread at " . localtime() . "\n\n" ;
|
||||
|
||||
|
||||
if ( !( $sim{args}{e} || $sim{args}{s} || $sim{args}{m} || $sim{args}{d} ) ) {
|
||||
$sim{args}{e} = $sim{args}{s} = $sim{args}{m} = $sim{args}{d} = 1 ;
|
||||
}
|
||||
|
||||
# if no python is specified, turn off the python InputProcessor sim_object in S_define.
|
||||
if ( $sim{args}{p} == 0 ) {
|
||||
$ENV{TRICK_SFLAGS} .= " -DTRICK_NO_INPUTPROCESSOR" ;
|
||||
@ -117,158 +71,34 @@ parse_s_define(\%sim) ;
|
||||
|
||||
trick_print( $sim{fh}, "\nCompleted parsing S_define\n\n" , "normal_green" , $ sim{args}{v} ) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# If this is CP -z|model_dirs, print model dirs and exit
|
||||
if ( $sim{args}{z} ) {
|
||||
my %model_dirs ;
|
||||
foreach ( keys %{$sim{headers_full_path}} ) {
|
||||
$model_dirs{dirname($_)} = 1 ;
|
||||
}
|
||||
foreach ( @{$sim{mis_entry_files}} ) {
|
||||
$model_dirs{dirname($_)} = 1 ;
|
||||
}
|
||||
trick_print($sim{fh}, "Model directory listing\n", "title_cyan", $sim{args}{v});
|
||||
foreach ( sort keys %model_dirs ) {
|
||||
trick_print($sim{fh}, "$_\n", "normal_white", $sim{args}{v});
|
||||
}
|
||||
exit ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make S_source.c
|
||||
|
||||
if ($sim{args}{s}) {
|
||||
trick_print($sim{fh}, "Creating S_source.c...", "title_cyan", $sim{args}{v});
|
||||
s_source( \%sim ) ;
|
||||
trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Get all headers used by the sim and their modification dates
|
||||
get_headers(\%sim, abs_path("S_source.hh")) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# ICG all headers that S_define references
|
||||
# ICG will return:
|
||||
# -> Hash of types (used to create S_source.c)
|
||||
# %types{type_name} -> {name,value,xml}
|
||||
# value == 102 means enumerated type
|
||||
# value == 103 means struct type
|
||||
# -> Hash of dependencies (used to create Makefile)
|
||||
my @files_to_mis ;
|
||||
my ($new_mis_depends_ref , $rcs_tags_ref) ;
|
||||
my @mis_entry_files ;
|
||||
my @headers_to_ICG ;
|
||||
my @all_headers_to_ICG ;
|
||||
|
||||
chdir ($cwd) ;
|
||||
|
||||
trick_print($sim{fh}, "Determining structure dependencies.\n" , "normal_cyan" , $sim{args}{v}) ;
|
||||
|
||||
@all_headers_to_ICG = (sort keys %{$sim{headers_full_path}}) ;
|
||||
foreach ( @all_headers_to_ICG ) {
|
||||
if ( !/trick_source/ ) {
|
||||
push @headers_to_ICG , $_ ;
|
||||
}
|
||||
}
|
||||
if ( scalar @headers_to_ICG ) {
|
||||
trick_print( $sim{fh}, "ICG'ing header files to get all header file dependencies..." , "title_cyan" , $sim{args}{v} ) ;
|
||||
trick_print( $sim{fh}, "\n" , "title_white" , $sim{args}{v} ) if ( $sim{args}{v} != 1 ) ;
|
||||
}
|
||||
|
||||
my @defs ;
|
||||
my @temp_array = ( abs_path("S_source.hh")) ;
|
||||
ICG ( @temp_array , "CP" , \@defs, \%sim ) ;
|
||||
if ( $sim{args}{v} == 1 ) {
|
||||
print " [32mComplete[00m\n" ;
|
||||
}
|
||||
|
||||
if ( scalar @headers_to_ICG ) {
|
||||
trick_print( $sim{fh}, "\nAll header file dependencies found.\n" , "normal_green" , $sim{args}{v} ) ;
|
||||
}
|
||||
|
||||
foreach my $h ( @all_headers_to_ICG ) {
|
||||
# push the header dependencies for c++ files onto the lists for mis processing
|
||||
foreach ( keys %{$sim{all_icg_depends}{$h}} ) {
|
||||
if ( exists $sim{head_deps}{$_} and defined $sim{head_deps}{$_}{files} ) {
|
||||
push @mis_entry_files , @{$sim{head_deps}{$_}{files}} ;
|
||||
push @{$sim{mis_entry_files}} , @{$sim{head_deps}{$_}{files}} ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trick_print( $sim{fh}, "Determining module dependencies.\n", "normal_cyan" , $sim{args}{v}) ;
|
||||
|
||||
push @mis_entry_files , (grep !/trick_source/ , @{$sim{mis_entry_files}}) ;
|
||||
foreach ( @mis_entry_files ) {
|
||||
if ( ! exists $sim{src_only}{$_} ) {
|
||||
if ( !/trick_source/ ) {
|
||||
push @files_to_mis , $_ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %temp_hash ;
|
||||
@files_to_mis = grep ++$temp_hash{$_} < 2, @files_to_mis ;
|
||||
|
||||
$new_mis_depends_ref = mis_dep(\%sim , @files_to_mis) ;
|
||||
|
||||
# Add the object only listings
|
||||
mis_catalog_dep(\%sim , $new_mis_depends_ref) ;
|
||||
|
||||
foreach my $k ( keys %$new_mis_depends_ref ) {
|
||||
$sim{all_mis_depends}{$k} = $$new_mis_depends_ref{$k} ;
|
||||
}
|
||||
|
||||
my @all_src_files ;
|
||||
foreach my $n ( @{$sim{mis_entry_files}} ) {
|
||||
foreach my $k ( grep !/last_look/ ,
|
||||
(keys %{$sim{all_mis_depends}{$n}}) ) {
|
||||
|
||||
push @all_src_files ,
|
||||
@{$sim{all_mis_depends}{$n}{$k}} ;
|
||||
}
|
||||
}
|
||||
undef %temp_hash ;
|
||||
@all_src_files = grep ++$temp_hash{$_} < 2, @all_src_files ;
|
||||
@all_src_files = grep !/trick_source|\.a$|^\-/ , @all_src_files ;
|
||||
|
||||
if ( $sim{args}{v} == 1 ) {
|
||||
print " [32mComplete[00m\n" ;
|
||||
}
|
||||
trick_print($sim{fh}, "\nMIS complete\n\n" , "normal_green" , $sim{args}{v}) ;
|
||||
trick_print($sim{fh}, "Creating S_source.c...", "title_cyan", $sim{args}{v});
|
||||
s_source( \%sim ) ;
|
||||
trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make Default Data
|
||||
|
||||
if ($sim{args}{d}) {
|
||||
chdir ($cwd) ;
|
||||
trick_print($sim{fh}, "Creating Default_data...", "title_cyan" , $sim{args}{v}) ;
|
||||
make_default_data( \%sim ) ;
|
||||
trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Make Makefile
|
||||
|
||||
if ($sim{args}{m}) {
|
||||
trick_print($sim{fh}, "Creating New Makefile... ", "title_cyan" , $sim{args}{v}) ;
|
||||
make_makefile( \@temp_array , \%sim , $cwd) ;
|
||||
trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ;
|
||||
|
||||
if ( $sim{args}{p} == 1 ) {
|
||||
trick_print($sim{fh}, "Creating SWIG Makefile... ", "title_cyan" , $sim{args}{v}) ;
|
||||
make_swig_makefile( \@temp_array , \%sim , $cwd) ;
|
||||
trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ;
|
||||
} else {
|
||||
trick_print($sim{fh}, "Creating No-python Makefile... ", "title_cyan" , $sim{args}{v}) ;
|
||||
make_no_swig_makefile() ;
|
||||
trick_print($sim{fh}, " Complete\n" , "title_green" , $sim{args}{v}) ;
|
||||
}
|
||||
}
|
||||
chdir ($cwd) ;
|
||||
trick_print($sim{fh}, "Creating Default_data...", "title_cyan" , $sim{args}{v}) ;
|
||||
make_default_data( \%sim ) ;
|
||||
trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ;
|
||||
|
||||
close OUTFILE ;
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Write out the library dependencies found in the S_define file.
|
||||
open LIBDEP, ">build/S_define.lib_deps" ;
|
||||
foreach my $file ( @{$sim{mis_entry_files}} ) {
|
||||
if ( $file ne "" ) {
|
||||
$file = abs_path(dirname($file)) . "/" . basename($file) ;
|
||||
print LIBDEP "$file\n" ;
|
||||
}
|
||||
}
|
||||
close LIBDEP ;
|
||||
|
||||
################################################################################
|
||||
# END MAIN
|
||||
################################################################################
|
||||
@ -324,22 +154,10 @@ output all CP output to an external file
|
||||
|
||||
Create a simulation without python input processor.
|
||||
|
||||
=item B<-s>
|
||||
|
||||
S_source.c (Simulation specific executive source code)
|
||||
|
||||
=item B<-r>
|
||||
|
||||
S_sie.resource (Smart Input Editor data base)
|
||||
|
||||
=item B<-v> I<level> | B<--verbose>=I<level>
|
||||
|
||||
Set the verbose level. Valid entries are 0-3.
|
||||
|
||||
=item B<-z> | B<--model_dirs>
|
||||
|
||||
Print out the model directories this S_define depends on.
|
||||
|
||||
=item B<-DTRICK_VER=x.x>
|
||||
|
||||
Note: -DTRICK_VER=x.x is automatically used when parsing header files and the S_define file
|
||||
|
@ -10,7 +10,6 @@ use lib "$RealBin/pm" ;
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path' ;
|
||||
use gte ;
|
||||
use get_headers ;
|
||||
use trick_version ;
|
||||
use Digest::MD5 qw(md5_hex) ;
|
||||
use File::Path qw(make_path) ;
|
||||
@ -38,31 +37,25 @@ Options:
|
||||
display this help and exit
|
||||
-s, --stl
|
||||
Allow convert_swig to process STLs
|
||||
-o, --outfile <OUT_FILE>
|
||||
provide a name for the generated SWIG interface file which
|
||||
is usually denoted with a special [2m[3m.i[00m or [2m[3m.swg[00m suffix
|
||||
|
||||
Usage:
|
||||
convert_swig [-o <OUT_FILE>] <IN_FILE>
|
||||
convert_swig <IN_FILES>
|
||||
|
||||
Examples:
|
||||
% convert_swig -o swig/Ball.i include/Ball.hh
|
||||
% convert_swig -o swig_src/S_source.i S_source.hh
|
||||
% convert_swig include/Ball.hh
|
||||
% convert_swig S_source.hh
|
||||
" ;
|
||||
|
||||
|
||||
my ($in_file , $out_file ) ;
|
||||
my $help = ''; # option variable with default value (false)
|
||||
my $stls = 0; # option variable with default value (false)
|
||||
|
||||
my ( @include_paths, @include_dirs , @defines) ;
|
||||
my ( @include_dirs , @defines) ;
|
||||
my ( @swig_exclude_dirs) ;
|
||||
my ( @exclude_dirs) ;
|
||||
my %sim ;
|
||||
my %out_of_date ;
|
||||
my ($version, $thread, $year) ;
|
||||
my %icg_no ;
|
||||
my %skipped_files ;
|
||||
my %processed_templates ;
|
||||
|
||||
my $typedef_def = qr/typedef\s+ # the word typedef
|
||||
@ -113,8 +106,7 @@ my %stl_names = qw(deque 1 set 1 multiset 1 multimap 1 hash_set 1
|
||||
std::bitset 1 std::auto_ptr 1 pair 1 std::pair 1 std::tr1::shared_ptr 1) ;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
GetOptions ( "outfile|o=s" => \$out_file ,
|
||||
"stl|s" => sub { $stls = 1 } ,
|
||||
GetOptions ( "stl|s" => sub { $stls = 1 } ,
|
||||
'help|h' => \$help ) or usage() ;
|
||||
|
||||
if ( $help ) {
|
||||
@ -124,188 +116,65 @@ if ( $help ) {
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
@include_dirs = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_SWIG_EXCLUDE"} ;
|
||||
if ( scalar @swig_exclude_dirs == 0 ) {
|
||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"} ;
|
||||
}
|
||||
@exclude_dirs = split /:/ , $ENV{"TRICK_EXCLUDE"} ;
|
||||
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
|
||||
push @defines , "-DTRICK_VER=$year" ;
|
||||
}
|
||||
#(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
# Use the c preporcessor directly
|
||||
my $cc ;
|
||||
my $system_type = `uname -s` ;
|
||||
chomp $system_type ;
|
||||
if ( $system_type eq "Darwin" ) {
|
||||
$cc = "/usr/bin/llvm-gcc -E" ;
|
||||
} else {
|
||||
$cc = "/usr/bin/cpp" ;
|
||||
}
|
||||
|
||||
($in_file) = (grep !/^-/ , @ARGV) ;
|
||||
|
||||
## The list of header files to be processed is usually produced by the script
|
||||
## make_swig_makefile.pm, as it's creating Makefile_swig. This list is stored in
|
||||
## the file ".S_library_swig". So, if .S_library_swig exists, we can just open and read it.
|
||||
##
|
||||
|
||||
my ($s_library_swig) = "build/S_library_swig" ;
|
||||
|
||||
if ( -e $s_library_swig ) {
|
||||
open FILE_LIST, $s_library_swig ;
|
||||
if ( scalar @ARGV == 0 ) {
|
||||
my ($s_library_swig) = "build/S_library_swig" ;
|
||||
open FILE_LIST, $s_library_swig or die "Could not open $s_library_swig" ;
|
||||
while ( <FILE_LIST> ) {
|
||||
chomp ;
|
||||
$sim{final_all_includes}{$_} = 1 ;
|
||||
|
||||
my ($f) = $_ ;
|
||||
my ($swig_dir , $base_file , $swig_file ) ;
|
||||
|
||||
$base_file = basename($f) ;
|
||||
$base_file =~ s/\.[^\.]+$// ;
|
||||
|
||||
$swig_dir = dirname($f) ;
|
||||
$swig_dir = "build/$swig_dir" ;
|
||||
$swig_file = "$swig_dir/${base_file}.i" ;
|
||||
|
||||
#print "$swig_file\n" ;
|
||||
if ( -e $swig_file ) {
|
||||
if ( !exists $sim{mod_date}{$f} ) {
|
||||
$sim{mod_date}{$f} = (stat $f)[9] ;
|
||||
}
|
||||
$sim{swig_mod_date}{$f} = (stat $swig_file)[9] ;
|
||||
if ( $sim{mod_date}{$f} > $sim{swig_mod_date}{$f} ) {
|
||||
$out_of_date{$f} = 1 ;
|
||||
}
|
||||
} else {
|
||||
$out_of_date{$f} = 1 ;
|
||||
$sim{swig_mod_date}{$f} = 0 ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
## Otherwise we need to process S_source.hh to produce the list of header files.
|
||||
##
|
||||
## Specifically, we want to generate SWIG interfaces for those header files that are:
|
||||
## 1) actual dependencies of S_source.hh, GIVEN THE CURRENT environment and
|
||||
## 2) not excluded from ICG processing ( by ICG_NO or ICG_EXCLUDE).
|
||||
##
|
||||
## The header files that are actually included are the dependencies we care
|
||||
## about. Keep in mind that the pre-processor and the current ENVIRONMENT
|
||||
## may cause some headers to be conditionally included or excluded. We only
|
||||
## want to generate SWIG interfaces for headers that are ACTUALLY included.
|
||||
##
|
||||
## Whereas the pre-processor can (using the gcc -MM option) generate a list
|
||||
## of dependencies that satisfy 1) (above), it can't handle that ICG exclusions.
|
||||
## And, whereas the function get_headers() can generate a list of dependences
|
||||
## which are flagged if they contain ICG_NO, it doesn't handle conditional includes.
|
||||
##
|
||||
## So, the strategy that we employ is to generate and then find the
|
||||
## intersection of both lists. Then we eliminate those that are in 1)
|
||||
## $TRICK_HOME/trick_source, or 2) flagged as containing ICG_NO or 3) are
|
||||
## in ICG_EXCLUDE'd directories.
|
||||
##
|
||||
## First, create a list headers using the GCC with the -MM option. GCC will
|
||||
## handle conditional inclusion.
|
||||
##
|
||||
|
||||
# list of files to process does not exist. Process S_source.hh to create one.
|
||||
my ($s_source_full_path) = abs_path("S_source.hh") ;
|
||||
open FILE_LIST, "$cc -MM -DSWIG @include_paths @defines $in_file |" ;
|
||||
my $dir ;
|
||||
$dir = dirname($s_source_full_path) ;
|
||||
while ( <FILE_LIST> ) {
|
||||
next if ( /^#/ or /^\s+\\/ ) ;
|
||||
my $word ;
|
||||
foreach $word ( split ) {
|
||||
next if ( $word eq "\\" or $word =~ /o:/ ) ;
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir/$word" ;
|
||||
}
|
||||
$word = abs_path(dirname($word)) . "/" . basename($word) ;
|
||||
# filter out system headers that are missed by the compiler -MM flag
|
||||
next if ( $word =~ /^\/usr\/include/) ;
|
||||
next if ( $word =~ /$ENV{TRICK_HOME}\/trick_source\//) ;
|
||||
|
||||
#print "gcc found $word\n" ;
|
||||
$sim{gcc_all_includes}{$word} = 1 ;
|
||||
#$sim{mod_date}{$word} = (stat $word)[9] ;
|
||||
}
|
||||
}
|
||||
|
||||
## Second, create a list where the files are flagged if they contain ICG_NO.
|
||||
##
|
||||
|
||||
get_headers(\%sim, $s_source_full_path) ;
|
||||
if ( open ICGNOFOUND , ("build/icg_no_found") ) {
|
||||
while ( <ICGNOFOUND> ) {
|
||||
chomp ;
|
||||
$icg_no{$_} = 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
## Then we generate the intersection of the two lists and then eliminate the dependencies that:
|
||||
## 1) are in $TRICK_HOME/trick_source.
|
||||
## 2) contain ICG_NO.
|
||||
## 3) are in ICG_EXCLUDE'd directories.
|
||||
## to create the final list of header dependencies that we need to convert into SWIG interfaces.
|
||||
##
|
||||
|
||||
foreach my $k ( keys %{$sim{gcc_all_includes}} ) {
|
||||
$sim{final_all_includes}{$k} = 1 if exists $sim{all_includes}{$s_source_full_path} ;
|
||||
}
|
||||
|
||||
foreach my $f ( keys %{$sim{final_all_includes}} ) {
|
||||
if ( $f =~ /$ENV{TRICK_HOME}\/trick_source/ ) {
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
} elsif ( exists $icg_no{$f} ) {
|
||||
$skipped_files{$f} = "ICG No found" ;
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
} else {
|
||||
foreach my $ie ( @swig_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
$skipped_files{$f} = "ICG exclude dir $ie" ;
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
$skipped_files{$f} = "Exclude dir $ie" ;
|
||||
delete $sim{final_all_includes}{$f} ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#print "HERE I AM @ARGV\n" ;
|
||||
map { $out_of_date{$_} = 1 } @ARGV ;
|
||||
}
|
||||
|
||||
## Next we need to determine which of the files do not have up-to-date SWIG files.
|
||||
## For each header file in final dependency list, if the corresponding SWIG (.i) file
|
||||
## doesn't exist or the header file is newer than the existing SWIG file, then record
|
||||
## that a new SWIG file needs needs to be created. The global hash %out_of_date
|
||||
## represents a list of header files whose corresponding .i files need to be regenerated.
|
||||
## The global hash %out_of_date represents a list of header files whose
|
||||
## corresponding .i files need to be regenerated.
|
||||
##
|
||||
|
||||
foreach my $f ( keys %{$sim{final_all_includes}} ) {
|
||||
my ($swig_dir , $base_file , $swig_file ) ;
|
||||
|
||||
$base_file = basename($f) ;
|
||||
$base_file =~ s/\.[^\.]+$// ;
|
||||
|
||||
$swig_dir = dirname($f) ;
|
||||
$swig_dir = "build/$swig_dir" ;
|
||||
$swig_file = "$swig_dir/${base_file}.i" ;
|
||||
|
||||
#print "$swig_file\n" ;
|
||||
if ( -e $swig_file ) {
|
||||
if ( !exists $sim{mod_date}{$f} ) {
|
||||
$sim{mod_date}{$f} = (stat $f)[9] ;
|
||||
}
|
||||
$sim{swig_mod_date}{$f} = (stat $swig_file)[9] ;
|
||||
if ( $sim{mod_date}{$f} > $sim{swig_mod_date}{$f} ) {
|
||||
$out_of_date{$f} = 1 ;
|
||||
}
|
||||
} else {
|
||||
$out_of_date{$f} = 1 ;
|
||||
$sim{swig_mod_date}{$f} = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( scalar keys %out_of_date == 0 ) {
|
||||
exit ;
|
||||
}
|
||||
|
||||
foreach ( sort keys %skipped_files ) {
|
||||
print "convert_swig skipping $_ ($skipped_files{$_})\n" ;
|
||||
}
|
||||
|
||||
## Finally, call process_file() to create SWIG interface files for each of the out_of_date headers.
|
||||
##
|
||||
|
||||
process_file(\%sim , abs_path($in_file)) ;
|
||||
process_file() ;
|
||||
|
||||
##
|
||||
## ================================================================================
|
||||
@ -320,16 +189,10 @@ process_file(\%sim , abs_path($in_file)) ;
|
||||
##
|
||||
## sim_ref
|
||||
##
|
||||
## Is this parameter ever used?
|
||||
##
|
||||
## in_file
|
||||
##
|
||||
## The name of input file, invariably "S_source.hh".
|
||||
##
|
||||
|
||||
sub process_file($$) {
|
||||
|
||||
my ($sim_ref , $in_file) = @_ ;
|
||||
sub process_file() {
|
||||
|
||||
## Foreach out_of_date header file, generate a SWIG interface file.
|
||||
|
||||
@ -426,6 +289,7 @@ sub process_file($$) {
|
||||
my ($out_dir) = dirname($f) ;
|
||||
$out_dir = "build$out_dir" ;
|
||||
|
||||
my $out_file ;
|
||||
$out_file = basename($f) ;
|
||||
$out_file =~ s/\.h.*$/\.i/ ;
|
||||
|
||||
@ -448,7 +312,6 @@ sub process_file($$) {
|
||||
open OUT, ">$out_file" ;
|
||||
|
||||
print OUT "\%module m$md5_sum\n\n" ;
|
||||
print OUT "/* $in_file */\n" ;
|
||||
|
||||
print OUT "#include \"trick/swig/trick_swig.i\"\n\n" ;
|
||||
|
||||
|
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use Cwd 'abs_path' ;
|
||||
use File::Basename;
|
||||
use strict ;
|
||||
|
||||
my $full_path ;
|
||||
my $dir ;
|
||||
my $dir_no_src ;
|
||||
my $file_base ;
|
||||
my $word ;
|
||||
my $cont ;
|
||||
|
||||
#$full_path = abs_path(@ARGV[0]) ;
|
||||
$full_path = abs_path(dirname(@ARGV[0])) . "/" . basename(@ARGV[0]) ;
|
||||
|
||||
$dir = dirname($full_path) ;
|
||||
($dir_no_src = $dir) =~ s/\/src$// ;
|
||||
|
||||
$file_base = basename($full_path) ;
|
||||
$file_base =~ s/\.[^\.]+$// ;
|
||||
|
||||
open FILE, "$dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.d" or die "Could not open $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.d" ;
|
||||
|
||||
open OUTFILE, "> $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.dep" or die "Could not open $dir_no_src/object_$ENV{TRICK_HOST_CPU}/${file_base}.dep" ;
|
||||
|
||||
while ( <FILE> ) {
|
||||
next if ( /^#/ ) ;
|
||||
next if ( /^\s+\\/ ) ;
|
||||
|
||||
$cont = 0 ;
|
||||
foreach $word ( split ) {
|
||||
|
||||
if ( $word eq "\\" ) {
|
||||
$word = "\\\n" ;
|
||||
$cont = 1 ;
|
||||
}
|
||||
else {
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir/$word" ;
|
||||
}
|
||||
$word = abs_path($word) ;
|
||||
}
|
||||
print OUTFILE "$word " ;
|
||||
}
|
||||
if ( $cont == 0 ) {
|
||||
print OUTFILE "\n" ;
|
||||
}
|
||||
}
|
||||
|
437
libexec/trick/make_makefile_src
Executable file
437
libexec/trick/make_makefile_src
Executable file
@ -0,0 +1,437 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/pm" ;
|
||||
|
||||
use strict ;
|
||||
use File::Basename ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path';
|
||||
use trick_version ;
|
||||
use get_lib_deps ;
|
||||
|
||||
my %processed_files ;
|
||||
my %non_lib_processed_files ;
|
||||
|
||||
sub read_lib_deps(@) {
|
||||
my (@files_to_process) = @_ ;
|
||||
foreach my $l ( @files_to_process ) {
|
||||
next if ( $l eq "" ) ;
|
||||
if ( ! exists $processed_files{$l} ) {
|
||||
$processed_files{$l} = 1 ;
|
||||
next if ( $l =~ /^-|\.a$/ ) ;
|
||||
$non_lib_processed_files{$l} = 1 ;
|
||||
my ( $file, $dir, $suffix) = fileparse($l, qr/\.[^.]*/) ;
|
||||
my ($lib_dep_file_name) = "build$dir${file}.lib_deps" ;
|
||||
if ( -e $lib_dep_file_name ) {
|
||||
open FH, "$lib_dep_file_name" or die 'cannot open $lib_dep_file_name' ;
|
||||
my (@all_lines) = <FH> ;
|
||||
close FH ;
|
||||
chomp @all_lines ;
|
||||
read_lib_deps(@all_lines) ;
|
||||
} else {
|
||||
print "Getting Dependencies for $l\n" ;
|
||||
if ( -e $l ) {
|
||||
my $contents ;
|
||||
my @resolved_files ;
|
||||
@resolved_files = write_lib_deps($l) ;
|
||||
read_lib_deps(@resolved_files) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for my $f ( @ARGV ) {
|
||||
if ( $f !~ /Makefile_io_src/ ) {
|
||||
print "Updating Dependencies for $f\n" ;
|
||||
write_lib_deps($f) ;
|
||||
}
|
||||
}
|
||||
|
||||
open FILE, "build/header_lib_deps_files" or die 'cannot open build/header_lib_deps_files' ;
|
||||
my (@top_lib_dep_file_names) = <FILE> ;
|
||||
close FILE ;
|
||||
chomp @top_lib_dep_file_names ;
|
||||
push @top_lib_dep_file_names, "build/S_define.lib_deps" ;
|
||||
|
||||
foreach my $f ( @top_lib_dep_file_names ) {
|
||||
my @all_lines ;
|
||||
next if ( $f eq "" ) ;
|
||||
open FH, "$f" or die 'cannot open $f' ;
|
||||
@all_lines = <FH> ;
|
||||
close FH ;
|
||||
chomp @all_lines ;
|
||||
read_lib_deps(@all_lines) ;
|
||||
}
|
||||
|
||||
#print map {"$_\n"} (sort keys %processed_files) ;
|
||||
|
||||
my ($n , $f , $k , $i , $m);
|
||||
my $num_inc_objs ;
|
||||
my %all_mis_depends ;
|
||||
my %temp_hash ;
|
||||
my @all_cfly_files ;
|
||||
my @all_read_only_libs ;
|
||||
my @all_compile_libs ;
|
||||
my %files_by_dir ;
|
||||
my ( $sp_dir , $src_dir , $sp_file , $base_name , $suffix) ;
|
||||
my @temp_array ;
|
||||
|
||||
my @exclude_dirs ;
|
||||
@exclude_dirs = split /:/ , $ENV{"TRICK_EXCLUDE"};
|
||||
# See if there are any elements in the exclude_dirs array
|
||||
if (scalar @exclude_dirs) {
|
||||
@exclude_dirs = sort(@exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @exclude_dirs ;
|
||||
while ( not length @exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @exclude_dirs ;
|
||||
}
|
||||
@exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @exclude_dirs ;
|
||||
}
|
||||
|
||||
@all_cfly_files = keys %processed_files ;
|
||||
@all_read_only_libs = sort (grep /^-/ , @all_cfly_files) ;
|
||||
@all_compile_libs = grep /\.a$/ , @all_cfly_files ;
|
||||
@all_compile_libs = sort (grep !/trick_source/ , @all_compile_libs) ;
|
||||
@all_cfly_files = sort (grep !/^-|trick_source|a$/ , @all_cfly_files) ;
|
||||
|
||||
# split off files by directory
|
||||
foreach ( @all_cfly_files ) {
|
||||
$sp_file = basename($_) ;
|
||||
$_ = abs_path(dirname($_)) ;
|
||||
|
||||
( $sp_dir , $src_dir ) = /(.*?)(?:\/(src))?$/ ;
|
||||
$src_dir .= "/" if ($src_dir ne "") ;
|
||||
($base_name , $suffix) = $sp_file =~ /(.*?)([cfly]$|C$|cc$|cxx$|cpp$|c\+\+$)/ ;
|
||||
|
||||
$files_by_dir{$sp_dir}{src_dir} = $src_dir ;
|
||||
push @{$files_by_dir{$sp_dir}{$suffix}} , $base_name ;
|
||||
}
|
||||
|
||||
# get all of the files required by compiled libraries
|
||||
# compile all files as normal files, we're not going to make a library anymore.
|
||||
foreach $n ( @all_compile_libs ) {
|
||||
my @local_files ;
|
||||
$sp_file = basename($n) ;
|
||||
$sp_dir = dirname($n) ;
|
||||
$sp_dir =~ s/\/object_\$\{TRICK_HOST_CPU\}?$// ;
|
||||
$sp_dir = abs_path($sp_dir) ;
|
||||
$src_dir = ( -e "$sp_dir/src" ) ? "src/" : "" ;
|
||||
$files_by_dir{$sp_dir}{src_dir} = $src_dir ;
|
||||
opendir THISDIR, "$sp_dir/$src_dir" or die "Could not open the directory $sp_dir/$src_dir";
|
||||
@local_files = grep !/^\.\.\./ , readdir THISDIR;
|
||||
@local_files = grep /\.[cfly]$|C$|cc$|cxx$|cpp$|c\+\+$/ , @local_files;
|
||||
foreach $k ( @local_files ) {
|
||||
($base_name , $suffix) = $k =~ /(.*?)([cfly]$|C$|cc$|cxx$|cpp$|c\+\+$)/ ;
|
||||
push @{$files_by_dir{$sp_dir}{$suffix}} , $base_name ;
|
||||
}
|
||||
closedir THISDIR ;
|
||||
}
|
||||
|
||||
# sort and weed out duplicate files
|
||||
foreach $k ( keys %files_by_dir ) {
|
||||
foreach $n ( qw{ c f l y h C cc cxx cpp c++} ) {
|
||||
undef %temp_hash ;
|
||||
@{$files_by_dir{$k}{$n}} = sort grep ++$temp_hash{$_} < 2, @{$files_by_dir{$k}{$n}} ;
|
||||
}
|
||||
}
|
||||
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
# if file location begins with $ie (an exclude dir)
|
||||
if ( $k =~ /^\Q$ie/ ) {
|
||||
delete $files_by_dir{$k} ;
|
||||
print "[33mexcluding $k from build[00m\n" ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# set the "dir_num" of each directory.
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
$_ = $k ;
|
||||
($files_by_dir{$k}{dir_num} = $_) =~ s#^/## ;
|
||||
$files_by_dir{$k}{dir_num} =~ s/[\/.]/_/g ;
|
||||
# if a particular directory had an override file, save that into memory
|
||||
if (open OV_FILE, "$k/makefile_overrides") {
|
||||
while ( <OV_FILE> ) {
|
||||
s/(#.*)// ;
|
||||
my ($comment) = $1 ;
|
||||
s/\$[{(]CURDIR[})]\/(\S+)/$k\/$1/g ;
|
||||
s/(?:\$[{(]CURDIR[})]\/)?(\S*)\$[{(]OBJ_DIR[})]/$k\/$1object_\${TRICK_HOST_CPU}/g ;
|
||||
s/\$[{(]CURDIR[})]/$k/g ;
|
||||
while ( s,/[^/]+/\.\.,, ) {}
|
||||
s//$comment/ ;
|
||||
if ( s/^objects\s*:\s*// ) {
|
||||
foreach my $ext ( qw{c C cc cxx cpp CPLUSPLUS l y} ) {
|
||||
$files_by_dir{$k}{overrides} .= "\$(MODEL_${ext}_OBJ_$files_by_dir{$k}{dir_num}): $_" ;
|
||||
}
|
||||
}
|
||||
elsif ( s/^depend\s*:\s*// ) {
|
||||
$files_by_dir{$k}{overrides} .= "depend_$files_by_dir{$k}{dir_num}: $_" ;
|
||||
}
|
||||
elsif ( s/([cfhy]|C|cc|cxx|cpp|CPLUSPLUS)_objects\s*:\s*// ) {
|
||||
$files_by_dir{$k}{overrides} .= "\$(MODEL_$1_OBJ_$files_by_dir{$k}{dir_num}): $_" ;
|
||||
}
|
||||
else {
|
||||
$files_by_dir{$k}{overrides} .= $_ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $wd = abs_path(cwd()) ;
|
||||
my $dt = localtime();
|
||||
my ($trick_ver) = get_trick_version() ;
|
||||
chomp $trick_ver ;
|
||||
|
||||
open MAKEFILE , ">build/Makefile_src" or return ;
|
||||
|
||||
print MAKEFILE "\
|
||||
#############################################################################
|
||||
# Makefile:
|
||||
# This is a makefile for maintaining the
|
||||
# '$wd'
|
||||
# simulation directory. This make file was automatically generated by trick-CP
|
||||
#
|
||||
#############################################################################
|
||||
# Creation:
|
||||
# Author: Trick Configuration Processor - trick-CP Version $trick_ver
|
||||
# Date: $dt
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||
|
||||
S_MAIN = \$(CURDIR)/S_main_\${TRICK_HOST_CPU}.exe
|
||||
ifeq (\$(MAKECMDGOALS), test)
|
||||
TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
|
||||
S_MAIN = \$(CURDIR)/T_main_\${TRICK_HOST_CPU}.exe
|
||||
endif
|
||||
|
||||
LIB_DIR = \$(CURDIR)/build/lib
|
||||
|
||||
ifdef TRICK_VERBOSE_BUILD
|
||||
PRINT_COMPILE =
|
||||
PRINT_INC_LINK =
|
||||
PRINT_EXE_LINK =
|
||||
PRINT_S_DEF_DEPS =
|
||||
ECHO_CMD =
|
||||
else
|
||||
PRINT_COMPILE = \@echo \"[34mCompiling [0m \$(subst \$(CURDIR)/build,build,\$<)\"
|
||||
PRINT_INC_LINK = \@echo \"[34mPartial link[0m \$(subst \$(CURDIR)/build,build,\${<D})\"
|
||||
PRINT_EXE_LINK = \@echo \"[34mFinal link [0m \$(subst \$(CURDIR)/,,\$(S_MAIN))\"
|
||||
PRINT_S_DEF_DEPS = \@echo \"[34mGet depends [0m for S_define\"
|
||||
ECHO_CMD = \@
|
||||
ifeq (\$(MAKECMDGOALS), all)
|
||||
\$(info [34mPerforming build with these compilation flags[0m)
|
||||
\$(info [33mTRICK_CFLAGS = \$(TRICK_CFLAGS)[0m)
|
||||
\$(info [33mTRICK_CXXFLAGS = \$(TRICK_CXXFLAGS)[0m)
|
||||
endif
|
||||
endif
|
||||
|
||||
S_OBJECT_FILES = \$(CURDIR)/build/S_source.o
|
||||
|
||||
\$(S_OBJECT_FILES) : | \$(LIB_DIR)\n\n" ;
|
||||
|
||||
my %object_files_by_type ;
|
||||
$num_inc_objs = 0 ;
|
||||
# list out all of the source and object files
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
foreach my $ext ( qw{ c C cc cxx cpp c++ l y} ) {
|
||||
my $print_ext ;
|
||||
if ( $ext eq "c++" ) {
|
||||
$print_ext = "CPLUSPLUS" ;
|
||||
} else {
|
||||
$print_ext = $ext ;
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) {
|
||||
print MAKEFILE "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num} =" ;
|
||||
foreach $f ( @{$files_by_dir{$k}{$ext}} ) {
|
||||
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "o" ;
|
||||
}
|
||||
push @{$object_files_by_type{$ext}}, "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}" ;
|
||||
|
||||
print MAKEFILE "\n\n\$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}) : | \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f\n" ;
|
||||
print MAKEFILE "\$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f :\n" ;
|
||||
print MAKEFILE "\t@ mkdir -p \$\@\n\n" ;
|
||||
|
||||
#print MAKEFILE "\$(CURDIR)/build/lib/o${num_inc_objs}.o : \$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num})\n" ;
|
||||
print MAKEFILE "\$(CURDIR)/build/lib/o_${print_ext}_$files_by_dir{$k}{dir_num}.o : \$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num})\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_INC_LINK)\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)cd \${<D} ; ld \$(LD_PARTIAL) -o \$\@ \$(notdir \$^)\n\n" ;
|
||||
$num_inc_objs++ ;
|
||||
}
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{l}} ne 0 ) {
|
||||
print MAKEFILE "MODEL_clex_SRC_$files_by_dir{$k}{dir_num} =" ;
|
||||
foreach $f ( @{$files_by_dir{$k}{l}} ) {
|
||||
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "clex" ;
|
||||
}
|
||||
print MAKEFILE "\n\n" ;
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{y}} ne 0 ) {
|
||||
print MAKEFILE "MODEL_y_c_SRC_$files_by_dir{$k}{dir_num} =" ;
|
||||
foreach $f ( @{$files_by_dir{$k}{y}} ) {
|
||||
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "y.c" ;
|
||||
}
|
||||
print MAKEFILE "\n\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $ext ( sort keys %object_files_by_type ) {
|
||||
my $print_ext ;
|
||||
if ( $ext eq "c++" ) {
|
||||
$print_ext = "CPLUSPLUS" ;
|
||||
} else {
|
||||
$print_ext = $ext ;
|
||||
}
|
||||
print MAKEFILE "MODEL_${print_ext}_OBJ =" ;
|
||||
foreach $f ( @{$object_files_by_type{$print_ext}} ) {
|
||||
print MAKEFILE " \\\n \$($f)" ;
|
||||
}
|
||||
print MAKEFILE "\n\n" ;
|
||||
}
|
||||
|
||||
# Write out the compile rules for each type of file.
|
||||
print MAKEFILE "\${MODEL_c_OBJ} : \$(CURDIR)/build\%.o : \%.c\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CC) \$(TRICK_CFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_C_OBJ} : \$(CURDIR)/build\%.o : \%.C\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_cc_OBJ} : \$(CURDIR)/build\%.o : \%.cc\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_cpp_OBJ} : \$(CURDIR)/build\%.o : \%.cpp\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_cxx_OBJ} : \$(CURDIR)/build\%.o : \%.cxx\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_CPLUSPLUS_OBJ} : \$(CURDIR)/build\%.o : \%.c++\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_clex_SRC} : \$(CURDIR)/build\%.clex : \%.l\n" ;
|
||||
print MAKEFILE "\t\$(LEX) -o\$\@ \$<\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_y_c_SRC} : \$(CURDIR)/build\%.y.c : \%.y\n" ;
|
||||
print MAKEFILE "\t\$(YACC) -o\$\@ \$<\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_y_OBJ} : \$(CURDIR)/build\%.o : \%.y.c\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)cd \$(<D) ; \$(TRICK_CC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$\@\n\n" ;
|
||||
|
||||
# Include all of the dependency files for each object code file
|
||||
print MAKEFILE "-include \$(MODEL_c_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_C_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_cc_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_cpp_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_cxx_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_CPLUSPLUS_OBJ:.o=.d)\n\n" ;
|
||||
|
||||
printf MAKEFILE "\n\nOBJECTS =" ;
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
foreach my $ext ( qw{ c C cc cxx cpp c++ l y} ) {
|
||||
my $print_ext ;
|
||||
if ( $ext eq "c++" ) {
|
||||
$print_ext = "CPLUSPLUS" ;
|
||||
} else {
|
||||
$print_ext = $ext ;
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) {
|
||||
print MAKEFILE "\\\n\t\$(CURDIR)/build/lib/o_${print_ext}_$files_by_dir{$k}{dir_num}.o" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# print out the libraries we link
|
||||
print MAKEFILE "\n\nREAD_ONLY_LIBS = ";
|
||||
foreach ( @all_read_only_libs ) {
|
||||
print MAKEFILE " \\\n\t$_" ;
|
||||
}
|
||||
|
||||
print MAKEFILE "\n\n
|
||||
test: TRICK_CXXFLAGS += -DTRICK_UNIT_TEST
|
||||
test: TRICK_CFLAGS += -DTRICK_UNIT_TEST
|
||||
|
||||
all: S_main
|
||||
|
||||
test: all
|
||||
|
||||
S_main : \$(S_MAIN) build/S_define.deps S_sie.resource
|
||||
\t@ echo \"\"
|
||||
\t@ echo \"[32m=== Simulation make complete ===[00m\"
|
||||
|
||||
#\t\t\$(S_OBJECT_FILES) build/lib/*.o
|
||||
|
||||
\$(S_MAIN): \${TRICK_STATIC_LIB} \$(OBJECTS) \$(S_OBJECT_FILES)
|
||||
\t\$(PRINT_EXE_LINK)
|
||||
\t\$(ECHO_CMD)\$(TRICK_LD) \$(TRICK_LDFLAGS) -o \$@ \\
|
||||
\t\t\$(S_OBJECT_FILES) \$(OBJECTS) \\
|
||||
\t\t\${TRICK_USER_LINK_LIBS} \${READ_ONLY_LIBS} \\
|
||||
\t\t\$(LD_WHOLE_ARCHIVE) \${TRICK_LIBS} \$(LD_NO_WHOLE_ARCHIVE)\\
|
||||
\t\t\${TRICK_EXEC_LINK_LIBS}
|
||||
|
||||
\$(OBJECTS) : | \$(LIB_DIR)
|
||||
|
||||
\$(LIB_DIR) :
|
||||
\t@ mkdir -p \$@
|
||||
|
||||
\$(CURDIR)/build/S_source.o: \$(CURDIR)/build/S_source.cpp
|
||||
\t\$(PRINT_COMPILE)
|
||||
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \$\< -o \$\@
|
||||
|
||||
-include build/S_source.d
|
||||
|
||||
build/S_define.deps:
|
||||
\t\$(PRINT_S_DEF_DEPS)
|
||||
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_SFLAGS) -M -MT Makefile_sim -MF build/S_define.deps -x c++ S_define
|
||||
|
||||
\$(CURDIR)/build/S_source.cpp S_default.dat: S_define
|
||||
\t\$(PERL) \${TRICK_HOME}/bin/trick-CP -s -d
|
||||
|
||||
sie: S_sie.resource
|
||||
|
||||
S_sie.resource: \$(S_MAIN)
|
||||
\t@ echo \"[34mGenerating S_sie.resource...[0m\"
|
||||
\t\$(ECHO_CMD)\$(S_MAIN) sie
|
||||
|
||||
S_define_exp:
|
||||
\t\$(TRICK_CC) -E -C -xc++ \${TRICK_SFLAGS} S_define > \$@\n\n" ;
|
||||
|
||||
# write out the override files we have read in
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
if ( exists $files_by_dir{$k}{overrides} ) {
|
||||
print MAKEFILE "\n# Overrides from $k\n\n" ;
|
||||
print MAKEFILE "$files_by_dir{$k}{overrides}\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
print MAKEFILE "\n-include build/Makefile_io_src\n" ;
|
||||
print MAKEFILE "include build/Makefile_swig\n" ;
|
||||
print MAKEFILE "-include S_overrides.mk\n" ;
|
||||
close MAKEFILE ;
|
||||
|
||||
# write out all of files as dependencies to Makefile_src
|
||||
open MAKEFILEDEPS, ">build/Makefile_src_deps" or die "Could not open build/Makefile_src_deps" ;
|
||||
print MAKEFILEDEPS "\$(CURDIR)/build/Makefile_src :" ;
|
||||
print MAKEFILEDEPS map {"\\\n $_"} (sort keys %non_lib_processed_files) ;
|
||||
print MAKEFILEDEPS "\n" ;
|
||||
close MAKEFILEDEPS ;
|
||||
|
||||
# write out all of the files we used to S_library_list
|
||||
open LIB_LIST, ">build/S_library_list" or die "Could not open build/S_library_list" ;
|
||||
print LIB_LIST map {"$_\n"} (sort keys %processed_files) ;
|
||||
close LIB_LIST ;
|
||||
|
260
libexec/trick/pm/make_swig_makefile.pm → libexec/trick/make_makefile_swig
Normal file → Executable file
260
libexec/trick/pm/make_swig_makefile.pm → libexec/trick/make_makefile_swig
Normal file → Executable file
@ -1,48 +1,21 @@
|
||||
package make_swig_makefile ;
|
||||
#!/usr/bin/perl
|
||||
|
||||
use Exporter ();
|
||||
use trick_version ;
|
||||
use File::Path ;
|
||||
use FindBin qw($RealBin);
|
||||
use lib "$RealBin/pm" ;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(make_swig_makefile);
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use File::Basename ;
|
||||
use gte ;
|
||||
use trick_print ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path';
|
||||
use gte ;
|
||||
use Digest::MD5 qw(md5_hex) ;
|
||||
use trick_version ;
|
||||
use strict ;
|
||||
|
||||
sub make_swig_makefile($$$) {
|
||||
|
||||
my ($h_ref , $sim_ref , $make_cwd ) = @_ ;
|
||||
my ($n , $f , $k , $m);
|
||||
my (%all_icg_depends) = %{$$sim_ref{all_icg_depends}} ;
|
||||
my %temp_hash ;
|
||||
my @all_h_files ;
|
||||
my (@temp_array , @temp_array2) ;
|
||||
my ($ii) ;
|
||||
my ($swig_sim_dir, $swig_src_dir) ;
|
||||
my (%py_module_map) ;
|
||||
my @exclude_dirs ;
|
||||
my @swig_exclude_dirs ;
|
||||
|
||||
my (@include_paths) ;
|
||||
my (@s_inc_paths) ;
|
||||
my (@defines) ;
|
||||
my ($version, $thread, $year) ;
|
||||
my $s_source_full_path = abs_path("S_source.hh") ;
|
||||
my $s_source_md5 = md5_hex($s_source_full_path) ;
|
||||
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
|
||||
my @exclude_dirs ;
|
||||
my @swig_exclude_dirs ;
|
||||
my @files_to_process ;
|
||||
|
||||
sub get_exclude_dirs() {
|
||||
@exclude_dirs = split /:/ , $ENV{"TRICK_EXCLUDE"};
|
||||
# See if there are any elements in the exclude_dirs array
|
||||
if (scalar @exclude_dirs) {
|
||||
@ -87,114 +60,63 @@ sub make_swig_makefile($$$) {
|
||||
@swig_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @swig_exclude_dirs ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub read_files_to_process() {
|
||||
open FILE, "build/ICG_processed" or die 'could not open build/ICG_processed' ;
|
||||
@files_to_process = <FILE> ;
|
||||
close FILE ;
|
||||
chomp @files_to_process ;
|
||||
}
|
||||
|
||||
sub make_swig_makefile() {
|
||||
|
||||
my ($n , $f , $k , $m);
|
||||
my %temp_hash ;
|
||||
my (@temp_array , @temp_array2) ;
|
||||
my ($ii) ;
|
||||
my ($swig_sim_dir, $swig_src_dir) ;
|
||||
my (%py_module_map) ;
|
||||
|
||||
my (@include_paths) ;
|
||||
my (@defines) ;
|
||||
my ($version, $thread, $year) ;
|
||||
my $s_source_full_path = abs_path("S_source.hh") ;
|
||||
my $s_source_md5 = md5_hex($s_source_full_path) ;
|
||||
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @include_paths , ("-I".$ENV{"TRICK_HOME"}."/trick_source" , "-I../include") ;
|
||||
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
push @defines , "-DTRICK_VER=$year" ;
|
||||
push @defines , "-DSWIG" ;
|
||||
|
||||
@s_inc_paths = $ENV{"TRICK_SFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
|
||||
# make a list of all the header files required by this sim
|
||||
foreach $n ( @$h_ref ) {
|
||||
push @all_h_files , $n ;
|
||||
foreach $k ( keys %{$all_icg_depends{$n}} ) {
|
||||
push @all_h_files , $k ;
|
||||
push @all_h_files , @{$all_icg_depends{$n}{$k}} ;
|
||||
}
|
||||
}
|
||||
|
||||
# remove duplicate elements
|
||||
undef %temp_hash ;
|
||||
@all_h_files = grep ++$temp_hash{$_} < 2, @all_h_files ;
|
||||
@all_h_files = sort (grep !/trick_source/ , @all_h_files) ;
|
||||
|
||||
$swig_sim_dir = "\$(CURDIR)/trick" ;
|
||||
$swig_src_dir = "\$(CURDIR)/build" ;
|
||||
|
||||
# create output directories if they don't exist
|
||||
if ( ! -e "trick" ) {
|
||||
mkdir "trick", 0775 ;
|
||||
}
|
||||
if ( ! -e "build" ) {
|
||||
mkdir "build", 0775 ;
|
||||
}
|
||||
|
||||
undef @temp_array2 ;
|
||||
foreach $n (sort @$h_ref) {
|
||||
if ( $n !~ /trick_source/ ) {
|
||||
undef @temp_array ;
|
||||
if ( !exists $all_icg_depends{$n}{$n} ) {
|
||||
@temp_array = ($n) ;
|
||||
}
|
||||
push @temp_array , keys %{$all_icg_depends{$n}} ;
|
||||
@temp_array = grep !/\/trick_source\// , @temp_array ;
|
||||
@temp_array = grep !/C$/ , @temp_array ;
|
||||
foreach $n (@files_to_process) {
|
||||
undef @temp_array ;
|
||||
# check to see if the parent directory of each file is writable.
|
||||
# If it isn't, then don't add it to the list of files to requiring ICG
|
||||
|
||||
# check to see if the parent directory of each file is writable.
|
||||
# If it isn't, then don't add it to the list of files to requiring ICG
|
||||
foreach my $f ( @temp_array ) {
|
||||
$f = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
if (exists $$sim_ref{icg_no}{$f}) {
|
||||
trick_print($$sim_ref{fh}, "CP(swig) skipping $f (ICG No found)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
next ;
|
||||
}
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @swig_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
trick_print($$sim_ref{fh}, "CP(swig) skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
my $temp_str ;
|
||||
$temp_str = dirname($f) ;
|
||||
$temp_str =~ s/\/include$// ;
|
||||
if ( -w $temp_str ) {
|
||||
push @temp_array2 , $f ;
|
||||
}
|
||||
$f = abs_path(dirname($n)) . "/" . basename($n) ;
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @swig_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
if ( $f =~ /^\Q$ie/ ) {
|
||||
print "CP(swig) skipping $f (ICG exclude dir $ie)\n" ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
push @temp_array2 , $f ;
|
||||
}
|
||||
|
||||
undef %temp_hash ;
|
||||
@temp_array2 = grep ++$temp_hash{$_} < 2, @temp_array2 ;
|
||||
|
||||
# Get the list header files from the compiler to compare to what get_headers processed.
|
||||
open FILE_LIST, "$cc -MM -DSWIG @include_paths @defines S_source.hh |" ;
|
||||
my $dir ;
|
||||
$dir = dirname($s_source_full_path) ;
|
||||
while ( <FILE_LIST> ) {
|
||||
next if ( /^#/ or /^\s+\\/ ) ;
|
||||
my $word ;
|
||||
foreach $word ( split ) {
|
||||
next if ( $word eq "\\" or $word =~ /o:/ ) ;
|
||||
if ( $word !~ /^\// and $dir ne "\/" ) {
|
||||
$word = "$dir/$word" ;
|
||||
}
|
||||
$word = abs_path(dirname($word)) . "/" . basename($word) ;
|
||||
# filter out system headers that are missed by the compiler -MM flag
|
||||
next if ( $word =~ /^\/usr\/include/) ;
|
||||
#print "gcc found $word\n" ;
|
||||
$$sim_ref{gcc_all_includes}{$word} = 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
# Only use header files that the compiler says are included.
|
||||
undef %temp_hash ;
|
||||
foreach my $k ( @temp_array2 ) {
|
||||
if ( exists $$sim_ref{gcc_all_includes}{$k} and
|
||||
$k !~ /$ENV{TRICK_HOME}\/trick_source/ ) {
|
||||
$temp_hash{$k} = 1 ;
|
||||
}
|
||||
}
|
||||
@temp_array2 = sort keys %temp_hash ;
|
||||
#print map { "$_\n" } @temp_array2 ;
|
||||
|
||||
# remove headers found in trick_source and ${TRICK_HOME}/include/trick
|
||||
@temp_array2 = sort (grep !/$ENV{"TRICK_HOME"}\/include\/trick\// , @temp_array2) ;
|
||||
|
||||
open MAKEFILE , ">build/Makefile_swig" or return ;
|
||||
open LINK_PY_OBJS , ">build/link_py_objs" or return ;
|
||||
print LINK_PY_OBJS "build/init_swig_modules.o\n" ;
|
||||
@ -212,12 +134,12 @@ ifdef TRICK_VERBOSE_BUILD
|
||||
PRINT_SWIG =
|
||||
PRINT_COMPILE_SWIG =
|
||||
PRINT_SWIG_INC_LINK =
|
||||
PRINT_CONVERT_SWIG =
|
||||
#PRINT_CONVERT_SWIG =
|
||||
else
|
||||
PRINT_SWIG = \@echo \"[34mSwig[0m \$(subst \$(CURDIR)/build,build,\$<)\"
|
||||
PRINT_COMPILE_SWIG = \@echo \"[34mCompiling swig[0m \$(subst .o,.cpp,\$(subst \$(CURDIR)/build,build,\$@))\"
|
||||
PRINT_SWIG_INC_LINK = \@echo \"[34mPartial linking[0m swig objects\"
|
||||
PRINT_CONVERT_SWIG = \@echo \"[34mRunning convert_swig[0m\"
|
||||
PRINT_SWIG = \@echo \"[34mSwig [0m \$(subst \$(CURDIR)/build,build,\$<)\"
|
||||
PRINT_COMPILE_SWIG = \@echo \"[34mCompiling [0m \$(subst .o,.cpp,\$(subst \$(CURDIR)/build,build,\$@))\"
|
||||
PRINT_SWIG_INC_LINK = \@echo \"[34mPartial link[0m swig objects\"
|
||||
#PRINT_CONVERT_SWIG = \@echo \"[34mRunning convert_swig[0m\"
|
||||
endif
|
||||
|
||||
SWIG_MODULE_OBJECTS = \$(LIB_DIR)/swig_python.o
|
||||
@ -245,10 +167,9 @@ SWIG_PY_OBJECTS =" ;
|
||||
print MAKEFILE "\\\n $swig_src_dir/init_swig_modules.o" ;
|
||||
print MAKEFILE "\\\n $swig_src_dir/py_top.o\n\n" ;
|
||||
|
||||
print MAKEFILE "convert_swig:\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_CONVERT_SWIG)\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\${TRICK_HOME}/\$(LIBEXEC)/trick/convert_swig \${TRICK_CONVERT_SWIG_FLAGS} S_source.hh\n" ;
|
||||
print MAKEFILE "\n\n" ;
|
||||
print MAKEFILE "\$(SWIG_PY_OBJECTS) : | trick\n" ;
|
||||
print MAKEFILE "trick :\n" ;
|
||||
print MAKEFILE "\t\@mkdir \$\@\n" ;
|
||||
|
||||
my %swig_dirs ;
|
||||
my %python_modules ;
|
||||
@ -258,18 +179,19 @@ SWIG_PY_OBJECTS =" ;
|
||||
my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ;
|
||||
my ($swig_f) = $f ;
|
||||
|
||||
if ( $$sim_ref{python_module}{$f} ne "" ) {
|
||||
#print "[31mpython module for $f = $$sim_ref{python_module}{$f}[0m\n" ;
|
||||
my ($temp_str) = $$sim_ref{python_module}{$f} ;
|
||||
$temp_str =~ s/\./\//g ;
|
||||
$swig_module_dir = "$temp_str/" ;
|
||||
$temp_str =~ $$sim_ref{python_module}{$f} ;
|
||||
$temp_str =~ s/\\/\./g ;
|
||||
push @{$python_modules{$temp_str}} , $f ;
|
||||
} else {
|
||||
$swig_module_dir = "" ;
|
||||
# TODO: Add back python modules
|
||||
# if ( $$sim_ref{python_module}{$f} ne "" ) {
|
||||
# #print "[31mpython module for $f = $$sim_ref{python_module}{$f}[0m\n" ;
|
||||
# my ($temp_str) = $$sim_ref{python_module}{$f} ;
|
||||
# $temp_str =~ s/\./\//g ;
|
||||
# $swig_module_dir = "$temp_str/" ;
|
||||
# $temp_str =~ $$sim_ref{python_module}{$f} ;
|
||||
# $temp_str =~ s/\\/\./g ;
|
||||
# push @{$python_modules{$temp_str}} , $f ;
|
||||
# } else {
|
||||
# $swig_module_dir = "" ;
|
||||
push @{$python_modules{"root"}} , $f ;
|
||||
}
|
||||
# }
|
||||
|
||||
my ($continue) = 1 ;
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
@ -285,7 +207,7 @@ SWIG_PY_OBJECTS =" ;
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
# check if .sm file was accidentally ##included instead of #included
|
||||
if ( rindex($swig_f,".sm") != -1 ) {
|
||||
trick_print($$sim_ref{fh}, "\nError: $swig_f should be in a #include not a ##include \n\n", "title_red", $$sim_ref{args}{v}) ;
|
||||
#trick_print($$sim_ref{fh}, "\nError: $swig_f should be in a #include not a ##include \n\n", "title_red", $$sim_ref{args}{v}) ;
|
||||
exit -1 ;
|
||||
}
|
||||
$swig_f =~ s/([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/$1.i/ ;
|
||||
@ -319,6 +241,7 @@ SWIG_PY_OBJECTS =" ;
|
||||
print MAKEFILE "
|
||||
\$(SWIG_MODULE_OBJECTS) : TRICK_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls
|
||||
|
||||
OBJECTS += \$(SWIG_MODULE_OBJECTS)
|
||||
\$(S_MAIN): \$(SWIG_MODULE_OBJECTS)
|
||||
|
||||
\$(SWIG_MODULE_OBJECTS) : \$(SWIG_PY_OBJECTS) | \$(LIB_DIR)
|
||||
@ -366,30 +289,21 @@ SWIG_PY_OBJECTS =" ;
|
||||
}
|
||||
close SWIGLIB ;
|
||||
|
||||
open S_INSTANCE , "build/S_instances" or return ;
|
||||
my @instances = <S_INSTANCE> ;
|
||||
close S_INSTANCE ;
|
||||
open TOPFILE , ">build/top.i" or return ;
|
||||
print TOPFILE "\%module top\n\n" ;
|
||||
print TOPFILE "\%{\n#include \"../S_source.hh\"\n\n" ;
|
||||
foreach my $inst ( @{$$sim_ref{instances}} ) {
|
||||
print TOPFILE "extern $$sim_ref{instances_type}{$inst} $inst ;\n" ;
|
||||
}
|
||||
foreach my $integ_loop ( @{$$sim_ref{integ_loop}} ) {
|
||||
print TOPFILE "extern IntegLoopSimObject $$integ_loop{name} ;" ;
|
||||
}
|
||||
|
||||
print TOPFILE @instances ;
|
||||
print TOPFILE "\n\%}\n\n" ;
|
||||
print TOPFILE "\%import \"build$wd/S_source.i\"\n\n" ;
|
||||
foreach my $inst ( @{$$sim_ref{instances}} ) {
|
||||
print TOPFILE "$$sim_ref{instances_type}{$inst} $inst ;\n" ;
|
||||
}
|
||||
foreach my $integ_loop ( @{$$sim_ref{integ_loop}} ) {
|
||||
print TOPFILE "IntegLoopSimObject $$integ_loop{name} ;" ;
|
||||
}
|
||||
print TOPFILE @instances ;
|
||||
close TOPFILE ;
|
||||
|
||||
open INITSWIGFILE , ">build/init_swig_modules.cpp" or return ;
|
||||
print INITSWIGFILE "extern \"C\" {\n\n" ;
|
||||
foreach $f ( @temp_array2 ) {
|
||||
|
||||
my $md5_sum = md5_hex($f) ;
|
||||
print INITSWIGFILE "void init_m${md5_sum}(void) ; /* $f */\n" ;
|
||||
}
|
||||
@ -416,6 +330,9 @@ SWIG_PY_OBJECTS =" ;
|
||||
print INITSWIGFILE " return ;\n}\n\n}\n" ;
|
||||
close INITSWIGFILE ;
|
||||
|
||||
if ( ! -e "trick") {
|
||||
mkdir "trick" ;
|
||||
}
|
||||
open INITFILE , ">trick/__init__.py" or return ;
|
||||
|
||||
print INITFILE "import sys\n" ;
|
||||
@ -494,9 +411,16 @@ SWIG_PY_OBJECTS =" ;
|
||||
}
|
||||
}
|
||||
|
||||
return ;
|
||||
open MAKEFILECONV , ">build/Makefile_convert_swig" or return ;
|
||||
print MAKEFILECONV "\$(CURDIR)/build/convert_swig_last_run :" ;
|
||||
foreach $f ( @temp_array2 ) {
|
||||
print MAKEFILECONV " \\\n $f" ;
|
||||
}
|
||||
close MAKEFILECONV ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
get_exclude_dirs() ;
|
||||
read_files_to_process() ;
|
||||
make_swig_makefile() ;
|
@ -1,57 +0,0 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# Usage: mis_dep <src file>
|
||||
#
|
||||
# Description: Given a source file, this program will find all library
|
||||
# dependencies that this source file's object will depend on.
|
||||
# The dependency tree is built using the library dependencies
|
||||
# from the TRICK HEADERs in the source files. TRICK_CFLAGS
|
||||
# are used to actually find all files in the dependency tree.
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use Cwd ;
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use mis_dep ;
|
||||
|
||||
my ($all_mis_depends, %rcs_tags) ;
|
||||
my ($k , $a) ;
|
||||
my @all_depends ;
|
||||
my %temp_hash ;
|
||||
my $wd ;
|
||||
|
||||
# prepend current dir name if none given
|
||||
$wd = cwd() ;
|
||||
foreach (@ARGV) {
|
||||
$_ = $wd . "/" . $_ if ( !/^\// ) ;
|
||||
}
|
||||
|
||||
$all_mis_depends = mis_dep(\%rcs_tags , @ARGV) ;
|
||||
|
||||
print "\n" ;
|
||||
foreach $a ( sort keys %$all_mis_depends ) {
|
||||
traverse_tree($a, 0, %{$$all_mis_depends{$a}} );
|
||||
print "\n" ;
|
||||
}
|
||||
|
||||
foreach $a ( sort keys %$all_mis_depends ) {
|
||||
|
||||
print "[32m$a[00m\n";
|
||||
@all_depends = () ;
|
||||
|
||||
# push all depends for all files onto one array
|
||||
foreach $k ( sort keys %{$$all_mis_depends{$a}} ) {
|
||||
if ( $k ne "last_look" ) {
|
||||
push @all_depends , @{$$all_mis_depends{$a}{$k}} ;
|
||||
}
|
||||
}
|
||||
|
||||
# remove duplicate elements
|
||||
%temp_hash = {};
|
||||
@all_depends = grep ++$temp_hash{$_} < 2, @all_depends ;
|
||||
|
||||
foreach $k ( sort @all_depends ) {
|
||||
print "[33m $k[00m\n";
|
||||
}
|
||||
}
|
@ -1,456 +0,0 @@
|
||||
package ICG ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
use vars qw($arg_lang);
|
||||
@EXPORT = qw(ICG);
|
||||
|
||||
use File::Basename ;
|
||||
use Text::Balanced qw ( extract_bracketed );
|
||||
use Cwd ;
|
||||
use strict ;
|
||||
use gte ;
|
||||
use MIS ;
|
||||
use html ;
|
||||
use trick_print ;
|
||||
use trick_version ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
##############################################################################
|
||||
# Important Hashes
|
||||
##############################################################################
|
||||
#
|
||||
# VALID-TYPES HASH
|
||||
# Key Value
|
||||
# <type-specifier> Ref to TYPE-INFO HASH
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# TYPE-INFO HASH
|
||||
# Key Value
|
||||
# value Trick parameter type as defined in parameter_types.h
|
||||
# Examples: "TRICK_CHARACTER", "TRICK_INTEGER", etc.
|
||||
# name C/C++ type specifier.
|
||||
# Examples: "char", "int", etc.
|
||||
# intrinsic 0= User-defined type. 1= Intrinsic type.
|
||||
# class Parent class.
|
||||
# file File where this type was declared.
|
||||
# typedef 0 or 1. Whether declaration starts with struct or union.
|
||||
# inherit_class @ of strings that name the classes from which this class is inherits.
|
||||
# virtual Whether this class inherits virtually.
|
||||
# abstract Whether this class is abstract (and therefore cannot be instantiated). 0=no, 1=yes.
|
||||
# def_construct 0 or 1. Indicates whether we should create an io_src_allocate_ routine.
|
||||
|
||||
##############################################################################
|
||||
# Global Variables
|
||||
##############################################################################
|
||||
|
||||
# Variable: $top_file
|
||||
# Description:
|
||||
my $top_file ;
|
||||
|
||||
# Variable: all_icg_depends_ref
|
||||
# Description:
|
||||
|
||||
my ( $all_icg_depends_ref ) ;
|
||||
|
||||
my $verbose ;
|
||||
my %header ;
|
||||
my $indent = 3 ;
|
||||
my %already_processed ;
|
||||
|
||||
my @file_levels ;
|
||||
|
||||
################################################################################
|
||||
# SUBROUTINE: ICG
|
||||
#
|
||||
# DESCRIPTION: FIXME
|
||||
#
|
||||
# PARAMETERS:
|
||||
# temp_h_files array of strings representing the names of header files to be processed.
|
||||
# operation scalar string that indicates what ICG is supposed to do.
|
||||
# Recognized values are "full", "CP", "sim_services", "single", "s_source", "tree".
|
||||
# user_defs array of strings (e.g.: "-DFOO" representing user defines.
|
||||
# sim_ref Reference to global SIM-HASH.
|
||||
#
|
||||
# RETURNS: FIXME
|
||||
################################################################################
|
||||
sub ICG(\@$$$) {
|
||||
|
||||
my ($temp_h_files , $operation, $user_defs, $sim_ref) = @_ ;
|
||||
my @h_files ;
|
||||
my $wd ;
|
||||
my $path_dir ;
|
||||
my @include_paths ;
|
||||
my @defines ;
|
||||
my $curr_file ;
|
||||
my (@file_stack , %file_contents ) ;
|
||||
my ($f) ;
|
||||
my $file_path_dir ;
|
||||
my @inc_paths ;
|
||||
my @file_order ;
|
||||
my %tree ;
|
||||
my @icg_exclude_dirs ;
|
||||
my ($version, $thread, $year) ;
|
||||
my $cc ;
|
||||
|
||||
@h_files = @$temp_h_files ;
|
||||
|
||||
# used by make_makefile
|
||||
$all_icg_depends_ref = \%{$$sim_ref{all_icg_depends}} ;
|
||||
|
||||
$wd = cwd();
|
||||
$path_dir = dirname($wd) ;
|
||||
if ($path_dir eq ".") {
|
||||
$path_dir = cwd();
|
||||
}
|
||||
|
||||
($version, $thread) = get_trick_version() ;
|
||||
($year) = $version =~ /^(\d+)/ ;
|
||||
|
||||
($cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
@include_paths = $ENV{"TRICK_CFLAGS"} =~ /(-I\s*\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @include_paths , ("-I" . $ENV{"TRICK_HOME"} . "/trick_source" , "-I../include") ;
|
||||
@defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ; # get defines from TRICK_CFLAGS
|
||||
if ( $ENV{"TRICK_CFLAGS"} !~ /DTRICK_VER=/ ) {
|
||||
push @defines , "-DTRICK_VER=$year" ;
|
||||
}
|
||||
push @defines , "-DTRICK_ICG" ;
|
||||
|
||||
# Break up the $TRICK_ICG_EXCLUDE string based on some delimiter (colon).
|
||||
# In an array context, split returns a list of the things that were found.
|
||||
@icg_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"};
|
||||
# See if there are any elements in the icg_exclude_dirs array
|
||||
if (scalar @icg_exclude_dirs) {
|
||||
@icg_exclude_dirs = sort(@icg_exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@icg_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @icg_exclude_dirs ;
|
||||
while ( not length @icg_exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @icg_exclude_dirs ;
|
||||
}
|
||||
@icg_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @icg_exclude_dirs ;
|
||||
}
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
# Get only the include paths that exist
|
||||
my @valid_inc_paths ;
|
||||
foreach (@inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@inc_paths = @valid_inc_paths ;
|
||||
|
||||
# return if no header files are to be processed
|
||||
if (scalar @h_files == 0) {
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
open SLIB , "build/icg_no_found" ;
|
||||
while ( <SLIB> ) {
|
||||
chomp ;
|
||||
$$sim_ref{icg_no}{$_} = 1 ;
|
||||
}
|
||||
|
||||
while (@h_files) {
|
||||
|
||||
my %temp_hash ;
|
||||
my $cc_inc ;
|
||||
my $curr_dir ;
|
||||
|
||||
#Clear out variables for new file
|
||||
undef %file_contents ;
|
||||
undef @file_stack ;
|
||||
undef @file_levels ;
|
||||
undef @file_order ;
|
||||
|
||||
$curr_file = shift @h_files ;
|
||||
|
||||
#get the absolute path to this header file... use this from now on.
|
||||
$curr_file = abs_path(dirname($curr_file)) . "/" . basename($curr_file) ;
|
||||
$top_file = $curr_file ;
|
||||
$curr_dir = dirname($curr_file) ;
|
||||
|
||||
if ( $operation ne "treedep" and $operation ne "single" ) {
|
||||
trick_print($$sim_ref{fh}, "ICG $curr_file\n\n" , "normal_cyan" , $$sim_ref{args}{v}) ;
|
||||
}
|
||||
|
||||
open FILE, "$curr_file" or die "Couldn't find file: $curr_file\n";
|
||||
|
||||
# Use the C preprocessor to get all of the include dependencies for the current file
|
||||
# This way we can properly take care of #defines with h files
|
||||
# When you open a filehandle (FILE) that's already open, Perl
|
||||
# implicitly closes it first.
|
||||
if ( $curr_file =~ /\.h$/ ) {
|
||||
open FILE, "cd $curr_dir ; $cc -E -C @include_paths @defines @$user_defs $curr_file |" ;
|
||||
}
|
||||
elsif ( $curr_file =~ /(\.hh|\.H|\.h\+\+|\.hxx)$/ ) {
|
||||
open FILE, "cd $curr_dir ; $cc -E -C -x c++ @include_paths $cc_inc @defines @$user_defs $curr_file |" ;
|
||||
}
|
||||
else {
|
||||
open FILE, "cd $curr_dir ; $cc -E -C -x c @include_paths $cc_inc @defines @$user_defs $curr_file |" ;
|
||||
}
|
||||
|
||||
# read the result of the preprocessor and separate the output to individual files
|
||||
while ( <FILE> ) {
|
||||
# change file we are in to include dependencies
|
||||
if ( /^#(\s*line)?\s*\d+\s*"(.*?)"/ ) {
|
||||
$curr_file = $2 ;
|
||||
$curr_file =~ s/\/(\/)+/\//g ;
|
||||
|
||||
# Replace directories that are symbolic links
|
||||
# with real/absolute paths. Also substitute out
|
||||
# /dir_a/dir_b/../file.c with /dir_a/file.c
|
||||
$curr_file = abs_path(dirname($curr_file)) . "/" . basename($curr_file) ;
|
||||
|
||||
if ($curr_file !~ /^\/usr\/include/ and
|
||||
$curr_file !~ /^\/usr\/lib/ and
|
||||
($curr_file =~ /^\/usr\/local\/trick/ # Trick install PREFIX
|
||||
or $curr_file !~ /^\/usr\/local/) and
|
||||
$curr_file !~ /^\/usr\/X11/ and
|
||||
$curr_file !~ /gcc-lib/ and
|
||||
$curr_file !~ /^\/Developer/ and
|
||||
$curr_file !~ /^\/Library\/Developer/ and
|
||||
$curr_file !~ /^\/Applications\/Xcode.app/ and
|
||||
$curr_file !~ /^\/usr\/llvm-gcc-4.2/ and
|
||||
$curr_file !~ /opt\/sfw/ and
|
||||
$curr_file !~ /<built-in>/ and
|
||||
$curr_file !~ /^\/usr\/qnx.*?\/target/ and
|
||||
$curr_file !~ /<command.line>/) {
|
||||
|
||||
# keep a record of the order the files were visited
|
||||
push @file_order , $curr_file ;
|
||||
}
|
||||
}
|
||||
|
||||
# add line to file we are in
|
||||
if ($curr_file !~ /^\/usr\/include/ and $curr_file !~ /^\/usr\/lib/ and
|
||||
$curr_file !~ /^\/usr\/X11/ and $curr_file !~ /gcc-lib/ ) {
|
||||
# string concatenate
|
||||
$file_contents{$curr_file} .= "$_" ;
|
||||
}
|
||||
}
|
||||
|
||||
# Convert the flat file output from cc to a tree dependency hash
|
||||
foreach $f ( @file_order ) {
|
||||
# skip c++ .i files
|
||||
next if ( $f =~ /\.i$/ ) ;
|
||||
|
||||
# Use absolute path
|
||||
if ( $f =~ /^\// ) {
|
||||
my $old_f = $f ;
|
||||
$f = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
if ( ! exists $file_contents{$f} ) {
|
||||
$file_contents{$f} = $file_contents{$old_f} ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
my $old_f = $f ;
|
||||
$f = abs_path(dirname("$curr_dir/$f")) . "/" . basename($f) ;
|
||||
if ( ! exists $file_contents{$f} ) {
|
||||
$file_contents{$f} = $file_contents{$old_f} ;
|
||||
}
|
||||
}
|
||||
|
||||
if (! defined $file_stack[$#file_stack] or $f ne $file_stack[$#file_stack]) {
|
||||
# if file name is equal to previous file on stack pop up to that file
|
||||
if ($#file_stack ge 1 and $file_stack[$#file_stack - 1] eq $f) {
|
||||
pop @file_stack ;
|
||||
}
|
||||
else {
|
||||
# make sure this is not the top level file
|
||||
if ( $#file_stack ge 0 ) {
|
||||
# if file name does not exist in it's parent's list add it
|
||||
my $temp_f = quotemeta $f ;
|
||||
if ( !(grep /$temp_f/, @{$$all_icg_depends_ref{$top_file}{$file_stack[$#file_stack]}}) ) {
|
||||
push @{$$all_icg_depends_ref{$top_file}{$file_stack[$#file_stack]}} , $f ;
|
||||
}
|
||||
# if there is no entry yet for this file make one
|
||||
if (!exists $$all_icg_depends_ref{$top_file}{$f}) {
|
||||
@{$$all_icg_depends_ref{$top_file}{$f}} = () ;
|
||||
}
|
||||
}
|
||||
# push this file name onto the stack
|
||||
push @file_stack, $f ;
|
||||
$tree{$f} = 1 ;
|
||||
if ($operation eq "tree" ) {
|
||||
print $$sim_ref{fh}, " " x ($#file_stack * 3) . $f . "\n" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# if ICG was called with the -tree option exit here.
|
||||
return %tree if ($operation eq "tree" or $operation eq "treedep" ) ;
|
||||
|
||||
# Get the realpath of all the files we read in from the C preprocessor
|
||||
foreach $f ( keys %file_contents ) {
|
||||
my $new_name = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
if ( $new_name ne $f and !exists $file_contents{$new_name} ) {
|
||||
$file_contents{$new_name} = $file_contents{$f};
|
||||
}
|
||||
}
|
||||
|
||||
my %all_file_names ;
|
||||
@file_levels = traverse_tree_to_file_levels($top_file, \%all_file_names , \%{$$all_icg_depends_ref{$top_file}} ) ;
|
||||
|
||||
foreach $f (@file_levels) {
|
||||
|
||||
my @structs_info ;
|
||||
my @enums_info ;
|
||||
my $continue ;
|
||||
|
||||
# skip file if already processed this invocation of ICG
|
||||
if ( exists $already_processed{$f} ) {
|
||||
next ;
|
||||
}
|
||||
$already_processed{$f} = 1 ;
|
||||
|
||||
if ( $f =~ /\.C$|\.cc$|\.cxx$|\.cpp$|\.c\+\+$/ ) {
|
||||
next ;
|
||||
}
|
||||
elsif ( $f =~ /\.c$/ ) {
|
||||
# MIS
|
||||
mis_c($f , $file_contents{$f} , $sim_ref) ;
|
||||
next ;
|
||||
}
|
||||
elsif ( $f =~ /\.i$/ ) {
|
||||
next ;
|
||||
}
|
||||
|
||||
$continue = 1 ;
|
||||
foreach my $ie ( @icg_exclude_dirs ) {
|
||||
# if file location begins with $ie (an IGC exclude dir)
|
||||
my $dum = $f ;
|
||||
if ( $dum =~ s/^\Q$ie// ) {
|
||||
if ( $dum =~ /^\// ) {
|
||||
trick_print($$sim_ref{fh}, "ICG skipping $f (ICG exclude dir $ie)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
$continue = 0 ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
next if ( $continue == 0 ) ;
|
||||
|
||||
if ( exists $$sim_ref{icg_no}{$f} ) {
|
||||
trick_print($$sim_ref{fh}, "ICG skipping $f (ICG No found)\n" , "normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
next ;
|
||||
}
|
||||
|
||||
$file_path_dir = dirname($f) ;
|
||||
if ($file_path_dir eq ".") {
|
||||
$file_path_dir = cwd();
|
||||
}
|
||||
$file_path_dir =~ s/\/+$// ; # remove trailing slash
|
||||
$file_path_dir =~ s/\/include$// ;
|
||||
|
||||
# extract the Trick header
|
||||
%header = extract_trick_header( $f, $file_contents{$f}, $verbose , $indent );
|
||||
|
||||
$$sim_ref{python_module}{$f} = $header{python_module} ;
|
||||
$$sim_ref{python_module}{$f} =~ s/\(|\)|\s+//g ;
|
||||
|
||||
if ( $operation eq "CP" ) {
|
||||
|
||||
next if ( $f =~ /$ENV{TRICK_HOME}\/include/) ;
|
||||
next if ( $f =~ /$ENV{TRICK_HOME}\/trick_source/) ;
|
||||
|
||||
trick_print($$sim_ref{fh}, "Getting dependencies for $f\n" , "normal_white" , $$sim_ref{args}{v});
|
||||
|
||||
delete $$sim_ref{head_deps}{$f} ;
|
||||
|
||||
# add any external dependencies from an .exd file
|
||||
my ($exd_file_name) = $f ;
|
||||
my @exd_file_list ;
|
||||
undef @exd_file_list ;
|
||||
$exd_file_name =~ s/\.[^\/]*$/\.exd/ ;
|
||||
if ( open EXD , "$exd_file_name" ) {
|
||||
while ( <EXD> ) {
|
||||
push @exd_file_list , $_ if ( /\.o\s*$/ and !/^\s*#/ ) ;
|
||||
}
|
||||
chomp @exd_file_list ;
|
||||
}
|
||||
|
||||
# we have library dependencies in an h file. ( possible for c++ )
|
||||
if (exists $header{libdep} or (scalar @exd_file_list != 0) ) {
|
||||
my @lib_list = split /\)[ \t\n\r\*]*\(/ , $header{libdep} ;
|
||||
push @lib_list , @exd_file_list ;
|
||||
foreach my $l (@lib_list) {
|
||||
my $found = 0 ;
|
||||
$l =~ s/\(|\)|\s+//g ;
|
||||
$l =~ s/\${(.+?)}/$ENV{$1}/eg ;
|
||||
next if ( $l eq "" ) ;
|
||||
|
||||
if ( $l !~ /\.o$/ ) {
|
||||
foreach my $inc ( dirname($f) , @inc_paths) {
|
||||
if ( -e "$inc/$l" ) {
|
||||
#print "found $inc/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/$l")) . "/" . basename("$inc/$l") ;
|
||||
push @{$$sim_ref{mis_entry_files}} , $f ;
|
||||
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$l =~ s/o$// ;
|
||||
foreach my $inc ( $file_path_dir , @inc_paths) {
|
||||
foreach my $ext ( "cpp" , "cc" , "c" , "c++" , "cxx" , "C" ) {
|
||||
if ( -e "$inc/$l$ext" ) {
|
||||
#print "found $inc/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/$l$ext")) . "/" . basename("$inc/$l$ext") ;
|
||||
push @{$$sim_ref{mis_entry_files}} , $f ;
|
||||
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
elsif ( -e "$inc/src/$l$ext" ) {
|
||||
#print "found $inc/src/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/src/$l$ext")) . "/" . basename("$inc/src/$l$ext") ;
|
||||
push @{$$sim_ref{mis_entry_files}} , $f ;
|
||||
push @{$$sim_ref{head_deps}{$f}{files}} , $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
last if ( $found == 1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $found == 0 ) {
|
||||
trick_print($$sim_ref{fh}, "$f: Warning: Could not find dependency $l" . "o\n" ,
|
||||
"normal_yellow" , $$sim_ref{args}{v}) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
next ;
|
||||
}
|
||||
|
||||
} # End of foreach on filelevel
|
||||
|
||||
} # End of gigantic while loop
|
||||
|
||||
return 0 ;
|
||||
|
||||
} # end of ICG
|
||||
|
||||
sub traverse_tree_to_file_levels($$$$$) {
|
||||
my ($file, $all_file_names_ref , $curr_tree ) = @_ ;
|
||||
my $a ;
|
||||
my @lower_levels ;
|
||||
my $io_src_file ;
|
||||
my ($ret_stat , @ret_files) ;
|
||||
my $ret ;
|
||||
|
||||
foreach $a ( @{$$curr_tree{$file}} ) {
|
||||
if ( ($a ne $file) and !(exists $$all_file_names_ref{$a}) ) {
|
||||
$$all_file_names_ref{$a} = 1 ;
|
||||
( @ret_files ) = &traverse_tree_to_file_levels($a, $all_file_names_ref , $curr_tree ) ;
|
||||
push @lower_levels , @ret_files ;
|
||||
|
||||
}
|
||||
}
|
||||
$$all_file_names_ref{$file} = 1 ;
|
||||
return ( @lower_levels , $file ) ;
|
||||
}
|
||||
|
||||
1;
|
@ -1,290 +0,0 @@
|
||||
package MIS ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(mis_c mis_all_c process_args);
|
||||
|
||||
use strict ;
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use File::Basename ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path' ;
|
||||
use html ;
|
||||
use mis_dep ;
|
||||
use trick_print ;
|
||||
use auto_doc ;
|
||||
|
||||
my @includes ;
|
||||
my %this_dir ;
|
||||
my $rel_path_curr_file ;
|
||||
my @files_to_mis_dep ;
|
||||
my @class_names = qw( initialization restart derivative
|
||||
integration dynamic_event post_integration
|
||||
automatic environment asynchronous_mustfinish asynchronous
|
||||
random sensor sensor_emitter sensor_reflector
|
||||
sensor_receiver scheduled effector effector_emitter
|
||||
effector_receiver automatic_last malfunction
|
||||
malfunction_trigger logging shutdown freeze_init freeze
|
||||
unfreeze checkpoint pre_load_checkpoint
|
||||
monte_master_init monte_master_pre
|
||||
monte_master_post monte_master_shutdown
|
||||
monte_slave_init monte_slave_pre
|
||||
monte_slave_post monte_slave_shutdown
|
||||
N/A) ;
|
||||
|
||||
sub mis_all_c($$) {
|
||||
my ( $all_src_files_ref , $sim_ref ) = @_ ;
|
||||
my ( @all_lines , $contents ) ;
|
||||
my ( $file_path_dir , $xml_file ) ;
|
||||
my ( $name , $path ) ;
|
||||
my ( $xml_time , $src_time ) ;
|
||||
|
||||
foreach my $f ( @$all_src_files_ref ) {
|
||||
# determine the xml file name
|
||||
$file_path_dir = dirname($f) ;
|
||||
($name, $path) = fileparse($f, ("h" , "c" , "f", "cpp" , "cxx" , "C" , "cc" , "c\\+\\+" ));
|
||||
$file_path_dir =~ s/\/src$// ;
|
||||
$xml_file = $file_path_dir . "/xml/" . $name . "xml" ;
|
||||
|
||||
# skip this file if the xml file is newer than the source file
|
||||
if ( -e $xml_file ) {
|
||||
$xml_time = (stat $xml_file)[9] ;
|
||||
$src_time = (stat $f)[9] ;
|
||||
next if ( $xml_time > $src_time ) ;
|
||||
}
|
||||
|
||||
# read in the file and MIS parse it
|
||||
open FILE , "$f" ;
|
||||
@all_lines = <FILE> ;
|
||||
$contents = join "" , @all_lines ;
|
||||
mis_c( $f , $contents , $sim_ref ) ;
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
sub mis_c($$$) {
|
||||
|
||||
my ($curr_file , $contents, $sim_ref) = @_ ;
|
||||
my ($object_file , @entry_names);
|
||||
my (@comments , @entries ) ;
|
||||
my ($num_valid_entries ,$num_args_left) ;
|
||||
my @all_lines ;
|
||||
my $nm ;
|
||||
my %header ;
|
||||
my $i ;
|
||||
my $entry ;
|
||||
my @split_args ;
|
||||
my $language ;
|
||||
|
||||
trick_print($$sim_ref{fh}, " Processing $curr_file\n", "debug_cyan" , $$sim_ref{args}{v}) ;
|
||||
|
||||
($object_file = $curr_file) =~ s/(?:src\/)?(\w+)\.c$/object_$ENV{"TRICK_HOST_CPU"}\/$1.o/ ;
|
||||
|
||||
($rel_path_curr_file) = $curr_file =~ /([^\/]+)$/ ;
|
||||
|
||||
%header = extract_trick_header($curr_file , $contents , $sim_ref , 0 );
|
||||
|
||||
if ( exists $header{language} ) {
|
||||
# if the language specified is c++ cpp cxx c<something> then set the language as cpp
|
||||
if ( $header{language} =~ /c[\w\+]+/i ) {
|
||||
$language = "CPP" ;
|
||||
}
|
||||
else {
|
||||
$language = "C" ;
|
||||
}
|
||||
}
|
||||
elsif ($curr_file =~ /\.c$/ ) {
|
||||
# else if the current file ends in .c set the language to c
|
||||
$language = "C" ;
|
||||
}
|
||||
else {
|
||||
# all other extensions are cpp
|
||||
$language = "CPP" ;
|
||||
}
|
||||
|
||||
#Pull out comments
|
||||
$i = 0;
|
||||
while ($contents =~ /(?:\/\*(.*?)\*\/)|(?:\/\/(.*?)\n)/sg) {
|
||||
push @comments , $+ ;
|
||||
}
|
||||
$contents =~ s/\/\*(.*?)\*\/|\/\/(.*?)(\n)/" " . $i++ . " " . $3/esg ;
|
||||
|
||||
@includes = $contents =~ /(#include\s*["<][^">]+[">])/g ;
|
||||
|
||||
# The next loop finds all of the function entry points in the file.
|
||||
while ( $contents =~ /
|
||||
(?:(auto|register|static|extern)\s+)? # optional keywords = $1
|
||||
(?:(enum|class|struct|const|volatile|signed|unsigned|long|unsigned\s+long)\s+)? # optional keywords = $2
|
||||
(\#?[A-Za-z]\w*|(?:[A-Za-z]\w*\s*<\s+[A-Za-z]\w*\s+>)) # type name = $3
|
||||
([\*\s]+) # pointers or spaces = $4 (at least 1 space or pointer)
|
||||
(\w[\:\-\w]*)\s* # function name = $5
|
||||
\(\s* # open paren
|
||||
([^)]*) # everything to close paren = $6
|
||||
\) # close paren
|
||||
\s*(\d+)?\s* # optional comment = $7
|
||||
(?:(const|volatile)\s+)?\s* # optional const|volatile = $8
|
||||
(throw\s*\(.*?\))?\s* # optional throw
|
||||
(?:\d+\s*)* # extra comments discarded
|
||||
{ # open brace , balance }
|
||||
/sgx ) {
|
||||
|
||||
|
||||
my $return_type = $1 ;
|
||||
$return_type .= ( $return_type eq "" ) ? $2 : " $2" ;
|
||||
$return_type .= ( $return_type eq "" ) ? $3 : " $3" ;
|
||||
my $pointers = $4 ;
|
||||
if ( $pointers ne "" ) {
|
||||
$pointers =~ s/(^\s+|\s+$)//g ;# remove leading & trailing whitespaces
|
||||
$pointers = " $pointers" ;
|
||||
}
|
||||
$return_type .= $pointers ;
|
||||
my $name = $5 ;
|
||||
my $raw_args = $6 ;
|
||||
$raw_args .= " $7" if ( $7 ne "" ) ;
|
||||
|
||||
# skip this entry point because it's actulally a macro
|
||||
next if ( $return_type =~ /\#/ ) ;
|
||||
|
||||
if ( $name eq "if" or $name eq "for" or
|
||||
$name eq "while" or $name eq "switch" or
|
||||
$name eq "do" or $name =~ /operator[^\w]/ ) {
|
||||
next ;
|
||||
}
|
||||
else {
|
||||
push @entries , { 'return_type' => $return_type ,
|
||||
'name' => $name ,
|
||||
'file_name' => $curr_file ,
|
||||
'raw_args' => $raw_args ,
|
||||
'language' => $language } ;
|
||||
}
|
||||
}
|
||||
|
||||
$num_valid_entries = 0 ;
|
||||
|
||||
foreach $entry (@entries) {
|
||||
trick_print($$sim_ref{fh}, " Processing $$entry{name}\n" , "debug_cyan" , $$sim_ref{args}{v}) ;
|
||||
if ( process_args ($entry, \@comments, 6 , $sim_ref) == 0 ) {
|
||||
add_proto_to_cat( $entry , $sim_ref , 6 ) ;
|
||||
$num_valid_entries++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $num_valid_entries eq 0 ) {
|
||||
trick_print($$sim_ref{fh}, " WARNING: No entry points found\n", "debug_yellow" , $$sim_ref{args}{v});
|
||||
}
|
||||
else {
|
||||
print_xml_mis($curr_file , \@entries , \%header, \@includes) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub process_args($$$$) {
|
||||
|
||||
my ($entry, $comments, $indent , $sim_ref) = @_ ;
|
||||
my ($entry_comment , $hdr_comment ) ;
|
||||
my @arg_list ;
|
||||
|
||||
$hdr_comment = -1 ;
|
||||
|
||||
$$entry{valid} = 0 ;
|
||||
|
||||
# clear out leading spaces
|
||||
$$entry{raw_args} =~ s/^\s+//s ;
|
||||
|
||||
$$entry{raw_args} =~ s/\s+(\*+)/$1 /g ;
|
||||
if ($$entry{raw_args} =~ s/^\s*(\d+)\s*//s ) {
|
||||
$entry_comment = $1 ;
|
||||
$hdr_comment = $entry_comment - 1 ;
|
||||
($$entry{units} , $$entry{desc}) =
|
||||
@$comments[$entry_comment] =~ /\s*RETURN:\s*(?:((?:[-*\/\w^|\.]+)|(?:\(.*?\))))\s+\s*(.*)/six ;
|
||||
}
|
||||
else {
|
||||
$$entry{units} = "--" ;
|
||||
$$entry{desc} = "Not Specified" ;
|
||||
}
|
||||
$$entry{raw_args} =~ s/^\s*void\s*$// ;
|
||||
|
||||
$$entry{class} = "" ;
|
||||
while ( $$entry{class} eq "" and $hdr_comment >= 0 ) {
|
||||
($$entry{class}) = @$comments[$hdr_comment] =~ /CLASS:.*?\(\s*([\w\/]+)/si ;
|
||||
$hdr_comment -= 1 ;
|
||||
}
|
||||
if ( !(grep /^$$entry{class}$/ , @class_names )) {
|
||||
$$entry{class} = "N/A" ;
|
||||
}
|
||||
|
||||
my $arg_count = 1 ;
|
||||
while ( $$entry{raw_args} =~ s/^(?:
|
||||
(?:
|
||||
((?:(?:enum|class|struct|const|volatile|signed|unsigned|long|unsigned\s+long)\s+)?.*?) # argument type = $1
|
||||
(<.*?>)?\s* # c++ template = $2
|
||||
(\**)\s+ # argument pointers = $3
|
||||
(?:(const)\s+)?\s* # c++ const keyword = $4
|
||||
(\&)?\s* # c++ reference symbol = $5
|
||||
(\w+)?\s* # name (optional in c++ method decl.) = $6
|
||||
(\[[^,=]*\])?\s* # optional array specs = $7
|
||||
(\s*=\s*[\w\.]+)?[\s,]* # optional default value = $8
|
||||
)
|
||||
|
|
||||
(\.\.\.)\s* # variable argument spec = $9
|
||||
)
|
||||
(\d+)?\s* # in|inout|out comment = $10
|
||||
(?:\d+\s*)* # optional extra comments discarded
|
||||
//six ) {
|
||||
my %func_arg ;
|
||||
my $comment_index ;
|
||||
|
||||
$func_arg{type} = $1 ;
|
||||
$func_arg{cpp_template} = ( $2 ne "" ) ? $2 : "" ;
|
||||
$func_arg{pointers} = ( $3 ne "" ) ? $3 : "" ;
|
||||
$func_arg{cpp_const} = $4 ;
|
||||
$func_arg{cpp_ref} = $5 ;
|
||||
|
||||
$func_arg{name} = ( $6 ne "" ) ? $6 : "" ;
|
||||
$func_arg{array} = ( $7 ne "" ) ? $7 : "" ;
|
||||
$func_arg{optional} = ( $8 ne "" ) ? 1 : 0 ;
|
||||
$func_arg{type} = $9 if ( $9 ne "" ) ;
|
||||
$comment_index = $10 ;
|
||||
|
||||
if ( $comment_index ne "" ) {
|
||||
($func_arg{comment} = @$comments[$comment_index]) =~ s/(IN|INOUT|OUT):\s*// ;
|
||||
( $func_arg{inout} , $func_arg{unit} , $func_arg{desc} ) =
|
||||
@$comments[$comment_index] =~ /^\s*(?:(IN|INOUT|OUT):)?\s*
|
||||
(?:((?:[-*\/\w^|\.]+)|(?:\(.*?\))))\s+
|
||||
\s*(.*)
|
||||
/six ;
|
||||
}
|
||||
else {
|
||||
$func_arg{comment} = "-- Not specified" ;
|
||||
$func_arg{inout} = "" ;
|
||||
$func_arg{unit} = "--" ;
|
||||
$func_arg{desc} = "Not specified" ;
|
||||
}
|
||||
|
||||
trick_print($$sim_ref{fh}, " "x($indent+3) . "Arg $arg_count\n" , "debug_white" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, " "x($indent+6) . "type = $func_arg{type} $func_arg{pointers} $func_arg{array}\n" ,
|
||||
"debug_white" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, " "x($indent+6) . "name = $func_arg{name}\n" , "debug_white" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, " "x($indent+6) . "comm = $func_arg{comment}\n" , "debug_white" , $$sim_ref{args}{v} ) ;
|
||||
$arg_count++ ;
|
||||
|
||||
push @arg_list , \%func_arg ;
|
||||
}
|
||||
|
||||
if ( $$entry{raw_args} ne "" ) {
|
||||
trick_print($$sim_ref{fh}, "Could not process argument for $entry->{name}\n" , "title_red" , $$sim_ref{args}{v} ) ;
|
||||
trick_print($$sim_ref{fh}, "Last Read:\n$entry->{args_list}\n" , "title_red" , $$sim_ref{args}{v} ) ;
|
||||
return -1 ;
|
||||
}
|
||||
else {
|
||||
|
||||
# set the values to return
|
||||
$$entry{valid} = 1 ;
|
||||
@{$$entry{arg_list}} = @arg_list ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
||||
1;
|
@ -1,412 +0,0 @@
|
||||
package auto_doc;
|
||||
|
||||
# Note:
|
||||
# Firefox 3 fails to process XSLT files if they are on the local hard drive plus
|
||||
# outside of the current XML file's path (or descendant paths). Users may need
|
||||
# to edit $HOME/.mozilla/firefox/*.default/prefs.js and add a new URI setting:
|
||||
# - user_pref("security.fileuri.strict_origin_policy", false);
|
||||
# OR
|
||||
# - type about:config in the address bar
|
||||
# - change security.fileuri.strict_origin_policy to false
|
||||
|
||||
use Exporter();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(print_xml_CP print_xml_mis print_xml_icg);
|
||||
|
||||
use File::Basename;
|
||||
use Text::Balanced qw ( extract_bracketed );
|
||||
use strict;
|
||||
use gte;
|
||||
|
||||
my(%default_data_files, %object_jobs, @object_names, %jobs, %object_structs, $vt_ref);
|
||||
|
||||
sub print_xml_CP($)
|
||||
{
|
||||
my($sim_ref) = @_;
|
||||
my $title;
|
||||
|
||||
# Get the title of the sim from the file "Title"
|
||||
if (open TITLE, "Title") {
|
||||
$title = <TITLE>;
|
||||
chomp $title;
|
||||
} else {
|
||||
$title = "No Title Specified";
|
||||
}
|
||||
|
||||
open XML_FILE, ">S_document.xml" or die "Could not open S_document.xml\n";
|
||||
|
||||
# Start the xml code
|
||||
print_xml_xml_header("$ENV{TRICK_HOME}/docs/trick_s_define.xsl");
|
||||
print XML_FILE "<s_define>\n";
|
||||
print XML_FILE " " x 4, "<title>$title</title>\n";
|
||||
|
||||
# Given an array of simulation objects, sort array by 'objname' values
|
||||
# foreach my $o (sort { ${$a}{objname} cmp ${$b}{objname} } @{$$sim_ref{objs}}) {
|
||||
#
|
||||
# print XML_FILE " " x 4, "<sim_object>\n";
|
||||
#
|
||||
# print XML_FILE " " x 8,
|
||||
# "<sim_object_name>$$o{objname}</sim_object_name>\n\n";
|
||||
#
|
||||
# # printout the structures found in each object
|
||||
# print XML_FILE " " x 8, "<structs>\n";
|
||||
# # Given an array of structures per sim_object, sort array by 'strname' values
|
||||
# foreach my $s (sort { ${$a}{strname} cmp ${$b}{strname} } @{$$o{structs}}) {
|
||||
# print XML_FILE " " x 12, "<struct>\n";
|
||||
# print XML_FILE " " x 16, "<struct_name>$$s{strname}</struct_name>\n";
|
||||
# $$sim_ref{icg_types}{$$s{strname}}{files}{$$s{file}}{xml} =~ s/^TRICK_HOME\//$ENV{TRICK_HOME}\// ;
|
||||
# print XML_FILE " " x 16, "<link>$$sim_ref{icg_types}{$$s{strname}}{files}{$$s{file}}{xml}</link>\n";
|
||||
# print XML_FILE " " x 16, "<default_data>\n";
|
||||
# foreach my $d (sort @{$$s{def_data}}) {
|
||||
# print XML_FILE " " x 20, "<file>$d</file>\n";
|
||||
# }
|
||||
# print XML_FILE " " x 16, "</default_data>\n";
|
||||
# print XML_FILE " " x 12, "</struct>\n";
|
||||
# }
|
||||
# print XML_FILE " " x 8, "</structs>\n\n";
|
||||
#
|
||||
# # print out each job found in this object
|
||||
# print XML_FILE " " x 8, "<jobs>\n";
|
||||
# # Given an array of jobs per sim_object, sort array by 'jobname' values
|
||||
# foreach my $j (sort { ${$a}{jobname} cmp ${$b}{jobname} } @{$$o{jobs}}) {
|
||||
# my ($file_name, $model_dir, $suffix) =
|
||||
# fileparse( $$j{file}, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
|
||||
# ($model_dir = $$j{file}) =~ s/(\/src)?\/([^\/]+)$// ;
|
||||
# if ($model_dir =~ m/\/include$/ ){
|
||||
# $model_dir =~ s/(\/include)?\/([^\/]+)$// ;
|
||||
# }
|
||||
# print XML_FILE " " x 12, "<job>\n";
|
||||
# print XML_FILE " " x 16, "<job_name>$$j{jobname}</job_name>\n";
|
||||
# print XML_FILE " " x 16, "<link>${model_dir}/xml/${file_name}${suffix}.xml</link>\n";
|
||||
# print XML_FILE " " x 12, "</job>\n";
|
||||
# }
|
||||
# print XML_FILE " " x 8, "</jobs>\n";
|
||||
# print XML_FILE " " x 4, "</sim_object>\n\n";
|
||||
# }
|
||||
|
||||
print XML_FILE "</s_define>\n";
|
||||
|
||||
close XML_FILE ;
|
||||
}
|
||||
|
||||
sub print_xml_mis ($$$$) {
|
||||
|
||||
my ($curr_file , $entries , $header_ptr, $includes) = @_ ;
|
||||
my ($out_file_basename , $name , $path , $suffix, $file_path_dir ) ;
|
||||
my %header = %$header_ptr ;
|
||||
my ($xml_file , $xml_dir , $file_version ) ;
|
||||
my ($subme , @inc_paths ) ;
|
||||
my $i ;
|
||||
|
||||
$out_file_basename = $curr_file ;
|
||||
($name, $path, $suffix) =
|
||||
fileparse( $curr_file, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
|
||||
|
||||
$file_path_dir = dirname($curr_file) ;
|
||||
if ($file_path_dir eq ".") {
|
||||
$file_path_dir = cwd();
|
||||
}
|
||||
$file_path_dir =~ s/\/+$// ; # remove trailing slash
|
||||
$path =~ s/\/+$// ; # remove trailing slash
|
||||
|
||||
if ($file_path_dir !~ /sim_services\/include/ and $file_path_dir =~ s/\/src$// ) {
|
||||
$xml_file = $file_path_dir . "/xml/" . $name . $suffix . ".xml" ;
|
||||
$xml_dir = $file_path_dir . "/xml" ;
|
||||
}
|
||||
else {
|
||||
$xml_file = $path . "/xml/" . $name . $suffix . ".xml" ;
|
||||
$xml_dir = $path . "/xml" ;
|
||||
}
|
||||
|
||||
if ( ! -e $xml_dir ) {
|
||||
mkdir $xml_dir, 0775 ;
|
||||
}
|
||||
$file_version = $file_path_dir ;
|
||||
foreach $subme (@inc_paths) {
|
||||
if ($file_version =~ s,^$subme/,, ) { # if found break out
|
||||
last ;
|
||||
}
|
||||
}
|
||||
|
||||
open XML_FILE ,">$xml_file" or die "Couldn't open file for writing $xml_file\n" ;
|
||||
|
||||
print_xml_xml_header( "$ENV{TRICK_HOME}/docs/trick_module.xsl") ;
|
||||
print_xml_body_header();
|
||||
print_xml_trick_header($curr_file, \%header);
|
||||
|
||||
print XML_FILE " " x 4 , "<jobs>\n" ;
|
||||
foreach my $entry (@$entries) {
|
||||
if ( !exists $$entry{valid} ) {
|
||||
next ;
|
||||
}
|
||||
print XML_FILE " " x 8 , "<job>\n" ;
|
||||
print_xml_child("job_name", $$entry{name}, 12);
|
||||
print_xml_child("return_type", $$entry{return_type}, 12);
|
||||
print_xml_child("units", $$entry{units}, 12);
|
||||
print_xml_child("comment", $$entry{desc}, 12);
|
||||
print XML_FILE " " x 12 , "<argument_list>\n" ;
|
||||
foreach my $arg ( @{$$entry{arg_list}} ) {
|
||||
print XML_FILE " " x 16 , "<arg>\n" ;
|
||||
print_xml_child("arg_name", $$arg{name}, 20);
|
||||
print_xml_child("type", $$arg{type}, 20);
|
||||
print_xml_child("dims", "$$arg{pointers} $$arg{array}", 20);
|
||||
print_xml_child("inout", ucfirst lc $$arg{inout}, 20);
|
||||
print_xml_child("units", $$arg{unit}, 20);
|
||||
print_xml_child("comment", $$arg{desc}, 20);
|
||||
print XML_FILE " " x 16 , "</arg>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 12 , "</argument_list>\n" ;
|
||||
print XML_FILE " " x 8 , "</job>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 4 , "</jobs>\n" ;
|
||||
|
||||
print XML_FILE " " x 4 , "<includes>\n" ;
|
||||
foreach (@$includes) {
|
||||
s/</</g;
|
||||
s/>/>/g;
|
||||
s/"/"/g;
|
||||
print XML_FILE " " x 8 , "<file>$_</file>\n";
|
||||
}
|
||||
print XML_FILE " " x 4 , "</includes>\n" ;
|
||||
|
||||
print_xml_body_footer();
|
||||
|
||||
close XML_FILE ;
|
||||
}
|
||||
|
||||
sub print_xml_icg ($$$$$) {
|
||||
|
||||
my ($file_name, $xml_file, $header, $enums_info, $structs_info) = @_ ;
|
||||
|
||||
open XML_FILE ,">$xml_file" or die "Couldn't open file for writing $xml_file\n" ;
|
||||
|
||||
print_xml_xml_header( "$ENV{TRICK_HOME}/docs/trick_struct.xsl") ;
|
||||
print_xml_body_header();
|
||||
print_xml_trick_header( $file_name, $header) ;
|
||||
|
||||
# print the enums
|
||||
print XML_FILE " " x 4 , "<enumerations>\n" ;
|
||||
foreach my $pe_ret ( @$enums_info ) {
|
||||
foreach my $enum ( @{$$pe_ret{enum_names}} ) {
|
||||
print XML_FILE " " x 8 , "<enum>\n" ;
|
||||
print XML_FILE " " x 12 , "<enum_name>$enum</enum_name>\n" ;
|
||||
foreach my $name_val ( @{$$pe_ret{enums}} ) {
|
||||
print XML_FILE " " x 12 , "<member>\n" ;
|
||||
print XML_FILE " " x 16 , "<mname>$$name_val{name}</mname>\n" ;
|
||||
print XML_FILE " " x 16 , "<value>$$name_val{value}</value>\n" ;
|
||||
$$name_val{comment} =~ s/&/&/g ;
|
||||
$$name_val{comment} =~ s/\\?"/"/g ;
|
||||
$$name_val{comment} =~ s/</</g ;
|
||||
$$name_val{comment} =~ s/>/>/g ;
|
||||
print XML_FILE " " x 16 , "<comment>$$name_val{comment}</comment>\n" ;
|
||||
print XML_FILE " " x 12 , "</member>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 8 , "</enum>\n" ;
|
||||
}
|
||||
}
|
||||
print XML_FILE " " x 4 , "</enumerations>\n\n" ;
|
||||
|
||||
# print the structs
|
||||
print XML_FILE " " x 4 , "<structures>\n" ;
|
||||
foreach my $ps_ret ( @$structs_info ) {
|
||||
foreach my $str ( @{$$ps_ret{struct_names}} ) {
|
||||
print XML_FILE " " x 8 , "<struct>\n" ;
|
||||
print XML_FILE " " x 12 , "<struct_name>$str</struct_name>\n" ;
|
||||
foreach my $param ( @{$$ps_ret{param_info}} ) {
|
||||
print XML_FILE " " x 12 , "<member>\n" ;
|
||||
print XML_FILE " " x 16 , "<pname>$$param{p_name}</pname>\n" ;
|
||||
print XML_FILE " " x 16 , "<type>$$param{p_type}</type>\n" ;
|
||||
if ( $$param{p_link} ne "" ) {
|
||||
$$param{p_link} =~ s/^TRICK_HOME\//$ENV{TRICK_HOME}\// ;
|
||||
print XML_FILE " " x 16 , "<link>$$param{p_link}</link>\n" ;
|
||||
}
|
||||
if ( $$param{p_is_enum} ) {
|
||||
print XML_FILE " " x 16 , "<is_enum>$$param{p_is_enum}</is_enum>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 16 , "<dims>$$param{p_dim_xml}</dims>\n" ;
|
||||
print XML_FILE " " x 16 , "<units>$$param{p_unit}</units>\n" ;
|
||||
$$param{p_desc} =~ s/&/&/g ;
|
||||
$$param{p_desc} =~ s/\\?"/"/g ;
|
||||
$$param{p_desc} =~ s/</</g ;
|
||||
$$param{p_desc} =~ s/>/>/g ;
|
||||
print XML_FILE " " x 16 , "<comment>$$param{p_desc}</comment>\n" ;
|
||||
print XML_FILE " " x 12 , "</member>\n" ;
|
||||
}
|
||||
print XML_FILE " " x 8 , "</struct>\n\n" ;
|
||||
}
|
||||
}
|
||||
print XML_FILE " " x 4 , "</structures>\n\n" ;
|
||||
|
||||
print_xml_body_footer();
|
||||
close XML_FILE ;
|
||||
}
|
||||
|
||||
sub print_xml_xml_header($)
|
||||
{
|
||||
my ($xsl_file) = @_ ;
|
||||
print XML_FILE "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
|
||||
print XML_FILE "<?xml-stylesheet type=\"text/xsl\" href=\"$xsl_file\"?>\n";
|
||||
|
||||
print XML_FILE "\n" ;
|
||||
print XML_FILE "<!--Note:\n" ;
|
||||
print XML_FILE " " x 4 , "Firefox 3 fails to process XSLT files if they are on the local hard drive\n" ;
|
||||
print XML_FILE " " x 4 , "plus outside of the current XML file's path (or descendant paths). Users\n" ;
|
||||
print XML_FILE " " x 4 , "may need to edit \$HOME/.mozilla/firefox/*.default/prefs.js and add a new\n" ;
|
||||
print XML_FILE " " x 4 , "URI setting in order to properly view this file in a firefox browser:\n" ;
|
||||
print XML_FILE " " x 4 , "- user_pref(\"security.fileuri.strict_origin_policy\", false);\n" ;
|
||||
print XML_FILE " " x 4 , "OR\n" ;
|
||||
print XML_FILE " " x 4 , "- type about:config in the address bar\n" ;
|
||||
print XML_FILE " " x 4 , "- change security.fileuri.strict_origin_policy to false\n" ;
|
||||
print XML_FILE "-->\n" ;
|
||||
print XML_FILE "\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_body_header()
|
||||
{
|
||||
print XML_FILE "<file>\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_body_footer()
|
||||
{
|
||||
print XML_FILE "</file>\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_trick_header($$) {
|
||||
|
||||
my ($full_file_name, $header) = @_ ;
|
||||
my ($tail_name, $path, $suffix) =
|
||||
fileparse( $full_file_name, ("\.h" , "\.hh" , "\.c" , "\.f", "\.cpp" , "\.cxx" , "\.C" , "\.cc" , "\.c\\+\\+" ));
|
||||
|
||||
print_xml_child("file_name", "$tail_name$suffix", 4);
|
||||
print_xml_child("full_path_file_name", $full_file_name, 4);
|
||||
print XML_FILE " " x 4 , "<trick_header>\n" ;
|
||||
print_xml_references($header);
|
||||
print_xml_parent_children($header, "assumptions", "assumption", "assumptions and limitations");
|
||||
print_xml_parent_children($header, "requirements", "requirement", "requirements");
|
||||
print_xml_parent_children($header, "library_dependencies", "library_dependency", "libdep");
|
||||
print_xml_parent_children($header, "purpose", "", "purpose");
|
||||
print_xml_parent_children($header, "class", "", "class");
|
||||
print_xml_programmers($header, "programmers", "programmer", "programmers");
|
||||
print XML_FILE " " x 4 , "</trick_header>\n\n" ;
|
||||
}
|
||||
|
||||
sub print_xml_parent_children($$$$) {
|
||||
#
|
||||
# Print:
|
||||
# <xml parent name>
|
||||
# <children xml nodes>
|
||||
# </xml parent name>
|
||||
|
||||
my ($header_ptr, $xml_parent_name, $xml_child_name, $trick_name) = @_ ;
|
||||
|
||||
my %header = %$header_ptr ;
|
||||
|
||||
print XML_FILE " " x 8 , "<$xml_parent_name>" ;
|
||||
if ( $xml_child_name ne "" ) {
|
||||
print XML_FILE "\n" ;
|
||||
}
|
||||
foreach my $h ( keys %header ) {
|
||||
my @list ;
|
||||
@list = split /\)[ \t\n]*\(/ , $header{$h} ;
|
||||
foreach my $ll ( @list ) {
|
||||
if ( $h eq $trick_name ) {
|
||||
print_xml_child($xml_child_name, $ll, 12);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( $xml_child_name ne "" ) {
|
||||
print XML_FILE " " x 8 , "</$xml_parent_name>\n" ;
|
||||
} else {
|
||||
print XML_FILE "</$xml_parent_name>\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_xml_child($$$) {
|
||||
|
||||
# Print a child xml node
|
||||
# <child_name>
|
||||
# value
|
||||
# </child_name>
|
||||
|
||||
my ($xml_name, $value, $indent_level) = @_ ;
|
||||
|
||||
$value =~ s/\(|\)//g ;
|
||||
$value =~ s/&/&/g ;
|
||||
$value =~ s/\\?"/"/g ;
|
||||
$value =~ s/</</g ;
|
||||
$value =~ s/>/>/g ;
|
||||
$value =~ s/\n/ /g ;
|
||||
$value =~ s/[ ]+/ /g ;
|
||||
$value =~ s/\s\s+/ /g ;
|
||||
|
||||
if ( $xml_name ne "" ) {
|
||||
print XML_FILE " " x $indent_level , "<$xml_name>" ;
|
||||
}
|
||||
|
||||
print XML_FILE " $value " ;
|
||||
|
||||
if ( $xml_name ne "" ) {
|
||||
print XML_FILE "</$xml_name>\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_xml_references($) {
|
||||
|
||||
my ($header_ptr) = @_ ;
|
||||
my %header = %$header_ptr ;
|
||||
my $idx = 0 ;
|
||||
|
||||
print XML_FILE " " x 8 , "<references>\n" ;
|
||||
|
||||
my @list ;
|
||||
my ($temp , $ref) ;
|
||||
$temp = $header{"reference"} ;
|
||||
$temp =~ s/^\(// ;
|
||||
|
||||
do {
|
||||
($ref, $temp) = extract_bracketed($temp,"()");
|
||||
if ( $ref ne "" ) {
|
||||
@list = split /\)[ \t\n]*\(/ , $ref ;
|
||||
print XML_FILE " " x 12 , "<reference>\n" ;
|
||||
print_xml_child("author", @list[0], 16) ;
|
||||
print_xml_child("source", @list[1], 16) ;
|
||||
print_xml_child("ident", @list[2], 16) ;
|
||||
print_xml_child("location", @list[3], 16) ;
|
||||
print_xml_child("date", @list[4], 16) ;
|
||||
print_xml_child("notes", @list[5], 16) ;
|
||||
print XML_FILE " " x 12 , "</reference>\n" ;
|
||||
$idx = $idx + 6 ;
|
||||
}
|
||||
} while ( $ref ne "" ) ;
|
||||
print XML_FILE " " x 8 , "</references>\n" ;
|
||||
|
||||
}
|
||||
|
||||
sub print_xml_programmers($) {
|
||||
|
||||
my ($header_ptr) = @_ ;
|
||||
my %header = %$header_ptr ;
|
||||
my $idx = 0 ;
|
||||
|
||||
print XML_FILE " " x 8 , "<modifications>\n" ;
|
||||
foreach my $h ( keys %header ) {
|
||||
my @list ;
|
||||
@list = split /\)[ \t\n]*\(/ , $header{$h} ;
|
||||
if ( $h eq "programmers" ) {
|
||||
while ( $idx <= $#list ) {
|
||||
print XML_FILE " " x 12 , "<modification>\n" ;
|
||||
print_xml_child("programmer", @list[$idx + 0], 16) ;
|
||||
print_xml_child("employer", @list[$idx + 1], 16) ;
|
||||
print_xml_child("date", @list[$idx + 2], 16) ;
|
||||
print_xml_child("ident", @list[$idx + 3], 16) ;
|
||||
print_xml_child("notes", @list[$idx + 4], 16) ;
|
||||
print XML_FILE " " x 12 , "</modification>\n" ;
|
||||
$idx = $idx + 5 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
print XML_FILE " " x 8 , "</modifications>\n" ;
|
||||
}
|
||||
|
||||
|
||||
1;
|
@ -1,110 +0,0 @@
|
||||
package get_headers ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(get_headers);
|
||||
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use Cwd 'abs_path';
|
||||
|
||||
my ( @inc_paths , @valid_inc_paths ) ;
|
||||
my %immediate_includes ;
|
||||
my %visited_files ;
|
||||
|
||||
sub parse_file($$) {
|
||||
my ($file_name, $sim_ref) = @_ ;
|
||||
my $curr_path ;
|
||||
|
||||
if ( ! exists $visited_files{$file_name} ) {
|
||||
$visited_files{$file_name} = 1 ;
|
||||
$curr_path = dirname($file_name) ;
|
||||
|
||||
open my $fh, $file_name or warn "Could not open file $file_name" ;
|
||||
while ( <$fh> ) {
|
||||
if ( /^\s*#\s*include\s+\"(.*)\"/ ) {
|
||||
#print "[31m$1[00m\n" ;
|
||||
my ($include_file) = $1 ;
|
||||
my $include_file_full_path ;
|
||||
if ( -e "$curr_path/$include_file") {
|
||||
$include_file_full_path = abs_path(dirname("$curr_path/$include_file")) . "/" . basename("$include_file");
|
||||
$immediate_includes{$file_name}{$include_file_full_path} = 1 ;
|
||||
#print "1 $include_file_full_path\n" ;
|
||||
parse_file( $include_file_full_path , $sim_ref );
|
||||
} else {
|
||||
my ($found) = 0 ;
|
||||
foreach my $p ( @inc_paths ) {
|
||||
if ( -e "$p/$include_file" || -e "$include_file" ) {
|
||||
if ( -e "$p/$include_file" ) {
|
||||
$include_file_full_path = abs_path(dirname("$p/$include_file")) . "/" . basename("$include_file");
|
||||
} else {
|
||||
$include_file_full_path = $include_file ;
|
||||
}
|
||||
#print "2 $include_file_full_path\n" ;
|
||||
$immediate_includes{$file_name}{$include_file_full_path} = 1 ;
|
||||
$found = 1 ;
|
||||
parse_file( $include_file_full_path , $sim_ref );
|
||||
last ;
|
||||
}
|
||||
}
|
||||
if ( $found == 0 ) {
|
||||
#print "[31mcould not file $include_file in $file_name[00m\n" ;
|
||||
}
|
||||
}
|
||||
} elsif ( /ICG:/i ) {
|
||||
my ($line) = $_ ;
|
||||
my ($next_line) ;
|
||||
do {
|
||||
$next_line = <$fh> ;
|
||||
$line .= $next_line ;
|
||||
} while ( $next_line =~ /^\s*$/ and !eof($fh) ) ;
|
||||
if ( $line =~ /\(\s*No\s*\)/si ) {
|
||||
#print "[31mICG no found in $file_name[00m\n" ;
|
||||
$$sim_ref{icg_no}{$file_name} = 1 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub get_all_includes($$$) {
|
||||
my ($sim_ref , $top_file , $curr_file ) = @_ ;
|
||||
|
||||
foreach my $f ( keys %{$immediate_includes{$curr_file}} ) {
|
||||
if ( ! exists $$sim_ref{all_includes}{$top_file}{$f} ) {
|
||||
$$sim_ref{all_includes}{$top_file}{$f} = 1 ;
|
||||
get_all_includes( $sim_ref , $top_file , $f ) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub get_headers($$) {
|
||||
|
||||
my ( $sim_ref, $top_file ) = @_ ;
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
push @inc_paths , "$ENV{TRICK_HOME}/trick_source" ;
|
||||
push @inc_paths , "../include" ;
|
||||
|
||||
# Get only the include paths that exist
|
||||
foreach (@inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@inc_paths = @valid_inc_paths ;
|
||||
|
||||
parse_file($top_file, $sim_ref) ;
|
||||
|
||||
# make hash of all downward files that are included by $f
|
||||
foreach my $f ( keys %immediate_includes ) {
|
||||
get_all_includes($sim_ref , $f , $f) ;
|
||||
}
|
||||
|
||||
# get all file modification times. The hash of $top_file plus S_source.hh constitute all include files
|
||||
foreach my $f ( (keys %{$$sim_ref{all_includes}{$top_file}}) , $top_file ) {
|
||||
$$sim_ref{mod_date}{$f} = (stat $f)[9] ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1 ;
|
112
libexec/trick/pm/get_lib_deps.pm
Normal file
112
libexec/trick/pm/get_lib_deps.pm
Normal file
@ -0,0 +1,112 @@
|
||||
package get_lib_deps ;
|
||||
|
||||
use File::Basename ;
|
||||
use Cwd 'abs_path';
|
||||
use File::Path qw(make_path) ;
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(get_lib_deps write_lib_deps);
|
||||
|
||||
use strict ;
|
||||
|
||||
sub get_lib_deps ($$) {
|
||||
my ($contents, $source_file_name) = @_ ;
|
||||
my ($lib_deps) ;
|
||||
my (@lib_list) ;
|
||||
my (@inc_paths) ;
|
||||
|
||||
($lib_deps) = $contents =~ /LIBRARY[ _]DEPENDENC(?:Y|IES):[^(]*(.*?)\)([A-Z _\t\n\r]+:|\s*\*)/si ;
|
||||
@lib_list = split /\)[ \t\n\r\*]*\(/ , $lib_deps ;
|
||||
|
||||
@inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ; # get include paths from TRICK_CFLAGS
|
||||
# Get only the include paths that exist
|
||||
my @valid_inc_paths ;
|
||||
foreach (@inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@inc_paths = @valid_inc_paths ;
|
||||
|
||||
my ($file_path_dir) = dirname($source_file_name) ;
|
||||
$file_path_dir =~ s/\/+$// ; # remove trailing slash
|
||||
$file_path_dir =~ s/\/include$// ;
|
||||
|
||||
my @resolved_files ;
|
||||
foreach my $l (@lib_list) {
|
||||
my $found = 0 ;
|
||||
$l =~ s/\(|\)|\s+//g ;
|
||||
$l =~ s/\${(.+?)}/$ENV{$1}/eg ;
|
||||
next if ( $l eq "" ) ;
|
||||
|
||||
if ( $l =~ /\.a$/ ) {
|
||||
my ($rel_dir) = dirname($l) ;
|
||||
foreach my $inc ( dirname($source_file_name) , @inc_paths) {
|
||||
if ( -e "$inc/$rel_dir" ) {
|
||||
my $f = abs_path("$inc/$rel_dir") . "/" . basename($l) ;
|
||||
push @resolved_files, $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
} elsif ( $l !~ /\.o$/ ) {
|
||||
foreach my $inc ( dirname($source_file_name) , @inc_paths) {
|
||||
if ( -e "$inc/$l" ) {
|
||||
#print "found $inc/$l$ext\n" ;
|
||||
my $f = abs_path(dirname("$inc/$l")) . "/" . basename("$inc/$l") ;
|
||||
push @resolved_files, $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$l =~ s/o$// ;
|
||||
my ($rel_dir) = dirname($l) ;
|
||||
my ($base) = basename($l) ;
|
||||
foreach my $inc ( $file_path_dir , @inc_paths) {
|
||||
foreach my $ext ( "cpp" , "cc" , "c" , "c++" , "cxx" , "C" ) {
|
||||
if ( -e "$inc/$rel_dir/$base$ext" ) {
|
||||
#print "found $inc/$l$ext\n" ;
|
||||
my $f = abs_path("$inc/$rel_dir") . "/$base$ext" ;
|
||||
push @resolved_files, $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
elsif ( -e "$inc/$rel_dir/src/$base$ext" ) {
|
||||
#print "found $inc/src/$l$ext\n" ;
|
||||
my $f = abs_path("$inc/$rel_dir/src") . "/$base$ext" ;
|
||||
push @resolved_files, $f ;
|
||||
$found = 1 ;
|
||||
last ;
|
||||
}
|
||||
}
|
||||
last if ( $found == 1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $found == 0 ) {
|
||||
print STDERR "[33m$source_file_name: Warning: Could not find dependency $l[0m\n" ;
|
||||
}
|
||||
}
|
||||
return @resolved_files ;
|
||||
}
|
||||
|
||||
sub write_lib_deps($) {
|
||||
my ($source_file_name) = @_ ;
|
||||
local $/ = undef ;
|
||||
open SOURCE, $source_file_name or warn 'cannot read $source_file_name' ;
|
||||
my ($contents) = <SOURCE> ;
|
||||
close SOURCE ;
|
||||
my (@resolved_files) = get_lib_deps($contents, $source_file_name) ;
|
||||
|
||||
my ( $file, $dir, $suffix) = fileparse($source_file_name, qr/\.[^.]*/) ;
|
||||
my ($lib_dep_file_name) = "build$dir${file}.lib_deps" ;
|
||||
if ( ! -e "build$dir" ) {
|
||||
make_path("build$dir") ;
|
||||
}
|
||||
open LIBDEP, ">$lib_dep_file_name" ;
|
||||
print LIBDEP map {"$_\n"} (sort @resolved_files) ;
|
||||
close LIBDEP ;
|
||||
|
||||
return @resolved_files ;
|
||||
}
|
||||
|
||||
1
|
@ -1,403 +0,0 @@
|
||||
package make_makefile ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(make_makefile);
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/libexec/trick/pm" ;
|
||||
use Cwd ;
|
||||
use Cwd 'abs_path';
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use trick_version ;
|
||||
|
||||
sub make_makefile($$$) {
|
||||
|
||||
my ($h_ref , $sim_ref , $make_cwd ) = @_ ;
|
||||
my ($n , $f , $k , $i , $m);
|
||||
my $num_inc_objs ;
|
||||
my %all_mis_depends ;
|
||||
my %temp_hash ;
|
||||
my @all_cfly_files ;
|
||||
my @all_read_only_libs ;
|
||||
my @all_compile_libs ;
|
||||
my %files_by_dir ;
|
||||
my ( $sp_dir , $src_dir , $sp_file , $base_name , $suffix) ;
|
||||
my @temp_array ;
|
||||
|
||||
if ( exists $$sim_ref{all_mis_depends} ) {
|
||||
%all_mis_depends = %{$$sim_ref{all_mis_depends}} ;
|
||||
}
|
||||
|
||||
my @exclude_dirs ;
|
||||
@exclude_dirs = split /:/ , $ENV{"TRICK_EXCLUDE"};
|
||||
# See if there are any elements in the exclude_dirs array
|
||||
if (scalar @exclude_dirs) {
|
||||
@exclude_dirs = sort(@exclude_dirs );
|
||||
# Error check - delete any element that is null
|
||||
# (note: sort forced all blank names to front of array
|
||||
@exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @exclude_dirs ;
|
||||
while ( not length @exclude_dirs[0] ) {
|
||||
# Delete an element from the left side of an array (element zero)
|
||||
shift @exclude_dirs ;
|
||||
}
|
||||
@exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @exclude_dirs ;
|
||||
}
|
||||
|
||||
# get a list of all source files required by this file
|
||||
foreach $n ( @{$$sim_ref{mis_entry_files}} ) {
|
||||
foreach $k ( grep !/last_look/ , (keys %{$all_mis_depends{$n}}) ) {
|
||||
push @all_cfly_files , @{$all_mis_depends{$n}{$k}} ;
|
||||
}
|
||||
}
|
||||
|
||||
# remove duplicate elements
|
||||
undef %temp_hash ;
|
||||
@all_cfly_files = grep ++$temp_hash{$_} < 2, @all_cfly_files ;
|
||||
@all_read_only_libs = sort (grep /^-/ , @all_cfly_files) ;
|
||||
@all_compile_libs = grep /\.a$/ , @all_cfly_files ;
|
||||
@all_compile_libs = sort (grep !/trick_source/ , @all_compile_libs) ;
|
||||
@all_cfly_files = sort (grep !/^-|trick_source|a$/ , @all_cfly_files) ;
|
||||
|
||||
# split off files by directory
|
||||
foreach ( @all_cfly_files ) {
|
||||
$sp_file = basename($_) ;
|
||||
$_ = abs_path(dirname($_)) ;
|
||||
|
||||
( $sp_dir , $src_dir ) = /(.*?)(?:\/(src))?$/ ;
|
||||
$src_dir .= "/" if ($src_dir ne "") ;
|
||||
($base_name , $suffix) = $sp_file =~ /(.*?)([cfly]$|C$|cc$|cxx$|cpp$|c\+\+$)/ ;
|
||||
|
||||
$files_by_dir{$sp_dir}{src_dir} = $src_dir ;
|
||||
push @{$files_by_dir{$sp_dir}{$suffix}} , $base_name ;
|
||||
}
|
||||
|
||||
# get all of the files required by compiled libraries
|
||||
# compile all files as normal files, we're not going to make a library anymore.
|
||||
foreach $n ( @all_compile_libs ) {
|
||||
my @local_files ;
|
||||
$sp_file = basename($n) ;
|
||||
$sp_dir = dirname($n) ;
|
||||
$sp_dir =~ s/\/object_\$\{TRICK_HOST_CPU\}?$// ;
|
||||
$sp_dir = abs_path($sp_dir) ;
|
||||
$src_dir = ( -e "$sp_dir/src" ) ? "src/" : "" ;
|
||||
$files_by_dir{$sp_dir}{src_dir} = $src_dir ;
|
||||
opendir THISDIR, "$sp_dir/$src_dir" or die "Could not open the directory $sp_dir/$src_dir";
|
||||
@local_files = grep !/^\.\.\./ , readdir THISDIR;
|
||||
@local_files = grep /\.[cfly]$|C$|cc$|cxx$|cpp$|c\+\+$/ , @local_files;
|
||||
foreach $k ( @local_files ) {
|
||||
($base_name , $suffix) = $k =~ /(.*?)([cfly]$|C$|cc$|cxx$|cpp$|c\+\+$)/ ;
|
||||
push @{$files_by_dir{$sp_dir}{$suffix}} , $base_name ;
|
||||
}
|
||||
closedir THISDIR ;
|
||||
}
|
||||
|
||||
# sort and weed out duplicate files
|
||||
foreach $k ( keys %files_by_dir ) {
|
||||
foreach $n ( qw{ c f l y h C cc cxx cpp c++} ) {
|
||||
undef %temp_hash ;
|
||||
@{$files_by_dir{$k}{$n}} = sort grep ++$temp_hash{$_} < 2, @{$files_by_dir{$k}{$n}} ;
|
||||
}
|
||||
}
|
||||
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
foreach my $ie ( @exclude_dirs ) {
|
||||
# if file location begins with $ie (an ICG exclude dir)
|
||||
if ( $k =~ /^\Q$ie/ ) {
|
||||
delete $files_by_dir{$k} ;
|
||||
print "[33mexcluding $k from build[00m\n" ;
|
||||
last ; # break out of loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# set the "dir_num" of each directory.
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
$_ = $k ;
|
||||
($files_by_dir{$k}{dir_num} = $_) =~ s#^/## ;
|
||||
$files_by_dir{$k}{dir_num} =~ s/[\/.]/_/g ;
|
||||
# if a particular directory had an override file, save that into memory
|
||||
if (open OV_FILE, "$k/makefile_overrides") {
|
||||
while ( <OV_FILE> ) {
|
||||
s/(#.*)// ;
|
||||
my ($comment) = $1 ;
|
||||
s/\$[{(]CURDIR[})]\/(\S+)/$k\/$1/g ;
|
||||
s/(?:\$[{(]CURDIR[})]\/)?(\S*)\$[{(]OBJ_DIR[})]/$k\/$1object_\${TRICK_HOST_CPU}/g ;
|
||||
s/\$[{(]CURDIR[})]/$k/g ;
|
||||
while ( s,/[^/]+/\.\.,, ) {}
|
||||
s//$comment/ ;
|
||||
if ( s/^objects\s*:\s*// ) {
|
||||
foreach my $ext ( qw{c C cc cxx cpp CPLUSPLUS l y} ) {
|
||||
$files_by_dir{$k}{overrides} .= "\$(MODEL_${ext}_OBJ_$files_by_dir{$k}{dir_num}): $_" ;
|
||||
}
|
||||
}
|
||||
elsif ( s/^depend\s*:\s*// ) {
|
||||
$files_by_dir{$k}{overrides} .= "depend_$files_by_dir{$k}{dir_num}: $_" ;
|
||||
}
|
||||
elsif ( s/([cfhy]|C|cc|cxx|cpp|CPLUSPLUS)_objects\s*:\s*// ) {
|
||||
$files_by_dir{$k}{overrides} .= "\$(MODEL_$1_OBJ_$files_by_dir{$k}{dir_num}): $_" ;
|
||||
}
|
||||
else {
|
||||
$files_by_dir{$k}{overrides} .= $_ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chdir($make_cwd ) ;
|
||||
my $wd = abs_path(cwd()) ;
|
||||
my $dt = localtime();
|
||||
my ($trick_ver) = get_trick_version() ;
|
||||
chomp $trick_ver ;
|
||||
|
||||
open MAKEFILE , ">build/Makefile_sim" or return ;
|
||||
|
||||
print MAKEFILE "\
|
||||
#############################################################################
|
||||
# Makefile:
|
||||
# This is a makefile for maintaining the
|
||||
# '$wd'
|
||||
# simulation directory. This make file was automatically generated by trick-CP
|
||||
#
|
||||
#############################################################################
|
||||
# Creation:
|
||||
# Author: Trick Configuration Processor - trick-CP Version $trick_ver
|
||||
# Date: $dt
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||
|
||||
S_MAIN = \$(CURDIR)/S_main_\${TRICK_HOST_CPU}.exe
|
||||
ifeq (\$(MAKECMDGOALS), test_all)
|
||||
TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
|
||||
S_MAIN = \$(CURDIR)/T_main_\${TRICK_HOST_CPU}.exe
|
||||
endif
|
||||
|
||||
LIB_DIR = \$(CURDIR)/build/lib
|
||||
|
||||
ifdef TRICK_VERBOSE_BUILD
|
||||
PRINT_ICG =
|
||||
PRINT_COMPILE =
|
||||
PRINT_INC_LINK =
|
||||
PRINT_EXE_LINK =
|
||||
PRINT_S_DEF_DEPS =
|
||||
ECHO_CMD =
|
||||
else
|
||||
PRINT_ICG = \@echo \"[34mRunning ICG[0m\"
|
||||
PRINT_COMPILE = \@echo \"[34mCompiling[0m \$(subst \$(CURDIR)/build,build,\$<)\"
|
||||
PRINT_INC_LINK = \@echo \"[34mPartial linking[0m \$(subst \$(CURDIR)/build,build,\${<D})\"
|
||||
PRINT_EXE_LINK = \@echo \"[34mFinal linking[0m \$(subst \$(CURDIR)/,,\$(S_MAIN))\"
|
||||
PRINT_S_DEF_DEPS = \@echo \"[34mGenerating dependencies[0m for S_define\"
|
||||
ECHO_CMD = \@
|
||||
ifeq (\$(MAKECMDGOALS), all)
|
||||
\$(info [34mPerforming build with these compilation flags[0m)
|
||||
\$(info [33mTRICK_CFLAGS = \$(TRICK_CFLAGS)[0m)
|
||||
\$(info [33mTRICK_CXXFLAGS = \$(TRICK_CXXFLAGS)[0m)
|
||||
endif
|
||||
endif
|
||||
|
||||
S_OBJECT_FILES = \$(CURDIR)/build/S_source.o
|
||||
|
||||
\$(S_OBJECT_FILES) : | \$(LIB_DIR)\n\n" ;
|
||||
|
||||
my %object_files_by_type ;
|
||||
$num_inc_objs = 0 ;
|
||||
# list out all of the source and object files
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
foreach my $ext ( qw{ c C cc cxx cpp c++ l y} ) {
|
||||
my $print_ext ;
|
||||
if ( $ext eq "c++" ) {
|
||||
$print_ext = "CPLUSPLUS" ;
|
||||
} else {
|
||||
$print_ext = $ext ;
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) {
|
||||
print MAKEFILE "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num} =" ;
|
||||
foreach $f ( @{$files_by_dir{$k}{$ext}} ) {
|
||||
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "o" ;
|
||||
}
|
||||
push @{$object_files_by_type{$ext}}, "MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}" ;
|
||||
|
||||
print MAKEFILE "\n\n\$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num}) : | \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f\n" ;
|
||||
print MAKEFILE "\$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f :\n" ;
|
||||
print MAKEFILE "\t@ mkdir -p \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\$(CURDIR)/build/lib/o${num_inc_objs}.o : \$(MODEL_${print_ext}_OBJ_$files_by_dir{$k}{dir_num})\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_INC_LINK)\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)cd \${<D} ; ld \$(LD_PARTIAL) -o \$\@ \$(notdir \$^)\n\n" ;
|
||||
$num_inc_objs++ ;
|
||||
}
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{l}} ne 0 ) {
|
||||
print MAKEFILE "MODEL_clex_SRC_$files_by_dir{$k}{dir_num} =" ;
|
||||
foreach $f ( @{$files_by_dir{$k}{l}} ) {
|
||||
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "clex" ;
|
||||
}
|
||||
print MAKEFILE "\n\n" ;
|
||||
}
|
||||
if ( scalar @{$files_by_dir{$k}{y}} ne 0 ) {
|
||||
print MAKEFILE "MODEL_y_c_SRC_$files_by_dir{$k}{dir_num} =" ;
|
||||
foreach $f ( @{$files_by_dir{$k}{y}} ) {
|
||||
print MAKEFILE " \\\n \$(CURDIR)/build$k/$files_by_dir{$k}{src_dir}$f" . "y.c" ;
|
||||
}
|
||||
print MAKEFILE "\n\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
foreach my $ext ( sort keys %object_files_by_type ) {
|
||||
my $print_ext ;
|
||||
if ( $ext eq "c++" ) {
|
||||
$print_ext = "CPLUSPLUS" ;
|
||||
} else {
|
||||
$print_ext = $ext ;
|
||||
}
|
||||
print MAKEFILE "MODEL_${print_ext}_OBJ =" ;
|
||||
foreach $f ( @{$object_files_by_type{$print_ext}} ) {
|
||||
print MAKEFILE " \\\n \$($f)" ;
|
||||
}
|
||||
print MAKEFILE "\n\n" ;
|
||||
}
|
||||
|
||||
# Write out the compile rules for each type of file.
|
||||
print MAKEFILE "\${MODEL_c_OBJ} : \$(CURDIR)/build\%.o : \%.c\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CC) \$(TRICK_CFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_C_OBJ} : \$(CURDIR)/build\%.o : \%.C\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_cc_OBJ} : \$(CURDIR)/build\%.o : \%.cc\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_cpp_OBJ} : \$(CURDIR)/build\%.o : \%.cpp\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_cxx_OBJ} : \$(CURDIR)/build\%.o : \%.cxx\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_CPLUSPLUS_OBJ} : \$(CURDIR)/build\%.o : \%.c++\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -I\${<D} -I\${<D}/../include -MMD -MP -c \$< -o \$\@\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_clex_SRC} : \$(CURDIR)/build\%.clex : \%.l\n" ;
|
||||
print MAKEFILE "\t\$(LEX) -o\$\@ \$<\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_y_c_SRC} : \$(CURDIR)/build\%.y.c : \%.y\n" ;
|
||||
print MAKEFILE "\t\$(YACC) -o\$\@ \$<\n\n" ;
|
||||
|
||||
print MAKEFILE "\${MODEL_y_OBJ} : \$(CURDIR)/build\%.o : \%.y.c\n" ;
|
||||
print MAKEFILE "\t\$(PRINT_COMPILE)\n\n" ;
|
||||
print MAKEFILE "\t\$(ECHO_CMD)cd \$(<D) ; \$(TRICK_CC) \$(TRICK_CXXFLAGS) -MMD -MP -c \${<F} -o \$\@\n\n" ;
|
||||
|
||||
# Include all of the dependency files for each object code file
|
||||
print MAKEFILE "-include \$(MODEL_c_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_C_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_cc_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_cpp_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_cxx_OBJ:.o=.d)\n" ;
|
||||
print MAKEFILE "-include \$(MODEL_CPLUSPLUS_OBJ:.o=.d)\n\n" ;
|
||||
|
||||
printf MAKEFILE "\n\nOBJECTS =" ;
|
||||
for( $i = 0 ; $i < $num_inc_objs ; $i++ ) {
|
||||
print MAKEFILE " \\\n\t\$(LIB_DIR)/o$i.o" ;
|
||||
}
|
||||
|
||||
# print out the libraries we link
|
||||
print MAKEFILE "\n\nREAD_ONLY_LIBS = ";
|
||||
foreach ( @all_read_only_libs ) {
|
||||
print MAKEFILE " \\\n\t$_" ;
|
||||
}
|
||||
|
||||
print MAKEFILE "\n\n
|
||||
test_all: TRICK_CXXFLAGS += -DTRICK_UNIT_TEST
|
||||
test_all: TRICK_CFLAGS += -DTRICK_UNIT_TEST
|
||||
|
||||
all: S_main
|
||||
|
||||
test_all: all
|
||||
|
||||
ICG:
|
||||
\t\$(PRINT_ICG)
|
||||
\t\$(ECHO_CMD)\${TRICK_HOME}/bin/trick-ICG -m \${TRICK_CXXFLAGS} S_source.hh
|
||||
|
||||
force_ICG:
|
||||
\t\$(PRINT_ICG)
|
||||
\t\$(ECHO_CMD)\${TRICK_HOME}/bin/trick-ICG -f -m \${TRICK_CXXFLAGS} S_source.hh
|
||||
|
||||
S_main : \$(S_MAIN) build/S_define.deps S_sie.resource
|
||||
\t@ echo \"\"
|
||||
\t@ echo \"[32m=== Simulation make complete ===[00m\"
|
||||
|
||||
\$(S_MAIN): \${TRICK_STATIC_LIB} \$(OBJECTS) \$(S_OBJECT_FILES)
|
||||
\t\$(PRINT_EXE_LINK)
|
||||
\t\$(ECHO_CMD)\$(TRICK_LD) \$(TRICK_LDFLAGS) -o \$@ \\
|
||||
\t\t\$(S_OBJECT_FILES) build/lib/*.o \\
|
||||
\t\t\${TRICK_USER_LINK_LIBS} \${READ_ONLY_LIBS} \\
|
||||
\t\t\$(LD_WHOLE_ARCHIVE) \${TRICK_LIBS} \$(LD_NO_WHOLE_ARCHIVE)\\
|
||||
\t\t\${TRICK_EXEC_LINK_LIBS}
|
||||
|
||||
\$(OBJECTS) : | \$(LIB_DIR)
|
||||
|
||||
\$(LIB_DIR) :
|
||||
\t@ mkdir -p \$@
|
||||
|
||||
\$(CURDIR)/build/S_source.o: \$(CURDIR)/build/S_source.cpp
|
||||
\t\$(PRINT_COMPILE)
|
||||
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) -MMD -MP -c \$\< -o \$\@
|
||||
|
||||
-include build/S_source.d
|
||||
|
||||
build/S_define.deps:
|
||||
\t\$(PRINT_S_DEF_DEPS)
|
||||
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_SFLAGS) -M -MT Makefile_sim -MF build/S_define.deps -x c++ S_define
|
||||
|
||||
\$(CURDIR)/build/S_source.cpp S_default.dat: S_define
|
||||
\t\$(PERL) \${TRICK_HOME}/bin/trick-CP -s -d
|
||||
|
||||
sie: S_sie.resource
|
||||
|
||||
S_sie.resource: \$(S_MAIN)
|
||||
\t@ echo \"[34mGenerating S_sie.resource...[0m\"
|
||||
\t\$(ECHO_CMD)\$(S_MAIN) sie
|
||||
|
||||
S_define_exp:
|
||||
\t\$(TRICK_CC) -E -C -xc++ \${TRICK_SFLAGS} S_define > \$@\n\n" ;
|
||||
|
||||
# write out the override files we have read in
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
if ( exists $files_by_dir{$k}{overrides} ) {
|
||||
print MAKEFILE "\n# Overrides from $k\n\n" ;
|
||||
print MAKEFILE "$files_by_dir{$k}{overrides}\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
print MAKEFILE "\n-include build/Makefile_io_src\n" ;
|
||||
print MAKEFILE "include build/Makefile_swig\n" ;
|
||||
print MAKEFILE "-include S_overrides.mk\n" ;
|
||||
|
||||
close MAKEFILE ;
|
||||
|
||||
# write out all of the files we used to S_library_list
|
||||
open LIB_LIST, ">build/S_library_list" or die "Could not open build/S_library_list" ;
|
||||
foreach $k ( sort keys %files_by_dir ) {
|
||||
foreach my $ext ( qw{ c C cc cxx cpp c++ y l } ) {
|
||||
if ( scalar @{$files_by_dir{$k}{$ext}} ne 0 ) {
|
||||
foreach $f ( @{$files_by_dir{$k}{$ext}} ) {
|
||||
push @temp_array, "$k/$files_by_dir{$k}{src_dir}$f$ext" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@temp_array = sort @temp_array;
|
||||
print LIB_LIST (sort join "\n" , @temp_array) , "\n" ;
|
||||
close LIB_LIST ;
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
1;
|
@ -1,20 +0,0 @@
|
||||
package make_no_swig_makefile ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(make_no_swig_makefile);
|
||||
|
||||
use strict ;
|
||||
|
||||
sub make_no_swig_makefile() {
|
||||
open MAKEFILE , ">Makefile_swig" or return ;
|
||||
print MAKEFILE "# Override TRICK_LIBS variables removing libtrick_pyip.a and remove python libs.\n" ;
|
||||
print MAKEFILE "TRICK_LIBS := \${TRICK_LIB_DIR}/libtrick.a\n" ;
|
||||
print MAKEFILE "PYTHON_LIB =\n\n" ;
|
||||
print MAKEFILE "convert_swig:\n\n" ;
|
||||
close MAKEFILE ;
|
||||
return ;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -1,285 +0,0 @@
|
||||
package mis_dep ;
|
||||
|
||||
use Exporter ();
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(mis_dep mis_catalog_dep traverse_tree);
|
||||
|
||||
use Cwd ;
|
||||
use File::Basename ;
|
||||
use strict ;
|
||||
use Cwd 'abs_path';
|
||||
use trick_print ;
|
||||
use gte ;
|
||||
|
||||
my @mis_inc_paths ;
|
||||
my %processed_files ;
|
||||
my %mis_depends_tree ;
|
||||
|
||||
# Get TRICK_CFLAGS and parse out -I include paths
|
||||
sub mis_dep ($@) {
|
||||
|
||||
my $file ;
|
||||
my %all_depend_trees ;
|
||||
my ($k , $a) ;
|
||||
my ($sim_ref , @fileList) = @_;
|
||||
|
||||
@mis_inc_paths = $ENV{"TRICK_CFLAGS"} =~ /-I\s*(\S+)/g ;
|
||||
push @mis_inc_paths , "../include" ;
|
||||
@mis_inc_paths = grep !/trick_source/, @mis_inc_paths ;
|
||||
push @mis_inc_paths , "$ENV{TRICK_HOME}/trick_source" ;
|
||||
my @valid_inc_paths ;
|
||||
foreach (@mis_inc_paths) {
|
||||
push @valid_inc_paths , $_ if ( -e $_ ) ;
|
||||
}
|
||||
@mis_inc_paths = @valid_inc_paths ;
|
||||
|
||||
@fileList = grep !/\.h$|\.H$|\.hh$|\.h\+\+$/ , @fileList ;
|
||||
|
||||
foreach $file ( @fileList ) {
|
||||
if ( $file ne "" ) {
|
||||
undef %mis_depends_tree ;
|
||||
$file = abs_path(dirname($file)) . "/" . basename($file) ;
|
||||
trick_print($$sim_ref{fh}, "Getting dependencies for $file\n" , "normal_cyan" , $$sim_ref{args}{v}) ;
|
||||
get_depends($file, $sim_ref);
|
||||
%{$all_depend_trees{$file}} = %mis_depends_tree ;
|
||||
$all_depend_trees{$file}{last_look} = time ;
|
||||
}
|
||||
}
|
||||
|
||||
return \%all_depend_trees ;
|
||||
}
|
||||
|
||||
sub traverse_tree {
|
||||
my ($file, $level, %curr_tree) = @_ ;
|
||||
my $a ;
|
||||
|
||||
print " " x $level , $file , "\n";
|
||||
foreach $a ( @{$curr_tree{$file}} ) {
|
||||
if ( $a ne $file ) {
|
||||
traverse_tree($a, $level+1, %curr_tree) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Show Depends Recursive Algorithm
|
||||
sub get_depends($$) {
|
||||
|
||||
my $file ;
|
||||
my $sim_ref ;
|
||||
my @list_objects ;
|
||||
my @list_libs ;
|
||||
my $found_dep ;
|
||||
my @lib_list ;
|
||||
my $contents ;
|
||||
my $size ;
|
||||
my $libdep ;
|
||||
my $language ;
|
||||
my ( $full_path ) ;
|
||||
my ($rcs_file_name, $rcs_ver, $rcs_date, $rcs_owner ) ;
|
||||
|
||||
($file, $sim_ref) = @_;
|
||||
|
||||
# If you have already seen this dependency, then don't process
|
||||
# Trim the tree ! And prevent infinite circular recursion !!! Yikes ...
|
||||
return if ( exists $processed_files{$file} ) ;
|
||||
|
||||
# Add this file to processed list, if it is a full path
|
||||
$processed_files{$file} = 1 ;
|
||||
|
||||
open FILE, $file or die "Could not process $file\n";
|
||||
seek FILE , 0 , 2 ;
|
||||
$size = tell FILE ;
|
||||
seek FILE , 0 , 0 ;
|
||||
read FILE , $contents , $size;
|
||||
close(FILE);
|
||||
|
||||
while ( $contents =~ /LIBRARY(\s|_)DEPENDENC(Y|IES):[^(]*(.*?)\)([A-Z \t\n\r]+:|[ \t\n\r]*\*)/gsi ) {
|
||||
$libdep .= $3 ;
|
||||
}
|
||||
|
||||
if ( $libdep =~ /#/ ) {
|
||||
(my $cc = gte("TRICK_CC")) =~ s/\n// ;
|
||||
my @defines = $ENV{"TRICK_CFLAGS"} =~ /(-D\S+)/g ;
|
||||
my $temp ;
|
||||
open FILE, "echo \"$libdep\" | cpp -P @defines |" ;
|
||||
while ( <FILE> ) {
|
||||
$temp .= $_ ;
|
||||
}
|
||||
$libdep = $temp ;
|
||||
}
|
||||
|
||||
|
||||
@lib_list = split /\)[ \t\n\r\*]*\(/ , $libdep ;
|
||||
foreach (@lib_list) {
|
||||
s/\(|\)|\s+//g ;
|
||||
s/\${(.+?)}/$ENV{$1}/eg ;
|
||||
}
|
||||
@list_objects = grep /\.o$/ , @lib_list ;
|
||||
@list_libs = grep /\.so$|\.a$/ , @lib_list ;
|
||||
|
||||
# Always add self-dependency
|
||||
push @{$mis_depends_tree{$file}} , $file ;
|
||||
|
||||
# Now for each object, construct full path to object's src and find src file
|
||||
foreach my $o (@list_objects) {
|
||||
|
||||
# look for object code with source
|
||||
$found_dep = find_depends_file($file,$o,$sim_ref) ;
|
||||
|
||||
# Did not find dependency
|
||||
if ( $found_dep == 0 ) {
|
||||
$o =~ s/\.[\w\+]+$/\.o/ ;
|
||||
trick_print($$sim_ref{fh}, "ERROR: Dependency \"$o\" not found for \"$file\"\n", "title_red" , $$sim_ref{args}{v}) ;
|
||||
exit( -1 ) ;
|
||||
}
|
||||
}
|
||||
|
||||
# Now for each lib, construct full path to lib's src and add to list
|
||||
foreach my $l ( @list_libs ) {
|
||||
|
||||
my ($rel_path , $lib_name ) ;
|
||||
|
||||
($rel_path , $lib_name ) = $l =~ /(?:(.*)\/)?([^\/]+)/ ;
|
||||
|
||||
if ($rel_path eq "") {
|
||||
$found_dep = 1 ;
|
||||
$lib_name =~ s,lib,,;
|
||||
$lib_name =~ s,\.so$|\.a$,,;
|
||||
$processed_files{"-l$lib_name"} = 1 ;
|
||||
push @{$mis_depends_tree{$file}} , "-l$lib_name" ;
|
||||
trick_print($$sim_ref{fh}, " $lib_name\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
} else {
|
||||
|
||||
$found_dep = 0 ;
|
||||
foreach my $ipath ( @mis_inc_paths ) {
|
||||
|
||||
# Construct possible full paths to lib dir from include paths
|
||||
$full_path = $ipath . "/" . $rel_path;
|
||||
|
||||
if ( -s $full_path ) {
|
||||
|
||||
$found_dep = 1;
|
||||
$lib_name = $full_path ."/object_\${TRICK_HOST_CPU}/". $lib_name ;
|
||||
|
||||
# remove ../
|
||||
while ( $lib_name =~ s,/[^/]+/\.\.,, ) {}
|
||||
|
||||
push @{$mis_depends_tree{$file}} , $lib_name ;
|
||||
trick_print($$sim_ref{fh}, " $lib_name\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
|
||||
$processed_files{$lib_name} = 1 ;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Did not find dependency
|
||||
if ( $found_dep == 0 ) {
|
||||
trick_print($$sim_ref{fh}, "ERROR: Dependency $l not found for $file\n", "title_red" , $$sim_ref{args}{v}) ;
|
||||
exit( -1 ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub find_depends_file($$$) {
|
||||
|
||||
my ($file, $o , $sim_ref) ;
|
||||
my @list_languages ;
|
||||
my $lex_yacc ;
|
||||
my ( $full_path , $full_path1 , $full_path2 ) ;
|
||||
my ( $curr_path ) ;
|
||||
my ( $dep_to_search ) ;
|
||||
|
||||
($file , $dep_to_search, $sim_ref) = @_;
|
||||
|
||||
$o = $dep_to_search ;
|
||||
|
||||
$curr_path = dirname($file) ;
|
||||
# Decide how to search through languages
|
||||
opendir THISDIR, $curr_path or die "Could not open the directory of $curr_path" ;
|
||||
$lex_yacc = grep /\.[ly]$/ , readdir THISDIR ;
|
||||
|
||||
if ( $lex_yacc ) {
|
||||
@list_languages = ("y", "l", "c", "cpp" , "cc" , "cxx" , "C" , "c\+\+");
|
||||
}
|
||||
else {
|
||||
@list_languages = ("c", "cpp" , "cc" , "cxx" , "C" , "c\+\+", "y", "l");
|
||||
}
|
||||
|
||||
# Otherwise use TRICK_CFLAGS and find it
|
||||
if ( $dep_to_search !~ /\.o$/ ) {
|
||||
foreach my $ipath ( $curr_path , @mis_inc_paths ) {
|
||||
if ( -s "$ipath/$dep_to_search" ) {
|
||||
my $f = "$ipath/$dep_to_search" ;
|
||||
$full_path = abs_path(dirname($f)) . "/" . basename($f) ;
|
||||
push @{$mis_depends_tree{$file}} , $full_path ;
|
||||
trick_print($$sim_ref{fh}, " $full_path\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
get_depends($full_path , $sim_ref);
|
||||
return(1) ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach my $ipath ( $curr_path , @mis_inc_paths ) {
|
||||
foreach my $lang ( @list_languages ) {
|
||||
|
||||
my $found_dep ;
|
||||
my ($file_name ) ;
|
||||
my ($dir_name ) ;
|
||||
my ($rspath , $rpath ) ;
|
||||
|
||||
$o =~ s/\.[\w\+]+$/\.$lang/ ;
|
||||
|
||||
#
|
||||
# Construct possible full paths to src from include paths
|
||||
#
|
||||
$file_name = basename($o) ;
|
||||
$dir_name = dirname($o) ;
|
||||
|
||||
# if full path sepcified (possible, but not recommended)
|
||||
# don't prepend include path.
|
||||
if ( $dir_name =~ /^\// ) {
|
||||
$full_path1 = "$dir_name/src/$file_name" ;
|
||||
$full_path2 = "$dir_name/$file_name" ;
|
||||
}
|
||||
else {
|
||||
$full_path1 = "$ipath/$dir_name/src/$file_name" ;
|
||||
$full_path2 = "$ipath/$dir_name/$file_name" ;
|
||||
}
|
||||
|
||||
$found_dep = 0;
|
||||
# Construct full path
|
||||
if ( -s $full_path1 ) {
|
||||
$full_path = abs_path(dirname($full_path1)) . "/" . basename($full_path1) ;
|
||||
$found_dep = 1;
|
||||
}
|
||||
elsif ( -s $full_path2 ) {
|
||||
$full_path = abs_path(dirname($full_path2)) . "/" . basename($full_path2);
|
||||
$found_dep = 1;
|
||||
}
|
||||
|
||||
if ( $found_dep == 1 ) {
|
||||
push @{$mis_depends_tree{$file}} , $full_path ;
|
||||
trick_print($$sim_ref{fh}, " $full_path\n" , "debug_white" , $$sim_ref{args}{v}) ;
|
||||
if ( $lang eq "y" ) {
|
||||
($full_path1 = $full_path ) =~ s/\.y$/\.l/ ;
|
||||
push @{$mis_depends_tree{$file}} , $full_path1 ;
|
||||
}
|
||||
get_depends($full_path , $sim_ref);
|
||||
return(1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0) ;
|
||||
}
|
||||
|
||||
|
||||
sub mis_catalog_dep ($$) {
|
||||
return ;
|
||||
}
|
||||
|
||||
1;
|
@ -12,7 +12,6 @@ use Cwd 'abs_path';
|
||||
use IPC::Open3 ;
|
||||
|
||||
use lib $ENV{"TRICK_HOME"} . "/bin/pm" ;
|
||||
use ICG ;
|
||||
use edit ;
|
||||
use find_module ;
|
||||
use gte ;
|
||||
|
@ -317,6 +317,13 @@ PURPOSE:
|
||||
|
||||
close S_SOURCE ;
|
||||
|
||||
|
||||
open S_INSTANCE, ">build/S_instances" or die "Couldn't open build/S_instances!\n";
|
||||
print S_INSTANCE $$sim_ref{extern_instance_declarations} ;
|
||||
foreach my $integ_loop ( @{$$sim_ref{integ_loop}} ) {
|
||||
print S_INSTANCE "extern IntegLoopSimObject $$integ_loop{name} ;\n" ;
|
||||
}
|
||||
close S_INSTANCE ;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------
|
||||
|
@ -1,410 +0,0 @@
|
||||
package trick_units ;
|
||||
|
||||
%units_info = (
|
||||
"s" => ["seconds", "Standard", "Time"],
|
||||
"ps" => ["pico-seconds", "Standard", "Time"],
|
||||
"ns" => ["nano-seconds", "Standard", "Time"],
|
||||
"us" => ["micro-seconds", "Standard", "Time"],
|
||||
"ms" => ["milli-seconds", "Standard", "Time"],
|
||||
"cs" => ["centi-seconds", "Standard", "Time"],
|
||||
"ds" => ["deci-seconds", "Standard", "Time"],
|
||||
"das" => ["deca-seconds", "Standard", "Time"],
|
||||
"hs" => ["hecto-seconds", "Standard", "Time"],
|
||||
"ks" => ["kilo-seconds", "Standard", "Time"],
|
||||
"Ms" => ["mega-seconds", "Standard", "Time"],
|
||||
"Gs" => ["giga-seconds", "Standard", "Time"],
|
||||
"Ts" => ["tera-seconds", "Standard", "Time"],
|
||||
"min" => ["minutes", "Standard", "Time"],
|
||||
"hr" => ["hours", "Standard", "Time"],
|
||||
"day" => ["days", "Standard", "Time"],
|
||||
"m" => ["meters", "Metric", "Length"],
|
||||
"M" => ["meters", "Metric", "Length"],
|
||||
"pm" => ["pico-meters", "Metric", "Length"],
|
||||
"nm" => ["nano-meters", "Metric", "Length"],
|
||||
"um" => ["micro-meters", "Metric", "Length"],
|
||||
"mm" => ["milli-meters", "Metric", "Length"],
|
||||
"cm" => ["centi-meters", "Metric", "Length"],
|
||||
"dm" => ["deci-meters", "Metric", "Length"],
|
||||
"dam" => ["deca-meters", "Metric", "Length"],
|
||||
"hm" => ["hecto-meters", "Metric", "Length"],
|
||||
"km" => ["kilo-meters", "Metric", "Length"],
|
||||
"Mm" => ["mega-meters", "Metric", "Length"],
|
||||
"Gm" => ["giga-meters", "Metric", "Length"],
|
||||
"Tm" => ["tera-meters", "Metric", "Length"],
|
||||
"ft" => ["feet", "English", "Length"],
|
||||
"kft" => ["kilo-feet", "English", "Length"],
|
||||
"in" => ["inches", "English", "Length"],
|
||||
"yd" => ["yards", "English", "Length"],
|
||||
"mi" => ["miles", "English", "Length"],
|
||||
"n.m." => ["nautical-miles", "English", "Length"],
|
||||
"r" => ["radians", "Standard", "Angle"],
|
||||
"pr" => ["pico-radians", "Standard", "Angle"],
|
||||
"nr" => ["nano-radians", "Standard", "Angle"],
|
||||
"ur" => ["micro-radians", "Standard", "Angle"],
|
||||
"mr" => ["milli-radians", "Standard", "Angle"],
|
||||
"cr" => ["centi-radians", "Standard", "Angle"],
|
||||
"dr" => ["deci-radians", "Standard", "Angle"],
|
||||
"dar" => ["deca-radians", "Standard", "Angle"],
|
||||
"kr" => ["kilo-radians", "Standard", "Angle"],
|
||||
"Mr" => ["mega-radians", "Standard", "Angle"],
|
||||
"Gr" => ["giga-radians", "Standard", "Angle"],
|
||||
"Tr" => ["tera-radians", "Standard", "Angle"],
|
||||
"d" => ["degrees", "Standard", "Angle"],
|
||||
"as" => ["arc-seconds", "Standard", "Angle"],
|
||||
"am" => ["arc-minutes", "Standard", "Angle"],
|
||||
"rev" => ["revolutions", "Standard", "Angle"],
|
||||
"g" => ["grams", "Metric", "Mass"],
|
||||
"pg" => ["pico-grams", "Metric", "Mass"],
|
||||
"ng" => ["nano-grams", "Metric", "Mass"],
|
||||
"ug" => ["micro-grams", "Metric", "Mass"],
|
||||
"mg" => ["milli-grams", "Metric", "Mass"],
|
||||
"cg" => ["centi-grams", "Metric", "Mass"],
|
||||
"dg" => ["deci-grams", "Metric", "Mass"],
|
||||
"dag" => ["deca-grams", "Metric", "Mass"],
|
||||
"hg" => ["hecto-grams", "Metric", "Mass"],
|
||||
"kg" => ["kilo-grams", "Metric", "Mass"],
|
||||
"Mg" => ["mega-grams", "Metric", "Mass"],
|
||||
"Gg" => ["giga-grams", "Metric", "Mass"],
|
||||
"Tg" => ["tera-grams", "Metric", "Mass"],
|
||||
"mt" => ["metric-tons", "Metric", "Mass"],
|
||||
"sl" => ["slugs", "English", "Mass"],
|
||||
"lbm" => ["pound(mass)", "English", "Mass"],
|
||||
"N" => ["newtons", "Metric", "Force"],
|
||||
"pN" => ["pico-newtons", "Metric", "Force"],
|
||||
"nN" => ["nano-newtons", "Metric", "Force"],
|
||||
"uN" => ["micro-newtons", "Metric", "Force"],
|
||||
"mN" => ["milli-newtons", "Metric", "Force"],
|
||||
"cN" => ["centi-newtons", "Metric", "Force"],
|
||||
"dN" => ["deci-newtons", "Metric", "Force"],
|
||||
"daN" => ["deca-newtons", "Metric", "Force"],
|
||||
"hN" => ["hecto-newtons", "Metric", "Force"],
|
||||
"kN" => ["kilo-newtons", "Metric", "Force"],
|
||||
"MN" => ["mega-newtons", "Metric", "Force"],
|
||||
"GN" => ["giga-newtons", "Metric", "Force"],
|
||||
"TN" => ["tera-newtons", "Metric", "Force"],
|
||||
"oz" => ["ounzes", "English", "Force"],
|
||||
"lbf" => ["pound(force)", "English", "Force"],
|
||||
"v" => ["volts", "Standard", "Voltage"],
|
||||
"pv" => ["pico-volts", "Standard", "Voltage"],
|
||||
"nv" => ["nano-volts", "Standard", "Voltage"],
|
||||
"uv" => ["micro-volts", "Standard", "Voltage"],
|
||||
"mv" => ["milli-volts", "Standard", "Voltage"],
|
||||
"cv" => ["centi-volts", "Standard", "Voltage"],
|
||||
"dv" => ["deci-volts", "Standard", "Voltage"],
|
||||
"dav" => ["deca-volts", "Standard", "Voltage"],
|
||||
"hv" => ["hecto-volts", "Standard", "Voltage"],
|
||||
"kv" => ["kilo-volts", "Standard", "Voltage"],
|
||||
"Mv" => ["mega-volts", "Standard", "Voltage"],
|
||||
"Gv" => ["giga-volts", "Standard", "Voltage"],
|
||||
"Tv" => ["tera-volts", "Standard", "Voltage"],
|
||||
"amp" => ["amperes", "Standard", "Current"],
|
||||
"pamp" => ["pico-amperes", "Standard", "Current"],
|
||||
"namp" => ["nano-amperes", "Standard", "Current"],
|
||||
"uamp" => ["micro-amperes", "Standard", "Current"],
|
||||
"mamp" => ["milli-amperes", "Standard", "Current"],
|
||||
"camp" => ["centi-amperes", "Standard", "Current"],
|
||||
"damp" => ["deci-amperes", "Standard", "Current"],
|
||||
"daamp" => ["deca-amperes", "Standard", "Current"],
|
||||
"hamp" => ["hecto-amperes", "Standard", "Current"],
|
||||
"kamp" => ["kilo-amperes", "Standard", "Current"],
|
||||
"Mamp" => ["mega-amperes", "Standard", "Current"],
|
||||
"Gamp" => ["giga-amperes", "Standard", "Current"],
|
||||
"Tamp" => ["tera-amperes", "Standard", "Current"],
|
||||
"ohm" => ["ohms", "Standard", "Resistance"],
|
||||
"pohm" => ["pico-ohms", "Standard", "Resistance"],
|
||||
"nohm" => ["nano-ohms", "Standard", "Resistance"],
|
||||
"uohm" => ["micro-ohms", "Standard", "Resistance"],
|
||||
"mohm" => ["milli-ohms", "Standard", "Resistance"],
|
||||
"cohm" => ["centi-ohms", "Standard", "Resistance"],
|
||||
"dohm" => ["deci-ohms", "Standard", "Resistance"],
|
||||
"daohm" => ["deca-ohms", "Standard", "Resistance"],
|
||||
"hohm" => ["hecto-ohms", "Standard", "Resistance"],
|
||||
"kohm" => ["kilo-ohms", "Standard", "Resistance"],
|
||||
"Mohm" => ["mega-ohms", "Standard", "Resistance"],
|
||||
"Gohm" => ["giga-ohms", "Standard", "Resistance"],
|
||||
"Tohm" => ["tera-ohms", "Standard", "Resistance"],
|
||||
"C" => ["degrees-celsius", "Metric", "Temperature"],
|
||||
"K" => ["degrees-kelvin", "Metric", "Temperature"],
|
||||
"F" => ["degrees-fahrenheit", "English", "Temperature"],
|
||||
"R" => ["degrees-rankine", "English", "Temperature"],
|
||||
"dB" => ["decibels", "Standard", "Sound"],
|
||||
"J" => ["joule", "Metric", "Energy"],
|
||||
"pJ" => ["pico-joule", "Metric", "Energy"],
|
||||
"nJ" => ["nano-joule", "Metric", "Energy"],
|
||||
"uJ" => ["micro-joule", "Metric", "Energy"],
|
||||
"mJ" => ["milli-joule", "Metric", "Energy"],
|
||||
"cJ" => ["centi-joule", "Metric", "Energy"],
|
||||
"dJ" => ["deci-joule", "Metric", "Energy"],
|
||||
"daJ" => ["deca-joule", "Metric", "Energy"],
|
||||
"hJ" => ["hecto-joule", "Metric", "Energy"],
|
||||
"kJ" => ["kilo-joule", "Metric", "Energy"],
|
||||
"MJ" => ["mega-joule", "Metric", "Energy"],
|
||||
"GJ" => ["giga-joule", "Metric", "Energy"],
|
||||
"TJ" => ["tera-joule", "Metric", "Energy"],
|
||||
"BTU" => ["british-thermal", "English", "Energy"],
|
||||
"TNT" => ["ton-tnt", "English", "Energy"],"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
"W" => ["watt", "Metric", "Power"],
|
||||
"pW" => ["pico-watt", "Metric", "Power"],
|
||||
"nW" => ["nano-watt", "Metric", "Power"],
|
||||
"uW" => ["micro-watt", "Metric", "Power"],
|
||||
"mW" => ["milli-watt", "Metric", "Power"],
|
||||
"cW" => ["centi-watt", "Metric", "Power"],
|
||||
"dW" => ["deci-watt", "Metric", "Power"],
|
||||
"daW" => ["deca-watt", "Metric", "Power"],
|
||||
"hW" => ["hecto-watt", "Metric", "Power"],
|
||||
"kW" => ["kilo-watt", "Metric", "Power"],
|
||||
"MW" => ["mega-watt", "Metric", "Power"],
|
||||
"GW" => ["giga-watt", "Metric", "Power"],
|
||||
"TW" => ["tera-watt", "Metric", "Power"],
|
||||
"hp" => ["horse-power", "English", "Power"],
|
||||
"Pa" => ["pascal", "Metric", "Pressure"],
|
||||
"pPa" => ["pico-pascal", "Metric", "Pressure"],
|
||||
"nPa" => ["nano-pascal", "Metric", "Pressure"],
|
||||
"uPa" => ["micro-pascal", "Metric", "Pressure"],
|
||||
"mPa" => ["milli-pascal", "Metric", "Pressure"],
|
||||
"cPa" => ["centi-pascal", "Metric", "Pressure"],
|
||||
"dPa" => ["deci-pascal", "Metric", "Pressure"],
|
||||
"daPa" => ["deca-pascal", "Metric", "Pressure"],
|
||||
"hPa" => ["hecto-pascal", "Metric", "Pressure"],
|
||||
"kPa" => ["kilo-pascal", "Metric", "Pressure"],
|
||||
"MPa" => ["mega-pascal", "Metric", "Pressure"],
|
||||
"GPa" => ["giga-pascal", "Metric", "Pressure"],
|
||||
"TPa" => ["tera-pascal", "Metric", "Pressure"],
|
||||
"psi" => ["pounds-sq-inch", "English", "Pressure"],
|
||||
"atm" => ["atmospheres", "Metric", "Pressure"],
|
||||
"mmHg" => ["milli-meters-mercury", "Metric", "Pressure"],
|
||||
"inHg" => ["inches-mercury", "English", "Pressure"],
|
||||
"mmWater" => ["milli-meters-water", "Metric", "Pressure"],
|
||||
"inWater" => ["inches-water", "English", "Pressure"],
|
||||
"l" => ["liter", "Metric", "Volume"],
|
||||
"pl" => ["pico-liter", "Metric", "Volume"],
|
||||
"nl" => ["nano-liter", "Metric", "Volume"],
|
||||
"ul" => ["micro-liter", "Metric", "Volume"],
|
||||
"ml" => ["milli-liter", "Metric", "Volume"],
|
||||
"cl" => ["centi-liter", "Metric", "Volume"],
|
||||
"dl" => ["deci-liter", "Metric", "Volume"],
|
||||
"dal" => ["deca-liter", "Metric", "Volume"],
|
||||
"hl" => ["hecto-liter", "Metric", "Volume"],
|
||||
"kl" => ["kilo-liter", "Metric", "Volume"],
|
||||
"Ml" => ["mega-liter", "Metric", "Volume"],
|
||||
"Gl" => ["giga-liter", "Metric", "Volume"],
|
||||
"Tl" => ["tera-liter", "Metric", "Volume"],
|
||||
"gal" => ["gallon", "English", "Volume"],
|
||||
"floz" => ["fluid-ounce", "English", "Volume"],
|
||||
"--" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"cnt" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"1" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"one" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"mol" => ["<Unitless>", "Standard", "Unitless"],
|
||||
"Hz" => ["hertz", "Metric", "Frequency"],
|
||||
"pHz" => ["pico-hertz", "Metric", "Frequency"],
|
||||
"nz" => ["nano-hertz", "Metric", "Frequency"],
|
||||
"uHz" => ["micro-hertz", "Metric", "Frequency"],
|
||||
"mHz" => ["milli-hertz", "Metric", "Frequency"],
|
||||
"cHz" => ["centi-hertz", "Metric", "Frequency"],
|
||||
"dHz" => ["deci-hertz", "Metric", "Frequency"],
|
||||
"daHz" => ["deca-hertz", "Metric", "Frequency"],
|
||||
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
|
||||
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
);
|
||||
|
||||
|
||||
sub list_units {
|
||||
foreach $unit_primitive ( sort ( keys %units_info ) ) {
|
||||
printf ( STDOUT "\"%s\" means \"%s\", a %s unit of %s.\n",
|
||||
$unit_primitive,
|
||||
$units_info{$unit_primitive}[0],
|
||||
$units_info{$unit_primitive}[1],
|
||||
$units_info{$unit_primitive}[2]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub is_valid_primitive {
|
||||
my ($unit_primitive) = @_;
|
||||
|
||||
if ( $units_info{$unit_primitive} ) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub validate_unit_spec {
|
||||
my ($unit_spec) = @_;
|
||||
|
||||
my $warn_msg = "" ;
|
||||
my @valid_parts = ();
|
||||
|
||||
# If the string starts with a parenthesis, then it is a release-07 dual units spec.
|
||||
if ( $unit_spec =~ /^\(/ ) {
|
||||
my @part_attrs = (0,0);
|
||||
my @part_class = (0,0);
|
||||
|
||||
# Strip out right and left parens and whitespace.
|
||||
$unit_spec =~ s/^\(|\s|\)$//g ;
|
||||
$unit_spec =~ s/\^//g ;
|
||||
|
||||
# Split the dual unit spec into its metric and english parts.
|
||||
@dual_unit_parts = split /\|/, $unit_spec ;
|
||||
|
||||
# There should be either one or two parts.
|
||||
$number_of_parts = scalar( @dual_unit_parts );
|
||||
|
||||
if ( $number_of_parts == 1 ) {
|
||||
|
||||
for (my $ii = 0 ; $ii < $number_of_parts ; $ii ++ ) {
|
||||
my $unit_factor;
|
||||
|
||||
# Split the unit spec, using '*' and '/' as delimiters.
|
||||
my @unit_factors = split /\/|\*/ , $dual_unit_parts[$ii] ;
|
||||
|
||||
foreach $unit_factor ( @unit_factors ) {
|
||||
|
||||
|
||||
# Substitute out any exponents unless it is just "1" all by itself.
|
||||
$unit_factor =~ s/[1-3]+$//g if ( $unit_factor ne "1" );
|
||||
$unit_system = $units_info{$unit_factor}[1];
|
||||
|
||||
if ( $unit_system eq "Metric") {
|
||||
# The ii'th part contains metric primitives.
|
||||
$part_attrs[$ii] |= 1 ;
|
||||
} elsif ( $unit_system eq "Standard") {
|
||||
# The ii'th part contains english primitives.
|
||||
$part_attrs[$ii] |= 2;
|
||||
} elsif ( $unit_system eq "English") {
|
||||
# The ii'th part contains standard primitives.
|
||||
$part_attrs[$ii] |= 4;
|
||||
} else {
|
||||
# The ii'th part contains stuff we dont recognize.
|
||||
# It's broke.
|
||||
$part_attrs[$ii] |= 8;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $part_attrs[$ii] == 2 ) {
|
||||
$part_class[$ii] = 1; # pure standard
|
||||
} elsif ( $part_attrs[$ii] == 1 || $part_attrs[$ii] == 3 ) {
|
||||
@part_class[$ii] = 2; # metric (possibly mixed with standard )"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"pHz" => ["pico-hertz", "Metric", "Frequency"],
|
||||
"nHz" => ["nano-hertz", "Metric", "Frequency"],
|
||||
"uHz" => ["micro-hertz", "Metric", "Frequency"],
|
||||
"mHz" => ["milli-hertz", "Metric", "Frequency"],
|
||||
"cHz" => ["centi-hertz", "Metric", "Frequency"],
|
||||
"dHz" => ["deci-hertz", "Metric", "Frequency"],
|
||||
"daHz" => ["deca-hertz", "Metric", "Frequency"],
|
||||
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
|
||||
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
} elsif ( $part_attrs[$ii] == 4 || $part_attrs[$ii] == 6 ) {
|
||||
$part_class[$ii] = 3; # english (possibly mixed with standard )
|
||||
} else {
|
||||
$part_class[$ii] = 0; # invalid
|
||||
}
|
||||
|
||||
if ( $part_class[$ii] ) {
|
||||
push @valid_parts, $dual_unit_parts[$ii];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $number_of_parts == scalar ( @valid_parts )) {
|
||||
if ( $number_of_parts == 2 ) {
|
||||
if ( ( $part_class[0] == $part_class[1] ) && ( $part_class[0] != 1 ) ) {
|
||||
@valid_parts = ();
|
||||
} elsif ( ($part_class[0] == 3) || ( ($part_class[0] == 1) && ($part_class[1] == 2) ) ) {
|
||||
$temp = $valid_parts[0];
|
||||
$valid_parts[0] = $valid_parts[1];
|
||||
$valid_parts[1] = $temp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@valid_parts = ();
|
||||
}
|
||||
}
|
||||
elsif ( $number_of_parts == 2 ) {
|
||||
$warn_msg = "Dual units are no longer supported" ;
|
||||
return ($warn_msg , @valid_parts) ;
|
||||
}
|
||||
} else {
|
||||
|
||||
my ($orig_unit_spec) = $unit_spec ;
|
||||
|
||||
# Pre 07, old style units
|
||||
$superset_units = "sl|rev" ;
|
||||
$std_units = "1|s|M|r|kg|N|v|amp|ohm|C|dB|J|W|Pa|--" ;
|
||||
$derived_units = "min|hr|day|ft|in|mm|cm|km|yd|mi|nm|n\.m\.|kft|d|as|am|mr|lbm|g|mt|kN|oz|lbf|kv|mamp|K|R|F|BTU|TNT|hp|psi|atm|cnt|one|mol|pJ|nJ|uJ|mJ|cJ
|
||||
|dJ|daJ|hJ|kJ|MJ|GJ|TJ|pW|nW|uW|mW|cW|dW|daW|hW|kW|MW|GW|TW|Pa|pPa|nPa|uPa|mPa|cPa|dPa|daPa|hPa|kPa|MPa|GPa|TPa|pHz|nHz|uHz|mHz|cHz|dHz|daHz|hHz|kHz|MHz|GHz|THz" ;
|
||||
|
||||
my $first_product = 0;
|
||||
my @elements = ();
|
||||
|
||||
$unit_spec =~ s/\*//g; # Remove any asterisks that may incorrectly represent an exponent/power.
|
||||
$unit_spec =~ s/\^//g; # Remove any "^" that may incorrectly represent an exponent/power.
|
||||
|
||||
if ( $unit_spec =~ s/^1?\/// ) {
|
||||
$first_product = 1;
|
||||
push @elements, "1";
|
||||
}
|
||||
|
||||
while ( $unit_spec =~ s/([^\/]+)(\/|$)// ) {
|
||||
$unit_product = $1 ;
|
||||
if ( !$first_product ) {"pHz" => ["pico-hertz", "Metric", "Frequency"],
|
||||
"nHz" => ["nano-hertz", "Metric", "Frequency"],
|
||||
"uHz" => ["micro-hertz", "Metric", "Frequency"],
|
||||
"mHz" => ["milli-hertz", "Metric", "Frequency"],
|
||||
"cHz" => ["centi-hertz", "Metric", "Frequency"],
|
||||
"dHz" => ["deci-hertz", "Metric", "Frequency"],
|
||||
"daHz" => ["deca-hertz", "Metric", "Frequency"],
|
||||
"hHz" => ["hecto-hertz", "Metric", "Frequency"],
|
||||
"kHz" => ["kilo-hertz", "Metric", "Frequency"],
|
||||
"MHz" => ["mega-hertz", "Metric", "Frequency"],
|
||||
"GHz" => ["giga-hertz", "Metric", "Frequency"],
|
||||
"THz" => ["tera-hertz", "Metric", "Frequency"],
|
||||
|
||||
$first_product = 1;
|
||||
} else {
|
||||
push @elements, "/";
|
||||
}
|
||||
$unit_product =~ s/^(($superset_units|$std_units|$derived_units)([123]?))// ;
|
||||
if ( $1 ne "" ) {
|
||||
if ( $1 eq "nm" ) {
|
||||
$warn_msg = " Units \"nm\" assumed to be nautical miles." .
|
||||
" Please clarify by using \"n.m.\" or \"(n.m.)\". Use \"(nm)\" for nanometers." ;
|
||||
push @elements, "n.m.";
|
||||
}
|
||||
else {
|
||||
push @elements, $1;
|
||||
}
|
||||
|
||||
while ( $unit_product =~ s/^(($superset_units|$std_units|$derived_units)([123]?))// ) {
|
||||
push @elements, "*", $1;
|
||||
}
|
||||
} else {
|
||||
# Units product contains no primitives at all. Not good.
|
||||
@elements = (); last;
|
||||
}
|
||||
if ( $unit_product ne "" ) {
|
||||
@elements = (); last;
|
||||
}
|
||||
}
|
||||
$valid_parts[0] = join '', @elements;
|
||||
# convert old "M" to standard "m"
|
||||
$valid_parts[0] =~ s/M/m/g ;
|
||||
if ( $valid_parts[0] eq "" ) {
|
||||
$warn_msg = " No valid units found. If you are using \"m\" for meters, enclose the units in parenthesis. i.e. \"(m)\"\n" ;
|
||||
$warn_msg .=" Defaulting units to \"--\" instead of \"$orig_unit_spec\"" ;
|
||||
# Provide a default unit for validity
|
||||
$valid_parts[0] = "--" ;
|
||||
}
|
||||
}
|
||||
return ($warn_msg , @valid_parts) ;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/java/jdk1.6.0/bin/java -classpath ./java/dist/trick.jar trick.test.Client
|
@ -1,6 +1,22 @@
|
||||
|
||||
include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||
|
||||
ifdef TRICK_VERBOSE_BUILD
|
||||
PRINT_CP =
|
||||
PRINT_ICG =
|
||||
PRINT_CONVERT_SWIG =
|
||||
PRINT_MAKEFILE_SRC =
|
||||
PRINT_MAKEFILE_SWIG =
|
||||
ECHO_CMD =
|
||||
else
|
||||
PRINT_CP = @echo "[34mRunning configuration_processor[0m"
|
||||
PRINT_ICG = @echo "[34mRunning ICG[0m"
|
||||
PRINT_CONVERT_SWIG = @echo "[34mRunning convert_swig[0m"
|
||||
PRINT_MAKEFILE_SRC = @echo "[34mCreating/updating source Makefile[0m"
|
||||
PRINT_MAKEFILE_SWIG = @echo "[34mCreating/updating swig Makefile[0m"
|
||||
ECHO_CMD = @
|
||||
endif
|
||||
|
||||
.NOTPARALLEL: all test
|
||||
|
||||
export TRICK_ICG_EXCLUDE
|
||||
@ -8,39 +24,69 @@ export TRICK_ICG_EXCLUDE
|
||||
# Use /bin/bash as the shell so we can use PIPESTATUS
|
||||
SHELL = /bin/bash
|
||||
|
||||
ifeq ($(MAKECMDGOALS), debug)
|
||||
TRICK_CPFLAGS += --debug
|
||||
endif
|
||||
|
||||
all : ${TRICK_LIB_DIR}/libtrick.a build/Makefile_sim
|
||||
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt build/MAKE_out
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_sim ICG 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_sim convert_swig 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_sim all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
|
||||
test : ${TRICK_LIB_DIR}/libtrick.a build/Makefile_sim
|
||||
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt build/MAKE_out
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_sim ICG 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_sim convert_swig 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_sim test_all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
all test : ${TRICK_LIB_DIR}/libtrick.a S_source.hh \
|
||||
$(CURDIR)/build/Makefile_io_src \
|
||||
$(CURDIR)/build/Makefile_src \
|
||||
$(CURDIR)/build/Makefile_swig \
|
||||
$(CURDIR)/build/convert_swig_last_run \
|
||||
$(CURDIR)/build/MAKE_out
|
||||
@$(MAKE) --no-print-directory -f build/Makefile_src $@ 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||
|
||||
build:
|
||||
mkdir $@
|
||||
|
||||
debug : all
|
||||
debug : TRICK_CPFLAGS += --debug
|
||||
|
||||
${TRICK_LIB_DIR}/libtrick.a:
|
||||
@echo "Cannot find $@. Please build Trick for this platfrom"
|
||||
@exit -1
|
||||
|
||||
build/Makefile_sim: S_define | build
|
||||
@${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS)
|
||||
$(CURDIR)/build/MAKE_out : | build
|
||||
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt $@
|
||||
|
||||
model_dirs:
|
||||
@${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor -z
|
||||
# CP creates S_source.hh required for ICG and SWIG processing
|
||||
S_source.hh : S_define | build
|
||||
$(PRINT_CP)
|
||||
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS)
|
||||
|
||||
sie ICG force_ICG convert_swig S_define_exp:
|
||||
@if [ -f build/Makefile_sim ] ; then $(MAKE) --no-print-directory -f build/Makefile_sim $@ ; else echo "No build/Makefile_sim found" ; fi
|
||||
# Automatic and manual ICG rules
|
||||
$(CURDIR)/build/Makefile_io_src : | S_source.hh
|
||||
$(PRINT_ICG)
|
||||
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_CXXFLAGS} S_source.hh
|
||||
|
||||
ICG:
|
||||
$(PRINT_ICG)
|
||||
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_CXXFLAGS} S_source.hh
|
||||
|
||||
force_ICG:
|
||||
$(PRINT_ICG)
|
||||
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -f -m ${TRICK_CXXFLAGS} S_source.hh
|
||||
|
||||
# Create makefile for source code
|
||||
$(CURDIR)/build/Makefile_src: $(CURDIR)/build/Makefile_io_src
|
||||
$(PRINT_MAKEFILE_SRC)
|
||||
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_src $?
|
||||
|
||||
# Create makefile for SWIG code
|
||||
$(CURDIR)/build/Makefile_swig : | $(CURDIR)/build/Makefile_io_src
|
||||
$(PRINT_MAKEFILE_SWIG)
|
||||
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_swig $?
|
||||
|
||||
# Automatic and manual convert_swig rules
|
||||
$(CURDIR)/build/convert_swig_last_run : | $(CURDIR)/build/Makefile_swig
|
||||
$(PRINT_CONVERT_SWIG)
|
||||
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS}
|
||||
@ touch $@
|
||||
|
||||
convert_swig:
|
||||
$(PRINT_CONVERT_SWIG)
|
||||
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS}
|
||||
@ touch $(CURDIR)/build/convert_swig_last_run
|
||||
|
||||
# Pass these options
|
||||
sie S_define_exp:
|
||||
@if [ -f build/Makefile_src ] ; then $(MAKE) --no-print-directory -f build/Makefile_src $@ ; else echo "No build/Makefile_src found" ; fi
|
||||
|
||||
help:
|
||||
@ echo -e "\
|
||||
@ -53,16 +99,15 @@ Simulation make options:\n\
|
||||
make apocalypse - Performs a clean"
|
||||
|
||||
tidy:
|
||||
-rm -f S_sie.resource
|
||||
-rm -f DP_Product/DP_rt_frame DP_Product/DP_rt_itimer
|
||||
-rm -f DP_Product/DP_rt_jobs DP_Product/DP_rt_timeline DP_Product/DP_mem_stats
|
||||
-rm -f S_source.hh S_sie.resource
|
||||
-rm -f S_main* T_main*
|
||||
-rm -f build/Makefile_*
|
||||
-rm -rf S_default.dat
|
||||
|
||||
clean: tidy
|
||||
-rm -rf Default_data S_default.dat
|
||||
rm -f S_source.hh
|
||||
rm -rf build
|
||||
-rm -rf trick
|
||||
-rm -f DP_Product/DP_rt_frame DP_Product/DP_rt_itimer
|
||||
-rm -f DP_Product/DP_rt_jobs DP_Product/DP_rt_timeline DP_Product/DP_mem_stats
|
||||
-rm -rf build trick
|
||||
@ echo "Removed build directory"
|
||||
|
||||
spotless: clean
|
||||
@ -71,6 +116,9 @@ apocalypse: clean
|
||||
@echo "[31mI love the smell of napalm in the morning[0m"
|
||||
|
||||
|
||||
# Dependencies to other files that may cause a re-CP
|
||||
# Dependencies for the above rules generated by configuration_process, ICG, make_makefile and make_makefile_swig
|
||||
-include build/S_define.deps
|
||||
-include build/Makefile_ICG
|
||||
-include build/Makefile_convert_swig
|
||||
-include build/Makefile_src_deps
|
||||
|
||||
|
@ -54,7 +54,7 @@ std::string CommentSaver::getTrickHeaderComment( std::string file_name ) {
|
||||
std::string comment_str = getComment((*cit).second) ;
|
||||
std::transform(comment_str.begin(), comment_str.end(), comment_str.begin(), ::toupper) ;
|
||||
if ( comment_str.find("PURPOSE") != std::string::npos ) {
|
||||
trick_header_comments[file_name] = comment_str ;
|
||||
trick_header_comments[file_name] = getComment((*cit).second) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
@ -72,6 +72,7 @@ void CommentSaver::getICGField( std::string file_name ) {
|
||||
std::string th_str = getTrickHeaderComment(file_name) ;
|
||||
if ( ! th_str.empty() ) {
|
||||
|
||||
std::transform(th_str.begin(), th_str.end(), th_str.begin(), ::toupper) ;
|
||||
int ret ;
|
||||
regex_t reg_expr ;
|
||||
regmatch_t pmatch[10] ;
|
||||
@ -148,6 +149,8 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
||||
std::string th_str = getTrickHeaderComment(file_name) ;
|
||||
if ( ! th_str.empty() ) {
|
||||
//std::cout << "here in getIgnoreTypes\n" << th_str << std::endl ;
|
||||
std::transform(th_str.begin(), th_str.end(), th_str.begin(), ::toupper) ;
|
||||
|
||||
int ret ;
|
||||
regex_t reg_expr ;
|
||||
regmatch_t pmatch[10] ;
|
||||
@ -193,3 +196,68 @@ std::set< std::string > CommentSaver::getIgnoreTypes( std::string file_name ) {
|
||||
return ignore_types ;
|
||||
}
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
/*
|
||||
As of right now I call a perl script to parse the header comment and return
|
||||
the library dependencies because perl is awesome!
|
||||
TODO: Someday when C++11 is working on all the platforms we support we should
|
||||
rewrite this using the language built in regular expressions.
|
||||
TODO: Only fork and exec a single instance of the script.
|
||||
*/
|
||||
|
||||
std::vector< std::string > CommentSaver::getLibraryDependencies( std::string file_name ) {
|
||||
|
||||
pid_t pid ;
|
||||
int pipes[4] ;
|
||||
|
||||
// Open two pipes to allow us to write to and read from child process.
|
||||
pipe(&pipes[0]) ;
|
||||
pipe(&pipes[2]) ;
|
||||
if (( pid = fork()) == 0 ) {
|
||||
// child pipes: read = pipe[2], write = pipe[1]
|
||||
close(pipes[0]) ;
|
||||
close(pipes[3]) ;
|
||||
dup2(pipes[2], STDIN_FILENO) ;
|
||||
dup2(pipes[1], STDOUT_FILENO) ;
|
||||
|
||||
// exec the perl script that parses header comments.
|
||||
std::string parse_lib_deps_path = std::string(getenv("TRICK_HOME")) + "/libexec/trick/ICG_lib_deps_helper" ;
|
||||
execl(parse_lib_deps_path.c_str(), parse_lib_deps_path.c_str(), file_name.c_str(), (char *)NULL) ;
|
||||
exit(1) ;
|
||||
}
|
||||
// parent pipes: read = pipe[0], write = pipe[3]
|
||||
close(pipes[1]) ;
|
||||
close(pipes[2]) ;
|
||||
|
||||
// get the header comment and send it with a end delimiter to the perl script
|
||||
std::string header = getTrickHeaderComment(file_name) + "\nEND ICG PROCESSING\n" ;
|
||||
write(pipes[3], header.c_str() , header.size()) ;
|
||||
|
||||
// wait for the child process to end
|
||||
int status ;
|
||||
waitpid(pid, &status, 0) ;
|
||||
|
||||
// read the result from the perl script
|
||||
int num_read ;
|
||||
char buf[4096] ;
|
||||
std::string response ;
|
||||
while (( num_read = read(pipes[0], buf, sizeof(buf) - 1) ) > 0 ) {
|
||||
buf[num_read] = 0 ;
|
||||
response += buf ;
|
||||
}
|
||||
|
||||
// parse the single string result into a vector of strings.
|
||||
std::vector< std::string > lib_deps ;
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type prev = 0;
|
||||
while ((pos = response.find("\n", prev)) != std::string::npos)
|
||||
{
|
||||
lib_deps.push_back(response.substr(prev, pos - prev));
|
||||
prev = pos + 1;
|
||||
}
|
||||
lib_deps.push_back(response.substr(prev));
|
||||
|
||||
return lib_deps ;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "clang/Lex/Preprocessor.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
@ -76,6 +77,12 @@ class CommentSaver : public clang::CommentHandler {
|
||||
*/
|
||||
std::set< std::string > getIgnoreTypes( std::string file_name ) ;
|
||||
|
||||
/** Returns a vector of library dependencies from the Trick comment
|
||||
@param file_name = File name to search
|
||||
@return vector of library dependency strings
|
||||
*/
|
||||
std::vector< std::string > getLibraryDependencies( std::string file_name ) ;
|
||||
|
||||
private:
|
||||
/** The compiler's source manager. Holds file/line info for everything. */
|
||||
clang::CompilerInstance & ci ;
|
||||
|
@ -221,18 +221,18 @@ std::string PrintAttributes::createIOFileName(std::string header_file_name) {
|
||||
free(temp_str) ;
|
||||
|
||||
if ( hsd.isPathInUserDir( dir_name ) ) {
|
||||
if ( dir_name.length() >= 8 and ! dir_name.compare(dir_name.size() - 8 , dir_name.size() , "/include" )) {
|
||||
if ( dir_name.length() < 13 or dir_name.compare(dir_name.size() - 13 , dir_name.size() , "trick/include" )) {
|
||||
dir_name.replace(dir_name.size() - 8 , dir_name.size() , "") ;
|
||||
}
|
||||
}
|
||||
if ( ! output_dir.empty() ) {
|
||||
io_file_name = output_dir + "/io_src/" + base_name ;
|
||||
io_file_name = output_dir + "/" + base_name ;
|
||||
} else {
|
||||
// Put all of the sim_services io_files in ${TRICK_HOME}/trick_source/sim_services/include/io_src unless
|
||||
// it is in er7_utils. The er7_utils io_files have duplicate file names so the overwrite each other
|
||||
// leave those in their respective directories.
|
||||
if ( sim_services_flag ) {
|
||||
if ( dir_name.length() >= 8 and ! dir_name.compare(dir_name.size() - 8 , dir_name.size() , "/include" )) {
|
||||
if ( dir_name.length() < 13 or dir_name.compare(dir_name.size() - 13 , dir_name.size() , "trick/include" )) {
|
||||
dir_name.replace(dir_name.size() - 8 , dir_name.size() , "") ;
|
||||
}
|
||||
}
|
||||
if ( dir_name.find("er7_utils") == std::string::npos ) {
|
||||
io_file_name = std::string(getenv("TRICK_HOME")) + "/trick_source/sim_services/include/io_src/" + base_name ;
|
||||
} else {
|
||||
@ -241,7 +241,7 @@ std::string PrintAttributes::createIOFileName(std::string header_file_name) {
|
||||
} else {
|
||||
//TODO: only use build directory if we are ICG'ing a sim
|
||||
// All files go into a build directory based in the current directory.
|
||||
io_file_name = std::string("build") + dir_name + "/io_src/" + base_name ;
|
||||
io_file_name = std::string("build") + dir_name + "/" + base_name ;
|
||||
}
|
||||
}
|
||||
return io_file_name ;
|
||||
@ -347,18 +347,52 @@ void PrintAttributes::closeMapFiles() {
|
||||
|
||||
// If we wrote any new io_src files, move the temporary class and enum map files to new location
|
||||
if ( out_of_date_io_files.size() > 0 ) {
|
||||
rename( std::string(map_dir + "/.class_map.cpp").c_str(), std::string(map_dir + "/class_map.cpp").c_str()) ;
|
||||
rename( std::string(map_dir + "/.enum_map.cpp").c_str(), std::string(map_dir + "/enum_map.cpp").c_str()) ;
|
||||
std::ifstream class_map(std::string(map_dir + "/.class_map.cpp").c_str()) ;
|
||||
std::ifstream enum_map(std::string(map_dir + "/.enum_map.cpp").c_str()) ;
|
||||
std::ofstream combined_map(std::string(map_dir + "/class_map.cpp").c_str()) ;
|
||||
combined_map << class_map.rdbuf() << enum_map.rdbuf() ;
|
||||
} else {
|
||||
remove( std::string(map_dir + "/.class_map.cpp").c_str() ) ;
|
||||
remove( std::string(map_dir + "/.enum_map.cpp").c_str() ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void PrintAttributes::addEmptyFiles() {
|
||||
// Make a list of the empty files we processed.
|
||||
// This list is written to the ICG_processed file and used by other processors.
|
||||
clang::SourceManager::fileinfo_iterator fi ;
|
||||
for ( fi = ci.getSourceManager().fileinfo_begin() ; fi != ci.getSourceManager().fileinfo_end() ; fi++ ) {
|
||||
const clang::FileEntry * fe = (*fi).first ;
|
||||
std::string header_file_name = fe->getName() ;
|
||||
if ( visited_files.find(header_file_name) == visited_files.end() ) {
|
||||
visited_files.insert(header_file_name) ;
|
||||
// several tests require the real path of the header file.
|
||||
char * rp = almostRealPath(header_file_name.c_str()) ;
|
||||
if ( rp != NULL ) {
|
||||
// Only include user directories (not system dirs like /usr/include)
|
||||
if ( hsd.isPathInUserDir(rp) ) {
|
||||
// Don't process files in excluded directories
|
||||
if ( hsd.isPathInICGExclude(rp) == false ) {
|
||||
// Only include files that do not have ICG: (No)
|
||||
// hasICGNo uses original header name, not the real path
|
||||
if ( ! cs.hasICGNo(header_file_name) ) {
|
||||
std::string io_file_name = createIOFileName(std::string(rp)) ;
|
||||
empty_header_files.insert(rp) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(rp) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Move this into PrintFileContents10.
|
||||
void PrintAttributes::printIOMakefile() {
|
||||
std::ofstream makefile ;
|
||||
std::ofstream makefile_io_src ;
|
||||
std::ofstream makefile_ICG ;
|
||||
std::ofstream link_io_objs ;
|
||||
std::ofstream ICG_processed ;
|
||||
unsigned int ii ;
|
||||
|
||||
// Don't create a makefile if we didn't process any files.
|
||||
@ -366,71 +400,120 @@ void PrintAttributes::printIOMakefile() {
|
||||
return ;
|
||||
}
|
||||
|
||||
makefile.open("build/Makefile_io_src") ;
|
||||
std::cout << "[34mCreating/updating io_src Makefile[0m" << std::endl ;
|
||||
makefile_io_src.open("build/Makefile_io_src") ;
|
||||
|
||||
makefile << "TRICK_IO_CXXFLAGS := \\" << std::endl ;
|
||||
makefile << " -Wno-invalid-offsetof \\" << std::endl ;
|
||||
makefile << " -Wno-old-style-cast \\" << std::endl ;
|
||||
makefile << " -Wno-write-strings \\" << std::endl ;
|
||||
makefile << " -Wno-unused-variable" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
makefile << "ifeq ($(IS_CC_CLANG), 0)" << std::endl ;
|
||||
makefile << " GCCVERSIONGTEQ48 := $(shell perl -e 'printf \"\%d\\n\", ($(GCC_MAJOR)>4)||(($(GCC_MAJOR)==4)&&($(GCC_MINOR)>=8)) ;' )" << std::endl ;
|
||||
makefile << " ifeq ($(GCCVERSIONGTEQ48), 1)" << std::endl ;
|
||||
makefile << " TRICK_IO_CXXFLAGS += -Wno-unused-but-set-variable -Wno-unused-local-typedefs" << std::endl ;
|
||||
makefile << " endif" << std::endl ;
|
||||
makefile << "endif" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
makefile << "ifdef TRICK_VERBOSE_BUILD" << std::endl ;
|
||||
makefile << "PRINT_IO_COMPILE =" << std::endl ;
|
||||
makefile << "PRINT_IO_INC_LINK =" << std::endl ;
|
||||
makefile << "else" << std::endl ;
|
||||
makefile << "PRINT_IO_COMPILE = @echo \"[34mCompiling io[0m $(subst $(CURDIR)/build,build,$<)\"" << std::endl ;
|
||||
makefile << "PRINT_IO_INC_LINK = @echo \"[34mPartial linking[0m io objects\"" << std::endl ;
|
||||
makefile << "endif" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
makefile_io_src << "TRICK_IO_CXXFLAGS := \\" << std::endl ;
|
||||
makefile_io_src << " -Wno-invalid-offsetof \\" << std::endl ;
|
||||
makefile_io_src << " -Wno-old-style-cast \\" << std::endl ;
|
||||
makefile_io_src << " -Wno-write-strings \\" << std::endl ;
|
||||
makefile_io_src << " -Wno-unused-variable" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
makefile_io_src << "ifeq ($(IS_CC_CLANG), 0)" << std::endl ;
|
||||
makefile_io_src << " TRICK_IO_CXXFLAGS += -Wno-unused-local-typedefs" << std::endl ;
|
||||
makefile_io_src << " GCCVERSIONGTEQ48 := $(shell perl -e 'printf \"\%d\\n\", " <<
|
||||
"($(GCC_MAJOR)>4)||(($(GCC_MAJOR)==4)&&($(GCC_MINOR)>=8)) ;' )" << std::endl ;
|
||||
makefile_io_src << " ifeq ($(GCCVERSIONGTEQ48), 1)" << std::endl ;
|
||||
makefile_io_src << " TRICK_IO_CXXFLAGS += -Wno-unused-but-set-variable" << std::endl ;
|
||||
makefile_io_src << " endif" << std::endl ;
|
||||
makefile_io_src << "endif" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
makefile_io_src << "ifdef TRICK_VERBOSE_BUILD" << std::endl ;
|
||||
makefile_io_src << "PRINT_ICG =" << std::endl ;
|
||||
makefile_io_src << "PRINT_IO_COMPILE =" << std::endl ;
|
||||
makefile_io_src << "PRINT_IO_INC_LINK =" << std::endl ;
|
||||
makefile_io_src << "else" << std::endl ;
|
||||
makefile_io_src << "PRINT_ICG = @echo \"[34mRunning ICG[0m\"" << std::endl ;
|
||||
makefile_io_src << "PRINT_IO_COMPILE = @echo \"[34mCompiling [0m $(subst $(CURDIR)/build,build,$<)\"" << std::endl ;
|
||||
makefile_io_src << "PRINT_IO_INC_LINK = @echo \"[34mPartial link[0m io objects\"" << std::endl ;
|
||||
makefile_io_src << "endif" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
|
||||
//TODO: create the io_file name if it doesn't exist
|
||||
makefile << "IO_OBJ_FILES =" ;
|
||||
std::set<std::string>::iterator sit ;
|
||||
for ( sit = visited_files.begin() ; sit != visited_files.end() ; sit++ ) {
|
||||
std::map< std::string , std::string >::iterator mit = all_io_files.find(*sit) ;
|
||||
if ( mit != all_io_files.end() ) {
|
||||
size_t found ;
|
||||
found = (*mit).second.find_last_of(".") ;
|
||||
makefile << " \\\n $(CURDIR)/" << (*mit).second.substr(0,found) << ".o" ;
|
||||
}
|
||||
makefile_io_src << "IO_OBJ_FILES =" ;
|
||||
|
||||
std::map< std::string , std::string >::iterator mit ;
|
||||
for ( mit = all_io_files.begin() ; mit != all_io_files.end() ; mit++ ) {
|
||||
size_t found ;
|
||||
found = (*mit).second.find_last_of(".") ;
|
||||
makefile_io_src << " \\\n $(CURDIR)/" << (*mit).second.substr(0,found) << ".o" ;
|
||||
}
|
||||
makefile << " \\\n $(CURDIR)/build/class_map.o" ;
|
||||
makefile << " \\\n $(CURDIR)/build/enum_map.o" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
makefile << "$(IO_OBJ_FILES) : \%.o : \%.cpp" << std::endl ;
|
||||
makefile << "\t$(PRINT_IO_COMPILE)" << std::endl ;
|
||||
makefile << "\t$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_IO_CXXFLAGS) -MMD -MP -c $< -o $@" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
makefile << "-include $(IO_OBJ_FILES:.o=.d)" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
|
||||
makefile << "$(S_MAIN) : $(LIB_DIR)/io_src.o" << std::endl ;
|
||||
makefile << std::endl ;
|
||||
makefile << "$(LIB_DIR)/io_src.o : $(IO_OBJ_FILES) | $(LIB_DIR)" << std::endl ;
|
||||
makefile << "\t$(PRINT_IO_INC_LINK)" << std::endl ;
|
||||
makefile << "\t$(ECHO_CMD)ld $(LD_PARTIAL) -o $@ $(LD_FILELIST)build/link_io_objs" << std::endl ;
|
||||
makefile_io_src << " \\\n $(CURDIR)/build/class_map.o" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
|
||||
makefile.close() ;
|
||||
makefile_io_src << "$(IO_OBJ_FILES) : \%.o : \%.cpp" << std::endl ;
|
||||
makefile_io_src << "\t$(PRINT_IO_COMPILE)" << std::endl ;
|
||||
makefile_io_src << "\t$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_IO_CXXFLAGS) -MMD -MP -c $< -o $@" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
makefile_io_src << "-include $(IO_OBJ_FILES:.o=.d)" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
|
||||
makefile_io_src << "OBJECTS += $(LIB_DIR)/io_src.o" << std::endl ;
|
||||
makefile_io_src << "$(S_MAIN) : $(LIB_DIR)/io_src.o" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
makefile_io_src << "$(LIB_DIR)/io_src.o : $(IO_OBJ_FILES) | $(LIB_DIR)" << std::endl ;
|
||||
makefile_io_src << "\t$(PRINT_IO_INC_LINK)" << std::endl ;
|
||||
makefile_io_src << "\t$(ECHO_CMD)ld $(LD_PARTIAL) -o $@ $(LD_FILELIST)build/link_io_objs" << std::endl ;
|
||||
makefile_io_src << std::endl ;
|
||||
|
||||
makefile_io_src.close() ;
|
||||
|
||||
/*
|
||||
Makefile_ICG lists all headers as dependencies of Makefile_io_src
|
||||
causing ICG to run if any header file changes.
|
||||
|
||||
link_io_objs lists all io_src object files to be partially
|
||||
linked into a single io_object.
|
||||
|
||||
ICG_process lists all header files to be used by SWIG.
|
||||
*/
|
||||
makefile_ICG.open("build/Makefile_ICG") ;
|
||||
link_io_objs.open("build/link_io_objs") ;
|
||||
for ( sit = visited_files.begin() ; sit != visited_files.end() ; sit++ ) {
|
||||
std::map< std::string , std::string >::iterator mit = all_io_files.find(*sit) ;
|
||||
if ( mit != all_io_files.end() ) {
|
||||
size_t found ;
|
||||
found = (*mit).second.find_last_of(".") ;
|
||||
link_io_objs << (*mit).second.substr(0,found) << ".o" << std::endl ;
|
||||
ICG_processed.open("build/ICG_processed") ;
|
||||
makefile_ICG << "$(CURDIR)/build/Makefile_io_src :" ;
|
||||
for ( mit = all_io_files.begin() ; mit != all_io_files.end() ; mit++ ) {
|
||||
makefile_ICG << "\\\n " << (*mit).first ;
|
||||
size_t found ;
|
||||
found = (*mit).second.find_last_of(".") ;
|
||||
link_io_objs << (*mit).second.substr(0,found) << ".o" << std::endl ;
|
||||
ICG_processed << (*mit).first << std::endl ;
|
||||
}
|
||||
// Create the list of empty (of classes/enums) header files to be written to ICG_processed.
|
||||
addEmptyFiles() ;
|
||||
std::set< std::string >::iterator sit ;
|
||||
for ( sit = empty_header_files.begin() ; sit != empty_header_files.end() ; sit++ ) {
|
||||
ICG_processed << (*sit) << std::endl ;
|
||||
}
|
||||
makefile_ICG << std::endl << std::endl ;
|
||||
makefile_ICG.close() ;
|
||||
link_io_objs << "build/class_map.o" << std::endl ;
|
||||
link_io_objs.close() ;
|
||||
ICG_processed.close() ;
|
||||
|
||||
}
|
||||
|
||||
void PrintAttributes::printHeaderLibraryDependencies() {
|
||||
std::ofstream header_lib_deps ;
|
||||
|
||||
header_lib_deps.open("build/header_lib_deps_files") ;
|
||||
std::map< std::string , std::string >::iterator mit ;
|
||||
for ( mit = all_io_files.begin() ; mit != all_io_files.end() ; mit++ ) {
|
||||
size_t found ;
|
||||
found = (*mit).first.find_last_of(".") ;
|
||||
std::string lib_dep_file = std::string("build") + (*mit).first.substr(0,found) + ".lib_deps" ;
|
||||
header_lib_deps << lib_dep_file << std::endl ;
|
||||
if ( out_of_date_io_files.find((*mit).first) != out_of_date_io_files.end()) {
|
||||
std::ofstream file_list ;
|
||||
file_list.open(lib_dep_file) ;
|
||||
std::vector< std::string > lib_deps = cs.getLibraryDependencies((*mit).first) ;
|
||||
std::vector< std::string >::iterator vit ;
|
||||
for ( vit = lib_deps.begin() ; vit != lib_deps.end() ; vit++ ) {
|
||||
file_list << *vit << std::endl ;
|
||||
}
|
||||
file_list.close() ;
|
||||
}
|
||||
}
|
||||
link_io_objs << "build/class_map.o" << std::endl ;
|
||||
link_io_objs << "build/enum_map.o" << std::endl ;
|
||||
link_io_objs.close() ;
|
||||
header_lib_deps.close() ;
|
||||
}
|
||||
|
||||
void PrintAttributes::printICGNoFiles() {
|
||||
|
@ -45,6 +45,9 @@ class PrintAttributes {
|
||||
/** Create makefile for IO files */
|
||||
virtual void printIOMakefile() ;
|
||||
|
||||
/** Print header library dependencies */
|
||||
virtual void printHeaderLibraryDependencies() ;
|
||||
|
||||
/** Prints list of files that contain ICG:(No) in the Trick header */
|
||||
virtual void printICGNoFiles() ;
|
||||
|
||||
@ -95,6 +98,9 @@ class PrintAttributes {
|
||||
bool isIOFileOutOfDate(std::string header_file_name, std::string io_file_name ) ;
|
||||
bool doesIODirectoryExist(std::string io_file_name ) ;
|
||||
|
||||
/** Adds empty header files to list of processed files. */
|
||||
void addEmptyFiles() ;
|
||||
|
||||
/** Determines the io_file_name based on the given header file name
|
||||
@param header_file_name = full path to header file
|
||||
@return string of full path to io_src file name.
|
||||
@ -107,6 +113,9 @@ class PrintAttributes {
|
||||
/** map of all io_files we processed */
|
||||
std::map< std::string , std::string > all_io_files ;
|
||||
|
||||
/** map of all io_files we processed */
|
||||
std::set< std::string > empty_header_files ;
|
||||
|
||||
/** map of open files to the out of date io_src file */
|
||||
std::map< std::string , std::string > out_of_date_io_files ;
|
||||
|
||||
|
@ -452,6 +452,7 @@ void PrintFileContents10::printClassMapHeader( std::ofstream & outfile , std::st
|
||||
"#include <map>\n"
|
||||
"#include <string>\n\n"
|
||||
"#include \"trick/AttributesMap.hh\"\n"
|
||||
"#include \"trick/EnumAttributesMap.hh\"\n"
|
||||
"#include \"trick/attributes.h\"\n\n"
|
||||
"void " << function_name << "() {\n\n"
|
||||
" Trick::AttributesMap * class_attribute_map = Trick::AttributesMap::attributes_map();\n\n" ;
|
||||
@ -474,19 +475,11 @@ void PrintFileContents10::printClassMap( std::ofstream & outfile , ClassValues *
|
||||
}
|
||||
|
||||
void PrintFileContents10::printClassMapFooter( std::ofstream & outfile ) {
|
||||
outfile << "}" << std::endl ;
|
||||
outfile << "}" << std::endl << std::endl ;
|
||||
}
|
||||
|
||||
void PrintFileContents10::printEnumMapHeader( std::ofstream & outfile , std::string function_name ) {
|
||||
outfile <<
|
||||
"/*\n"
|
||||
" * This file was automatically generated by the ICG\n"
|
||||
" * This file contains the map from enum names to attributes\n"
|
||||
" */\n\n"
|
||||
"#include <map>\n"
|
||||
"#include <string>\n\n"
|
||||
"#include \"trick/EnumAttributesMap.hh\"\n"
|
||||
"#include \"trick/attributes.h\"\n\n"
|
||||
"void " << function_name << "() {\n"
|
||||
" Trick::EnumAttributesMap * enum_attribute_map __attribute__((unused)) = Trick::EnumAttributesMap::attributes_map();\n\n" ;
|
||||
}
|
||||
@ -507,5 +500,5 @@ void PrintFileContents10::printEnumMap( std::ofstream & outfile , EnumValues * e
|
||||
}
|
||||
|
||||
void PrintFileContents10::printEnumMapFooter( std::ofstream & outfile ) {
|
||||
outfile << "}" << std::endl ;
|
||||
outfile << "}" << std::endl << std::endl ;
|
||||
}
|
||||
|
@ -191,6 +191,7 @@ int main( int argc , char * argv[] ) {
|
||||
|
||||
if ( ! sim_services_flag ) {
|
||||
pa.printIOMakefile() ;
|
||||
pa.printHeaderLibraryDependencies() ;
|
||||
}
|
||||
|
||||
// Close the map files
|
||||
|
@ -4,7 +4,7 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||
|
||||
CC := $(shell $(LLVM_HOME)/bin/llvm-config --bindir)/clang
|
||||
CXX := $(shell $(LLVM_HOME)/bin/llvm-config --bindir)/clang++
|
||||
CXXFLAGS := -g -I$(shell $(LLVM_HOME)/bin/llvm-config --includedir) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti
|
||||
CXXFLAGS := -g -I$(shell $(LLVM_HOME)/bin/llvm-config --includedir) -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-rtti -std=c++11
|
||||
|
||||
CLANG_MINOR_GTEQ5 := $(shell expr `$(LLVM_HOME)/bin/llvm-config --version | cut -f2 -d. ` \>= 5 )
|
||||
|
||||
|
@ -92,23 +92,23 @@ clean :
|
||||
# Builds gtest.a and gtest_main.a.
|
||||
|
||||
io_MM_user_defined_types.o : MM_user_defined_types.hh
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o . $(TRICK_CPPFLAGS) $<
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o ./io_src $(TRICK_CPPFLAGS) $<
|
||||
$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c io_src/io_MM_user_defined_types.cpp
|
||||
|
||||
io_MM_alloc_deps.o : MM_alloc_deps.hh
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o . $(TRICK_CPPFLAGS) $<
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o ./io_src $(TRICK_CPPFLAGS) $<
|
||||
$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c io_src/io_MM_alloc_deps.cpp
|
||||
|
||||
io_MM_write_checkpoint.o : MM_write_checkpoint.hh
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o . $(TRICK_CPPFLAGS) $<
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o ./io_src $(TRICK_CPPFLAGS) $<
|
||||
$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c io_src/io_MM_write_checkpoint.cpp
|
||||
|
||||
io_MM_get_enumerated.o : MM_get_enumerated.hh
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o . $(TRICK_CPPFLAGS) $<
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o ./io_src $(TRICK_CPPFLAGS) $<
|
||||
$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c io_src/io_MM_get_enumerated.cpp
|
||||
|
||||
io_MM_ref_name_from_address.o : MM_ref_name_from_address.hh
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o . $(TRICK_CPPFLAGS) $<
|
||||
${TRICK_HOME}/bin/trick-ICG -s -o ./io_src $(TRICK_CPPFLAGS) $<
|
||||
$(TRICK_CPPC) $(TRICK_CPPFLAGS) -c io_src/io_MM_ref_name_from_address.cpp
|
||||
|
||||
MM_creation_unittest.o : MM_creation_unittest.cc
|
||||
|
Loading…
x
Reference in New Issue
Block a user