mirror of
https://github.com/nasa/trick.git
synced 2025-06-01 07:00:58 +00:00
parent
86add82e35
commit
dd2a17e034
@ -80,10 +80,10 @@ TRICKIFY_PYTHON_DIR ?= python
|
|||||||
TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../../..)
|
TRICK_HOME := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/../../..)
|
||||||
|
|
||||||
ifneq ($(wildcard build),)
|
ifneq ($(wildcard build),)
|
||||||
OBJECTS := $(shell find build -name "*.i")
|
SWIG_OBJECTS := $(shell tail -n +2 build/S_library_swig)
|
||||||
OBJECTS := $(join $(dir $(OBJECTS)),$(patsubst %.i,%.cpp,$(notdir $(OBJECTS))))
|
SWIG_OBJECTS := $(addprefix build,$(addsuffix _py.o,$(basename $(SWIG_OBJECTS))))
|
||||||
OBJECTS += $(shell find build -name "*.cpp")
|
IO_OBJECTS := $(shell find build -name "io_*.cpp")
|
||||||
OBJECTS := $(OBJECTS:.cpp=.o)
|
IO_OBJECTS := $(IO_OBJECTS:.cpp=.o)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(TRICK_HOME)/share/trick/makefiles/Makefile.common
|
include $(TRICK_HOME)/share/trick/makefiles/Makefile.common
|
||||||
@ -107,29 +107,42 @@ TRICK_EXT_LIB_DIRS :=
|
|||||||
# change infrequently. Moreover, the methods for force-linking a library differ
|
# change infrequently. Moreover, the methods for force-linking a library differ
|
||||||
# between Linux and Mac, so obviating the need for it simplifies a Trickified
|
# between Linux and Mac, so obviating the need for it simplifies a Trickified
|
||||||
# project's user-facing makefile.
|
# project's user-facing makefile.
|
||||||
$(TRICKIFY_OBJECT_NAME): $(OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME))
|
$(TRICKIFY_OBJECT_NAME): $(SWIG_OBJECTS) $(IO_OBJECTS) | $(dir $(TRICKIFY_OBJECT_NAME))
|
||||||
$(info $(call COLOR,Linking) $@)
|
$(info $(call COLOR,Linking) $@)
|
||||||
@ld -r -o $@ $^
|
@ld -r -o $@ $^
|
||||||
|
|
||||||
$(dir $(TRICKIFY_OBJECT_NAME)) $(TRICKIFY_PYTHON_DIR):
|
$(dir $(TRICKIFY_OBJECT_NAME)) $(TRICKIFY_PYTHON_DIR):
|
||||||
@mkdir -p $@
|
@mkdir -p $@
|
||||||
|
|
||||||
%.cpp: %.i | $(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 $@ $<
|
||||||
|
|
||||||
|
$(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)
|
||||||
$(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 $@ $<
|
||||||
|
|
||||||
%.o: %.cpp
|
define create_convert_swig_rule
|
||||||
$(info $(call COLOR,Compiling) $<)
|
build/%_py.i: /%.$1
|
||||||
@$(TRICK_CC) $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) $(PYTHON_INCLUDES) -std=c++11 -Wno-invalid-offsetof -Wno-shadow -c -o $@ $<
|
${TRICK_HOME}/$(LIBEXEC)/trick/convert_swig ${TRICK_CONVERT_SWIG_FLAGS} $$<
|
||||||
|
endef
|
||||||
|
|
||||||
# $(OBJECTS) is meant to contain all of the py_* and io_* object file names. We
|
EXTENSIONS := H h hh hxx h++ hpp
|
||||||
# can't construct those until we run ICG and convert_swig. But we can't run the
|
$(foreach EXTENSION,$(EXTENSIONS),$(eval $(call create_convert_swig_rule,$(EXTENSION))))
|
||||||
# rule for ICG and convert_swig before $(OBJECTS) is expanded because it is a
|
|
||||||
# prerequisite of $(TRICKIFY_OBJECT_NAME), and prerequisites are always
|
# SWIG_OBJECTS and IO_OBJECTS are meant to contain all of the *_py and io_*
|
||||||
# immediately expanded. Therefore, when make processes this file (for the first
|
# object file names, respectively, by looking at products of ICG and
|
||||||
# time after a clean), $(OBJECTS) is empty, because the find will be executed
|
# make_makefile_swig. However, we can't run a rule for ICG before those
|
||||||
# before ICG and convert_swig have created any files. What we really want is to
|
# variables are expanded because they are prerequisites of
|
||||||
# run ICG and convert_swig before $(OBJECTS) is expanded.
|
# TRICKIFY_OBJECT_NAME, and prerequisites are immediately expanded.
|
||||||
|
# Therefore, when make processes this file (for the first time after a clean),
|
||||||
|
# the variables are empty because the files from which they are populated have
|
||||||
|
# yet to be created by ICG. What we really want is to run ICG before OBJECTS is
|
||||||
|
# expanded, but only if we need to.
|
||||||
#
|
#
|
||||||
# We can do this by taking advantage of (abusing) make's behavior in the
|
# We can do this by taking advantage of (abusing) make's behavior in the
|
||||||
# presence of included files. When you include another file, make attempts to
|
# presence of included files. When you include another file, make attempts to
|
||||||
@ -137,12 +150,12 @@ $(dir $(TRICKIFY_OBJECT_NAME)) $(TRICKIFY_PYTHON_DIR):
|
|||||||
# slate if any of the included files changed. So we need a rule that:
|
# slate if any of the included files changed. So we need a rule that:
|
||||||
#
|
#
|
||||||
# 1. Executes only if S_source.hh or anything in its include tree changes.
|
# 1. Executes only if S_source.hh or anything in its include tree changes.
|
||||||
# 2. Runs ICG and convert_swig to generate py_* and io_* files.
|
# 2. Runs ICG and make_makefile_swig to generate io_* files and S_library_swig.
|
||||||
# 3. Updates its dependency file.
|
# 3. Updates its dependency file.
|
||||||
#
|
#
|
||||||
# We can then include the dependency file to trigger make to re-execute this
|
# We can then include the dependency file to trigger make to re-execute this
|
||||||
# main makefile if changes were detected, thus updating $(OBJECTS) to the
|
# main makefile if changes were detected, thus updating SWIG_OBJECTS and
|
||||||
# latest results of ICG and convert_swig.
|
# IO_OBJECTS to the latest results of ICG and make_makefile_swig.
|
||||||
#
|
#
|
||||||
# gcc's option to automatically generate dependency information is exactly
|
# gcc's option to automatically generate dependency information is exactly
|
||||||
# what we need. It will produce a file containing a make rule whose
|
# what we need. It will produce a file containing a make rule whose
|
||||||
@ -161,8 +174,7 @@ $(dir $(TRICKIFY_OBJECT_NAME)) $(TRICKIFY_PYTHON_DIR):
|
|||||||
|
|
||||||
$(CURDIR)/build/S_source.d:
|
$(CURDIR)/build/S_source.d:
|
||||||
@$(TRICK_HOME)/bin/trick-ICG $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) $(TRICK_ICGFLAGS) S_source.hh
|
@$(TRICK_HOME)/bin/trick-ICG $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) $(TRICK_ICGFLAGS) S_source.hh
|
||||||
@$(TRICK_HOME)/libexec/trick/make_makefile_swig
|
@$(TRICK_HOME)/$(LIBEXEC)/trick/make_makefile_swig
|
||||||
@$(TRICK_HOME)/libexec/trick/convert_swig
|
|
||||||
@$(TRICK_CC) -MM -MP -MT $@ -MF $@ $(TRICKIFY_CXX_FLAGS) $(CURDIR)/S_source.hh
|
@$(TRICK_CC) -MM -MP -MT $@ -MF $@ $(TRICKIFY_CXX_FLAGS) $(CURDIR)/S_source.hh
|
||||||
|
|
||||||
-include $(CURDIR)/build/S_source.d
|
-include $(CURDIR)/build/S_source.d
|
||||||
|
Loading…
x
Reference in New Issue
Block a user