Automatically generate dependencies with SWIG

Like gcc, swig supports all those -M options. Use them to automatically
manage *_py.cpp dependencies.
Add dependency generation to trickify.mk as well.
This commit is contained in:
Derek Bankieris 2017-03-14 13:38:09 -05:00
parent 22d0fe9f23
commit 2e4c3286a3
3 changed files with 17 additions and 5 deletions

View File

@ -226,7 +226,11 @@ SWIG_SRC = \$(subst .i,.cpp,\$(SWIG_I)) $swig_src_dir/top.cpp
\$(SWIG_SRC) : %.cpp: %.i | \$(SWIG_I)
\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 -MMD -MP -outdir trick -o \$@ \$<
\$(SWIG_OBJECTS:.o=.d): ;
-include \$(SWIG_OBJECTS:.o=.d)
# SWIG_OBJECTS =================================================================

View File

@ -116,15 +116,23 @@ $(dir $(TRICKIFY_OBJECT_NAME)) $(TRICKIFY_PYTHON_DIR):
$(IO_OBJECTS): %.o: %.cpp
$(info $(call COLOR,Compiling) $<)
@$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) -std=c++11 -Wno-invalid-offsetof -c -o $@ $<
@$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) -std=c++11 -Wno-invalid-offsetof -MMD -MP -c -o $@ $<
$(IO_OBJECTS:.o=.d): %.d: ;
-include $(IO_OBJECTS:.o=.d)
$(SWIG_OBJECTS): %.o: %.cpp
$(info $(call COLOR,Compiling) $<)
@$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) $(PYTHON_INCLUDES) -Wno-unused-parameter -Wno-shadow -c -o $@ $<
$(SWIG_OBJECTS:.o=.cpp): %.cpp: %.i | $(TRICKIFY_PYTHON_DIR)
$(SWIG_OBJECTS:.o=.cpp): %.cpp: %.i %.d | $(TRICKIFY_PYTHON_DIR)
$(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 -w201,303,325,362,389,401,451 -MMD -MP -outdir $(TRICKIFY_PYTHON_DIR) -o $@ $<
$(SWIG_OBJECTS:.o=.d): ;
-include $(SWIG_OBJECTS:.o=.d)
define create_convert_swig_rule
build/%_py.i: /%.$1

View File

@ -458,7 +458,7 @@ void PrintAttributes::printIOMakefile() {
<< "\t$(PRINT_COMPILE)" << std::endl
<< "\t$(ECHO_CMD)$(TRICK_CPPC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) -MMD -MP -c -o $@ $<" << std::endl
<< std::endl
<< "$(IO_OBJECTS:.o=.d): \%.d: ;" << std::endl
<< "$(IO_OBJECTS:.o=.d): ;" << std::endl
<< std::endl
<< "-include $(IO_OBJECTS:.o=.d)" << std::endl
<< std::endl