mirror of
https://github.com/nasa/trick.git
synced 2024-12-20 05:37:55 +00:00
Split CP up into components that can be called individually
Found some more dead code to delete. Added a couple of progress printouts. refs #86
This commit is contained in:
parent
9b7a933a06
commit
deac866379
@ -208,7 +208,7 @@ print MAKEFILE "\
|
|||||||
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common
|
||||||
|
|
||||||
S_MAIN = \$(CURDIR)/S_main_\${TRICK_HOST_CPU}.exe
|
S_MAIN = \$(CURDIR)/S_main_\${TRICK_HOST_CPU}.exe
|
||||||
ifeq (\$(MAKECMDGOALS), test_all)
|
ifeq (\$(MAKECMDGOALS), test)
|
||||||
TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
|
TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
|
||||||
S_MAIN = \$(CURDIR)/T_main_\${TRICK_HOST_CPU}.exe
|
S_MAIN = \$(CURDIR)/T_main_\${TRICK_HOST_CPU}.exe
|
||||||
endif
|
endif
|
||||||
@ -362,12 +362,12 @@ foreach ( @all_read_only_libs ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print MAKEFILE "\n\n
|
print MAKEFILE "\n\n
|
||||||
test_all: TRICK_CXXFLAGS += -DTRICK_UNIT_TEST
|
test: TRICK_CXXFLAGS += -DTRICK_UNIT_TEST
|
||||||
test_all: TRICK_CFLAGS += -DTRICK_UNIT_TEST
|
test: TRICK_CFLAGS += -DTRICK_UNIT_TEST
|
||||||
|
|
||||||
all: S_main
|
all: S_main
|
||||||
|
|
||||||
test_all: all
|
test: all
|
||||||
|
|
||||||
S_main : \$(S_MAIN) build/S_define.deps S_sie.resource
|
S_main : \$(S_MAIN) build/S_define.deps S_sie.resource
|
||||||
\t@ echo \"\"
|
\t@ echo \"\"
|
||||||
|
@ -171,11 +171,6 @@ SWIG_PY_OBJECTS =" ;
|
|||||||
print MAKEFILE "trick :\n" ;
|
print MAKEFILE "trick :\n" ;
|
||||||
print MAKEFILE "\t\@mkdir \$\@\n" ;
|
print MAKEFILE "\t\@mkdir \$\@\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" ;
|
|
||||||
|
|
||||||
my %swig_dirs ;
|
my %swig_dirs ;
|
||||||
my %python_modules ;
|
my %python_modules ;
|
||||||
$ii = 0 ;
|
$ii = 0 ;
|
||||||
|
@ -83,7 +83,7 @@ sub get_lib_deps ($$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( $found == 0 ) {
|
if ( $found == 0 ) {
|
||||||
print STDERR "[33mWarning: Could not find dependency $l[0m\n" ;
|
print STDERR "[33m$source_file_name: Warning: Could not find dependency $l[0m\n" ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return @resolved_files ;
|
return @resolved_files ;
|
||||||
|
@ -1,393 +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 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_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 "\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
|
|
||||||
|
|
||||||
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,507 +0,0 @@
|
|||||||
package make_swig_makefile ;
|
|
||||||
|
|
||||||
use Exporter ();
|
|
||||||
use trick_version ;
|
|
||||||
use File::Path ;
|
|
||||||
|
|
||||||
@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 Digest::MD5 qw(md5_hex) ;
|
|
||||||
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") ;
|
|
||||||
|
|
||||||
@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 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_SWIG_EXCLUDE"};
|
|
||||||
# See if there are any elements in the swig_exclude_dirs array
|
|
||||||
if (scalar @swig_exclude_dirs) {
|
|
||||||
@swig_exclude_dirs = sort(@swig_exclude_dirs );
|
|
||||||
# Error check - delete any element that is null
|
|
||||||
# (note: sort forced all blank names to front of array
|
|
||||||
@swig_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @swig_exclude_dirs ;
|
|
||||||
while ( not length @swig_exclude_dirs[0] ) {
|
|
||||||
# Delete an element from the left side of an array (element zero)
|
|
||||||
shift @swig_exclude_dirs ;
|
|
||||||
}
|
|
||||||
@swig_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @swig_exclude_dirs ;
|
|
||||||
}
|
|
||||||
|
|
||||||
# If there were no directories listed in TRICK_SWIG_EXCLUDE then copy the ones from ICG_EXCLUDE.
|
|
||||||
if ( scalar @swig_exclude_dirs == 0 ) {
|
|
||||||
@swig_exclude_dirs = split /:/ , $ENV{"TRICK_ICG_EXCLUDE"};
|
|
||||||
# See if there are any elements in the swig_exclude_dirs array
|
|
||||||
if (scalar @swig_exclude_dirs) {
|
|
||||||
@swig_exclude_dirs = sort(@swig_exclude_dirs );
|
|
||||||
# Error check - delete any element that is null
|
|
||||||
# (note: sort forced all blank names to front of array
|
|
||||||
@swig_exclude_dirs = map { s/(^\s+|\s+$)//g ; $_ } @swig_exclude_dirs ;
|
|
||||||
while ( not length @swig_exclude_dirs[0] ) {
|
|
||||||
# Delete an element from the left side of an array (element zero)
|
|
||||||
shift @swig_exclude_dirs ;
|
|
||||||
}
|
|
||||||
@swig_exclude_dirs = map { (-e $_) ? abs_path($_) : $_ } @swig_exclude_dirs ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 ;
|
|
||||||
|
|
||||||
# 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 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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" ;
|
|
||||||
print LINK_PY_OBJS "build/py_top.o\n" ;
|
|
||||||
|
|
||||||
print MAKEFILE "\
|
|
||||||
# SWIG rule
|
|
||||||
SWIG_FLAGS =
|
|
||||||
SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers
|
|
||||||
ifeq (\$(IS_CC_CLANG), 1)
|
|
||||||
SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef TRICK_VERBOSE_BUILD
|
|
||||||
PRINT_SWIG =
|
|
||||||
PRINT_COMPILE_SWIG =
|
|
||||||
PRINT_SWIG_INC_LINK =
|
|
||||||
#PRINT_CONVERT_SWIG =
|
|
||||||
else
|
|
||||||
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
|
|
||||||
|
|
||||||
SWIG_PY_OBJECTS =" ;
|
|
||||||
|
|
||||||
foreach my $f ( @temp_array2 ) {
|
|
||||||
my ($continue) = 1 ;
|
|
||||||
foreach my $ie ( @exclude_dirs ) {
|
|
||||||
# if file location begins with $ie (an IGC exclude dir)
|
|
||||||
if ( $f =~ /^\Q$ie/ ) {
|
|
||||||
$continue = 0 ;
|
|
||||||
$ii++ ;
|
|
||||||
last ; # break out of loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next if ( $continue == 0 ) ;
|
|
||||||
|
|
||||||
my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ;
|
|
||||||
my ($swig_f) = $f ;
|
|
||||||
$swig_object_dir = dirname($f) ;
|
|
||||||
($swig_file_only) = ($f =~ /([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/) ;
|
|
||||||
print MAKEFILE" \\\n \$(CURDIR)/build$swig_object_dir/py_${swig_file_only}.o" ;
|
|
||||||
}
|
|
||||||
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" ;
|
|
||||||
|
|
||||||
my %swig_dirs ;
|
|
||||||
my %python_modules ;
|
|
||||||
$ii = 0 ;
|
|
||||||
foreach my $f ( @temp_array2 ) {
|
|
||||||
|
|
||||||
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 = "" ;
|
|
||||||
push @{$python_modules{"root"}} , $f ;
|
|
||||||
}
|
|
||||||
|
|
||||||
my ($continue) = 1 ;
|
|
||||||
foreach my $ie ( @exclude_dirs ) {
|
|
||||||
# if file location begins with $ie (an IGC exclude dir)
|
|
||||||
if ( $f =~ /^\Q$ie/ ) {
|
|
||||||
$continue = 0 ;
|
|
||||||
$ii++ ;
|
|
||||||
last ; # break out of loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
next if ( $continue == 0 ) ;
|
|
||||||
|
|
||||||
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}) ;
|
|
||||||
exit -1 ;
|
|
||||||
}
|
|
||||||
$swig_f =~ s/([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx)$/$1.i/ ;
|
|
||||||
$swig_file_only = $1 ;
|
|
||||||
my $link_py_obj = "build" . dirname($swig_f) . "/py_${swig_file_only}.o";
|
|
||||||
$swig_f = "\$(CURDIR)/build" . $swig_f ;
|
|
||||||
$swig_dir = dirname($swig_f) ;
|
|
||||||
$swig_object_dir = dirname($swig_f) ;
|
|
||||||
$swig_dirs{$swig_dir} = 1 ;
|
|
||||||
|
|
||||||
print MAKEFILE "$swig_object_dir/py_${swig_file_only}.o : $swig_f\n" ;
|
|
||||||
print MAKEFILE "\t\$(PRINT_SWIG)\n" ;
|
|
||||||
print MAKEFILE "\t\$(ECHO_CMD)\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) \$(SWIG_FLAGS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir trick -o $swig_dir/py_${swig_file_only}.cpp \$<\n" ;
|
|
||||||
print MAKEFILE "\t\$(PRINT_COMPILE_SWIG)\n" ;
|
|
||||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_IO_CXXFLAGS) \$(SWIG_CFLAGS) -c $swig_dir/py_${swig_file_only}.cpp -o \$@\n\n" ;
|
|
||||||
print LINK_PY_OBJS "$link_py_obj\n" ;
|
|
||||||
|
|
||||||
$ii++ ;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach $m ( keys %python_modules ) {
|
|
||||||
next if ( $m eq "root") ;
|
|
||||||
my ($temp_str) = $m ;
|
|
||||||
$temp_str =~ s/\./\//g ;
|
|
||||||
print MAKEFILE "$swig_sim_dir/$m:\n" ;
|
|
||||||
print MAKEFILE "\tmkdir -p \$@\n\n" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
my $wd = abs_path(cwd()) ;
|
|
||||||
|
|
||||||
print MAKEFILE "
|
|
||||||
\$(SWIG_MODULE_OBJECTS) : TRICK_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls
|
|
||||||
|
|
||||||
\$(S_MAIN): \$(SWIG_MODULE_OBJECTS)
|
|
||||||
|
|
||||||
\$(SWIG_MODULE_OBJECTS) : \$(SWIG_PY_OBJECTS) | \$(LIB_DIR)
|
|
||||||
\t\$(PRINT_SWIG_INC_LINK)
|
|
||||||
\t\$(ECHO_CMD)ld \$(LD_PARTIAL) -o \$\@ \$(LD_FILELIST)build/link_py_objs
|
|
||||||
\n\n" ;
|
|
||||||
|
|
||||||
print MAKEFILE "$swig_src_dir/py_top.cpp : $swig_src_dir/top.i\n" ;
|
|
||||||
print MAKEFILE "\t\$(PRINT_SWIG)\n" ;
|
|
||||||
print MAKEFILE "\t\$(ECHO_CMD)\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,303,362,389,401,451 -outdir $swig_sim_dir -o \$@ \$<\n\n" ;
|
|
||||||
|
|
||||||
print MAKEFILE "$swig_src_dir/py_top.o : $swig_src_dir/py_top.cpp\n" ;
|
|
||||||
print MAKEFILE "\t\$(PRINT_COMPILE_SWIG)\n" ;
|
|
||||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
|
|
||||||
|
|
||||||
print MAKEFILE "$swig_src_dir/init_swig_modules.o : $swig_src_dir/init_swig_modules.cpp\n" ;
|
|
||||||
print MAKEFILE "\t\$(PRINT_COMPILE_SWIG)\n" ;
|
|
||||||
print MAKEFILE "\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ;
|
|
||||||
|
|
||||||
print MAKEFILE "TRICK_FIXED_PYTHON = \\
|
|
||||||
$swig_sim_dir/swig_double.py \\
|
|
||||||
$swig_sim_dir/swig_int.py \\
|
|
||||||
$swig_sim_dir/swig_ref.py \\
|
|
||||||
$swig_sim_dir/shortcuts.py \\
|
|
||||||
$swig_sim_dir/unit_test.py \\
|
|
||||||
$swig_sim_dir/sim_services.py \\
|
|
||||||
$swig_sim_dir/exception.py\n\n" ;
|
|
||||||
print MAKEFILE "S_main: \$(TRICK_FIXED_PYTHON)\n\n" ;
|
|
||||||
|
|
||||||
print MAKEFILE "\$(TRICK_FIXED_PYTHON) : $swig_sim_dir/\% : \${TRICK_HOME}/share/trick/swig/\%\n" ;
|
|
||||||
print MAKEFILE "\t\$(ECHO_CMD)/bin/cp \$< \$@\n\n" ;
|
|
||||||
|
|
||||||
foreach (keys %swig_dirs) {
|
|
||||||
print MAKEFILE "$_:\n" ;
|
|
||||||
print MAKEFILE "\tmkdir -p $_\n\n" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
print MAKEFILE "\n" ;
|
|
||||||
close MAKEFILE ;
|
|
||||||
close LINK_PY_OBJS ;
|
|
||||||
|
|
||||||
open SWIGLIB , ">build/S_library_swig" or return ;
|
|
||||||
foreach my $f ( @temp_array2 ) {
|
|
||||||
print SWIGLIB "$f\n" ;
|
|
||||||
}
|
|
||||||
close SWIGLIB ;
|
|
||||||
|
|
||||||
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 "\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} ;" ;
|
|
||||||
}
|
|
||||||
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" ;
|
|
||||||
}
|
|
||||||
print INITSWIGFILE "void init_sim_services(void) ;\n" ;
|
|
||||||
print INITSWIGFILE "void init_top(void) ;\n" ;
|
|
||||||
print INITSWIGFILE "void init_swig_double(void) ;\n" ;
|
|
||||||
print INITSWIGFILE "void init_swig_int(void) ;\n" ;
|
|
||||||
print INITSWIGFILE "void init_swig_ref(void) ;\n" ;
|
|
||||||
|
|
||||||
print INITSWIGFILE "\nvoid init_swig_modules(void) {\n\n" ;
|
|
||||||
foreach $f ( @temp_array2 ) {
|
|
||||||
next if ( $f =~ /S_source.hh/ ) ;
|
|
||||||
my $md5_sum = md5_hex($f) ;
|
|
||||||
print INITSWIGFILE " init_m${md5_sum}() ;\n" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
print INITSWIGFILE " init_m${s_source_md5}() ;\n" ;
|
|
||||||
|
|
||||||
print INITSWIGFILE " init_sim_services() ;\n" ;
|
|
||||||
print INITSWIGFILE " init_top() ;\n" ;
|
|
||||||
print INITSWIGFILE " init_swig_double() ;\n" ;
|
|
||||||
print INITSWIGFILE " init_swig_int() ;\n" ;
|
|
||||||
print INITSWIGFILE " init_swig_ref() ;\n" ;
|
|
||||||
print INITSWIGFILE " return ;\n}\n\n}\n" ;
|
|
||||||
close INITSWIGFILE ;
|
|
||||||
|
|
||||||
open INITFILE , ">trick/__init__.py" or return ;
|
|
||||||
|
|
||||||
print INITFILE "import sys\n" ;
|
|
||||||
print INITFILE "import os\n" ;
|
|
||||||
print INITFILE "sys.path.append(os.getcwd() + \"/trick\")\n" ;
|
|
||||||
|
|
||||||
foreach $m ( keys %python_modules ) {
|
|
||||||
next if ( $m eq "root") ;
|
|
||||||
my ($temp_str) = $m ;
|
|
||||||
$temp_str =~ s/\./\//g ;
|
|
||||||
print INITFILE "sys.path.append(os.getcwd() + \"/trick/$temp_str\")\n" ;
|
|
||||||
}
|
|
||||||
print INITFILE "\n" ;
|
|
||||||
print INITFILE "import _sim_services\n" ;
|
|
||||||
print INITFILE "from sim_services import *\n\n" ;
|
|
||||||
|
|
||||||
print INITFILE "# create \"all_cvars\" to hold all global/static vars\n" ;
|
|
||||||
print INITFILE "all_cvars = new_cvar_list()\n" ;
|
|
||||||
print INITFILE "combine_cvars(all_cvars, cvar)\n" ;
|
|
||||||
print INITFILE "cvar = None\n\n" ;
|
|
||||||
|
|
||||||
foreach $m ( keys %python_modules ) {
|
|
||||||
next if ( $m eq "root") ;
|
|
||||||
my ($temp_str) = $m ;
|
|
||||||
$temp_str =~ s/\//\./g ;
|
|
||||||
print INITFILE "import $temp_str\n" ;
|
|
||||||
}
|
|
||||||
print INITFILE "\n" ;
|
|
||||||
|
|
||||||
foreach $f ( @{$python_modules{"root"}} ) {
|
|
||||||
next if ( $f =~ /S_source.hh/ ) ;
|
|
||||||
my $md5_sum = md5_hex($f) ;
|
|
||||||
print INITFILE "# $f\n" ;
|
|
||||||
print INITFILE "import _m${md5_sum}\n" ;
|
|
||||||
print INITFILE "from m${md5_sum} import *\n" ;
|
|
||||||
print INITFILE "combine_cvars(all_cvars, cvar)\n" ;
|
|
||||||
print INITFILE "cvar = None\n\n" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
print INITFILE "# S_source.hh\n" ;
|
|
||||||
print INITFILE "import _m${s_source_md5}\n" ;
|
|
||||||
print INITFILE "from m${s_source_md5} import *\n\n" ;
|
|
||||||
print INITFILE "import _top\n" ;
|
|
||||||
print INITFILE "import top\n\n" ;
|
|
||||||
print INITFILE "import _swig_double\n" ;
|
|
||||||
print INITFILE "import swig_double\n\n" ;
|
|
||||||
print INITFILE "import _swig_int\n" ;
|
|
||||||
print INITFILE "import swig_int\n\n" ;
|
|
||||||
print INITFILE "import _swig_ref\n" ;
|
|
||||||
print INITFILE "import swig_ref\n\n" ;
|
|
||||||
print INITFILE "from shortcuts import *\n\n" ;
|
|
||||||
print INITFILE "from exception import *\n\n" ;
|
|
||||||
print INITFILE "cvar = all_cvars\n\n" ;
|
|
||||||
close INITFILE ;
|
|
||||||
|
|
||||||
foreach $m ( keys %python_modules ) {
|
|
||||||
next if ( $m eq "root") ;
|
|
||||||
my ($temp_str) = $m ;
|
|
||||||
$temp_str =~ s/\./\//g ;
|
|
||||||
if ( ! -e "trick/$temp_str" ) {
|
|
||||||
mkpath("trick/$temp_str", {mode=>0775}) ;
|
|
||||||
}
|
|
||||||
open INITFILE , ">trick/$temp_str/__init__.py" or return ;
|
|
||||||
foreach $f ( @{$python_modules{$m}} ) {
|
|
||||||
next if ( $f =~ /S_source.hh/ ) ;
|
|
||||||
my $md5_sum = md5_hex($f) ;
|
|
||||||
print INITFILE "# $f\n" ;
|
|
||||||
print INITFILE "import _m${md5_sum}\n" ;
|
|
||||||
print INITFILE "from m${md5_sum} import *\n\n" ;
|
|
||||||
}
|
|
||||||
close INITFILE ;
|
|
||||||
|
|
||||||
while ( $temp_str =~ s/\/.*?$// ) {
|
|
||||||
open INITFILE , ">trick/$temp_str/__init__.py" or return ;
|
|
||||||
close INITFILE ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
/usr/java/jdk1.6.0/bin/java -classpath ./java/dist/trick.jar trick.test.Client
|
|
@ -24,17 +24,13 @@ export TRICK_ICG_EXCLUDE
|
|||||||
# Use /bin/bash as the shell so we can use PIPESTATUS
|
# Use /bin/bash as the shell so we can use PIPESTATUS
|
||||||
SHELL = /bin/bash
|
SHELL = /bin/bash
|
||||||
|
|
||||||
all : ${TRICK_LIB_DIR}/libtrick.a S_source.hh \
|
all test : ${TRICK_LIB_DIR}/libtrick.a S_source.hh \
|
||||||
$(CURDIR)/build/Makefile_io_src \
|
$(CURDIR)/build/Makefile_io_src \
|
||||||
$(CURDIR)/build/Makefile_src \
|
$(CURDIR)/build/Makefile_src \
|
||||||
$(CURDIR)/build/Makefile_swig \
|
$(CURDIR)/build/Makefile_swig \
|
||||||
$(CURDIR)/build/convert_swig_last_run
|
$(CURDIR)/build/convert_swig_last_run \
|
||||||
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt build/MAKE_out
|
$(CURDIR)/build/MAKE_out
|
||||||
@$(MAKE) --no-print-directory -f build/Makefile_src all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
@$(MAKE) --no-print-directory -f build/Makefile_src $@ 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
||||||
|
|
||||||
#test : ${TRICK_LIB_DIR}/libtrick.a build/Makefile_sim $(CURDIR)/build/class_map.cpp $(CURDIR)/build/convert_swig_last_run
|
|
||||||
# @/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt build/MAKE_out
|
|
||||||
# @$(MAKE) --no-print-directory -f build/Makefile_sim test_all 2>&1 | tee -a build/MAKE_out ; exit $${PIPESTATUS[0]}
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir $@
|
mkdir $@
|
||||||
@ -46,6 +42,9 @@ ${TRICK_LIB_DIR}/libtrick.a:
|
|||||||
@echo "Cannot find $@. Please build Trick for this platfrom"
|
@echo "Cannot find $@. Please build Trick for this platfrom"
|
||||||
@exit -1
|
@exit -1
|
||||||
|
|
||||||
|
$(CURDIR)/build/MAKE_out : | build
|
||||||
|
@/bin/cp ${TRICK_HOME}/share/trick/MAKE_out_header.txt $@
|
||||||
|
|
||||||
# CP creates S_source.hh required for ICG and SWIG processing
|
# CP creates S_source.hh required for ICG and SWIG processing
|
||||||
S_source.hh : S_define | build
|
S_source.hh : S_define | build
|
||||||
$(PRINT_CP)
|
$(PRINT_CP)
|
||||||
@ -118,7 +117,6 @@ apocalypse: clean
|
|||||||
|
|
||||||
|
|
||||||
# Dependencies for the above rules generated by configuration_process, ICG, make_makefile and make_makefile_swig
|
# Dependencies for the above rules generated by configuration_process, ICG, make_makefile and make_makefile_swig
|
||||||
#-include S_overrides.mk
|
|
||||||
-include build/S_define.deps
|
-include build/S_define.deps
|
||||||
-include build/Makefile_ICG
|
-include build/Makefile_ICG
|
||||||
-include build/Makefile_convert_swig
|
-include build/Makefile_convert_swig
|
||||||
|
@ -400,6 +400,7 @@ void PrintAttributes::printIOMakefile() {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "[34mCreating/updating io_src Makefile[0m" << std::endl ;
|
||||||
makefile_io_src.open("build/Makefile_io_src") ;
|
makefile_io_src.open("build/Makefile_io_src") ;
|
||||||
|
|
||||||
makefile_io_src << "TRICK_IO_CXXFLAGS := \\" << std::endl ;
|
makefile_io_src << "TRICK_IO_CXXFLAGS := \\" << std::endl ;
|
||||||
|
Loading…
Reference in New Issue
Block a user