S_overrides.mk is included twice when building #360

A different approach.  Instead of trying to limit the number of times
S_overrides.mk is included, combine the makefiles so only one
call to make is made.
This commit is contained in:
Alex Lin 2017-02-09 09:42:16 -06:00
parent 3db5056db3
commit 337139cacb
7 changed files with 137 additions and 47 deletions

View File

@ -52,13 +52,108 @@ ifndef TRICK_HOME
export TRICK_HOME := SUB_TRICK_HOME export TRICK_HOME := SUB_TRICK_HOME
endif endif
-include ${TRICK_HOME}/share/trick/makefiles/Makefile.sim ifneq ($(wildcard ${TRICK_HOME}/share/trick/makefiles/Makefile.common),)
-include S_overrides.mk include ${TRICK_HOME}/share/trick/makefiles/Makefile.common
ifndef CLEAN_RULES_DEFINED ifndef TRICK_VERBOSE_BUILD
no_makefile_sim: PRINT_CP = $(info $(call COLOR,Running) configuration_processor)
@echo ${TRICK_HOME}/share/trick/makefiles/Makefile.sim not found PRINT_ICG = $(info $(call COLOR,Running) ICG)
exit -1 PRINT_S_DEF_DEPS = $(info $(call COLOR,Tracing) S_define)
PRINT_CONVERT_SWIG = $(info $(call COLOR,Running) convert_swig)
PRINT_MAKEFILE_SRC = $(info $(call COLOR,Writing) Makefile_src)
PRINT_MAKEFILE_SWIG = $(info $(call COLOR,Writing) Makefile_swig)
endif
all test: $(TRICK_STATIC_LIB) S_source.hh \
build/Makefile_io_src \
build/Makefile_src \
build/Makefile_swig \
build/convert_swig_last_run \
S_main
build:
@mkdir $@
debug: all
debug: TRICK_CPFLAGS += --debug
$(TRICK_STATIC_LIB):
$(info Cannot find $@. Please build Trick for this platform.)
@exit -1
# CP creates S_source.hh required for ICG and SWIG processing
S_source.hh build/S_define.lib_deps: S_define | build
$(PRINT_CP)
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS)
$(PRINT_S_DEF_DEPS)
$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_SFLAGS) $(TRICK_SYSTEM_SFLAGS) -M -MT S_source.hh -MF build/S_define.deps -x c++ S_define
# Automatic and manual ICG rules
build/Makefile_io_src: | S_source.hh build
$(PRINT_ICG)
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh
ICG:
$(PRINT_ICG)
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh
force_ICG:
$(PRINT_ICG)
$(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -f -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh
# Create makefile for source code
build/Makefile_src: | build/Makefile_io_src build/S_define.lib_deps
$(PRINT_MAKEFILE_SRC)
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_src $?
# Create makefile for SWIG code
build/Makefile_swig: | build/Makefile_io_src
$(PRINT_MAKEFILE_SWIG)
$(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/make_makefile_swig $?
# Automatic and manual convert_swig rules
build/convert_swig_last_run: | 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 build/convert_swig_last_run
# Force S_define_exp to be remade each time this rule runs
.PHONY: S_define_exp
S_define_exp:
$(TRICK_CC) -E -C -xc++ ${TRICK_SFLAGS} $(TRICK_SYSTEM_SFLAGS) S_define > $@
help:
@echo -e "\
Simulation make options:\n\
make [debug] [TRICK_VERBOSE_BUILD=1] - Makes everything: S_main and S_sie.resource\n\
make sie - Builds the S_sie.resource file.\n\
make clean - Removes all object files in simulation directory\n\
make spotless - Performs a clean\n\
make apocalypse - Performs a clean"
CLEAN_TARGETS = tidy clean spotless distclean apocalypse
ifeq ($(findstring ${MAKECMDGOALS},$(CLEAN_TARGETS)),)
-include S_overrides.mk
-include build/S_define.deps
-include build/Makefile_src
-include build/Makefile_src_deps
-include build/Makefile_io_src
-include build/Makefile_swig
-include build/Makefile_ICG
-include build/Makefile_convert_swig
-include build/Makefile_src_deps
endif
else
all:
$(error error with TRICK_HOME, cannot find ${TRICK_HOME}/share/trick/makefiles/Makefile.common)
endif
tidy: tidy:
-rm -f S_source.hh S_sie.resource -rm -f S_source.hh S_sie.resource
@ -70,7 +165,6 @@ clean: tidy
-rm -f DP_Product/DP_rt_frame DP_Product/DP_rt_itimer -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 DP_Product/DP_rt_jobs DP_Product/DP_rt_timeline DP_Product/DP_mem_stats
-rm -rf build trick -rm -rf build trick
@ echo "Removed build directory"
spotless: clean spotless: clean
@ -79,4 +173,4 @@ distclean: clean
apocalypse: distclean apocalypse: distclean
@echo "I love the smell of napalm in the morning" @echo "I love the smell of napalm in the morning"
endif

View File

@ -146,7 +146,7 @@ if ( scalar @ARGV == 0 ) {
$swig_dir = dirname($f) ; $swig_dir = dirname($f) ;
$swig_dir = "build/$swig_dir" ; $swig_dir = "build/$swig_dir" ;
$swig_file = "$swig_dir/${base_file}.i" ; $swig_file = "$swig_dir/py_${base_file}.i" ;
#print "$swig_file\n" ; #print "$swig_file\n" ;
if ( -e $swig_file ) { if ( -e $swig_file ) {
@ -275,6 +275,7 @@ sub process_file() {
if ( $exclude == 0 ) { if ( $exclude == 0 ) {
$file_name =~ s/\.[^\.]+\"/\.i\"/ ; $file_name =~ s/\.[^\.]+\"/\.i\"/ ;
$file_name = dirname($file_name) . "/py_" . basename($file_name) ;
} }
$contents .= "\%import $file_name\n" ; $contents .= "\%import $file_name\n" ;
} else { } else {
@ -301,7 +302,7 @@ sub process_file() {
$out_file = basename($f) ; $out_file = basename($f) ;
$out_file =~ s/\.h.*$/\.i/ ; $out_file =~ s/\.h.*$/\.i/ ;
$out_file = "$out_dir/$out_file" ; $out_file = "$out_dir/py_$out_file" ;
if ( ! -e $out_dir ) { if ( ! -e $out_dir ) {
make_path($out_dir) ; make_path($out_dir) ;

View File

@ -227,14 +227,6 @@ print MAKEFILE
# #
################################################################################ ################################################################################
include \${TRICK_HOME}/share/trick/makefiles/Makefile.common
S_MAIN = S_main_\${TRICK_HOST_CPU}.exe
ifeq (\$(MAKECMDGOALS), test)
TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
S_MAIN = T_main_\${TRICK_HOST_CPU}.exe
endif
ifndef TRICK_VERBOSE_BUILD ifndef TRICK_VERBOSE_BUILD
PRINT_COMPILE = \$(info \$(call COLOR,Compiling) \$<) PRINT_COMPILE = \$(info \$(call COLOR,Compiling) \$<)
PRINT_EXE_LINK = \$(info \$(call COLOR,Linking) \$@) PRINT_EXE_LINK = \$(info \$(call COLOR,Linking) \$@)
@ -336,12 +328,6 @@ foreach $k ( sort keys %files_by_dir ) {
} }
} }
print MAKEFILE "
-include build/Makefile_io_src
include build/Makefile_swig
-include S_overrides.mk" ;
close MAKEFILE ;
# write out all of files we processed as dependencies to Makefile_src # write out all of files we processed as dependencies to Makefile_src
open MAKEFILEDEPS, ">build/Makefile_src_deps" or die "Could not open build/Makefile_src_deps" ; open MAKEFILEDEPS, ">build/Makefile_src_deps" or die "Could not open build/Makefile_src_deps" ;
print MAKEFILEDEPS "build/Makefile_src:" ; print MAKEFILEDEPS "build/Makefile_src:" ;

View File

@ -166,7 +166,7 @@ sub make_swig_makefile() {
open MAKEFILE , ">build/Makefile_swig" or return ; open MAKEFILE , ">build/Makefile_swig" or return ;
open PY_LINK_LIST , ">build/py_link_list" or return ; open PY_LINK_LIST , ">build/py_link_list" or return ;
print PY_LINK_LIST "build/init_swig_modules.o\n" ; print PY_LINK_LIST "build/init_swig_modules.o\n" ;
print PY_LINK_LIST "build/py_top.o\n" ; print PY_LINK_LIST "build/top.o\n" ;
print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers print MAKEFILE "SWIG_CFLAGS := -I../include \${PYTHON_INCLUDES} -Wno-shadow -Wno-missing-field-initializers
@ -179,17 +179,20 @@ ifndef TRICK_VERBOSE_BUILD
PRINT_COMPILE_SWIG = \$(info \$(call COLOR,Compiling) \$<) PRINT_COMPILE_SWIG = \$(info \$(call COLOR,Compiling) \$<)
endif endif
SWIG_OBJECTS =" ; SWIG_I =" ;
foreach my $f ( @files_to_process ) { foreach my $f ( @files_to_process ) {
my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ; my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ;
my ($swig_f) = $f ; my ($swig_f) = $f ;
$swig_object_dir = dirname($f) ; $swig_object_dir = dirname($f) ;
($swig_file_only) = ($f =~ /([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx|\.hpp)$/) ; ($swig_file_only) = ($f =~ /([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx|\.hpp)$/) ;
print MAKEFILE" \\\n build$swig_object_dir/py_${swig_file_only}.o" ; print MAKEFILE" \\\n build$swig_object_dir/py_${swig_file_only}.i" ;
} }
print MAKEFILE "\\\n $swig_src_dir/top.i\n" ;
print MAKEFILE "\nSWIG_SRC = \$(subst .i,.cpp,\$(SWIG_I))\n" ;
print MAKEFILE "\nSWIG_OBJECTS = \$(subst .cpp,.o,\$(SWIG_SRC))\n" ;
print MAKEFILE "OTHER_SWIG_OBJECTS =" ;
print MAKEFILE "\\\n $swig_src_dir/init_swig_modules.o" ; print MAKEFILE "\\\n $swig_src_dir/init_swig_modules.o" ;
print MAKEFILE "\\\n $swig_src_dir/py_top.o\n" ;
print MAKEFILE " print MAKEFILE "
TRICK_FIXED_PYTHON = \\ TRICK_FIXED_PYTHON = \\
@ -202,12 +205,11 @@ TRICK_FIXED_PYTHON = \\
$swig_sim_dir/exception.py $swig_sim_dir/exception.py
" ; " ;
my %swig_dirs ;
my %python_modules ; my %python_modules ;
$ii = 0 ; $ii = 0 ;
foreach my $f ( @files_to_process ) { foreach my $f ( @files_to_process ) {
my ($swig_dir, $swig_object_dir , $swig_module_dir , $swig_file_only) ; my ($swig_module_dir , $swig_file_only) ;
my ($swig_f) = $f ; my ($swig_f) = $f ;
# TODO: Add back python modules # TODO: Add back python modules
@ -224,7 +226,6 @@ TRICK_FIXED_PYTHON = \\
push @{$python_modules{"root"}} , $f ; push @{$python_modules{"root"}} , $f ;
# } # }
my $md5_sum = md5_hex($f) ;
# check if .sm file was accidentally ##included instead of #included # check if .sm file was accidentally ##included instead of #included
if ( rindex($swig_f,".sm") != -1 ) { 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}) ;
@ -233,11 +234,6 @@ TRICK_FIXED_PYTHON = \\
$swig_f =~ s/([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx|\.hpp)$/$1.i/ ; $swig_f =~ s/([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx|\.hpp)$/$1.i/ ;
$swig_file_only = $1 ; $swig_file_only = $1 ;
my $link_py_obj = "build" . dirname($swig_f) . "/py_${swig_file_only}.o"; my $link_py_obj = "build" . dirname($swig_f) . "/py_${swig_file_only}.o";
$swig_f = "build" . $swig_f ;
$swig_dir = dirname($swig_f) ;
$swig_object_dir = dirname($swig_f) ;
$swig_dirs{$swig_dir} = 1 ;
print PY_LINK_LIST "$link_py_obj\n" ; print PY_LINK_LIST "$link_py_obj\n" ;
$ii++ ; $ii++ ;
@ -256,7 +252,7 @@ TRICK_FIXED_PYTHON = \\
print MAKEFILE " print MAKEFILE "
LINK_LISTS += \$(LD_FILELIST)build/py_link_list LINK_LISTS += \$(LD_FILELIST)build/py_link_list
\$(S_MAIN): \$(SWIG_OBJECTS) \$(S_MAIN): \$(SWIG_OBJECTS) \$(OTHER_SWIG_OBJECTS)
#\$(SWIG_OBJECTS): TRICK_SYSTEM_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls #\$(SWIG_OBJECTS): TRICK_SYSTEM_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls
@ -265,17 +261,17 @@ S_main: \$(TRICK_FIXED_PYTHON)
\$(TRICK_FIXED_PYTHON): $swig_sim_dir/\% : \${TRICK_HOME}/share/trick/swig/\% \$(TRICK_FIXED_PYTHON): $swig_sim_dir/\% : \${TRICK_HOME}/share/trick/swig/\%
\t\$(ECHO_CMD)/bin/cp -f \$< \$@ \t\$(ECHO_CMD)/bin/cp -f \$< \$@
py_%.cpp: %.i \$(SWIG_SRC) : %.cpp: %.i
\t\$(PRINT_SWIG) \t\$(PRINT_SWIG)
\t\$(ECHO_CMD)\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) \$(SWIG_FLAGS) -c++ -python -includeall -ignoremissing -w201,303,325,362,389,401,451 -outdir trick -o \$@ \$< \t\$(ECHO_CMD)\$(SWIG) \$(TRICK_INCLUDE) \$(TRICK_DEFINES) \$(TRICK_VERSIONS) \$(SWIG_FLAGS) -c++ -python -includeall -ignoremissing -w201,303,325,362,389,401,451 -outdir trick -o \$@ \$<
\$(SWIG_OBJECTS): %.o: %.cpp \$(SWIG_I) : build/convert_swig_last_run
\$(SWIG_OBJECTS) \$(OTHER_SWIG_OBJECTS): %.o: %.cpp
\t\$(PRINT_COMPILE_SWIG) \t\$(PRINT_COMPILE_SWIG)
\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_SYSTEM_CXXFLAGS) \$(SWIG_CFLAGS) -c -o \$@ \$< \t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_SYSTEM_CXXFLAGS) \$(SWIG_CFLAGS) -c -o \$@ \$<
# We don't really need to keep these, but make prints out a huge \"rm -f\" when it automatically " ;
# deletes intermediate files, and I don't know how to silence that.
.PRECIOUS: py_%.cpp" ;
close MAKEFILE ; close MAKEFILE ;
close PY_LINK_LIST ; close PY_LINK_LIST ;
@ -294,7 +290,7 @@ py_%.cpp: %.i
print TOPFILE "\%{\n#include \"../S_source.hh\"\n\n" ; print TOPFILE "\%{\n#include \"../S_source.hh\"\n\n" ;
print TOPFILE @instances ; print TOPFILE @instances ;
print TOPFILE "\n\%}\n\n" ; print TOPFILE "\n\%}\n\n" ;
print TOPFILE "\%import \"build$wd/S_source.i\"\n\n" ; print TOPFILE "\%import \"build$wd/py_S_source.i\"\n\n" ;
print TOPFILE @instances ; print TOPFILE @instances ;
close TOPFILE ; close TOPFILE ;

View File

@ -58,11 +58,18 @@ export TRICK_SYSTEM_SFLAGS
export TRICK_SYSTEM_LDFLAGS export TRICK_SYSTEM_LDFLAGS
export SWIG_FLAGS export SWIG_FLAGS
S_MAIN = S_main_${TRICK_HOST_CPU}.exe
ifeq ($(MAKECMDGOALS), test)
TRICK_HOST_CPU := $(shell $(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test
S_MAIN = T_main_${TRICK_HOST_CPU}.exe
endif
IO_SRC_DIR := io_src/ IO_SRC_DIR := io_src/
OBJ_DIR := object_${TRICK_HOST_CPU} OBJ_DIR := object_${TRICK_HOST_CPU}
TRICK_STATIC_LIB := ${TRICK_LIB_DIR}/libtrick.a TRICK_STATIC_LIB := ${TRICK_LIB_DIR}/libtrick.a
TRICK_RANLIB = TRICK_RANLIB =
ifndef CONFIG_MK ifndef CONFIG_MK
ifneq ($(MAKECMDGOALS), clean) ifneq ($(MAKECMDGOALS), clean)
$(error Please run $(TRICK_HOME)/configure before running make) $(error Please run $(TRICK_HOME)/configure before running make)

View File

@ -78,7 +78,7 @@ TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../../..)
ifneq ($(wildcard build),) ifneq ($(wildcard build),)
OBJECTS := $(shell find build -name "*.i") OBJECTS := $(shell find build -name "*.i")
OBJECTS := $(join $(dir $(OBJECTS)),$(patsubst %.i,py_%.cpp,$(notdir $(OBJECTS)))) OBJECTS := $(join $(dir $(OBJECTS)),$(patsubst %.i,%.cpp,$(notdir $(OBJECTS))))
OBJECTS += $(shell find build -name "*.cpp") OBJECTS += $(shell find build -name "*.cpp")
OBJECTS := $(OBJECTS:.cpp=.o) OBJECTS := $(OBJECTS:.cpp=.o)
endif endif
@ -158,7 +158,7 @@ icg:
$(dir $(TRICKIFY_LIB_NAME)) $(TRICKIFY_PYTHON_DIR): $(dir $(TRICKIFY_LIB_NAME)) $(TRICKIFY_PYTHON_DIR):
@mkdir -p $@ @mkdir -p $@
py_%.cpp: %.i | $(TRICKIFY_PYTHON_DIR) %.cpp: %.i | $(TRICKIFY_PYTHON_DIR)
$(info $(call COLOR,SWIGing) $<) $(info $(call COLOR,SWIGing) $<)
@$(SWIG) $(TRICK_INCLUDE) $(TRICK_DEFINES) $(TRICK_VERSIONS) $(SWIG_FLAGS) -c++ -python -includeall -ignoremissing -w201,303,325,362,389,401,451 -outdir $(TRICKIFY_PYTHON_DIR) -o $@ $< @$(SWIG) $(TRICK_INCLUDE) $(TRICK_DEFINES) $(TRICK_VERSIONS) $(SWIG_FLAGS) -c++ -python -includeall -ignoremissing -w201,303,325,362,389,401,451 -outdir $(TRICKIFY_PYTHON_DIR) -o $@ $<

View File

@ -54,8 +54,14 @@ void FindTrickICG::If(clang::SourceLocation Loc, clang::SourceRange ConditionRan
if ( print_msgs ) { if ( print_msgs ) {
print_header() ; print_header() ;
std::string loc_str = Loc.printToString(ci.getSourceManager()) ; std::string loc_str = Loc.printToString(ci.getSourceManager()) ;
std::cout << color(WARNING, char * rpath = almostRealPath(loc_str.c_str()) ;
std::string("Warning: TRICK_ICG used in preprocessor conditional ") + loc_str) << std::endl ; if ( rpath ) {
std::cout << color(WARNING,
std::string("Warning: TRICK_ICG used in preprocessor conditional ") + rpath) << std::endl ;
} else {
std::cout << color(WARNING,
std::string("Warning: TRICK_ICG used in preprocessor conditional ") + loc_str) << std::endl ;
}
} }
} }
} }