From 2f43db8e2ef5493be53d05a8ead3eea70ffa7c6c Mon Sep 17 00:00:00 2001 From: Pherring04 Date: Thu, 14 Nov 2024 09:42:09 -0600 Subject: [PATCH] Checkpoint --- bin/trick-ify | 70 +++++++++++++------ share/trick/makefiles/trickify.mk | 10 ++- test/Makefile | 5 ++ .../trickified_project/trickified/Makefile | 1 + .../trickified_project/trickified/S_source.hh | 2 - .../trickified/myproject_vars.mk | 2 +- 6 files changed, 61 insertions(+), 29 deletions(-) delete mode 100644 test/SIM_trickified/trickified_project/trickified/S_source.hh diff --git a/bin/trick-ify b/bin/trick-ify index dfe214bb..f8a7dd20 100755 --- a/bin/trick-ify +++ b/bin/trick-ify @@ -7,7 +7,9 @@ $source_dir = "." ; # Base $header_dir = "." ; # Base path to build source from. Default to working directory $trickify_make_args = "" ; # Arguments to pass into the trickify make $trickify_make_path = "$my_path../share/trick/makefiles/trickify.mk" ; # Path of the trickify make file -$build_s_source = 0 ; # Whether to generate a S_source +$build_s_source = 1 ; # Whether to generate a S_source +$build_trickify_src_list = 1 ; # Whether to generate a trickify_src_list +$build_trickify_obj_list = 1 ; # Whether to generate a trickify_obj_list $full_build = 1 ; # Whether to build only ICG/Swig artifacts or entire source $name = "trickified" ; # Name of the library $build_type = "o" ; # Type of library to be built (o, a , so) @@ -42,9 +44,17 @@ foreach $argnum (0 .. $#ARGV) $header_dir = $ARGV[$argnum + 1] ; $skip_arg = 1 ; } - elsif($arg eq "-R") # Rebuild S_source + elsif($arg eq "-ph") # Preserve S_source.hh { - $build_s_source = 1 ; + $build_s_source = 0 ; + } + elsif($arg eq "-ps") # Preserve trickify_src_list + { + $build_trickify_src_list = 0 ; + } + elsif($arg eq "-po") # Preserve trickify_obj_list + { + $build_trickify_obj_list = 0 ; } elsif($arg eq "-t") # Build trick artifacts only { @@ -101,6 +111,10 @@ foreach $argnum (0 .. $#ARGV) } #Set Environment Variables +if ( $full_build ) +{ + $ENV{'FULL_TRICKIFY_BUILD'} = "1" ; +} $ENV{'TRICKIFY_CXX_FLAGS'} = "-I $source_dir -I $trick_home" . "/include" ; #TODO: Test with multiple dirs passed in at once $ENV{'TRICKIFY_OBJECT_NAME'} = "$name.$build_type" ; $ENV{'TRICKIFY_SOURCE'} = "$source_dir" ; @@ -121,21 +135,28 @@ elsif ( $build_type eq so ) } #Build the S_source.hh -$make_s_source = "python3 $my_path../share/trick/makefiles/build_trickify_S_source_hh.py" ; -print(`$make_s_source`) ; +if ($build_s_source) +{ + print "Building S_source.hh\n" ; + $make_s_source = "python3 $my_path../share/trick/makefiles/build_trickify_S_source_hh.py" ; + print(`$make_s_source`) ; +} #Build source file list, only if trickifying the entire library #TODO: Move build artifacts into build? Maybe? -print "Building trickify_src_list\n" ; -if($full_build) +if ($build_trickify_src_list) { - $make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ; - print(`$make_src_list`) ; -} -else -{ - open (fh, ">", "$work_dir"."trickify_src_list") ; - close (fh) ; + print "Building trickify_src_list\n" ; + if($full_build) + { + $make_src_list = "python3 $my_path../share/trick/makefiles/build_trickify_src_list.py" ; + print(`$make_src_list`) ; + } + else + { + open (fh, ">", "$work_dir"."trickify_src_list") ; + close (fh) ; + } } #Build array of source files @@ -149,18 +170,21 @@ while (my $line = <$fh>) close (fh) ; #Build object files from source file list -print "Building object files\n" ; -foreach $src (@src_files) +if ($build_trickify_src_list) { - $file = $src ; - $file =~ s/\Q.cpp\E$// ; - $file =~ s/\Q.c$\E$// ; - $cmd = "g++ -c $src -o $file.o" ; - if($debug) + print "Building object files\n" ; + foreach $src (@src_files) { - print "Building obj file: $cmd\n" ; + $file = $src ; + $file =~ s/\Q.cpp\E$// ; + $file =~ s/\Q.c$\E$// ; + $cmd = "g++ -c $src -o $file.o" ; + if($debug) + { + print "Building obj file: $cmd\n" ; + } + print(`$cmd`) ; } - print(`$cmd`) ; } #Build object file list, only if trickifying the entire library diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index 0ee94643..74c9fdcb 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -108,10 +108,14 @@ BUILD_DIR := $(dir $(MAKE_OUT)) PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list OBJ_LINK_LIST := trickify_obj_list -LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) +ifdef FULL_TRICKIFY_BUILD + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) @$(OBJ_LINK_LIST) +else + LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) +endif ifneq ($(wildcard $(BUILD_DIR)),) - SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) - IO_OBJECTS := $(shell cat $(IO_LINK_LIST)) + SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) + IO_OBJECTS := $(shell cat $(IO_LINK_LIST)) endif TRICK_CFLAGS += $(TRICKIFY_CXX_FLAGS) diff --git a/test/Makefile b/test/Makefile index 2ea36ea3..5f15e1e6 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,10 +6,15 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common SIM_DIRECTORIES = $(wildcard SIM_*) UNIT_TEST_RESULTS = $(addprefix $(TRICK_HOME)/trick_test/, $(addsuffix .xml, $(SIM_DIRECTORIES))) +# The auto-generated makefile for each test does not know to call other makefiles the user may have included. +# User generated clean calls must be directly called here +# Otherwise build artifacts may not be cleaned and give misleading test results clean_trickify: for i in $(SIM_DIRECTORIES) ; do \ if [ -f "$$i/trickified_project/trickified/"[Mm]"akefile" ] ; then \ $(MAKE) -C $$i/trickified_project/trickified/ clean ; \ + elif [ -f "$$i/models/trickified/"[Mm]"akefile" ] ; then \ + $(MAKE) -C $$i/models/trickified/ clean ; \ fi \ done diff --git a/test/SIM_trickified/trickified_project/trickified/Makefile b/test/SIM_trickified/trickified_project/trickified/Makefile index 5fd890ce..5f8dd292 100644 --- a/test/SIM_trickified/trickified_project/trickified/Makefile +++ b/test/SIM_trickified/trickified_project/trickified/Makefile @@ -10,3 +10,4 @@ clean: @rm -rf $(MYPROJECT_TRICK) @rm -rf trickify_obj_list @rm -rf trickify_src_list + @rm -rf S_source.hh diff --git a/test/SIM_trickified/trickified_project/trickified/S_source.hh b/test/SIM_trickified/trickified_project/trickified/S_source.hh deleted file mode 100644 index a410df75..00000000 --- a/test/SIM_trickified/trickified_project/trickified/S_source.hh +++ /dev/null @@ -1,2 +0,0 @@ -#include "/home/patrick/trick/test/SIM_trickified/trickified_project/trickified/../include/Foo.hh" -#include "/home/patrick/trick/test/SIM_trickified/trickified_project/trickified/../include/Bar.hh" diff --git a/test/SIM_trickified/trickified_project/trickified/myproject_vars.mk b/test/SIM_trickified/trickified_project/trickified/myproject_vars.mk index 25e3ae8a..390f15a1 100644 --- a/test/SIM_trickified/trickified_project/trickified/myproject_vars.mk +++ b/test/SIM_trickified/trickified_project/trickified/myproject_vars.mk @@ -12,7 +12,7 @@ TRICK_CFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) TRICK_CXXFLAGS += $(MYPROJECT_INCLUDE) $(MYPROJECT_SOURCE) export TRICKIFY_BUILD_TYPE := STATIC -export TRICKIFY_OBJECT_NAME := trickified_myproject.a +export TRICKIFY_OBJECT_NAME := trickified_myproject.o MYPROJECT_TRICK := $(MYPROJECT_HOME)/trickified/$(TRICKIFY_OBJECT_NAME) # Tell Trick the headers and source at this location are part of a