diff --git a/libexec/trick/configuration_processor b/libexec/trick/configuration_processor index c55246e4..c8e98a4d 100755 --- a/libexec/trick/configuration_processor +++ b/libexec/trick/configuration_processor @@ -64,27 +64,29 @@ if ( $sim{args}{p} == 0 ) { #-------------------------------------------------------------- # Parse the S_define file -trick_print($sim{fh}, "Parsing S_define..." , "title_cyan" , $sim{args}{v}) ; +trick_print($sim{fh}, "Parsing " , "title_blue" , $sim{args}{v}) ; +trick_print($sim{fh}, "S_define" , "title_white" , $sim{args}{v}) ; trick_print($sim{fh}, "\n" , "title_white" , $sim{args}{v}) if ( $sim{args}{v} != 1 ) ; parse_s_define(\%sim) ; -trick_print( $sim{fh}, "\nCompleted parsing S_define\n\n" , "normal_green" , $ sim{args}{v} ) ; +trick_print( $sim{fh}, "Finished " , "normal_blue" , $ sim{args}{v} ) ; +trick_print( $sim{fh}, "S_define\n" , "normal_white" , $ sim{args}{v} ) ; #-------------------------------------------------------------- -# Make S_source.c +# Make S_source.c -trick_print($sim{fh}, "Creating S_source.c...", "title_cyan", $sim{args}{v}); +trick_print($sim{fh}, "Writing ", "title_blue", $sim{args}{v}); +trick_print($sim{fh}, "S_source.c\n", "title_white", $sim{args}{v}); s_source( \%sim ) ; -trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ; #-------------------------------------------------------------- # Make Default Data chdir ($cwd) ; -trick_print($sim{fh}, "Creating Default_data...", "title_cyan" , $sim{args}{v}) ; +trick_print($sim{fh}, "Writing ", "title_blue" , $sim{args}{v}) ; +trick_print($sim{fh}, "Default_data\n", "title_white" , $sim{args}{v}) ; make_default_data( \%sim ) ; -trick_print($sim{fh}, " Complete\n", "title_green", $sim{args}{v}) ; close OUTFILE ; diff --git a/libexec/trick/convert_swig b/libexec/trick/convert_swig index afe92f3d..f07942db 100755 --- a/libexec/trick/convert_swig +++ b/libexec/trick/convert_swig @@ -360,7 +360,7 @@ sub process_file() { } close OUT ; - print "Writing swig_file $out_file\n" ; + print "Writing $out_file\n" ; } } diff --git a/libexec/trick/make_build b/libexec/trick/make_build deleted file mode 100755 index 8394f961..00000000 --- a/libexec/trick/make_build +++ /dev/null @@ -1,458 +0,0 @@ -#! /usr/bin/perl - -################################################################################ -# Program: make_build -# -# This program constructs Makefiles for model directories in -# /. -# -# Command Syntax: make_build -# -#******************************************************************* - -use lib $ENV{"TRICK_HOME"} . "/bin/pm" ; -use Cwd ; -use File::Basename ; -use trick_version ; - -############################################################################### -# Process command line options -############################################################################### - -$lib_file = ""; - -# Check calling args. -if ( @ARGV[0] ne "") { - if ( @ARGV[0] eq "lib" and @ARGV[1] ne "" ) { - $lib_file = @ARGV[1]; - if ( $lib_file !~ /\.a$/ ) { - print "USAGE: make_build lib lib_file_name.a\n"; - exit; - } - $lib_file =~ s/lib.*?\/// ; - $lib_file = "lib_\${TRICK_HOST_CPU}/$lib_file"; - } - elsif ( @ARGV[0] eq "sharedlib" and @ARGV[1] ne "" ) { - $sharedlib_file = @ARGV[1]; - if ( $sharedlib_file !~ /\.so$/ ) { - print "USAGE: make_build sharedlib lib_file_name.so\n"; - exit; - } - $sharedlib_file =~ s/lib.*?\/// ; - $sharedlib_file = "lib_\${TRICK_HOST_CPU}/$sharedlib_file"; - $lib_file = $sharedlib_file ; - $lib_file =~ s/\.so/\.a/ ; - } - else { - print "USAGE: make_build [lib ]\n"; - exit; - } -} - -# Get the full path of the current working directory -$wd = cwd(); -if ($ENV{TRICK_HOME} eq "") { - print "TRICK_HOME is not set... cannot continue\n" ; - exit (1) -} - -# If this is a /src, /include, /xml, /io_src, /catalog, or /object_* -# directory, then start make_build in the ../ directory. -if ( $wd =~ /\/include/ and $wd !~ /\/sim_services\// ) { - - $wd = dirname($wd); - -} elsif ( $wd =~ /\/src/ or $wd =~ /\/xml/ or $wd =~ /\/io_src/ - or $wd =~ /\/catalog/ or $wd =~ /\/object_/ ) { - - $wd = dirname($wd); -} - -# Let user know what's going on. -print "Processing $wd\n"; -print "Building Makefile...\n"; - -# Open the file "Makefile" -my ($all_lines) = do { local $/; }; -open MAKEFILE , ">Makefile"; - -$date = `date` ; -chomp $date ; - -my ($trick_ver, $trick_thread) = get_trick_version() ; -my ($trick_major , $trick_minor ) ; -($trick_major , $trick_minor ) = $trick_ver =~ /(\d+)\.([^\.]+)/ ; - -#$trick_ver = `trick_version -f` ; -#chomp $trick_ver ; - -$all_lines =~ s/DATE/$date/ ; -$all_lines =~ s/REPLACE_TRICK_MAJOR/$trick_major/g ; -$all_lines =~ s/REPLACE_TRICK_MINOR/$trick_minor/g ; -$all_lines =~ s/REPLACE_TRICK_THREAD/$trick_thread/g ; -$all_lines =~ s/LIB_FILE/$lib_file/ ; -$all_lines =~ s/SHARED_LIB_FILE/$sharedlib_file/ ; -print MAKEFILE $all_lines ; - -close MAKEFILE ; - -# If this directory has a '/src' directory, create a Makefile for -# /src as well. -if ( -e "$wd/src" ) { - - # Open the file "src/Makefile" - open MAKEFILE , ">src/Makefile"; - - print MAKEFILE "# Go up to parent directory and run make from there\ -default:\ -\tcd .. ; make\ -ICG:\ -\tcd .. ; make ICG\ -depend:\ -\tcd .. ; make depend\ -io_clean:\ -\tcd .. ; make io_clean\ -catalog_clean:\ -\tcd .. ; make catalog_clean\ -clean:\ -\tcd .. ; make clean\ -real_clean:\ -\tcd .. ; make real_clean" ; - - close MAKEFILE ; - -} - -print "Adding file dependencies in Makefile...\n" ; -system "make depend"; -print "make_build complete\n" ; - -__END__ -############################################################################# -# -# This make file was automatically generated by: -# -# /user2/lin/trick_dev/03/bin/make_build -# -# Trick ver: REPLACE_TRICK_MAJOR.REPLACE_TRICK_MINOR-REPLACE_TRICK_THREAD -# -# Date: DATE -# -############################################################################# -# -# To get a desription of the arguments accepted by this makefile, -# type 'make help' -# -############################################################################# - - -############################################################################# -## DIRECTORY DEFINITIONS ## -############################################################################# - -ifeq ($(wildcard src),src) -SRC_DIR := src/ -CD_CMD := cd src ; -UP_DIR := ../ -else -SRC_DIR := -CD_CMD := -UP_DIR := -endif - -PWD = $(shell pwd) - -IO_SRC_DIR = io_src/ -OBJ_DIR = lib_${TRICK_HOST_CPU} -LIB = LIB_FILE -SHARED_LIB = SHARED_LIB_FILE - -ifndef TRICK_CC - TRICK_CC = cc -endif - -ifndef TRICK_CPPC - TRICK_CPPC = c++ -endif - -ifndef TRICK_FC - TRICK_FC = f90 -endif - -TRICK_CFLAGS += -I${TRICK_HOME}/trick_source -I../include -fPIC -ifdef TRICK_CXXFLAGS - TRICK_CXXFLAGS += -DTRICK_VER=REPLACE_TRICK_MAJOR -DTRICK_MINOR=REPLACE_TRICK_MINOR -I${TRICK_HOME}/trick_source -I../include -fPIC -else - TRICK_CXXFLAGS = ${TRICK_CFLAGS} -DTRICK_VER=REPLACE_TRICK_MAJOR -DTRICK_MINOR=REPLACE_TRICK_MINOR -I${TRICK_HOME}/trick_source -I../include -fPIC -endif -TRICK_FTNFLAGS += -I${TRICK_HOME}/trick_source -I../include - -ifeq ($(TRICK_HOST_TYPE), Linux) - MAKEDEP_CPP_INC = -Iinclude -I/usr/include/g++-3 - TRICK_CFLAGS += -I/usr/X11R6/include -endif - -ifeq ($(TRICK_HOST_TYPE), QNX) - MAKEDEP_CPP_INC = -Iinclude - TRICK_EXEC_LINK_LIBS += -lm -lsocket -endif - -ifeq ($(TRICK_HOST_TYPE), LynxOS) - TRICK_CFLAGS += -mthreads - TRICK_CXXFLAGS += -mthreads -endif - -ifeq ($(TRICK_HOST_TYPE), Darwin) - MAKEDEP_CPP_INC = -Iinclude -I/usr/include/gcc/darwin/3.1/g++-v3 \ - -I/usr/include/gcc/darwin/3.1/g++-v3/ppc-darwin \ - -I/usr/include/gcc/darwin/default/g++-v3/backward \ - -I/usr/include/gcc/darwin/3.1 - TRICK_RANLIB = /usr/bin/ranlib - TRICK_CFLAGS += -I/usr/X11R6/include -I/usr/local/include -endif - -ifeq ($(TRICK_HOST_TYPE), SunOS_5.6_plus) - # These are specific to our gcc 2.95 installation in /opt/sfw - MAKEDEP_CPP_INC = -Iinclude -I/opt/sfw/include/g++-3 \ - -I/opt/sfw/sparc-sun-solaris2.8/include \ - -I/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/include -endif - -ifeq ($(TRICK_HOST_TYPE), IRIX_6.x) - MAKEDEP_CPP_INC = -Iinclude -I/usr/include/CC -endif - -ifeq ($(TRICK_HOST_TYPE), Interix) - TRICK_CFLAGS += -D_ALL_SOURCE - TRICK_CXXFLAGS += -D_ALL_SOURCE - TRICK_EXEC_LINK_LIBS += -lm -endif - - -############################################################################# -## UTILITY DEFINITIONS ## -############################################################################# -SHELL = /bin/sh -AWK = awk -SED = sed -LEX = /usr/bin/flex -YACC = /usr/bin/bison -PERL = /usr/bin/perl -CD = cd -MV = mv -RM = rm - -# -# Make information -# -MAKEFILE = $(PWD)/Makefile -DEPFILE = $(PWD)/Makefile_deps -DEPTEMPFILE = Makefile_temp_depends - -############################################################################# -## FILE NAME DEFINITIONS ## -############################################################################# - -L_SRC = $(wildcard $(SRC_DIR)*.l) -L_OUT = $(subst .l,.clex,$(L_SRC)) - -Y_SRC = $(wildcard $(SRC_DIR)*.y) -Y_OUT = $(subst .y,.c,$(Y_SRC)) -Y_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .y,.o,$(Y_SRC)))) - -C_SRC = $(wildcard $(SRC_DIR)*.c) -C_OBJS = $(filter-out $(Y_OBJS), $(addprefix $(OBJ_DIR)/,$(notdir $(subst .c,.o,$(C_SRC))))) - -CPP_C_SRC = $(wildcard $(SRC_DIR)*.C) -CPP_CC_SRC = $(wildcard $(SRC_DIR)*.cc) -CPP_CPP_SRC = $(wildcard $(SRC_DIR)*.cpp) -CPP_CXX_SRC = $(wildcard $(SRC_DIR)*.cxx) -CPP_CPLUS_SRC = $(wildcard $(SRC_DIR)*.c++) -CPP_SRC = $(CPP_C_SRC) $(CPP_CC_SRC) $(CPP_CPP_SRC) $(CPP_CXX_SRC) $(CPP_CPLUS_SRC) -CPP_C_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .C,.o,$(CPP_C_SRC)))) -CPP_CC_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .cc,.o,$(CPP_CC_SRC)))) -CPP_CPP_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .cpp,.o,$(CPP_CPP_SRC)))) -CPP_CXX_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .cxx,.o,$(CPP_CXX_SRC)))) -CPP_CPLUS_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .c++,.o,$(CPP_CPLUS_SRC)))) -CPP_OBJS = $(CPP_C_OBJS) $(CPP_CC_OBJS) $(CPP_CPP_OBJS) $(CPP_CXX_OBJS) $(CPP_CPLUS_OBJS) - -F_SRC = $(wildcard $(SRC_DIR)*.f) -F_OBJS = $(addprefix $(OBJ_DIR)/,$(notdir $(subst .f,.o,$(F_SRC)))) - -IO_C_SRC = $(wildcard $(IO_SRC_DIR)*.c) -IO_C_OBJS =$(subst io_src,$(OBJ_DIR),$(subst .c,.o,$(IO_C_SRC))) - -IO_CPP_SRC = $(wildcard $(IO_SRC_DIR)*.cpp) -IO_CPP_OBJS =$(subst io_src,$(OBJ_DIR),$(subst .cpp,.o,$(IO_CPP_SRC))) - -IO_SRC = $(IO_C_SRC) $(IO_CPP_SRC) -IO_OBJS = $(IO_C_OBJS) $(IO_CPP_OBJS) - -OBJECT_FILES = $(IO_OBJS) $(Y_OBJS) $(C_OBJS) $(CPP_OBJS) $(F_OBJS) - -############################################################################# -## MODEL TARGETS ## -############################################################################# - -ifneq ($(LIB),"") -default: objects $(LIB) $(SHARED_LIB) -else -default: objects -endif - -trick: objects - -object_dir: $(OBJ_DIR) - -objects: y_objects c_objects cpp_objects f_objects h_objects - @ echo "$(CURDIR) object files up to date" - -c_objects: $(OBJ_DIR) $(C_OBJS) - -cpp_objects: $(OBJ_DIR) $(CPP_OBJS) - -f_objects: $(OBJ_DIR) $(F_OBJS) - -h_objects: $(OBJ_DIR) $(IO_OBJS) - -y_objects: $(OBJ_DIR) $(L_OUT) $(Y_OUT) $(Y_OBJS) - -$(LIB) : $(OBJECT_FILES) - ar cr $(LIB) $? - @ if [ "${TRICK_RANLIB}" != "" ] ; then \ - echo ${TRICK_RANLIB} $(LIB) ; \ - ${TRICK_RANLIB} $(LIB) ; \ - fi - -$(SHARED_LIB) : $(OBJECT_FILES) - gcc -shared -o $(SHARED_LIB) $(OBJECT_FILES) - -$(OBJ_DIR): - @ mkdir -p $(OBJ_DIR) - @ echo "Created $(OBJ_DIR)" - -# -# IO_OBJS -# - -$(IO_C_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.c - $(TRICK_CC) $(TRICK_CFLAGS) -c $< -o $@ - -$(IO_CPP_OBJS): $(OBJ_DIR)/%.o : $(IO_SRC_DIR)%.cpp - $(TRICK_CPPC) $(TRICK_CXXFLAGS) -c $< -o $@ - -# -# -# C_OBJS -# - -$(C_OBJS): $(OBJ_DIR)/%.o : $(SRC_DIR)%.c - $(CD_CMD) $(TRICK_CC) $(TRICK_CFLAGS) -c ${> $(DEPTEMPFILE) - @ $(PERL) ${TRICK_HOME}/bin/depend_cp $(DEPTEMPFILE) > $(DEPFILE) - @ $(RM) $(DEPTEMPFILE) - @ echo "Created dependency file $(DEPFILE)" - -io_clean: - $(RM) -rf io_src - -real_clean: clean io_clean catalog_clean - $(RM) -rf xml *~ *.bak core - @ echo "Directory is really clean!" - -clean: -ifeq ($(notdir $(LIB)),libtrick.a) - $(RM) -rf $(OBJ_DIR) $(L_OUT) $(Y_OUT) -else - $(RM) -rf $(LIB) $(OBJ_DIR) $(L_OUT) $(Y_OUT) -endif - @ echo "Object files successfully removed" - -catalog_clean : - @ echo y | catalog -dp $(CURDIR) - @ echo "Catalog purged" - -catalog : catalog_clean $(IO_SRC) - MIS - @ echo "$(CURDIR) Catalog rebuilt" - -help : - @ echo -e "\n\ -Source Directory Make Options:\n\ - make - Compiles are source files\n\ -\n\ - make ICG - Deletes the io_src directory and runs ICG\n\ - on all pertinent *.h files\n\ -\n\ - make catalog - Deletes the local catalog and builds a new one\n\ -\n\ - make depend - Adds file dependencies to Makefile\n\ -\n\ - make io_clean - Deletes the local io_src directory\n\ -\n\ - make catalog_clean - Deletes the local catalog directory\n\ -\n\ - make clean - Deletes the object code directory\n\ -\n\ - make real_clean - Deletes xml/, io_src/,\n\ - and lib_${TRICK_HOST_CPU}/ directories\n" - -ifeq ($(wildcard makefile_overrides),makefile_overrides) -include makefile_overrides -endif - --include Makefile_deps - diff --git a/libexec/trick/make_makefile_src b/libexec/trick/make_makefile_src index 711be2da..3efa4395 100755 --- a/libexec/trick/make_makefile_src +++ b/libexec/trick/make_makefile_src @@ -31,7 +31,7 @@ sub read_lib_deps($@) { chomp @all_lines ; read_lib_deps($indent + 1 , @all_lines) ; } else { - print "Getting Dependencies for " , " " x $indent, "$l\n" ; + print "Tracing " , " " x $indent, "$l\n" ; if ( -e $l ) { my $deps_changed ; my @resolved_files ; @@ -41,7 +41,7 @@ sub read_lib_deps($@) { } } } elsif ( exists $ENV{TRICK_VERBOSE_BUILD} ) { - print "Previously processed " , " " x $indent, "$l\n" ; + print "Skipping Previously processed file \"$l\"\n" ; } } } @@ -213,52 +213,45 @@ chomp $trick_ver ; open MAKEFILE , ">build/Makefile_src" or return ; -print MAKEFILE "\ -############################################################################# +print MAKEFILE +"################################################################################ # Makefile: # This is a makefile for maintaining the # '$wd' -# simulation directory. This make file was automatically generated by trick-CP +# simulation directory. This makefile 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 +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 = \$(CURDIR)/T_main_\${TRICK_HOST_CPU}.exe + TRICK_HOST_CPU := \$(shell \$(TRICK_HOME)/bin/trick-gte TRICK_HOST_CPU)_test + S_MAIN = T_main_\${TRICK_HOST_CPU}.exe endif -LIB_DIR = \$(CURDIR)/build/lib +LIB_DIR = build/lib -ifdef TRICK_VERBOSE_BUILD -PRINT_COMPILE = -PRINT_INC_LINK = -PRINT_EXE_LINK = -PRINT_S_DEF_DEPS = -ECHO_CMD = -else -PRINT_COMPILE = \@echo \"Compiling  \$(subst \$(CURDIR)/build,build,\$<)\" -PRINT_INC_LINK = \@echo \"Partial link \$(subst \$(CURDIR)/build,build,\${build/Makefile_src_deps" or die "Could not open build/Makefile_src_deps" ; -print MAKEFILEDEPS "\$(CURDIR)/build/Makefile_src :" ; +print MAKEFILEDEPS "build/Makefile_src:" ; print MAKEFILEDEPS map {"\\\n $_"} (sort keys %non_lib_processed_files) ; print MAKEFILEDEPS "\n" ; close MAKEFILEDEPS ; diff --git a/libexec/trick/make_makefile_swig b/libexec/trick/make_makefile_swig index 3537bfa9..7c89f936 100755 --- a/libexec/trick/make_makefile_swig +++ b/libexec/trick/make_makefile_swig @@ -141,8 +141,8 @@ sub make_swig_makefile() { my $s_source_full_path = abs_path("S_source.hh") ; my $s_source_md5 = md5_hex($s_source_full_path) ; - $swig_sim_dir = "\$(CURDIR)/trick" ; - $swig_src_dir = "\$(CURDIR)/build" ; + $swig_sim_dir = "trick" ; + $swig_src_dir = "build" ; foreach $n (@files_to_process) { # check to see if the parent directory of each file is writable. @@ -168,27 +168,20 @@ sub make_swig_makefile() { 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 + print MAKEFILE "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 -Wno-deprecated-register + SWIG_CFLAGS += -Wno-self-assign -Wno-sometimes-uninitialized -Wno-deprecated-register endif -ifdef TRICK_VERBOSE_BUILD -PRINT_SWIG = -PRINT_COMPILE_SWIG = -PRINT_SWIG_INC_LINK = -#PRINT_CONVERT_SWIG = -else -PRINT_SWIG = \@echo \"Swig  \$(subst \$(CURDIR)/build,build,\$<)\" -PRINT_COMPILE_SWIG = \@echo \"Compiling  \$(subst .o,.cpp,\$(subst \$(CURDIR)/build,build,\$@))\" -PRINT_SWIG_INC_LINK = \@echo \"Partial link swig objects\" -#PRINT_CONVERT_SWIG = \@echo \"Running convert_swig\" +ifndef TRICK_VERBOSE_BUILD + PRINT_SWIG = \$(info \$(call COLOR,SWIGing) \$<) + PRINT_COMPILE_SWIG = \$(info \$(call COLOR,Compiling) \$<) + PRINT_SWIG_INC_LINK = \$(info \$(call COLOR,Linking) SWIG objects) endif SWIG_MODULE_OBJECTS = \$(LIB_DIR)/swig_python.o +OBJECTS += \$(SWIG_MODULE_OBJECTS) +LINK_OBJECTS += \$(SWIG_MODULE_OBJECTS) SWIG_PY_OBJECTS =" ; @@ -197,14 +190,21 @@ SWIG_PY_OBJECTS =" ; my ($swig_f) = $f ; $swig_object_dir = dirname($f) ; ($swig_file_only) = ($f =~ /([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx|\.hpp)$/) ; - print MAKEFILE" \\\n \$(CURDIR)/build$swig_object_dir/py_${swig_file_only}.o" ; + print MAKEFILE" \\\n 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 "\\\n $swig_src_dir/init_swig_modules.o" ; + print MAKEFILE "\\\n $swig_src_dir/py_top.o\n" ; - print MAKEFILE "\$(SWIG_PY_OBJECTS) : | trick\n" ; - print MAKEFILE "trick :\n" ; - print MAKEFILE "\t\@mkdir \$\@\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 +" ; my %swig_dirs ; my %python_modules ; @@ -237,16 +237,11 @@ SWIG_PY_OBJECTS =" ; $swig_f =~ s/([^\/]*)(?:\.h|\.H|\.hh|\.h\+\+|\.hxx|\.hpp)$/$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_f = "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_SYSTEM_CXXFLAGS) \$(SWIG_CFLAGS) -c $swig_dir/py_${swig_file_only}.cpp -o \$@\n\n" ; print LINK_PY_OBJS "$link_py_obj\n" ; $ii++ ; @@ -263,48 +258,30 @@ SWIG_PY_OBJECTS =" ; my $wd = abs_path(cwd()) ; print MAKEFILE " -\$(SWIG_MODULE_OBJECTS) : TRICK_SYSTEM_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls - -OBJECTS += \$(SWIG_MODULE_OBJECTS) -LINK_OBJECTS += \$(SWIG_MODULE_OBJECTS) \$(S_MAIN): \$(SWIG_MODULE_OBJECTS) -\$(SWIG_MODULE_OBJECTS) : \$(SWIG_PY_OBJECTS) | \$(LIB_DIR) +\$(SWIG_MODULE_OBJECTS): TRICK_SYSTEM_CXXFLAGS += -Wno-unused-parameter -Wno-redundant-decls +\$(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" ; +S_main: \$(TRICK_FIXED_PYTHON) - 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) \$(TRICK_SYSTEM_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ; +\$(TRICK_FIXED_PYTHON): $swig_sim_dir/\% : \${TRICK_HOME}/share/trick/swig/\% +\t\$(ECHO_CMD)/bin/cp -f \$< \$@ - 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) \$(TRICK_SYSTEM_CXXFLAGS) \$(SWIG_CFLAGS) -c \$< -o \$@\n\n" ; +py_%.cpp: %.i +\t\$(PRINT_SWIG) +\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 \$@ \$< - 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" ; +%.o: %.cpp +\t\$(PRINT_COMPILE_SWIG) +\t\$(ECHO_CMD)\$(TRICK_CPPC) \$(TRICK_CXXFLAGS) \$(TRICK_SYSTEM_CXXFLAGS) \$(SWIG_CFLAGS) -c -o \$@ \$< - print MAKEFILE "\$(TRICK_FIXED_PYTHON) : $swig_sim_dir/\% : \${TRICK_HOME}/share/trick/swig/\%\n" ; - print MAKEFILE "\t\$(ECHO_CMD)/bin/cp -f \$< \$@\n\n" ; +# 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" ; - foreach (keys %swig_dirs) { - print MAKEFILE "$_:\n" ; - print MAKEFILE "\tmkdir -p $_\n\n" ; - } - - print MAKEFILE "\n" ; close MAKEFILE ; close LINK_PY_OBJS ; @@ -491,9 +468,9 @@ LINK_OBJECTS += \$(SWIG_MODULE_OBJECTS) } open MAKEFILECONV , ">build/Makefile_convert_swig" or return ; - print MAKEFILECONV "\$(CURDIR)/build/convert_swig_last_run :" ; + print MAKEFILECONV "build/convert_swig_last_run:" ; foreach $f ( @files_to_process ) { - print MAKEFILECONV " \\\n $f" ; + print MAKEFILECONV " \\\n $f" ; } close MAKEFILECONV ; diff --git a/libexec/trick/pm/get_lib_deps.pm b/libexec/trick/pm/get_lib_deps.pm index 72da0686..229d66c6 100644 --- a/libexec/trick/pm/get_lib_deps.pm +++ b/libexec/trick/pm/get_lib_deps.pm @@ -145,10 +145,11 @@ sub get_lib_deps ($$) { $l .= "o" ; } if ( $found == 0 ) { + print STDERR "Warning $source_file_name\n " ; if ( $l =~ /^(sim_services)/ or $l =~ /^(er7_utils)/ ) { - print STDERR "Warning: Not necessary to list $1 dependencies $l\n" ; + print STDERR "It is not necessary to list dependencies found in $1: \"$l\"\n" ; } else { - print STDERR "Warning: Could not find dependency $l\n" ; + print STDERR "Could not find dependency \"$l\"\n" ; } } } diff --git a/libexec/trick/pm/parse_s_define.pm b/libexec/trick/pm/parse_s_define.pm index 4ac8f9d1..f318f804 100644 --- a/libexec/trick/pm/parse_s_define.pm +++ b/libexec/trick/pm/parse_s_define.pm @@ -524,7 +524,8 @@ sub handle_sim_class ($$$$) { $template_args =~ s/class|typename//g ; $template_args =~ s/\s//g ; - trick_print($$sim_ref{fh}, "Processing sim_class $class_name\n" , "normal white" , $$sim_ref{args}{v}); + trick_print($$sim_ref{fh}, "Processing " , "normal_blue" , $$sim_ref{args}{v}); + trick_print($$sim_ref{fh}, "$class_name\n" , "normal_white" , $$sim_ref{args}{v}); # grab the entire contents of the class out of the S_define file. ($class_contents, $$file_contents) = extract_bracketed($$file_contents,"{}"); @@ -814,9 +815,11 @@ sub handle_line_tag($$) { trick_print($$sim_ref{fh},"Line: $s\n", "debug_yellow", $$sim_ref{args}{v}) ; if ( $file_name !~ /^\&1 | tee build/MAKE_out ; exit $${PIPESTATUS[0]} build: mkdir $@ -debug : all -debug : TRICK_CPFLAGS += --debug +debug: all +debug: TRICK_CPFLAGS += --debug -${TRICK_LIB_DIR}/libtrick.a: - @echo "Cannot find $@. Please build Trick for this platfrom" +$(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 $(CURDIR)/build/S_define.lib_deps : S_define | build +S_source.hh build/S_define.lib_deps: S_define | build $(PRINT_CP) $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/configuration_processor $(TRICK_CPFLAGS) # Automatic and manual ICG rules -$(CURDIR)/build/Makefile_io_src : | S_source.hh +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 @@ -63,30 +53,30 @@ force_ICG: $(ECHO_CMD)${TRICK_HOME}/bin/trick-ICG -f -m ${TRICK_ICGFLAGS} ${TRICK_CXXFLAGS} ${TRICK_SYSTEM_CXXFLAGS} S_source.hh # Build dependencies for recreating S_source.hh -$(CURDIR)/build/S_define.deps : +build/S_define.deps: | build $(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 # Create makefile for source code -$(CURDIR)/build/Makefile_src: | $(CURDIR)/build/Makefile_io_src $(CURDIR)/build/S_define.lib_deps +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 -$(CURDIR)/build/Makefile_swig : | $(CURDIR)/build/Makefile_io_src +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 -$(CURDIR)/build/convert_swig_last_run : | $(CURDIR)/build/Makefile_swig +build/convert_swig_last_run: | build/Makefile_swig $(PRINT_CONVERT_SWIG) $(ECHO_CMD)${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS} - @ touch $@ + @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 + @touch build/convert_swig_last_run # prints the value of a makefile variable, example invocation "make print-TRICK_CXXFLAGS" # This rule is used by trick-config @@ -95,6 +85,7 @@ print-%: # 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 > $@ @@ -103,7 +94,7 @@ sie: @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 "\ + @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\ @@ -121,12 +112,11 @@ clean: tidy -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 apocalypse: clean - @echo "I love the smell of napalm in the morning" + $(info I love the smell of napalm in the morning) CLEAN_RULES_DEFINED = 1 @@ -135,4 +125,3 @@ CLEAN_RULES_DEFINED = 1 -include build/Makefile_ICG -include build/Makefile_convert_swig -include build/Makefile_src_deps - diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 4b317fb1..f7dae28e 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -98,8 +98,8 @@ TRICK_EXT_LIB_DIRS := # .NOTPARALLEL (a file-wide flag), significantly slowing the build process. $(TRICKIFY_LIB_NAME): $(OBJECTS) | $(dir $(TRICKIFY_LIB_NAME)) + $(info $(call COLOR,Linking) $@) @ar rsc $@ $? - $(info Built $@) # $(OBJECTS) is meant to contain all of the py_* and io_* object file names. We can't construct # those until we run ICG and convert_swig. But we can't run the rules for ICG and convert_swig @@ -159,9 +159,9 @@ $(dir $(TRICKIFY_LIB_NAME)) $(TRICKIFY_PYTHON_DIR): @mkdir -p $@ py_%.cpp: %.i | $(TRICKIFY_PYTHON_DIR) - $(info SWIGing $<) + $(info $(call COLOR,SWIGing) $<) @$(SWIG) $(TRICK_INCLUDE) $(TRICK_DEFINES) $(TRICK_VERSIONS) -c++ -python -includeall -ignoremissing -w201,362,389,451 -outdir $(TRICKIFY_PYTHON_DIR) -o $@ $< %.o: %.cpp - $(info Compiling $<) + $(info $(call COLOR,Compiling) $<) @$(TRICK_CC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) $(PYTHON_INCLUDES) -std=c++11 -Wno-invalid-offsetof -Wno-shadow -Wno-unused-but-set-variable -c -o $@ $< diff --git a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp index f055f5d1..5ca07774 100644 --- a/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp +++ b/trick_source/codegen/Interface_Code_Gen/FieldDescription.cpp @@ -242,16 +242,16 @@ void FieldDescription::parseComment(std::string comment) { std::string new_units = map_trick_units_to_udunits(units) ; if ( units.compare(new_units) ) { if ( ! units_truth_is_scary ) { - std::cout << "\033[33mUnits converted from [" << units << "] to [" << new_units << "] " - << file_name << ":" << line_no << "\033[0m" << std::endl ; + std::cout << bold(color(WARNING, "Warning ") + file_name + ":" + std::to_string(line_no)) << std::endl + << " Units converted from " << quote(units) << " to " << quote(new_units) << std::endl; } units = new_units ; } ut_unit * test_units = ut_parse(u_system, units.c_str() , UT_ASCII) ; if ( test_units == NULL ) { // If the units are invalid write an error message and change the units to "1" - std::cout << "\033[31mBad units specification [" << units << "] " << file_name << ":" << line_no - << "\033[0m" << std::endl ; + std::cout << bold(color(WARNING, "Warning ") + file_name + ":" + std::to_string(line_no)) << std::endl + << " Invalid units specification. Changing " << quote(units) << " to " << quote("1") << std::endl; units = "1" ; } else { // If the units are valid, free the memory allocated by new_units. @@ -262,8 +262,8 @@ void FieldDescription::parseComment(std::string comment) { } if ( io == 4 ) { - std::cout << "\033[33mWarning: " << file_name << ": line " << line_no << ": " << - "\"--\" is not a valid trick_io value. Setting to *io (3)\033[0m" << std::endl ; + std::cout << bold(color(WARNING, "Warning ") + file_name + ":" + std::to_string(line_no)) << std::endl + << " -- is not a valid trick_io value. Setting to *io" << std::endl ; io = 3 ; } diff --git a/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp b/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp index 0bae7bd3..1268f25c 100644 --- a/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp +++ b/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.cpp @@ -160,7 +160,7 @@ void HeaderSearchDirs::AddICGExcludeDirs () { icg_exclude_dirs.push_back(std::string(resolved_path)); } } else { - std::cout << "Cannot find TRICK_ICG_EXCLUDE directory " << item << std::endl ; + std::cout << bold(color(WARNING, "Warning")) << " Cannot find TRICK_ICG_EXCLUDE directory " << quote(bold(item)) << std::endl ; } } } @@ -188,7 +188,7 @@ void HeaderSearchDirs::AddExcludeDirs () { exclude_dirs.push_back(std::string(resolved_path)); } } else { - std::cout << "Cannot find TRICK_ICG_EXCLUDE directory " << item << std::endl ; + std::cout << bold(color(WARNING, "Warning")) << " Cannot find TRICK_EXCLUDE directory " << quote(bold(item)) << std::endl ; } } } @@ -210,7 +210,7 @@ void HeaderSearchDirs::AddExtLibDirs () { if ( resolved_path ) { ext_lib_dirs.push_back(std::string(resolved_path) + std::string("/")); } else { - std::cout << "Cannot find TRICK_EXT_LIB_DIRS directory " << item << std::endl ; + std::cout << bold(color(WARNING, "Warning")) << " Cannot find TRICK_EXT_LIB_DIRS directory " << quote(bold(item)) << std::endl ; } } } @@ -232,7 +232,7 @@ void HeaderSearchDirs::AddICGNoCommentDirs () { if ( resolved_path ) { icg_nocomment_dirs.push_back(std::string(resolved_path) + std::string("/")); } else { - std::cout << "Cannot find TRICK_ICG_NOCOMMENT directory " << item << std::endl ; + std::cout << bold(color(WARNING, "Warning")) << " Cannot find TRICK_ICG_NOCOMMENT directory " << quote(bold(item)) << std::endl ; } } } @@ -267,7 +267,7 @@ void HeaderSearchDirs::addSearchDirs ( std::vector & include_dirs ) ApplyHeaderSearchOptions() ; } -bool HeaderSearchDirs::isPathInUserDir (std::string in_dir ) { +bool HeaderSearchDirs::isPathInUserDir (const std::string& in_dir ) { clang::HeaderSearch::search_dir_iterator sdi ; for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ ) { @@ -285,7 +285,7 @@ bool HeaderSearchDirs::isPathInUserDir (std::string in_dir ) { return true ; } -bool HeaderSearchDirs::isPathInUserOrTrickDir (std::string in_dir ) { +bool HeaderSearchDirs::isPathInUserOrTrickDir (const std::string& in_dir ) { clang::HeaderSearch::search_dir_iterator sdi ; for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ ) { @@ -297,7 +297,7 @@ bool HeaderSearchDirs::isPathInUserOrTrickDir (std::string in_dir ) { return true ; } -bool HeaderSearchDirs::isPathInExclude (std::string in_dir ) { +bool HeaderSearchDirs::isPathInExclude (const std::string& in_dir ) { std::vector::iterator vit ; for ( vit = exclude_dirs.begin() ; vit != exclude_dirs.end() ; vit++ ) { @@ -309,7 +309,7 @@ bool HeaderSearchDirs::isPathInExclude (std::string in_dir ) { return false ; } -bool HeaderSearchDirs::isPathInICGExclude (std::string in_dir ) { +bool HeaderSearchDirs::isPathInICGExclude (const std::string& in_dir ) { std::vector::iterator vit ; for ( vit = icg_exclude_dirs.begin() ; vit != icg_exclude_dirs.end() ; vit++ ) { @@ -321,7 +321,7 @@ bool HeaderSearchDirs::isPathInICGExclude (std::string in_dir ) { return false ; } -bool HeaderSearchDirs::isPathInExtLib (std::string in_dir ) { +bool HeaderSearchDirs::isPathInExtLib (const std::string& in_dir ) { std::vector::iterator vit ; for ( vit = ext_lib_dirs.begin() ; vit != ext_lib_dirs.end() ; vit++ ) { @@ -333,7 +333,7 @@ bool HeaderSearchDirs::isPathInExtLib (std::string in_dir ) { return false ; } -bool HeaderSearchDirs::isPathInICGNoComment (std::string in_file ) { +bool HeaderSearchDirs::isPathInICGNoComment (const std::string& in_file ) { char * resolved_path = almostRealPath(in_file.c_str() ) ; @@ -357,7 +357,7 @@ bool HeaderSearchDirs::isPathInICGNoComment (std::string in_file ) { return false ; } -std::string HeaderSearchDirs::getPathInExclude (std::string in_dir ) { +std::string HeaderSearchDirs::getPathInExclude (const std::string& in_dir ) { std::vector::iterator vit ; for ( vit = exclude_dirs.begin() ; vit != exclude_dirs.end() ; vit++ ) { @@ -369,7 +369,7 @@ std::string HeaderSearchDirs::getPathInExclude (std::string in_dir ) { return std::string() ; } -std::string HeaderSearchDirs::getPathInICGExclude (std::string in_dir ) { +std::string HeaderSearchDirs::getPathInICGExclude (const std::string& in_dir ) { std::vector::iterator vit ; for ( vit = icg_exclude_dirs.begin() ; vit != icg_exclude_dirs.end() ; vit++ ) { @@ -381,7 +381,7 @@ std::string HeaderSearchDirs::getPathInICGExclude (std::string in_dir ) { return std::string() ; } -std::string HeaderSearchDirs::getPathInExtLib (std::string in_dir ) { +std::string HeaderSearchDirs::getPathInExtLib (const std::string& in_dir ) { std::vector::iterator vit ; for ( vit = ext_lib_dirs.begin() ; vit != ext_lib_dirs.end() ; vit++ ) { diff --git a/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.hh b/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.hh index 2472dea2..9209d5ee 100644 --- a/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.hh +++ b/trick_source/codegen/Interface_Code_Gen/HeaderSearchDirs.hh @@ -39,59 +39,59 @@ class HeaderSearchDirs { @param path = directory path to be checked @return true = path is in user directory, false = path is not in a user dir. */ - bool isPathInUserDir (std::string path) ; + bool isPathInUserDir (const std::string& path) ; /** Returns true if the path argument is in a user model or Trick directory @param path = directory path to be checked @return true = path is in user directory, false = path is not in a user dir. */ - bool isPathInUserOrTrickDir (std::string path) ; + bool isPathInUserOrTrickDir (const std::string& path) ; /** Returns true if directory is a subdirectory of an excluded directory listed in the TRICK_EXCLUDE environment variable. @param path = directory path to be checked @return true = path is in a system directory, false = not in system directory. */ - bool isPathInExclude (std::string path) ; + bool isPathInExclude (const std::string& path) ; /** Returns true if directory is a subdirectory of an excluded directory listed in the TRICK_ICG_EXCLUDE environment variable. @param path = directory path to be checked @return true = path is in a system directory, false = not in system directory. */ - bool isPathInICGExclude (std::string path) ; + bool isPathInICGExclude (const std::string& path) ; /** Returns true if directory is a subdirectory of an external library directory listed in the TRICK_EXT_LIB_DIRS environment variable. @param path = directory path to be checked @return true = path is in a system directory, false = not in system directory. */ - bool isPathInExtLib (std::string path) ; + bool isPathInExtLib (const std::string& path) ; /** Returns true if directory is a subdirectory of a no comment directory in the TRICK_ICG_NOCOMMENT environment variable. @param path = directory path to be checked @return true = path is in a system directory, false = not in system directory. */ - bool isPathInICGNoComment (std::string path) ; + bool isPathInICGNoComment (const std::string& path) ; /** Returns the TRICK_EXCLUDE directory that contains the path argument. @param path = path to be checked @return string from TRICK_EXCLUDE that contains the path. */ - std::string getPathInExclude (std::string path) ; + std::string getPathInExclude (const std::string& path) ; /** Returns the TRICK_ICG_EXCLUDE directory that contains the path argument. @param path = path to be checked @return string from TRICK_ICG_EXCLUDE that contains the path. */ - std::string getPathInICGExclude (std::string path) ; + std::string getPathInICGExclude (const std::string& path) ; /** Returns the TRICK_EXT_LIB_DIRS directory that contains the path argument. @param path = path to be checked @return string from TRICK_ICG_EXCLUDE that contains the path. */ - std::string getPathInExtLib (std::string path) ; + std::string getPathInExtLib (const std::string& path) ; /** Add all #defines from the command line and built in default predefines @param defines = a list of all -D arguments on the command line. diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 84f2a369..ecd9955d 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -78,45 +78,33 @@ static void _mkdir(const char *dir) { if(*p == '/') { *p = 0; if ( stat( tmp , &buf ) != 0 ) { - if ( mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO ) != 0 ) { - std::cout << "Unable to create " << tmp << " for writing." << std::endl ; + int returnValue = mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO); + if (returnValue) { + std::cout << bold(color(ERROR, "Error")) << " Unable to create " << quote(bold(tmp)) << " for writing: " << strerror(errno) << std::endl; return ; } } *p = '/'; } if ( stat( tmp , &buf ) != 0 ) { - if ( mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO) ) { - std::cout << "Unable to create " << tmp << " for writing." << std::endl ; + int returnValue = mkdir(tmp, S_IRWXU | S_IRWXG | S_IRWXO); + if (returnValue) { + std::cout << bold(color(ERROR, "Error")) << " Unable to create " << quote(bold(tmp)) << " for writing: " << strerror(errno) << std::endl; return ; } } } -bool PrintAttributes::doesIODirectoryExist(std::string io_file_name) { - // dirname alters the string so make a temporary copy of io_file_name - char * temp_name = strdup(io_file_name.c_str()) ; - char * dir_name ; - struct stat buf ; - bool ret = true ; - - dir_name = dirname((char *)temp_name) ; - - _mkdir(dir_name) ; - free(temp_name) ; - return ret ; -} - // this is a subset of tests on the header file to determine if this file is not excluded for any reason. bool PrintAttributes::isFileIncluded(std::string header_file_name) { // several tests require the real path of the header file. - char * rp = almostRealPath(header_file_name.c_str()) ; + char * realPath = almostRealPath(header_file_name.c_str()) ; - if ( rp != NULL ) { + if ( realPath != NULL ) { // Only include user directories (not system dirs like /usr/include) - if ( hsd.isPathInUserDir(rp) ) { + if ( hsd.isPathInUserDir(realPath) ) { // Don't process files in excluded directories - if ( (hsd.isPathInExclude(rp) == false) and (hsd.isPathInICGExclude(rp) == false) ) { + if ( (hsd.isPathInExclude(realPath) == false) and (hsd.isPathInICGExclude(realPath) == 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) ) { @@ -128,84 +116,109 @@ bool PrintAttributes::isFileIncluded(std::string header_file_name) { return false ; } -bool PrintAttributes::openIOFile(std::string header_file_name) { - // There are a lot of conditions to be met in order to open an io_src file. We store - // the file names we have visited so we don't have to retest the file each time a new - // class/enum is processed. - 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.isPathInExclude(rp) == false ) { - 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) ) { - // Don't process files in external library directories - if ( hsd.isPathInExtLib(rp) == false ) { - std::string io_file_name = createIOFileName(std::string(rp)) ; - all_io_files[header_file_name] = io_file_name ; - // Does the io_src directory exist or can we successfully mkdir it? - if ( doesIODirectoryExist(io_file_name) ) { - // Is the io_src file out of date or does not exist yet - if ( isIOFileOutOfDate(rp, io_file_name) ) { - // All conditions have been met. Store the io_src file name in out_of_date_io_files. - out_of_date_io_files[header_file_name] = io_file_name ; - free(rp) ; - /* This is the first time we are visiting the file, - open the file and write header information */ - outfile.open(out_of_date_io_files[header_file_name].c_str()) ; - printer->printIOHeader(outfile, header_file_name) ; - if ( ! cs.hasTrickHeader(header_file_name) ) { - std::cout << "No Trick header comment found in " << header_file_name << "" << std::endl ; - } - std::cout << "Writing " << out_of_date_io_files[header_file_name] << "" << std::endl ; - // Get all of the ignored types from this file. - ignored_types[header_file_name] = cs.getIgnoreTypes(header_file_name) ; - return true ; - } - } else { - std::cout << "ICG skipping " << rp << " (cannot create io_src dir)" << std::endl ; - } - } else { - std::cout << "ICG skipping " << rp << " (ext lib dir " << - hsd.getPathInExtLib(rp) << ")" << std::endl ; - ext_lib_io_files.insert(header_file_name) ; - } - } else { - std::cout << "ICG skipping " << rp << " (ICG No found)" << std::endl ; - icg_no_files.push_back(rp) ; - } - } else { - std::cout << "ICG skipping " << rp << " (ICG exclude " << - hsd.getPathInICGExclude(rp) << ")" << std::endl ; - } - } else { - std::cout << "ICG skipping " << rp << " (exclude " << - hsd.getPathInExclude(rp) << ")" << std::endl ; - } - } else { - //std::cout << "ICG skipping " << rp << " (not in user path) " << std::endl ; - } - free(rp) ; - } else { - std::cout << "ICG could not resolve realpath of " << header_file_name << "" << std::endl ; - } - } else { - /* We have visited this file before, if there is a valid io_file name, append to the io_file */ - if ( out_of_date_io_files.find(header_file_name) != out_of_date_io_files.end() ) { - outfile.open(out_of_date_io_files[header_file_name].c_str(), std::fstream::app) ; +bool PrintAttributes::openIOFile(const std::string& header_file_name) { + /** + * There are a lot of conditions to be met in order to open an IO file. We store the headers + * we have visited so we don't have to retest the them each time a new class/enum is processed. + */ + if (visited_files.find(header_file_name) != visited_files.end()) { + // We have visited this header before. If there is a valid name, append to the existing IO file. + if (out_of_date_io_files.find(header_file_name) != out_of_date_io_files.end()) { + outfile.open(out_of_date_io_files[header_file_name].c_str(), std::fstream::app); return true ; } + return false; } - // No io_file was opened. - return false ; + + // add it to the list of visited files + visited_files.insert(header_file_name) ; + + // several tests require the real path of the header file + char* temp = almostRealPath(header_file_name.c_str()); + + if (!temp) { + std::cout << bold(color(WARNING, "Warning")) << " ICG could not resolve realpath of " << quote(bold(header_file_name)) << std::endl; + return false; + } + + const std::string realPath = std::string(temp); + const bool verboseBuild = getenv("TRICK_VERBOSE_BUILD"); + + /** + * Exclude files: + * - in system directories + * - in TRICK_EXCLUDE directories + * - in TRICK_ICG_EXCLUDE directories + * - in TRICK_EXT_LIB_DIRS directories + * - whose Trick header comments preclude ICG + */ + const std::string skipping = color(INFO, "Skipping "); + + if (!hsd.isPathInUserDir(realPath)) { + return false; + } + + if (hsd.isPathInExclude(realPath)) { + if (verboseBuild) { + std::cout << skipping << "TRICK_EXCLUDE: " << underline(realPath, hsd.getPathInExclude(realPath).size()) << std::endl; + } + return false; + } + + if (hsd.isPathInICGExclude(realPath)) { + if (verboseBuild) { + std::cout << skipping << "TRICK_ICG_EXCLUDE: " << underline(realPath, hsd.getPathInICGExclude(realPath).size()) << std::endl; + } + return false; + } + + if (hsd.isPathInExtLib(realPath)) { + if (verboseBuild) { + std::cout << skipping << "TRICK_EXT_LIB_DIRS: " << underline(realPath, hsd.getPathInExtLib(realPath).size()) << std::endl; + } + ext_lib_io_files.insert(header_file_name) ; + return false; + } + + if (cs.hasICGNo(header_file_name)) { + if (verboseBuild) { + std::cout << skipping << "ICG: (NO): " << realPath << std::endl; + } + icg_no_files.push_back(realPath); + return false; + } + + // map the header to its IO file + const std::string io_file_name = createIOFileName(realPath) ; + all_io_files[header_file_name] = io_file_name ; + + // make the parent directories + char* name = strdup(io_file_name.c_str()); + _mkdir(dirname(name)); + free(name); + + // no further processing is required if it's not out of date + if (!isIOFileOutOfDate(realPath, io_file_name)) { + std::cout << "Not out of date: " << io_file_name << std::endl; + return false; + } + + // add it to the map of out of date IO files + out_of_date_io_files[header_file_name] = io_file_name ; + + // write header information + std::cout << color(INFO, "Writing ") << out_of_date_io_files[header_file_name] << std::endl; + outfile.open(out_of_date_io_files[header_file_name].c_str()); + printer->printIOHeader(outfile, header_file_name); + if (!cs.hasTrickHeader(header_file_name) ) { + std::cout << bold(color(WARNING, "Warning ") + header_file_name) << std::endl + << " No Trick header comment found" << std::endl; + } + + // get the ignored types from this header + ignored_types[header_file_name] = cs.getIgnoreTypes(header_file_name) ; + + return true ; } /** Determines the io_file_name based on the given header file name */ @@ -280,12 +293,12 @@ void PrintAttributes::printClass( ClassValues * cv ) { } // if we are successful in opening the map file - char * rp = almostRealPath(cv->getFileName().c_str()) ; - if ( rp != NULL ) { - if ( isFileIncluded( cv->getFileName()) or hsd.isPathInExtLib(rp)) { + char * realPath = almostRealPath(cv->getFileName().c_str()) ; + if ( realPath != NULL ) { + if ( isFileIncluded( cv->getFileName()) or hsd.isPathInExtLib(realPath)) { printer->printClassMap(class_map_outfile, cv) ; } - free(rp) ; + free(realPath) ; } } } @@ -341,7 +354,7 @@ void PrintAttributes::createMapFiles() { if ( stat( map_dir.c_str() , &buf ) != 0 ) { if ( mkdir( map_dir.c_str() , 0755 ) != 0 ) { // dir does not exist and cannot make the directory. - std::cout << "\033[31mUnable to create " << map_dir.c_str() << " for writing.\033[00m" << std::endl ; + std::cout << bold(color(WARNING, "Warning")) << " Unable to create " << quote(bold(map_dir)) << " for writing" << std::endl ; } } @@ -381,27 +394,27 @@ void PrintAttributes::addEmptyFiles() { 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 ) { + char * realPath = almostRealPath(header_file_name.c_str()) ; + if ( realPath != NULL ) { // Only include user directories (not system dirs like /usr/include) - if ( hsd.isPathInUserDir(rp) ) { - if ( hsd.isPathInExclude(rp) == false ) { - if ( hsd.isPathInICGExclude(rp) == false ) { + if ( hsd.isPathInUserDir(realPath) ) { + if ( hsd.isPathInExclude(realPath) == false ) { + if ( hsd.isPathInICGExclude(realPath) == 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) ) { // Don't process files in excluded directories - if ( hsd.isPathInExtLib(rp) == false ) { - std::string io_file_name = createIOFileName(std::string(rp)) ; - empty_header_files.insert(rp) ; + if ( hsd.isPathInExtLib(realPath) == false ) { + std::string io_file_name = createIOFileName(std::string(realPath)) ; + empty_header_files.insert(realPath) ; } else { - ext_lib_io_files.insert(rp) ; + ext_lib_io_files.insert(realPath) ; } } } } } - free(rp) ; + free(realPath) ; } } } @@ -421,59 +434,50 @@ void PrintAttributes::printIOMakefile() { return ; } - std::cout << "Creating/updating io_src Makefile" << std::endl ; + std::cout << color(INFO, "Writing") << " Makefile_io_src" << std::endl ; + makefile_io_src.open("build/Makefile_io_src") ; - - makefile_io_src << "TRICK_SYSTEM_CXXFLAGS += -std=c++11" << std::endl ; - makefile_io_src << "TRICK_SYSTEM_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_SYSTEM_CXXFLAGS += -Wno-unused-local-typedefs" << std::endl ; - makefile_io_src << " TRICK_SYSTEM_CXXFLAGS += -Wno-unused-but-set-variable" << 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 \"Running ICG\"" << std::endl ; - makefile_io_src << "PRINT_IO_COMPILE = @echo \"Compiling  $(subst $(CURDIR)/build,build,$<)\"" << std::endl ; - makefile_io_src << "PRINT_IO_INC_LINK = @echo \"Partial link io objects\"" << std::endl ; - makefile_io_src << "endif" << std::endl ; - makefile_io_src << std::endl ; - - makefile_io_src << "IO_OBJ_FILES =" ; + makefile_io_src << "TRICK_SYSTEM_CXXFLAGS += \\" << std::endl + << " -std=c++11 \\" << std::endl + << " -Wno-invalid-offsetof \\" << std::endl + << " -Wno-old-style-cast \\" << std::endl + << " -Wno-write-strings \\" << std::endl + << " -Wno-unused-variable" << std::endl + << std::endl + << "ifeq ($(IS_CC_CLANG), 0)" << std::endl + << " TRICK_SYSTEM_CXXFLAGS += -Wno-unused-local-typedefs -Wno-unused-but-set-variable" << std::endl + << "endif" << std::endl + << std::endl + << "ifndef TRICK_VERBOSE_BUILD" << std::endl + << " PRINT_IO_INC_LINK = @echo \"$(call COLOR,Linking) IO objects\"" << std::endl + << "endif" << std::endl + << std::endl + << "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_io_src << " \\\n $(CURDIR)/" << (*mit).second.substr(0,found) << ".o" ; } - makefile_io_src << " \\\n $(CURDIR)/build/class_map.o" << std::endl ; - makefile_io_src << std::endl ; - - 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_SYSTEM_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 << "LINK_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 << " \\\n $(CURDIR)/build/class_map.o" << std::endl + << std::endl + << "$(IO_OBJ_FILES): \%.o : \%.cpp" << std::endl + << "\t$(PRINT_IO_COMPILE)" << std::endl + << "\t$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) -MMD -MP -c $< -o $@" << std::endl + << std::endl + << "-include $(IO_OBJ_FILES:.o=.d)" << std::endl + << std::endl + << "OBJECTS += $(LIB_DIR)/io_src.o" << std::endl + << "LINK_OBJECTS += $(LIB_DIR)/io_src.o" << std::endl + << std::endl + << "$(S_MAIN): $(LIB_DIR)/io_src.o" << std::endl + << std::endl + << "$(LIB_DIR)/io_src.o : $(IO_OBJ_FILES) | $(LIB_DIR)" << std::endl + << "\t$(PRINT_IO_INC_LINK)" << std::endl + << "\t$(ECHO_CMD)$(LD) $(LD_PARTIAL) -o $@ $(LD_FILELIST)build/link_io_objs" << std::endl + << std::endl ; makefile_io_src.close() ; @@ -489,25 +493,27 @@ void PrintAttributes::printIOMakefile() { makefile_ICG.open("build/Makefile_ICG") ; link_io_objs.open("build/link_io_objs") ; ICG_processed.open("build/ICG_processed") ; - makefile_ICG << "$(CURDIR)/build/Makefile_io_src :" ; + + makefile_ICG << "build/Makefile_io_src:" ; for ( mit = all_io_files.begin() ; mit != all_io_files.end() ; mit++ ) { - makefile_ICG << "\\\n " << (*mit).first ; + 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 ; } + makefile_ICG.close() ; + // 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() ; + ICG_processed.close() ; + link_io_objs << "build/class_map.o" << std::endl ; link_io_objs.close() ; - ICG_processed.close() ; ext_lib.open("build/ICG_ext_lib") ; for ( sit = ext_lib_io_files.begin() ; sit != ext_lib_io_files.end() ; sit++ ) { diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh index 3970f889..b85b5a78 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.hh @@ -89,11 +89,10 @@ class PrintAttributes { /** We are specifying an output directory for all files */ std::string output_dir ; - bool openIOFile(std::string header_file_name) ; + bool openIOFile(const std::string& header_file_name) ; bool isFileIncluded(std::string header_file_name) ; 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() ; diff --git a/trick_source/codegen/Interface_Code_Gen/Utilities.cpp b/trick_source/codegen/Interface_Code_Gen/Utilities.cpp index 6c8184bd..2e35ad70 100644 --- a/trick_source/codegen/Interface_Code_Gen/Utilities.cpp +++ b/trick_source/codegen/Interface_Code_Gen/Utilities.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "Utilities.hh" @@ -92,3 +93,31 @@ char * almostRealPath( const char * in_path ) { return final_path ; } +static const std::string escapeSequence = "["; +static const std::string defaultForegroundColorSequence = escapeSequence + "39m"; +static const std::string boldSequence = escapeSequence + "1m"; +static const std::string noBoldSequence = escapeSequence + "21m"; +static const std::string underlineSequence = escapeSequence + "4m"; +static const std::string noUnderlineSequence = escapeSequence + "24m"; + +std::string color(const Color& color, const std::string& text) { + std::ostringstream oss; + oss << escapeSequence << color << "m" << text << defaultForegroundColorSequence; + return oss.str(); +} + +std::string bold(const std::string& text) { + return boldSequence + text + noBoldSequence; +} + +std::string underline(const std::string& text) { + return underlineSequence + text + noUnderlineSequence; +} + +std::string underline(const std::string& text, unsigned length) { + return underline(text.substr(0, length)) + text.substr(length); +} + +std::string quote(const std::string& text) { + return "\"" + text + "\""; +} diff --git a/trick_source/codegen/Interface_Code_Gen/Utilities.hh b/trick_source/codegen/Interface_Code_Gen/Utilities.hh index dfabb3d6..22ad6403 100644 --- a/trick_source/codegen/Interface_Code_Gen/Utilities.hh +++ b/trick_source/codegen/Interface_Code_Gen/Utilities.hh @@ -7,10 +7,22 @@ #include "clang/Basic/SourceLocation.h" #include "HeaderSearchDirs.hh" +enum Color { + ERROR = 31, + WARNING = 33, + INFO = 34 +}; + std::string trim( const std::string& str, const std::string& whitespace = " \t\n\r" ) ; bool isInUserCode( clang::CompilerInstance & ci , clang::SourceLocation sl , HeaderSearchDirs & hsd ) ; bool isInUserOrTrickCode( clang::CompilerInstance & ci , clang::SourceLocation sl , HeaderSearchDirs & hsd ) ; std::string getFileName( clang::CompilerInstance & ci , clang::SourceLocation sl , HeaderSearchDirs & hsd ) ; char * almostRealPath( const char * in_path ) ; +std::string color(const Color& color, const std::string& text); +std::string bold(const std::string& text); +std::string underline(const std::string& text); +std::string underline(const std::string& text, unsigned length); +std::string quote(const std::string& text); + #endif diff --git a/trick_source/sim_services/Sie/Sie.cpp b/trick_source/sim_services/Sie/Sie.cpp index 21557128..f50261b2 100644 --- a/trick_source/sim_services/Sie/Sie.cpp +++ b/trick_source/sim_services/Sie/Sie.cpp @@ -37,9 +37,8 @@ int Trick::Sie::process_sim_args() { /* If main is being invoked by the configuration processor (cp) to generate the sie resource file... */ /* Generate the sie resource file */ sie_print_xml(); - std::cout << "Created S_sie.resource file." << std::endl ; - // Silently exit the sim without printing the termination message + // Silently exit the sim without printing the termination message exit(0) ; } }