From 9b7e18af15969f494703dfd3d096c22c4aea25b9 Mon Sep 17 00:00:00 2001 From: Derek Bankieris Date: Wed, 2 Jun 2021 13:56:21 -0500 Subject: [PATCH] Create link_list files for Trickification ICG and make_makefile_swig create py_link_list and io_link_list files listing the files to be linked during sim builds. Trickified projects require slightly altered lists. Fixes #1155 --- libexec/trick/make_makefile_swig | 3 +++ share/trick/makefiles/trickify.mk | 17 +++++++++-------- .../Interface_Code_Gen/PrintAttributes.cpp | 6 ++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libexec/trick/make_makefile_swig b/libexec/trick/make_makefile_swig index a5fa5647..c182f248 100755 --- a/libexec/trick/make_makefile_swig +++ b/libexec/trick/make_makefile_swig @@ -139,6 +139,7 @@ sub write_makefile_swig() { open MAKEFILE , ">build/Makefile_swig" or die "Could not open build/Makefile_swig for writing" ; open PY_LINK_LIST , ">build/py_link_list" or die "Could not open build/py_link_list for writing" ; + open TRICKIFY_PY_LINK_LIST , ">build/trickify_py_link_list" or die "Could not open build/trickify_py_link_list for writing" ; print PY_LINK_LIST "build/init_swig_modules.o\n" ; print PY_LINK_LIST "build/top.o\n" ; @@ -180,6 +181,7 @@ SWIG_I =" ; (my $swig_file = $file) =~ s/(\.[^.]*)?$/_py/ ; print MAKEFILE " \\\n build$swig_file.i" ; print PY_LINK_LIST "build$swig_file.o\n" ; + print TRICKIFY_PY_LINK_LIST "build$swig_file.o\n" ; } print MAKEFILE " @@ -234,6 +236,7 @@ all: $swig_sim_zip close MAKEFILE ; close PY_LINK_LIST ; + close TRICKIFY_PY_LINK_LIST ; open SWIGLIB , ">build/S_library_swig" or die "Could not open build/S_library_swig for writing" ; foreach my $file ( @files_to_process ) { diff --git a/share/trick/makefiles/trickify.mk b/share/trick/makefiles/trickify.mk index b7416fea..9f2ab8c9 100644 --- a/share/trick/makefiles/trickify.mk +++ b/share/trick/makefiles/trickify.mk @@ -103,11 +103,12 @@ TRICKIFY_PYTHON_DIR := $(abspath $(TRICKIFY_PYTHON_DIR)) include $(dir $(lastword $(MAKEFILE_LIST)))Makefile.common BUILD_DIR := $(dir $(MAKE_OUT)) +PY_LINK_LIST := $(BUILD_DIR)trickify_py_link_list +IO_LINK_LIST := $(BUILD_DIR)trickify_io_link_list +LINK_LISTS := @$(IO_LINK_LIST) @$(PY_LINK_LIST) ifneq ($(wildcard $(BUILD_DIR)),) - SWIG_OBJECTS := $(shell cat $(BUILD_DIR)S_library_swig) - SWIG_OBJECTS := $(addprefix $(BUILD_DIR),$(addsuffix _py.o,$(basename $(SWIG_OBJECTS)))) - IO_OBJECTS := $(shell find $(BUILD_DIR) -name "io_*.cpp") - IO_OBJECTS := $(IO_OBJECTS:.cpp=.o) + SWIG_OBJECTS := $(shell cat $(PY_LINK_LIST)) + IO_OBJECTS := $(shell cat $(IO_LINK_LIST)) endif TRICK_CFLAGS += $(TRICKIFY_CXX_FLAGS) @@ -122,11 +123,11 @@ all: $(TRICKIFY_OBJECT_NAME) $(TRICKIFY_PYTHON_DIR) $(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME)) $(info $(call COLOR,Linking) $@) ifeq ($(TRICKIFY_BUILD_TYPE),PLO) - $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $^) + $(call ECHO_AND_LOG,$(LD) $(LD_PARTIAL) -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),SHARED) - $(call ECHO_AND_LOG,$(TRICK_CXX) -shared -o $@ $^) + $(call ECHO_AND_LOG,$(TRICK_CXX) -shared -o $@ $(LINK_LISTS)) else ifeq ($(TRICKIFY_BUILD_TYPE),STATIC) - $(call ECHO_AND_LOG,ar rcs $@ $^) + $(call ECHO_AND_LOG,ar rcs $@ $(LINK_LISTS)) endif $(dir $(TRICKIFY_OBJECT_NAME)) $(BUILD_DIR) $(dir $(TRICKIFY_PYTHON_DIR)) .trick: @@ -153,7 +154,7 @@ $(SWIG_OBJECTS:.o=.d): ; -include $(SWIG_OBJECTS:.o=.d) define create_convert_swig_rule -$(BUILD_DIR)/%_py.i: /%.$1 +$(shell basename $(BUILD_DIR))/%_py.i: /%.$1 $$(call ECHO_AND_LOG,${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig $${TRICK_CONVERT_SWIG_FLAGS} $$<) endef diff --git a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp index 51a6f9fc..1e1fc79d 100644 --- a/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp +++ b/trick_source/codegen/Interface_Code_Gen/PrintAttributes.cpp @@ -421,6 +421,7 @@ void PrintAttributes::printIOMakefile() { std::ofstream makefile_io_src ; std::ofstream makefile_ICG ; std::ofstream io_link_list ; + std::ofstream trickify_io_link_list ; std::ofstream ICG_processed ; std::ofstream ext_lib ; @@ -476,10 +477,13 @@ void PrintAttributes::printIOMakefile() { io_link_list lists all io object files to be linked. + trickify_io_link_list lists all io object files to be linked for a Trickified project. + ICG_process lists all header files to be used by SWIG. */ makefile_ICG.open("build/Makefile_ICG") ; io_link_list.open("build/io_link_list") ; + trickify_io_link_list.open("build/trickify_io_link_list") ; ICG_processed.open("build/ICG_processed") ; makefile_ICG << "build/Makefile_io_src:" ; @@ -488,6 +492,7 @@ void PrintAttributes::printIOMakefile() { size_t found ; found = (*mit).second.find_last_of(".") ; io_link_list << (*mit).second.substr(0,found) << ".o" << std::endl ; + trickify_io_link_list << (*mit).second.substr(0,found) << ".o" << std::endl ; ICG_processed << (*mit).first << std::endl ; } makefile_ICG.close() ; @@ -500,6 +505,7 @@ void PrintAttributes::printIOMakefile() { io_link_list << "build/class_map.o" << std::endl ; io_link_list.close() ; + trickify_io_link_list.close() ; ext_lib.open("build/ICG_ext_lib") ; for ( auto& file : ext_lib_io_files ) {